r=dougt, sr=dmose
OS/2 only - remove config/os2 from the tree
This commit is contained in:
mkaply%us.ibm.com 2003-01-21 00:05:39 +00:00
Родитель ba067c962e
Коммит fe73ee5935
6 изменённых файлов: 9 добавлений и 604 удалений

Просмотреть файл

@ -78,19 +78,11 @@ ifeq ($(OS_ARCH), Linux)
DEFINES += -D_BSD_SOURCE
endif
ifeq ($(MOZ_OS2_TOOLS),VACPP)
LOCAL_INCLUDES += -I$(srcdir)/os2
HSRCS += dirent.h
endif
ifeq ($(OS_CONFIG),SunOS4.1)
NSPR_CFLAGS += -I$(srcdir)/../nsprpub/pr/include/md
endif
HEADERS = nsBuildID.h $(DEPTH)/mozilla-config.h
ifeq ($(MOZ_OS2_TOOLS),VACPP)
HEADERS += $(srcdir)/os2/dirent.h
endif
export:: $(TARGETS) $(HEADERS)
$(INSTALL) $(IFLAGS1) $(HEADERS) $(DIST)/include

Просмотреть файл

@ -1,348 +0,0 @@
#ifdef OS2
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
/*#ifndef __EMX__
#include <libx.h>
#endif */
#define INCL_DOSFILEMGR
#define INCL_DOSERRORS
#include <os2.h>
#if OS2 >= 2
# define FFBUF FILEFINDBUF3
# define Word ULONG
/*
* LS20 recommends a request count of 100, but according to the
* APAR text it does not lead to missing files, just to funny
* numbers of returned entries.
*
* LS30 HPFS386 requires a count greater than 2, or some files
* are missing (those starting with a character less that '.').
*
* Novell looses entries which overflow the buffer. In previous
* versions of dirent2, this could have lead to missing files
* when the average length of 100 directory entries was 40 bytes
* or more (quite unlikely for files on a Novell server).
*
* Conclusion: Make sure that the entries all fit into the buffer
* and that the buffer is large enough for more than 2 entries
* (each entry is at most 300 bytes long). And ignore the LS20
* effect.
*/
# define Count 25
# define BufSz (25 * (sizeof(FILEFINDBUF3)+1))
#else
# define FFBUF FILEFINDBUF
# define Word USHORT
# define BufSz 1024
# define Count 3
#endif
#if defined(__IBMC__) || defined(__IBMCPP__)
#define error(rc) _doserrno = rc, errno = EOS2ERR
#elif defined(MICROSOFT)
#define error(rc) _doserrno = rc, errno = 255
#else
#define error(rc) errno = 255
#endif
struct _dirdescr {
HDIR handle; /* DosFindFirst handle */
char fstype; /* filesystem type */
Word count; /* valid entries in <ffbuf> */
long number; /* absolute number of next entry */
int index; /* relative number of next entry */
FFBUF * next; /* pointer to next entry */
char name[MAXPATHLEN+3]; /* directory name */
unsigned attrmask; /* attribute mask for seekdir */
struct dirent entry; /* buffer for directory entry */
BYTE ffbuf[BufSz];
};
/*
* Return first char of filesystem type, or 0 if unknown.
*/
static char
getFSType(const char *path)
{
static char cache[1+26];
char drive[3], info[512];
Word unit, infolen;
char r;
if (isalpha(path[0]) && path[1] == ':') {
unit = toupper(path[0]) - '@';
path += 2;
} else {
ULONG driveMap;
#if OS2 >= 2
if (DosQueryCurrentDisk(&unit, &driveMap))
#else
if (DosQCurDisk(&unit, &driveMap))
#endif
return 0;
}
if ((path[0] == '\\' || path[0] == '/')
&& (path[1] == '\\' || path[1] == '/'))
return 0;
if (cache [unit])
return cache [unit];
drive[0] = '@' + unit;
drive[1] = ':';
drive[2] = '\0';
infolen = sizeof info;
#if OS2 >= 2
if (DosQueryFSAttach(drive, 0, FSAIL_QUERYNAME, (PVOID)info, &infolen))
return 0;
if (infolen >= sizeof(FSQBUFFER2)) {
FSQBUFFER2 *p = (FSQBUFFER2 *)info;
r = p->szFSDName[p->cbName];
} else
#else
if (DosQFSAttach((PSZ)drive, 0, FSAIL_QUERYNAME, (PVOID)info, &infolen, 0))
return 0;
if (infolen >= 9) {
char *p = info + sizeof(USHORT);
p += sizeof(USHORT) + *(USHORT *)p + 1 + sizeof(USHORT);
r = *p;
} else
#endif
r = 0;
return cache [unit] = r;
}
char *
abs_path(const char *name, char *buffer, int len)
{
char buf[4];
if (isalpha(name[0]) && name[1] == ':' && name[2] == '\0') {
buf[0] = name[0];
buf[1] = name[1];
buf[2] = '.';
buf[3] = '\0';
name = buf;
}
#if OS2 >= 2
if (DosQueryPathInfo((PSZ)name, FIL_QUERYFULLNAME, buffer, len))
#else
if (DosQPathInfo((PSZ)name, FIL_QUERYFULLNAME, (PBYTE)buffer, len, 0L))
#endif
return NULL;
return buffer;
}
DIR *
openxdir(const char *path, unsigned att_mask)
{
DIR *dir;
char name[MAXPATHLEN+3];
Word rc;
dir = malloc(sizeof(DIR));
if (dir == NULL) {
errno = ENOMEM;
return NULL;
}
strncpy(name, path, MAXPATHLEN);
name[MAXPATHLEN] = '\0';
switch (name[strlen(name)-1]) {
default:
strcat(name, "\\");
case '\\':
case '/':
case ':':
;
}
strcat(name, ".");
if (!abs_path(name, dir->name, MAXPATHLEN+1))
strcpy(dir->name, name);
if (dir->name[strlen(dir->name)-1] == '\\')
strcat(dir->name, "*");
else
strcat(dir->name, "\\*");
dir->fstype = getFSType(dir->name);
dir->attrmask = att_mask | A_DIR;
dir->handle = HDIR_CREATE;
dir->count = 100;
#if OS2 >= 2
rc = DosFindFirst(dir->name, &dir->handle, dir->attrmask,
dir->ffbuf, sizeof dir->ffbuf, &dir->count, FIL_STANDARD);
#else
rc = DosFindFirst((PSZ)dir->name, &dir->handle, dir->attrmask,
(PFILEFINDBUF)dir->ffbuf, sizeof dir->ffbuf, &dir->count, 0);
#endif
switch (rc) {
default:
free(dir);
error(rc);
return NULL;
case NO_ERROR:
case ERROR_NO_MORE_FILES:
;
}
dir->number = 0;
dir->index = 0;
dir->next = (FFBUF *)dir->ffbuf;
return (DIR *)dir;
}
DIR *
opendir(const char *pathname)
{
return openxdir(pathname, 0);
}
struct dirent *
readdir(DIR *dir)
{
static int dummy_ino = 2;
if (dir->index == dir->count) {
Word rc;
dir->count = 100;
#if OS2 >= 2
rc = DosFindNext(dir->handle, dir->ffbuf,
sizeof dir->ffbuf, &dir->count);
#else
rc = DosFindNext(dir->handle, (PFILEFINDBUF)dir->ffbuf,
sizeof dir->ffbuf, &dir->count);
#endif
if (rc) {
error(rc);
return NULL;
}
dir->index = 0;
dir->next = (FFBUF *)dir->ffbuf;
}
if (dir->index == dir->count)
return NULL;
memcpy(dir->entry.d_name, dir->next->achName, dir->next->cchName);
dir->entry.d_name[dir->next->cchName] = '\0';
dir->entry.d_ino = dummy_ino++;
dir->entry.d_reclen = dir->next->cchName;
dir->entry.d_namlen = dir->next->cchName;
dir->entry.d_size = dir->next->cbFile;
dir->entry.d_attribute = dir->next->attrFile;
dir->entry.d_time = *(USHORT *)&dir->next->ftimeLastWrite;
dir->entry.d_date = *(USHORT *)&dir->next->fdateLastWrite;
switch (dir->fstype) {
case 'F': /* FAT */
case 'C': /* CDFS */
if (dir->next->attrFile & FILE_DIRECTORY)
strupr(dir->entry.d_name);
else
strlwr(dir->entry.d_name);
}
#if OS2 >= 2
dir->next = (FFBUF *)((BYTE *)dir->next + dir->next->oNextEntryOffset);
#else
dir->next = (FFBUF *)((BYTE *)dir->next->achName + dir->next->cchName + 1);
#endif
++dir->number;
++dir->index;
return &dir->entry;
}
long
telldir(DIR *dir)
{
return dir->number;
}
void
seekdir(DIR *dir, long off)
{
if (dir->number > off) {
char name[MAXPATHLEN+2];
Word rc;
DosFindClose(dir->handle);
strcpy(name, dir->name);
strcat(name, "*");
dir->handle = HDIR_CREATE;
dir->count = 32767;
#if OS2 >= 2
rc = DosFindFirst(name, &dir->handle, dir->attrmask,
dir->ffbuf, sizeof dir->ffbuf, &dir->count, FIL_STANDARD);
#else
rc = DosFindFirst((PSZ)name, &dir->handle, dir->attrmask,
(PFILEFINDBUF)dir->ffbuf, sizeof dir->ffbuf, &dir->count, 0);
#endif
switch (rc) {
default:
error(rc);
return;
case NO_ERROR:
case ERROR_NO_MORE_FILES:
;
}
dir->number = 0;
dir->index = 0;
dir->next = (FFBUF *)dir->ffbuf;
}
while (dir->number < off && readdir(dir))
;
}
void
closedir(DIR *dir)
{
DosFindClose(dir->handle);
free(dir);
}
/*****************************************************************************/
#ifdef TEST
main(int argc, char **argv)
{
int i;
DIR *dir;
struct dirent *ep;
for (i = 1; i < argc; ++i) {
dir = opendir(argv[i]);
if (!dir)
continue;
while (ep = readdir(dir))
if (strchr("\\/:", argv[i] [strlen(argv[i]) - 1]))
printf("%s%s\n", argv[i], ep->d_name);
else
printf("%s/%s\n", argv[i], ep->d_name);
closedir(dir);
}
return 0;
}
#endif
#endif /* OS2 */

