home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD1.bin
/
gnu
/
man
/
cat1
/
brik.0
< prev
next >
Wrap
Text File
|
1993-12-08
|
30KB
|
925 lines
BRIK(1) RISC/os Reference Manual BRIK(1)
NAME
brik - calculate 32-bit CRC
SYNOPSIS
brik -h
brik -gcGCbafvsqWHT _f_i_l_e ...
DESCRIPTION
_B_r_i_k 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 for-
mat for each system. _B_r_i_k 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.
_B_r_i_k 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 [ _f_i_l_e ] ...
The brackets mean that _f_i_l_e, 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 _B_r_i_k options available (as they
appear on the help screen) are:
-g look for _C_h_e_c_k_s_u_m: 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
Printed 0/0/0 Jul 8, 1989 1
BRIK(1) RISC/os Reference Manual BRIK(1)
-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 _B_r_i_k is to verify _C_h_e_c_k_s_u_m:
headers in Usenet postings and in C and Pascal source files.
A _C_h_e_c_k_s_u_m: header looks like this:
Checksum: 9485762645b (verify with "brik")
The word _C_h_e_c_k_s_u_m: 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 _B_r_i_k is invoked with the syntax
brik -c _f_i_l_e ...
it will search for the _C_h_e_c_k_s_u_m: header in each specified
_f_i_l_e, 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 _f_i_l_e ...
tells _B_r_i_k to look for the _C_h_e_c_k_s_u_m: header in each speci-
fied _f_i_l_e, calculate the CRC of the lines in the file fol-
lowing the header, and print the CRC and filename without
changing the file in any way. You can also ask _B_r_i_k to
update the _C_h_e_c_k_s_u_m: header with the following command:
Printed 0/0/0 Jul 8, 1989 2
BRIK(1) RISC/os Reference Manual BRIK(1)
brik -gW _f_i_l_e ...
This causes _B_r_i_k to update the _C_h_e_c_k_s_u_m: header in the file
with the newly-calculated CRC. If there is not enough space
for the CRC in the existing header, _B_r_i_k reports an error
and does not change the existing header. To initially add a
_C_h_e_c_k_s_u_m: 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 _C_h_e_c_k_s_u_m 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 _m_a_i_n._c, you might have:
/*
Checksum: XXXXXXXXXX (verify or update with brik)
*/
Once a header like this exists in the file, invoke _B_r_i_k 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 _B_r_i_k is invoked with the -c or -g options and it cannot
find a _C_h_e_c_k_s_u_m: header in a file, it prints a row of ques-
tion marks. If it is invoked with the -gW option and it
does not find enough character positions after the _C_h_e_c_k_s_u_m:
string to hold the CRC, it does not fill in the CRC and
prints an error message.
_B_r_i_k can be asked to generate a complete _C_h_e_c_k_s_u_m: 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
Printed 0/0/0 Jul 8, 1989 3
BRIK(1) RISC/os Reference Manual BRIK(1)
are given, the _C_h_e_c_k_s_u_m: 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 con-
tents of a file, without looking for a _C_h_e_c_k_s_u_m: header.
The command
brik -G _f_i_l_e ...
asks _B_r_i_k 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 _c_r_c._l_s_t:
# 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 _B_r_i_k 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 _B_r_i_k read the file _c_r_c._l_s_t, 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 _c_r_c._l_s_t.
**IX and