home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3606 < prev    next >
Encoding:
Text File  |  1991-07-11  |  41.2 KB  |  1,493 lines

  1. Newsgroups: alt.sources
  2. Subject: zoo 2.1 source part 01/15
  3. Message-ID: <12767@bsu-cs.bsu.edu>
  4. From: dhesi@bsu-cs.bsu.edu (Rahul Dhesi)
  5. Date: 10 Jul 91 08:44:23 GMT
  6.  
  7. Here is version 2.1 of the zoo archiver.  It includes improved compression,
  8. better online help, VAX/VMS file timestamp preservation, faster
  9. uncompression, and other features.  An MS-DOS binary is being sent to
  10. comp.binaries.ibm.pc.
  11.  
  12. Each part of this 15-part posting is a separate shar archive.  Do not
  13. concatenate -- feed each part separately to /bin/sh in any order.
  14.  
  15. Rahul Dhesi <dhesi@bsu-cs.bsu.edu>
  16.  
  17. Checksum: 2265637808 (verify with "brik -cv")
  18. Submitted-by: dhesi@bsu-cs.bsu.edu
  19. Archive-name: zoo210/part01
  20.  
  21. ---- Cut Here and feed the following to sh ----
  22. #!/bin/sh
  23. # This is zoo210, a shell archive (produced by shar 3.49)
  24. # To extract the files from this archive, save it to a file, remove
  25. # everything above the "!/bin/sh" line above, and type "sh file_name".
  26. #
  27. # made 07/10/1991 06:47 UTC by dhesi@bsu-cs.bsu.edu
  28. # Source directory /tmp
  29. #
  30. # existing files will NOT be overwritten unless -c is specified
  31. #
  32. # This shar contains:
  33. # length  mode       name
  34. # ------ ---------- ------------------------------------------
  35. #   2176 -rw-r--r-- Checksums
  36. #   2160 -rw-r--r-- Copyright
  37. #   2138 -rw-r--r-- Install
  38. #   2706 -rw-r--r-- List
  39. #    852 -rw-r--r-- addbfcrc.c
  40. #   2097 -rw-r--r-- addbftcc.c
  41. #   3872 -rw-r--r-- addfname.c
  42. #   3097 -rw-r--r-- ar.h
  43. #    517 -rw-r--r-- asmconst.ai
  44. #    995 -rw-r--r-- assert.h
  45. #   3181 -rw-r--r-- basename.c
  46. #   6214 -rw-r--r-- bilf.c
  47. #   2650 -rw-r--r-- bsd.c
  48. #   9595 -rw-r--r-- comment.c
  49. #   2446 -rw-r--r-- crcdefs.c
  50. #    615 -rw-r--r-- debug.h
  51. #   1444 -rw-r--r-- decode.c
  52. #   4173 -rw-r--r-- descrip.mms
  53. #   7292 -rw-r--r-- encode.c
  54. #    825 -rw-r--r-- errors.i
  55. #   1814 -rw-r--r-- file.fix
  56. #   3849 -rw-r--r-- fiz.1
  57. #   6784 -rw-r--r-- fiz.c
  58. #   4227 -rw-r--r-- fiz.man
  59. #   2422 -rw-r--r-- generic.c
  60. #   4549 -rw-r--r-- getfile.c
  61. #   7757 -rw-r--r-- huf.c
  62. #   3003 -rw-r--r-- io.c
  63. #  12283 -rw-r--r-- lzc.asm
  64. #   8393 -rw-r--r-- lzc.c
  65. #    574 -rw-r--r-- lzconst.h
  66. #   9144 -rw-r--r-- lzd.asm
  67. #  29821 -rw-r--r-- lzd.c
  68. #   1255 -rw-r--r-- lzh.c
  69. #    934 -rw-r--r-- lzh.h
  70. #   1589 -rw-r--r-- machine.c
  71. #   1069 -rw-r--r-- machine.h
  72. #    369 -rw-r--r-- macros.ai
  73. #  10232 -rw-r--r-- makefile
  74. #   4490 -rw-r--r-- makefile.tcc
  75. #   6198 -rw-r--r-- makelist.c
  76. #   1836 -rw-r--r-- maketbl.c
  77. #   2836 -rw-r--r-- maketree.c
  78. #   9679 -rw-r--r-- misc.c
  79. #   8587 -rw-r--r-- misc2.c
  80. #   2290 -rw-r--r-- msdos.c
  81. #   2860 -rw-r--r-- mstime.i
  82. #   8266 -rw-r--r-- needed.c
  83. #   7588 -rw-r--r-- nextfile.c
  84. #   1127 -rw-r--r-- nixmode.i
  85. #   3434 -rw-r--r-- nixtime.i
  86. #   1874 -rw-r--r-- options.c
  87. #  16246 -rw-r--r-- options.doc
  88. #   8466 -rw-r--r-- options.h
  89. #     28 -rw-r--r-- options.opt
  90. #   5640 -rw-r--r-- parse.c
  91. #    704 -rw-r--r-- parse.h
  92. #  21613 -rw-r--r-- portable.c
  93. #   2657 -rw-r--r-- portable.h
  94. #   9094 -rw-r--r-- prterror.c
  95. #   4088 -rw-r--r-- sysv.c
  96. #   2063 -rw-r--r-- turboc.c
  97. #    113 -rw-r--r-- turboc.cfg
  98. #   2097 -rw-r--r-- various.h
  99. #    111 -rw-r--r-- version.c
  100. #  10243 -rw-r--r-- vms.c
  101. #  18584 -rw-r--r-- vmsbugs.doc
  102. #   3909 -rw-r--r-- vmsbuild.com
  103. #   6408 -rw-r--r-- vmstime.c
  104. #  46685 -rw-r--r-- zoo.1
  105. #  16090 -rw-r--r-- zoo.c
  106. #  10237 -rw-r--r-- zoo.h
  107. #  50054 -rw-r--r-- zoo.man
  108. #  26320 -rw-r--r-- zooadd.c
  109. #   8758 -rw-r--r-- zooadd2.c
  110. #   9676 -rw-r--r-- zoodel.c
  111. #  22207 -rw-r--r-- zooext.c
  112. #   2179 -rw-r--r-- zoofilt.c
  113. #   3423 -rw-r--r-- zoofns.h
  114. #   1939 -rw-r--r-- zooio.h
  115. #  18884 -rw-r--r-- zoolist.c
  116. #   1639 -rw-r--r-- zoomem.h
  117. #  13324 -rw-r--r-- zoopack.c
  118. #
  119. # ============= Checksums ==============
  120. if test -f 'Checksums' -a X"$1" != X"-c"; then
  121.     echo 'x - skipping Checksums (File already exists)'
  122. else
  123. echo 'x - extracting Checksums (Text)'
  124. sed 's/^X//' << 'SHAR_EOF' > 'Checksums' &&
  125. # Whole file CRCs generated by Brik v2.0.  Use "brik -C" to verify them.
  126. X
  127. # CRC-32        filename
  128. # ------        --------
  129. X
  130. 1667442549      Copyright
  131. X 359392938      Install
  132. X 630248997      List
  133. X 325879421      addbfcrc.c
  134. X 669949366      addbftcc.c
  135. 4137570368      addfname.c
  136. X 260075838      ar.h
  137. 3176247825      asmconst.ai
  138. 1968829781      assert.h
  139. 2774589019      basename.c
  140. 1418550454      bilf.c
  141. 3571167278      bsd.c
  142. 1744985930      comment.c
  143. 1095290529      crcdefs.c
  144. 1757282176      debug.h
  145. 3021583345      decode.c
  146. X  73743136      descrip.mms
  147. X 489796322      encode.c
  148. 4075798129      errors.i
  149. 3490413857      file.fix
  150. 3485210749      fiz.1
  151. 3600565988      fiz.c
  152. 1774024002      fiz.man
  153. 4182972025      generic.c
  154. 4010994345      getfile.c
  155. X 955564271      huf.c
  156. 2264840036      io.c
  157. X  75805716      lzc.asm
  158. 3570919889      lzc.c
  159. 2349470583      lzconst.h
  160. 1707878509      lzd.asm
  161. 2897597557      lzd.c
  162. 3828693743      lzh.c
  163. 2429644475      lzh.h
  164. 3979315416      machine.c
  165. X 182740816      machine.h
  166. X 535357786      macros.ai
  167. 2011785281      makefile
  168. 2589398917      makefile.tcc
  169. 2126848007      makelist.c
  170. 3525602735      maketbl.c
  171. X 876325461      maketree.c
  172. 2551733860      misc.c
  173. 2137143154      misc2.c
  174. 3638187888      msdos.c
  175. 3448357770      mstime.i
  176. X  31631311      needed.c
  177. 1766157868      nextfile.c
  178. X 199542926      nixmode.i
  179. 4077222384      nixtime.i
  180. X 538776329      options.c
  181. 1046541896      options.doc
  182. X 180668707      options.h
  183. X 900930479      options.opt
  184. X 736653532      parse.c
  185. X 574404514      parse.h
  186. 1002254917      portable.c
  187. 2748395706      portable.h
  188. 2801811069      prterror.c
  189. 3802884050      sysv.c
  190. 2806576319      turboc.c
  191. 3251857396      turboc.cfg
  192. 3963527820      various.h
  193. 1396445097      version.c
  194. 2692606938      vms.c
  195. 1336602147      vmsbugs.doc
  196. 2881095287      vmsbuild.com
  197. 3049809232      vmstime.c
  198. 3500434419      zoo.1
  199. 2239462961      zoo.c
  200. 2894729456      zoo.h
  201. 2869866215      zoo.man
  202. 2959104574      zooadd.c
  203. 3729120263      zooadd2.c
  204. X 367556730      zoodel.c
  205. 3847646036      zooext.c
  206. X 987202888      zoofilt.c
  207. 2253746453      zoofns.h
  208. X 778874820      zooio.h
  209. 1037042734      zoolist.c
  210. X 879931512      zoomem.h
  211. 3513827030      zoopack.c
  212. SHAR_EOF
  213. chmod 0644 Checksums ||
  214. echo 'restore of Checksums failed'
  215. Wc_c="`wc -c < 'Checksums'`"
  216. test 2176 -eq "$Wc_c" ||
  217.     echo 'Checksums: original size 2176, current size' "$Wc_c"
  218. fi
  219. # ============= Copyright ==============
  220. if test -f 'Copyright' -a X"$1" != X"-c"; then
  221.     echo 'x - skipping Copyright (File already exists)'
  222. else
  223. echo 'x - extracting Copyright (Text)'
  224. sed 's/^X//' << 'SHAR_EOF' > 'Copyright' &&
  225. X
  226. X                            COPYRIGHT
  227. X
  228. X
  229. The following rules apply only to the zoo archiver itself.
  230. Currently, all extract-only programs, and all supporting utili-
  231. ties, are fully in the public domain and are expected to remain so
  232. for the forseeable future.
  233. X
  234. X            COPYRIGHT STATEMENT FOR ZOO ARCHIVE PROGRAM
  235. X
  236. 1.   "This software" refers separately to each existing version, and
  237. X     each existing authorized derivative work, of my zoo archive
  238. X     program as of the date at the bottom of this copyright statement.
  239. X
  240. 2.   DISTRIBUTION IN UNMODIFIED FORM:  You may copy this software in
  241. X     unmodified form for any purpose, whether commercial or
  242. X     noncommercial, provided that you make no attempt to restrict
  243. X     distribution of it by others.
  244. X
  245. 3.   CREATION OF DERIVATIVE WORKS:  You may create and distribute
  246. X     derivative works made from any source code files that are part of
  247. X     this software, provided that you (a) preserve all copyright
  248. X     notices and author attributions, (b) do not create, whether
  249. X     deliberately or through negligence, any derivative work that
  250. X     violates the compatibility goals describe in the reference manual
  251. X     for zoo 2.1, (c) do not attempt to restrict the distribution or
  252. X     use of the derivative work by others, (d) make the fully commented
  253. X     source code of the derivative work available to me at no cost if
  254. X     I so request, and make no attempt to restrict the distribution
  255. X     or use of this source code.
  256. X
  257. 4.   NO WARRANTY.  I make no claim that this software is free of defects.
  258. X     I do not accept any legal obligation to provide any bug fixes or
  259. X     any other type of support whatsoever.  I disclaim all liability
  260. X     for damages, whether direct or consequential.
  261. X
  262. 5.   EXCEPTIONS:  Exceptions to the above conditions are probably
  263. X     possible.  Please contact me to negotiate.
  264. X
  265. 6.   The prohibition against incompatible derivative works does not 
  266. X     necessarily imply that the archiver and the archive format cannot
  267. X     be enhanced.  However, if any incompatibility is created, it may
  268. X     be done only with my permission.
  269. X
  270. X                                   -- Rahul Dhesi 1991/07/07
  271. SHAR_EOF
  272. chmod 0644 Copyright ||
  273. echo 'restore of Copyright failed'
  274. Wc_c="`wc -c < 'Copyright'`"
  275. test 2160 -eq "$Wc_c" ||
  276.     echo 'Copyright: original size 2160, current size' "$Wc_c"
  277. fi
  278. # ============= Install ==============
  279. if test -f 'Install' -a X"$1" != X"-c"; then
  280.     echo 'x - skipping Install (File already exists)'
  281. else
  282. echo 'x - extracting Install (Text)'
  283. sed 's/^X//' << 'SHAR_EOF' > 'Install' &&
  284. X
  285. X                              INSTALLATION
  286. X
  287. This is version 2.1 of the zoo archiver.  It includes improved compression,
  288. better online help, VAX/VMS file timestamp preservation, faster
  289. uncompression, and other features that are described in the accompanying
  290. manual ("zoo.1" or "zoo.man").
  291. X
  292. The supplied makefile contains a number of targets for selected systems.
  293. Type "make help" for help from the makefile.  Also, for VAX/VMS
  294. systems, see the file vmsbugs.doc for VMS-specific information.
  295. X
  296. The file ``options.h'' defines preprocessor symbols for the various sys-
  297. tems.  In most cases, given a reasonably powerful C compiler and
  298. library, you will be able to find a combination of options that will
  299. work.  Documentation for these options is in the file ``options.doc''.
  300. X
  301. Other machine-dependent code and definitions are in machine.h,
  302. machine.c, and portable.h.  Also, the amount of memory used for some
  303. arrays can be customized by defining symbols that are described and used
  304. in zoomem.h.
  305. X
  306. The low-level input/output routines are in portable.c.  In most cases
  307. these will not need to be modified.
  308. X
  309. On machines with older (Intel-style) architectures zoo requires the
  310. large memory model.  Compiling with the small memory model will
  311. cause problems.
  312. X
  313. EXTRACT-ONLY VERSION.  For a new system, your first concern should be
  314. the ability to extract and list zoo archives.  For this purpose try com-
  315. piling booz (which stands for Barebones Ooz) (currently version 2.0),
  316. which is small and portable.  It is distributed separately from zoo.
  317. X
  318. X                                KNOWN BUGS
  319. X
  320. 1.  The filter mode of zoo 2.1 appears to compresses and uncompresses
  321. correctly, but often reports an "Uncompression error" even when
  322. uncompression was successful.
  323. X
  324. 2.  It is possible for zoo 2.1 to fail to detect an out of disk space
  325. situation when adding files to a zoo archive.
  326. X
  327. 3.   The MS-DOS version of zoo 2.1 may unnecessarily report an error
  328. when extracting a file to standard output.  Normal file extraction
  329. to disk is not affected.
  330. X
  331. These bugs are expected to be fixed in the next release.
  332. X
  333. X                                     -- Rahul Dhesi 1991/07/07
  334. SHAR_EOF
  335. chmod 0644 Install ||
  336. echo 'restore of Install failed'
  337. Wc_c="`wc -c < 'Install'`"
  338. test 2138 -eq "$Wc_c" ||
  339.     echo 'Install: original size 2138, current size' "$Wc_c"
  340. fi
  341. # ============= List ==============
  342. if test -f 'List' -a X"$1" != X"-c"; then
  343.     echo 'x - skipping List (File already exists)'
  344. else
  345. echo 'x - extracting List (Text)'
  346. sed 's/^X//' << 'SHAR_EOF' > 'List' &&
  347. ## List of files for zoo 2.1
  348. ##
  349. ## Here is a list of all files that are part of the zoo 2.1 source
  350. ## distribution.
  351. ## 
  352. ## @all:   for all systems
  353. ## @bsd:   BSD
  354. ## @sysv:  System V
  355. ## @vms:   VMS
  356. ## @gen:   Generic **IX systems
  357. ## @tcc:   Turbo C/MS-DOS
  358. ## @doc:   Documentation (not source code etc.)
  359. ## 
  360. ## To select all files needed for a specific system, just do a search.
  361. ## For example, to find all non-doc files needed for BSD:
  362. ##
  363. ##      egrep '@bsd|@all' list.master | grep -v '@doc' | grep -v '^##'
  364. ##
  365. Copyright            @doc @all
  366. Install              @doc @all
  367. List                 @doc @all
  368. addbfcrc.c           @all -@tcc
  369. addbftcc.c           @tcc
  370. addfname.c           @all
  371. ar.h                 @all
  372. asmconst.ai          @tcc
  373. assert.h             @all
  374. basename.c           @all
  375. bilf.c               @vms
  376. bsd.c                @bsd
  377. comment.c            @all
  378. crcdefs.c            @all
  379. debug.h              @all
  380. decode.c             @all
  381. descrip.mms          @vms
  382. encode.c             @all
  383. errors.i             @all
  384. file.fix             @doc @bsd @sysv
  385. fiz.1                @doc @all
  386. fiz.c                @all
  387. fiz.man              @doc @all
  388. generic.c            @gen
  389. getfile.c            @all
  390. huf.c                @all
  391. io.c                 @all
  392. lzc.asm              @tcc
  393. lzc.c                @all
  394. lzconst.h            @all
  395. lzd.asm              @tcc
  396. lzd.c                @all
  397. lzh.c                @all
  398. lzh.h                @all
  399. machine.c            @all
  400. machine.h            @all
  401. macros.ai            @tcc
  402. makefile             @bsd @sysv
  403. makefile.tcc         @tcc
  404. makelist.c           @all
  405. maketbl.c            @all
  406. maketree.c           @all
  407. misc.c               @all
  408. misc2.c              @all
  409. msdos.c              @all
  410. mstime.i             @all
  411. needed.c             @all
  412. nextfile.c           @all
  413. nixmode.i            @bsd @sysv
  414. nixtime.i            @bsd @sysv
  415. options.c            @all
  416. options.doc          @doc
  417. options.h            @all
  418. options.opt          @vms
  419. parse.c              @all
  420. parse.h              @all
  421. portable.c           @all
  422. portable.h           @all
  423. prterror.c           @all
  424. sysv.c               @sysv
  425. turboc.c             @tcc
  426. turboc.cfg           @tcc
  427. various.h            @all
  428. version.c            @all
  429. vms.c                @vms
  430. vmsbugs.doc          @doc
  431. vmsbuild.com         @vms
  432. vmstime.c            @vms
  433. zoo.1                @doc
  434. zoo.c                @all
  435. zoo.h                @all
  436. zoo.man              @doc
  437. zooadd.c             @all
  438. zooadd2.c            @all
  439. zoodel.c             @all
  440. zooext.c             @all
  441. zoofilt.c            @all
  442. zoofns.h             @all
  443. zooio.h              @all
  444. zoolist.c            @all
  445. zoomem.h             @all
  446. zoopack.c            @all
  447. SHAR_EOF
  448. chmod 0644 List ||
  449. echo 'restore of List failed'
  450. Wc_c="`wc -c < 'List'`"
  451. test 2706 -eq "$Wc_c" ||
  452.     echo 'List: original size 2706, current size' "$Wc_c"
  453. fi
  454. # ============= addbfcrc.c ==============
  455. if test -f 'addbfcrc.c' -a X"$1" != X"-c"; then
  456.     echo 'x - skipping addbfcrc.c (File already exists)'
  457. else
  458. echo 'x - extracting addbfcrc.c (Text)'
  459. sed 's/^X//' << 'SHAR_EOF' > 'addbfcrc.c' &&
  460. #ifndef LINT
  461. static char sccsid[]="@(#) addbfcrc.c 2.2 88/01/29 17:04:31";
  462. #endif /* LINT */
  463. X
  464. #include "options.h"
  465. /*
  466. addbfcrc() accepts a buffer address and a count and adds the CRC for
  467. all bytes in the buffer to the global variable crccode using
  468. CRC-16.
  469. X
  470. CRC computation algorithm originally from an article by David Schwaderer 
  471. in the April 1985 issue of PC Tech Journal.
  472. X
  473. Loop optimization done by J. Brian Waters.
  474. X
  475. I claim no copyright over the contents of this file.
  476. X
  477. X                                    -- Rahul Dhesi 1986/08/27
  478. X
  479. */
  480. X
  481. extern unsigned int crccode;
  482. extern unsigned crctab[];
  483. X
  484. void addbfcrc(buffer,count)
  485. register char *buffer;
  486. register int count;
  487. X
  488. {
  489. X   register unsigned int localcrc;
  490. X   localcrc = crccode;
  491. X
  492. X   for (; count--; )
  493. X      localcrc = (localcrc>>8) ^ crctab[(localcrc ^ (*buffer++)) & 0x00ff];
  494. X   crccode = localcrc;
  495. }
  496. SHAR_EOF
  497. chmod 0644 addbfcrc.c ||
  498. echo 'restore of addbfcrc.c failed'
  499. Wc_c="`wc -c < 'addbfcrc.c'`"
  500. test 852 -eq "$Wc_c" ||
  501.     echo 'addbfcrc.c: original size 852, current size' "$Wc_c"
  502. fi
  503. # ============= addbftcc.c ==============
  504. if test -f 'addbftcc.c' -a X"$1" != X"-c"; then
  505.     echo 'x - skipping addbftcc.c (File already exists)'
  506. else
  507. echo 'x - extracting addbftcc.c (Text)'
  508. sed 's/^X//' << 'SHAR_EOF' > 'addbftcc.c' &&
  509. #pragma inline                    /* tell turbo assemble to use inline assembly */
  510. #ifndef LINT
  511. static char sccsid[]="$Source: /usr/home/dhesi/zoo/RCS/addbftcc.c,v $\n\
  512. $Id: addbftcc.c,v 1.1 91/07/07 18:40:11 dhesi Exp $";
  513. #endif /* LINT */
  514. X
  515. extern unsigned int crccode;
  516. extern unsigned crctab[];
  517. X
  518. void addbfcrc(buffer,count)
  519. char *buffer;
  520. int count;
  521. {
  522. X    (void) kbhit();                /* allow keyboard interrupt to occur */
  523. X    _AX = crccode;                    /* ax holds crccode value */
  524. X    _CX = count;                    /* cx holds byte count */
  525. X    asm     les di,buffer            /* es:di holds buffer address */
  526. X
  527. X    asm     jcxz    done        /* if zero bytes, just skip */
  528. X
  529. /* loop begins here */
  530. xloop:
  531. X    asm     sub bh,bh
  532. X    asm    mov bl,al
  533. X    asm     xor bl,es:[di]        /* now bx = (crccode xor c) & 0x00ff */
  534. X    /* next statement shifts _BX left (2-byte items) */
  535. X   _DX = crctab[_BX];        /* dx <= *buffer == exp2 */
  536. X    asm    sub bh,bh            /* bh = 0 */
  537. X    asm    mov bl,ah            /* bx <- exp1 */
  538. X    asm    xor bx,dx            /* bx <- exp1 xor exp2 */
  539. X    asm    mov ax,bx            /* crccode <- exp1 xor exp2 */
  540. X    asm    inc di                /* inc buffer pointer */
  541. X    asm    loop xloop            /* dec CX, jump if not zero */
  542. /* loop ends here */
  543. X
  544. X    crccode = _AX;                /* put back calculated CRC value */
  545. X
  546. done:
  547. X    ;
  548. X
  549. }
  550. X
  551. X
  552. #if 0
  553. ; The following (edited) code was generated by Turbo C from the
  554. ; preceding code.  It is supplied here for porting to other systems
  555. ; and for user education.
  556. X
  557. _TEXT    segment byte public 'CODE'
  558. _TEXT    ends
  559. X
  560. DGROUP    group    _DATA,_BSS
  561. X    assume    cs:_TEXT,ds:DGROUP
  562. X
  563. _DATA    segment word public 'DATA'
  564. _DATA    ends
  565. X
  566. _BSS    segment word public 'BSS'
  567. _BSS    ends
  568. X
  569. _TEXT    segment byte public 'CODE'
  570. X
  571. X    assume    cs:_TEXT
  572. _addbfcrc    proc    near
  573. X    push    bp
  574. X    mov    bp,sp
  575. X    push    di
  576. X
  577. X    call    near ptr _kbhit
  578. X    mov    ax,word ptr DGROUP:_crccode
  579. X    mov    cx,word ptr [bp+8]
  580. X         les     di,[bp+4]            
  581. X    jcxz    short @1@362
  582. @1@98:
  583. X     sub     bh,bh
  584. X    mov     bl,al
  585. X     xor     bl,es:[di]        
  586. X    shl    bx,1
  587. X    mov    dx,word ptr DGROUP:_crctab[bx]
  588. X    sub     bh,bh            
  589. X    mov     bl,ah            
  590. X    xor     bx,dx            
  591. X    mov     ax,bx            
  592. X    inc     di                
  593. X    loop    short @1@98
  594. X    mov    word ptr DGROUP:_crccode,ax
  595. @1@362:
  596. X    pop    di
  597. X    pop    bp
  598. X    ret    
  599. _addbfcrc    endp
  600. _TEXT    ends
  601. X
  602. X    extrn    _crccode:word
  603. X    extrn    _kbhit:near
  604. X    extrn    _crctab:word
  605. X    public    _addbfcrc
  606. X    end
  607. #endif
  608. SHAR_EOF
  609. chmod 0644 addbftcc.c ||
  610. echo 'restore of addbftcc.c failed'
  611. Wc_c="`wc -c < 'addbftcc.c'`"
  612. test 2097 -eq "$Wc_c" ||
  613.     echo 'addbftcc.c: original size 2097, current size' "$Wc_c"
  614. fi
  615. # ============= addfname.c ==============
  616. if test -f 'addfname.c' -a X"$1" != X"-c"; then
  617.     echo 'x - skipping addfname.c (File already exists)'
  618. else
  619. echo 'x - extracting addfname.c (Text)'
  620. sed 's/^X//' << 'SHAR_EOF' > 'addfname.c' &&
  621. #ifndef LINT
  622. static char sccsid[]="@(#) addfname.c 2.11 88/02/06 20:17:17";
  623. #endif /* LINT */
  624. X
  625. /*
  626. Copyright (C) 1986, 1987 Rahul Dhesi -- All rights reserved
  627. (C) Copyright 1988 Rahul Dhesi -- All rights reserved
  628. */
  629. #include "options.h"
  630. X
  631. /* Adds a filename to global list.  (This global list will eventually
  632. be searched by the inlist() function.)  The second and subsequent
  633. parameters suppplied are stored with the name of the file and 
  634. returned by inlist. */
  635. X
  636. #include "zooio.h"
  637. #include "various.h"
  638. #include "zoo.h"
  639. #include "zoofns.h"
  640. #include "zoomem.h" /* to get LIST_SIZE */
  641. X
  642. #define FENTRY_BSIZE        80        /* allocation granularity for fentry below */
  643. static struct item **fentry;    /* array of ptrs to file information structs */
  644. static unsigned sz_fentry;        /* its current size */
  645. static int lastname = 0;                  /* index of last name */
  646. X
  647. struct item {              /* global filename list entry */
  648. X   char *fname;
  649. X   long position;
  650. X   unsigned int date;
  651. X   unsigned int time;
  652. X    unsigned vflag;
  653. X    unsigned version_no;
  654. };
  655. X
  656. void addfname(fname, position, date, time, vflag, version_no)
  657. char *fname;
  658. long position;
  659. unsigned int date, time;
  660. unsigned vflag;
  661. unsigned version_no;
  662. {
  663. X   if (lastname == 0) {
  664. X        sz_fentry = FENTRY_BSIZE;
  665. X        fentry = (struct item **) ealloc(sizeof(struct item *) * sz_fentry);
  666. X      fentry[0] = (struct item *) ealloc (sizeof(struct item));
  667. X    }
  668. X
  669. X    /* allocated more memory if needed */
  670. X   if (lastname >= sz_fentry - 3) {
  671. X        sz_fentry += FENTRY_BSIZE;
  672. X        fentry = (struct item **) 
  673. X            erealloc(fentry, sizeof(struct item *) * sz_fentry);
  674. X    }
  675. X
  676. X   fentry[lastname]->fname = str_dup(fname);
  677. X   fentry[lastname]->position = position;
  678. X   fentry[lastname]->date = date;
  679. X   fentry[lastname]->time = time;
  680. X    fentry[lastname]->vflag = vflag;
  681. X    fentry[lastname]->version_no = version_no;
  682. X   lastname++;
  683. X   /* allocate memory for empty entry at end */
  684. X   fentry[lastname] = (struct item *) ealloc (sizeof(struct item)); 
  685. } /* addfname */
  686. X
  687. /* inlist() */
  688. /* Examines global list built by addfname() to see if supplied filename
  689. is in the list.  
  690. X
  691. If found, returns the file's position within the archive as the function 
  692. value and the date, time, version flag, and version number as parameters.
  693. If not found, returns -1.  Also returns the highest version no. seen
  694. for this filename and the vflag associated with that version.
  695. X
  696. A simple sequential search is done.
  697. X
  698. If justname is nonzero, then the search is for the filename only
  699. without the directory prefix;  else it is for the full
  700. pathname.
  701. */
  702. X
  703. long inlist (fname, date, time, this_version_no, high_vflag, 
  704. X                    high_version_no, high_pos, justname)
  705. char *fname;
  706. unsigned int *date, *time;
  707. unsigned *high_vflag;
  708. unsigned *this_version_no;
  709. unsigned *high_version_no;
  710. long *high_pos;
  711. int justname;
  712. {
  713. X   register int i = 0;
  714. X
  715. X    *high_version_no = 0;
  716. X    if (justname)
  717. X        fname = nameptr (fname);                    /* if directory wanted */
  718. X   fentry[lastname]->fname = fname;          /* sentinel */
  719. X    fentry[lastname]->version_no = 0;
  720. X
  721. #ifdef IGNORECASE
  722. #define    COMPARE    str_icmp
  723. #else
  724. #define    COMPARE    strcmp
  725. #endif
  726. X
  727. X   while (COMPARE(fname,
  728. X            (justname ? nameptr (fentry[i]->fname) : fentry[i]->fname)) != 0) {
  729. X      i++;
  730. X   }
  731. X
  732. X   if (i == lastname)
  733. X      return (-1L);
  734. X   else {
  735. X        int j;
  736. X        *date = fentry[i]->date;
  737. X        *time = fentry[i]->time;
  738. X        *high_pos = fentry[i]->position;
  739. X        *high_vflag = fentry[i]->vflag;
  740. X        for (j = i; j < lastname; j++) {    /* find highest version no. for file */
  741. X            if (COMPARE(fname,
  742. X                (justname ? nameptr (fentry[j]->fname) : fentry[j]->fname)) == 0) {
  743. X                if (*high_version_no < fentry[j]->version_no) {
  744. X                    *high_version_no = fentry[j]->version_no;
  745. X                    *high_vflag = fentry[j]->vflag;
  746. X                    *high_pos = fentry[j]->position;
  747. X                    *date = fentry[j]->date;
  748. X                    *time = fentry[j]->time;
  749. X                }
  750. X            }
  751. X        }
  752. X        *this_version_no = fentry[i]->version_no;
  753. X      return (fentry[i]->position);
  754. X   }
  755. } /* inlist() */
  756. SHAR_EOF
  757. chmod 0644 addfname.c ||
  758. echo 'restore of addfname.c failed'
  759. Wc_c="`wc -c < 'addfname.c'`"
  760. test 3872 -eq "$Wc_c" ||
  761.     echo 'addfname.c: original size 3872, current size' "$Wc_c"
  762. fi
  763. # ============= ar.h ==============
  764. if test -f 'ar.h' -a X"$1" != X"-c"; then
  765.     echo 'x - skipping ar.h (File already exists)'
  766. else
  767. echo 'x - extracting ar.h (Text)'
  768. sed 's/^X//' << 'SHAR_EOF' > 'ar.h' &&
  769. /*$Source: /usr/home/dhesi/zoo/RCS/ar.h,v $*/
  770. /*$Id: ar.h,v 1.17 91/07/09 01:39:50 dhesi Exp $*/
  771. /***********************************************************
  772. X    ar.h
  773. X
  774. Adapted from "ar" archiver written by Haruhiko Okumura.
  775. ***********************************************************/
  776. X
  777. #include <stdio.h>
  778. X
  779. #ifdef ANSI_HDRS
  780. # include <limits.h>
  781. #endif
  782. X
  783. /* uchar should be 8 bits or more */
  784. /* typedef unsigned char  uchar;   -- already in zoo.h */
  785. X
  786. typedef unsigned int   uint;    /* 16 bits or more */
  787. typedef unsigned short ushort;  /* 16 bits or more */
  788. typedef unsigned long  ulong;   /* 32 bits or more */
  789. X
  790. /* T_UINT16 must be #defined in options.h to be 
  791. a 16-bit unsigned integer type */
  792. X
  793. #ifndef T_UINT16
  794. # include "T_UINT16 not defined"
  795. #endif
  796. X
  797. typedef T_UINT16          t_uint16;    /* exactly 16 bits */
  798. X
  799. #ifndef SEEK_SET
  800. # define SEEK_SET 0
  801. #endif
  802. #ifndef SEEK_CUR
  803. # define SEEK_CUR 1
  804. #endif
  805. #ifndef SEEK_END
  806. # define SEEK_END 2
  807. #endif
  808. #ifndef EXIT_SUCCESS
  809. # define EXIT_SUCCESS 0
  810. #endif
  811. #ifndef EXIT_FAILURE
  812. # define EXIT_FAILURE 1
  813. #endif
  814. X
  815. /* ar.c */
  816. X
  817. extern int unpackable;
  818. extern ulong origsize, compsize;
  819. X
  820. /* all the prototypes follow here for all files */
  821. X
  822. /* standard library functions */
  823. #ifndef ANSI_HDRS
  824. X extern void exit();
  825. X extern long ftell();
  826. X extern int fseek();
  827. X extern int strlen();
  828. X extern char *strchr();
  829. X extern char *strpbrk();
  830. X extern int strcmp();
  831. X extern char *strcpy();
  832. X extern int memcmp();
  833. X extern VOIDPTR malloc();
  834. X extern VOIDPTR memcpy();
  835. #endif /* ANSI_HDRS */
  836. X
  837. /* AR.C */
  838. int get_line PARMS((char *s , int n ));
  839. void exitfunc PARMS((int code));
  840. void dlog PARMS((char *fmt, ...));
  841. void d1log PARMS((char *fmt, ...));
  842. void outcf PARMS((FILE *stream, char *buf, int n));
  843. void c1log PARMS((char *buf, int n));
  844. X
  845. /* DECODE.C */
  846. void decode_start PARMS((void ));
  847. int decode PARMS((uint count , uchar buffer []));
  848. X
  849. /* ENCODE.C */
  850. void encode PARMS((FILE *, FILE *));
  851. X
  852. /* HUF.C */
  853. void output PARMS((uint c , uint p ));
  854. void huf_encode_start PARMS((void ));
  855. void huf_encode_end PARMS((void ));
  856. uint decode_c PARMS((void ));
  857. uint decode_p PARMS((void ));
  858. void huf_decode_start PARMS((void ));
  859. X
  860. /* IO.C */
  861. void make_crctable PARMS((void ));
  862. void fillbuf PARMS((int n ));
  863. uint getbits PARMS((int n ));
  864. void putbits PARMS((int n , uint x ));
  865. int fread_crc PARMS((uchar *p , int n , FILE *f ));
  866. void fwrite_crc PARMS((uchar *p , int n , FILE *f ));
  867. void init_getbits PARMS((void ));
  868. void init_putbits PARMS((void ));
  869. X
  870. /* MAKETBL.C */
  871. void make_table
  872. X    PARMS((int nchar, uchar bitlen[], int tablebits, ushort table[]));
  873. X
  874. /* MAKETREE.C */
  875. int make_tree
  876. X    PARMS((int nparm, ushort freqparm [], uchar lenparm [], ushort codeparm []));
  877. X
  878. /* delete */
  879. X
  880. #ifdef NEED_MEMMOVE
  881. # define MOVE_LEFT move_left
  882. X  void move_left();
  883. #else
  884. # define MOVE_LEFT memmove
  885. X extern VOIDPTR memmove();
  886. #endif
  887. X
  888. #if 0
  889. /* global crc variable stuff for use by various routines */
  890. extern t_uint16 crc;
  891. #define INIT_CRC  0  /* CCITT: 0xFFFF */
  892. #endif
  893. X
  894. /* for lzh modules and also for ar.c to use in defining buffer size */
  895. #define DICBIT    13    /* 12(-lh4-) or 13(-lh5-) */
  896. #define DICSIZ ((unsigned) 1 << DICBIT)
  897. SHAR_EOF
  898. chmod 0644 ar.h ||
  899. echo 'restore of ar.h failed'
  900. Wc_c="`wc -c < 'ar.h'`"
  901. test 3097 -eq "$Wc_c" ||
  902.     echo 'ar.h: original size 3097, current size' "$Wc_c"
  903. fi
  904. # ============= asmconst.ai ==============
  905. if test -f 'asmconst.ai' -a X"$1" != X"-c"; then
  906.     echo 'x - skipping asmconst.ai (File already exists)'
  907. else
  908. echo 'x - extracting asmconst.ai (Text)'
  909. sed 's/^X//' << 'SHAR_EOF' > 'asmconst.ai' &&
  910. ; $Source: /usr/home/dhesi/zoo/RCS/asmconst.ai,v $
  911. ; $Id: asmconst.ai,v 1.2 91/07/07 09:37:47 dhesi Exp $
  912. ;The contents of this file are hereby released to the public domain.
  913. ;                                 -- Rahul Dhesi 1988/08/25
  914. X
  915. ;Constant values for lzc.asm and lzd.asm
  916. maxbits        equ    13
  917. clear        equ    256        ;Clear code
  918. eof        equ    257        ;End of file marker
  919. first_free    equ    258        ;First free code
  920. maxmax        equ    1 shl maxbits    ;Max code + 1
  921. X
  922. inbufsiz    equ    8192        ;size of input buffer
  923. outbufsiz    equ    8192        ;size of output buffer
  924. SHAR_EOF
  925. chmod 0644 asmconst.ai ||
  926. echo 'restore of asmconst.ai failed'
  927. Wc_c="`wc -c < 'asmconst.ai'`"
  928. test 517 -eq "$Wc_c" ||
  929.     echo 'asmconst.ai: original size 517, current size' "$Wc_c"
  930. fi
  931. # ============= assert.h ==============
  932. if test -f 'assert.h' -a X"$1" != X"-c"; then
  933.     echo 'x - skipping assert.h (File already exists)'
  934. else
  935. echo 'x - extracting assert.h (Text)'
  936. sed 's/^X//' << 'SHAR_EOF' > 'assert.h' &&
  937. /* @(#) assert.h 2.1 87/12/25 12:21:32 */
  938. X
  939. /*
  940. The contents of this file are hereby released to the public domain.
  941. X
  942. X                           -- Rahul Dhesi 1991/07/04
  943. X
  944. Defines a macro assert() that causes an assertion error if the assertion
  945. fails.
  946. X
  947. Conditional compilation:
  948. X
  949. X   If NDEBUG is defined then
  950. X      assert() is defined as null so all assertions vanish
  951. X   else
  952. X        if __FILE__ and __LINE__ are defined then
  953. X         assertions print message including filename and line number
  954. X      else
  955. X         assertions print a message but not the filename and line number
  956. X      endif
  957. X   endif
  958. */
  959. X
  960. #ifdef NDEBUG
  961. # define assert(E)
  962. #else
  963. X
  964. #undef LINE_FILE
  965. X
  966. #ifdef __LINE__
  967. # ifdef __FILE__
  968. #  define LINE_FILE
  969. # endif
  970. #endif
  971. X
  972. #ifdef LINE_FILE
  973. # undef LINE_FILE
  974. # define assert(E) \
  975. X   { if (!(E)) \
  976. X      prterror ('w',"Assertion error in %s:%d.\n", __FILE__, __LINE__); \
  977. X   }
  978. #else
  979. # define assert(E) \
  980. X   { if (!(E)) \
  981. X      prterror ('w', "Assertion error.\n"); \
  982. X   }
  983. #endif
  984. #endif /* NDEBUG */
  985. SHAR_EOF
  986. chmod 0644 assert.h ||
  987. echo 'restore of assert.h failed'
  988. Wc_c="`wc -c < 'assert.h'`"
  989. test 995 -eq "$Wc_c" ||
  990.     echo 'assert.h: original size 995, current size' "$Wc_c"
  991. fi
  992. # ============= basename.c ==============
  993. if test -f 'basename.c' -a X"$1" != X"-c"; then
  994.     echo 'x - skipping basename.c (File already exists)'
  995. else
  996. echo 'x - extracting basename.c (Text)'
  997. sed 's/^X//' << 'SHAR_EOF' > 'basename.c' &&
  998. #ifndef LINT
  999. /* @(#) basename.c 2.2 87/12/27 13:42:40 */
  1000. static char sccsid[]="@(#) basename.c 2.2 87/12/27 13:42:40";
  1001. #endif /* LINT */
  1002. X
  1003. /*
  1004. Copyright (C) 1986, 1987 Rahul Dhesi -- All rights reserved
  1005. */
  1006. X
  1007. #include "options.h"
  1008. #include "zooio.h"
  1009. #include "zoo.h"
  1010. #include "parse.h"
  1011. #include "various.h"
  1012. #include "zoofns.h"
  1013. #include "debug.h"
  1014. #include "assert.h"
  1015. X
  1016. /* This function strips device/directory information from
  1017. a pathname and returns just the plain filename */
  1018. void basename (pathname, fname)
  1019. char *pathname;
  1020. char fname[];
  1021. {
  1022. X   strcpy (fname, nameptr (pathname));
  1023. }
  1024. X
  1025. /* Set of legal MSDOS filename characters.  The working of cvtchr() depends
  1026. on the order of the first few characters here.  In particular, '_' is
  1027. positioned so '.' gets converted to it. */
  1028. static char legal[] = 
  1029. "tabcdefghijklmnopqrs_uvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ@^`{}~!#$%&'()-";
  1030. X
  1031. /****************
  1032. cvtchr() converts a character to a lowercase alphabetic character in
  1033. a somewhat random way.  
  1034. */
  1035. #define  cvtchr(ch)        legal[(ch & 0xff) % 26]
  1036. X
  1037. /***************
  1038. cleanup() cleans up a string so it contains only legal MSDOS filename
  1039. characters.  Any other characters are converted to an underscore.
  1040. If the filename is null or if it begins with a dot, it is fixed.
  1041. All dots are also converted.
  1042. */
  1043. X
  1044. void cleanup (p)
  1045. char *p;
  1046. {
  1047. X   assert(p != NULL);
  1048. X   if (*p == '\0')
  1049. X      strcpy (p, "X");
  1050. X   if (*p == '.')
  1051. X      *p = '_';
  1052. X   while (*p != '\0') {
  1053. X      if (strchr (legal, *p) == NULL) {   /* if invalid character */
  1054. X         *p = cvtchr(*p);
  1055. X      }
  1056. X      p++;
  1057. X   }
  1058. }
  1059. /* This function strips device/directory information from a pathname,
  1060. forces the remaining filename to MSDOS format, and returns it.  Any
  1061. illegal characters are fixed.
  1062. */
  1063. void dosname (pathname, fname)
  1064. char *pathname;
  1065. char fname[];
  1066. {
  1067. X   struct path_st path_st;
  1068. X   parse (&path_st, pathname);
  1069. X   strcpy (fname, path_st.fname);
  1070. X   cleanup (fname);
  1071. X
  1072. #ifdef VER_CH  /* remove any trailing extension field */
  1073. X   if (path_st.ext[0] != '\0')
  1074. X      strip_ver (path_st.ext);
  1075. #endif
  1076. X
  1077. X   /* extension could have been nulled, so we test again */
  1078. X   if (path_st.ext[0] != '\0') {
  1079. X      cleanup (path_st.ext);
  1080. X      strcat (fname, ".");
  1081. X      strcat (fname, path_st.ext);
  1082. X   }
  1083. X
  1084. #ifdef SPECMOD
  1085. X   specfname (fname);
  1086. #endif
  1087. }
  1088. X
  1089. /* rootname() */
  1090. /* Accepts a pathname.  Returns the root filename, i.e., with both the
  1091. directory path and the extension stripped. */
  1092. X
  1093. void rootname (path, root)
  1094. char *path, *root;
  1095. {
  1096. X   char *p;
  1097. X   static char dot[] = {EXT_CH, '\0'};
  1098. X   strcpy(root, nameptr(path));           /* copy all but path prefix */
  1099. X   p = findlast(root, dot);               /* find last dot */
  1100. X   if (p != NULL)                         /* if found ... */
  1101. X      *p = '\0';                          /* ... null it out */
  1102. }
  1103. X
  1104. /* nameptr() */
  1105. /* Accepts a pathname.  Returns a pointer to the filename within
  1106. that pathname.
  1107. */
  1108. X
  1109. char *nameptr (path)
  1110. char *path;
  1111. {
  1112. X   char *t;
  1113. X   t = findlast (path, PATH_SEP);   /* last char separating device/directory */
  1114. X   debug ((printf ("nameptr:  findlast returned ptr to string [%s].\n",t)))
  1115. X   if (t == NULL)                /* no separator */
  1116. X      return (path);
  1117. X   else {
  1118. X      return (t+1);
  1119. X   }
  1120. }
  1121. SHAR_EOF
  1122. chmod 0644 basename.c ||
  1123. echo 'restore of basename.c failed'
  1124. Wc_c="`wc -c < 'basename.c'`"
  1125. test 3181 -eq "$Wc_c" ||
  1126.     echo 'basename.c: original size 3181, current size' "$Wc_c"
  1127. fi
  1128. # ============= bilf.c ==============
  1129. if test -f 'bilf.c' -a X"$1" != X"-c"; then
  1130.     echo 'x - skipping bilf.c (File already exists)'
  1131. else
  1132. echo 'x - extracting bilf.c (Text)'
  1133. sed 's/^X//' << 'SHAR_EOF' > 'bilf.c' &&
  1134. /* $Source: /usr/home/dhesi/zoo/RCS/bilf.c,v $ */
  1135. /* $Id: bilf.c,v 1.2 91/07/07 14:57:06 dhesi Exp $ */
  1136. X
  1137. /*
  1138. This program performs conversion of files between stream-LF format
  1139. (as used by zoo) and fixed-length record binary format (used for Kermit
  1140. transfers of zoo archives).
  1141. X
  1142. This program is:
  1143. X   (C) Copyright 1987 Rahul Dhesi.
  1144. X   All Rights Reserved.
  1145. X
  1146. Permission is hereby granted to copy and modify this for any purpose,
  1147. whether commercial or noncommercial, provided only that the above
  1148. copyright notice and this paragraph be preserved and included
  1149. in all copies.
  1150. X
  1151. X                                 -- Rahul Dhesi 1987/07/25
  1152. */
  1153. X
  1154. #include <stdio.h>
  1155. #include <ssdef.h>
  1156. #define STAT_NORM SS$_NORMAL
  1157. #define STAT_ABORT SS$_ABORT
  1158. X
  1159. char *strrchr();
  1160. char *strdup ();
  1161. X
  1162. main (argc, argv)
  1163. int argc;
  1164. char *argv[];
  1165. {
  1166. X   char *inname;
  1167. X   char *outname;
  1168. X   char *option;
  1169. X   int status;
  1170. X
  1171. X   if (argc < 3 || argc > 4) {
  1172. X      printf ("BILF version 1.00 for VAX/VMS by Rahul Dhesi (1987/07/25)\n\n");
  1173. X      printf ("(C) Copyright 1987 Rahul Dhesi,  All Rights Reserved\n");
  1174. X      printf ("Permission to use and distribute is granted provided this copyright\n"); 
  1175. X      printf ("notice is preserved and included in all copies.\n\n");
  1176. X      printf ("Usage:  BILF {lb} infile [ outfile ]\n\n");
  1177. X      printf ("Choose one character from within braces.  If outfile is not supplied\n");
  1178. X      printf ("it has the same name as infile but a higher version number.\n");
  1179. X      printf ("Options are:\n\n");
  1180. X      printf ("l:  Write output file in stream-LF format.  This is the format that\n");
  1181. X      printf ("    zoo expects all zoo archives to be in.  If a zoo archive was\n");
  1182. X      printf ("    uploaded to a VAX/VMS system, it will need to be converted to\n");
  1183. X      printf ("    stream-LF format before manipulating with zoo.\n\n");
  1184. X      printf ("b:  Write output file in fixed-length 512-byte binary record format.  Before\n");
  1185. X      printf ("    a zoo archive can be downloaded from a VAX/VMS system to a\n");
  1186. X      printf ("    microcomputer using VAX/VMS Kermit, it must be converted to\n");
  1187. X      printf ("    this binary format.  Failure to do so will result in a corrupted\n");
  1188. X      printf ("    download.\n");
  1189. X      exit (STAT_NORM);
  1190. X   }
  1191. X
  1192. X   inname = argv[2];
  1193. X   option = argv[1];
  1194. X
  1195. X   if (argc == 3) {                    /* use same filename for output */
  1196. X      char *p;
  1197. X      outname = strdup (inname);
  1198. X      p = strrchr (outname, ';');      /* strip trailing version field */
  1199. X      if (p != NULL)
  1200. X         *p = '\0';
  1201. X   } else
  1202. X      outname = argv[3];
  1203. X
  1204. X   if (*option == 'l')
  1205. X      status = cvtstream (outname, inname);
  1206. X   else if (*option == 'b')
  1207. X      status = cvtbin (outname, inname);
  1208. X   else
  1209. X      prterror ('f', "Option %s is invalid\n", option);
  1210. X   if (status == -1)
  1211. X      prterror ('w', "An error occurred -- output file may be corrupted\n");
  1212. X   exit (STAT_NORM);
  1213. }
  1214. X
  1215. #define  MYBUFSIZ    8192
  1216. X
  1217. /* writes input file to output file in stream format */
  1218. int cvtstream (outname, inname)
  1219. char *outname, *inname;
  1220. {
  1221. X   FILE *infile, *outfile;
  1222. X   char buffer[MYBUFSIZ];
  1223. X   int count;
  1224. X
  1225. X   infile = fopen (inname, "r");
  1226. X   if (infile == NULL)
  1227. X      prterror ('f', "Could not open input file %s\n", inname);
  1228. X   outfile = fopen (outname, "w");
  1229. X   if (outfile == NULL)
  1230. X      prterror ('f', "Could not open output file %s\n", outname);
  1231. X
  1232. X   while ((count = fread (buffer, 1, sizeof (buffer), infile)) > 0)
  1233. X      count = fwrite (buffer, 1, count, outfile);
  1234. X
  1235. X   close (infile); close (outfile);
  1236. X   if (count == -1)
  1237. X      return (-1);
  1238. X   else
  1239. X      return (0);
  1240. }
  1241. X
  1242. /*
  1243. VMS C doesn't have strdup().
  1244. */
  1245. char *strdup (str)
  1246. char *str;
  1247. {
  1248. X   char *malloc();
  1249. X   char *newstr = malloc (strlen (str) + 1);
  1250. X   if (newstr != NULL) {
  1251. X      strcpy (newstr, str);
  1252. X      return (newstr);
  1253. X   } else
  1254. X      return ((char *) NULL);
  1255. }
  1256. X
  1257. /* BLKSIZ must correspond to block size specified below in creat() */
  1258. #define BLKSIZ 512
  1259. X
  1260. /*
  1261. Writes input file to output in fixed-length BLKSIZ-byte record format.
  1262. */
  1263. X
  1264. #if 1
  1265. #include <file.h>
  1266. #else
  1267. #include <fcntl.h>
  1268. #endif
  1269. X
  1270. int convert ();
  1271. X
  1272. int cvtbin (outname, inname)
  1273. char *outname, *inname;
  1274. {
  1275. X   int status, inhan, outhan;
  1276. X   inhan = open (inname, O_RDONLY);
  1277. X   if (inhan == -1)
  1278. X      prterror ('f', "Could not open input file %s\n", inname);
  1279. X   outhan = creat (outname, 0, "rfm=fix", "mrs=512");
  1280. X   if (outhan == -1)
  1281. X      prterror ('f', "Could not open output file %s\n", outname);
  1282. X   status = convert (outhan, inhan);
  1283. X   close (inhan);
  1284. X   close (outhan);
  1285. X   return (status);
  1286. }
  1287. X
  1288. /*
  1289. Function convert() reads from inhan and writes to outhan, always
  1290. writing in BLKSIZ-byte blocks, padding with nulls if necessary
  1291. */
  1292. X
  1293. int convert (outhan, inhan)
  1294. int inhan, outhan;
  1295. {
  1296. X   char junk[BLKSIZ];
  1297. X   int count;
  1298. X   int done = 0;
  1299. X   do {
  1300. X      count = vmsread (inhan, junk, BLKSIZ);
  1301. X      if (count <= 0)
  1302. X         break;
  1303. X      if (count < BLKSIZ) {
  1304. X         int i;
  1305. X         for (i = count; i < BLKSIZ; i++)
  1306. X            junk[i] = 0;
  1307. X         done++;
  1308. X      }
  1309. X      count = write (outhan, junk, BLKSIZ);
  1310. X      if (count == -1)
  1311. X         break;
  1312. X   } while (!done);
  1313. X   if (count == -1)
  1314. X      return (-1);
  1315. X   else
  1316. X      return (0);
  1317. }
  1318. X
  1319. /**** Function vmsread() does a standard read() but gets around bugs
  1320. in the read() function of VAX/VMS C which make it unable to always
  1321. read the entire amount requested in a single read() call.
  1322. */
  1323. int vmsread (han, buf, amount)
  1324. int han;
  1325. char *buf;
  1326. int amount;
  1327. {
  1328. X   int count;
  1329. X   int thiscount;
  1330. X   count = 0;
  1331. X   while (count != -1 && count < amount) {
  1332. X      thiscount = read (han, &buf[count], amount - count);
  1333. X      if (thiscount == 0)
  1334. X         thiscount = read (han, &buf[count], amount - count);
  1335. X      if (thiscount == 0)
  1336. X          break;
  1337. X      if (thiscount == -1)
  1338. X         count = -1;
  1339. X      else
  1340. X         count += thiscount;
  1341. X   }
  1342. X   return (count);
  1343. }
  1344. X
  1345. prterror (level, msg1, msg2)
  1346. char level;
  1347. char *msg1, *msg2;
  1348. {
  1349. X   if (level == 'e' || level == 'w' || level == 'f')
  1350. X      printf ("BILF: ");
  1351. X
  1352. X   switch (level) {
  1353. X      case 'e': printf ("ERROR: ");    break;
  1354. X      case 'w': printf ("WARNING: ");  break;
  1355. X      case 'f': printf ("FATAL: ");    break;
  1356. X      default:  prterror ('f', "Internal error in prterror()\n");
  1357. X   }
  1358. X
  1359. X   printf (msg1, msg2);
  1360. X   if (level == 'f')
  1361. X      exit (STAT_ABORT);
  1362. }
  1363. SHAR_EOF
  1364. chmod 0644 bilf.c ||
  1365. echo 'restore of bilf.c failed'
  1366. Wc_c="`wc -c < 'bilf.c'`"
  1367. test 6214 -eq "$Wc_c" ||
  1368.     echo 'bilf.c: original size 6214, current size' "$Wc_c"
  1369. fi
  1370. # ============= bsd.c ==============
  1371. if test -f 'bsd.c' -a X"$1" != X"-c"; then
  1372.     echo 'x - skipping bsd.c (File already exists)'
  1373. else
  1374. echo 'x - extracting bsd.c (Text)'
  1375. sed 's/^X//' << 'SHAR_EOF' > 'bsd.c' &&
  1376. #ifndef LINT
  1377. static char bsdid[]="@(#) bsd.c 2.3 88/01/10 14:45:19";
  1378. #endif /* LINT */
  1379. X
  1380. /* machine.c for 4.3BSD. */
  1381. X
  1382. /*
  1383. The contents of this file are hereby released to the public domain.
  1384. X
  1385. X                                    -- Rahul Dhesi  1987/07/23
  1386. */
  1387. X
  1388. /* 
  1389. WARNING:  This file assumes that ZOOFILE is a standard buffered
  1390. file.  It will have to be modified if ZOOFILE is changed to
  1391. be an unbuffered file descriptor or to any other kind of file.
  1392. */
  1393. X
  1394. #ifdef UNBUF_IO
  1395. /*
  1396. Function tell() returns the current seek position for a file 
  1397. descriptor.  4.3BSD on VAX-11/785 has an undocumented tell() function
  1398. but it may not exist on all implementations, so we code one here
  1399. to be on the safe side.  It is needed for unbuffered I/O only.
  1400. */
  1401. long lseek PARMS ((int, long, int));
  1402. long tell (fd)
  1403. int fd;
  1404. { return (lseek (fd, 0L, 1)); }
  1405. #endif
  1406. X
  1407. long ftell();
  1408. X
  1409. /****************
  1410. Function fixfname() converts the supplied filename to a syntax
  1411. legal for the host system.  It is used during extraction.
  1412. */
  1413. X
  1414. char *fixfname(fname)
  1415. char *fname;
  1416. {
  1417. X   return fname; /* default is no-op */
  1418. }
  1419. X
  1420. /****************
  1421. Date and time functions are standard UNIX-style functions.
  1422. */
  1423. X
  1424. #include <sys/types.h>
  1425. #include <sys/stat.h>
  1426. #include <sys/time.h>
  1427. X
  1428. /* Function isadir() returns 1 if the supplied handle is a directory, 
  1429. else it returns 0.  
  1430. */
  1431. X
  1432. int isadir (f)
  1433. ZOOFILE f;
  1434. {
  1435. X   struct stat buf;           /* buffer to hold file information */
  1436. X   if (fstat (fileno (f), &buf) == -1) {
  1437. X      return (0);             /* inaccessible -- assume not dir */
  1438. X   } else {
  1439. X      if (buf.st_mode & S_IFDIR)
  1440. X         return (1);
  1441. X      else
  1442. X         return (0);
  1443. X   }
  1444. }
  1445. X
  1446. /* Function gettz() returns the offset from GMT in seconds */
  1447. long gettz()
  1448. {
  1449. #define SEC_IN_DAY    (24L * 60L * 60L)
  1450. #define INV_VALUE        (SEC_IN_DAY + 1L)
  1451. X    static long retval = INV_VALUE;         /* cache, init to impossible value */
  1452. X   struct timeval tp;
  1453. X   struct timezone tzp;
  1454. X    if (retval != INV_VALUE)                 /* if have cached value, return it */
  1455. X        return retval;
  1456. X   gettimeofday (&tp, &tzp);              /* specific to 4.3BSD */
  1457. X   /* return (tzp.tz_minuteswest * 60); */ /* old incorrect code */
  1458. X    /* Timezone fix thanks to Bill Davidsen <wedu@ge-crd.ARPA> */
  1459. X    retval = tzp.tz_minuteswest * 60 - tzp.tz_dsttime * 3600L;
  1460. X    return retval;
  1461. }
  1462. X
  1463. /* Standard UNIX-compatible time routines */
  1464. #include "nixtime.i"
  1465. X
  1466. /* Standard UNIX-specific file attribute routines */
  1467. #include "nixmode.i"
  1468. X
  1469. #ifndef SEEK_CUR
  1470. # define  SEEK_CUR    1
  1471. #endif
  1472. X
  1473. /* Truncate a file. */
  1474. int zootrunc(f) FILE *f;
  1475. {
  1476. X    extern long lseek();
  1477. X    long seekpos;
  1478. X    int fd = fileno(f);
  1479. X    seekpos = lseek(fd, 0L, SEEK_CUR);
  1480. X    if (seekpos >= 0)
  1481. X        return ftruncate(fd, seekpos);
  1482. }
  1483. SHAR_EOF
  1484. chmod 0644 bsd.c ||
  1485. echo 'restore of bsd.c failed'
  1486. Wc_c="`wc -c < 'bsd.c'`"
  1487. test 2650 -eq "$Wc_c" ||
  1488.     echo 'bsd.c: original size 2650, current size' "$Wc_c"
  1489. fi
  1490. true || echo 'restore of comment.c failed'
  1491. echo End of part 1, continue with part 2
  1492. exit 0
  1493.