Просмотреть файл

@ -1,97 +0,0 @@
#ifndef __DIRENT_H__
#define __DIRENT_H__
/*
* @(#)msd_dir.h 1.4 87/11/06 Public Domain.
*
* A public domain implementation of BSD directory routines for
* MS-DOS. Written by Michael Rendell ({uunet,utai}michael@garfield),
* August 1897
*
* Extended by Peter Lim (lim@mullian.oz) to overcome some MS DOS quirks
* and returns 2 more pieces of information - file size & attribute.
* Plus a little reshuffling of some #define's positions December 1987
*
* Some modifications by Martin Junius 02-14-89
*
* AK900712
* AK910410 abs_path - make absolute path
*
*/
#ifdef __EMX__
#include <sys/param.h>
#else
#if defined(__IBMC__) || defined(__IBMCPP__) || defined(XP_W32_MSVC)
#include <stdio.h>
#ifdef MAXPATHLEN
#undef MAXPATHLEN
#endif
#define MAXPATHLEN (FILENAME_MAX*4)
#define MAXNAMLEN FILENAME_MAX
#else
#include <param.h>
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* attribute stuff */
#ifndef A_RONLY
# define A_RONLY 0x01
# define A_HIDDEN 0x02
# define A_SYSTEM 0x04
# define A_LABEL 0x08
# define A_DIR 0x10
# define A_ARCHIVE 0x20
#endif
struct dirent {
#if defined(OS2) || defined(WIN32) /* use the layout of EMX to avoid trouble */
int d_ino; /* Dummy */
int d_reclen; /* Dummy, same as d_namlen */
int d_namlen; /* length of name */
char d_name[MAXNAMLEN + 1];
unsigned long d_size;
unsigned short d_attribute; /* attributes (see above) */
unsigned short d_time; /* modification time */
unsigned short d_date; /* modification date */
#else
char d_name[MAXNAMLEN + 1]; /* garentee null termination */
char d_attribute; /* .. extension .. */
unsigned long d_size; /* .. extension .. */
#endif
};
typedef struct _dirdescr DIR;
/* the structs do not have to be defined here */
extern DIR *opendir(const char *);
extern DIR *openxdir(const char *, unsigned);
extern struct dirent *readdir(DIR *);
extern void seekdir(DIR *, long);
extern long telldir(DIR *);
extern void closedir(DIR *);
#define rewinddir(dirp) seekdir(dirp, 0L)
extern char * abs_path(const char *name, char *buffer, int len);
#ifndef S_IFMT
#define S_IFMT ( S_IFDIR | S_IFREG )
#endif
#ifndef S_ISDIR
#define S_ISDIR( m ) (((m) & S_IFMT) == S_IFDIR)
#endif
#ifndef S_ISREG
#define S_ISREG( m ) (((m) & S_IFMT) == S_IFREG)
#endif
#ifdef __cplusplus
}
#endif
#endif

