home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD2.bin
/
bbs
/
gnu
/
brik-2.0-src.lha
/
brik-2.0
/
brik.doc
< prev
next >
Wrap
Text File
|
1993-08-30
|
29KB
|
705 lines
BRIK(1) USER MANUAL BRIK(1)
NAME
brik - calculate 32-bit CRC
SYNOPSIS
brik -h
brik -gcGCbafvsqWHT file ...
DESCRIPTION
Brik generates and verifies 32-bit CRC values (checksums).
It is designed to generate CRCs for text files that are the
same on all computer systems that use the ASCII character
set, provided each text file is in the usual text file
format for each system. Brik will also optionally use binary
CRCs calculated using every byte in a file. Such binary
CRCs are portable across systems for binary files that are
moved from system to system without any newline conversion.
Brik can be asked to decide by examining each file whether
to calculate a text mode or binary mode CRC for it.
Changes from version 1.0 are summarized at the end of this
document.
The general usage format is:
brik -gcGCbafvsqWHT [ file ] ...
The brackets mean that file, which is the name of a file, is
optional. The three dots indicate that more than one
filename may be typed (separated by blanks). Exactly one of
the options -c, -C, -g, -G, or -h, is required. The -h
option gives a help screen.
In addition to -h, the Brik options available (as they
appear on the help screen) are:
-g look for Checksum: header, generate CRC for rest of
file
-c get CRC from header, verify CRC of rest of file
-G generate CRC for entire file (add -b for binary files)
-C verify all file CRCs from output of -G (-f is not
needed)
-b use binary mode -- read file byte by byte, not line by
line
-a automatically decide whether each file is text or
binary
-f read filenames (wildcards ok) from specified files
-v be verbose, report all results (else only errors are
reported)
-s be silent, say nothing, just return status code
-q be quiet, don't print header for -G
-W after generating CRC with -g, write it to original
header
-H after generating CRC with -g, print header to stdout
-T include trailing empty lines, normally ignored (text
mode only)
VERIFYING CRC HEADERS
The primary intended use of Brik is to verify Checksum:
headers in Usenet postings and in C and Pascal source files.
A Checksum: header looks like this:
Checksum: 9485762645b (verify with "brik")
The word Checksum: must occur at the beginning of a line.
It is followed by a colon, an optional blank, a ten-digit
decimal 32-bit CRC, and any arbitrary optional string such
as the comment shown above. The CRC value may be followed
by a one-character suffix identifying the type of the CRC.
These suffixes are described later.
When Brik is invoked with the syntax
brik -c file ...
it will search for the Checksum: header in each specified
file, read the CRC value from that header, calculate the
CRC-32 for all lines in the file (except trailing empty
lines) that occur *after* the header line, and report an
error if the two values do not match.
CALCULATING CRC HEADERS
The command
brik -g file ...
tells Brik to look for the Checksum: header in each
specified file, calculate the CRC of the lines in the file
following the header, and print the CRC and filename without
changing the file in any way. You can also ask Brik to
update the Checksum: header with the following command:
brik -gW file ...
This causes Brik to update the Checksum: header in the file
with the newly-calculated CRC. If there is not enough space
for the CRC in the existing header, Brik reports an error
and does not change the existing header. To initially add a
Checksum: header to a file, insert a line of the following
form into the file with a text editor:
Checksum: XXXXXXXXXX -- this is an optional comment
The word Checksum must be at the beginning of a line. The
ten `X' characters shown can be any ten characters. They
will be later replaced by the calculated CRC value. They do
not need to be `X'. The comment following them is optional
and can be any arbitrary string of characters after the CRC
field, separated from it by blanks. As an example, in a C
source file called main.c, you might have:
/*
Checksum: XXXXXXXXXX (verify or update with brik)
*/
Once a header like this exists in the file, invoke Brik as
follows:
brik -gW main.c
This will cause the ten `X' characters to be replaced with
the calculated checksum, giving something like this:
/*
Checksum: 1922837484 (verify or update with brik)
*/
Later you can use the command
brik -c main.c
to verify that the contents of the file following the header
have the same CRC as the stored value.
If Brik is invoked with the -c or -g options and it cannot
find a Checksum: header in a file, it prints a row of
question marks. If it is invoked with the -gW option and it
does not find enough character positions after the Checksum:
string to hold the CRC, it does not fill in the CRC and
prints an error message.
Brik can be asked to generate a complete Checksum: header
but print it to standard output instead of writing it to the
file. Do this by adding the -H option. If both -W and -H
are given, the Checksum: header will be written both to the
file and to standard output.
WHOLE-FILE CRCS
A "whole-file" CRC calculation is done for the entire
contents of a file, without looking for a Checksum: header.
The command
brik -G file ...
asks Brik to do this calculation for all specified files.
The output from this command is a list of files and their
whole-file CRCs. It is sent to the standard output stream,
which in most cases is your screen. The output should be
saved in a file by redirecting it. For example, the command
brik -G *.h *.c > crc.lst
on an MS-DOS system might yield the following in the output
file crc.lst:
# CRC-32 filename
# ------ --------
2566277976 getopt.c
100594287 brik.c
1151475469 vms.c
3929503738 turboc.c
2424271922 addbfcrc.c
1943472856 assert.h
2601923477 brik.h
The output of the -G option is in free format. The output
file may be edited by hand. Empty lines and lines beginning
with '#' will be ignored by Brik when it is later asked to
read this file.
This list of filenames and whole-file CRCs may be verified
by a command like this:
brik -C crc.lst
This makes Brik read the file crc.lst, get the CRCs and
filenames from it, do the CRC calculation again for each
file, and report an error if it does not match the CRC
recorded inside crc.lst.
**IX and MS-DOS users (and others who can pipe the output of
one command into another) could use a command like the
following to see if Brik's -G and -C options are working: