home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume23 / zip / part09 < prev    next >
Text File  |  1991-10-21  |  42KB  |  1,309 lines

  1. Newsgroups: comp.sources.misc
  2. From: kirsch@usasoc.soc.mil (David Kirschbaum)
  3. Subject:  v23i096:  zip - Portable zip v1.0, Part09/09
  4. Message-ID: <1991Oct21.042253.8320@sparky.imd.sterling.com>
  5. X-Md4-Signature: 257e761b177443508ff2a00c7da97aaa
  6. Date: Mon, 21 Oct 1991 04:22:53 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: kirsch@usasoc.soc.mil (David Kirschbaum)
  10. Posting-number: Volume 23, Issue 96
  11. Archive-name: zip/part09
  12. Environment: UNIX, Minix, MSDOS, OS/2, VMS
  13.  
  14. #! /bin/sh
  15. # into a shell via "sh file" or similar.  To overwrite existing files,
  16. # type "sh file -c".
  17. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  18. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  19. # Contents:  INFOZIP.WHO crypt.h dir_os2.h globals.c makecrc.c makefile
  20. #   makefile.bor makefile.msc revision.h tailor.h tempf.c tempf.h
  21. # Wrapped by kent@sparky on Sun Oct 20 22:58:57 1991
  22. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  23. echo If this archive is complete, you will see the following message:
  24. echo '          "shar: End of archive 9 (of 9)."'
  25. if test -f 'INFOZIP.WHO' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'INFOZIP.WHO'\"
  27. else
  28.   echo shar: Extracting \"'INFOZIP.WHO'\" \(4521 characters\)
  29.   sed "s/^X//" >'INFOZIP.WHO' <<'END_OF_FILE'
  30. XThese members of the INFO-ZIP group contributed to the development and
  31. Xtesting of portable Zip.  They are responsible for whatever works in Zip.
  32. XWhatever doesn't work is solely the fault of the authors of Zip (Mark Adler,
  33. XRich Wales, and Jean-loup Gailly).
  34. X
  35. XMark Adler              madler@tybalt.caltech.edu       NeXT 2.x
  36. XGlenn J. Andrews        oper1%drcv06.decnet@drcvax.af.mil       VAX VMS
  37. XTom Betz                marob!upaya!tbetz@phri.nyu.edu  SCO Xenix 2.3.1
  38. XJames Birdsall          jwbirdsa@amc.com                AT&T 3B1
  39. XWim Bonner              27313853@WSUVM1.CSC.WSU.EDU     HP 9000/840a HPUX
  40. XPaul Borman             prb@cray.com                    Cray-X/YMP,2 UNICOS 6-8
  41. XLeslie C. Brown         lbrown@BRL.MIL                  Pyramid MIS-4
  42. XRalf Brown              ralf@b.gp.cs.cmu.edu            Pyramid MIS-4
  43. XPietro Caselli          zaphod@petruz.sublink.org       Minix 1.5.10
  44. XBill Davidsen           davidsen@crdos1.crd.ge.com      Xenix (on what?)
  45. XDaniel Deimert          daniel@hexagon.se               zeus3.21 Zilog S8000
  46. XJames P. Dugal          jpd@usl.edu                     Pyramid 90X OSx4.1
  47. X"Evil Ed"               esaffle@gmuvax2.gmu.edu         Ulrix-32 V3.1 (Rev. 9)
  48. XGreg Flint              afc@klaatu.cc.purdue.edu        ETA-10P* hybrid Sys V
  49. XJeff Foy                jfoy@glia.biostr.washington.edu IRIX Sys V Rel 3.3.1
  50. XKevin M. Fritz          kmfritz@apgea.army.mil          Turbo C++ 1.0
  51. XJean-loup Gailly        jloup@chorus.fr                 MS-DOS Microsoft C 5.1
  52. XScott D. Galloway       sgallowa@letterkenn-emh1.army.mil   Sperry 5000 SysV.3
  53. XDavid Gundlach          david@rolf.stat.uga.edu         Sun SS1+ SunOS 4.1
  54. XPeter Jones             jones@mips1.info.uqam.ca        MIPS UMIPS 4.0
  55. XBruce Kahn              bkahn@archive.webo.dg.com       MS-DOS Microsoft C 5.1
  56. XBob Kemp                Robert.V.Kemp@ATT.COM           AT&T 3B2 SysV 3.2v2
  57. XEarl Kiech              KIECH@utkvx.utk.edu             VAX VMS V5.4-1A
  58. XDavid Kirschbaum        kirsch@usasoc.soc.mil           He got us all in this
  59. X                                                        mess in the first place
  60. XBo Kullmar              bk@kullmar.se                   DNIX 5.2, 5.3
  61. XHarry Langenbacher      harry@neuron6.Jpl.Nasa.Gov      Sun SS1+ SunOS 4.1
  62. XMichael D. Lawler       mdlawler@bsu-cs.bsu.edu         Mt.Xinu BSD 4.3 on VAX
  63. XDavid Lemson            lemson@ux1.cso.uiuc.edu         Sequent Dynix 3.0.17
  64. XOnno van der Linden     linden@fwi.uva.nl               SCO Unix 3.2.0
  65. XWarner Losh             imp@Solbourne.COM               packing algorithm help
  66. XJohn Lundin             lundin@urvax.urich.edu          VAX VMS
  67. XCliff Manis             root@csoftec.csf.com            SCO 2.3.1 (386)
  68. XBill Marsh              bmarsh@cod.nosc.mil             SGI Iris 4D35
  69. XRobert McBroom (?)      rm3@ornl.gov                    DECsystem 5810
  70. XWilliam O'Shaughnessy   williamo@hpcupt1.cup.hp.com     HPUX
  71. XEnrico Renato Palmerini palmer@vxscaq.cineca.it         UNISYS 7000 Sys 5 r2.3
  72. XKeith Petersen          w8sdz@simtel20.army.mil         Maintainer of Info-ZIP
  73. X                                                        Pyramid UCB OSx4.4c
  74. XDavid A Rasmussen       dave@convex.csd.uwm.edu         Convex C220 with 9.0 OS
  75. XMichael Regoli          mr@cica.indiana.edu             Ultrix 3.1 VAX 8650     
  76. X                                                        BSD 4.3 IBM RT/125
  77. X                                                        BSD 4.3 MicroVAX 3500
  78. X                                                        SunOS 4.0.3 Sun 4/330
  79. XGreg Roelofs            roelofs@amelia.nas.nasa.gov     BSD 4.3 VAX 11/780
  80. X                                                        VMS 5.2 VAX 8600
  81. X                                                        UTS 1.2.4 Amdahl 5800
  82. X                                                        Ultrix 4.1 DEC 5810
  83. X                                                        Unicos 5.1, 6.0.11 Cray
  84. X                                                        MS-DOS Microsoft C 6.0
  85. X                                                        Irix 3.3.2, SGI Iris 4D
  86. XKai Uwe Rommel          rommel@informatik.tu-muenchen.de        OS/2
  87. XDave Sisson             daves@vtcosy.cns.vt.edu         AIX 1.1.1 PS/2 & 3090
  88. XRon Srodawa             srodawa@vela.acs.oakland.edu    SCO Xenix/386 2.3.3
  89. XBertil Stenstr|m        stenis@heron.qz.se              HP-UX 7.0 HP9000/835
  90. XArjan de Vet            devet@info.win.tue.nl           SunOS 4.1, MSC 5.1
  91. XRich Wales              wales@cs.ucla.edu               SunOS 4.0.3 Sun-3/50
  92. END_OF_FILE
  93.   if test 4521 -ne `wc -c <'INFOZIP.WHO'`; then
  94.     echo shar: \"'INFOZIP.WHO'\" unpacked with wrong size!
  95.   fi
  96.   # end of 'INFOZIP.WHO'
  97. fi
  98. if test -f 'crypt.h' -a "${1}" != "-c" ; then 
  99.   echo shar: Will not clobber existing file \"'crypt.h'\"
  100. else
  101.   echo shar: Extracting \"'crypt.h'\" \(1087 characters\)
  102.   sed "s/^X//" >'crypt.h' <<'END_OF_FILE'
  103. X/*
  104. X
  105. X Copyright (C) 1990,1991 Mark Adler, Richard B. Wales, and Jean-loup Gailly.
  106. X Permission is granted to any individual or institution to use, copy, or
  107. X redistribute this software so long as all of the original files are included
  108. X unmodified, that it is not sold for profit, and that this copyright notice
  109. X is retained.
  110. X
  111. X*/
  112. X
  113. X/*
  114. X *  crypt.h by Mark Adler.
  115. X */
  116. X
  117. X/* Set up portability */
  118. X#include "tailor.h"
  119. X
  120. X/* Define zfwrite() and zputc() functions */
  121. X#ifdef EXPORT
  122. X#  define zfwrite fwrite
  123. X#  define zputc putc
  124. X#else /* !EXPORT */
  125. X   extern int zfwrite OF((voidp *, extent, extent, FILE *));
  126. X   extern int zfputc OF((int, FILE *));
  127. X   extern char *key;
  128. X#  define zputc(b,f) (key!=NULL?zfputc(b,f):putc(b,f))
  129. X#endif /* ?EXPORT */
  130. X
  131. X/* The implode routines now use the same temporary name generator */
  132. Xchar *tempname OF((int));
  133. X
  134. X/* I'm sneaking this in on Rich's code to make my compiler a bit happier */
  135. X#ifdef NeXT
  136. X   extern void free(voidp *);
  137. X   extern voidp *qsort(voidp *, extent, extent, int (*)());
  138. X   extern extent strlen(char *);
  139. X   extern int unlink(char *);
  140. X#endif /* NeXT */
  141. END_OF_FILE
  142.   if test 1087 -ne `wc -c <'crypt.h'`; then
  143.     echo shar: \"'crypt.h'\" unpacked with wrong size!
  144.   fi
  145.   # end of 'crypt.h'
  146. fi
  147. if test -f 'dir_os2.h' -a "${1}" != "-c" ; then 
  148.   echo shar: Will not clobber existing file \"'dir_os2.h'\"
  149. else
  150.   echo shar: Extracting \"'dir_os2.h'\" \(1975 characters\)
  151.   sed "s/^X//" >'dir_os2.h' <<'END_OF_FILE'
  152. X/*
  153. X * @(#) dir.h 1.4 87/11/06   Public Domain.
  154. X *
  155. X *  A public domain implementation of BSD directory routines for
  156. X *  MS-DOS.  Written by Michael Rendell ({uunet,utai}michael@garfield),
  157. X *  August 1987
  158. X *
  159. X *  Enhanced and ported to OS/2 by Kai Uwe Rommel; added scandir() prototype
  160. X *  December 1989, February 1990
  161. X *  Change of MAXPATHLEN for HPFS, October 1990
  162. X */
  163. X
  164. X
  165. X#define MAXNAMLEN  256
  166. X#define MAXPATHLEN 256
  167. X
  168. X#define A_RONLY    0x01
  169. X#define A_HIDDEN   0x02
  170. X#define A_SYSTEM   0x04
  171. X#define A_LABEL    0x08
  172. X#define A_DIR      0x10
  173. X#define A_ARCHIVE  0x20
  174. X
  175. X
  176. Xstruct direct
  177. X{
  178. X  ino_t    d_ino;                   /* a bit of a farce */
  179. X  int      d_reclen;                /* more farce */
  180. X  int      d_namlen;                /* length of d_name */
  181. X  char     d_name[MAXNAMLEN + 1];   /* null terminated */
  182. X  /* nonstandard fields */
  183. X  long     d_size;                  /* size in bytes */
  184. X  unsigned d_mode;                  /* DOS or OS/2 file attributes */
  185. X  unsigned d_time;
  186. X  unsigned d_date;
  187. X};
  188. X
  189. X/* The fields d_size and d_mode are extensions by me (Kai Uwe Rommel).
  190. X * The find_first and find_next calls deliver this data without any extra cost.
  191. X * If this data is needed, these fields save a lot of extra calls to stat() 
  192. X * (each stat() again performs a find_first call !).
  193. X */
  194. X
  195. Xstruct _dircontents
  196. X{
  197. X  char *_d_entry;
  198. X  long _d_size;
  199. X  unsigned _d_mode, _d_time, _d_date;
  200. X  struct _dircontents *_d_next;
  201. X};
  202. X
  203. Xtypedef struct _dirdesc
  204. X{
  205. X  int  dd_id;                   /* uniquely identify each open directory */
  206. X  long dd_loc;                  /* where we are in directory entry is this */
  207. X  struct _dircontents *dd_contents;   /* pointer to contents of dir */
  208. X  struct _dircontents *dd_cp;         /* pointer to current position */
  209. X}
  210. XDIR;
  211. X
  212. X
  213. Xextern int attributes;
  214. X
  215. Xextern DIR *opendir(char *);
  216. Xextern struct direct *readdir(DIR *);
  217. Xextern void seekdir(DIR *, long);
  218. Xextern long telldir(DIR *);
  219. Xextern void closedir(DIR *);
  220. X#define rewinddir(dirp) seekdir(dirp, 0L)
  221. END_OF_FILE
  222.   if test 1975 -ne `wc -c <'dir_os2.h'`; then
  223.     echo shar: \"'dir_os2.h'\" unpacked with wrong size!
  224.   fi
  225.   # end of 'dir_os2.h'
  226. fi
  227. if test -f 'globals.c' -a "${1}" != "-c" ; then 
  228.   echo shar: Will not clobber existing file \"'globals.c'\"
  229. else
  230.   echo shar: Extracting \"'globals.c'\" \(2276 characters\)
  231.   sed "s/^X//" >'globals.c' <<'END_OF_FILE'
  232. X/*
  233. X
  234. X Copyright (C) 1990,1991 Mark Adler, Richard B. Wales, and Jean-loup Gailly.
  235. X Permission is granted to any individual or institution to use, copy, or
  236. X redistribute this software so long as all of the original files are included
  237. X unmodified, that it is not sold for profit, and that this copyright notice
  238. X is retained.
  239. X
  240. X*/
  241. X
  242. X/*
  243. X *  globals.c by Mark Adler.
  244. X */
  245. X
  246. X#define GLOBALS         /* include definition of errors[] in zip.h */
  247. X#include "zip.h"
  248. X
  249. X
  250. X/* Handy place to build error messages */
  251. Xchar errbuf[FNMAX+81];
  252. X
  253. X/* Argument processing globals */
  254. Xint recurse = 0;        /* 1=recurse into directories encountered */
  255. Xint pathput = 1;        /* 1=store path with name */
  256. Xint method = BEST;      /* one of BEST, SHRINK (only), or IMPLODE (only) */
  257. Xint dosify = 0;         /* 1=make new entries look like MSDOS */
  258. Xint verbose = 0;        /* 1=report oddities in zip file structure */
  259. Xint level = 5;          /* 0=fastest compression, 9=best compression */
  260. X#ifdef VMS
  261. X   int vmsver = 0;      /* 1=append VMS version number to file names */
  262. X#endif /* VMS */
  263. Xint linkput = 0;        /* 1=store symbolic links as such */
  264. Xint noisy = 1;          /* 0=quiet operation */
  265. Xchar *special = NULL;   /* List of special suffixes */
  266. Xchar *key = NULL;       /* Scramble password if scrambling */
  267. Xchar *tempath = NULL;   /* Path for temporary files */
  268. X
  269. X/* Zip file globals */
  270. Xchar *zipfile;          /* New or existing zip archive (zip file) */
  271. Xulg zipbeg;             /* Starting offset of zip structures */
  272. Xulg cenbeg;             /* Starting offset of central directory */
  273. Xstruct zlist far *zfiles = NULL;  /* Pointer to list of files in zip file */
  274. Xextent zcount;          /* Number of files in zip file */
  275. Xextent zcomlen;         /* Length of zip file comment */
  276. Xchar *zcomment;         /* Zip file comment (not zero-terminated) */
  277. Xstruct zlist far **zsort;       /* List of files sorted by name */
  278. X
  279. X/* Files to operate on that are not in zip file */
  280. Xstruct flist far *found = NULL; /* List of names found */
  281. Xstruct flist far * far *fnxt;   /* Where to put next name in found list */
  282. Xextent fcount;          /* Count of files in list */
  283. X
  284. X/* Flags for cleaning up after compression routines */
  285. Xint shract = 0;         /* Shrink active */
  286. Xint impact = 0;         /* Implosion active */
  287. END_OF_FILE
  288.   if test 2276 -ne `wc -c <'globals.c'`; then
  289.     echo shar: \"'globals.c'\" unpacked with wrong size!
  290.   fi
  291.   # end of 'globals.c'
  292. fi
  293. if test -f 'makecrc.c' -a "${1}" != "-c" ; then 
  294.   echo shar: Will not clobber existing file \"'makecrc.c'\"
  295. else
  296.   echo shar: Extracting \"'makecrc.c'\" \(2388 characters\)
  297.   sed "s/^X//" >'makecrc.c' <<'END_OF_FILE'
  298. X/* Not copyrighted 1990 Mark Adler */
  299. X
  300. X#include <stdio.h>
  301. X
  302. Xmain()
  303. X/*
  304. X  Generate a table for a byte-wise 32-bit CRC calculation on the polynomial:
  305. X  x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
  306. X
  307. X  Polynomials over GF(2) are represented in binary, one bit per coefficient,
  308. X  with the lowest powers in the most significant bit.  Then adding polynomials
  309. X  is just exclusive-or, and multiplying a polynomial by x is a right shift by
  310. X  one.  If we call the above polynomial p, and represent a byte as the
  311. X  polynomial q, also with the lowest power in the most significant bit (so the
  312. X  byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
  313. X  where a mod b means the remainder after dividing a by b.
  314. X
  315. X  This calculation is done using the shift-register method of multiplying and
  316. X  taking the remainder.  The register is initialized to zero, and for each
  317. X  incoming bit, x^32 is added mod p to the register if the bit is a one (where
  318. X  x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
  319. X  x (which is shifting right by one and adding x^32 mod p if the bit shifted
  320. X  out is a one).  We start with the highest power (least significant bit) of
  321. X  q and repeat for all eight bits of q.
  322. X
  323. X  The table is simply the CRC of all possible eight bit values.  This is all
  324. X  the information needed to generate CRC's on data a byte at a time for all
  325. X  combinations of CRC register values and incoming bytes.  The table is
  326. X  written to stdout as 256 long hexadecimal values in C language format.
  327. X*/
  328. X{
  329. X  unsigned long c;      /* crc shift register */
  330. X  unsigned long e;      /* polynomial exclusive-or pattern */
  331. X  int i;                /* counter for all possible eight bit values */
  332. X  int k;                /* byte being shifted into crc apparatus */
  333. X
  334. X  /* terms of polynomial defining this crc (except x^32): */
  335. X  static int p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
  336. X
  337. X  /* Make exclusive-or pattern from polynomial */
  338. X  e = 0;
  339. X  for (i = 0; i < sizeof(p)/sizeof(int); i++)
  340. X    e |= 1L << (31 - p[i]);
  341. X
  342. X  /* Compute and print table of CRC's, five per line */
  343. X  printf("  0x00000000L");
  344. X  for (i = 1; i < 256; i++)
  345. X  {
  346. X    c = 0;
  347. X    for (k = i | 256; k != 1; k >>= 1)
  348. X    {
  349. X      c = c & 1 ? (c >> 1) ^ e : c >> 1;
  350. X      if (k & 1)
  351. X        c ^= e;
  352. X    }
  353. X    printf(i % 5 ? ", 0x%08lxL" : ",\n  0x%08lxL", c);
  354. X  }
  355. X  putchar('\n');
  356. X  return 0;
  357. X}
  358. END_OF_FILE
  359.   if test 2388 -ne `wc -c <'makecrc.c'`; then
  360.     echo shar: \"'makecrc.c'\" unpacked with wrong size!
  361.   fi
  362.   # end of 'makecrc.c'
  363. fi
  364. if test -f 'makefile' -a "${1}" != "-c" ; then 
  365.   echo shar: Will not clobber existing file \"'makefile'\"
  366. else
  367.   echo shar: Extracting \"'makefile'\" \(4489 characters\)
  368.   sed "s/^X//" >'makefile' <<'END_OF_FILE'
  369. X# Makefile for Zip, ZipNote, ZipSplit, and Ship.
  370. X# Note: this makefile leaves out the encryption/decryption part of zip, and
  371. X#  completely leaves out the zipcloak program.
  372. X
  373. X# what you can make ...
  374. Xdefault:
  375. X    @echo ''
  376. X    @echo 'Make what?  You must say what system to make Zip for--e.g.'
  377. X    @echo '"make bsd".  Choices: bsd, bsdold, sysv, sun, next, next10,'
  378. X    @echo 'hpux, dnix, cray, 3b1, zilog, aux, convex, aix, and minix.'
  379. X    @echo 'See the file zip.doc for more information.'
  380. X    @echo ''
  381. X
  382. X# variables (to use the Gnu compiler, change cc to gcc in CC and BIND)
  383. XMAKE = make
  384. XCC = cc
  385. XBIND = cc
  386. XRENAME = mv
  387. X
  388. X# flags
  389. X#   CFLAGS    flags for C compile
  390. X#   LFLAGS1   flags after output file spec, before obj file list
  391. X#   LFLAGS2   flags after obj file list (libraries, etc)
  392. XCFLAGS =
  393. XLFLAGS1 =
  394. XLFLAGS2 = -s
  395. X
  396. X# object file lists
  397. XOBJZ = zip.o zipfile.o zipup.o fileio.o util.o tempf.o shrink.o globals.o
  398. XOBJI = implode.o im_lmat.o im_ctree.o im_bits.o
  399. XOBJN = zipnote.o zipfile_.o zipup_.o fileio_.o globals.o
  400. XOBJS = zipsplit.o zipfile_.o zipup_.o fileio_.o globals.o
  401. X
  402. X# suffix rules
  403. X.SUFFIXES:
  404. X.SUFFIXES: _.o .o .c .doc .1
  405. X.c_.o:
  406. X    $(RENAME) $< $*_.c
  407. X    $(CC) $(CFLAGS) -DUTIL -DEXPORT -c $*_.c
  408. X    $(RENAME) $*_.c $<
  409. X.c.o:
  410. X    $(CC) $(CFLAGS) -DEXPORT -c $<
  411. X.1.doc:
  412. X    nroff -man $< | col -b > $@
  413. X
  414. X# rules for zip, zipnote, zipsplit, and zip.doc.
  415. X$(OBJZ): zip.h ziperr.h tempf.h tailor.h
  416. X$(OBJI): implode.h crypt.h ziperr.h tempf.h tailor.h
  417. X$(OBJN): zip.h ziperr.h tailor.h
  418. X$(OBJS): zip.h ziperr.h tailor.h
  419. Xzip.o zipup.o zipnote.o zipsplit.o: revision.h
  420. Xzips: zip zipnote zipsplit ship
  421. Xzipsman: zip zipnote zipsplit ship zip.doc
  422. Xzip: $(OBJZ) $(OBJI)
  423. X    $(BIND) -o zip $(LFLAGS1) $(OBJZ) $(OBJI) $(LFLAGS2)
  424. Xzipnote: $(OBJN)
  425. X    $(BIND) -o zipnote $(LFLAGS1) $(OBJN) $(LFLAGS2)
  426. Xzipsplit: $(OBJS)
  427. X    $(BIND) -o zipsplit $(LFLAGS1) $(OBJS) $(LFLAGS2)
  428. Xship: ship.c
  429. X    $(CC) $(CFLAGS) -o ship $(LFLAGS1) ship.c $(LFLAGS2)
  430. X
  431. X# These symbols, when #defined using -D have these effects on compilation:
  432. X# ZMEM        - includes C language versions of memset(), memcpy(), and
  433. X#          memcmp() (util.c).
  434. X# DIRENT    - use <sys/dirent.h> and getdents() instead of <sys/dir.h>
  435. X#          and opendir(), etc. (fileio.c).
  436. X# NODIR        - used for 3B1, which has neither getdents() nor opendir().
  437. X# NDIR        - use "ndir.h" instead of <sys/dir.h> (fileio.c).
  438. X# UTIL        - select routines for utilities (note and split).
  439. X# PROTO        - enable function prototypes.
  440. X# RMDIR        - remove directories using a system("rmdir ...") call.
  441. X# CONVEX    - for Convex make target.
  442. X# AIX        - for AIX make target.
  443. X# EXPORT    - leave out the encryption code.
  444. X
  445. X# BSD 4.3 (also Unisys 7000--AT&T System V with heavy BSD 4.2)
  446. Xbsd:
  447. X    $(MAKE) zips CFLAGS="-O"
  448. X
  449. X# BSD, but missing memset(), memcmp().
  450. Xbsdold:
  451. X    $(MAKE) zips CFLAGS="-O -DZMEM"
  452. X
  453. X# AT&T System V, Rel 3.  Also SCO, Xenix, OpenDeskTop, ETA-10P*, SGI.
  454. Xsysv:
  455. X    $(MAKE) zips CFLAGS="-O -DDIRENT"
  456. X
  457. X# DNIX 5.x: like System V but optimization is messed up.
  458. Xdnix:
  459. X    $(MAKE) zips CFLAGS="-DDIRENT"
  460. X
  461. X# Sun OS 4.x: BSD, but use getdents().
  462. Xsun:
  463. X    $(MAKE) zips CFLAGS="-O -DDIRENT"
  464. X
  465. X# NeXT 1.0: BSD, but use shared library.
  466. Xnext10:
  467. X    $(MAKE) zips CFLAGS="-O" LFLAGS2="-s -lsys_s"
  468. X
  469. X# NeXT 2.0: BSD, but use MH_OBJECT format for smaller executables.
  470. Xnext:
  471. X    $(MAKE) zips CFLAGS="-O" LFLAGS2="-s -object"
  472. X
  473. X# HPUX: System V, but use <ndir.h> and opendir(), etc.
  474. Xhpux:
  475. X    $(MAKE) zips CFLAGS="-O -DNDIR"
  476. X
  477. X# Cray Unicos 5.1.10 & 6.0.11, Standard C compiler 2.0
  478. Xcray:
  479. X    $(MAKE) zips CFLAGS="-O -DDIRENT" CC="scc"
  480. X
  481. X# AT&T 3B1: System V, but missing a few things.
  482. X3b1:
  483. X    $(MAKE) zips CFLAGS="-O -DNODIR -DRMDIR"
  484. X
  485. X# zilog zeus 3.21
  486. Xzilog:
  487. X    $(MAKE) zips CFLAGS="-O -DZMEM -DNDIR -DRMDIR" CC="scc -i"
  488. X
  489. X# SCO 386 cross compile for MS-DOS
  490. X# Note: zip.exe should be lzexe'd on DOS to reduce its size
  491. Xscodos:
  492. X    $(MAKE) zips CFLAGS="-O -Ms -dos -DNO_ASM" LFLAGS1="-Ms -dos" \
  493. X     LFLAGS2=""
  494. X    $(RENAME) zip zip.exe
  495. X
  496. X# A/UX:
  497. Xaux:
  498. X    $(MAKE) zips CFLAGS="-O -DTERMIO"
  499. X
  500. X# Convex C220, OS 9.0
  501. Xconvex:
  502. X    $(MAKE) zips CFLAGS="-O2 -rl -DCONVEX"
  503. X
  504. X# AIX Version 3.1 for RISC System/6000 
  505. Xaix:
  506. X    $(MAKE) zips CC="c89" BIND="c89" \
  507. X       CFLAGS="-O -D_POSIX_SOURCE -D_ALL_SOURCE -D_BSD -DAIX"
  508. X
  509. X# MINIX 1.5.10 with Bruce Evans 386 patches and gcc/GNU make
  510. Xminix:
  511. X    $(MAKE) zips CFLAGS="-O -DDIRENT -DMINIX" CC=gcc BIND=gcc
  512. X    chmem =262144 zip
  513. X
  514. X# clean up after making stuff and installing it
  515. Xclean:
  516. X    rm -f *.o
  517. X    rm -f zip zipnote zipsplit ship
  518. X
  519. X# This one's for my own use during development.
  520. Xit:
  521. X    $(MAKE) zipsman CFLAGS="-O -Wall -DPROTO" LFLAGS2="-s -object"\
  522. X    VPATH="${HOME}/Unix/bin"
  523. X
  524. X# end of Makefile
  525. END_OF_FILE
  526.   if test 4489 -ne `wc -c <'makefile'`; then
  527.     echo shar: \"'makefile'\" unpacked with wrong size!
  528.   fi
  529.   # end of 'makefile'
  530. fi
  531. if test -f 'makefile.bor' -a "${1}" != "-c" ; then 
  532.   echo shar: Will not clobber existing file \"'makefile.bor'\"
  533. else
  534.   echo shar: Extracting \"'makefile.bor'\" \(3300 characters\)
  535.   sed "s/^X//" >'makefile.bor' <<'END_OF_FILE'
  536. X# Makefile for Zip, ZipNote, ZipSplit, and Ship, for
  537. X# Borland (Turbo) C++ 1.0 or 2.0.
  538. X# Warning: this file is not suitable for Turbo C 2.0. Use zip.prj instead.
  539. X
  540. X# To use, do "make -fmakefile.bor"
  541. X# If you do not have masm or tasm, or if you are using the compact model,
  542. X# then add -DNO_ASM to CFLAGS and remove im_lm.obj from OBJI
  543. X
  544. X# Warning: the default used here is the small model, which produces
  545. X# faster code, but imposes some limitation on the number of files
  546. X# that zip can process. Compile with the compact model to remove these
  547. X# limitations.
  548. X
  549. X# ------------- Turbo C++, Borland C++ -------------
  550. XMODEL=-ms
  551. X#   Change to -mc for compact model
  552. XCFLAGS=-w -w-eff -w-def -w-sig -a -d -G -O -Z $(MODEL) -DEXPORT
  553. XUTILFLAGS=-DUTIL $(CFLAGS) -o
  554. XCC=bcc
  555. XLD=bcc
  556. X#   replace bcc with tcc for Turbo C++ 1.0
  557. XLDFLAGS=$(MODEL)
  558. XAS=tasm
  559. XASFLAGS=-ml -t -DDYN_ALLOC
  560. X
  561. X# ------------- Common declarations:
  562. XSTRIP=rem
  563. X#    If you don't have lzexe, get it. Then define:
  564. X#STRIP=lzexe
  565. X#    This makes a big difference in .exe size (and possibly load time)
  566. X
  567. X# variables
  568. XOBJZ = zip.obj zipfile.obj zipup.obj fileio.obj util.obj tempf.obj shrink.obj\
  569. X globals.obj
  570. XOBJI = implode.obj im_lmat.obj im_ctree.obj im_bits.obj im_lm.obj
  571. X# remove im_lm.obj in above line if you do not have masm
  572. X
  573. XOBJN = zipnote.obj zipfile_.obj zipup_.obj fileio_.obj globals.obj
  574. XOBJS = zipsplit.obj zipfile_.obj zipup_.obj fileio_.obj globals.obj
  575. X
  576. Xzips:    zip.exe zipnote.exe zipsplit.exe ship.exe
  577. X
  578. Xzip.obj:    zip.h ziperr.h tailor.h revision.h zip.c
  579. X    $(CC) -c $(CFLAGS) $*.c
  580. X
  581. Xzipfile.obj:    zip.h ziperr.h tailor.h zipfile.c
  582. X    $(CC) -c $(CFLAGS) $*.c
  583. X
  584. Xzipup.obj:    zip.h ziperr.h tailor.h revision.h zipup.c
  585. X    $(CC) -c $(CFLAGS) $*.c
  586. X
  587. Xfileio.obj:    zip.h ziperr.h tailor.h fileio.c
  588. X    $(CC) -c $(CFLAGS) $*.c
  589. X
  590. Xutil.obj:    zip.h ziperr.h tailor.h util.c
  591. X    $(CC) -c $(CFLAGS) $*.c
  592. X
  593. Xtempf.obj:    tempf.h tailor.h tempf.c
  594. X    $(CC) -c $(CFLAGS) $*.c
  595. X
  596. Xshrink.obj:    zip.h ziperr.h tempf.h tailor.h shrink.c
  597. X    $(CC) -c $(CFLAGS) $*.c
  598. X
  599. Xglobals.obj:    zip.h ziperr.h tailor.h globals.c
  600. X    $(CC) -c $(CFLAGS) $*.c
  601. X
  602. Xzipnote.obj:    zip.h ziperr.h tailor.h revision.h zipnote.c
  603. X    $(CC) -c $(CFLAGS) $*.c
  604. X
  605. Xzipsplit.obj:    zipsplit.c zip.h ziperr.h tailor.h revision.h
  606. X    $(CC) -c $(CFLAGS) $*.c
  607. X
  608. Ximplode.obj:    implode.h crypt.h ziperr.h tempf.h tailor.h implode.c
  609. X    $(CC) -c $(CFLAGS) $*.c
  610. X
  611. Xim_lmat.obj:    implode.h crypt.h ziperr.h tempf.h tailor.h im_lmat.c
  612. X    $(CC) -c $(CFLAGS) $*.c
  613. X
  614. Xim_lm.obj:    im_lm.asm
  615. X    $(AS) $(ASFLAGS) im_lm;
  616. X
  617. Xim_ctree.obj:    implode.h crypt.h ziperr.h tempf.h tailor.h im_ctree.c
  618. X    $(CC) -c $(CFLAGS) $*.c
  619. X
  620. Xim_bits.obj:    implode.h crypt.h ziperr.h tempf.h tailor.h im_bits.c
  621. X    $(CC) -c $(CFLAGS) $*.c
  622. X
  623. Xzipfile_.obj:    zipfile.c zip.h
  624. X    $(CC) -c $(UTILFLAGS)$* zipfile.c
  625. X
  626. Xzipup_.obj:    zipup.c zip.h
  627. X    $(CC) -c $(UTILFLAGS)$* zipup.c
  628. X
  629. Xfileio_.obj:    fileio.c zip.h
  630. X    $(CC) -c $(UTILFLAGS)$* fileio.c
  631. X
  632. X# we must cut the command line to fit in the MS/DOS 128 byte limit:
  633. Xzip.exe: $(OBJZ) $(OBJI)
  634. X    echo $(OBJZ) > zip.rsp
  635. X    echo $(OBJI) >> zip.rsp
  636. X    $(LD) $(LDFLAGS) @zip.rsp
  637. X    del zip.rsp
  638. X    $(STRIP) zip.exe
  639. X
  640. Xzipnote.exe: $(OBJN)
  641. X    echo $(OBJN) > zipn.rsp
  642. X    $(LD) $(LDFLAGS) @zipn.rsp
  643. X    del zipn.rsp
  644. X    $(STRIP) zipnote.exe
  645. X
  646. Xzipsplit.exe: $(OBJS)
  647. X    echo $(OBJS) > zips.rsp
  648. X    $(LD) $(LDFLAGS) @zips.rsp
  649. X    del zips.rsp
  650. X    $(STRIP) zipsplit.exe
  651. X
  652. Xship.exe: ship.c
  653. X    $(CC) $(CFLAGS) ship.c
  654. X    $(STRIP) ship.exe
  655. END_OF_FILE
  656.   if test 3300 -ne `wc -c <'makefile.bor'`; then
  657.     echo shar: \"'makefile.bor'\" unpacked with wrong size!
  658.   fi
  659.   # end of 'makefile.bor'
  660. fi
  661. if test -f 'makefile.msc' -a "${1}" != "-c" ; then 
  662.   echo shar: Will not clobber existing file \"'makefile.msc'\"
  663. else
  664.   echo shar: Extracting \"'makefile.msc'\" \(3286 characters\)
  665.   sed "s/^X//" >'makefile.msc' <<'END_OF_FILE'
  666. X# Makefile for Zip, ZipNote, ZipSplit, and Ship, for
  667. X# Microsoft C 5.1 or 6.0.
  668. X
  669. X# To use, do "make makefile.msc"
  670. X# If you do not have masm or tasm, then add -DNO_ASM to CFLAGS and remove
  671. X# im_lm.obj from OBJI
  672. X
  673. X# Warning: the default used here is the small model, which produces
  674. X# faster code, but imposes some limitation on the number of files
  675. X# that zip can process. Compile with the compact model to remove these
  676. X# limitations.
  677. X
  678. X# ------------- Microsoft C 5.1 or 6.0 -------------
  679. XMODEL=-AS
  680. X#     Change to -AC for compact model
  681. XCFLAGS=-W3 -Ox -nologo $(MODEL)
  682. XSPECFLAGS=-W3 -Oaict -Gs -nologo $(MODEL) -DEXPORT
  683. XUTILFLAGS=-DUTIL $(CFLAGS) -Fo
  684. XCC=cl
  685. XLD=link
  686. XLDFLAGS=/e/st:0x1000
  687. X#     If you use lzexe as recommended, remove /e from LDFLAGS
  688. XAS=masm
  689. X#     For MSC 6.0, use: AS=ml 
  690. XASFLAGS=-ml -t
  691. X
  692. X# ------------- Common declarations:
  693. XSTRIP=rem
  694. X#    If you don't have lzexe, get it. Then define:
  695. X#STRIP=lzexe
  696. X#    This makes a big difference in .exe size (and possibly load time)
  697. X
  698. X# variables
  699. XOBJZ = zip.obj zipfile.obj zipup.obj fileio.obj util.obj tempf.obj shrink.obj\
  700. X globals.obj
  701. XOBJI = implode.obj im_lmat.obj im_ctree.obj im_bits.obj im_lm.obj
  702. X# remove im_lm.obj in above line if you do not have masm
  703. X
  704. XOBJN = zipnote.obj zipfile_.obj zipup_.obj fileio_.obj globals.obj
  705. XOBJS = zipsplit.obj zipfile_.obj zipup_.obj fileio_.obj globals.obj
  706. X
  707. Xzips:    zip.exe zipnote.exe zipsplit.exe ship.exe
  708. X
  709. Xzip.obj:    zip.h ziperr.h tailor.h revision.h zip.c
  710. X    $(CC) -c $(CFLAGS) $*.c
  711. X
  712. Xzipfile.obj:    zip.h ziperr.h tailor.h zipfile.c
  713. X    $(CC) -c $(SPECFLAGS) $*.c
  714. X
  715. Xzipup.obj:    zip.h ziperr.h tailor.h revision.h zipup.c
  716. X    $(CC) -c $(CFLAGS) $*.c
  717. X
  718. Xfileio.obj:    zip.h ziperr.h tailor.h fileio.c
  719. X    $(CC) -c $(CFLAGS) $*.c
  720. X
  721. Xutil.obj:    zip.h ziperr.h tailor.h util.c
  722. X    $(CC) -c $(CFLAGS) $*.c
  723. X
  724. Xtempf.obj:    tempf.h tailor.h tempf.c
  725. X    $(CC) -c $(CFLAGS) $*.c
  726. X
  727. Xshrink.obj:    zip.h ziperr.h tempf.h tailor.h shrink.c
  728. X    $(CC) -c $(CFLAGS) $*.c
  729. X
  730. Xglobals.obj:    zip.h ziperr.h tailor.h globals.c
  731. X    $(CC) -c $(CFLAGS) $*.c
  732. X
  733. Xzipnote.obj:    zip.h ziperr.h tailor.h revision.h zipnote.c
  734. X    $(CC) -c $(CFLAGS) $*.c
  735. X
  736. X# MSC 5.1 dies on zipsplit with -Ox
  737. Xzipsplit.obj:    zipsplit.c zip.h ziperr.h tailor.h revision.h
  738. X    $(CC) -c $(SPECFLAGS) $*.c
  739. X
  740. Ximplode.obj:    implode.h crypt.h ziperr.h tempf.h tailor.h implode.c
  741. X    $(CC) -c $(CFLAGS) $*.c
  742. X
  743. Xim_lmat.obj:    implode.h crypt.h ziperr.h tempf.h tailor.h im_lmat.c
  744. X    $(CC) -c $(CFLAGS) $*.c
  745. X
  746. Xim_lm.obj:    im_lm.asm
  747. X    $(AS) $(ASFLAGS) im_lm;
  748. X
  749. Xim_ctree.obj:    implode.h crypt.h ziperr.h tempf.h tailor.h im_ctree.c
  750. X    $(CC) -c $(CFLAGS) $*.c
  751. X
  752. Xim_bits.obj:    implode.h crypt.h ziperr.h tempf.h tailor.h im_bits.c
  753. X    $(CC) -c $(CFLAGS) $*.c
  754. X
  755. Xzipfile_.obj:    zipfile.c zip.h
  756. X    $(CC) -c $(UTILFLAGS)$@ zipfile.c
  757. X
  758. Xzipup_.obj:    zipup.c zip.h
  759. X    $(CC) -c $(UTILFLAGS)$@ zipup.c
  760. X
  761. Xfileio_.obj:    fileio.c zip.h
  762. X    $(CC) -c $(UTILFLAGS)$@ fileio.c
  763. X
  764. X# we must cut the command line to fit in the MS/DOS 128 byte limit:
  765. Xzip.exe: $(OBJZ) $(OBJI)
  766. X    echo $(OBJZ)+ > zip.rsp
  767. X    echo $(OBJI); >> zip.rsp
  768. X    $(LD) $(LDFLAGS) @zip.rsp
  769. X    del zip.rsp
  770. X    $(STRIP) zip.exe
  771. X
  772. Xzipnote.exe: $(OBJN)
  773. X    echo $(OBJN); > zipn.rsp
  774. X    $(LD) $(LDFLAGS) @zipn.rsp
  775. X    del zipn.rsp
  776. X    $(STRIP) zipnote.exe
  777. X
  778. Xzipsplit.exe: $(OBJS)
  779. X    echo $(OBJS); > zips.rsp
  780. X    $(LD) $(LDFLAGS) @zips.rsp
  781. X    del zips.rsp
  782. X    $(STRIP) zipsplit.exe
  783. X
  784. Xship.exe: ship.c
  785. X    $(CC) $(CFLAGS) ship.c
  786. X    $(STRIP) ship.exe
  787. END_OF_FILE
  788.   if test 3286 -ne `wc -c <'makefile.msc'`; then
  789.     echo shar: \"'makefile.msc'\" unpacked with wrong size!
  790.   fi
  791.   # end of 'makefile.msc'
  792. fi
  793. if test -f 'revision.h' -a "${1}" != "-c" ; then 
  794.   echo shar: Will not clobber existing file \"'revision.h'\"
  795. else
  796.   echo shar: Extracting \"'revision.h'\" \(1198 characters\)
  797.   sed "s/^X//" >'revision.h' <<'END_OF_FILE'
  798. X/*
  799. X
  800. X Copyright (C) 1990,1991 Mark Adler, Richard B. Wales, and Jean-loup Gailly.
  801. X Permission is granted to any individual or institution to use, copy, or
  802. X redistribute this software so long as all of the original files are included
  803. X unmodified, that it is not sold for profit, and that this copyright notice
  804. X is retained.
  805. X
  806. X*/
  807. X
  808. X/*
  809. X *  revision.h by Mark Adler.
  810. X */
  811. X
  812. X#define REVISION 10
  813. X#define REVDATE "29 September 1991"
  814. X
  815. X/* Copyright notice for binary executables--this notice only applies to
  816. X * those (zip, zipcloak, zipsplit, and zipnote), not to this file
  817. X * (revision.h).
  818. X */
  819. X
  820. X#ifndef NOCPYRT
  821. Xchar *copyright[] = {
  822. X"Copyright (C) 1990,1991 Mark Adler, Richard B. Wales, and Jean-loup Gailly.",
  823. X"Permission is granted to any individual or institution to use, copy, or",
  824. X"redistribute this executable so long as it is not modified and that it is",
  825. X"not sold for profit."
  826. X};
  827. Xchar *disclaimer[] = {
  828. X"",
  829. X"LIKE ANYTHING ELSE THAT'S FREE, ZIP AND ITS ASSOCIATED UTILITIES ARE",
  830. X"PROVIDED AS IS AND COME WITH NO WARRANTY OF ANY KIND, EITHER EXPRESSED OR",
  831. X"IMPLIED. IN NO EVENT WILL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES",
  832. X"RESULTING FROM THE USE OF THIS SOFTWARE."
  833. X};
  834. X#endif /* !NOCPYRT */
  835. END_OF_FILE
  836.   if test 1198 -ne `wc -c <'revision.h'`; then
  837.     echo shar: \"'revision.h'\" unpacked with wrong size!
  838.   fi
  839.   # end of 'revision.h'
  840. fi
  841. if test -f 'tailor.h' -a "${1}" != "-c" ; then 
  842.   echo shar: Will not clobber existing file \"'tailor.h'\"
  843. else
  844.   echo shar: Extracting \"'tailor.h'\" \(3123 characters\)
  845.   sed "s/^X//" >'tailor.h' <<'END_OF_FILE'
  846. X/* tailor.h -- Not copyrighted 1991 Mark Adler */
  847. X
  848. X/* const's are inconsistently used across ANSI libraries--kill for all
  849. X   header files. */
  850. X#define const
  851. X
  852. X
  853. X/* Use prototypes and ANSI libraries if __STDC__ */
  854. X#ifdef __STDC__
  855. X#  ifndef PROTO
  856. X#    define PROTO
  857. X#  endif /* !PROTO */
  858. X#  define MODERN
  859. X#endif /* __STDC__ */
  860. X
  861. X
  862. X/* Use prototypes and ANSI libraries if Silicon Graphics */
  863. X#ifdef sgi
  864. X#  ifndef PROTO
  865. X#    define PROTO
  866. X#  endif /* !PROTO */
  867. X#  define MODERN
  868. X#endif /* sgi */
  869. X
  870. X
  871. X/* Define MSDOS for Turbo C as well as Microsoft C */
  872. X#ifdef __POWERC                 /* For Power C too */
  873. X#  define __TURBOC__
  874. X#endif /* __POWERC */
  875. X#ifdef __TURBOC__
  876. X#  ifndef MSDOS
  877. X#    define MSDOS
  878. X#  endif /* !MSDOS */
  879. X#endif /* __TURBOC__ */
  880. X
  881. X
  882. X/* Use prototypes and ANSI libraries if Microsoft or Borland C */
  883. X#ifdef MSDOS
  884. X#  ifndef PROTO
  885. X#    define PROTO
  886. X#  endif /* !PROTO */
  887. X#  define MODERN
  888. X#endif /* MSDOS */
  889. X
  890. X
  891. X/* Turn off prototypes if requested */
  892. X#ifdef NOPROTO
  893. X#  ifdef PROTO
  894. X#    undef PROTO
  895. X#  endif /* PROTO */
  896. X#endif /* NOPROT */
  897. X
  898. X
  899. X/* Used to remove arguments in function prototypes for non-ANSI C */
  900. X#ifdef PROTO
  901. X#  define OF(a) a
  902. X#else /* !PROTO */
  903. X#  define OF(a) ()
  904. X#endif /* ?PROTO */
  905. X
  906. X
  907. X/* Allow far and huge allocation for small model (Microsoft C or Turbo C) */
  908. X#ifdef MSDOS
  909. X#  ifdef __TURBOC__
  910. X#    include <alloc.h>
  911. X#  else /* !__TURBOC__ */
  912. X#    include <malloc.h>
  913. X#    define farmalloc _fmalloc
  914. X#    define farfree   _ffree
  915. X#  endif /* ?__TURBOC__ */
  916. X#else /* !MSDOS */
  917. X#  define huge
  918. X#  define far
  919. X#  define near
  920. X#  define farmalloc malloc
  921. X#  define farfree   free
  922. X#endif /* ?MSDOS */
  923. X
  924. X
  925. X/* Define MSVMS if either MSDOS or VMS defined */
  926. X#ifdef MSDOS
  927. X#  define MSVMS
  928. X#else /* !MSDOS */
  929. X#  ifdef VMS
  930. X#    define MSVMS
  931. X#  endif /* VMS */
  932. X#endif /* ?MSDOS */
  933. X
  934. X
  935. X/* Define void, voidp, and extent (size_t) */
  936. X#include <stdio.h>
  937. X#ifdef MODERN
  938. X#  ifndef M_XENIX
  939. X#    include <stddef.h>
  940. X#  endif /* !M_XENIX */
  941. X#  include <stdlib.h>
  942. X   typedef size_t extent;
  943. X   typedef void voidp;
  944. X#else /* !MODERN */
  945. X   typedef unsigned int extent;
  946. X#  define void int
  947. X   typedef char voidp;
  948. X#endif /* ?MODERN */
  949. X
  950. X/* Get types and stat */
  951. X#ifdef VMS
  952. X#  include <types.h>
  953. X#  include <stat.h>
  954. X#else /* !VMS */
  955. X#  include <sys/types.h>
  956. X#  include <sys/stat.h>
  957. X#endif /* ?VMS */
  958. X
  959. X
  960. X/* Cheap fix for unlink on VMS */
  961. X#ifdef VMS
  962. X#  define unlink delete
  963. X#endif /* VMS */
  964. X
  965. X
  966. X/* For Pyramid */
  967. X#ifdef pyr
  968. X#  define strrchr rindex
  969. X#  define ZMEM
  970. X#endif /* pyr */
  971. X
  972. X
  973. X/* File operations--use "b" for binary if allowed */
  974. X#ifdef MODERN
  975. X#  define FOPR "rb"
  976. X#  define FOPM "r+b"
  977. X#  define FOPW "w+b"
  978. X#else /* !MODERN */
  979. X#  define FOPR "r"
  980. X#  define FOPM "r+"
  981. X#  define FOPW "w+"
  982. X#endif /* ?MODERN */
  983. X
  984. X
  985. X/* Fine tuning */
  986. X#ifndef MSDOS
  987. X#   define BSZ 8192   /* Buffer size for files */
  988. X#else /* !MSDOS */
  989. X#   define BSZ 4096   /* Keep precious NEAR space */
  990. X    /* BSZ can't be 8192 even for compact model because of 64K limitation
  991. X     * in im_lmat.c. If you run out of memory when processing a large number
  992. X     * files, use the compact model and reduce BSZ to 2048 here and in
  993. X     * im_lm.asm.
  994. X     */
  995. X#endif /* ?MSDOS */
  996. X
  997. X/* end of tailor.h */
  998. END_OF_FILE
  999.   if test 3123 -ne `wc -c <'tailor.h'`; then
  1000.     echo shar: \"'tailor.h'\" unpacked with wrong size!
  1001.   fi
  1002.   # end of 'tailor.h'
  1003. fi
  1004. if test -f 'tempf.c' -a "${1}" != "-c" ; then 
  1005.   echo shar: Will not clobber existing file \"'tempf.c'\"
  1006. else
  1007.   echo shar: Extracting \"'tempf.c'\" \(4437 characters\)
  1008.   sed "s/^X//" >'tempf.c' <<'END_OF_FILE'
  1009. X/*
  1010. X
  1011. X Copyright (C) 1990,1991 Mark Adler, Richard B. Wales, and Jean-loup Gailly.
  1012. X Permission is granted to any individual or institution to use, copy, or
  1013. X redistribute this software so long as all of the original files are included
  1014. X unmodified, that it is not sold for profit, and that this copyright notice
  1015. X is retained.
  1016. X
  1017. X*/
  1018. X
  1019. X/*
  1020. X *  tempf.c by Mark Adler.
  1021. X */
  1022. X
  1023. X#include "tailor.h"
  1024. X#include "tempf.h"
  1025. X
  1026. Xextern char *tempname OF((int));
  1027. X
  1028. X#ifdef MODERN
  1029. X#  include <string.h>
  1030. X#else /* !MODERN */
  1031. X   voidp *malloc();
  1032. X#  ifndef ZMEM
  1033. X     char *memcpy();
  1034. X#  endif /* !ZMEM */
  1035. X#endif /* ?MODERN */
  1036. X#ifdef ZMEM
  1037. X   char *memcpy OF((char *, char *, unsigned int));
  1038. X#endif /* ZMEM */
  1039. Xint unlink OF((char *));
  1040. X
  1041. X
  1042. X/* Define a special memcpy for MSDOS small model */
  1043. X#if defined(MSDOS) && (defined(M_I86SM) || defined(__SMALL__))
  1044. X#  include <dos.h>
  1045. X#  define memcpy farmemcpy
  1046. X   void farmemcpy(char far *d, char far *s, unsigned n)
  1047. X   {
  1048. X      movedata(FP_SEG(s), FP_OFF(s), FP_SEG(d), FP_OFF(d), n);
  1049. X   }
  1050. X#endif
  1051. X
  1052. X
  1053. XtFILE *topen(c)
  1054. Xint c;
  1055. X/* Create a new temporary file and return its descriptor.  Save the character
  1056. X   c to be used in the temporary file name, if needed. */
  1057. X{
  1058. X  tFILE *t;
  1059. X
  1060. X  if ((t = (tFILE *)malloc(sizeof(tFILE))) == NULL ||
  1061. X      (t->b = farmalloc(TMPSIZ)) == NULL)
  1062. X    return NULL;
  1063. X  t->p = t->m = 0;
  1064. X  t->c = c;
  1065. X  t->f = NULL;
  1066. X  return t;
  1067. X}
  1068. X
  1069. X
  1070. Xint tnew(t)
  1071. XtFILE *t;               /* temporary file descriptor */
  1072. X/* Create a temporary file with a unique name */
  1073. X{
  1074. X  return (t->n = tempname(t->c)) == NULL ||
  1075. X         (t->f = fopen(t->n, FOPW)) == NULL;
  1076. X}
  1077. X
  1078. X
  1079. Xunsigned twrite(b, s, n, t)
  1080. Xchar *b;                /* buffer to write from */
  1081. Xunsigned s;             /* size of items */
  1082. Xunsigned n;             /* number of items */
  1083. XtFILE *t;               /* temporary file descriptor */
  1084. X/* Like fwrite()--will create a temporary file if needed. */
  1085. X{
  1086. X  unsigned j;           /* room in memory, items to write */
  1087. X  long k;               /* bytes to write */
  1088. X  long w;               /* bytes written to file */
  1089. X
  1090. X  /* write to memory portion */
  1091. X  j = TMPSIZ - t->p;
  1092. X  k = s * (long) n;
  1093. X  if (j && k)
  1094. X  {
  1095. X    j = (long)j > k ? (unsigned)k : j;
  1096. X    memcpy(t->b + t->p, (char far *)b, j);
  1097. X    t->p += j;
  1098. X    if (t->m < t->p)
  1099. X      t->m = t->p;
  1100. X    b += j;
  1101. X    k -= j;
  1102. X  }
  1103. X  if (k == 0)
  1104. X    return n;
  1105. X
  1106. X  /* create temporary file if needed */
  1107. X  if (t->f == NULL && tnew(t))
  1108. X    return 0;
  1109. X
  1110. X  /* write to temporary file */
  1111. X  j = (unsigned)(k / s);
  1112. X  if (j && fwrite(b, s, j, t->f) != j)
  1113. X    return 0;
  1114. X  b += w = s * (long)j;
  1115. X  k -= w;
  1116. X  if (k && fwrite(b, (unsigned)k, 1, t->f) != 1)
  1117. X    return 0;
  1118. X  return n;
  1119. X}
  1120. X
  1121. X
  1122. Xint tflush(t)
  1123. XtFILE *t;               /* temporary file descriptor */
  1124. X/* Like fflush() */
  1125. X{
  1126. X  return t->f == NULL ? 0 : fflush(t->f);
  1127. X}
  1128. X
  1129. X
  1130. Xvoid trewind(t)
  1131. XtFILE *t;               /* temporary file descriptor */
  1132. X/* Like rewind() */
  1133. X{
  1134. X  t->p = 0;
  1135. X  if (t->f != NULL)
  1136. X    rewind(t->f);
  1137. X}
  1138. X
  1139. X
  1140. Xunsigned tread(b, s, n, t)
  1141. Xchar *b;                /* buffer to read into */
  1142. Xunsigned s;             /* size of items */
  1143. Xunsigned n;             /* number of items */
  1144. XtFILE *t;               /* temporary file descriptor */
  1145. X/* Like fread() */
  1146. X{
  1147. X  unsigned j;           /* bytes in memory, items to read */
  1148. X  long k;               /* bytes requested */
  1149. X  long r;               /* bytes read from file */
  1150. X
  1151. X  /* read from memory */
  1152. X  j = t->m - t->p;
  1153. X  k = s * (long)n;
  1154. X  if (j && k)
  1155. X  {
  1156. X    j = (long)j > k ? (unsigned)k : j;
  1157. X    memcpy((char far *)b, t->b + t->p, j);
  1158. X    t->p += j;
  1159. X    b += j;
  1160. X    k -= j;
  1161. X  }
  1162. X
  1163. X  /* read from file if more requested */
  1164. X  if (k && t->f != NULL)
  1165. X  {
  1166. X    j = (unsigned)(k / s);
  1167. X    if (j)
  1168. X    {
  1169. X      r = s * (long)fread(b, s, j, t->f);
  1170. X      b += r;
  1171. X      k -= r;
  1172. X    }
  1173. X    if (k && k < s)
  1174. X      k -= fread(b, 1, (unsigned)k, t->f);
  1175. X  }
  1176. X
  1177. X  /* return complete items read */
  1178. X  return n - (unsigned)((k + s - 1) / s);
  1179. X}
  1180. X
  1181. X
  1182. Xint terror(t)
  1183. XtFILE *t;               /* temporary file descriptor */
  1184. X/* Like ferror() */
  1185. X{
  1186. X  return t->f == NULL ? 0 : ferror(t->f);
  1187. X}
  1188. X
  1189. X
  1190. Xint teof(t)
  1191. XtFILE *t;               /* temporary file descriptor */
  1192. X/* Like feof() */
  1193. X{
  1194. X  return t->f == NULL ? t->p == t->m : feof(t->f);
  1195. X}
  1196. X
  1197. X
  1198. Xint tclose(t)
  1199. XtFILE *t;               /* temporary file descriptor */
  1200. X/* Like fclose()--frees the memory used by the descriptor and deletes
  1201. X   the temporary file, if any. */
  1202. X{
  1203. X  int r;
  1204. X
  1205. X  r = 0;
  1206. X  if (t->f != NULL)
  1207. X  {
  1208. X    r = fclose(t->f);
  1209. X    unlink(t->n);
  1210. X    free(t->n);
  1211. X  }
  1212. X  farfree(t->b);
  1213. X  free(t);
  1214. X  return r;
  1215. X}
  1216. END_OF_FILE
  1217.   if test 4437 -ne `wc -c <'tempf.c'`; then
  1218.     echo shar: \"'tempf.c'\" unpacked with wrong size!
  1219.   fi
  1220.   # end of 'tempf.c'
  1221. fi
  1222. if test -f 'tempf.h' -a "${1}" != "-c" ; then 
  1223.   echo shar: Will not clobber existing file \"'tempf.h'\"
  1224. else
  1225.   echo shar: Extracting \"'tempf.h'\" \(2182 characters\)
  1226.   sed "s/^X//" >'tempf.h' <<'END_OF_FILE'
  1227. X/*
  1228. X
  1229. X Copyright (C) 1990,1991 Mark Adler, Richard B. Wales, and Jean-loup Gailly.
  1230. X Permission is granted to any individual or institution to use, copy, or
  1231. X redistribute this software so long as all of the original files are included
  1232. X unmodified, that it is not sold for profit, and that this copyright notice
  1233. X is retained.
  1234. X
  1235. X*/
  1236. X
  1237. X/*
  1238. X *  tempf.h by Mark Adler.
  1239. X */
  1240. X
  1241. X/* These "t" functions behave like their "f" counterparts, except that
  1242. X   topen() takes one character to (possibly) be used in a temporary file
  1243. X   name, twrite() can create a temporary file, and tclose() will delete
  1244. X   the temporary file, if any.  tnew() is only defined for use in the
  1245. X   tputc() macro.  It should not be called explicitly.  These functions
  1246. X   use the type tFILE instead of FILE to point to a file descriptor. */
  1247. X
  1248. X#if !defined(OS2) && (defined(M_I86CM) || defined(__COMPACT__))
  1249. X#   define TMPSIZ  0x8000  /* memory portion of temporary files */
  1250. X    /* The MSDOS compact model is to be used only for processing a large
  1251. X     * number of files. In this case we try to reduce the memory requirements.
  1252. X     * You can reduce TMPSIZ to 16384 or 8192 if 32K is still too large,
  1253. X     * but the resulting code will be slower.
  1254. X     */
  1255. X#else
  1256. X#   define TMPSIZ  0xe000  /* memory portion of temporary files */
  1257. X#endif
  1258. X
  1259. Xtypedef struct {
  1260. X  char far *b;          /* memory part of file */
  1261. X  unsigned p;           /* current read/write pointer for memory part */
  1262. X  unsigned m;           /* bytes in memory part */
  1263. X  int c;                /* character to use in spill file name */
  1264. X  FILE *f;              /* spill file pointer or NULL*/
  1265. X  char *n;              /* spill file name if f not NULL */
  1266. X} tFILE;
  1267. X
  1268. XtFILE *topen OF((int));
  1269. Xint tnew OF((tFILE *));
  1270. Xunsigned twrite OF((char *, unsigned, unsigned, tFILE *));
  1271. Xint tflush OF((tFILE *));
  1272. Xvoid trewind OF((tFILE *));
  1273. Xunsigned tread OF((char *, unsigned, unsigned, tFILE *));
  1274. Xint terror OF((tFILE *));
  1275. Xint teof OF((tFILE *));
  1276. Xint tclose OF((tFILE *));
  1277. X
  1278. X#define tputcm(c,t) ((t)->b[(t)->p++]=(c),(t)->m<(t)->p?((t)->m=(t)->p):0,c)
  1279. X#define tputcf(c,t) ((t)->f==NULL?(tnew(t)?-1:putc(c,(t)->f)):putc(c,(t)->f))
  1280. X#define tputc(c,t) ((t)->p<TMPSIZ?(int)tputcm(c,t):tputcf(c,t))
  1281. END_OF_FILE
  1282.   if test 2182 -ne `wc -c <'tempf.h'`; then
  1283.     echo shar: \"'tempf.h'\" unpacked with wrong size!
  1284.   fi
  1285.   # end of 'tempf.h'
  1286. fi
  1287. echo shar: End of archive 9 \(of 9\).
  1288. cp /dev/null ark9isdone
  1289. MISSING=""
  1290. for I in 1 2 3 4 5 6 7 8 9 ; do
  1291.     if test ! -f ark${I}isdone ; then
  1292.     MISSING="${MISSING} ${I}"
  1293.     fi
  1294. done
  1295. if test "${MISSING}" = "" ; then
  1296.     echo You have unpacked all 9 archives.
  1297.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1298. else
  1299.     echo You still must unpack the following archives:
  1300.     echo "        " ${MISSING}
  1301. fi
  1302. exit 0
  1303. exit 0 # Just in case...
  1304. -- 
  1305. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1306. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1307. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1308. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1309.