Просмотреть файл

@ -1,140 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* Copyright (c) 1987 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that: (1) source distributions retain this entire copyright
* notice and comment, and (2) distributions including binaries display
* the following acknowledgement: ``This product includes software
* developed by the University of California, Berkeley and its contributors''
* in the documentation or other materials provided with the distribution
* and in all advertising materials mentioning features or use of this
* software. Neither the name of the University nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getopt.c 4.12 (Berkeley) 6/1/90";
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
#include <string.h>
#define index strchr
#define rindex strrchr
/*
* get option letter from argument vector
*/
int opterr = 1, /* if error message should be printed */
optind = 1, /* index into parent argv vector */
optopt; /* character checked for validity */
char *optarg; /* argument associated with option */
#define BADCH (int)'?'
#define EMSG ""
getopt(int nargc, char **nargv, char *ostr)
{
static char *place = EMSG; /* option letter processing */
register char *oli; /* option letter list index */
char *p;
if (!*place) { /* update scanning pointer */
if (optind >= nargc || *(place = nargv[optind]) != '-') {
place = EMSG;
return(EOF);
}
if (place[1] && *++place == '-') { /* found "--" */
++optind;
place = EMSG;
return(EOF);
}
} /* option letter okay? */
if ((optopt = (int)*place++) == (int)':' ||
!(oli = index(ostr, optopt))) {
/*
* if the user didn't specify '-' as an option,
* assume it means EOF.
*/
if (optopt == (int)'-')
return(EOF);
if (!*place)
++optind;
if (opterr) {
if (!(p = rindex(*nargv, '/')))
p = *nargv;
else
++p;
(void)fprintf(stderr, "%s: illegal option -- %c\n",
p, optopt);
}
return(BADCH);
}
if (*++oli != ':') { /* don't need argument */
optarg = NULL;
if (!*place)
++optind;
}
else { /* need an argument */
if (*place) /* no white space */
optarg = place;
else if (nargc <= ++optind) { /* no arg */
place = EMSG;
if (!(p = rindex(*nargv, '/')))
p = *nargv;
else
++p;
if (opterr)
(void)fprintf(stderr,
"%s: option requires an argument -- %c\n",
p, optopt);
return(BADCH);
}
else /* white space */
optarg = nargv[optind];
place = EMSG;
++optind;
}
return(optopt); /* dump back option letter */
}

