home *** CD-ROM | disk | FTP | other *** search
- From: zip-bugs@wkuvx1.wku.edu (Info-ZIP group)
- Newsgroups: comp.sources.misc
- Subject: v44i070: unzip - Info-ZIP portable UnZip, version 5.12, Part05/20
- Date: 18 Sep 1994 23:14:49 -0500
- Organization: Sterling Software
- Sender: kent@sparky.sterling.com
- Approved: kent@sparky.sterling.com
- Message-ID: <35j37p$qmo@sparky.sterling.com>
- X-Md4-Signature: 67ab425609829ea013b7f64b4defee4f
-
- Submitted-by: zip-bugs@wkuvx1.wku.edu (Info-ZIP group)
- Posting-number: Volume 44, Issue 70
- Archive-name: unzip/part05
- Environment: UNIX, VMS, OS/2, MS-DOS, MACINTOSH, WIN-NT, LINUX, MINIX, COHERENT, AMIGA?, ATARI TOS, SGI, DEC, Cray, Convex, Amdahl, Sun
- Supersedes: unzip50: Volume 31, Issue 104-117
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # Contents: unzip-5.12/Where unzip-5.12/os2/os2.c
- # Wrapped by kent@sparky on Sat Sep 17 23:33:37 1994
- PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 5 (of 20)."'
- if test -f 'unzip-5.12/Where' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'unzip-5.12/Where'\"
- else
- echo shar: Extracting \"'unzip-5.12/Where'\" \(9912 characters\)
- sed "s/^X//" >'unzip-5.12/Where' <<'END_OF_FILE'
- X__________________________________________________________________________
- X
- X This is the Info-ZIP file ``Where,'' last updated on 7 September 1994.
- X__________________________________________________________________________
- X
- X Note that some ftp sites may not yet have the latest versions of
- X Zip and UnZip when you read this. The latest versions, including
- X the crypt sources, always appear in ftp.uu.net:/pub/archiving/zip
- X (and subdirectories thereof) first.
- X
- X IF YOU FIND AN ERROR: please let us know! We don't have time to
- X check each and every site personally (or even collectively), so any
- X number of the sites listed below may have moved or disappeared en-
- X tirely. E-mail to zip-bugs@wkuvx1.wku.edu and we'll update this file.
- X__________________________________________________________________________
- X
- X
- XSource-code archives for Info-ZIP's portable Zip, UnZip, and related
- Xutilities (on some ftp sites, the .zip files for UnZip may have a .zoo
- Xequivalent in Zoo 2.10 format):
- X
- X zip201.zip Zip 2.0.1 (deflation; includes zipnote, zipsplit)
- X zip201.tar.Z ditto, compress'd tar format
- X
- X zip11.zip Zip 1.1 (shrinking, implosion; compatible with PKUNZIP 1.1)
- X zip11.tar.Z ditto, compress'd tar format
- X
- X unzip512.zip UnZip 5.12 (all methods supported; zipinfo, funzip, unzipsfx)
- X unzip512.tar.Z ditto, compress'd tar format
- X
- X wunz20sr.zip WizUnZip 2.0 sources for Windows 3.x; based on UnZip 5.0p1
- X
- X zcrypt23.zip encryption/decryption support (includes zipcloak)
- X
- XExecutables archives (and related files) for Info-ZIP's software; see BBS
- Xsection below for special CompuServe (6.3) filenames:
- X
- X zip201x.zip MSDOS executables and docs for zip, zipnote, zipsplit
- X zcryp20x.zip MSDOS encryption executables and docs for zip, zipcloak
- X zip201x1.zip OS/2 1.x (16-bit) executables and docs (no encryption)
- X zip201x2.zip OS/2 2.x (32-bit) executables and docs (no encryption)
- X zip201c2.zip OS/2 2.x (32-bit) executables and docs (with encryption)
- X zip201-vax.zip VMS exes (VAX) and docs
- X zip201-axp.zip VMS exes (Alpha) and docs
- X zip201x.lha Amiga executables and docs
- X
- X unz512x.exe MSDOS self-extracting executable (16-bit unzip, ..., docs)
- X unz512x3.exe MSDOS self-extracting executable (16-, 32-bit unzip, docs)
- X unz512x1.exe OS/2 1.x (16-bit) self-extracting executables and docs
- X unz512x2.exe OS/2 2.x (32-bit) self-extracting executables and docs
- X unz512xN.exe Windows NT (and Chicago) self-extracting Intel exes and docs
- X (unz512xN-mips.exe, unz512xN-axp.exe: Windows NT exes/docs for MIPS & Alpha)
- X unz512x-vax.exe VMS self-extracting executables and docs for VAX unzip
- X unz512x-axp.exe VMS self-extracting executables and docs for Alpha unzip
- X unz512x.lha Amiga executables and docs for unzip
- X unz512x.tos Atari self-extracting executables and docs for unzip
- X unz512x.hqx Macintosh BinHex'd executables and docs for unzip
- X (unz512x.tar.Z or .gz: Unix exes/docs for Solaris 2.x, SCO Unix or Linux,
- X depending on directory/location)
- X
- X UnzpHist.zip complete changes history of UnZip and its precursors
- X
- X wunz20x.zip WizUnZip 2.0 executable/docs for Windows & NT 3.1, OS/2 2.1
- X wunl20x.zip same as wunz20x.zip, plus two DLLs for Win 3.0 and OS/2 2.0
- X
- XThe latest from PKWARE (the guys who started it all):
- X
- X pkz204g.exe MS-DOS PKZIP/PKUNZIP 2.04g (self-extracting archive)
- X pkz110eu.exe MS-DOS PKZIP/PKUNZIP 1.1 (self-extracting)
- X pkz206-2.exe OS/2 PKZIP/PKUNZIP 2.06 (IBM internal only; same as 2.04g)
- X pkz102-2.exe OS/2 PKZIP/PKUNZIP 1.02 (self-extracting)
- X
- XThird-party software which is based on or uses (or can use) Info-ZIP software:
- X
- X zipme11.zip, zipctl.zip, wuz131.zip, zpfly91b.zip, pmzip01.zip (OS/2)
- X winzip5b.zip, z101.zip (Windows)
- X
- Xftp sites for the US-exportable sources and executables:
- X
- X NOTE: Look for the file names given above in the following directories.
- X Some sites like to use slightly different names, such as zip-2.0.1.tar.gz
- X instead of zip201.tar.Z. In the case of some comp.sources.misc archive
- X sites, directories may be used (zip201/part01.Z, ..., zip201/part11.Z,
- X zip201/patch01.Z, etc.).
- X
- X ftp.uu.net:/pub/archiving/zip [THIS MIRRORS THE INFO-ZIP HOME SITE]
- X
- X oak.oakland.edu:/pub/msdos/{zip,windows3} [AND OTHER SIMTEL MIRRORS]
- X oak.oakland.edu:/pub/misc/{unix,vaxvms}
- X garbo.uwasa.fi:/{unix,pc}/arcers [AND OTHER GARBO MIRRORS]
- X ftp-os2.cdrom.com:/pub/os2/{2_x,all}/archiver
- X ftp-os2.nmsu.edu:/os2/{2_x,all}/archiver
- X ftp.informatik.tu-muenchen.de:/pub/comp/os/os2/archiver
- X sumex-aim.stanford.edu:/info-mac/util
- X ftp.wustl.edu:/pub/aminet/util/arc [AND OTHER AMINET MIRRORS]
- X atari.archive.umich.edu:/pub/Archivers (?) [AND OTHER UMICH MIRRORS]
- X lpuds.oea.ihep.su:/ ... ?
- X
- Xftp sites for the encryption and decryption sources and/or executables:
- X
- X NOTE 1: Non-US users, please do NOT ftp from the US sites (US
- X regulations and all that). Likewise, US users, please do not
- X ftp from the European sites (it's not illegal, but it sure is
- X a waste of expensive bandwidth).
- X
- X NOTE 2: Some sites may carry both encryption and non-encryption
- X executables with slightly different names; for example, zip201c2.zip
- X instead of zip201x2.zip ("c" == crypt version). Other sites may
- X include *only* the encryption-related executables (zip and zipcloak)
- X in a second archive (e.g., zcryp20x.zip).
- X
- X From the US:
- X wuarchive.wustl.edu:/mirrors/garbo.uwasa.fi/arcutil
- X ftp.uu.net:/pub/archiving/zip
- X
- X Outside the US:
- X garbo.uwasa.fi:/pc/arcutil
- X ftp.inria.fr:/system/arch-compr
- X ftp.informatik.tu-muenchen.de:/pub/comp/os/os2/archiver
- X (mail server at ftp-mailer@informatik.tu-muenchen.de)
- X
- X ftp.win.tue.nl:/pub/compression/zip/...
- X ftp.uni-erlangen.de:/pub/pc/msdos/utilities/zip/...
- X
- Xftp sites for VMS-format Zip and UnZip packages (sources, object files and
- Xexecutables, no encryption/decryption--see also "Mail servers" section below):
- X
- X ftp.spc.edu [192.107.46.27] and ftp.wku.edu:
- X
- X [.MACRO32]AAAREADME.TXT
- X [.MACRO32.SAVESETS]UNZIP.BCK or UNZIP.ZIP (if already have older version)
- X [.MACRO32.SAVESETS]ZIP20.ZIP (to be renamed to ZIP.ZIP in next release)
- X
- XTo find other ftp sites:
- X
- X The "archie" ftp database utility can be used to find an ftp site
- X near you (although it always seems to find old versions...). If
- X you don't know how to use it, DON'T ASK US--check the Usenet groups
- X news.announce.newusers or news.answers or some such, or ask your
- X system administrator (or just RTFM :-) ).
- X
- XUUCP sites:
- X
- X uunet!~/pub/archiving/zip/ ...
- X
- XBulletin boards (commercial and otherwise):
- X
- X Sources, MS-DOS executables:
- X CompuServe IBMPRO forum, Library 10, Data Compression (unz512.zip,
- X sources; unz512.exe, self-extracting executables and docs)
- X CompuServe (ZiffNet) PBSUTIL forum and Public Brand Software BBS
- X [US, membership required; V.32 line, (317) 856-1490]
- X (unz512.zip, sources; unz512.exe, self-extracting exes and docs)
- X America Online OS/2 Forum, Free Uploading area; also Top Picks lib-
- X rary, File/Disk Utilities library, and OS/2 1.x library (do key-
- X word search via ctrl-K: FILE SEARCH on "INFOZIP")
- X FidoNet node 1:124/2113, Lunatic Fringe [Richardson, Texas; BBS
- X (214) 235-5288; sysop john.stewart@lunatic.com; complete mirror
- X of Info-ZIP home site]
- X FidoNet node 1:246/74, Metal Shoppe BBS [Windsor, Ontario; CLink
- X node 911:6510/0; BBS (519) 256-0278; sysop rakey@cyberspace.net
- X (Ray Akey); micro-based files but no Unix/VMS/NT stuff]
- X Drealm Conference System [London, UK; V.22bis, subscriber lines
- X to V.32bis, etc.; (+44) 81 568 2204]
- X Compulink Information eXchange (CIX) [London, UK; (+44) 181 390 1244
- X and 181 390 1255; sources in free_software/sources, executables
- X in "the filepool"]
- X
- X Windows sources and executables:
- X CompuServe ZENITH forum (wunzip.zip, WizUnZip exe + libs for
- X Win 3.x, NT, OS/2 2.x)
- X CompuServe CRAFTS forum (wunz20.exe, WizUnZip bare executable
- X for Win 3.1, NT, OS/2 2.1)
- X
- X OS/2 executables:
- X CompuServe OS2USER forum (zip201.zip and unz512.exe, OS/2 16-
- X and 32-bit exes and docs)
- X
- X Amiga executables:
- X BIX in AMIGA files section (perform keyword search on "info-zip")
- X [requires account; telnet bix.com, or "C BIX" via local Sprint
- X X.25 PAD, or dial direct in US at (617) 491-5410]
- X
- XMail servers:
- X
- X If you don't have anonymous FTP capability, you can mail one
- X of the following commands (in the body of an e-mail message) to
- X listserv@vm.ecs.rpi.edu or listserv@vm1.nodak.edu in order to
- X get a copy of the source code via e-mail:
- X
- X /pdget mail /pub/misc/unix/unzip512.tar.Z uuencode
- X /pdget mail /pub/msdos/zip/unzip512.zip uuencode
- X /pdget mail /pub/msdos/zip/zip201.zip uuencode
- X
- X The older, pseudo-TOPS-20 style also works:
- X
- X /pdget mail pd:<misc.unix>unzip512.tar.Z uuencode
- X /pdget mail pd:<misc.unix>zip201.zip uuencode
- X
- X To get the encryption source by e-mail, send the following commands
- X to ftp-mailer@informatik.tu-muenchen.de:
- X
- X get /pub/comp/os/os2/archiver/zcrypt23.zip
- X quit
- X
- X To get the VMS Zip/UnZip package by e-mail, send the following
- X commands in the body of a mail message to mxserver@wkuvx1.wku.edu
- X (the "HELP" command is also accepted):
- X
- X SEND UNZIP
- X SEND ZIP20 <-- will change to plain "ZIP" in next release
- X SEND FILESERV_TOOLS
- X
- X To get Atari executables by e-mail, send a message to
- X atari@atari.archive.umich.edu for information about the mail server.
- X__________________________________________________________________________
- X
- END_OF_FILE
- if test 9912 -ne `wc -c <'unzip-5.12/Where'`; then
- echo shar: \"'unzip-5.12/Where'\" unpacked with wrong size!
- fi
- # end of 'unzip-5.12/Where'
- fi
- if test -f 'unzip-5.12/os2/os2.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'unzip-5.12/os2/os2.c'\"
- else
- echo shar: Extracting \"'unzip-5.12/os2/os2.c'\" \(57190 characters\)
- sed "s/^X//" >'unzip-5.12/os2/os2.c' <<'END_OF_FILE'
- X/*---------------------------------------------------------------------------
- X
- X os2.c
- X
- X OS/2-specific routines for use with Info-ZIP's UnZip 5.1 and later.
- X
- X This file contains the OS/2 versions of the file name/attribute/time/etc
- X code. Most or all of the routines which make direct use of OS/2 system
- X calls (i.e., the non-lowercase routines) are Kai Uwe Rommel's. The read-
- X dir() suite was written by Michael Rendell and ported to OS/2 by Kai Uwe;
- X it is in the public domain.
- X
- X Contains: GetCountryInfo()
- X GetFileTime()
- X SetPathInfo()
- X IsEA()
- X SetEAs()
- X SizeOfEAs()
- X GetLoadPath()
- X opendir()
- X closedir()
- X readdir()
- X [ seekdir() ] not used
- X [ telldir() ] not used
- X free_dircontents()
- X getdirent()
- X IsFileSystemFAT()
- X do_wild()
- X mapattr()
- X mapname()
- X checkdir()
- X isfloppy()
- X IsFileNameValid()
- X map2fat()
- X SetLongNameEA()
- X close_outfile()
- X check_for_newer()
- X dateformat()
- X version()
- X InitNLS()
- X IsUpperNLS()
- X ToLowerNLS()
- X StringLower()
- X DebugMalloc()
- X
- X ---------------------------------------------------------------------------*/
- X
- X
- X#include "unzip.h"
- Xchar *StringLower(char *szArg);
- X
- X/* local prototypes */
- Xstatic int isfloppy __((int nDrive));
- Xstatic int IsFileNameValid __((char *name));
- Xstatic void map2fat __((char *pathcomp, char **pEndFAT));
- Xstatic int SetLongNameEA __((char *name, char *longname));
- Xstatic void InitNLS __((void));
- X
- X#ifndef __EMX__
- X# if (_MSC_VER >= 600) || defined(__IBMC__)
- X# include <direct.h> /* have special MSC/IBM C mkdir prototype */
- X# else /* own prototype because dir.h conflicts? */
- X int mkdir(const char *path);
- X# endif
- X# define MKDIR(path,mode) mkdir(path)
- X#else
- X# define MKDIR(path,mode) mkdir(path,mode)
- X#endif
- X
- X#define INCL_NOPM
- X#define INCL_DOSNLS
- X#define INCL_DOSPROCESS
- X#define INCL_DOSDEVICES
- X#define INCL_DOSDEVIOCTL
- X#define INCL_DOSERRORS
- X#include <os2.h>
- X
- X#ifdef __32BIT__
- X
- XUSHORT DosDevIOCtl32(PVOID pData, USHORT cbData, PVOID pParms, USHORT cbParms,
- X USHORT usFunction, USHORT usCategory, HFILE hDevice)
- X{
- X ULONG ulParmLengthInOut = cbParms, ulDataLengthInOut = cbData;
- X return (USHORT) DosDevIOCtl(hDevice, usCategory, usFunction,
- X pParms, cbParms, &ulParmLengthInOut,
- X pData, cbData, &ulDataLengthInOut);
- X}
- X
- X# define DosDevIOCtl DosDevIOCtl32
- X#else
- X# define DosDevIOCtl DosDevIOCtl2
- X#endif
- X
- X
- X#define EAID 0x0009
- X
- X
- Xtypedef struct
- X{
- X ush nID;
- X ush nSize;
- X ulg lSize;
- X}
- XEAHEADER, *PEAHEADER;
- X
- X
- X#ifndef __32BIT__
- X
- Xtypedef struct
- X{
- X ULONG oNextEntryOffset;
- X BYTE fEA;
- X BYTE cbName;
- X USHORT cbValue;
- X CHAR szName[1];
- X}
- XFEA2, *PFEA2;
- X
- Xtypedef struct
- X{
- X ULONG cbList;
- X FEA2 list[1];
- X}
- XFEA2LIST, *PFEA2LIST;
- X
- X
- X#define DosSetPathInfo(p1, p2, p3, p4, p5) \
- X DosSetPathInfo(p1, p2, p3, p4, p5, 0)
- X#define DosQueryPathInfo(p1, p2, p3, p4) \
- X DosQPathInfo(p1, p2, p3, p4, 0)
- X#define DosMapCase DosCaseMap
- X#define DosQueryCtryInfo DosGetCtryInfo
- X
- X#endif /* !__32BIT__ */
- X
- X
- X
- X
- X
- X/*
- X * @(#) dir.h 1.4 87/11/06 Public Domain.
- X */
- X
- X#define MAXNAMLEN 256
- X#define MAXPATHLEN 256
- X
- X#define A_RONLY 0x01
- X#define A_HIDDEN 0x02
- X#define A_SYSTEM 0x04
- X#define A_LABEL 0x08
- X#define A_DIR 0x10
- X#define A_ARCHIVE 0x20
- X
- X
- Xstruct direct
- X{
- X ino_t d_ino; /* a bit of a farce */
- X int d_reclen; /* more farce */
- X int d_namlen; /* length of d_name */
- X char d_name[MAXNAMLEN + 1]; /* null terminated */
- X /* nonstandard fields */
- X long d_size; /* size in bytes */
- X unsigned d_mode; /* MS-DOS or OS/2 file attributes */
- X unsigned d_time;
- X unsigned d_date;
- X};
- X
- X/* The fields d_size and d_mode are extensions by me (Kai Uwe Rommel). The
- X * find_first and find_next calls deliver these data without any extra cost.
- X * If these data are needed, the fields save a lot of extra calls to stat()
- X * (each stat() again performs a find_first call !).
- X */
- X
- Xstruct _dircontents
- X{
- X char *_d_entry;
- X long _d_size;
- X unsigned _d_mode, _d_time, _d_date;
- X struct _dircontents *_d_next;
- X};
- X
- Xtypedef struct _dirdesc
- X{
- X int dd_id; /* uniquely identify each open directory */
- X long dd_loc; /* where we are in directory entry is this */
- X struct _dircontents *dd_contents; /* pointer to contents of dir */
- X struct _dircontents *dd_cp; /* pointer to current position */
- X}
- XDIR;
- X
- X
- Xextern DIR *opendir(char *);
- Xextern struct direct *readdir(DIR *);
- Xextern void seekdir(DIR *, long);
- Xextern long telldir(DIR *);
- Xextern void closedir(DIR *);
- X#define rewinddir(dirp) seekdir(dirp, 0L)
- X
- Xint IsFileSystemFAT(char *dir);
- Xchar *StringLower(char *);
- X
- X
- X
- X
- X/*
- X * @(#)dir.c 1.4 87/11/06 Public Domain.
- X */
- X
- X#ifdef __32BIT__
- X# define DosFindFirst(p1, p2, p3, p4, p5, p6) \
- X DosFindFirst(p1, p2, p3, p4, p5, p6, 1)
- X#else
- X# define DosQueryCurrentDisk DosQCurDisk
- X# define DosQueryFSAttach(p1, p2, p3, p4, p5) \
- X DosQFSAttach(p1, p2, p3, p4, p5, 0)
- X# define DosQueryPathInfo(p1, p2, p3, p4) \
- X DosQPathInfo(p1, p2, p3, p4, 0)
- X# define DosSetPathInfo(p1, p2, p3, p4, p5) \
- X DosSetPathInfo(p1, p2, p3, p4, p5, 0)
- X# define DosEnumAttribute(p1, p2, p3, p4, p5, p6, p7) \
- X DosEnumAttribute(p1, p2, p3, p4, p5, p6, p7, 0)
- X# define DosFindFirst(p1, p2, p3, p4, p5, p6) \
- X DosFindFirst(p1, p2, p3, p4, p5, p6, 0)
- X# define DosMapCase DosCaseMap
- X#endif
- X
- X#ifndef S_IFMT
- X# define S_IFMT 0xF000
- X#endif
- X
- X
- X#ifdef __WATCOMC__
- X unsigned char __near _osmode = OS2_MODE;
- X#endif
- X
- X#ifndef SFX
- X static char *getdirent(char *);
- X static void free_dircontents(struct _dircontents *);
- X static int attributes = A_DIR | A_HIDDEN | A_SYSTEM;
- X# ifdef __32BIT__
- X static HDIR hdir;
- X static ULONG count;
- X static FILEFINDBUF3 find;
- X# else
- X static HDIR hdir; /* GRR: is there a difference? HDIR2?? */
- X static USHORT count;
- X static FILEFINDBUF find;
- X# endif
- X#endif /* !SFX */
- X
- X
- X
- X
- Xstatic int created_dir; /* used by mapname(), checkdir() */
- Xstatic int renamed_fullpath; /* ditto */
- Xstatic int fnlen; /* ditto */
- X#ifdef __32BIT__
- X static ULONG nLabelDrive; /* ditto */
- X#else
- X static USHORT nLabelDrive;
- X#endif
- Xstatic int longnameEA; /* checkdir(), close_outfile() */
- Xstatic char *lastpathcomp; /* ditto */
- X
- X
- Xint GetCountryInfo(void)
- X{
- X COUNTRYINFO ctryi;
- X COUNTRYCODE ctryc;
- X#ifdef __32BIT__
- X ULONG cbInfo;
- X#else
- X USHORT cbInfo;
- X#endif
- X
- X ctryc.country = ctryc.codepage = 0;
- X
- X if ( DosQueryCtryInfo(sizeof(ctryi), &ctryc, &ctryi, &cbInfo) != NO_ERROR )
- X return 0;
- X
- X return ctryi.fsDateFmt;
- X}
- X
- X
- Xlong GetFileTime(char *name)
- X{
- X#ifdef __32BIT__
- X FILESTATUS3 fs;
- X#else
- X FILESTATUS fs;
- X#endif
- X USHORT nDate, nTime;
- X
- X if ( DosQueryPathInfo(name, 1, (PBYTE) &fs, sizeof(fs)) )
- X return -1;
- X
- X nDate = * (USHORT *) &fs.fdateLastWrite;
- X nTime = * (USHORT *) &fs.ftimeLastWrite;
- X
- X return ((ULONG) nDate) << 16 | nTime;
- X}
- X
- X
- Xvoid SetPathInfo(char *path, ush moddate, ush modtime, int flags)
- X{
- X union {
- X FDATE fd; /* system file date record */
- X ush zdate; /* date word */
- X } ud;
- X union {
- X FTIME ft; /* system file time record */
- X ush ztime; /* time word */
- X } ut;
- X FILESTATUS fs;
- X USHORT nLength;
- X char szName[CCHMAXPATH];
- X
- X strcpy(szName, path);
- X nLength = strlen(szName);
- X if (szName[nLength - 1] == '/')
- X szName[nLength - 1] = 0;
- X
- X if ( DosQueryPathInfo(szName, FIL_STANDARD, (PBYTE) &fs, sizeof(fs)) )
- X return;
- X
- X ud.zdate = moddate;
- X ut.ztime = modtime;
- X fs.fdateLastWrite = fs.fdateCreation = ud.fd;
- X fs.ftimeLastWrite = fs.ftimeCreation = ut.ft;
- X
- X if ( flags != -1 )
- X fs.attrFile = flags; /* hidden, system, archive, read-only */
- X
- X DosSetPathInfo(szName, FIL_STANDARD, (PBYTE) &fs, sizeof(fs), 0);
- X}
- X
- X
- Xtypedef struct
- X{
- X ULONG cbList; /* length of value + 22 */
- X#ifdef __32BIT__
- X ULONG oNext;
- X#endif
- X BYTE fEA; /* 0 */
- X BYTE cbName; /* length of ".LONGNAME" = 9 */
- X USHORT cbValue; /* length of value + 4 */
- X BYTE szName[10]; /* ".LONGNAME" */
- X USHORT eaType; /* 0xFFFD for length-preceded ASCII */
- X USHORT eaSize; /* length of value */
- X BYTE szValue[CCHMAXPATH];
- X}
- XFEALST;
- X
- X
- Xint IsEA(void *extra_field)
- X{
- X EAHEADER *pEAblock = (PEAHEADER) extra_field;
- X return extra_field != NULL && pEAblock -> nID == EAID;
- X}
- X
- X
- Xvoid SetEAs(char *path, void *eablock)
- X{
- X EAHEADER *pEAblock = (PEAHEADER) eablock;
- X#ifdef __32BIT__
- X EAOP2 eaop;
- X PFEA2LIST pFEA2list;
- X#else
- X EAOP eaop;
- X PFEALIST pFEAlist;
- X PFEA pFEA;
- X PFEA2LIST pFEA2list;
- X PFEA2 pFEA2;
- X ULONG nLength2;
- X#endif
- X USHORT nLength;
- X char szName[CCHMAXPATH];
- X
- X if ( !IsEA(eablock) )
- X return;
- X
- X strcpy(szName, path);
- X nLength = strlen(szName);
- X if (szName[nLength - 1] == '/')
- X szName[nLength - 1] = 0;
- X
- X if ( (pFEA2list = (PFEA2LIST) malloc((size_t) pEAblock -> lSize)) == NULL )
- X return;
- X
- X if ( memextract((char *) pFEA2list, pEAblock -> lSize,
- X (char *) (pEAblock + 1),
- X pEAblock -> nSize - sizeof(pEAblock -> lSize)) )
- X {
- X free(pFEA2list);
- X return;
- X }
- X
- X#ifdef __32BIT__
- X eaop.fpGEA2List = NULL;
- X eaop.fpFEA2List = pFEA2list;
- X#else
- X pFEAlist = (PVOID) pFEA2list;
- X pFEA2 = pFEA2list -> list;
- X pFEA = pFEAlist -> list;
- X
- X do
- X {
- X nLength2 = pFEA2 -> oNextEntryOffset;
- X nLength = sizeof(FEA) + pFEA2 -> cbName + 1 + pFEA2 -> cbValue;
- X
- X memcpy(pFEA, (PCH) pFEA2 + sizeof(pFEA2 -> oNextEntryOffset), nLength);
- X
- X pFEA2 = (PFEA2) ((PCH) pFEA2 + nLength2);
- X pFEA = (PFEA) ((PCH) pFEA + nLength);
- X }
- X while ( nLength2 != 0 );
- X
- X pFEAlist -> cbList = (PCH) pFEA - (PCH) pFEAlist;
- X
- X eaop.fpGEAList = NULL;
- X eaop.fpFEAList = pFEAlist;
- X#endif
- X
- X eaop.oError = 0;
- X DosSetPathInfo(szName, FIL_QUERYEASIZE, (PBYTE) &eaop, sizeof(eaop), 0);
- X
- X if (!tflag && (qflag < 2))
- X PRINTF(" (%ld bytes EA's)", pFEA2list -> cbList);
- X
- X free(pFEA2list);
- X}
- X
- X
- Xulg SizeOfEAs(void *extra_field)
- X{
- X EAHEADER *pEAblock = (PEAHEADER)extra_field;
- X
- X if (extra_field != NULL && makeword((uch *)&pEAblock->nID) == EAID)
- X return makelong((uch *)&pEAblock->lSize);
- X
- X return 0L;
- X}
- X
- X
- X
- X
- X
- X#ifdef SFX
- X
- Xchar *GetLoadPath(void)
- X{
- X#ifdef __32BIT__ /* generic for 32-bit API */
- X
- X PTIB pptib;
- X PPIB pppib;
- X char *szPath;
- X
- X DosGetInfoBlocks(&pptib, &pppib);
- X szPath = pppib -> pib_pchenv;
- X
- X while (*szPath) /* find end of process environment */
- X szPath = strchr(szPath, 0) + 1;
- X
- X return szPath + 1; /* .exe file name follows environment */
- X
- X#else /* 16-bit, specific for MS C 6.00, note: requires large data model */
- X
- X extern char _far *_pgmptr;
- X return _pgmptr;
- X
- X#endif
- X} /* end function GetLoadPath() */
- X
- X
- X
- X
- X
- X#else /* !SFX */
- X
- XDIR *opendir(char *name)
- X{
- X struct stat statb;
- X DIR *dirp;
- X char c;
- X char *s;
- X struct _dircontents *dp;
- X char nbuf[MAXPATHLEN + 1];
- X int len;
- X
- X strcpy(nbuf, name);
- X if ((len = strlen(nbuf)) == 0)
- X return NULL;
- X
- X if ( ((c = nbuf[len - 1]) == '\\' || c == '/') && (len > 1) )
- X {
- X nbuf[len - 1] = 0;
- X --len;
- X
- X if ( nbuf[len - 1] == ':' )
- X {
- X strcpy(nbuf+len, "\\.");
- X len += 2;
- X }
- X }
- X else
- X if ( nbuf[len - 1] == ':' )
- X {
- X strcpy(nbuf+len, ".");
- X ++len;
- X }
- X
- X /* GRR: Borland and Watcom C return non-zero on wildcards... < 0 ? */
- X if (stat(nbuf, &statb) < 0 || (statb.st_mode & S_IFMT) != S_IFDIR)
- X {
- X Trace((stderr, "opendir: stat(%s) returns negative or not directory\n",
- X nbuf));
- X return NULL;
- X }
- X
- X if ( (dirp = malloc(sizeof(DIR))) == NULL )
- X return NULL;
- X
- X if ( nbuf[len - 1] == '.' && (len == 1 || nbuf[len - 2] != '.') )
- X strcpy(nbuf+len-1, "*");
- X else
- X if ( ((c = nbuf[len - 1]) == '\\' || c == '/') && (len == 1) )
- X strcpy(nbuf+len, "*");
- X else
- X strcpy(nbuf+len, "\\*");
- X
- X /* len is no longer correct (but no longer needed) */
- X Trace((stderr, "opendir: nbuf = [%s]\n", nbuf));
- X
- X dirp -> dd_loc = 0;
- X dirp -> dd_contents = dirp -> dd_cp = NULL;
- X
- X if ((s = getdirent(nbuf)) == NULL)
- X return dirp;
- X
- X do
- X {
- X if (((dp = malloc(sizeof(struct _dircontents))) == NULL) ||
- X ((dp -> _d_entry = malloc(strlen(s) + 1)) == NULL) )
- X {
- X if (dp)
- X free(dp);
- X free_dircontents(dirp -> dd_contents);
- X
- X return NULL;
- X }
- X
- X if (dirp -> dd_contents)
- X {
- X dirp -> dd_cp -> _d_next = dp;
- X dirp -> dd_cp = dirp -> dd_cp -> _d_next;
- X }
- X else
- X dirp -> dd_contents = dirp -> dd_cp = dp;
- X
- X strcpy(dp -> _d_entry, s);
- X dp -> _d_next = NULL;
- X
- X dp -> _d_size = find.cbFile;
- X dp -> _d_mode = find.attrFile;
- X dp -> _d_time = *(unsigned *) &(find.ftimeLastWrite);
- X dp -> _d_date = *(unsigned *) &(find.fdateLastWrite);
- X }
- X while ((s = getdirent(NULL)) != NULL);
- X
- X dirp -> dd_cp = dirp -> dd_contents;
- X
- X return dirp;
- X}
- X
- X
- Xvoid closedir(DIR * dirp)
- X{
- X free_dircontents(dirp -> dd_contents);
- X free(dirp);
- X}
- X
- X
- Xstruct direct *readdir(DIR * dirp)
- X{
- X static struct direct dp;
- X
- X if (dirp -> dd_cp == NULL)
- X return NULL;
- X
- X dp.d_namlen = dp.d_reclen =
- X strlen(strcpy(dp.d_name, dirp -> dd_cp -> _d_entry));
- X
- X dp.d_ino = 0;
- X
- X dp.d_size = dirp -> dd_cp -> _d_size;
- X dp.d_mode = dirp -> dd_cp -> _d_mode;
- X dp.d_time = dirp -> dd_cp -> _d_time;
- X dp.d_date = dirp -> dd_cp -> _d_date;
- X
- X dirp -> dd_cp = dirp -> dd_cp -> _d_next;
- X dirp -> dd_loc++;
- X
- X return &dp;
- X}
- X
- X
- X
- X#if 0 /* not used in unzip; retained for possibly future use */
- X
- Xvoid seekdir(DIR * dirp, long off)
- X{
- X long i = off;
- X struct _dircontents *dp;
- X
- X if (off >= 0)
- X {
- X for (dp = dirp -> dd_contents; --i >= 0 && dp; dp = dp -> _d_next);
- X
- X dirp -> dd_loc = off - (i + 1);
- X dirp -> dd_cp = dp;
- X }
- X}
- X
- X
- Xlong telldir(DIR * dirp)
- X{
- X return dirp -> dd_loc;
- X}
- X
- X#endif /* 0 */
- X
- X
- X
- Xstatic void free_dircontents(struct _dircontents * dp)
- X{
- X struct _dircontents *odp;
- X
- X while (dp)
- X {
- X if (dp -> _d_entry)
- X free(dp -> _d_entry);
- X
- X dp = (odp = dp) -> _d_next;
- X free(odp);
- X }
- X}
- X
- X
- Xstatic char *getdirent(char *dir)
- X{
- X int done;
- X static int lower;
- X
- X if (dir != NULL)
- X { /* get first entry */
- X hdir = HDIR_SYSTEM;
- X count = 1;
- X done = DosFindFirst(dir, &hdir, attributes, &find, sizeof(find), &count);
- X lower = IsFileSystemFAT(dir);
- X }
- X else /* get next entry */
- X done = DosFindNext(hdir, &find, sizeof(find), &count);
- X
- X if (done == 0)
- X {
- X if ( lower )
- X StringLower(find.achName);
- X return find.achName;
- X }
- X else
- X {
- X DosFindClose(hdir);
- X return NULL;
- X }
- X}
- X
- X
- X
- Xint IsFileSystemFAT(char *dir) /* FAT / HPFS detection */
- X{
- X static USHORT nLastDrive=(USHORT)(-1), nResult;
- X ULONG lMap;
- X BYTE bData[64], bName[3];
- X#ifdef __32BIT__
- X ULONG nDrive, cbData;
- X PFSQBUFFER2 pData = (PFSQBUFFER2) bData;
- X#else
- X USHORT nDrive, cbData;
- X PFSQBUFFER pData = (PFSQBUFFER) bData;
- X#endif
- X
- X if ( _osmode == DOS_MODE )
- X return TRUE;
- X else
- X {
- X /* We separate FAT and HPFS+other file systems here.
- X at the moment I consider other systems to be similar to HPFS,
- X i.e. support long file names and case sensitive */
- X
- X if ( isalpha(dir[0]) && (dir[1] == ':') )
- X nDrive = toupper(dir[0]) - '@';
- X else
- X DosQueryCurrentDisk(&nDrive, &lMap);
- X
- X if ( nDrive == nLastDrive )
- X return nResult;
- X
- X bName[0] = (char) (nDrive + '@');
- X bName[1] = ':';
- X bName[2] = 0;
- X
- X nLastDrive = nDrive;
- X cbData = sizeof(bData);
- X
- X if ( !DosQueryFSAttach(bName, 0, FSAIL_QUERYNAME, (PVOID) pData, &cbData) )
- X nResult = !strcmp(pData -> szFSDName + pData -> cbName, "FAT");
- X else
- X nResult = FALSE;
- X
- X /* End of this ugly code */
- X return nResult;
- X }
- X} /* end function IsFileSystemFAT() */
- X
- X
- X
- X
- X
- X/************************/
- X/* Function do_wild() */
- X/************************/
- X
- Xchar *do_wild(wildspec)
- X char *wildspec; /* only used first time on a given dir */
- X{
- X static DIR *dir = NULL;
- X static char *dirname, *wildname, matchname[FILNAMSIZ];
- X static int firstcall=TRUE, have_dirname, dirnamelen;
- X struct direct *file;
- X
- X
- X /* Even when we're just returning wildspec, we *always* do so in
- X * matchname[]--calling routine is allowed to append four characters
- X * to the returned string, and wildspec may be a pointer to argv[].
- X */
- X if (firstcall) { /* first call: must initialize everything */
- X firstcall = FALSE;
- X
- X /* break the wildspec into a directory part and a wildcard filename */
- X if ((wildname = strrchr(wildspec, '/')) == NULL &&
- X (wildname = strrchr(wildspec, ':')) == NULL) {
- X dirname = ".";
- X dirnamelen = 1;
- X have_dirname = FALSE;
- X wildname = wildspec;
- X } else {
- X ++wildname; /* point at character after '/' or ':' */
- X dirnamelen = wildname - wildspec;
- X if ((dirname = (char *)malloc(dirnamelen+1)) == NULL) {
- X FPRINTF(stderr, "warning: can't allocate wildcard buffers\n");
- X strcpy(matchname, wildspec);
- X return matchname; /* but maybe filespec was not a wildcard */
- X }
- X strncpy(dirname, wildspec, dirnamelen);
- X dirname[dirnamelen] = '\0'; /* terminate for strcpy below */
- X have_dirname = TRUE;
- X }
- X Trace((stderr, "do_wild: dirname = [%s]\n", dirname));
- X
- X if ((dir = opendir(dirname)) != NULL) {
- X while ((file = readdir(dir)) != NULL) {
- X Trace((stderr, "do_wild: readdir returns %s\n", file->d_name));
- X if (match(file->d_name, wildname, 1)) { /* 1 == ignore case */
- X Trace((stderr, "do_wild: match() succeeds\n"));
- X if (have_dirname) {
- X strcpy(matchname, dirname);
- X strcpy(matchname+dirnamelen, file->d_name);
- X } else
- X strcpy(matchname, file->d_name);
- X return matchname;
- X }
- X }
- X /* if we get to here directory is exhausted, so close it */
- X closedir(dir);
- X dir = NULL;
- X }
- X Trace((stderr, "do_wild: opendir(%s) returns NULL\n", dirname));
- X
- X /* return the raw wildspec in case that works (e.g., directory not
- X * searchable, but filespec was not wild and file is readable) */
- X strcpy(matchname, wildspec);
- X return matchname;
- X }
- X
- X /* last time through, might have failed opendir but returned raw wildspec */
- X if (dir == NULL) {
- X firstcall = TRUE; /* nothing left to try--reset for new wildspec */
- X if (have_dirname)
- X free(dirname);
- X return (char *)NULL;
- X }
- X
- X /* If we've gotten this far, we've read and matched at least one entry
- X * successfully (in a previous call), so dirname has been copied into
- X * matchname already.
- X */
- X while ((file = readdir(dir)) != NULL)
- X if (match(file->d_name, wildname, 1)) { /* 1 == ignore case */
- X if (have_dirname) {
- X /* strcpy(matchname, dirname); */
- X strcpy(matchname+dirnamelen, file->d_name);
- X } else
- X strcpy(matchname, file->d_name);
- X return matchname;
- X }
- X
- X closedir(dir); /* have read at least one dir entry; nothing left */
- X dir = NULL;
- X firstcall = TRUE; /* reset for new wildspec */
- X if (have_dirname)
- X free(dirname);
- X return (char *)NULL;
- X
- X} /* end function do_wild() */
- X
- X#endif /* !SFX */
- X
- X
- X
- X
- X
- X/************************/
- X/* Function mapattr() */
- X/************************/
- X
- Xint mapattr()
- X{
- X /* set archive bit (file is not backed up): */
- X pInfo->file_attr = (unsigned)(crec.external_file_attributes | 32) & 0xff;
- X return 0;
- X}
- X
- X
- X
- X
- X
- X/************************/
- X/* Function mapname() */
- X/************************/
- X
- X/*
- X * There are presently two possibilities in OS/2: the output filesystem is
- X * FAT, or it is HPFS. If the former, we need to map to FAT, obviously, but
- X * we *also* must map to HPFS and store that version of the name in extended
- X * attributes. Either way, we need to map to HPFS, so the main mapname
- X * routine does that. In the case that the output file system is FAT, an
- X * extra filename-mapping routine is called in checkdir(). While it should
- X * be possible to determine the filesystem immediately upon entry to mapname(),
- X * it is conceivable that the DOS APPEND utility could be added to OS/2 some-
- X * day, allowing a FAT directory to be APPENDed to an HPFS drive/path. There-
- X * fore we simply check the filesystem at each path component.
- X *
- X * Note that when alternative IFS's become available/popular, everything will
- X * become immensely more complicated. For example, a Minix filesystem would
- X * have limited filename lengths like FAT but no extended attributes in which
- X * to store the longer versions of the names. A BSD Unix filesystem would
- X * support paths of length 1024 bytes or more, but it is not clear that FAT
- X * EAs would allow such long .LONGNAME fields or that OS/2 would properly
- X * restore such fields when moving files from FAT to the new filesystem.
- X *
- X * GRR: some or all of the following chars should be checked in either
- X * mapname (HPFS) or map2fat (FAT), depending: ,=^+'"[]<>|\t&
- X */
- X
- Xint mapname(renamed) /* return 0 if no error, 1 if caution (filename trunc), */
- X int renamed; /* 2 if warning (skip file because dir doesn't exist), */
- X{ /* 3 if error (skip file), 10 if no memory (skip file), */
- X /* IZ_VOL_LABEL if can't do vol label, IZ_CREATED_DIR */
- X char pathcomp[FILNAMSIZ]; /* path-component buffer */
- X char *pp, *cp=(char *)NULL; /* character pointers */
- X char *lastsemi=(char *)NULL; /* pointer to last semi-colon in pathcomp */
- X int quote = FALSE; /* flag: next char is literal */
- X int error = 0;
- X register unsigned workch; /* hold the character being tested */
- X
- X
- X/*---------------------------------------------------------------------------
- X Initialize various pointers and counters and stuff.
- X ---------------------------------------------------------------------------*/
- X
- X /* can create path as long as not just freshening, or if user told us */
- X create_dirs = (!fflag || renamed);
- X
- X created_dir = FALSE; /* not yet */
- X renamed_fullpath = FALSE;
- X fnlen = strlen(filename);
- X
- X/* GRR: for VMS, convert to internal format now or later? or never? */
- X if (renamed) {
- X cp = filename - 1; /* point to beginning of renamed name... */
- X while (*++cp)
- X if (*cp == '\\') /* convert backslashes to forward */
- X *cp = '/';
- X cp = filename;
- X /* use temporary rootpath if user gave full pathname */
- X if (filename[0] == '/') {
- X renamed_fullpath = TRUE;
- X pathcomp[0] = '/'; /* copy the '/' and terminate */
- X pathcomp[1] = '\0';
- X ++cp;
- X } else if (isalpha(filename[0]) && filename[1] == ':') {
- X renamed_fullpath = TRUE;
- X pp = pathcomp;
- X *pp++ = *cp++; /* copy the "d:" (+ '/', possibly) */
- X *pp++ = *cp++;
- X if (*cp == '/')
- X *pp++ = *cp++; /* otherwise add "./"? */
- X *pp = '\0';
- X }
- X }
- X
- X /* pathcomp is ignored unless renamed_fullpath is TRUE: */
- X if ((error = checkdir(pathcomp, INIT)) != 0) /* initialize path buffer */
- X return error; /* ...unless no mem or vol label on hard disk */
- X
- X *pathcomp = '\0'; /* initialize translation buffer */
- X pp = pathcomp; /* point to translation buffer */
- X if (!renamed) { /* cp already set if renamed */
- X if (jflag) /* junking directories */
- X/* GRR: watch out for VMS version... */
- X cp = (char *)strrchr(filename, '/');
- X if (cp == (char *)NULL) /* no '/' or not junking dirs */
- X cp = filename; /* point to internal zipfile-member pathname */
- X else
- X ++cp; /* point to start of last component of path */
- X }
- X
- X/*---------------------------------------------------------------------------
- X Begin main loop through characters in filename.
- X ---------------------------------------------------------------------------*/
- X
- X while ((workch = (uch)*cp++) != 0) {
- X
- X if (quote) { /* if character quoted, */
- X *pp++ = (char)workch; /* include it literally */
- X quote = FALSE;
- X } else
- X switch (workch) {
- X case '/': /* can assume -j flag not given */
- X *pp = '\0';
- X if ((error = checkdir(pathcomp, APPEND_DIR)) > 1)
- X return error;
- X pp = pathcomp; /* reset conversion buffer for next piece */
- X lastsemi = (char *)NULL; /* leave directory semi-colons alone */
- X break;
- X
- X case ':':
- X *pp++ = '_'; /* drive names not stored in zipfile, */
- X break; /* so no colons allowed */
- X
- X case ';': /* start of VMS version? */
- X lastsemi = pp; /* remove VMS version later... */
- X *pp++ = ';'; /* but keep semicolon for now */
- X break;
- X
- X case '\026': /* control-V quote for special chars */
- X quote = TRUE; /* set flag for next character */
- X break;
- X
- X case ' ': /* keep spaces unless specifically */
- X if (sflag) /* requested to change to underscore */
- X *pp++ = '_';
- X else
- X *pp++ = ' ';
- X break;
- X
- X default:
- X /* allow European characters in filenames: */
- X if (isprint(workch) || (128 <= workch && workch <= 254))
- X *pp++ = (char)workch;
- X } /* end switch */
- X
- X } /* end while loop */
- X
- X *pp = '\0'; /* done with pathcomp: terminate it */
- X
- X /* if not saving them, remove VMS version numbers (appended "###") */
- X if (!V_flag && lastsemi) {
- X pp = lastsemi + 1; /* semi-colon was kept: expect #'s after */
- X while (isdigit((uch)(*pp)))
- X ++pp;
- X if (*pp == '\0') /* only digits between ';' and end: nuke */
- X *lastsemi = '\0';
- X }
- X
- X/*---------------------------------------------------------------------------
- X Report if directory was created (and no file to create: filename ended
- X in '/'), check name to be sure it exists, and combine path and name be-
- X fore exiting.
- X ---------------------------------------------------------------------------*/
- X
- X if (filename[fnlen-1] == '/') {
- X checkdir(filename, GETPATH);
- X if (created_dir && QCOND2) {
- X/* GRR: trailing '/'? need to strip or not? */
- X FPRINTF(stdout, " creating: %-22s\n", filename);
- X if (extra_field) /* zipfile extra field has extended attributes */
- X SetEAs(filename, extra_field);
- X SetPathInfo(filename, lrec.last_mod_file_date,
- X lrec.last_mod_file_time, -1);
- X return IZ_CREATED_DIR; /* dir time already set */
- X }
- X return 2; /* dir existed already; don't look for data to extract */
- X }
- X
- X if (*pathcomp == '\0') {
- X FPRINTF(stderr, "mapname: conversion of %s failed\n", filename);
- X return 3;
- X }
- X
- X checkdir(pathcomp, APPEND_NAME); /* returns 1 if truncated: care? */
- X checkdir(filename, GETPATH);
- X Trace((stderr, "mapname returns with filename = [%s] (error = %d)\n\n",
- X filename, error));
- X
- X if (pInfo->vollabel) { /* set the volume label now */
- X VOLUMELABEL FSInfoBuf;
- X/* GRR: "VOLUMELABEL" defined for IBM C and emx, but haven't checked MSC... */
- X
- X strcpy(FSInfoBuf.szVolLabel, filename);
- X FSInfoBuf.cch = (BYTE)strlen(FSInfoBuf.szVolLabel);
- X
- X if (QCOND2)
- X FPRINTF(stdout, "labelling %c: %-22s\n",
- X (char)(nLabelDrive + 'a' - 1), filename);
- X if (DosSetFSInfo(nLabelDrive, FSIL_VOLSER, (PBYTE)&FSInfoBuf,
- X sizeof(VOLUMELABEL)))
- X {
- X FPRINTF(stderr, "mapname: error setting volume label\n");
- X return 3;
- X }
- X return 2; /* success: skip the "extraction" quietly */
- X }
- X
- X return error;
- X
- X} /* end function mapname() */
- X
- X
- X
- X
- X
- X/***********************/
- X/* Function checkdir() */
- X/***********************/
- X
- Xint checkdir(pathcomp, flag)
- X char *pathcomp;
- X int flag;
- X/*
- X * returns: 1 - (on APPEND_NAME) truncated filename
- X * 2 - path doesn't exist, not allowed to create
- X * 3 - path doesn't exist, tried to create and failed; or
- X * path exists and is not a directory, but is supposed to be
- X * 4 - path is too long
- X * 10 - can't allocate memory for filename buffers
- X */
- X{
- X static int rootlen = 0; /* length of rootpath */
- X static char *rootpath; /* user's "extract-to" directory */
- X static char *buildpathHPFS; /* full path (so far) to extracted file, */
- X static char *buildpathFAT; /* both HPFS/EA (main) and FAT versions */
- X static char *endHPFS; /* corresponding pointers to end of */
- X static char *endFAT; /* buildpath ('\0') */
- X
- X# define FN_MASK 7
- X# define FUNCTION (flag & FN_MASK)
- X
- X
- X
- X/*---------------------------------------------------------------------------
- X APPEND_DIR: append the path component to the path being built and check
- X for its existence. If doesn't exist and we are creating directories, do
- X so for this one; else signal success or error as appropriate.
- X ---------------------------------------------------------------------------*/
- X
- X if (FUNCTION == APPEND_DIR) {
- X char *p = pathcomp;
- X int longdirEA, too_long=FALSE;
- X
- X Trace((stderr, "appending dir segment [%s]\n", pathcomp));
- X while ((*endHPFS = *p++) != '\0') /* copy to HPFS filename */
- X ++endHPFS;
- X if (IsFileNameValid(buildpathHPFS)) {
- X longdirEA = FALSE;
- X p = pathcomp;
- X while ((*endFAT = *p++) != '\0') /* copy to FAT filename, too */
- X ++endFAT;
- X } else {
- X longdirEA = TRUE;
- X/* GRR: check error return? */
- X map2fat(pathcomp, &endFAT); /* map, put in FAT fn, update endFAT */
- X }
- X
- X /* GRR: could do better check, see if overrunning buffer as we go:
- X * check endHPFS-buildpathHPFS after each append, set warning variable
- X * if within 20 of FILNAMSIZ; then if var set, do careful check when
- X * appending. Clear variable when begin new path. */
- X
- X /* next check: need to append '/', at least one-char name, '\0' */
- X if ((endHPFS-buildpathHPFS) > FILNAMSIZ-3)
- X too_long = TRUE; /* check if extracting dir? */
- X#ifdef MSC /* MSC 6.00 bug: stat(non-existent-dir) == 0 [exists!] */
- X if (GetFileTime(buildpathFAT) == -1 || stat(buildpathFAT, &statbuf))
- X#else
- X if (stat(buildpathFAT, &statbuf)) /* path doesn't exist */
- X#endif
- X {
- X if (!create_dirs) { /* told not to create (freshening) */
- X free(buildpathHPFS);
- X free(buildpathFAT);
- X return 2; /* path doesn't exist: nothing to do */
- X }
- X if (too_long) { /* GRR: should allow FAT extraction w/o EAs */
- X FPRINTF(stderr, "checkdir error: path too long: %s\n",
- X buildpathHPFS);
- X fflush(stderr);
- X free(buildpathHPFS);
- X free(buildpathFAT);
- X return 4; /* no room for filenames: fatal */
- X }
- X if (MKDIR(buildpathFAT, 0777) == -1) { /* create the directory */
- X FPRINTF(stderr, "checkdir error: can't create %s\n\
- X unable to process %s.\n", buildpathFAT, filename);
- X fflush(stderr);
- X free(buildpathHPFS);
- X free(buildpathFAT);
- X return 3; /* path didn't exist, tried to create, failed */
- X }
- X created_dir = TRUE;
- X /* only set EA if creating directory */
- X/* GRR: need trailing '/' before function call? */
- X if (longdirEA) {
- X#ifdef DEBUG
- X int e =
- X#endif
- X SetLongNameEA(buildpathFAT, pathcomp);
- X Trace((stderr, "APPEND_DIR: SetLongNameEA() returns %d\n", e));
- X }
- X } else if (!S_ISDIR(statbuf.st_mode)) {
- X FPRINTF(stderr, "checkdir error: %s exists but is not directory\n\
- X unable to process %s.\n", buildpathFAT, filename);
- X fflush(stderr);
- X free(buildpathHPFS);
- X free(buildpathFAT);
- X return 3; /* path existed but wasn't dir */
- X }
- X if (too_long) {
- X FPRINTF(stderr, "checkdir error: path too long: %s\n",
- X buildpathHPFS);
- X fflush(stderr);
- X free(buildpathHPFS);
- X free(buildpathFAT);
- X return 4; /* no room for filenames: fatal */
- X }
- X *endHPFS++ = '/';
- X *endFAT++ = '/';
- X *endHPFS = *endFAT = '\0';
- X Trace((stderr, "buildpathHPFS now = [%s]\n", buildpathHPFS));
- X Trace((stderr, "buildpathFAT now = [%s]\n", buildpathFAT));
- X return 0;
- X
- X } /* end if (FUNCTION == APPEND_DIR) */
- X
- X/*---------------------------------------------------------------------------
- X GETPATH: copy full FAT path to the string pointed at by pathcomp (want
- X filename to reflect name used on disk, not EAs; if full path is HPFS,
- X buildpathFAT and buildpathHPFS will be identical). Also free both paths.
- X ---------------------------------------------------------------------------*/
- X
- X if (FUNCTION == GETPATH) {
- X Trace((stderr, "getting and freeing FAT path [%s]\n", buildpathFAT));
- X Trace((stderr, "freeing HPFS path [%s]\n", buildpathHPFS));
- X strcpy(pathcomp, buildpathFAT);
- X free(buildpathFAT);
- X free(buildpathHPFS);
- X buildpathHPFS = buildpathFAT = endHPFS = endFAT = (char *)NULL;
- X return 0;
- X }
- X
- X/*---------------------------------------------------------------------------
- X APPEND_NAME: assume the path component is the filename; append it and
- X return without checking for existence.
- X ---------------------------------------------------------------------------*/
- X
- X if (FUNCTION == APPEND_NAME) {
- X char *p = pathcomp;
- X int error = 0;
- X
- X Trace((stderr, "appending filename [%s]\n", pathcomp));
- X while ((*endHPFS = *p++) != '\0') { /* copy to HPFS filename */
- X ++endHPFS;
- X if ((endHPFS-buildpathHPFS) >= FILNAMSIZ) {
- X *--endHPFS = '\0';
- X FPRINTF(stderr, "checkdir warning: path too long; truncating\n\
- X %s\n -> %s\n", filename, buildpathHPFS);
- X fflush(stderr);
- X error = 1; /* filename truncated */
- X }
- X }
- X
- X/* GRR: how can longnameEA ever be set before this point??? we don't want
- X * to save the original name to EAs if user renamed it, do we?
- X *
- X * if (!longnameEA && ((longnameEA = !IsFileNameValid(name)) != 0))
- X */
- X if (pInfo->vollabel || IsFileNameValid(buildpathHPFS)) {
- X longnameEA = FALSE;
- X p = pathcomp;
- X while ((*endFAT = *p++) != '\0') /* copy to FAT filename, too */
- X ++endFAT;
- X } else {
- X longnameEA = TRUE;
- X if ((lastpathcomp = (char *)malloc(strlen(pathcomp)+1)) ==
- X (char *)NULL)
- X {
- X FPRINTF(stderr,
- X "checkdir warning: can't save longname EA: out of memory\n");
- X longnameEA = FALSE;
- X error = 1; /* can't set .LONGNAME extended attribute */
- X } else /* used and freed in close_outfile() */
- X strcpy(lastpathcomp, pathcomp);
- X map2fat(pathcomp, &endFAT); /* map, put in FAT fn, update endFAT */
- X }
- X Trace((stderr, "buildpathHPFS: %s\nbuildpathFAT: %s\n",
- X buildpathHPFS, buildpathFAT));
- X
- X return error; /* could check for existence, prompt for new name... */
- X
- X } /* end if (FUNCTION == APPEND_NAME) */
- X
- X/*---------------------------------------------------------------------------
- X INIT: allocate and initialize buffer space for the file currently being
- X extracted. If file was renamed with an absolute path, don't prepend the
- X extract-to path.
- X ---------------------------------------------------------------------------*/
- X
- X if (FUNCTION == INIT) {
- X Trace((stderr, "initializing buildpathHPFS and buildpathFAT to "));
- X if ((buildpathHPFS = (char *)malloc(fnlen+rootlen+1)) == (char *)NULL)
- X return 10;
- X if ((buildpathFAT = (char *)malloc(fnlen+rootlen+1)) == (char *)NULL) {
- X free(buildpathHPFS);
- X return 10;
- X }
- X if (pInfo->vollabel) { /* use root or renamed path, but don't store */
- X/* GRR: for network drives, do strchr() and return IZ_VOL_LABEL if not [1] */
- X if (renamed_fullpath && pathcomp[1] == ':')
- X *buildpathHPFS = ToLower(*pathcomp);
- X else if (!renamed_fullpath && rootpath && rootpath[1] == ':')
- X *buildpathHPFS = ToLower(*rootpath);
- X else {
- X ULONG lMap;
- X DosQueryCurrentDisk(&nLabelDrive, &lMap);
- X *buildpathHPFS = (char)(nLabelDrive - 1 + 'a');
- X }
- X nLabelDrive = *buildpathHPFS - 'a' + 1; /* save for mapname() */
- X if (volflag == 0 || *buildpathHPFS < 'a' || /* no labels/bogus? */
- X (volflag == 1 && !isfloppy(nLabelDrive))) { /* -$: no fixed */
- X free(buildpathHPFS);
- X free(buildpathFAT);
- X return IZ_VOL_LABEL; /* skipping with message */
- X }
- X *buildpathHPFS = '\0';
- X } else if (renamed_fullpath) /* pathcomp = valid data */
- X strcpy(buildpathHPFS, pathcomp);
- X else if (rootlen > 0)
- X strcpy(buildpathHPFS, rootpath);
- X else
- X *buildpathHPFS = '\0';
- X endHPFS = buildpathHPFS;
- X endFAT = buildpathFAT;
- X while ((*endFAT = *endHPFS) != '\0') {
- X ++endFAT;
- X ++endHPFS;
- X }
- X Trace((stderr, "[%s]\n", buildpathHPFS));
- X return 0;
- X }
- X
- X/*---------------------------------------------------------------------------
- X ROOT: if appropriate, store the path in rootpath and create it if neces-
- X sary; else assume it's a zipfile member and return. This path segment
- X gets used in extracting all members from every zipfile specified on the
- X command line. Note that under OS/2 and MS-DOS, if a candidate extract-to
- X directory specification includes a drive letter (leading "x:"), it is
- X treated just as if it had a trailing '/'--that is, one directory level
- X will be created if the path doesn't exist, unless this is otherwise pro-
- X hibited (e.g., freshening).
- X ---------------------------------------------------------------------------*/
- X
- X#if (!defined(SFX) || defined(SFX_EXDIR))
- X if (FUNCTION == ROOT) {
- X Trace((stderr, "initializing root path to [%s]\n", pathcomp));
- X if (pathcomp == (char *)NULL) {
- X rootlen = 0;
- X return 0;
- X }
- X if ((rootlen = strlen(pathcomp)) > 0) {
- X int had_trailing_pathsep=FALSE, has_drive=FALSE, xtra=2;
- X
- X if (isalpha(pathcomp[0]) && pathcomp[1] == ':')
- X has_drive = TRUE; /* drive designator */
- X if (pathcomp[rootlen-1] == '/') {
- X pathcomp[--rootlen] = '\0';
- X had_trailing_pathsep = TRUE;
- X }
- X if (has_drive && (rootlen == 2)) {
- X if (!had_trailing_pathsep) /* i.e., original wasn't "x:/" */
- X xtra = 3; /* room for '.' + '/' + 0 at end of "x:" */
- X } else if (rootlen > 0) { /* need not check "x:." and "x:/" */
- X#ifdef MSC /* MSC 6.00 bug: stat(non-existent-dir) == 0 [exists!] */
- X if (GetFileTime(pathcomp) == -1 ||
- X SSTAT(pathcomp, &statbuf) || !S_ISDIR(statbuf.st_mode))
- X#else
- X if (SSTAT(pathcomp, &statbuf) || !S_ISDIR(statbuf.st_mode))
- X#endif
- X { /* path does not exist */
- X if (!create_dirs /* || iswild(pathcomp) */
- X#ifdef OLD_EXDIR
- X || (!has_drive && !had_trailing_pathsep)
- X#endif
- X ) {
- X rootlen = 0;
- X return 2; /* treat as stored file */
- X }
- X /* create directory (could add loop here to scan pathcomp
- X * and create more than one level, but really necessary?) */
- X if (MKDIR(pathcomp, 0777) == -1) {
- X FPRINTF(stderr,
- X "checkdir: can't create extraction directory: %s\n",
- X pathcomp);
- X fflush(stderr);
- X rootlen = 0; /* path didn't exist, tried to create, */
- X return 3; /* failed: file exists, or need 2+ levels */
- X }
- X }
- X }
- X if ((rootpath = (char *)malloc(rootlen+xtra)) == (char *)NULL) {
- X rootlen = 0;
- X return 10;
- X }
- X strcpy(rootpath, pathcomp);
- X if (xtra == 3) /* had just "x:", make "x:." */
- X rootpath[rootlen++] = '.';
- X rootpath[rootlen++] = '/';
- X rootpath[rootlen] = '\0';
- X }
- X Trace((stderr, "rootpath now = [%s]\n", rootpath));
- X return 0;
- X }
- X#endif /* !SFX || SFX_EXDIR */
- X
- X/*---------------------------------------------------------------------------
- X END: free rootpath, immediately prior to program exit.
- X ---------------------------------------------------------------------------*/
- X
- X if (FUNCTION == END) {
- X Trace((stderr, "freeing rootpath\n"));
- X if (rootlen > 0)
- X free(rootpath);
- X return 0;
- X }
- X
- X return 99; /* should never reach */
- X
- X} /* end function checkdir() */
- X
- X
- X
- X
- X
- X/***********************/
- X/* Function isfloppy() */ /* more precisely, is it removable? */
- X/***********************/
- X
- Xstatic int isfloppy(nDrive)
- X int nDrive; /* 1 == A:, 2 == B:, etc. */
- X{
- X uch ParmList[1] = {0};
- X uch DataArea[1] = {0};
- X char Name[3];
- X HFILE handle;
- X#ifdef __32BIT__
- X ULONG rc;
- X ULONG action;
- X#else
- X USHORT rc;
- X UINT action;
- X#endif
- X
- X
- X Name[0] = (char) (nDrive + 'A' - 1);
- X Name[1] = ':';
- X Name[2] = 0;
- X
- X rc = DosOpen(Name, &handle, &action, 0L, FILE_NORMAL, FILE_OPEN,
- X OPEN_FLAGS_DASD | OPEN_FLAGS_FAIL_ON_ERROR |
- X OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE, 0L);
- X
- X if (rc == ERROR_NOT_READY) /* must be removable */
- X return TRUE;
- X else if (rc) { /* other error: do default a/b heuristic instead */
- X Trace((stderr, "error in DosOpen(DASD): guessing...\n", rc));
- X return (nDrive == 1 || nDrive == 2)? TRUE : FALSE;
- X }
- X
- X rc = DosDevIOCtl(DataArea, sizeof(DataArea), ParmList, sizeof(ParmList),
- X DSK_BLOCKREMOVABLE, IOCTL_DISK, handle);
- X DosClose(handle);
- X
- X if (rc) { /* again, just check for a/b */
- X Trace((stderr, "error in DosDevIOCtl category IOCTL_DISK, function "
- X "DSK_BLOCKREMOVABLE\n (rc = 0x%04x): guessing...\n", rc));
- X return (nDrive == 1 || nDrive == 2)? TRUE : FALSE;
- X } else {
- X return DataArea[0] ? FALSE : TRUE;
- X }
- X} /* end function isfloppy() */
- X
- X
- X
- X
- X
- Xint IsFileNameValid(char *name)
- X{
- X HFILE hf;
- X#ifdef __32BIT__
- X ULONG uAction;
- X#else
- X USHORT uAction;
- X#endif
- X
- X switch( DosOpen(name, &hf, &uAction, 0, 0, FILE_OPEN,
- X OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE, 0) )
- X {
- X case ERROR_INVALID_NAME:
- X case ERROR_FILENAME_EXCED_RANGE:
- X return FALSE;
- X case NO_ERROR:
- X DosClose(hf);
- X default:
- X return TRUE;
- X }
- X}
- X
- X
- X
- X
- X
- X/**********************/
- X/* Function map2fat() */
- X/**********************/
- X
- Xvoid map2fat(pathcomp, pEndFAT)
- X char *pathcomp, **pEndFAT;
- X{
- X char *ppc = pathcomp; /* variable pointer to pathcomp */
- X char *pEnd = *pEndFAT; /* variable pointer to buildpathFAT */
- X char *pBegin = *pEndFAT; /* constant pointer to start of this comp. */
- X char *last_dot = (char *)NULL; /* last dot not converted to underscore */
- X int dotname = FALSE; /* flag: path component begins with dot */
- X /* ("." and ".." don't count) */
- X register unsigned workch; /* hold the character being tested */
- X
- X
- X /* Only need check those characters which are legal in HPFS but not
- X * in FAT: to get here, must already have passed through mapname.
- X * (GRR: oops, small bug--if char was quoted, no longer have any
- X * knowledge of that.) Also must truncate path component to ensure
- X * 8.3 compliance...
- X */
- X while ((workch = (uch)*ppc++) != 0) {
- X switch (workch) {
- X case '[':
- X case ']':
- X *pEnd++ = '_'; /* convert brackets to underscores */
- X break;
- X
- X case '.':
- X if (pEnd == *pEndFAT) { /* nothing appended yet... */
- X if (*ppc == '\0') /* don't bother appending a */
- X break; /* "./" component to the path */
- X else if (*ppc == '.' && ppc[1] == '\0') { /* "../" */
- X *pEnd++ = '.'; /* add first dot, unchanged... */
- X ++ppc; /* skip second dot, since it will */
- X } else { /* be "added" at end of if-block */
- X *pEnd++ = '_'; /* FAT doesn't allow null filename */
- X dotname = TRUE; /* bodies, so map .exrc -> _.exrc */
- X } /* (extra '_' now, "dot" below) */
- X } else if (dotname) { /* found a second dot, but still */
- X dotname = FALSE; /* have extra leading underscore: */
- X *pEnd = '\0'; /* remove it by shifting chars */
- X pEnd = *pEndFAT + 1; /* left one space (e.g., .p1.p2: */
- X while (pEnd[1]) { /* __p1 -> _p1_p2 -> _p1.p2 when */
- X *pEnd = pEnd[1]; /* finished) [opt.: since first */
- X ++pEnd; /* two chars are same, can start */
- X } /* shifting at second position] */
- X }
- X last_dot = pEnd; /* point at last dot so far... */
- X *pEnd++ = '_'; /* convert dot to underscore for now */
- X break;
- X
- X default:
- X *pEnd++ = (char)workch;
- X
- X } /* end switch */
- X } /* end while loop */
- X
- X *pEnd = '\0'; /* terminate buildpathFAT */
- X
- X /* NOTE: keep in mind that pEnd points to the end of the path
- X * component, and *pEndFAT still points to the *beginning* of it...
- X * Also note that the algorithm does not try to get too fancy:
- X * if there are no dots already, the name either gets truncated
- X * at 8 characters or the last underscore is converted to a dot
- X * (only if more characters are saved that way). In no case is
- X * a dot inserted between existing characters.
- X */
- X if (last_dot == (char *)NULL) { /* no dots: check for underscores... */
- X char *plu = strrchr(pBegin, '_'); /* pointer to last underscore */
- X
- X if (plu == (char *)NULL) { /* no dots, no underscores: truncate at 8 */
- X *pEndFAT += 8; /* chars (or could insert '.' and keep 11?) */
- X if (*pEndFAT > pEnd)
- X *pEndFAT = pEnd; /* oops...didn't have 8 chars to truncate */
- X else
- X **pEndFAT = '\0';
- X } else if (MIN(plu - pBegin, 8) + MIN(pEnd - plu - 1, 3) > 8) {
- X last_dot = plu; /* be lazy: drop through to next if-blk */
- X } else if ((pEnd - *pEndFAT) > 8) {
- X *pEndFAT += 8; /* more fits into just basename than if */
- X **pEndFAT = '\0'; /* convert last underscore to dot */
- X } else
- X *pEndFAT = pEnd; /* whole thing fits into 8 chars or less */
- X }
- X
- X if (last_dot != (char *)NULL) { /* one dot (or two, in the case of */
- X *last_dot = '.'; /* "..") is OK: put it back in */
- X
- X if ((last_dot - pBegin) > 8) {
- X char *p=last_dot, *q=pBegin+8;
- X int i;
- X
- X for (i = 0; (i < 4) && *p; ++i) /* too many chars in basename: */
- X *q++ = *p++; /* shift .ext left and trun- */
- X *q = '\0'; /* cate/terminate it */
- X *pEndFAT = q;
- X } else if ((pEnd - last_dot) > 4) { /* too many chars in extension */
- X *pEndFAT = last_dot + 4;
- X **pEndFAT = '\0';
- X } else
- X *pEndFAT = pEnd; /* filename is fine; point at terminating zero */
- X }
- X} /* end function map2fat() */
- X
- X
- X
- X
- X
- Xint SetLongNameEA(char *name, char *longname)
- X{
- X EAOP eaop;
- X FEALST fealst;
- X
- X eaop.fpFEAList = (PFEALIST) &fealst;
- X eaop.fpGEAList = NULL;
- X eaop.oError = 0;
- X
- X strcpy(fealst.szName, ".LONGNAME");
- X strcpy(fealst.szValue, longname);
- X
- X fealst.cbList = sizeof(fealst) - CCHMAXPATH + strlen(fealst.szValue);
- X fealst.cbName = (BYTE) strlen(fealst.szName);
- X fealst.cbValue = sizeof(USHORT) * 2 + strlen(fealst.szValue);
- X
- X#ifdef __32BIT__
- X fealst.oNext = 0;
- X#endif
- X fealst.fEA = 0;
- X fealst.eaType = 0xFFFD;
- X fealst.eaSize = strlen(fealst.szValue);
- X
- X return DosSetPathInfo(name, FIL_QUERYEASIZE,
- X (PBYTE) &eaop, sizeof(eaop), 0);
- X}
- X
- X
- X
- X
- X
- X/****************************/
- X/* Function close_outfile() */
- X/****************************/
- X
- Xvoid close_outfile() /* only for extracted files, not directories */
- X{
- X fclose(outfile);
- X
- X /* set extra fields, both stored-in-zipfile and .LONGNAME flavors */
- X if (extra_field)
- X SetEAs(filename, extra_field);
- X
- X if (longnameEA) {
- X#ifdef DEBUG
- X int e =
- X#endif
- X SetLongNameEA(filename, lastpathcomp);
- X Trace((stderr, "close_outfile: SetLongNameEA() returns %d\n", e));
- X free(lastpathcomp);
- X }
- X
- X /* set date/time and permissions */
- X SetPathInfo(filename, lrec.last_mod_file_date,
- X lrec.last_mod_file_time, pInfo->file_attr);
- X
- X} /* end function close_outfile() */
- X
- X
- X
- X
- X
- X/******************************/
- X/* Function check_for_newer() */
- X/******************************/
- X
- Xint check_for_newer(filename) /* return 1 if existing file newer or equal; */
- X char *filename; /* 0 if older; -1 if doesn't exist yet */
- X{
- X long existing, archive;
- X
- X if ((existing = GetFileTime(filename)) == -1)
- X return DOES_NOT_EXIST;
- X archive = ((long) lrec.last_mod_file_date) << 16 | lrec.last_mod_file_time;
- X
- X return (existing >= archive);
- X}
- X
- X
- X
- X
- X
- X#ifndef SFX
- X
- X/*************************/
- X/* Function dateformat() */
- X/*************************/
- X
- Xint dateformat()
- X{
- X/*-----------------------------------------------------------------------------
- X For those operating systems which support it, this function returns a value
- X which tells how national convention says that numeric dates are displayed.
- X Return values are DF_YMD, DF_DMY and DF_MDY.
- X -----------------------------------------------------------------------------*/
- X
- X switch (GetCountryInfo()) {
- X case 0:
- X return DF_MDY;
- X case 1:
- X return DF_DMY;
- X case 2:
- X return DF_YMD;
- X }
- X return DF_MDY; /* default if error */
- X
- X} /* end function dateformat() */
- X
- X
- X
- X
- X
- X/************************/
- X/* Function version() */
- X/************************/
- X
- Xvoid version()
- X{
- X extern char Far CompiledWith[];
- X#if defined(__IBMC__) || defined(__WATCOMC__) || defined(_MSC_VER)
- X char buf[80];
- X#endif
- X
- X PRINTF(LoadFarString(CompiledWith),
- X
- X#ifdef __GNUC__
- X# ifdef __EMX__ /* __EMX__ is defined as "1" only (sigh) */
- X "emx+gcc ", __VERSION__,
- X# else
- X "gcc/2 ", __VERSION__,
- X# endif
- X#else
- X#ifdef __IBMC__
- X "IBM C Set/2", (sprintf(buf, " %d.%02d", __IBMC__/100,__IBMC__%100), buf),
- X#else
- X#ifdef __WATCOMC__
- X "Watcom C", (sprintf(buf, " (__WATCOMC__ = %d)", __WATCOMC__), buf),
- X#else
- X#ifdef __TURBOC__
- X# ifdef __BORLANDC__
- X "Borland C++",
- X# if (__BORLANDC__ < 0x0200)
- X " 1.0",
- X# else
- X# if (__BORLANDC__ == 0x0200)
- X " 2.0",
- X# else
- X# if (__BORLANDC__ == 0x0400)
- X " 3.0",
- X# else
- X# if (__BORLANDC__ == 0x0410)
- X " 3.1",
- X# else
- X " later than 3.1",
- X# endif
- X# endif
- X# endif
- X# endif
- X# else
- X "Turbo C",
- X# if (__TURBOC__ >= 661)
- X "++ 1.0 or later",
- X# else
- X# if (__TURBOC__ == 661)
- X " 3.0?",
- X# else
- X# if (__TURBOC__ == 397)
- X " 2.0",
- X# else
- X " 1.0 or 1.5?",
- X# endif
- X# endif
- X# endif
- X# endif
- X#else
- X#ifdef MSC
- X "Microsoft C ",
- X# ifdef _MSC_VER
- X (sprintf(buf, "%d.%02d", _MSC_VER/100, _MSC_VER%100), buf),
- X# else
- X "5.1 or earlier",
- X# endif
- X#else
- X "unknown compiler", "",
- X#endif /* MSC */
- X#endif /* __TURBOC__ */
- X#endif /* __WATCOMC__ */
- X#endif /* __IBMC__ */
- X#endif /* __GNUC__ */
- X
- X "OS/2",
- X
- X/* GRR: does IBM C/2 identify itself as IBM rather than Microsoft? */
- X#if (defined(MSC) || (defined(__WATCOMC__) && !defined(__386__)))
- X# if defined(M_I86HM) || defined(__HUGE__)
- X " (16-bit, huge)",
- X# else
- X# if defined(M_I86LM) || defined(__LARGE__)
- X " (16-bit, large)",
- X# else
- X# if defined(M_I86MM) || defined(__MEDIUM__)
- X " (16-bit, medium)",
- X# else
- X# if defined(M_I86CM) || defined(__COMPACT__)
- X " (16-bit, compact)",
- X# else
- X# if defined(M_I86SM) || defined(__SMALL__)
- X " (16-bit, small)",
- X# else
- X# if defined(M_I86TM) || defined(__TINY__)
- X " (16-bit, tiny)",
- X# else
- X " (16-bit)",
- X# endif
- X# endif
- X# endif
- X# endif
- X# endif
- X# endif
- X#else
- X " 2.x (32-bit)",
- X#endif
- X
- X#ifdef __DATE__
- X " on ", __DATE__
- X#else
- X "", ""
- X#endif
- X );
- X
- X /* temporary debugging code for Borland compilers only */
- X#ifdef __TURBOC__
- X PRINTF("\t(__TURBOC__ = 0x%04x = %d)\n", __TURBOC__, __TURBOC__);
- X#ifdef __BORLANDC__
- X PRINTF("\t(__BORLANDC__ = 0x%04x)\n", __BORLANDC__);
- X#else
- X PRINTF("\tdebug(__BORLANDC__ not defined)\n");
- X#endif
- X#ifdef __TCPLUSPLUS__
- X PRINTF("\t(__TCPLUSPLUS__ = 0x%04x)\n", __TCPLUSPLUS__);
- X#else
- X PRINTF("\tdebug(__TCPLUSPLUS__ not defined)\n");
- X#endif
- X#ifdef __BCPLUSPLUS__
- X PRINTF("\t(__BCPLUSPLUS__ = 0x%04x)\n\n", __BCPLUSPLUS__);
- X#else
- X PRINTF("\tdebug(__BCPLUSPLUS__ not defined)\n\n");
- X#endif
- X#endif /* __TURBOC__ */
- X
- X} /* end function version() */
- X
- X#endif /* !SFX */
- X
- X
- X
- X
- X
- Xstatic unsigned char cUpperCase[256], cLowerCase[256];
- Xstatic BOOL bInitialized;
- X
- X/* Initialize the tables of upper- and lowercase characters, including
- X handling of country-dependent characters. */
- X
- Xstatic void InitNLS(void)
- X{
- X unsigned nCnt, nU;
- X COUNTRYCODE cc;
- X
- X bInitialized = TRUE;
- X
- X for ( nCnt = 0; nCnt < 256; nCnt++ )
- X cUpperCase[nCnt] = cLowerCase[nCnt] = (unsigned char) nCnt;
- X
- X cc.country = cc.codepage = 0;
- X DosMapCase(sizeof(cUpperCase), &cc, (PCHAR) cUpperCase);
- X
- X for ( nCnt = 0; nCnt < 256; nCnt++ )
- X {
- X nU = cUpperCase[nCnt];
- X if (nU != nCnt && cLowerCase[nU] == (unsigned char) nU)
- X cLowerCase[nU] = (unsigned char) nCnt;
- X }
- X
- X for ( nCnt = 'A'; nCnt <= 'Z'; nCnt++ )
- X cLowerCase[nCnt] = (unsigned char) (nCnt - 'A' + 'a');
- X}
- X
- X
- Xint IsUpperNLS(int nChr)
- X{
- X if (!bInitialized)
- X InitNLS();
- X return (cUpperCase[nChr] == (unsigned char) nChr);
- X}
- X
- X
- Xint ToLowerNLS(int nChr)
- X{
- X if (!bInitialized)
- X InitNLS();
- X return cLowerCase[nChr];
- X}
- X
- X
- Xchar *StringLower(char *szArg)
- X{
- X unsigned char *szPtr;
- X
- X if (!bInitialized)
- X InitNLS();
- X for ( szPtr = szArg; *szPtr; szPtr++ )
- X *szPtr = cLowerCase[*szPtr];
- X return szArg;
- X}
- X
- X
- X#if defined(__IBMC__) && defined(__DEBUG_ALLOC__)
- Xvoid DebugMalloc(void)
- X{
- X _dump_allocated(0); /* print out debug malloc memory statistics */
- X}
- X#endif
- END_OF_FILE
- if test 57190 -ne `wc -c <'unzip-5.12/os2/os2.c'`; then
- echo shar: \"'unzip-5.12/os2/os2.c'\" unpacked with wrong size!
- fi
- # end of 'unzip-5.12/os2/os2.c'
- fi
- echo shar: End of archive 5 \(of 20\).
- cp /dev/null ark5isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 20 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-