home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / GCC / GCC258_3.LHA / gcc / man / cat1 / brik.0 < prev    next >
Encoding:
Text File  |  1993-12-08  |  29.5 KB  |  925 lines

  1.  
  2.  
  3.  
  4. BRIK(1)             RISC/os Reference Manual              BRIK(1)
  5.  
  6.  
  7.  
  8. NAME
  9.      brik - calculate 32-bit CRC
  10.  
  11. SYNOPSIS
  12.      brik -h
  13.      brik -gcGCbafvsqWHT _f_i_l_e ...
  14.  
  15. DESCRIPTION
  16.      _B_r_i_k generates and verifies 32-bit CRC values (checksums).
  17.      It is designed to generate CRCs for text files that are the
  18.      same on all computer systems that use the ASCII character
  19.      set, provided each text file is in the usual text file for-
  20.      mat for each system. _B_r_i_k will also optionally use binary
  21.      CRCs calculated using every byte in a file.  Such binary
  22.      CRCs are portable across systems for binary files that are
  23.      moved from system to system without any newline conversion.
  24.      _B_r_i_k can be asked to decide by examining each file whether
  25.      to calculate a text mode or binary mode CRC for it.
  26.  
  27.      Changes from version 1.0 are summarized at the end of this
  28.      document.
  29.  
  30.      The general usage format is:
  31.  
  32.           brik -gcGCbafvsqWHT [ _f_i_l_e ] ...
  33.  
  34.      The brackets mean that _f_i_l_e, which is the name of a file, is
  35.      optional.  The three dots indicate that more than one
  36.      filename may be typed (separated by blanks).  Exactly one of
  37.      the options -c, -C, -g, -G, or -h, is required.  The -h
  38.      option gives a help screen.
  39.  
  40.      In addition to -h, the _B_r_i_k options available (as they
  41.      appear on the help screen) are:
  42.  
  43.      -g   look for _C_h_e_c_k_s_u_m: header, generate CRC for rest of
  44.           file
  45.  
  46.      -c   get CRC from header, verify CRC of rest of file
  47.  
  48.      -G   generate CRC for entire file (add -b for binary files)
  49.  
  50.      -C   verify all file CRCs from output of -G (-f is not
  51.           needed)
  52.  
  53.      -b   use binary mode -- read file byte by byte, not line by
  54.           line
  55.  
  56.      -a   automatically decide whether each file is text or
  57.           binary
  58.  
  59.      -f   read filenames (wildcards ok) from specified files
  60.  
  61.  
  62.  
  63. Printed 0/0/0              Jul 8, 1989                          1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. BRIK(1)             RISC/os Reference Manual              BRIK(1)
  71.  
  72.  
  73.  
  74.      -v   be verbose, report all results (else only errors are
  75.           reported)
  76.  
  77.      -s   be silent, say nothing, just return status code
  78.  
  79.      -q   be quiet, don't print header for -G
  80.  
  81.      -W   after generating CRC with -g, write it to original
  82.           header
  83.  
  84.      -H   after generating CRC with -g, print header to stdout
  85.  
  86.      -T   include trailing empty lines, normally ignored (text
  87.           mode only)
  88.  
  89.      VERIFYING CRC HEADERS
  90.  
  91.      The primary intended use of _B_r_i_k is to verify _C_h_e_c_k_s_u_m:
  92.      headers in Usenet postings and in C and Pascal source files.
  93.      A _C_h_e_c_k_s_u_m: header looks like this:
  94.  
  95.           Checksum: 9485762645b   (verify with "brik")
  96.  
  97.      The word _C_h_e_c_k_s_u_m: must occur at the beginning of a line.
  98.      It is followed by a colon, an optional blank, a ten-digit
  99.      decimal 32-bit CRC, and any arbitrary optional string such
  100.      as the comment shown above.  The CRC value may be followed
  101.      by a one-character suffix identifying the type of the CRC.
  102.      These suffixes are described later.
  103.  
  104.      When _B_r_i_k is invoked with the syntax
  105.  
  106.           brik -c _f_i_l_e ...
  107.  
  108.      it will search for the _C_h_e_c_k_s_u_m: header in each specified
  109.      _f_i_l_e, read the CRC value from that header, calculate the
  110.      CRC-32 for all lines in the file (except trailing empty
  111.      lines) that occur *after* the header line, and report an
  112.      error if the two values do not match.
  113.  
  114.      CALCULATING CRC HEADERS
  115.  
  116.      The command
  117.  
  118.           brik -g _f_i_l_e ...
  119.  
  120.      tells _B_r_i_k to look for the _C_h_e_c_k_s_u_m: header in each speci-
  121.      fied _f_i_l_e, calculate the CRC of the lines in the file fol-
  122.      lowing the header, and print the CRC and filename without
  123.      changing the file in any way.  You can also ask _B_r_i_k to
  124.      update the _C_h_e_c_k_s_u_m: header with the following command:
  125.  
  126.  
  127.  
  128.  
  129. Printed 0/0/0              Jul 8, 1989                          2
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. BRIK(1)             RISC/os Reference Manual              BRIK(1)
  137.  
  138.  
  139.  
  140.           brik -gW _f_i_l_e ...
  141.  
  142.      This causes _B_r_i_k to update the _C_h_e_c_k_s_u_m: header in the file
  143.      with the newly-calculated CRC.  If there is not enough space
  144.      for the CRC in the existing header, _B_r_i_k reports an error
  145.      and does not change the existing header.  To initially add a
  146.      _C_h_e_c_k_s_u_m: header to a file, insert a line of the following
  147.      form into the file with a text editor:
  148.  
  149.           Checksum: XXXXXXXXXX  -- this is an optional comment
  150.  
  151.      The word _C_h_e_c_k_s_u_m must be at the beginning of a line.  The
  152.      ten `X' characters shown can be any ten characters.  They
  153.      will be later replaced by the calculated CRC value.  They do
  154.      not need to be `X'.  The comment following them is optional
  155.      and can be any arbitrary string of characters after the CRC
  156.      field, separated from it by blanks.  As an example, in a C
  157.      source file called _m_a_i_n._c, you might have:
  158.  
  159.           /*
  160.           Checksum: XXXXXXXXXX  (verify or update with brik)
  161.           */
  162.  
  163.      Once a header like this exists in the file, invoke _B_r_i_k as
  164.      follows:
  165.  
  166.           brik -gW main.c
  167.  
  168.      This will cause the ten `X' characters to be replaced with
  169.      the calculated checksum, giving something like this:
  170.  
  171.           /*
  172.           Checksum: 1922837484  (verify or update with brik)
  173.           */
  174.  
  175.      Later you can use the command
  176.  
  177.           brik -c main.c
  178.  
  179.      to verify that the contents of the file following the header
  180.      have the same CRC as the stored value.
  181.  
  182.      If _B_r_i_k is invoked with the -c or -g options and it cannot
  183.      find a _C_h_e_c_k_s_u_m: header in a file, it prints a row of ques-
  184.      tion marks.  If it is invoked with the -gW option and it
  185.      does not find enough character positions after the _C_h_e_c_k_s_u_m:
  186.      string to hold the CRC, it does not fill in the CRC and
  187.      prints an error message.
  188.  
  189.      _B_r_i_k can be asked to generate a complete _C_h_e_c_k_s_u_m: header
  190.      but print it to standard output instead of writing it to the
  191.      file.  Do this by adding the -H option.  If both -W and -H
  192.  
  193.  
  194.  
  195. Printed 0/0/0              Jul 8, 1989                          3
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. BRIK(1)             RISC/os Reference Manual              BRIK(1)
  203.  
  204.  
  205.  
  206.      are given, the _C_h_e_c_k_s_u_m: header will be written both to the
  207.      file and to standard output.
  208.  
  209.      WHOLE-FILE CRCS
  210.  
  211.      A "whole-file" CRC calculation is done for the entire con-
  212.      tents of a file, without looking for a _C_h_e_c_k_s_u_m: header.
  213.      The command
  214.  
  215.           brik -G _f_i_l_e ...
  216.  
  217.      asks _B_r_i_k to do this calculation for all specified files.
  218.      The output from this command is a list of files and their
  219.      whole-file CRCs.  It is sent to the standard output stream,
  220.      which in most cases is your screen.  The output should be
  221.      saved in a file by redirecting it.  For example, the command
  222.  
  223.           brik -G *.h *.c > crc.lst
  224.  
  225.      on an MS-DOS system might yield the following in the output
  226.      file _c_r_c._l_s_t:
  227.  
  228.           # CRC-32        filename
  229.           # ------        --------
  230.  
  231.           2566277976      getopt.c
  232.            100594287      brik.c
  233.           1151475469      vms.c
  234.           3929503738      turboc.c
  235.           2424271922      addbfcrc.c
  236.           1943472856      assert.h
  237.           2601923477      brik.h
  238.  
  239.      The output of the -G option is in free format.  The output
  240.      file may be edited by hand.  Empty lines and lines beginning
  241.      with '#' will be ignored by _B_r_i_k when it is later asked to
  242.      read this file.
  243.  
  244.      This list of filenames and whole-file CRCs may be verified
  245.      by a command like this:
  246.  
  247.           brik -C crc.lst
  248.  
  249.      This makes _B_r_i_k read the file _c_r_c._l_s_t, get the CRCs and
  250.      filenames from it, do the CRC calculation again for each
  251.      file, and report an error if it does not match the CRC
  252.      recorded inside _c_r_c._l_s_t.
  253.  
  254.      **IX and MS-DOS users (and others who can pipe the output of
  255.      one command into another) could use a command like the fol-
  256.      lowing to see if _B_r_i_k'_s -G and -C options are working:
  257.  
  258.  
  259.  
  260.  
  261. Printed 0/0/0              Jul 8, 1989                          4
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. BRIK(1)             RISC/os Reference Manual              BRIK(1)
  269.  
  270.  
  271.  
  272.           brik -G file ... | brik -C
  273.  
  274.      This invokes "brik -G" on some files, sending the output to
  275.      a pipe where it becomes the input of "brik -C".  If no
  276.      filename is specified, _B_r_i_k reads from standard input, so
  277.      "brik -C" will read from the pipe and concurrently verify
  278.      all the CRCs that are being generated by "brik -G".
  279.  
  280.      Whole-file CRCs are normally generated in text mode, in
  281.      which a file is treated as lines of text.  You can also gen-
  282.      erate whole-file CRCs in binary mode.  See below.
  283.  
  284.      BINARY VERSUS TEXT MODE
  285.  
  286.      _B_r_i_k can work in two different modes.  The most common mode,
  287.      used unless you specify otherwise, is text mode.
  288.  
  289.      In this mode _B_r_i_k reads all files line by line, and forces
  290.      each line of text to be terminated by a newline character of
  291.      constant value before doing a CRC calculation.  Thus, no
  292.      matter what newline character is used by your system, the
  293.      CRC calculation will be unaffected.  This means that whether
  294.      your operating system uses linefeeds to terminate lines
  295.      (e.g. **IX), or a carriage return and a linefeed (e.g. MS-
  296.      DOS) or a carriage return only (e.g. Macintosh) or nothing
  297.      but a record length field (e.g. VAX/VMS), the CRC calcula-
  298.      tion in text mode gives the same results.
  299.  
  300.      If a file is not intended to be a text file, the text mode
  301.      CRC calculated by _B_r_i_k may not be reliable and may be dif-
  302.      ferent on different systems.  If _B_r_i_k is calculating a text
  303.      mode CRC on a file that appears to contain binary data, it
  304.      still calculates the text-mode CRC but adds a "*" character
  305.      after the CRC to indicate to warn the user.
  306.  
  307.      _B_r_i_k can be asked to operate in binary mode by adding a -b
  308.      option.  Binary mode is applicable only to the -G command,
  309.      which acts on whole files.  Thus
  310.  
  311.           brik -G _f_i_l_e ...
  312.  
  313.      finds whole-file CRCs of all specified files in text mode,
  314.      while
  315.  
  316.           brik -Gb _f_i_l_e ...
  317.  
  318.      does the same in binary mode.  In binary mode _B_r_i_k simply
  319.      reads and calculates the CRC for all bytes in a file.  If a
  320.      file is moved from one system to another without any newline
  321.      conversion or any other changes, _B_r_i_k should calculate the
  322.      same binary mode CRC for it on both systems.
  323.  
  324.  
  325.  
  326.  
  327. Printed 0/0/0              Jul 8, 1989                          5
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. BRIK(1)             RISC/os Reference Manual              BRIK(1)
  335.  
  336.  
  337.  
  338.      The output from "brik -Gb" includes a trailing b suffix in
  339.      each CRC, so "brik -C" will correctly use binary mode for
  340.      such CRCs and it is never necessary to type "brik -Cb"
  341.      instead.
  342.  
  343.      In its auto-check mode, _B_r_i_k will itself examine each file
  344.      and determine whether it is a text or binary file and calcu-
  345.      late a CRC accordingly.  To do this, use the -a option.
  346.      Although _B_r_i_k can determine the type of each file with a
  347.      high degree of reliability, it is still possible for it to
  348.      come to a wrong conclusion about some files.
  349.  
  350.      The output from "brik -Ga" will include a trailing b charac-
  351.      ter in the CRC for those files that appeared to be binary to
  352.      _B_r_i_k.  You may find both text and binary CRCs in the output.
  353.  
  354.      TRAILING EMPTY LINES
  355.  
  356.      The normal behavior of _B_r_i_k in text mode is to ignore any
  357.      trailing empty lines in a file.  An empty line is a line
  358.      that contains nothing, not even blanks or tabs.  (Just hit-
  359.      ting a carriage return when you are editing a text file usu-
  360.      ally produces an empty line.)  If manipulating a text file
  361.      causes trailing empty lines to be added or deleted, the CRC
  362.      calculated by _B_r_i_k will be unaffected.  You can override
  363.      this if necessary with the -T option, which makes _B_r_i_k
  364.      include trailing empty lines in the CRC calculation.  For
  365.      example,
  366.  
  367.           brik -gWT
  368.  
  369.      will update the _C_h_e_c_k_s_u_m: header with a CRC that includes
  370.      all lines in a text file.  Similarly
  371.  
  372.           brik -GT
  373.  
  374.      will find whole-file CRCs that include all lines in a text
  375.      file.
  376.  
  377.      When _B_r_i_k is given the -T option, it adds a T suffix to each
  378.      generated CRC.  Then, when the CRC is verified with -c or
  379.      -C, _B_r_i_k will correctly include trailing empty lines when
  380.      needed without having to be explicitly told to do so.
  381.  
  382.      In binary mode _B_r_i_k always reads all bytes in a file, so it
  383.      does not ignore trailing empty lines, and the -T switch is
  384.      not needed.
  385.  
  386.      The effects of the -T and -b options are mutually exclusive.
  387.      If both are given, whichever is used later overrides the
  388.      first.  So -bT is equivalent to -T and -Tb is equivalent to
  389.      -T.
  390.  
  391.  
  392.  
  393. Printed 0/0/0              Jul 8, 1989                          6
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. BRIK(1)             RISC/os Reference Manual              BRIK(1)
  401.  
  402.  
  403.  
  404.      FILENAME CONVENTIONS
  405.  
  406.      Under MS-DOS and VAX/VMS, wildcards are allowed on the com-
  407.      mand line and will be expanded by _B_r_i_k.  Under **IX, wild-
  408.      cards are expected to be expanded by the shell and are not
  409.      expanded by _B_r_i_k.  If no filename is given, _B_r_i_k reads its
  410.      standard input.  By default this is keyboard input, but it
  411.      is expected that input will usually be redirected to come
  412.      from a file or a pipe.  Also, if a filename is explicitly
  413.      specified as a dash ("-"), it stands for standard input.
  414.  
  415.      The following five commands (valid under the **IX operating
  416.      system)
  417.  
  418.           brik -c myfile            # "myfile"
  419.           brik -c < myfile          # stdin = "myfile"
  420.           cat myfile | brik -c      # stdin = a pipe
  421.           brik -c - < myfile        # "-" = stdin = "myfile"
  422.           cat myfile | brik -c -    # "-" = stdin = a pipe
  423.  
  424.      all have the effect of verifying the _C_h_e_c_k_s_u_m: header in the
  425.      file _m_y_f_i_l_e.
  426.  
  427.      Standard input can also be read when using the -C option.
  428.      For example, suppose we have already given the command
  429.  
  430.           brik -G *.c *.h > crc.lst
  431.  
  432.      to create a file called "crc.lst" that contains a list of
  433.      whole-file CRCs.  We can now verify the integrity of these
  434.      files with any of the following commands:
  435.  
  436.           brik -C crc.lst          # "crc.lst"
  437.           brik -C < crc.lst        # stdin = "crc.lst"
  438.           brik -C - < crc.lst      # "-" = stdin = "crc.lst"
  439.           cat crc.lst | brik -C    # stdin = a pipe
  440.           cat crc.lst | brik -C -  # "-" = stdin = a pipe
  441.  
  442.  
  443.      INDIRECT FILE NAMING
  444.  
  445.      The -f option allows you to have filenames in a list rather
  446.      than on the command line.  For example, suppose you want to
  447.      generate whole-file CRCs of files whose names are selected
  448.      by some other program.  You could use _f_i_n_d (under **IX) or
  449.      _S_t_u_f_f (under MS-DOS) to generate a list of filenames.  When
  450.      the -f option is given, _B_r_i_k reads filenames, one per line,
  451.      from the file(s) specified.  Thus you could do the follow-
  452.      ing:
  453.  
  454.           find . -mtime +3 -print > flist
  455.           brik -Gf flist > crc.lst
  456.  
  457.  
  458.  
  459. Printed 0/0/0              Jul 8, 1989                          7
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466. BRIK(1)             RISC/os Reference Manual              BRIK(1)
  467.  
  468.  
  469.  
  470.      The first command asks _f_i_n_d to generate a list of names of
  471.      all files that were modified more than 3 days ago, and sends
  472.      the output to the file _f_l_i_s_t.  The contents of _f_l_i_s_t might
  473.      now look like this, as an example:
  474.  
  475.           ./sez.doc
  476.           ./brik.doc
  477.           ./stuff.doc
  478.           ./looz.doc
  479.  
  480.      The second command above asks _B_r_i_k to read the file called
  481.      _f_l_i_s_t, get a list of filenames from it, one per line, and
  482.      generate the whole-file CRC of each of these files.  We
  483.      additionally redirect the output of "brik -Gf" to the file
  484.      called _c_r_c._l_s_t.  Given the above contents of _f_l_i_s_t, the fol-
  485.      lowing two commands are exactly equivalent:
  486.  
  487.           brik -Gf flist >crc.lst
  488.           brik -G ./sez.doc ./brik.doc ./stuff.doc ./looz.doc >crc.lst
  489.  
  490.      The advantage of the -f option is that once you have
  491.      filenames in a file, you need not type them again at the
  492.      command line.  The -f option also allows you to feed _B_r_i_k
  493.      through a pipe filenames generated by another program.  Con-
  494.      sider this command:
  495.  
  496.           find . -mtime +3 -print | brik -Gf - > crc.lst
  497.  
  498.      Under **IX this concurrently invokes both _f_i_n_d and _B_r_i_k.  As
  499.      _f_i_n_d generates a filename and sends it to its standard out-
  500.      put (a pipe), _B_r_i_k reads the filename from its standard
  501.      input and generates its whole-file CRC.  The following pipe-
  502.      line
  503.  
  504.           find . -mtime +3 -print | brik -Gf - | brik -C -
  505.  
  506.      invokes _f_i_n_d to generate filenames, _B_r_i_k to print the
  507.      whole-file CRCs of those files, and _B_r_i_k again to immedi-
  508.      ately verify them.
  509.  
  510.      Under MS-DOS and VAX/VMS (and any other operating system
  511.      under which _B_r_i_k has been installed to expand wildcards
  512.      itself), a file specified by the -f option can itself con-
  513.      tain wildcards in the filenames.  For example, suppose the
  514.      file "wildfile" contains the following lines:
  515.  
  516.           /bin/*.exe
  517.           /bin/*.com
  518.           /doc/*.doc
  519.  
  520.      Now if we invoke _B_r_i_k with the command
  521.  
  522.  
  523.  
  524.  
  525. Printed 0/0/0              Jul 8, 1989                          8
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532. BRIK(1)             RISC/os Reference Manual              BRIK(1)
  533.  
  534.  
  535.  
  536.           brik -Gf wildfile
  537.  
  538.      it will read filespecs from "wildfile," expand wildcards in
  539.      each filespec, and generate whole-file CRCs for all matching
  540.      files.
  541.  
  542.      If you are checking whole-file CRCs with the -C option, you
  543.      do not normally need to use the -f option.  When used with
  544.      -C, the -f option introduces an additional level of file
  545.      naming indirection. For example, the command
  546.  
  547.           brik -C crc.lst
  548.  
  549.      takes a list of CRCs and filenames from "crc.lst" and veri-
  550.      fies them.  However, the command
  551.  
  552.           brik -Cf master.lst
  553.  
  554.      does not do the same thing.  Instead, it takes a list of
  555.      files from "master.lst," looks inside each of _t_h_o_s_e files
  556.      for a list of CRCs and filenames, and verifies them.
  557.  
  558.      As an example of the use of -Cf, consider this sequence:
  559.  
  560.           brik -Gb /bin/*.exe > exelist
  561.           brik -Gb /bin/*.com > comlist
  562.           brik -GT /doc/*.doc > doclist
  563.           brik -G  /doc/*.man > manlist
  564.  
  565.      Now we have four files called "exelist," "comlist,"
  566.      "doclist," and "manlist" containing whole-file CRCs of vari-
  567.      ous types.  We can test the integrity of files listed in
  568.      these in four separate commands like this:
  569.  
  570.           brik -C exelist
  571.           brik -C comlist
  572.           brik -C doclist
  573.           brik -C manlist
  574.  
  575.      But we could also do this in a single step by first creating
  576.      a file called "biglist" that contains the names of these
  577.      four files:
  578.  
  579.           exelist
  580.           comlist
  581.           doclist
  582.           manlist
  583.  
  584.      and then use -Cf thus:
  585.  
  586.           brik -Cf biglist
  587.  
  588.  
  589.  
  590.  
  591. Printed 0/0/0              Jul 8, 1989                          9
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598. BRIK(1)             RISC/os Reference Manual              BRIK(1)
  599.  
  600.  
  601.  
  602.      This causes _B_r_i_k to read filenames from "biglist," look
  603.      inside each of those files ("exelist," "comlist," "doclist,"
  604.      and "manlist") and check the CRCs found there.  A **IX exam-
  605.      ple to do the same thing in a more compact way might be:
  606.  
  607.           cat exelist comlist doclist manlist | brik -Cf -
  608.  
  609.      The above examples are somewhat contrived, however.  We
  610.      could also use the following command:
  611.  
  612.           brik -C exelist comlist doclist manlist
  613.  
  614.  
  615.      SILENT VERSUS VERBOSE VERSUS QUIET
  616.  
  617.      _B_r_i_k accepts options -s, -q, and -v that control the degree
  618.      of verbosity.
  619.  
  620.      Normally _B_r_i_k prints a message only if it detects an error.
  621.      For example, if you give the command
  622.  
  623.           brik -c *.c *.h
  624.  
  625.      and _B_r_i_k finds that all _C_h_e_c_k_s_u_m: headers contain CRCs that
  626.      match the calculated value, it prints nothing.
  627.  
  628.      The -v switch makes _B_r_i_k print a message for each file
  629.      tested that contains the word "ok" if stored and calculated
  630.      CRCs matched and "BAD" if they did not.
  631.  
  632.      In all messages reporting file CRCs, _B_r_i_k prints the actual
  633.      CRC it calculated, or a row of question marks if it could
  634.      not calculate one.  _B_r_i_k fails to calculate a CRC if it is
  635.      trying to calculate a header-based CRC (commands -c and -g)
  636.      but does not find a _C_h_e_c_k_s_u_m: header in a file.
  637.  
  638.      The -s switch tells _B_r_i_k to be silent.  This will cause
  639.      nothing to be printed if _B_r_i_k does not find a _C_h_e_c_k_s_u_m
  640.      header or if CRCs don't match.  However, the status code on
  641.      exit is still set.  The -s option is useful for invoking
  642.      _B_r_i_k from within a shell script (**IX) or a batch file (MS-
  643.      DOS) and later testing the error code it returned when it
  644.      exited.
  645.  
  646.      The -s switch does not suppress the error message printed if
  647.      _B_r_i_k is given a filename and the file cannot be found.  For
  648.      example, if the command
  649.  
  650.           brik -cs myfile
  651.  
  652.      is given but "myfile" does not exist, _B_r_i_k will print an
  653.      error message even though the -s option was given.
  654.  
  655.  
  656.  
  657. Printed 0/0/0              Jul 8, 1989                         10
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664. BRIK(1)             RISC/os Reference Manual              BRIK(1)
  665.  
  666.  
  667.  
  668.      The -q switch makes _B_r_i_k slightly quieter.  Its only effect
  669.      is to suppress the introductory comments that are otherwise
  670.      generated by the -C option.
  671.  
  672.      VAX/VMS BUGS
  673.  
  674.      o    Under VAX/VMS, file manipulation is unpredictable and
  675.           the VAX/VMS C runtime library in particular is very
  676.           unreliable.  One result is that under VAX/VMS, the -gW
  677.           option will work only for stream-LF files, which are
  678.           the only type of file that VAX/VMS seems to handle
  679.           correctly.  Fortunately, the -c option will correctly
  680.           work for VAX/VMS standard text files.
  681.  
  682.      o    The VAX/VMS implementation of _B_r_i_k simply ignores
  683.           filenames that correspond to nonexistent files instead
  684.           of giving an error message.  VMS users are invited to
  685.           fix this bug (probably somewhere in the _n_e_x_t_f_i_l_e()
  686.           function in the file _v_m_s._c) and send me the fix.
  687.  
  688.      o    To avoid annoying error messages, _B_r_i_k under VAX/VMS
  689.           always exits with a status code of 1.
  690.  
  691.      o    Due to a problem in the VAX/VMS command interpreter, if
  692.           any uppercase option characters are typed (e.g. -C, -G,
  693.           -T), _B_r_i_k will not recognize them as uppercase unless
  694.           they are enclosed in double quotes.  An example of a
  695.           correct command under VAX/VMS:
  696.  
  697.             brik "-GT" *.*
  698.  
  699.           An example of a command that won't work:
  700.  
  701.             brik -GT *.*
  702.  
  703.      USAGE HINTS
  704.  
  705.      This section discusses some ways of using _B_r_i_k.
  706.  
  707.      -    _B_r_i_k is currently used to create and verify checksums
  708.           of articles posted on the Usenet newsgroup
  709.           comp.binaries.ibm.pc.  While reading Usenet news with
  710.           _r_n, for example, you can verify the _C_h_e_c_k_s_u_m: header of
  711.           such an article with the command:
  712.  
  713.             | brik -cv
  714.  
  715.           This feeds the current article to _B_r_i_k as standard
  716.           input and asks it to verbosely verify the checksum.
  717.  
  718.      -    C and Pascal source files that are being distributed
  719.           can be given their own _C_h_e_c_k_s_u_m: headers.  The
  720.  
  721.  
  722.  
  723. Printed 0/0/0              Jul 8, 1989                         11
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730. BRIK(1)             RISC/os Reference Manual              BRIK(1)
  731.  
  732.  
  733.  
  734.           advantage of this over listing CRCs separately is that
  735.           each file contains its checksum no matter where it
  736.           goes.  The recipient can easily verify that each source
  737.           file was received intact.  This is especially valuable
  738.           when source files are being sent by electronic mail
  739.           through an IBM mainframe-based network, such as BITNET,
  740.           that can cause corruption of text files.
  741.  
  742.           Create the _C_h_e_c_k_s_u_m header with a text editor and ini-
  743.           tialize its value with the command:
  744.  
  745.             brik -gW file ...
  746.  
  747.           The recipient can verify the checksum with the command:
  748.  
  749.             brik -cv file ...
  750.  
  751.  
  752.      -    To keep track of any unexpected filesystem corruption
  753.           or unauthorized changes to system files, _B_r_i_k can be
  754.           used to create a list of checksums.  This should be
  755.           done using the -b option (all binary checksums) or the
  756.           -a option (use text or binary as appropriate).  Under
  757.           **IX this can be done with a command like this one:
  758.  
  759.             find /bin /usr/bin /lib /usr/lib /usr/new \
  760.              -type f -print | \
  761.             grep -v '^/usr/bin/beta' | \
  762.             grep -v '^/usr/new/lib/news' | \
  763.             brik -Gbf - > crc.list
  764.  
  765.           This example uses _f_i_n_d to print the pathnames of cer-
  766.           tain files, _g_r_e_p to filter out certain directory sub-
  767.           trees, and then _B_r_i_k to print checksums of all selected
  768.           files.  Periodically a background job can be run to
  769.           compare the file list against current files and report
  770.           any discrepancies:
  771.  
  772.             brik -C crc.lst | mail -s 'brik output' postmaster
  773.  
  774.           Under MS-DOS, create a list of checksums with the help
  775.           of _S_t_u_f_f, a _f_i_n_d-like file finder program that is dis-
  776.           tributed with _z_o_o 2.01:
  777.  
  778.             stuff /bin /msdos /turboc | brik -Gaf - > crc.list
  779.  
  780.           This is a simple mechanism that can be used to detect
  781.           unexpected file changes caused by hardware problems or
  782.           malicious programs such as viruses and worms.  Be
  783.           warned, however, that since _B_r_i_k uses a published CRC
  784.           algorithm, very clever deviant programs are possible
  785.           that could change a file without affecting its CRC.
  786.  
  787.  
  788.  
  789. Printed 0/0/0              Jul 8, 1989                         12
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796. BRIK(1)             RISC/os Reference Manual              BRIK(1)
  797.  
  798.  
  799.  
  800.           To avoid too many false alarms, only files that do not
  801.           change much (such as system binaries) should be
  802.           selected.
  803.  
  804. CHANGES
  805.      Changes from version 1.0 are as follows.
  806.  
  807.      -    The CRC calculation has been recoded in 8086 assembly
  808.           code suitable for Turbo C/MS-DOS.  As a result _B_r_i_k _2._0
  809.           under MS-DOS is much faster than version 1.0.
  810.  
  811.      -    The new -a flag makes _B_r_i_k automatically determine for
  812.           each file whether it is text or binary and calculate
  813.           the CRC accordingly
  814.  
  815.      -    When _B_r_i_k is asked to calculate a text mode CRC but the
  816.           file appears to be binary, it now does not print a
  817.           warning message but instead adds a "*" suffix to the
  818.           calculated CRC to indicate that the CRC may not be
  819.           reliable.
  820.  
  821.      -    The new -H flag makes _B_r_i_k print the formatted _C_h_e_c_k_-
  822.           _s_u_m: header to standard output.
  823.  
  824.      -    Detection of binary files is now more reliable under
  825.           MS-DOS.  If a control Z character occurs near the
  826.           beginning of a binary file, _B_r_i_k will not be fooled by
  827.           the apparent end-of-file but will in most cases reli-
  828.           ably detect that the file is binary.
  829.  
  830.      -    The new -q flag suppresses the introductory comments
  831.           from the output of the -G command.
  832.  
  833. BUGS
  834.      _B_r_i_k is designed to work with computer systems that use the
  835.      7-bit ASCII character set and 8-bit bytes with the eighth
  836.      (parity) bit set to zero.
  837.  
  838.      _B_r_i_k has not been tested with computer systems that use
  839.      ASCII characters with the eighth bit set or those that use
  840.      EBCDIC characters.  Although it will calculate a CRC on such
  841.      machines, the probability of this CRC being the same as the
  842.      one calculated on machines that use 7-bit ASCII is approxi-
  843.      mately 0.00000000023.
  844.  
  845. DIAGNOSTICS
  846.      Error messages are intended to be self-explanatory.
  847.  
  848.      The exit status returned is 1 if _B_r_i_k was invoked with
  849.      incorrect arguments, else it is the number of files found
  850.      with missing or invalid CRCs, but not greater than an
  851.      operating-system-dependent maximum value.
  852.  
  853.  
  854.  
  855. Printed 0/0/0              Jul 8, 1989                         13
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862. BRIK(1)             RISC/os Reference Manual              BRIK(1)
  863.  
  864.  
  865.  
  866. COPYRIGHT
  867.      Both this documentation and _B_r_i_k are Copyright 1989 Rahul
  868.      Dhesi, all rights reserved.  Permission is granted to copy,
  869.      use, and distribute for any commercial or noncommercial pur-
  870.      pose in accordance with the requirements of version 1.0 of
  871.      the _G_N_U _G_e_n_e_r_a_l _P_u_b_l_i_c _l_i_c_e_n_s_e.
  872.  
  873.      Note:  This software has not been endorsed by the Free
  874.      Software Foundation, the creator of the GNU license, and I
  875.      am not affiliated with that organization.
  876.  
  877. AUTHOR
  878.      Rahul Dhesi
  879.      UUCP: {iuvax,pur-ee}!bsu-cs!dhesi
  880.      Internet: dhesi@bsu-cs.bsu.edu
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921. Printed 0/0/0              Jul 8, 1989                         14
  922.  
  923.  
  924.  
  925.