Просмотреть файл

@ -179,16 +179,7 @@
#if defined(XP_MAC)
#include <Files.h>
#include "nsILocalFileMac.h"
#elif defined(XP_UNIX) || defined (XP_OS2) || defined(XP_BEOS)
#if defined(XP_OS2)
#define INCL_DOS
#define INCL_DOSERRORS
#define INCL_WIN
#define INCL_GPI
#include <os2.h>
#include <sys/types.h> // required for dirent.h
#include "prio.h"
#endif
#elif defined(XP_UNIX) || defined(XP_BEOS)
#include <dirent.h>
#elif defined(XP_WIN)
@ -201,6 +192,13 @@
#undef CreateDirectory
#endif
#include "prio.h"
#elif defined(XP_OS2)
#define INCL_DOS
#define INCL_DOSERRORS
#define INCL_WIN
#define INCL_GPI
#include <os2.h>
#include "prio.h"
#endif

Просмотреть файл

@ -54,7 +54,6 @@ static int isleadbyte(int c);
#ifdef XP_OS2_VACPP
#include <direct.h>
#include "dirent.h"
#else
#include <unistd.h>
#endif
@ -1258,6 +1257,7 @@ nsLocalFile::GetFileSize(PRInt64 *aFileSize)
*aFileSize = mFileInfo64.size;
printf("filesize = %ld\n", mFileInfo64.size);
return NS_OK;
}