home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / vmsnet / sources / 330 < prev    next >
Encoding:
Internet Message Format  |  1992-09-01  |  47.1 KB

  1. Path: sparky!uunet!munnari.oz.au!network.ucsd.edu!mvb.saic.com!vmsnet-sources
  2. From: goathunter@wkuvx1.bitnet
  3. Newsgroups: vmsnet.sources
  4. Subject: Zip v1.9 & UnZip v5.0, part 13/22
  5. Message-ID: <8009670@MVB.SAIC.COM>
  6. Date: Tue, 01 Sep 1992 22:52:43 GMT
  7. Organization: Western Kentucky University, Bowling Green, KY
  8. Lines: 1422
  9. Approved: Mark.Berryman@Mvb.Saic.Com
  10.  
  11. Submitted-by: goathunter@wkuvx1.bitnet
  12. Posting-number: Volume 3, Issue 135
  13. Archive-name: zip_unzip/part13
  14.  
  15. -+-+-+-+-+-+-+-+ START OF PART 13 -+-+-+-+-+-+-+-+
  16. X`09    nam.nam$b_rss = FILNAMSIZ - 1;
  17. X
  18. X`09    outfab->fab$l_fop `7C= FAB$M_MXV;
  19. X`09    outfab->fab$l_nam = &nam;
  20. X
  21. X`09    ierr = sys$create(outfab);
  22. X`09    if (!ERR(ierr))
  23. X`09    `7B
  24. X`09`09outfab->fab$l_nam = 0L;
  25. X`09`09filename`5Boutfab->fab$b_fns = nam.nam$b_rsl`5D = 0;
  26. X`09    `7D
  27. X`09    break;
  28. X`09case 'o':
  29. X`09    outfab->fab$l_fop `7C= FAB$M_SUP;
  30. X`09    ierr = sys$create(outfab);
  31. X`09    break;
  32. X    `7D
  33. X    return ierr;
  34. X`7D
  35. X
  36. X/*
  37. X*   Extra record format
  38. X*   ===================
  39. X*   signature       (2 bytes)   = 'I','M'
  40. X*   size            (2 bytes)
  41. X*   block signature (4 bytes)
  42. X*   flags           (2 bytes)
  43. X*   uncomprssed size(2 bytes)
  44. X*   reserved        (4 bytes)
  45. X*   data            ((size-12) bytes)
  46. X*   ....
  47. X*/
  48. X
  49. X#define BC_MASK `0907`09/* 3 bits for compression type */
  50. X#define BC_STORED`090`09/* Stored */
  51. X#define BC_00`09`091`09/* 0byte -> 0bit compression */
  52. X#define BC_DEFL`09`092`09/* Deflated */
  53. X
  54. Xstruct extra_block
  55. X`7B
  56. X    UWORD sig;`09`09`09/* Extra field block header structure */
  57. X    UWORD size;
  58. X    ULONG bid;
  59. X    UWORD flags;
  60. X    UWORD length;
  61. X    ULONG reserved;
  62. X    byte body`5B1`5D;
  63. X`7D;
  64. X
  65. X/*
  66. X *   Extra field signature and block signatures
  67. X */
  68. X
  69. X#define SIGNATURE "IM"
  70. X#define FABL    (cc$rms_fab.fab$b_bln)
  71. X#define RABL    (cc$rms_rab.rab$b_bln)
  72. X#define XALLL   (cc$rms_xaball.xab$b_bln)
  73. X#define XDATL   (cc$rms_xabdat.xab$b_bln)
  74. X#define XFHCL   (cc$rms_xabfhc.xab$b_bln)
  75. X#define XKEYL   (cc$rms_xabkey.xab$b_bln)
  76. X#define XPROL   (cc$rms_xabpro.xab$b_bln)
  77. X#define XRDTL   (cc$rms_xabrdt.xab$b_bln)
  78. X#define XSUML   (cc$rms_xabsum.xab$b_bln)
  79. X#define EXTBSL  4`09`09/* Block signature length   */
  80. X#define RESL    8`09`09/* Rserved 8 bytes  */
  81. X#define EXTHL   (4+EXTBSL)
  82. X#define FABSIG  "VFAB"
  83. X#define XALLSIG "VALL"
  84. X#define XFHCSIG "VFHC"
  85. X#define XDATSIG "VDAT"
  86. X#define XRDTSIG "VRDT"
  87. X#define XPROSIG "VPRO"
  88. X#define XKEYSIG "VKEY"
  89. X#define XNAMSIG "VNAM"
  90. X#define VERSIG  "VMSV"
  91. X
  92. X
  93. X
  94. X#define W(p)    (*(unsigned short*)(p))
  95. X#define L(p)    (*(unsigned long*)(p))
  96. X#define EQL_L(a,b)      ( L(a) == L(b) )
  97. X#define EQL_W(a,b)      ( W(a) == W(b) )
  98. X
  99. X/****************************************************************
  100. X * Function find_vms_attrs scans ZIP entry extra field if any   *
  101. X * and looks for VMS attribute records. Returns 0 if either no  *
  102. X * attributes found or no fab given.                            *
  103. X ****************************************************************/
  104. Xint find_vms_attrs()
  105. X`7B
  106. X    byte *scan = extra_field;
  107. X    struct extra_block *blk;
  108. X    int len;
  109. X
  110. X    outfab = xabfhc = xabdat = xabrdt = xabpro = first_xab = last_xab = 0L;
  111. X
  112. X    if (scan == NULL)
  113. X`09return 0;
  114. X    len = lrec.extra_field_length;
  115. X
  116. X#define LINK(p) `7B`09/* Link xaballs and xabkeys into chain */`09\
  117. X                if( first_xab == 0L )                   \
  118. X                        first_xab = p;                  \
  119. X                if( last_xab != 0L )                    \
  120. X                        last_xab -> xab$l_nxt = p;      \
  121. X                last_xab = p;                           \
  122. X                p -> xab$l_nxt = 0;                     \
  123. X        `7D
  124. X    /* End of macro LINK */
  125. X
  126. X    while (len > 0)
  127. X    `7B
  128. X`09blk = (struct block *) scan;
  129. X`09if (EQL_W(&blk->sig, SIGNATURE))
  130. X`09`7B
  131. X`09    byte *block_id;
  132. X
  133. X`09    block_id = &blk->bid;
  134. X`09    if (EQL_L(block_id, FABSIG))
  135. X`09    `7B
  136. X`09`09outfab = (struct FAB *) extract_block(blk, 0,
  137. X`09`09`09`09`09`09      &cc$rms_fab, FABL);
  138. X`09    `7D
  139. X`09    else if (EQL_L(block_id, XALLSIG))
  140. X`09    `7B
  141. X`09`09xaball = (struct XABALL *) extract_block(blk, 0,
  142. X`09`09`09`09`09`09`09 &cc$rms_xaball, XALLL);
  143. X`09`09LINK(xaball);
  144. X`09    `7D
  145. X`09    else if (EQL_L(block_id, XKEYSIG))
  146. X`09    `7B
  147. X`09`09xabkey = (struct XABKEY *) extract_block(blk, 0,
  148. X`09`09`09`09`09`09`09 &cc$rms_xabkey, XKEYL);
  149. X`09`09LINK(xabkey);
  150. X`09    `7D
  151. X`09    else if (EQL_L(block_id, XFHCSIG))
  152. X`09    `7B
  153. X`09`09xabfhc = (struct XABFHC *) extract_block(blk, 0,
  154. X`09`09`09`09`09`09`09 &cc$rms_xabfhc, XFHCL);
  155. X`09    `7D
  156. X`09    else if (EQL_L(block_id, XDATSIG))
  157. X`09    `7B
  158. X`09`09xabdat = (struct XABDAT *) extract_block(blk, 0,
  159. X`09`09`09`09`09`09`09 &cc$rms_xabdat, XDATL);
  160. X`09    `7D
  161. X`09    else if (EQL_L(block_id, XRDTSIG))
  162. X`09    `7B
  163. X`09`09xabrdt = (struct XABRDT *) extract_block(blk, 0,
  164. X`09`09`09`09`09`09`09 &cc$rms_xabrdt, XRDTL);
  165. X`09    `7D
  166. X`09    else if (EQL_L(block_id, XPROSIG))
  167. X`09    `7B
  168. X`09`09xabpro = (struct XABPRO *) extract_block(blk, 0,
  169. X`09`09`09`09`09`09`09 &cc$rms_xabpro, XPROL);
  170. X`09    `7D
  171. X`09    else if (EQL_L(block_id, VERSIG))
  172. X`09    `7B
  173. X`09`09char verbuf`5B80`5D;
  174. X`09`09int verlen = 0;
  175. X`09`09byte *vers;
  176. X`09`09char *m;
  177. X
  178. X`09`09get_vms_version(verbuf, 80);
  179. X`09`09vers = extract_block(blk, &verlen, 0, 0);
  180. X`09`09if ((m = strrchr(vers, '-')) != NULL)
  181. X`09`09    *m = 0;`09/* Cut out release number */
  182. X`09`09if (strcmp(verbuf, vers) && quietflg == 0)
  183. X`09`09`7B
  184. X`09`09    printf("`5B Warning: VMS version mismatch.");
  185. X
  186. X`09`09    printf("   This version %s --", verbuf);
  187. X`09`09    strncpy(verbuf, vers, verlen);
  188. X`09`09    verbuf`5Bverlen`5D = 0;
  189. X`09`09    printf(" version made by %s `5D\n", verbuf);
  190. X`09`09`7D
  191. X`09`09free(vers);
  192. X`09    `7D
  193. X`09    else if (quietflg == 0)
  194. X`09`09fprintf(stderr, "`5B Warning: Unknown block signature %s `5D\n",
  195. X`09`09`09block_id);
  196. X`09`7D
  197. X`09len -= blk->size + 4;
  198. X`09scan += blk->size + 4;
  199. X    `7D
  200. X
  201. X
  202. X    if (outfab != 0)
  203. X    `7B`09`09`09`09/* Do not link XABPRO,XABRDT now. Leave them for sys$clos
  204. Ve() */
  205. X
  206. X`09outfab->fab$l_xab = 0L;
  207. X`09if (xabfhc != 0L)
  208. X`09`7B
  209. X`09    xabfhc->xab$l_nxt = outfab->fab$l_xab;
  210. X`09    outfab->fab$l_xab = xabfhc;
  211. X`09`7D
  212. X`09if (xabdat != 0L)
  213. X`09`7B
  214. X`09    xabdat->xab$l_nxt = outfab->fab$l_xab;
  215. X`09    outfab->fab$l_xab = xabdat;
  216. X`09`7D
  217. X`09if (first_xab != 0L)`09/* Link xaball,xabkey subchain */
  218. X`09`7B
  219. X`09    last_xab->xab$l_nxt = outfab->fab$l_xab;
  220. X`09    outfab->fab$l_xab = first_xab;
  221. X`09`7D
  222. X`09return 1;
  223. X    `7D
  224. X    else
  225. X`09return 0;
  226. X`7D
  227. X
  228. Xstatic void free_up()
  229. X`7B`09`09`09`09/*
  230. X`09`09`09`09*`09Free up all allocated xabs
  231. X`09`09`09`09*/
  232. X    if (xabdat != 0L) free(xabdat);
  233. X    if (xabpro != 0L) free(xabpro);
  234. X    if (xabrdt != 0L) free(xabrdt);
  235. X    if (xabfhc != 0L) free(xabfhc);
  236. X    while (first_xab != 0L)
  237. X    `7B
  238. X`09struct XAB *x;
  239. X
  240. X`09x = first_xab->xab$l_nxt;
  241. X`09free(first_xab);
  242. X`09first_xab = x;
  243. X    `7D
  244. X    if (outfab != 0L && outfab != &fileblk)
  245. X`09free(outfab);
  246. X`7D
  247. X
  248. Xstatic int get_vms_version(verbuf, len)
  249. X    char *verbuf;
  250. Xint len;
  251. X`7B
  252. X    int i = SYI$_VERSION;
  253. X    int verlen = 0;
  254. X    struct dsc$descriptor version;
  255. X    char *m;
  256. X
  257. X    version.dsc$a_pointer = verbuf;
  258. X    version.dsc$w_length = len - 1;
  259. X    version.dsc$b_dtype = DSC$K_DTYPE_B;
  260. X    version.dsc$b_class = DSC$K_CLASS_S;
  261. X
  262. X    if (ERR(lib$getsyi(&i, 0, &version, &verlen, 0, 0)) `7C`7C verlen == 0)
  263. X`09return 0;
  264. X
  265. X    /* Cut out trailing spaces "V5.4-3   " -> "V5.4-3" */
  266. X    for (m = verbuf + verlen, i = verlen - 1; i > 0 && verbuf`5Bi`5D == ' ';
  267. V --i)
  268. X`09--m;
  269. X    *m = 0;
  270. X
  271. X    /* Cut out release number "V5.4-3" -> "V5.4" */
  272. X    if ((m = strrchr(verbuf, '-')) != NULL)
  273. X`09*m = 0;
  274. X    return strlen(verbuf) + 1;`09/* Transmit ending 0 too */
  275. X`7D
  276. X
  277. X/******************************
  278. X *   Function extract_block   *
  279. X ******************************/
  280. X/*
  281. X * Extracts block from p. If resulting length is less then needed, fill
  282. X * extra space with corresponding bytes from 'init'.
  283. X * Currently understands 3 formats of block compression:
  284. X * - Simple storing
  285. X * - Compression of zero bytes to zero bits
  286. X * - Deflation. See memextract() from extract.c
  287. X */
  288. Xstatic byte *extract_block(p, retlen, init, needlen)
  289. X    struct extra_block *p;
  290. Xint *retlen;
  291. Xbyte *init;
  292. Xint needlen;
  293. X`7B
  294. X    byte *block;`09`09/* Pointer to block allocated */
  295. X    int cmptype;
  296. X    int usiz, csiz, max;
  297. X
  298. X    cmptype = p->flags & BC_MASK;
  299. X    csiz = p->size - EXTBSL - RESL;
  300. X    usiz = (cmptype == BC_STORED ? csiz : p->length);
  301. X
  302. X    if (needlen == 0)
  303. X`09needlen = usiz;
  304. X
  305. X    if (retlen)
  306. X`09*retlen = usiz;
  307. X
  308. X#ifndef MAX
  309. X#define MAX(a,b)`09( (a) > (b) ? (a) : (b) )
  310. X#endif
  311. X
  312. X    if ((block = (byte *) malloc(MAX(needlen, usiz))) == NULL)
  313. X`09return NULL;
  314. X
  315. X    if (init && (usiz < needlen))
  316. X`09memcpy(block, init, needlen);
  317. X
  318. X    switch (cmptype)
  319. X    `7B
  320. X`09case BC_STORED:`09/* The simplest case */
  321. X`09    memcpy(block, &(p->body`5B0`5D), usiz);
  322. X`09    break;
  323. X`09case BC_00:
  324. X`09    decompress_bits(block, usiz, &(p->body`5B0`5D));
  325. X`09    break;
  326. X`09case BC_DEFL:
  327. X`09    memextract(block, usiz, &(p->body`5B0`5D), csiz);
  328. X`09    break;
  329. X`09default:
  330. X`09    free(block);
  331. X`09    block = NULL;
  332. X    `7D
  333. X    return block;
  334. X`7D
  335. X
  336. X/*
  337. X *  Simple uncompression routine. The compression uses bit stream.
  338. X *  Compression scheme:
  339. X *
  340. X *  if(byte!=0)
  341. X *      putbit(1),putbyte(byte)
  342. X *  else
  343. X *      putbit(0)
  344. X */
  345. Xstatic void decompress_bits(outptr, needlen, bitptr)
  346. X    byte *bitptr;
  347. X
  348. X/* Pointer into compressed data */
  349. Xbyte *outptr;`09`09`09/* Pointer into output block */
  350. Xint needlen;`09`09`09/* Size of uncompressed block */
  351. X`7B
  352. X    ULONG bitbuf = 0;
  353. X    int bitcnt = 0;
  354. X
  355. X#define _FILL   if(bitcnt+8 <= 32)                      \
  356. X                `7B       bitbuf `7C= (*bitptr++) << bitcnt;\
  357. X                        bitcnt += 8;                    \
  358. X                `7D
  359. X
  360. X    while (needlen--)
  361. X    `7B
  362. X`09if (bitcnt <= 0)
  363. X`09    _FILL;
  364. X
  365. X`09if (bitbuf & 1)
  366. X`09`7B
  367. X`09    bitbuf >>= 1;
  368. X`09    if ((bitcnt -= 1) < 8)
  369. X`09`09_FILL;
  370. X`09    *outptr++ = (byte) bitbuf;
  371. X`09    bitcnt -= 8;
  372. X`09    bitbuf >>= 8;
  373. X`09`7D
  374. X`09else
  375. X`09`7B
  376. X`09    *outptr++ = 0;
  377. X`09    bitcnt -= 1;
  378. X`09    bitbuf >>= 1;
  379. X`09`7D
  380. X    `7D
  381. X`7D
  382. X
  383. X/***************************/
  384. X/*  Function FlushOutput() */
  385. X/***************************/
  386. X
  387. Xint FlushOutput()
  388. X`7B
  389. X    if (mem_mode)
  390. X    `7B`09`09`09`09/* Hope, mem_mode stays constant during
  391. X`09`09`09`09 * extraction */
  392. X`09int rc = FlushMemory();`09/* For mem_extract() */
  393. X
  394. X`09outpos += outcnt;
  395. X`09outcnt = 0;
  396. X`09outptr = outbuf;
  397. X`09return rc;
  398. X    `7D
  399. X
  400. X    /* return PK-type error code */
  401. X    /* flush contents of output buffer */
  402. X    if (tflag)
  403. X    `7B`09`09`09`09/* Do not output. Update CRC only */
  404. X`09UpdateCRC(outbuf, outcnt);
  405. X`09outpos += outcnt;
  406. X`09outcnt = 0;
  407. X`09outptr = outbuf;
  408. X`09return 0;
  409. X    `7D
  410. X    else
  411. X`09return text_file ? _flush_records(0) : _flush_blocks(0);
  412. X`7D
  413. X
  414. Xstatic int _flush_blocks(final_flag)`09/* Asynchronous version */
  415. X    int final_flag;
  416. X
  417. X/* 1 if this is the final flushout */
  418. X`7B
  419. X    int round;
  420. X    int rest;
  421. X    int off = 0;
  422. X    int out_count = outcnt;
  423. X    int status;
  424. X
  425. X    while (out_count > 0)
  426. X    `7B
  427. X`09if (curbuf->bufcnt < BUFS512)
  428. X`09`7B
  429. X`09    int ncpy;
  430. X
  431. X`09    ncpy = out_count > (BUFS512 - curbuf->bufcnt) ?
  432. X`09`09`09    BUFS512 - curbuf->bufcnt :
  433. X`09`09`09    out_count;
  434. X`09    memcpy(curbuf->buf + curbuf->bufcnt, outbuf + off, ncpy);
  435. X`09    out_count -= ncpy;
  436. X`09    curbuf->bufcnt += ncpy;
  437. X`09    off += ncpy;
  438. X`09`7D
  439. X`09if (curbuf->bufcnt == BUFS512)
  440. X`09`7B
  441. X`09    status = WriteBuffer(curbuf->buf, curbuf->bufcnt);
  442. X`09    if (status)
  443. X`09`09return status;
  444. X`09    curbuf = curbuf->next;
  445. X`09    curbuf->bufcnt = 0;
  446. X`09`7D
  447. X    `7D
  448. X
  449. X    UpdateCRC(outbuf, outcnt);
  450. X    outpos += outcnt;
  451. X    outcnt = 0;
  452. X    outptr = outbuf;
  453. X
  454. X    return (final_flag && (curbuf->bufcnt > 0)) ?
  455. X`09WriteBuffer(curbuf->buf, curbuf->bufcnt) :
  456. X`090;
  457. X    /* 0:  no error */
  458. X`7D
  459. X
  460. X#define RECORD_END(c) ((c) == CR `7C`7C (c) == LF `7C`7C (c) == CTRLZ)
  461. X
  462. Xstatic int _flush_records(final_flag)
  463. X    int final_flag;
  464. X
  465. X/* 1 if this is the final flushout */
  466. X`7B
  467. X    int rest;
  468. X    int end = 0, start = 0;
  469. X    int off = 0;
  470. X
  471. X    if (outcnt == 0 && loccnt == 0)
  472. X`09return 0;`09`09/* Nothing to do ... */
  473. X
  474. X    if (loccnt)
  475. X    `7B
  476. X`09for (end = 0; end < outcnt && !RECORD_END(outbuf`5Bend`5D);)
  477. X`09    ++end;
  478. X
  479. X`09if (end >= outcnt && !final_flag)
  480. X`09`7B
  481. X`09    if (WriteRecord(locbuf, loccnt))
  482. X`09`09return (50);
  483. X`09    fprintf(stderr, "`5B Warning: Record too long (%d) `5D\n",
  484. X`09`09    outcnt + loccnt);
  485. X`09    memcpy(locbuf, outbuf, outcnt);
  486. X`09    locptr = &locbuf`5Bloccnt = outcnt`5D;
  487. X`09`7D
  488. X`09else
  489. X`09`7B
  490. X`09    memcpy(locptr, outbuf, end);
  491. X`09    if (WriteRecord(locbuf, loccnt + end))
  492. X`09`09return (50);
  493. X`09    loccnt = 0;
  494. X`09    locptr = &locbuf;
  495. X`09`7D
  496. X`09start = end + 1;
  497. X
  498. X`09if (start < outcnt && outbuf`5Bend`5D == CR && outbuf`5Bstart`5D == LF)
  499. X`09    ++start;
  500. X    `7D
  501. X
  502. X    do
  503. X    `7B
  504. X`09while (start < outcnt && outbuf`5Bstart`5D == CR)`09/* Skip CR's at the
  505. X`09`09`09`09`09`09`09*  beginning of rec. */
  506. X`09    ++start;
  507. X`09/* Find record end */
  508. X`09for (end = start; end < outcnt && !RECORD_END(outbuf`5Bend`5D);)
  509. X`09    ++end;
  510. X
  511. X`09if (end < outcnt)
  512. X`09`7B`09`09`09/* Record end found, write the record */
  513. X`09    if (WriteRecord(outbuf + start, end - start))
  514. X`09`09return (50);
  515. X`09    /* Shift to the begining of the next record */
  516. X`09    start = end + 1;
  517. X`09`7D
  518. X
  519. X`09if (start < outcnt && outbuf`5Bend`5D == CR && outbuf`5Bstart`5D == LF)
  520. X`09    ++start;
  521. X
  522. X    `7D while (start < outcnt && end < outcnt);
  523. X
  524. X    rest = outcnt - start;
  525. X
  526. X    if (rest > 0)
  527. X`09if (final_flag)
  528. X`09`7B
  529. X`09    /* This is a final flush. Put out all remaining in
  530. X`09    *  the buffer                               */
  531. X`09    if (loccnt && WriteRecord(locbuf, loccnt))
  532. X`09`09return (50);
  533. X`09`7D
  534. X`09else
  535. X`09`7B
  536. X`09    memcpy(locptr, outbuf + start, rest);
  537. X`09    locptr += rest;
  538. X`09    loccnt += rest;
  539. X`09`7D
  540. X    UpdateCRC(outbuf, outcnt);
  541. X    outpos += outcnt;
  542. X    outcnt = 0;
  543. X    outptr = outbuf;
  544. X    return (0);`09`09`09/* 0:  no error */
  545. X`7D
  546. X
  547. X/***************************/
  548. X/*  Function WriteBuffer() */
  549. X/***************************/
  550. X
  551. Xstatic int WriteBuffer(buf, len)/* return 0 if successful, 1 if not */
  552. X    unsigned char *buf;
  553. Xint len;
  554. X`7B
  555. X    int status;
  556. X
  557. X    status = sys$wait(outrab);
  558. X#ifdef DEBUG
  559. X    if (ERR(status))
  560. X    `7B
  561. X`09message("`5B WriteBuffer: sys$wait failed `5D\n", status);
  562. X`09message("", outrab->rab$l_stv);
  563. X    `7D
  564. X#endif
  565. X    outrab->rab$w_rsz = len;
  566. X    outrab->rab$l_rbf = buf;
  567. X
  568. X    if (ERR(status = sys$write(outrab)))
  569. X    `7B
  570. X`09message("`5B WriteBuffer: sys$write failed `5D\n", status);
  571. X`09message("", outrab->rab$l_stv);
  572. X`09return 50;
  573. X    `7D
  574. X    return (0);
  575. X`7D
  576. X
  577. X/***************************/
  578. X/*  Function WriteRecord() */
  579. X/***************************/
  580. X
  581. Xstatic int WriteRecord(rec, len)/* return 0 if successful, 1 if not */
  582. X    unsigned char *rec;
  583. Xint len;
  584. X`7B
  585. X    int status;
  586. X
  587. X    sys$wait(outrab);
  588. X#ifdef DEBUG
  589. X    if (ERR(status))
  590. X    `7B
  591. X`09message("`5B WriteRecord: sys$wait faled `5D\n", status);
  592. X`09message("", outrab->rab$l_stv);
  593. X    `7D
  594. X#endif
  595. X    outrab->rab$w_rsz = len;
  596. X    outrab->rab$l_rbf = rec;
  597. X
  598. X    if (ERR(status = sys$put(outrab)))
  599. X    `7B
  600. X`09message("`5B WriteRecord: sys$put failed `5D\n", status);
  601. X`09message("", outrab->rab$l_stv);
  602. X`09return 50;
  603. X    `7D
  604. X    return (0);
  605. X`7D
  606. X
  607. X/********************************/
  608. X/*  Function CloseOutputFile()  */
  609. X/********************************/
  610. X
  611. Xint CloseOutputFile()
  612. X`7B
  613. X    int status;
  614. X
  615. X    if (text_file) _flush_records(1);
  616. X    else
  617. X`09_flush_blocks(1);
  618. X    /* Link XABRDT,XABDAT and optionaly XABPRO */
  619. X    if (xabrdt != 0L)
  620. X    `7B
  621. X`09xabrdt->xab$l_nxt = 0L;
  622. X`09outfab->fab$l_xab = xabrdt;
  623. X    `7D
  624. X    else
  625. X    `7B
  626. X`09rdt.xab$l_nxt = 0L;
  627. X`09outfab->fab$l_xab = &rdt;
  628. X    `7D
  629. X    if (xabdat != 0L)
  630. X    `7B
  631. X`09xabdat->xab$l_nxt = outfab->fab$l_xab;
  632. X`09outfab->fab$l_xab = xabdat;
  633. X    `7D
  634. X    if (secinf && xabpro != 0L)
  635. X    `7B
  636. X`09xabpro->xab$l_nxt = outfab->fab$l_xab;
  637. X`09outfab->fab$l_xab = xabpro;
  638. X    `7D
  639. X
  640. X    sys$wait(outrab);
  641. X
  642. X    status = sys$close(outfab);
  643. X#ifdef DEBUG
  644. X    if (ERR(status))
  645. X    `7B
  646. X`09message("\r`5B Warning: cannot set owner/protection/time attributes `5D\n
  647. V", status);
  648. X`09message("", outfab->fab$l_stv);
  649. X    `7D
  650. X#endif
  651. X    free_up();
  652. X`7D
  653. X
  654. X#ifdef DEBUG
  655. Xdump_rms_block(p)
  656. X    unsigned char *p;
  657. X`7B
  658. X    unsigned char bid, len;
  659. X    int err;
  660. X    char *type;
  661. X    char buf`5B132`5D;
  662. X    int i;
  663. X
  664. X    err = 0;
  665. X    bid = p`5B0`5D;
  666. X    len = p`5B1`5D;
  667. X    switch (bid)
  668. X    `7B
  669. X`09case FAB$C_BID:
  670. X`09    type = "FAB";
  671. X`09    break;
  672. X`09case XAB$C_ALL:
  673. X`09    type = "xabALL";
  674. X`09    break;
  675. X`09case XAB$C_KEY:
  676. X`09    type = "xabKEY";
  677. X`09    break;
  678. X`09case XAB$C_DAT:
  679. X`09    type = "xabDAT";
  680. X`09    break;
  681. X`09case XAB$C_RDT:
  682. X`09    type = "xabRDT";
  683. X`09    break;
  684. X`09case XAB$C_FHC:
  685. X`09    type = "xabFHC";
  686. X`09    break;
  687. X`09case XAB$C_PRO:
  688. X`09    type = "xabPRO";
  689. X`09    break;
  690. X`09default:
  691. X`09    type = "Unknown";
  692. X`09    err = 1;
  693. X`09    break;
  694. X    `7D
  695. X    printf("Block @%08X of type %s (%d).", p, type, bid);
  696. X    if (err)
  697. X    `7B
  698. X`09printf("\n");
  699. X`09return;
  700. X    `7D
  701. X    printf(" Size = %d\n", len);
  702. X    printf(" Offset - Hex - Dec\n");
  703. X    for (i = 0; i < len; i += 8)
  704. X    `7B
  705. X`09int j;
  706. X
  707. X`09printf("%3d - ", i);
  708. X`09for (j = 0; j < 8; j++)
  709. X`09    if (i + j < len)
  710. X`09`09printf("%02X ", p`5Bi + j`5D);
  711. X`09    else
  712. X`09`09printf("   ");
  713. X`09printf(" - ");
  714. X`09for (j = 0; j < 8; j++)
  715. X`09    if (i + j < len)
  716. X`09`09printf("%03d ", p`5Bi + j`5D);
  717. X`09    else
  718. X`09`09printf("    ");
  719. X`09printf("\n");
  720. X    `7D
  721. X`7D
  722. X
  723. X#endif`09`09`09`09/* DEBUG */
  724. X
  725. Xstatic void message(string, status)
  726. X    int status;
  727. Xchar *string;
  728. X`7B
  729. X    char msgbuf`5B256`5D;
  730. X
  731. X    $DESCRIPTOR(msgd, msgbuf);
  732. X    int msglen = 0;
  733. X
  734. X    if (ERR(lib$sys_getmsg(&status, &msglen, &msgd, 0, 0)))
  735. X`09fprintf(stderr, "%s`5B VMS status = %d `5D\n", string, status);
  736. X    else
  737. X    `7B
  738. X`09msgbuf`5Bmsglen`5D = 0;
  739. X`09fprintf(stderr, "%s`5B %s `5D\n", string, msgbuf);
  740. X    `7D
  741. X`7D
  742. X
  743. X
  744. X#endif`09`09`09`09/* !ZIPINFO */
  745. X#endif`09`09`09`09/* VMS */
  746. $ CALL UNPACK [.UNZIP50]VMS.C;1 908005245
  747. $ create 'f'
  748. X                     VMS Notes for UnZip 5.0
  749. X                           24 May 1992
  750. X
  751. X
  752. XThe various VMS tweaks to UnZip 5.0 and ZipInfo 0.97 were tested on a`20
  753. XVAX 8600 running VMS 5.2 (and, later, VMS 5.4) and VAX C 3.0.  Older`20
  754. Xversions were also tested on a VAX 11/785.
  755. X
  756. XTo build UnZip (and its trusty sidekick, ZipInfo), just run one of the`20
  757. Xincluded command files MAKE_UNZIP_VAXC.COM or MAKE_UNZIP_GCC.COM, either
  758. Xdecryption or non-decryption versions, depending on whether you have the
  759. Xseparate crypt.c module and whether you use VAX C or GNU C (for example,`20
  760. X"@make_unzip_vaxc").  By default, this creates shareable-image executables,
  761. Xwhich are smaller and (supposedly) load faster than the normal type.  They`2
  762. V0
  763. Xalso (supposedly) will be better able to take advantage of any bug fixes`20
  764. Xor new capabilities that DEC might introduce, since the library code isn't`2
  765. V0
  766. Xbuilt into the executable.  The shared executable is about a quarter the`20
  767. Xsize of the ordinary type in the case of UnZip.
  768. X
  769. X`5BBtw, the VMS make utility "MMS" is not compatible enough with Unix make`2
  770. V0
  771. Xto use the same makefile.  Antonio Querubin, Jr., sent along an MMS makefile
  772. V,
  773. Xsubsequently modified by Igor Mandrichenko.  Read the comments at the top`20
  774. Xof DESCRIP.MMS for more info.  An alternate Unix-like makefile designed for`
  775. V20
  776. Xuse with Todd Aven's MAKE/VMS is included, as well.  Comments on where to
  777. Xget MAKE/VMS are at the bottom of VMS Contents.`5D
  778. X
  779. XUnZip is written to return the standard PK-type return codes (or error
  780. Xcodes, or exit codes, or whatever you want to call them).  Unfortunately,
  781. XVMS insists on interpreting the codes in its own lovable way, and this
  782. Xresults in endearing commentary such as "access violation, error mask =
  783. X0005, PC = 00003afc" (or something like that) when you run UnZip with no
  784. Xarguments.  To avoid this I've added a special VMS_return() function which
  785. Xeither ignores the error codes (and exits with normal status) or interprets
  786. Xthem, prints a semi-informative message (enclosed in square `5B`5D brackets)
  787. V,`20
  788. Xand then exits with a normal error status.  I personally can't stand the`20
  789. Xlatter behavior, so by default the error codes are simply ignored.  Tastes
  790. Xvary, however, and some people may actually like semi-informative messages.
  791. XIf you happen to be one of those people, you may enable the messages by`20
  792. Xrecompiling misc.c with RETURN_CODES defined.  (This adds a block or two
  793. Xto the executable size, though.)  The syntax is as follows:
  794. X`09cc /def=(RETURN_CODES) misc
  795. X
  796. XTo use UnZip in the normal way, define a symbol "unzip" as follows:
  797. X`09unzip :== "$diskname:`5Bdirectory`5Dunzip.exe"
  798. X(substitute for "diskname" and "directory" as appropriate, and DON'T FORGET
  799. XTHE `60$'!  It won't work if you omit that.)  In general it's wise to stick`
  800. V20
  801. Xsuch assignments in your LOGIN.COM file and THEN forget about them.  It is`2
  802. V0
  803. Xno longer necessary to worry about the record type of the zipfile...er,`20
  804. Xwell, most of the time, anyway (see the Kermit section below).
  805. X
  806. XHaving done all this you are ready to roll.  Use the unzip command in
  807. Xthe usual way; as with the Unix, OS/2 and MS-DOS versions, this one uses`20
  808. X'-' as a switch character.  If nothing much happens when you do a directory
  809. Xlisting, for example, you're probably trying to specify a filename which
  810. Xhas uppercase letters in it...VMS thoughtfully converts everything on the
  811. Xcommand line to lowercase, so even if you type:
  812. X`09unzip -v zipfile Makefile
  813. Xwhat you get is:
  814. X`09unzip -v zipfile makefile
  815. Xwhich, in my example here, doesn't match the contents of the zipfile.
  816. XThis is relatively easy to circumvent by enclosing the filespec(s) in`20
  817. Xquotes:
  818. X`09unzip -tq unzip401 "Makefile" "VMS*" *.c *.h
  819. X`5BThis example also demonstrates the use of wildcards, which act like Unix
  820. Xwildcards, not VMS ones.   In other words, "VMS*" matches files VMSNOTES,
  821. XVMS_MAKE.COM, and VMSSHARE.OPT, whereas the normal VMS behavior would be
  822. Xto match only the first file (since the others have extensions--ordinarily,
  823. Xyou would be required to specify "VMS*.*").`5D
  824. X
  825. XNote that created files get whatever default permissions you've set, but`20
  826. Xcreated directories additionally inherit the (possibly more restrictive)`20
  827. Xpermissions of the parent directory.  And, of course, things probably won't`
  828. V20
  829. Xwork too well if you don't have permission to write to whatever directory`20
  830. Xinto which you're trying to extract things.  (That made sense; read it`20
  831. Xagain if you don't believe me.)
  832. X
  833. XZipInfo, by the way, is an amusing little utility which tells you all sorts
  834. Xof amazingly useless information about zipfiles.  Occasionally it's useful
  835. Xto debug a problem with a corrupted zipfile (for example, we used it to`20
  836. Xfind a bug in PAK-created zipfiles, versions 2.5 and earlier).  Feel free
  837. Xto blow it away if you don't need it.  It's about 30 blocks on my system,
  838. Xand I find I actually prefer its listing format to that of UnZip now (hardly
  839. Xsurprising, since I wrote it :-) ).  I also find it useful to use "ii"`20
  840. Xrather than "zipinfo" as the symbol for zipinfo, since it's easier to type`2
  841. V0
  842. Xthan either "zipinfo" or "unzip -v", and it echoes the common Unix alias`20
  843. X"ll" for the similar style of directory listings.  Oh, and the reason it's`2
  844. V0
  845. Xstill got a beta version number is that I haven't finished it yet--it would`
  846. V20
  847. Xbe better with an automatic paging function, for example.  Oh well.
  848. X
  849. XRANDOM OTHER NOTES:  (1) Igor Mandrichenko (leader of our fearless Russian`2
  850. V0
  851. Xcontingent) rewrote major portions of the VMS file-handling code, with
  852. Xthe result that UnZip is much smarter now about VMS file formats.  For
  853. Xfull VMS compatibility (file attributes, ownership info, etc.), be sure
  854. Xto use the -X option of Zip 1.6 and later.  There are also some notes
  855. Xat the end of this file from Hugh Schmidt and Mike Freeman which give`20
  856. Xhints on how to save VMS attributes using Zip 1.0 and UnZip 4.1.  Most of
  857. Xthe information is still valid, but the -X option is much easier if you
  858. Xdon't have to transfer the zipfiles to a Unix or PC system.  (2) Zip 1.0`20
  859. Xcannot handle any zipfile that isn't in stream-LF format, so you may need`20
  860. Xto use Rahul Dhesi's BILF utility which is included with UnZip.  It will
  861. Xalso be necessary for certain other special occasions, like when you've`20
  862. Xforgotten to set the correct Kermit parameters while uploading a zipfile`20
  863. X(see Hugh Schmidt's note below for comments about Kermit, too).
  864. X
  865. XGreg Roelofs
  866. X
  867. X====================
  868. X
  869. XFrom INFO-ZIP Digest (Wed, 6 Nov 1991), Volume 91, Issue 290
  870. X
  871. X                VMS attributes and PKZIP compatibility
  872. X                  VMS attributes restored! (2 msgs)
  873. X
  874. X------------------------------
  875. X
  876. XDate: Tue, 5 Nov 91 15:31 CDT
  877. XFrom: Hugh Schmidt <HUGH@macc.wisc.edu>
  878. XSubject: VMS attributes and PKZIP compatibility
  879. XMessage-ID: <21110515313938@vms.macc.wisc.edu>
  880. X
  881. X           ******************************************************
  882. X(1)        *** Retaining VMS attributes - a proposed strategy ***
  883. X           ******************************************************
  884. X
  885. XThis is a proposed strategy for recovering VMS file attributes after
  886. Xzip/unzip:
  887. X
  888. Xa) capture VMS file attributes: VMS ANALYZE/RMS/FDL/OUTPUT=fdlfile vmsfile.e
  889. Vxt
  890. Xb) compress files on VMS......: ZIP zipfile vmsfile.ext, fdlfile.fdl
  891. Xc) uncompress files on VMS....: UNZIP zipfile vmsfile.ext, fdlfile.fdl
  892. Xd) recover VMS file attributes: CONVERT/FDL=fdlfile.fdl vmsfile.ext vmsfile.
  893. Vext
  894. X
  895. XThe wrinkle is that UNZIP creates files which are unreadable by CONVERT
  896. Xdespite a concerted effort to accomodate VMS file management system:
  897. X
  898. Xfile_io.c, line 178: ...creat(filename,0, "rat=cr", "rfm=streamlf")
  899. X
  900. XThese files are unCONVERTABLE because they appear to VMS to contain
  901. Xrecords with 512+ bytes.  Poring over VMS manuals (Programming V-6A, VAX
  902. XC RTL Reference Manual) doesn't readily suggest better alternatives.
  903. XExperimentation with "rat=fix", etc. may help suppress the spurious
  904. Xblock-end delimeters.
  905. X
  906. X          ****************************************************
  907. X(2)       *** VMS ZIP and PKZIP compatibility using KERMIT ***
  908. X          ****************************************************
  909. X
  910. XMany use Procomm's kermit to transfer zipped files between PC and VMS
  911. XVAX.  The following VMS kermit settings make VMS-ZIP compatible with
  912. XPKZIP:
  913. X
  914. X                                             VMS kermit      Procomm kermit
  915. X                                           ---------------   --------------
  916. XUploading PKZIPped file to be UNZIPped:    set fi ty fixed    set fi ty bi
  917. XDownloading ZIPped file to be PKUNZIPped:  set fi ty block    set fi ty bi
  918. X
  919. X"Block I/O lets you bypass the VMS RMS record-processing capabilities
  920. Xentirely", (Guide to VMS file applications, Section 8.5).  The kermit
  921. Xguys must have known this!
  922. X
  923. X         ************************************************
  924. X(3)      *** Making ZIP files compatible with VMS RMS ***
  925. X         ************************************************
  926. X
  927. XIt looks like a crummy patch, but to make VMS RMS happy, I inserted the
  928. Xfollowing near line 570 in the putend() section of zipfile.c:
  929. X
  930. X#ifdef VMS
  931. X fprintf(f,"\n")
  932. X#endif
  933. X
  934. XIt's probably of no consequence, but it satisfies VMS ANALYZE.
  935. X
  936. X------------------------------
  937. X
  938. XDate: Tue, 5 Nov 91 19:40 CDT
  939. XFrom: Hugh Schmidt <HUGH@macc.wisc.edu>
  940. XSubject: VMS attributes restored!
  941. XMessage-ID: <21110519403912@vms.macc.wisc.edu>
  942. X
  943. X           ************************************************************
  944. X           ***   Aha!  It works!  VMS attributes can be restored! *****
  945. X           ***                                                      ***
  946. X           *** Change FAB$C_STMLF to FAB$C_FIX in file_io.c         ***
  947. X           *** ANALYZE => .FDL `7C CONVERT => original VMS attributes ***
  948. X           ************************************************************
  949. X
  950. X(1) Change line 147 in file_io.c and dropping lines 148-149:
  951. X
  952. X    fileblk.fab$b_rfm = FAB$C_STMLF;    /* stream-LF record format */
  953. X    fileblk.fab$b_rat = FAB$M_CR;       /* carriage-return carriage ctrl */
  954. X    /*                      `5E`5E`5E`5E *NOT* V_CR!!!     */
  955. X
  956. X=>
  957. X
  958. X    fileblk.fab$b_rfm = FAB$C_FIX;    /* fixed record format */
  959. X
  960. X(2) Use VMS ANALYZE to store the VMS attributes for the original file
  961. X    into a file descripion language file.  Save the .FDL file with the
  962. X    original file.
  963. X
  964. X(3) Apply the original attributes to the UNZIPped file using VMS CREATE
  965. X    and the description file (test.fdl).
  966. X
  967. XIn the following example, the original attributes of a SPSSX system
  968. Xformat file were restored.  Later, SPSSX successfully read the UNZIPped/
  969. XCONVERTed file.
  970. X
  971. X!******** Procedure (or method for you ai'ers)
  972. X!********
  973. X!******** Create an .FDL file using ANALYZE
  974. X
  975. X$ analyze/rms/fdl/out=test test.spssxsav;1
  976. X
  977. X!******** ZIP the file and its description file
  978. X
  979. X$ zip test test.spssxsav;1 test.fdl;1
  980. Xadding test.spssxsav (imploded 62%)
  981. Xadding test.fdl (imploded 90%)
  982. X
  983. X!******** When the ZIPPED file is needed, UNZIP it and its description file
  984. X
  985. X$ unzip test
  986. X  Exploding: test.spssxsav
  987. X  Exploding: test.fdl
  988. X
  989. X!******** To restore the original attributes, apply the description file to
  990. X!********  the UNZIPped file using VMS CONVERT
  991. X
  992. X$ convert/fdl=test  test.spssxsav;2 test.spssxsav;3
  993. X
  994. X! ******* The following show that the VMS attributes are restored.
  995. X
  996. X$ analyze/rms/check test.spssxsav;1
  997. X
  998. X`09File Spec: PROJDISK5:`5B322042.CORE`5DTEST.SPSSXSAV;1
  999. X`09File Organization: sequential
  1000. X`09Record Format: fixed
  1001. X`09Record Attributes:
  1002. X`09Maximum Record Size: 4
  1003. X`09Longest Record: 4
  1004. X
  1005. XThe analysis uncovered NO errors.
  1006. X
  1007. X$ analyze/rms/check test.spssxsav;2
  1008. X`09File Spec: PROJDISK5:`5B322042.CORE`5DTEST.SPSSXSAV;2
  1009. X`09File Organization: sequential
  1010. X`09Record Format: undefined
  1011. X`09Record Attributes:
  1012. X`09Maximum Record Size: 0
  1013. X`09Longest Record: 512
  1014. XThe analysis uncovered NO errors.
  1015. X
  1016. X$ analyze/rms/check test.spssxsav;3
  1017. X`09File Spec: PROJDISK5:`5B322042.CORE`5DTEST.SPSSXSAV;3
  1018. X`09File Organization: sequential
  1019. X`09Record Format: fixed
  1020. X`09Record Attributes:
  1021. X`09Maximum Record Size: 4
  1022. X`09Longest Record: 4
  1023. X
  1024. XThank you all for your help and comments.  It was very reasurring to
  1025. Xknow that I was on the right track.  This is a humble contribution
  1026. Xcompared to the great efforts of others in the ZIP project.
  1027. X
  1028. X------------------------------
  1029. X
  1030. XDate: Wed, 6 Nov 91 12:49:33 EST
  1031. XFrom: Mike Freeman <freeman@watsun.cc.columbia.edu>
  1032. XSubject: Re: VMS attributes restored!
  1033. XMessage-ID: <CMM.0.90.0.689449773.freeman@watsun.cc.columbia.edu>
  1034. X
  1035. XHello, all.
  1036. X
  1037. XHUGH@macc.wisc.edu has come up with a commendable method for saving/
  1038. Xrestoring record attributes in Vax/VMS files when ZIPping/UNZIPping.
  1039. XThere are a couple of potential problems in his specific implementation,
  1040. Xhowever:
  1041. X
  1042. X(a) It would be better to leave the output file(s) in STREAM_LF format
  1043. X    and use Joe Meadows' FILE utility to put them in fixed-record
  1044. X    format if CONVERT has trouble reading them.
  1045. X
  1046. X    Outputting a text file as fixed-record format could be a pain, and
  1047. X    one would have to use FILE anyway.
  1048. X
  1049. X    (Incidentally, I ZIPped up a text file, UNZIPped it and used Hugh's
  1050. X    method to restore the attributes.  CONVERT had no trouble with the
  1051. X    STREAM_LF format -- it's only a problem with binary files and, as I
  1052. X    say, Joe Meadows' FILE will fix this.)
  1053. X
  1054. X(b) Even if ANALYZE/RMS complains, I do not think one ought to put the
  1055. X    "\n" in as Hugh advocates.  This contradicts the ZIP philosophy of
  1056. X    byte-for-byte storage/retrieval.
  1057. X
  1058. X    As Mr. Roelofs has said, there is nothing wrong with the ZIP file;
  1059. X    it's just that ANALYZE/RMS expects STREAM_LF files to end in an
  1060. X    <LF>.
  1061. X
  1062. XAnyway, I was able to use Hugh's method without modifying ZIP 1.0.  We
  1063. Xreally ought to get the word out about FILE, though -- it's very handy.
  1064. X
  1065. XMike Freeman, K7UIJ     `7C       Internet: freeman@watsun.cc.columbia.edu
  1066. X301 N.E. 107th Street   `7C       GEnie: M.FREEMAN11
  1067. XVancouvEr, WA 98685 USA `7C       Confidence is the feeling you have
  1068. XTelephone (206)574-8221 `7C       before you understand the situation.
  1069. X
  1070. X------------------------------
  1071. X
  1072. $ CALL UNPACK [.UNZIP50]VMS.NOTES;1 1631926756
  1073. $ create 'f'
  1074. Xsys$library:vaxcrtl.exe/share
  1075. $ CALL UNPACK [.UNZIP50]VMSSHARE.OPT;1 2088265681
  1076. $ create 'f'
  1077. X__________________________________________________________________________
  1078. X
  1079. X  This is the Info-ZIP file `60`60Where,'' last updated on 20 August 1992.
  1080. X__________________________________________________________________________
  1081. X
  1082. X
  1083. X  SITE OWNERS:  If you're listed in here but the information is not
  1084. X  correct (or if you're a big site but aren't listed at all), please
  1085. X  let us know!  E-mail to zip-bugs at the address given in Readme
  1086. X  and we'll update this file.
  1087. X
  1088. XBasic source-archive names for Info-ZIP's portable Zip, UnZip, and related
  1089. Xutilities (on some ftp sites, the .zip files may have a .zoo equivalent
  1090. Xin zoo 2.10 format):
  1091. X
  1092. X`09zip19.zip`09Zip 1.9 (includes zipnote and zipsplit)
  1093. X`09zip19.tar.Z`09ditto, compress'd tar format
  1094. X
  1095. X`09unzip50.zip`09UnZip 5.0 (includes zipinfo and funzip)
  1096. X`09unzip50.tar.Z`09ditto, compress'd tar format
  1097. X
  1098. X`09wunz12sr.zip`09WizUnZip 1.2 support files for Windows 3.1, UnZip 5.0
  1099. X
  1100. X`09zcrypt19.zip`09encryption/decryption support (includes zipcloak)
  1101. X
  1102. XRelated archives and files:
  1103. X
  1104. X`09UnzpHist.zip`09changes history of UnZip, back to 2.0
  1105. X
  1106. X`09zip19x.zip      MSDOS executables and docs for zip, zipnote, zipsplit
  1107. X`09unzip50.exe     MSDOS executable for unzip
  1108. X
  1109. X`09zip19_16.zip`09OS/2 1.x 16-bit executables and docs
  1110. X`09zip19_32.zip`09OS/2 2.x 32-bit executables and docs
  1111. X`09unz50_16.exe`09OS/2 1.x 16-bit executable
  1112. X`09unz50_32.exe`09OS/2 2.x 32-bit executable
  1113. X
  1114. X`09zip19vms.zip`09VMS executables and docs for zip, zipnote, zipsplit
  1115. X`09unz50vms.exe`09VMS executable for unzip
  1116. X
  1117. X`09zip_unzip.hqx   Macinstosh executables (zip 1.0 only, 1.9 not ready)
  1118. X
  1119. X`09winunz12.zip    Windows 3.1 executables (zip 1.0 only, 1.9 not ready)
  1120. X
  1121. X`09pkz110eu.exe`09MS-DOS PKZIP/PKUNZIP 1.1 (self-extracting archive)
  1122. X`09pkz193a.exe`09MS-DOS PKZIP/PKUNZIP beta 1.93 (self-extracting)
  1123. X`09pkz102-2.exe`09OS/2 PKZIP/PKUNZIP 1.02 (self-extracting)
  1124. X
  1125. Xftp sites for the US-exportable sources and executables.  Look for
  1126. Xthe file names given above in the following directories.  Some sites
  1127. Xlike to use slightly different names, such as zip-1.9.tar-z instead
  1128. Xof zip19.tar.Z.
  1129. X
  1130. X`09wuarchive.wustl.edu:/packages/compression/...
  1131. X`09wuarchive.wustl.edu:/mirrors/misc/unix/...
  1132. X`09wuarchive.wustl.edu:/mirrors/misc/vaxvms/...
  1133. X`09wuarchive.wustl.edu:/mirrors/msdos/zip/...
  1134. X`09wuarchive.wustl.edu:/mirrors/msdos/windows3/...
  1135. X
  1136. X`09ftp.uu.net:/pub/zip/...
  1137. X
  1138. X`09ftp-os2.nmsu.edu:/pub/os2/2.0/archivers/...
  1139. X`09ftp-os2.nmsu.edu:/pub/os2/all/archivers/...
  1140. X
  1141. X`09Zip 1.9 and UnZip 5.0 will also be available at any comp.sources.misc
  1142. X`09archive site as soon as they are posted.
  1143. X
  1144. X`09wuarchive.wustl.edu:/mirrors/msdos/zip/pkz110eu.exe
  1145. X`09ux1.cso.uiuc.edu:/pc/exec-pc/pkz193a.exe`09`5B128.174.5.59`5D
  1146. X
  1147. Xftp sites for the encryption and decryption sources:
  1148. X
  1149. X`09NOTE:  Non-US users, please do NOT ftp from the US site (US
  1150. X`09regulations and all that).  Likewise, US users, please do not
  1151. X`09ftp from the European sites (it's not illegal, but it sure is
  1152. X`09a waste of expensive bandwidth).
  1153. X
  1154. X`09From the US:
  1155. X`09   wuarchive.wustl.edu:/mirrors3/garbo.uwasa.fi/arcutil/zcrypt19.zip
  1156. X
  1157. X`09Outside the US:
  1158. X`09   garbo.uwasa.fi:/pc/arcutil/zcrypt19.zip
  1159. X`09   ftp.win.tue.nl:/pub/compression/zip/zcrypt19.zip
  1160. X`09   ftp.inria.fr:/system/arch-compr/zcrypt19.zip
  1161. X`09   ftp.informatik.tu-muenchen.de:/pub/utils/archiver/zcrypt19.zip
  1162. X`09     (mail server at ftp-mailer@ftp.informatik.tu-muenchen.de)
  1163. X
  1164. XTo find other ftp sites:
  1165. X
  1166. X`09The "archie" ftp database utility can be used to find an ftp site
  1167. X`09near you.  If you don't know how to use it, DON'T ASK US--check the
  1168. X`09Usenet groups news.newusers.questions or news.answers or some such,
  1169. X`09or ask your system administrator.
  1170. X
  1171. XUUCP sites:
  1172. X
  1173. X`09uunet!`7E/pub/zip/ ...
  1174. X
  1175. XMail servers:
  1176. X
  1177. X`09If you don't have anonymous FTP capability, you can mail one
  1178. X`09of the following commands (in the body of an e-mail message) to
  1179. X`09listserv@vm1.nodak.edu or listserv@vm.ecs.rpi.edu in order to
  1180. X`09get a copy via e-mail:
  1181. X
  1182. X`09/pdget mail pd:<misc.unix>unzip50.tar-z uuencode
  1183. X`09/pdget mail pd:<misc.unix>zip19.zip uuencode
  1184. X   or:`09/pdget mail pd:<misc.unix>zip19.tar-z uuencode
  1185. X
  1186. X`09To get the encryption source by email, send the following commands
  1187. X`09to ftp-mailer@ftp.informatik.tu-muenchen.de:
  1188. X
  1189. X`09get /pub/utils/archiver/zcrypt19.zip
  1190. X        quit
  1191. X
  1192. X__________________________________________________________________________
  1193. X
  1194. XAgain, if someone repackages any of the source or executable archives in
  1195. XVMS-, Mac- or Atari-specific formats, please let us know (send e-mail to`20
  1196. Xzip-bugs at the address listed in README).
  1197. X__________________________________________________________________________
  1198. X
  1199. $ CALL UNPACK [.UNZIP50]WHERE.;1 1668754520
  1200. $ create 'f'
  1201. X/* This is a dummy zip.h to allow crypt.c from Zip to compile for unzip */
  1202. X
  1203. X#include "unzip.h"
  1204. X#define SKIP_TIME_H   /* don't include time.h again in crypt.c */
  1205. X
  1206. X#define local
  1207. Xtypedef unsigned short ush;
  1208. Xtypedef unsigned long ulg;
  1209. X
  1210. Xextern ULONG crc_32_tab`5B`5D;
  1211. X#define crc32(c, b) (crc_32_tab`5B((int)(c) `5E (b)) & 0xff`5D `5E ((c) >> 8
  1212. V))
  1213. $ CALL UNPACK [.UNZIP50]ZIP.H;1 708390145
  1214. $ create 'f'
  1215. X.de X
  1216. X.nf
  1217. X.ien .ti -5
  1218. X.el \`7B .ti +2m
  1219. X.ps -1 \`7D
  1220. X\&\\$1
  1221. X.ien .ti +5
  1222. X.el \`7B .ti -2m
  1223. X.ps +1 \`7D
  1224. X.fi
  1225. X..
  1226. X.TH ZIPINFO 1 "19 Aug 92 (v1.0)"
  1227. X.SH NAME
  1228. Xzipinfo \- list detailed information about a ZIP archive file
  1229. X.SH SYNOPSIS
  1230. X\fBzipinfo\fP `5B\-\fB1smlvht\fP`5D \fRfile\fP`5B\fR.zip\fP`5D `5B\fRfilespe
  1231. Vc\fP\ ...`5D
  1232. X.SH ARGUMENTS
  1233. X.IP \fIfile\fP`5B\fI.zip\fP`5D \w'`5B\fIfilespec\fP`5D'u+2m
  1234. XPath of the ZIP archive.  The suffix `60`60\fR.zip\fP'' is applied
  1235. Xif the \fRfile\fP specified does not exist.  Note that
  1236. Xself-extracting ZIP files are supported; just specify
  1237. Xthe `60`60\fR.exe\fP'' suffix yourself.
  1238. X.IP `5B\fIfilespec\fP`5D
  1239. XAn optional list of archive members to be processed.
  1240. XExpressions may be used to match multiple members; be sure to quote
  1241. Xexpressions that contain characters interpreted by the Unix shell. See
  1242. XPATTERN MATCHING (below) for more details.
  1243. X.SH OPTIONS
  1244. X.PD 0
  1245. X.IP \-1 \w'\-1'u+2m
  1246. Xlist filenames only, one per line (useful for pipes)
  1247. X.IP \-s
  1248. Xlist zipfile info in short Unix `60`60ls \-l'' format:  default
  1249. X.IP \-m
  1250. Xlist zipfile info in medium Unix `60`60ls \-l'' format
  1251. X.IP \-l
  1252. Xlist zipfile info in long Unix `60`60ls \-l'' format
  1253. X.IP \-v
  1254. Xlist zipfile information in verbose, multi-page format
  1255. X.IP \-h
  1256. Xlist header line
  1257. X.IP \-t
  1258. Xlist totals for files listed or for all files
  1259. X.PD
  1260. X.SH PATTERN MATCHING
  1261. XAll archive members are listed unless a \fIfilespec\fP is provided to`20
  1262. Xspecify a subset of the archive members.  The \fIfilespec\fP is similar`20
  1263. Xto an \fRegrep\fP expression, and may contain:
  1264. X.PP
  1265. X.ta \w'`5B...`5D'u+2m
  1266. X*`09matches a sequence of 0 or more characters
  1267. X.br
  1268. X?`09matches exactly 1 character
  1269. X.br
  1270. X\\nnn`09matches the character having octal code nnn
  1271. X.PD 0
  1272. X.IP `5B...`5D \w'`5B...`5D'u+2m
  1273. Xmatches any single character found inside the brackets; ranges
  1274. Xare specified by a beginning character, a hyphen, and an ending
  1275. Xcharacter.  If an exclamation point or a carat (`60!' or `60`5E') follows
  1276. Xthe left bracket, then the range of characters matched is complemented
  1277. Xwith respect to the ASCII character set (that is, anything except the
  1278. Xcharacters inside the brackets is considered a match).
  1279. X.PD
  1280. X.SH DESCRIPTION
  1281. X.I ZipInfo
  1282. Xlists technical information about a ZIP archive, including information
  1283. Xfile access permissions, encryption status, type of compression, version
  1284. Xand operating system of compressing program, and the like.  The default
  1285. Xoption is to list files in the following format:
  1286. X.PP
  1287. X.X "-rw-rwl---  1.5 unx    2802 t- defX 11-Aug-91 13:48 perms.2660"
  1288. X.PP
  1289. XThe last three fields are clearly the modification date and time of
  1290. Xthe file, and its name.  The case of the filename is respected; thus
  1291. Xfiles which come from MS-DOS PKZIP are always capitalized.  If the file
  1292. Xwas zipped with a stored directory name, that is also displayed as part
  1293. Xof the filename.
  1294. X.PP
  1295. XThe second and third fields indicate that the file was zipped under
  1296. XUnix with version 1.5 of \fRZip\fP (a beta version).  Since it comes
  1297. Xfrom Unix, the file
  1298. Xpermissions at the beginning of the line are printed in Unix format.
  1299. XThe uncompressed file-size (2802 in this example) is the fourth field.
  1300. X.PP
  1301. XThe fifth field consists of two characters, either of which may take
  1302. Xon several values.  The first character may be either `60t' or `60b', indica
  1303. Vting
  1304. Xthat \fRZip\fP believes the file to be text or binary, respectively;
  1305. Xbut if the file is encrypted, \fIZipInfo\fP
  1306. Xnotes this fact by capitalizing the character (`60T' or `60B').  The second
  1307. Xcharacter may also take on four values, depending on whether there is
  1308. Xan extended local header and/or an `60`60extra field'' associated with the
  1309. Xfile (explained in PKWare's APPNOTE.TXT).  If neither exists, the character
  1310. Xwill be a hyphen (`60\-'); if there is an extended local header but no extra
  1311. Xfield, `60l'; if the reverse, `60x'; and if both exist, `60X'.  Thus the
  1312. Xfile in this example is (apparently) a text file, is not encrypted, and
  1313. Xhas neither an extra field nor an extended local header associated with it.
  1314. XThe example below, on the other hand, is an encrypted binary file with an`20
  1315. Xextra field:
  1316. X.PP
  1317. X.X "RWD,R,R     0.9 vms     168 Bx shrk  9-Aug-91 19:15 perms.0644"
  1318. X.PP
  1319. XExtra fields are used by PKWare for authenticity verification(?) and
  1320. Xpossibly other purposes, and by Info-ZIP's \fRZip\fP
  1321. X1.6 and later to store OS/2, Macintosh and VMS file attributes.
  1322. XThis example presumably falls into
  1323. Xthe latter class, then.  Note that the file attributes are listed in
  1324. XVMS format.  Other possibilities for the host operating system include
  1325. XOS/2 with High Performance File System (HPFS), DOS or OS/2 with File`20
  1326. XAllocation Table (FAT) file system, and Macintosh, denoted
  1327. Xas follows:
  1328. X.PP
  1329. X.X "arc,,rw,    1.0 os2    5358 Tl i4:3  4-Dec-91 11:33 longfilename.hpfs"
  1330. X.X "arc,hid,rdo,sys dos    4096 b- i4:2 14-Jul-91 12:58 EA DATA. SF"
  1331. X.X "--w-------  1.0 mac   17357 bx i8:2  4-May-92 04:02 unzip.macr"
  1332. X.PP
  1333. XFile attributes in the first two cases are indicated in a DOS-like format,
  1334. Xwhere the file may or may not have its archive bit set; may be hidden or not
  1335. V;
  1336. Xmay be read-write or read-only; and may be a system file or not.  If the
  1337. Xattributes are too long, the version number of the encoding software is
  1338. Xomitted.  (The information is still available in the verbose listing,`20
  1339. Xhowever.)  Interpretation of Macintosh file attributes needs some work yet.
  1340. X.PP
  1341. XFinally, the sixth field indicates
  1342. Xthe compression method and possible sub-method used.  There are six methods
  1343. Xknown at present:  storing (no compression), reducing, shrinking, imploding,
  1344. Xtokenizing, and deflating.  In addition, there are four levels of reducing
  1345. X(1 through 4); four types of imploding (4K or 8K sliding dictionary, and
  1346. X2 or 3 Shannon-Fano trees); and three levels of deflating (fast, normal,
  1347. Xmaximum compression).  \fIZipInfo\fP represents these methods and their
  1348. Xsub-methods as follows:  `60`60stor''; `60`60re:1,'' `60`60re:2,'' etc.; `60
  1349. V`60shrk'';
  1350. X`60`60i4:2,'' `60`60i8:3,'' etc.; `60`60tokn''; and `60`60defF,'' `60`60defN
  1351. V,'' and `60`60defX.''
  1352. X.PP
  1353. XThe medium and long listings are almost identical to the
  1354. Xshort format except that they add information on the file's
  1355. Xcompression.  The medium format indicates the file's
  1356. Xcompression factor as a percentage:
  1357. X.PP
  1358. X.X "-rw-rwl---  1.5 unx    2802 t- 81% defX 11-Aug-91 13:48 perms.2660"
  1359. X.PP
  1360. XIn this example, the file has been compressed by more than a factor of
  1361. Xfive; the compressed data are only 19% of the original size.  The long
  1362. Xformat gives the compressed file's size in bytes, instead:
  1363. X.PP
  1364. X.X "-rw-rwl---  1.5 unx    2802 t-     538 defX 11-Aug-91 13:48 perms.2660"
  1365. X.PP
  1366. XIn addition to individual file information, a default zipfile listing
  1367. Xalso includes header and trailer lines:
  1368. X.PP
  1369. X.X "Archive:  OS2.zip   5453 bytes   5 files"
  1370. X.X ",,rw,       1.0 os2     730 b- i4:3 26-Jun-92 23:40 Contents"
  1371. X.X ",,rw,       1.0 os2    3710 b- i4:3 26-Jun-92 23:33 makefile.os2"
  1372. X.X ",,rw,       1.0 os2    8753 b- i8:3 26-Jun-92 15:29 os2unzip.c"
  1373. X.X ",,rw,       1.0 os2      98 b- stor 21-Aug-91 15:34 unzip.def"
  1374. X.X ",,rw,       1.0 os2      95 b- stor 21-Aug-91 17:51 zipinfo.def"
  1375. X.X "5 files, 13386 bytes uncompressed, 4951 bytes compressed:  63%"
  1376. X.PP
  1377. XThe header line gives the name of the archive, its total size, and the
  1378. Xtotal number of files; the trailer gives the number of files listed,
  1379. Xtheir total uncompressed size, and their total compressed size (not
  1380. Xincluding any of \fRZip\fP's internal overhead).  If, however, one or`20
  1381. Xmore \fIfilespec\fPs are provided, the header and trailer lines are
  1382. Xnot listed.  This behavior is also similar to that of Unix's `60`60ls \-l'';
  1383. Xit may be overridden by specifying the \-h and \-t options explicitly.
  1384. XIn such a case the listing format must also be specified explicitly,
  1385. Xsince \-h or \-t (or both) in the absence of other options implies
  1386. Xthat ONLY the header or trailer line (or both) is listed.  See the
  1387. XEXAMPLES section below for a semi-intelligible translation of this
  1388. Xnonsense.
  1389. X.PP
  1390. XThe verbose listing is self-explanatory.  It also lists file
  1391. Xcomments and the zipfile comment, if any, and the number of
  1392. Xbytes of OS/2 extended attributes stored.  Note that the
  1393. Xlatter number will in general NOT match the number given by
  1394. XOS/2's `60`60dir'' command; OS/2 always reports the number of
  1395. Xbytes required in 16-bit format, whereas \fIZipInfo\fP
  1396. Xalways reports the 32-bit storage.
  1397. X.PD
  1398. X.SH ENVIRONMENT OPTIONS
  1399. XModifying \fIZipInfo\fP's default behavior via options placed in
  1400. Xan environment variable can be a bit complicated to explain, due to
  1401. X\fIZipInfo\fP's attempts to handle various defaults in an intuitive,
  1402. Xyet Unix-like, manner.  Nevertheless, there is some underlying logic.
  1403. XIn brief,`20
  1404. Xthere are three `60`60priority levels'' of options:  the default options;
  1405. Xenvironment options, which can override or add to the defaults; and`20
  1406. Xexplicit options given by the user, which can override or add to`20
  1407. Xeither of the above.
  1408. X.PP
  1409. XThe default listing format, as noted above, corresponds roughly
  1410. Xto the "zipinfo \-hst" command (except when individual zipfile members
  1411. Xare specified).
  1412. XA user who prefers the long-listing format (\-l) can make use of the
  1413. X\fIZIPINFO\fP environment variable to change this default:
  1414. X.ta \w'tabset'u +\w'ZIPINFO=\-l; export ZIPINFO'u+3m
  1415. X.PP
  1416. X.IP "\tsetenv ZIPINFO \-l\tUnix C shell"
  1417. X.br
  1418. X.IP "\tZIPINFO=\-l; export ZIPINFO\tUnix Bourne shell"
  1419. X.PP
  1420. X.IP "\tset ZIPINFO=\-l\tOS/2 or MS-DOS"
  1421. X.PP
  1422. X.IP "\tdefine ZIPINFO_OPTS ""\-l""\tVMS (quotes for LOWERCASE)"
  1423. X.PP
  1424. XIf, in addition, the user dislikes the trailer line, \fIZipInfo\fP's
  1425. Xconcept of `60`60negative options'' may be used to override the default
  1426. Xinclusion of the line.  This is accomplished by preceding the undesired
  1427. Xoption with one or more minuses:  e.g., `60`60\-l\-t'' or `60`60\-\-tl'', in
  1428. V this
  1429. Xexample.  The first hyphen is the regular switch character, but the one
  1430. Xbefore the `60t' is a minus sign.  The dual use of hyphens may seem a little
  1431. Xawkward, but it's reasonably intuitive nonetheless:  simply ignore the
  1432. +-+-+-+-+-+-+-+-  END  OF PART 13 +-+-+-+-+-+-+-+-
  1433.