home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / binaries / ibm / pc / 1063 < prev    next >
Encoding:
Text File  |  1993-01-02  |  37.0 KB  |  1,415 lines

  1. Newsgroups: comp.binaries.ibm.pc
  2. Path: sparky!uunet!ulowell!cs.ulowell.edu!oneill
  3. From: cbip@cs.ulowell.edu (CBIP Moderator)
  4. Subject: v21inf09: briksrc3.shar, brik source (part 01/01)
  5. Message-ID: <C08Fw0.wy@ulowell.ulowell.edu>
  6. Followup-To: comp.binaries.ibm.pc.d
  7. Originator: oneill@cs.ulowell.edu
  8. Keywords: cbip, 
  9. Sender: usenet@ulowell.ulowell.edu (News manager - ulowell)
  10. Organization: University of Massachusetts at Lowell Computer Science
  11. Date: Sat, 2 Jan 1993 15:19:12 GMT
  12. Approved: oneill@cs.ulowell.edu
  13. Lines: 1400
  14.  
  15. Checksum: 4235958783  (Verify with "brik -cv")
  16. X-Submissions-to: cbip@cs.ulowell.edu
  17. X-Questions-to: cbip-request@cs.ulowell.edu
  18. Submitted-by: oneill@cs.ulowell.edu
  19. Posting-number: Volume 21, Issue inf09
  20. Archive-name: admin/briksrc3.shar
  21.  
  22. [ Date of last change 08-Aug-91 ]
  23.  
  24. #!/bin/sh
  25. # shar:    Shell Archiver  (v1.27)
  26. #
  27. #    Run the following text with /bin/sh to create:
  28. #      brik.1
  29. #      addbfcrc.asm
  30. #      Makefile
  31. #      options.opt
  32. #      makefile.tcc
  33. #      makefile.msc
  34. #      makebrik.com
  35. #      descrip.mms
  36. #      crc.lst
  37. #      brik.prj
  38. #      assert.h
  39. #      addbfcrc.c
  40. #
  41. echo "x - extracting brik.1 (Text)"
  42. sed 's/^X//' << 'SHAR_EOF' > brik.1 &&
  43. X.\" ::[[ @(#) brik.1 1.12 89/07/12 00:11:50 ]]::
  44. X.\"
  45. X.TH BRIK 1 "Jul 8, 1989"
  46. X.AT 3
  47. X.\" ******* sh is a sub heading macro
  48. X.de sh
  49. X.br
  50. X.ne 5
  51. X.PP
  52. X\fB\\$1\fR
  53. X.PP
  54. X..
  55. X.\" ******** ex is for indented examples, no fill
  56. X.de ex
  57. X.RS 5
  58. X.nf
  59. X.sp 1
  60. X..
  61. X.\" ******** ef is for indented examples, with fill
  62. X.de ef
  63. X.RS 5
  64. X.fi
  65. X.sp 1
  66. X..
  67. X.\" ******* ee is to end ex and ef
  68. X.de ee
  69. X.fi
  70. X.RE
  71. X.sp 1
  72. X..
  73. X.\"
  74. X.SH NAME
  75. Xbrik \- calculate 32-bit CRC
  76. X.SH SYNOPSIS
  77. X.B brik \-h
  78. X.sp  0
  79. X.B brik \-gcGCbafvsqWHT
  80. X.I file ...
  81. X.SH DESCRIPTION
  82. X.I Brik
  83. Xgenerates and verifies 32-bit CRC values (checksums).  It is
  84. Xdesigned to generate CRCs for text files that are the same on all computer
  85. Xsystems that use the ASCII character set, provided each text file is in the
  86. Xusual text file format for each system.  
  87. X.I Brik
  88. Xwill also optionally use
  89. Xbinary CRCs calculated using every byte in a file.  Such binary CRCs are
  90. Xportable across systems for binary files that are moved from system to system
  91. Xwithout any newline conversion.  
  92. X.I Brik
  93. Xcan be asked to decide by examining
  94. Xeach file whether to calculate a text mode or binary mode CRC for it.
  95. X.PP
  96. XChanges from version 1.0 are summarized at the end of this document.
  97. X.PP
  98. XThe general usage format is:
  99. X.ef
  100. Xbrik -gcGCbafvsqWHT
  101. X[
  102. X.I file
  103. X] ...
  104. X.ee
  105. XThe brackets mean that
  106. X.IR file ,
  107. Xwhich is the name of a file, is optional.  The
  108. Xthree dots indicate that more than one filename may be typed (separated by
  109. Xblanks).  Exactly one of the options
  110. X.BR \-c ,
  111. X.BR \-C ,
  112. X.BR \-g ,
  113. X.BR \-G ,
  114. Xor
  115. X.BR \-h ,
  116. Xis required.  The
  117. X.B \-h
  118. Xoption gives a help screen.
  119. X.PP
  120. XIn addition to
  121. X.BR \-h ,
  122. Xthe 
  123. X.I Brik
  124. Xoptions available (as they appear on the help
  125. Xscreen) are:
  126. X.TP
  127. X.B \-g
  128. Xlook for
  129. X.I Checksum:
  130. Xheader, generate CRC for rest of file
  131. X.TP
  132. X.B \-c
  133. Xget CRC from header, verify CRC of rest of file
  134. X.TP
  135. X.B \-G
  136. Xgenerate CRC for entire file (add
  137. X.B \-b
  138. Xfor binary files)
  139. X.TP
  140. X.B \-C
  141. Xverify all file CRCs from output of
  142. X.B \-G
  143. X.RB ( \-f
  144. Xis not needed)
  145. X.TP
  146. X.B \-b
  147. Xuse binary mode -- read file byte by byte, not line by line
  148. X.TP
  149. X.B \-a
  150. Xautomatically decide whether each file is text or binary
  151. X.TP
  152. X.B \-f
  153. Xread filenames (wildcards ok) from specified files
  154. X.TP
  155. X.B \-v
  156. Xbe verbose, report all results (else only errors are reported)
  157. X.TP
  158. X.B \-s
  159. Xbe silent, say nothing, just return status code
  160. X.TP
  161. X.B \-q
  162. Xbe quiet, don't print header for
  163. X.B \-G
  164. X.TP
  165. X.B \-W
  166. Xafter generating CRC with
  167. X.BR \-g ,
  168. Xwrite it to original header
  169. X.TP
  170. X.B \-H
  171. Xafter generating CRC with
  172. X.BR \-g ,
  173. Xprint header to stdout
  174. X.TP
  175. X.B \-T
  176. Xinclude trailing empty lines, normally ignored (text mode only)
  177. X.sh "VERIFYING CRC HEADERS"
  178. XThe primary intended use of 
  179. X.I Brik
  180. Xis to verify
  181. X.I Checksum:
  182. Xheaders in Usenet
  183. Xpostings and in C and Pascal source files.  A
  184. X.I Checksum:
  185. Xheader looks like
  186. Xthis:
  187. X.ex
  188. X\&Checksum: 9485762645b   (verify with "brik")
  189. X.ee
  190. XThe word
  191. X.I Checksum:
  192. Xmust occur at the beginning of a line.  It is followed by a colon, an
  193. Xoptional blank, a ten-digit decimal 32-bit CRC, and any arbitrary
  194. Xoptional string such as the comment shown above.  The CRC value may
  195. Xbe followed by a one-character suffix identifying the type of the
  196. XCRC.  These suffixes are described later.
  197. X.PP
  198. XWhen 
  199. X.I Brik
  200. Xis invoked with
  201. Xthe syntax
  202. X.ef
  203. Xbrik -c
  204. X.I file ...
  205. X.ee
  206. Xit will search for the
  207. X.I Checksum:
  208. Xheader in each specified
  209. X.I file,
  210. Xread the CRC
  211. Xvalue from that header, calculate the CRC-32 for all lines in the file
  212. X(except trailing empty lines) that occur *after* the header line, and
  213. Xreport an error if the two values do not match.  
  214. X.ne 6
  215. X.sh "CALCULATING CRC HEADERS"
  216. XThe command
  217. X.ef
  218. Xbrik \-g
  219. X.I file ...
  220. X.ee
  221. Xtells 
  222. X.I Brik
  223. Xto look for the
  224. X.I Checksum:
  225. Xheader in each specified
  226. X.I file,
  227. Xcalculate the CRC of the lines in the file following the header, and
  228. Xprint the CRC and filename without changing the file in any way.  You
  229. Xcan also ask 
  230. X.I Brik
  231. Xto update the
  232. X.I Checksum:
  233. Xheader with the following command:
  234. X.ef
  235. Xbrik \-gW
  236. X.I file ...
  237. X.ee
  238. XThis causes 
  239. X.I Brik
  240. Xto update the
  241. X.I Checksum:
  242. Xheader in the file with the newly-calculated CRC.  If there is not
  243. Xenough space for the CRC in the existing header, 
  244. X.I Brik
  245. Xreports an error and does not change the existing header.  To
  246. Xinitially add a
  247. X.I Checksum:
  248. Xheader to a file, insert a line of the following form into the
  249. Xfile with a text editor:
  250. X.ex
  251. X\&Checksum: XXXXXXXXXX  -- this is an optional comment
  252. X.ee
  253. XThe word
  254. X.I Checksum
  255. Xmust be at the beginning of a line.  The ten `X' characters shown can
  256. Xbe any ten characters.  They will be later replaced by the calculated
  257. XCRC value.  They do not need to be `X'.  The comment following them
  258. Xis optional and can be any arbitrary string of characters after the
  259. XCRC field, separated from it by blanks.  As an example, in a C
  260. Xsource file called
  261. X.I main.c,
  262. Xyou might have:
  263. X.ex
  264. X/*
  265. X\&Checksum: XXXXXXXXXX  (verify or update with brik)
  266. X*/
  267. X.ee
  268. XOnce a header like this exists in the file, invoke 
  269. X.I Brik
  270. Xas follows:
  271. X.ex
  272. Xbrik \-gW main.c
  273. X.ee
  274. XThis will cause the ten `X' characters to be replaced with the calculated
  275. Xchecksum, giving something like this:
  276. X.ex
  277. X/*
  278. X\&Checksum: 1922837484  (verify or update with brik)
  279. X*/
  280. X.ee
  281. XLater you can use the command
  282. X.ex
  283. Xbrik \-c main.c
  284. X.ee
  285. Xto verify that the contents of the file following the header have the
  286. Xsame CRC as the stored value.
  287. X.PP
  288. XIf 
  289. X.I Brik
  290. Xis invoked with the
  291. X.B \-c
  292. Xor
  293. X.B \-g
  294. Xoptions and it cannot find a
  295. X.I Checksum:
  296. Xheader in a file, it prints a row of question marks.  If it is invoked
  297. Xwith the
  298. X.B \-gW
  299. Xoption and it does not find enough character positions after the
  300. X.I Checksum:
  301. Xstring to hold the CRC, it does not fill in the CRC and prints an
  302. Xerror message.
  303. X.PP
  304. X.I Brik
  305. Xcan be asked to generate a complete
  306. X.I Checksum:
  307. Xheader but print it to
  308. Xstandard output instead of writing it to the file.  Do this by adding the
  309. X.B \-H
  310. Xoption.  If both
  311. X.B \-W
  312. Xand
  313. X.B \-H
  314. Xare given, the
  315. X.I Checksum:
  316. Xheader will be written both to the file and to standard output.
  317. X.sh "WHOLE-FILE CRCS"
  318. XA "whole-file" CRC calculation is done for the entire contents of a file,
  319. Xwithout looking for a
  320. X.I Checksum:
  321. Xheader.  The command
  322. X.ef
  323. Xbrik \-G
  324. X.I file ...
  325. X.ee
  326. Xasks 
  327. X.I Brik
  328. Xto do this calculation for all specified files.  The output from this
  329. Xcommand is a list of files and their whole-file CRCs.  It is sent to
  330. Xthe standard output stream, which in most cases is your screen.  The
  331. Xoutput should be saved in a file by redirecting it.  For example, the
  332. Xcommand
  333. X.ex
  334. Xbrik \-G *.h *.c > crc.lst
  335. X.ee
  336. Xon an MS-DOS system might yield the following in the output file
  337. X.I crc.lst:
  338. X.ex
  339. X# CRC-32        filename
  340. X# ------        --------
  341. X
  342. X2566277976      getopt.c
  343. X 100594287      brik.c
  344. X1151475469      vms.c
  345. X3929503738      turboc.c
  346. X2424271922      addbfcrc.c
  347. X1943472856      assert.h
  348. X2601923477      brik.h
  349. X.ee
  350. XThe output of the
  351. X.B \-G
  352. Xoption is in free format.  The output file may be edited
  353. Xby hand.  Empty lines and lines beginning with '#' will be ignored by
  354. X.I Brik
  355. Xwhen it is later asked to read this file.
  356. X.PP
  357. XThis list of filenames and whole-file CRCs may be verified by a
  358. Xcommand like this:
  359. X.ex
  360. Xbrik \-C crc.lst
  361. X.ee
  362. XThis makes 
  363. X.I Brik
  364. Xread the file
  365. X.I crc.lst,
  366. Xget the CRCs and filenames from it, do the CRC calculation again for
  367. Xeach file, and report an error if it does not match the CRC recorded
  368. Xinside
  369. X.I crc.lst.
  370. X.PP
  371. X\&**IX and MS-DOS users (and others who can pipe the output of one
  372. Xcommand into another) could use a command like the following to see
  373. Xif 
  374. X.I "Brik's"
  375. X.B \-G
  376. Xand
  377. X.B \-C
  378. Xoptions are working:
  379. X.ex
  380. Xbrik \-G file ... | brik \-C
  381. X.ee
  382. XThis invokes "brik \-G" on some files, sending the output to a pipe
  383. Xwhere it becomes the input of "brik \-C".  If no filename is
  384. Xspecified, 
  385. X.I Brik
  386. Xreads from standard input, so "brik \-C" will read from the pipe and
  387. Xconcurrently verify all the CRCs that are being generated by
  388. X"brik \-G".
  389. X.PP
  390. XWhole-file CRCs are normally generated in text mode, in which a file
  391. Xis treated as lines of text.  You can also generate whole-file CRCs
  392. Xin binary mode.  See below.
  393. X.sh "BINARY VERSUS TEXT MODE"
  394. X.I Brik
  395. Xcan work in two different modes.  The most common mode, used unless
  396. Xyou specify otherwise, is text mode.
  397. X.PP
  398. XIn this mode
  399. X.I Brik
  400. Xreads all files line by line, and forces each line of text to be
  401. Xterminated by a newline character of constant value before doing a CRC
  402. Xcalculation.  Thus, no matter what newline character is used by your system,
  403. Xthe CRC calculation will be unaffected.  This means that whether your
  404. Xoperating system uses linefeeds to terminate lines (e.g. **IX), or a carriage
  405. Xreturn and a linefeed (e.g. MS-DOS) or a carriage return only
  406. X(e.g. Macintosh) or nothing but a record length field (e.g. VAX/VMS),
  407. Xthe CRC calculation in text mode gives the same results.
  408. X.PP
  409. XIf a file is not intended to be a text file, the text mode CRC
  410. Xcalculated by
  411. X.I Brik
  412. Xmay not be reliable and may be different on different systems.  If
  413. X.I Brik
  414. Xis calculating a text mode CRC on a file that appears to contain
  415. Xbinary data, it still calculates the text-mode CRC but adds a "*"
  416. Xcharacter after the CRC to indicate to warn the user.
  417. X.PP
  418. X.I Brik
  419. Xcan be asked to operate in binary mode by adding a
  420. X.B \-b
  421. Xoption.  Binary mode is applicable only to the
  422. X.B \-G
  423. Xcommand, which acts on whole
  424. Xfiles.  Thus
  425. X.ef
  426. Xbrik \-G
  427. X.I file ...
  428. X.ee
  429. Xfinds whole-file CRCs of all specified files in text mode, while
  430. X.ef
  431. Xbrik \-Gb
  432. X.I file ...
  433. X.ee
  434. Xdoes the same in binary mode.  In binary mode 
  435. X.I Brik
  436. Xsimply reads and calculates the CRC for all bytes in a file.  If a
  437. Xfile is moved from one system to another without any newline
  438. Xconversion or any other changes,
  439. X.I Brik
  440. Xshould calculate the same binary mode CRC for it on both systems.
  441. X.PP
  442. XThe output from "brik \-Gb" includes a trailing
  443. X.B b
  444. Xsuffix in each CRC, so "brik \-C" will correctly use binary mode for
  445. Xsuch CRCs and it is never necessary to type "brik \-Cb" instead.
  446. X.PP
  447. XIn its auto-check mode,
  448. X.I Brik
  449. Xwill itself examine each file and determine whether it is a text or
  450. Xbinary file and calculate a CRC accordingly.  To do this, use the
  451. X.B \-a
  452. Xoption.  Although
  453. X.I Brik
  454. Xcan determine the type of each file with a high degree of
  455. Xreliability, it is still possible for it to come to a wrong
  456. Xconclusion about some files.
  457. X.PP
  458. XThe output from "brik \-Ga" will include a trailing
  459. X.B b
  460. Xcharacter in the CRC for those files that appeared to be binary to 
  461. X.I Brik.
  462. X\& You may find both text and binary CRCs in the output.
  463. X.sh "TRAILING EMPTY LINES"
  464. XThe normal behavior of 
  465. X.I Brik
  466. Xin text mode is to ignore any trailing empty lines in a file.  An
  467. Xempty line is a line that contains nothing, not even blanks or
  468. Xtabs.  (Just hitting a carriage return when you are editing a text
  469. Xfile usually produces an empty line.)  If manipulating a text file
  470. Xcauses trailing empty lines to be added or deleted, the CRC
  471. Xcalculated by 
  472. X.I Brik
  473. Xwill be unaffected.  You can override this if necessary with the
  474. X.B \-T
  475. Xoption, which makes 
  476. X.I Brik
  477. Xinclude trailing empty lines in the CRC calculation.  For example,
  478. X.ex
  479. Xbrik \-gWT
  480. X.ee
  481. Xwill update the
  482. X.I Checksum:
  483. Xheader with a CRC that includes all lines in a text file.  Similarly
  484. X.ex
  485. Xbrik \-GT
  486. X.ee
  487. Xwill find whole-file CRCs that include all lines in a text file.
  488. X.PP
  489. XWhen 
  490. X.I Brik
  491. Xis given the
  492. X.B \-T
  493. Xoption, it adds a
  494. X.B T
  495. Xsuffix to each generated CRC.  Then, when the CRC is verified with
  496. X.B \-c
  497. Xor
  498. X.BR \-C ,
  499. X.I Brik
  500. Xwill correctly include trailing empty lines when needed without
  501. Xhaving to be explicitly told to do so.
  502. X.PP
  503. XIn binary mode 
  504. X.I Brik
  505. Xalways reads all bytes in a file, so it does not ignore trailing
  506. Xempty lines, and the
  507. X.B \-T
  508. Xswitch is not needed.
  509. X.PP
  510. XThe effects of the
  511. X.B \-T
  512. Xand
  513. X.B \-b
  514. Xoptions are mutually exclusive.  If both are given, whichever is
  515. Xused later overrides the first.  So
  516. X.B \-bT
  517. Xis equivalent
  518. Xto
  519. X.B \-T
  520. Xand
  521. X.B \-Tb
  522. Xis equivalent to
  523. X.BR \-T .
  524. X.sh "FILENAME CONVENTIONS"
  525. XUnder MS-DOS and VAX/VMS, wildcards are allowed on the command line
  526. Xand will be expanded by 
  527. X.I Brik.
  528. X\& Under **IX, wildcards are expected to be expanded by
  529. Xthe shell and are not expanded by 
  530. X.I Brik.
  531. X\& If no filename is given, 
  532. X.I Brik
  533. Xreads its standard input.  By default this is keyboard input, but it
  534. Xis expected that input will usually be redirected to come from a file
  535. Xor a pipe.  Also, if a filename is explicitly specified as a dash
  536. X("\-"), it stands for standard input.
  537. X.PP
  538. XThe following five commands (valid under the **IX operating system)
  539. X.ex
  540. Xbrik \-c myfile            # "myfile"
  541. Xbrik \-c < myfile          # stdin = "myfile"
  542. Xcat myfile | brik \-c      # stdin = a pipe
  543. Xbrik \-c \- < myfile        # "\-" = stdin = "myfile"
  544. Xcat myfile | brik \-c \-    # "\-" = stdin = a pipe
  545. X.ee
  546. Xall have the effect of verifying the
  547. X.I Checksum:
  548. Xheader in the file
  549. X.I myfile.
  550. X.PP
  551. XStandard input can also be read when using the
  552. X.B \-C
  553. Xoption.  For example, suppose we have already given the command
  554. X.ex
  555. Xbrik \-G *.c *.h > crc.lst
  556. X.ee
  557. Xto create a file called "crc.lst" that contains a list of whole-file
  558. XCRCs.  We can now verify the integrity of these files with any of the
  559. Xfollowing commands:
  560. X.ex
  561. Xbrik \-C crc.lst          # "crc.lst"
  562. Xbrik \-C < crc.lst        # stdin = "crc.lst"
  563. Xbrik \-C \- < crc.lst      # "\-" = stdin = "crc.lst"
  564. Xcat crc.lst | brik \-C    # stdin = a pipe
  565. Xcat crc.lst | brik \-C \-  # "\-" = stdin = a pipe
  566. X.ee
  567. X.sh "INDIRECT FILE NAMING"
  568. XThe
  569. X.B \-f
  570. Xoption allows you to have filenames in a list rather than on the
  571. Xcommand line.  For example, suppose you want to generate whole-file CRCs of
  572. Xfiles whose names are selected by some other program.  You could use
  573. X.I find
  574. X(under **IX) or
  575. X.I Stuff
  576. X(under MS-DOS) to generate a list of filenames.  When
  577. Xthe
  578. X.B \-f
  579. Xoption is given, 
  580. X.I Brik
  581. Xreads filenames, one per line, from the file(s)
  582. Xspecified.  Thus you could do the following:
  583. X.ex
  584. Xfind . \-mtime +3 \-print > flist
  585. Xbrik \-Gf flist > crc.lst
  586. X.ee
  587. XThe first command asks
  588. X.I find
  589. Xto generate a list of names of all files that
  590. Xwere modified more than 3 days ago, and sends the output to the file
  591. X.I flist.
  592. X\& The contents of
  593. X.I flist
  594. Xmight now look like this, as an example:
  595. X.ex
  596. X\&./sez.doc
  597. X\&./brik.doc
  598. X\&./stuff.doc
  599. X\&./looz.doc
  600. X.ee
  601. XThe second command above asks 
  602. X.I Brik
  603. Xto read the file called
  604. X.I flist,
  605. Xget a list of filenames from it, one per line, and generate the
  606. Xwhole-file CRC of each of these files.  We additionally redirect the
  607. Xoutput of "brik \-Gf" to the file called
  608. X.I crc.lst.
  609. X\& Given the above contents
  610. Xof
  611. X.I flist,
  612. Xthe following two commands are exactly equivalent:
  613. X.ex
  614. Xbrik \-Gf flist >crc.lst
  615. Xbrik \-G ./sez.doc ./brik.doc ./stuff.doc ./looz.doc >crc.lst
  616. X.ee
  617. XThe advantage of the
  618. X.B \-f
  619. Xoption is that once you have filenames in a file, you need not type
  620. Xthem again at the command line.  The
  621. X.B \-f
  622. Xoption also allows you to feed 
  623. X.I Brik
  624. Xthrough a pipe filenames generated by another program.  Consider this
  625. Xcommand:
  626. X.ex
  627. Xfind . \-mtime +3 \-print | brik \-Gf \- > crc.lst
  628. X.ee
  629. XUnder **IX this concurrently invokes both
  630. X.I find
  631. Xand 
  632. X.I Brik.
  633. X\& As
  634. X.I find
  635. Xgenerates a filename and sends it to its standard output (a pipe), 
  636. X.I Brik
  637. Xreads the filename from its standard input and generates its
  638. Xwhole-file CRC.  The following pipeline
  639. X.ex
  640. Xfind . \-mtime +3 \-print | brik \-Gf \- | brik \-C \-
  641. X.ee
  642. Xinvokes
  643. X.I find
  644. Xto generate filenames, 
  645. X.I Brik
  646. Xto print the whole-file CRCs of those files, and 
  647. X.I Brik
  648. Xagain to immediately verify them.
  649. X.PP
  650. XUnder MS-DOS and VAX/VMS (and any other operating system under which
  651. X.I Brik
  652. Xhas been installed to expand wildcards itself), a file specified by
  653. Xthe \-f option can itself contain wildcards in the filenames.  For
  654. Xexample, suppose the file "wildfile" contains the following lines:
  655. X.ex
  656. X/bin/*.exe
  657. X/bin/*.com
  658. X/doc/*.doc
  659. X.ee
  660. XNow if we invoke 
  661. X.I Brik
  662. Xwith the command
  663. X.ex
  664. Xbrik \-Gf wildfile
  665. X.ee
  666. Xit will read filespecs from "wildfile," expand wildcards in each
  667. Xfilespec, and generate whole-file CRCs for all matching files.
  668. X.PP
  669. XIf you are checking whole-file CRCs with the
  670. X.B \-C
  671. Xoption, you do not normally need to use the
  672. X.B \-f
  673. Xoption.  When used with
  674. X.BR \-C ,
  675. Xthe
  676. X.B \-f
  677. Xoption introduces an additional level of file naming indirection. For
  678. Xexample, the command
  679. X.ex
  680. Xbrik \-C crc.lst
  681. X.ee
  682. Xtakes a list of CRCs and filenames from "crc.lst" and
  683. Xverifies them.  However, the command
  684. X.ex
  685. Xbrik \-Cf master.lst
  686. X.ee
  687. Xdoes not do the same thing.  Instead, it takes a list of files from
  688. X"master.lst," looks inside each of
  689. X.I those
  690. Xfiles for a list of CRCs and filenames, and verifies them.
  691. X.PP
  692. XAs an example of the use of \-Cf, consider this sequence:
  693. X.ex
  694. Xbrik \-Gb /bin/*.exe > exelist
  695. Xbrik \-Gb /bin/*.com > comlist
  696. Xbrik \-GT /doc/*.doc > doclist
  697. Xbrik \-G  /doc/*.man > manlist
  698. X.ee
  699. XNow we have four files called "exelist," "comlist," "doclist," and
  700. X"manlist" containing whole-file CRCs of various types.  We can test
  701. Xthe integrity of files listed in these in four separate commands like
  702. Xthis:
  703. X.ex
  704. Xbrik \-C exelist
  705. Xbrik \-C comlist
  706. Xbrik \-C doclist
  707. Xbrik \-C manlist
  708. X.ee
  709. XBut we could also do this in a single step by first creating a file
  710. Xcalled "biglist" that contains the names of these four files:
  711. X.ex
  712. Xexelist
  713. Xcomlist
  714. Xdoclist
  715. Xmanlist
  716. X.ee
  717. Xand then use
  718. X.B \-Cf
  719. Xthus:
  720. X.ex
  721. Xbrik \-Cf biglist
  722. X.ee
  723. XThis causes 
  724. X.I Brik
  725. Xto read filenames from "biglist," look inside each of those files
  726. X("exelist," "comlist," "doclist," and "manlist") and check the CRCs
  727. Xfound there.  A **IX example to do the same thing in a more compact
  728. Xway might be:
  729. X.ex
  730. Xcat exelist comlist doclist manlist | brik \-Cf \-
  731. X.ee
  732. XThe above examples are somewhat contrived, however.  We could also use
  733. Xthe following command:
  734. X.ex
  735. Xbrik \-C exelist comlist doclist manlist
  736. X.ee
  737. X.sh "SILENT VERSUS VERBOSE VERSUS QUIET"
  738. X.I Brik
  739. Xaccepts options 
  740. X.BR \-s ,
  741. X.BR \-q ,
  742. Xand
  743. X.B \-v
  744. Xthat control the degree of verbosity.
  745. X.PP
  746. XNormally 
  747. X.I Brik
  748. Xprints a message only if it detects an error.  For example,
  749. Xif you give the command
  750. X.ex
  751. Xbrik \-c *.c *.h
  752. X.ee
  753. Xand 
  754. X.I Brik
  755. Xfinds that all
  756. X.I Checksum:
  757. Xheaders contain CRCs that match the calculated value, it prints nothing.
  758. X.PP
  759. XThe
  760. X.B \-v
  761. Xswitch makes 
  762. X.I Brik
  763. Xprint a message for each file tested that contains the
  764. Xword "ok" if stored and calculated CRCs matched and "BAD" if they did not.
  765. X.PP
  766. XIn all messages reporting file CRCs, 
  767. X.I Brik
  768. Xprints the actual CRC it calculated,
  769. Xor a row of question marks if it could not calculate one.  \fIBrik\fP
  770. Xfails to calculate a CRC if it is trying to calculate a header-based
  771. XCRC (commands
  772. X.B \-c
  773. Xand
  774. X.BR \-g )
  775. Xbut does not find a
  776. X.I Checksum:
  777. Xheader in a file.
  778. X.PP
  779. XThe
  780. X.B \-s
  781. Xswitch tells 
  782. X.I Brik
  783. Xto be silent.  This will cause nothing to be printed if 
  784. X.I Brik
  785. Xdoes not find a
  786. X.I Checksum
  787. Xheader or if CRCs don't match.  However, the
  788. Xstatus code on exit is still set.  The
  789. X.B \-s
  790. Xoption is useful for invoking 
  791. X.I Brik
  792. Xfrom within a shell script (**IX) or a batch file (MS-DOS) and later
  793. Xtesting the error code it returned when it exited.
  794. X.PP
  795. XThe
  796. X.B \-s
  797. Xswitch does not suppress the error message printed if 
  798. X.I Brik
  799. Xis given a filename and the file cannot be found.  For example, if
  800. Xthe command
  801. X.ex
  802. Xbrik \-cs myfile
  803. X.ee
  804. Xis given but "myfile" does not exist, 
  805. X.I Brik
  806. Xwill print an
  807. Xerror message even though the
  808. X.B \-s
  809. Xoption was given.
  810. X.PP
  811. XThe
  812. X.B \-q
  813. Xswitch makes 
  814. X.I Brik
  815. Xslightly quieter.  Its only effect is to suppress the introductory
  816. Xcomments that are otherwise generated by the
  817. X.B \-C
  818. Xoption.
  819. X.PP
  820. X.sh "VAX/VMS BUGS"
  821. X.TP
  822. Xo
  823. XUnder VAX/VMS, file manipulation is unpredictable and the VAX/VMS C
  824. Xruntime library in particular is very unreliable.  One result is that
  825. Xunder VAX/VMS, the
  826. X.B \-gW
  827. Xoption will work only for stream-LF files, which are the only type of
  828. Xfile that VAX/VMS seems to handle correctly.  Fortunately, the
  829. X.B \-c
  830. Xoption will correctly work for VAX/VMS standard text files.
  831. X.TP
  832. Xo
  833. XThe VAX/VMS implementation of 
  834. X.I Brik
  835. Xsimply ignores filenames that correspond to nonexistent files instead
  836. Xof giving an error message.  VMS users are invited to fix this bug
  837. X(probably somewhere in the
  838. X.I nextfile()
  839. Xfunction in the file
  840. X.IR vms.c )
  841. Xand send me the fix.
  842. X.TP
  843. Xo
  844. XTo avoid annoying error messages, 
  845. X.I Brik
  846. Xunder VAX/VMS always exits with
  847. Xa status code of 1.
  848. X.TP
  849. Xo
  850. XDue to a problem in the VAX/VMS command interpreter, if any uppercase
  851. Xoption characters are typed (e.g. \fB\-C\fP,
  852. X.BR \-G ,
  853. X.BR \-T ), 
  854. X.I Brik
  855. Xwill not recognize
  856. Xthem as uppercase unless they are enclosed in double quotes.  An
  857. Xexample of a correct command under VAX/VMS:
  858. X.sp 1
  859. X.nf
  860. X\&  brik "\-GT" *.*
  861. X.sp 1
  862. X.fi
  863. XAn example of a command that won't work:
  864. X.sp 1
  865. X\&  brik \-GT *.*
  866. X.sh "USAGE HINTS"
  867. XThis section discusses some ways of using 
  868. X.I Brik.
  869. X.TP
  870. X\- 
  871. X.I Brik
  872. Xis currently used to create and verify checksums of articles posted
  873. Xon the Usenet newsgroup comp.binaries.ibm.pc.  While reading Usenet
  874. Xnews with
  875. X.I rn,
  876. Xfor example, you can verify the
  877. X.I Checksum:
  878. Xheader of such an article with the command:
  879. X.sp 1
  880. X\&  | brik \-cv
  881. X.sp 1
  882. XThis feeds the current article to 
  883. X.I Brik
  884. Xas standard input and asks it to verbosely verify the checksum.
  885. X.TP
  886. X\-
  887. XC and Pascal source files that are being distributed can be given their own
  888. X.I Checksum:
  889. Xheaders.  The advantage of this over listing CRCs separately is
  890. Xthat each file contains its checksum no matter where it goes.  The
  891. Xrecipient can easily verify that each source file was received
  892. Xintact.  This is especially valuable when source files are being sent
  893. Xby electronic mail through an IBM mainframe-based network, such as
  894. XBITNET, that can cause corruption of text files.
  895. X.sp 1
  896. XCreate the
  897. X.I Checksum
  898. Xheader with a text editor and initialize its value
  899. Xwith the command:
  900. X.sp 1
  901. X\&  brik \-gW file ...
  902. X.sp 1
  903. XThe recipient can verify the checksum with the command:
  904. X.sp 1
  905. X\&  brik \-cv file ...
  906. X.sp 1
  907. X.TP
  908. X\-
  909. XTo keep track of any unexpected filesystem corruption or unauthorized
  910. Xchanges to system files, 
  911. X.I Brik
  912. Xcan be used to create a list of
  913. Xchecksums.  This should be done using the
  914. X.B \-b
  915. Xoption (all binary checksums)
  916. Xor the
  917. X.B \-a
  918. Xoption (use text or binary as appropriate).  Under **IX this
  919. Xcan be done with a command like this one:
  920. X.sp 1
  921. X.nf
  922. X\&  find /bin /usr/bin /lib /usr/lib /usr/new \\
  923. X\&   \-type f \-print | \\
  924. X\&  grep \-v '^/usr/bin/beta' | \\
  925. X\&  grep \-v '^/usr/new/lib/news' | \\
  926. X\&  brik \-Gbf \- > crc.list
  927. X.fi
  928. X.sp 1
  929. XThis example uses 
  930. X.I find
  931. Xto print the pathnames of certain files,
  932. X.I grep
  933. Xto
  934. Xfilter out certain directory subtrees, and then 
  935. X.I Brik
  936. Xto print checksums of
  937. Xall selected files.  Periodically a background job can be run to compare
  938. Xthe file list against current files and report any discrepancies:
  939. X.sp 1
  940. X\&  brik \-C crc.lst | mail \-s 'brik output' postmaster
  941. X.sp 1
  942. XUnder MS-DOS, create a list of checksums with the help of
  943. X.I Stuff,
  944. Xa
  945. X.IR find -like
  946. Xfile finder program that is distributed with
  947. X.I zoo
  948. X2.01:
  949. X.sp 1
  950. X\&  stuff /bin /msdos /turboc | brik \-Gaf \- > crc.list
  951. X.sp 1
  952. XThis is a simple mechanism that can be used to detect unexpected file
  953. Xchanges caused by hardware problems or malicious programs such as
  954. Xviruses and worms.  Be warned, however, that since 
  955. X.I Brik
  956. Xuses a published CRC algorithm, very clever deviant programs are
  957. Xpossible that could change a file without affecting its CRC.
  958. X.sp 1
  959. XTo avoid too many false alarms, only files that do not change much
  960. X(such as system binaries) should be selected.
  961. X.SH CHANGES
  962. XChanges from version 1.0 are as follows.
  963. X.TP
  964. X\-
  965. XThe CRC calculation has been recoded in 8086 assembly code suitable
  966. Xfor Turbo C/MS-DOS.  As a result 
  967. X.I Brik 2.0
  968. Xunder MS-DOS is much faster than version 1.0.
  969. X.TP
  970. X\- 
  971. XThe new 
  972. X.B \-a 
  973. Xflag makes 
  974. X.I Brik
  975. Xautomatically determine for each file whether it is text or binary
  976. Xand calculate the CRC accordingly
  977. X.TP
  978. X\- 
  979. XWhen 
  980. X.I Brik
  981. Xis asked to calculate a text mode CRC but the file appears to be
  982. Xbinary, it now does not print a warning message but instead adds a
  983. X"*" suffix to the calculated CRC to indicate that the CRC may not be
  984. Xreliable.
  985. X.TP
  986. X\- 
  987. XThe new 
  988. X.B \-H 
  989. Xflag makes 
  990. X.I Brik
  991. Xprint the formatted
  992. X.I Checksum:
  993. Xheader to standard output.
  994. X.TP
  995. X\- 
  996. XDetection of binary files is now more reliable under MS-DOS.  If a
  997. Xcontrol Z character occurs near the beginning of a binary file, 
  998. X.I Brik
  999. Xwill not be fooled by the apparent end-of-file but will in most cases
  1000. Xreliably detect that the file is binary.
  1001. X.TP
  1002. X\- 
  1003. XThe new 
  1004. X.B \-q 
  1005. Xflag suppresses the introductory comments from the output of
  1006. Xthe \-G command.
  1007. X.SH BUGS
  1008. X.I Brik
  1009. Xis designed to work with computer systems that use the 7-bit ASCII
  1010. Xcharacter set and 8-bit bytes with the eighth (parity) bit set to zero.
  1011. X.PP
  1012. X.I Brik
  1013. Xhas not been tested with computer systems that use ASCII characters
  1014. Xwith the eighth bit set or those that use EBCDIC
  1015. Xcharacters.  Although it will calculate a CRC on such machines, the
  1016. Xprobability of this CRC being the same as the one calculated on
  1017. Xmachines that use 7-bit ASCII is approximately 0.00000000023.
  1018. X.PP
  1019. X.ne 4
  1020. X.SH DIAGNOSTICS
  1021. XError messages are intended to be self-explanatory.
  1022. X.PP
  1023. XThe exit status returned
  1024. Xis 1 if
  1025. X.I Brik
  1026. Xwas invoked with incorrect arguments, else it is the number of files
  1027. Xfound with missing or invalid CRCs, but not greater than an
  1028. Xoperating-system-dependent maximum value.
  1029. X.SH COPYRIGHT
  1030. XBoth this documentation and
  1031. X.I Brik
  1032. Xare Copyright 1989 Rahul Dhesi, all
  1033. Xrights reserved.  Permission is granted to copy, use, and distribute for any
  1034. Xcommercial or noncommercial purpose in accordance with the requirements of
  1035. Xversion 1.0 of the
  1036. X.I GNU General Public license.
  1037. X.PP
  1038. XNote:  This software has not been endorsed by the Free Software Foundation,
  1039. Xthe creator of the GNU license, and I am not affiliated with that
  1040. Xorganization.
  1041. X.SH AUTHOR
  1042. X.nf
  1043. XRahul Dhesi
  1044. XUUCP: {iuvax,pur-ee}!bsu-cs!dhesi
  1045. XInternet: dhesi@bsu-cs.bsu.edu
  1046. X.fi
  1047. SHAR_EOF
  1048. chmod 0666 brik.1 || echo "restore of brik.1 fails"
  1049. echo "x - extracting addbfcrc.asm (Text)"
  1050. sed 's/^X//' << 'SHAR_EOF' > addbfcrc.asm &&
  1051. X; ::[[ @(#) addbfcrc.asm 1.1 89/07/08 10:48:28 ]]::
  1052. X; assembly implementation of addbfcrc() for Turbo C 2.0 -- small memory model
  1053. X
  1054. X; The following code was obtained from compiling addbfcrc.c using
  1055. X; Turbo C 2.0, then hand-optimized.  In the interest of making
  1056. X; faster CRC-32 calculations available to all, I hereby release
  1057. X; the contents of this file to the public domain.  This code is for
  1058. X; the small memory model only.  It will probably need to be revised
  1059. X; for use with other C compilers.
  1060. X;                                    -- Rahul Dhesi 1989/07/08
  1061. X
  1062. X_DATA   segment word public 'DATA'
  1063. X_DATA   ends
  1064. X
  1065. X        extrn   _crccode:word
  1066. X        extrn   _crctab:word
  1067. X        public  _addbfcrc
  1068. X
  1069. X_TEXT   segment byte public 'CODE'
  1070. X
  1071. XDGROUP  group   _DATA
  1072. X        assume  cs:_TEXT,ds:DGROUP,ss:DGROUP
  1073. X
  1074. X;void addbfcrc (buf, size) char *buf, int size
  1075. X
  1076. X_addbfcrc       proc    near
  1077. X        push    bp
  1078. X        mov     bp,sp
  1079. X        sub     sp,2
  1080. X        push    si
  1081. X        push    di
  1082. X        mov     cx,word ptr [bp+6]      ;cx = size
  1083. X        mov     si,word ptr [bp+4]      ;si = buf
  1084. X
  1085. X        xor     di,di                   ;i = 0
  1086. X
  1087. X        jcxz    done                    ;if size = 0, nothing to do
  1088. X@loop:
  1089. X
  1090. X;      crccode = crctab[(int) ((crccode) ^ (buf[i])) & 0xff] ^
  1091. X;         (((crccode) >> 8) & 0x00FFFFFFL);
  1092. X
  1093. X;       (dx,ax) <- ((crccode) >> 8) & 0x00FFFFFFL
  1094. X        mov     dx,word ptr DGROUP:_crccode+2
  1095. X        mov     ax,word ptr DGROUP:_crccode
  1096. X        mov     al,ah
  1097. X        mov     ah,dl
  1098. X        mov     dl,dh
  1099. X        xor     dh,dh
  1100. X
  1101. X        mov     bx,di                   ;bx <= i
  1102. X
  1103. X        mov     bl,byte ptr [bx+si]     ;bl <- buf[i]
  1104. X
  1105. X        xor     bl,byte ptr DGROUP:_crccode ;bl <- (bl ^ crccode) & 0xff
  1106. X        xor     bh,bh                   ;bx <- bl
  1107. X        shl     bx,1
  1108. X        shl     bx,1                    ;bx <- 4 * bx (for subscript)
  1109. X
  1110. X        xor     ax,word ptr DGROUP:_crctab[bx]
  1111. X        xor     dx,word ptr DGROUP:_crctab[bx+2]
  1112. X        mov     word ptr DGROUP:_crccode+2,dx
  1113. X        mov     word ptr DGROUP:_crccode,ax
  1114. X
  1115. X        inc     di              ; i++
  1116. X        loop    @loop
  1117. Xdone:
  1118. X
  1119. X        pop     di
  1120. X        pop     si
  1121. X        mov     sp,bp
  1122. X        pop     bp
  1123. X        ret     
  1124. X_addbfcrc       endp
  1125. X
  1126. X_TEXT   ends
  1127. X        end
  1128. SHAR_EOF
  1129. chmod 0666 addbfcrc.asm || echo "restore of addbfcrc.asm fails"
  1130. echo "x - extracting Makefile (Text)"
  1131. sed 's/^X//' << 'SHAR_EOF' > Makefile &&
  1132. X# Makefile for brik
  1133. X# ::[[ @(#) makefile.nix 1.2 89/07/08 10:41:32 ]]::
  1134. X
  1135. X# Please see brik.h for configuration options.
  1136. X
  1137. X# Make sure this file is called "makefile" (rename it if necessary).  Then
  1138. X# type one of the following.
  1139. X#
  1140. X# "make bsd", "make sys_v", "make ultrix", "make uport"
  1141. X#                   -- makes brik in current directory
  1142. X# "make install"    -- makes brik, then moves it into DESTDIR defined below
  1143. X# "make clean"      -- deletes "core", objects, and executable
  1144. X
  1145. X# Directory where we want to move executable brik on "make install"
  1146. XDESTDIR=/usr/local/bin/.
  1147. X
  1148. X# CFLAGS and CMORE are flags for the C compiler. 
  1149. X# LDFLAGS and LDMORE are flags for the loader.
  1150. X
  1151. XCFLAGS=-O
  1152. XCMORE=
  1153. XLDFLAGS=
  1154. XLDMORE=
  1155. X
  1156. XCC=cc
  1157. XLD=cc
  1158. X
  1159. X.c.o :
  1160. X    $(CC) -c $(CFLAGS) $(CMORE) $*.c
  1161. X
  1162. XOBJS = brik.o initcrc.o addbfcrc.o
  1163. X
  1164. Xall:
  1165. X    @echo 'Please type "make sys_v", "make bsd", "make ultrix", or "make uport"'
  1166. X
  1167. Xsys_v:
  1168. X    make "CMORE=-DSYS_V" brik
  1169. X
  1170. Xbsd:
  1171. X    make "CMORE=-DBSD" brik
  1172. X
  1173. Xuport:
  1174. X    make "CMORE=-Ml -DSYS_V" "LDMORE=-Ml" brik
  1175. X
  1176. Xultrix:
  1177. X    make "CMORE=-DBSD -DULTRIX_BUG" brik
  1178. X
  1179. Xbrik: $(OBJS)
  1180. X    $(LD) $(LDFLAGS) $(LDMORE) -o brik $(OBJS)
  1181. X
  1182. Xbrik.o: brik.c brik.h assert.h
  1183. X
  1184. Xinitcrc.o: initcrc.c brik.h
  1185. X
  1186. Xinstall: brik
  1187. X    mv brik $(DESTDIR)/brik
  1188. X
  1189. Xclean:
  1190. X    /bin/rm -f $(OBJS) core brik
  1191. SHAR_EOF
  1192. chmod 0666 Makefile || echo "restore of Makefile fails"
  1193. echo "x - extracting options.opt (Text)"
  1194. sed 's/^X//' << 'SHAR_EOF' > options.opt &&
  1195. Xsys$share:vaxcrtl.exe/share
  1196. SHAR_EOF
  1197. chmod 0666 options.opt || echo "restore of options.opt fails"
  1198. echo "x - extracting makefile.tcc (Text)"
  1199. sed 's/^X//' << 'SHAR_EOF' > makefile.tcc &&
  1200. X# needs NDMAKE (tested with version 4.31), Turbo C 2.0, Turbo Assembler
  1201. X# (tested with version 1.0).  Can be easily modified to use Micoroft
  1202. X# assembler instead.  Will work with Borland's make program (tested 
  1203. X# with version 2.0) if you comment out the .SUFFIXES line.
  1204. X
  1205. XCC = tcc
  1206. XCFLAGS = -c -DTURBOC -DLINT -DNDEBUG
  1207. XLD = tcc
  1208. XLDFLAGS = -eBRIK
  1209. XAS = tasm
  1210. XASFLAGS = -mx
  1211. X
  1212. X# To use Borland's make program, comment out the following line
  1213. X.SUFFIXES : .exe .obj .asm .c
  1214. X
  1215. X.asm.obj :
  1216. X    $(AS) $(ASFLAGS) $*.asm
  1217. X
  1218. X.c.obj :
  1219. X    $(CC) $(CFLAGS) $*.c
  1220. X
  1221. XOBJS = brik.obj initcrc.obj getopt.obj turboc.obj addbfcrc.obj
  1222. X
  1223. Xbrik.exe: $(OBJS)
  1224. X    $(LD) $(LDFLAGS) $(OBJS)
  1225. X
  1226. Xbrik.obj: brik.c brik.h assert.h
  1227. X
  1228. Xaddbfcrc.obj: addbfcrc.asm
  1229. SHAR_EOF
  1230. chmod 0666 makefile.tcc || echo "restore of makefile.tcc fails"
  1231. echo "x - extracting makefile.msc (Text)"
  1232. sed 's/^X//' << 'SHAR_EOF' > makefile.msc &&
  1233. X# Makefile for Microsoft C 5.1 thanks to Tom Horsley <tom@ssd.harris.com>.
  1234. X# Slightly modified.  You will need a good "make" utility.  Not tested.
  1235. X#                                   -- Rahul Dhesi
  1236. X
  1237. X# "make brik.exe"   -- make brik.exe in current directory
  1238. X# "make clean"      -- delete brik.exe and *.obj, needs "rm" to be present
  1239. X
  1240. X# define your library directory below
  1241. XLIB = C:\C51\LIB
  1242. X
  1243. X# see "brik.h" for other optional compile-time symbols
  1244. XCFLAGS = -DMSC51
  1245. X
  1246. XOBJS = brik.obj getopt.obj turboc.obj initcrc.obj addbfcrc.obj
  1247. X
  1248. Xbrik.exe: $(OBJS)
  1249. X    $(CC) -Febrik.exe -F 8000 $(OBJS) $(LIB)\setargv.obj /link /NOE
  1250. X
  1251. Xturboc.obj: turboc.c brik.h assert.h
  1252. X
  1253. Xinitcrc.obj: initcrc.c
  1254. X
  1255. Xbrik.obj: brik.c brik.h assert.h
  1256. X
  1257. Xgetopt.obj: getopt.c
  1258. X
  1259. X# there is also addbfcrc.asm for speed, designed to work
  1260. X# with Turbo C.  It may need to be revised for MSC.  -- R.D.
  1261. X
  1262. Xaddbfcrc.obj: addbfcrc.c
  1263. X
  1264. Xclean:
  1265. X    rm -f *.obj brik.exe
  1266. SHAR_EOF
  1267. chmod 0666 makefile.msc || echo "restore of makefile.msc fails"
  1268. echo "x - extracting makebrik.com (Text)"
  1269. sed 's/^X//' << 'SHAR_EOF' > makebrik.com &&
  1270. X$! This command file compiles brik for VAX/VMS and also defines a
  1271. X$! symbol so you can type "brik" to execute the program.
  1272. X$!
  1273. X$ cc /define=VMS brik.c
  1274. X$ cc /define=VMS addbfcrc
  1275. X$ cc /define=VMS initcrc.c
  1276. X$ cc /define=VMS vms.c
  1277. X$ cc /define=VMS getopt.c
  1278. X$ link/executable=brik.exe  brik,addbfcrc,initcrc,vms,getopt, options/opt
  1279. X$ brik:==$'f$trnlnm("sys$disk")''f$directory()'brik.exe
  1280. SHAR_EOF
  1281. chmod 0666 makebrik.com || echo "restore of makebrik.com fails"
  1282. echo "x - extracting descrip.mms (Text)"
  1283. sed 's/^X//' << 'SHAR_EOF' > descrip.mms &&
  1284. X# Makefile for brik -- for VAX/VMS "mms".  If you don't have mms,
  1285. X#  use the "makebrik.com" command file instead.
  1286. X#
  1287. X# Don't forget to define a symbol "brik" like this:
  1288. X#  $ brik:==$disk:[dir]brik.exe
  1289. X# where "disk" is your device name and "dir" is the directory in which
  1290. X# brik.exe is kept.
  1291. X
  1292. X# ::[[ @(#) descrip.mms 1.2 89/07/08 10:44:01 ]]::
  1293. X
  1294. X# Please see brik.h for configuration options.
  1295. X
  1296. XCFLAGS = /define=VMS
  1297. XOBJS = brik.obj, addbfcrc.obj, getopt.obj, vms.obj, initcrc.obj
  1298. XCC = cc
  1299. X
  1300. X.c.obj :
  1301. X    $(CC) $(CFLAGS) $*.c
  1302. X
  1303. Xbrik.exe : $(OBJS)
  1304. X    link/executable=brik.exe  $(OBJS), options/opt
  1305. X
  1306. Xbrik.obj : brik.c brik.h assert.h
  1307. X
  1308. Xaddbfcrc.obj : addbfcrc.c
  1309. X
  1310. Xvms.obj : vms.c
  1311. X
  1312. Xgetopt.obj : getopt.c
  1313. X
  1314. Xinitcrc.obj : initcrc.c
  1315. SHAR_EOF
  1316. chmod 0666 descrip.mms || echo "restore of descrip.mms fails"
  1317. echo "x - extracting crc.lst (Text)"
  1318. sed 's/^X//' << 'SHAR_EOF' > crc.lst &&
  1319. X# Whole file CRCs generated by Brik v2.0.  Use "brik -C" to verify them.
  1320. X
  1321. X# CRC-32        filename
  1322. X# ------        --------
  1323. X
  1324. X 596215296      Makefile
  1325. X2363322425      addbfcrc.asm
  1326. X2893546047      addbfcrc.c
  1327. X1943472856      assert.h
  1328. X2588064855      brik.1
  1329. X4124789894      brik.c
  1330. X1364707051      brik.doc
  1331. X2680503236      brik.h
  1332. X2417647845      brik.prj
  1333. X3056859226      descrip.mms
  1334. X2566277976      getopt.c
  1335. X1764729989      initcrc.c
  1336. X3651763827      install
  1337. X4163595257      makebrik.com
  1338. X3874945495      makefile.msc
  1339. X 596215296      makefile.nix
  1340. X 566402493      makefile.tcc
  1341. X 900930479      options.opt
  1342. X 775774555      turboc.c
  1343. X1446083007      turboc.cfg
  1344. X1151475469      vms.c
  1345. SHAR_EOF
  1346. chmod 0666 crc.lst || echo "restore of crc.lst fails"
  1347. echo "x - extracting brik.prj (Text)"
  1348. sed 's/^X//' << 'SHAR_EOF' > brik.prj &&
  1349. Xaddbfcrc.obj
  1350. Xbrik.c          (assert.h brik.h)
  1351. Xgetopt.c
  1352. Xturboc.c        (assert.h)
  1353. Xinitcrc.c
  1354. SHAR_EOF
  1355. chmod 0666 brik.prj || echo "restore of brik.prj fails"
  1356. echo "x - extracting assert.h (Text)"
  1357. sed 's/^X//' << 'SHAR_EOF' > assert.h &&
  1358. X/* @(#) assert.h 1.5 89/03/08 14:59:02 */
  1359. X
  1360. X/* I claim no copyright over the contents of this file.  -- Rahul Dhesi */
  1361. X
  1362. X/*
  1363. XChecksum: 3376323427      (check or update this with "brik")
  1364. X*/
  1365. X
  1366. X/*
  1367. X**   Assertions are enabled only if NDEBUG is not defined.
  1368. X**   Not all compilers define __FILE__ and __LINE__.  If yours
  1369. X**   doesn't, you can just let NDEBUG remain #defined in brik.h and no
  1370. X**   assertions will be compiled in.  Or, if you want to enable
  1371. X**   assertions, redefine the assert() macro so it works with your
  1372. X**   compiler.
  1373. X*/
  1374. X
  1375. X#ifndef OK_STDIO
  1376. X# include <stdio.h>
  1377. X# define OK_STDIO
  1378. X#endif
  1379. X
  1380. X#ifndef NDEBUG
  1381. X#define assert(E) \
  1382. X{if(!(E))fprintf(stderr,"Assertion error in %s line %d\n",__FILE__,__LINE__);}
  1383. X#else
  1384. X#define assert(E)
  1385. X#endif /* NDEBUG */
  1386. SHAR_EOF
  1387. chmod 0666 assert.h || echo "restore of assert.h fails"
  1388. echo "x - extracting addbfcrc.c (Text)"
  1389. sed 's/^X//' << 'SHAR_EOF' > addbfcrc.c &&
  1390. X/* ::[[ @(#) addbfcrc.c 1.10 89/07/08 10:34:48 ]]:: */
  1391. X/* Adapted from zmodem source code, which contained Gary Brown's code */
  1392. X
  1393. X#ifndef LINT
  1394. Xstatic char sccsid[]="::[[ @(#) addbfcrc.c 1.10 89/07/08 10:34:48 ]]::";
  1395. X#endif
  1396. X
  1397. Xtypedef unsigned long tcrc;      /* type of crc value -- same as in brik.c */
  1398. Xextern tcrc crccode;             /* holds all crc values */
  1399. Xextern tcrc crctab[];            /* the crc calculation table */
  1400. X
  1401. Xvoid addbfcrc (buf, size)
  1402. Xregister char *buf;
  1403. Xregister int size;
  1404. X{
  1405. X   int i;
  1406. X   for (i = 0;  i < size;  i ++) {
  1407. X      crccode = crctab[(int) ((crccode) ^ (buf[i])) & 0xff] ^
  1408. X         (((crccode) >> 8) & 0x00FFFFFFL);
  1409. X   }
  1410. X}
  1411. SHAR_EOF
  1412. chmod 0666 addbfcrc.c || echo "restore of addbfcrc.c fails"
  1413. exit 0
  1414.  
  1415.