aumann@trlsasy.trl.oz (Greg Aumann) (10/13/89)
Seeing that the great upgrade to version 1.4b is about to start and that ast has posted a crc list of the files that we should have; I thought I would post some code to make good use of the crc list. These programs enable you to compare a directory tree against a crc list and spot any differences. I do my upgrading on an Ultrix system so they are written for unix but should port fairly easily to minix. You will need to edit the file names in the posted list to suit your system. Use listcrcs to create a crc list of your directories and chklists to compare the two lists. If anyone ports it to minix I would like a cdif. Happy upgrading! Greg Aumann ---------------------------- cut here ----------------------------- #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of shell archive." # Contents: README chkcrcl.c chklists crclist listcrcs listcrcs.old # Wrapped by aumann@trlsasy on Fri Oct 13 10:49:38 1989 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'README'\" else echo shar: Extracting \"'README'\" \(1957 characters\) sed "s/^X//" >'README' <<'END_OF_FILE' XThis shar files contains some programs to check a directory tree against Xa crc list of the tree and report the differences. There are three programs X(one with an old version) in this package. X Xlistcrcs - a Bourne shell script that builds a crc list from the files X and directories given as command line arguments. It writes X to standard output and its output is suitable for human X consumption. Use with "listcrcs listofsrcdirs" X Xlistcrcs.old X - an old version of listcrcs that is recursive. X Xchklists - a Bourne shell script that takes as arguments the names X of two crc lists. It massages the lists and then calls X chkcrcl which does the real work. Use with X "chklists stdlist yourlist" X Xchkcrcl.c - a C program that reports the differences between two sorted X crc lists given as command line arguments on standard output. X Compile with "cc -o chkcrcl chkcrcl.c". Use -DMINIX if on minix. X XThe version 1.3 crc list has been recently posted by ast. X Message-ID <3696@ast.cs.vu.nl>. Note there are two X files that should not be on the list X minix/lib/IBM_PC/prtso.c - pascal run time support and X minix/doc/lib.doc - out of date documentation X XSome Comments: X These programs were written and used on a Microvax II running X Ultrix 3.1. They should run without modification on other X versions of UNIX but this has not been tested. In particular X they have not been tested on MINIX. The #ifdef MINIX take care X of some minor incompatiblities that I noticed (but not X tested). listcrcs.old is recursive and will probably run out X of memory on most MINIX systems, but the others may work on X MINIX. X X listcrcs is fairly slow (the old version is even slower) and takes X about 2-3 minutes of real time on my system. The others X are fairly fast. X X I am interested in hearing of improvements. X XThese programs were written by Greg Aumann 'aumann@trlsasy.trl.oz.au' and Xare released into the public domain. END_OF_FILE if test 1957 -ne `wc -c <'README'`; then echo shar: \"'README'\" unpacked with wrong size! fi # end of 'README' fi if test -f 'chkcrcl.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'chkcrcl.c'\" else echo shar: Extracting \"'chkcrcl.c'\" \(3688 characters\) sed "s/^X//" >'chkcrcl.c' <<'END_OF_FILE' X/* X * a program to check two sorted crc lists of files X * and to report the differences between them. X * X * Note filenames in the crc list should not contain whitespace. X * Each line must contain the output from crc at the beginning X * (apart from whitespace) but may have comments after the filename X * X * Written by Greg Aumann X * aumann@trlsasy.trl.oz.au X * X * This program is released into the public domain X */ X X#include <stdio.h> X X#define MAXLINE 100 /* if this is changed must change an X sscanf line in readcrc as well */ X X#ifndef SEEK_SET X#define SEEK_SET 0 X#endif X Xtypedef struct { X unsigned int crc; X long length; X char name[ MAXLINE ]; X} crc_t; X Xmain( argc, argv ) Xint argc; Xchar *argv[]; X{ X FILE *stdfile, *yourfile; X crc_t stdcrc[ 1 ], yourcrc[ 1 ]; X int stdeof, youreof; X void writecrc(); X X if (argc != 3) { X fprintf( stderr, "Usage: %s stdcrclist yourcrclist\n", argv[0] ); X exit( -1 ); X } X if ((stdfile = fopen( argv[1], "r")) == NULL) { X perror( argv[1] ); X exit( -1 ); X } X if ((yourfile = fopen( argv[2], "r")) == NULL) { X perror( argv[2] ); X exit( -1 ); X } X printf( "Missing files:\n" ); X youreof=readcrc( yourfile, yourcrc); X while (readcrc( stdfile, stdcrc ) == 0 ) { X while (youreof != EOF && strcmp( stdcrc -> name, yourcrc -> name ) > 0) X youreof=readcrc( yourfile, yourcrc ); X if (youreof == EOF || strcmp( stdcrc -> name, yourcrc -> name ) != 0) { X putc( '\t', stdout ); X writecrc( stdout, stdcrc ); X putc( '\n', stdout ); X } X } X printf( "\nExtra files:\n" ); X fseek( stdfile, 0L, SEEK_SET ); X fseek( yourfile, 0L, SEEK_SET ); X stdeof=readcrc( stdfile, stdcrc); X while (readcrc( yourfile, yourcrc ) == 0 ) { X while (stdeof != EOF && strcmp( yourcrc -> name, stdcrc -> name ) > 0) X stdeof=readcrc( stdfile, stdcrc ); X if (stdeof == EOF || strcmp( yourcrc -> name, stdcrc -> name ) != 0) { X putc( '\t', stdout ); X writecrc( stdout, yourcrc ); X putc( '\n', stdout ); X } X } X printf( "\nDifferent files:\n" ); X fseek( stdfile, 0L, SEEK_SET ); X fseek( yourfile, 0L, SEEK_SET ); X youreof=readcrc( yourfile, yourcrc); X while (readcrc( stdfile, stdcrc ) == 0 ) { X while (youreof != EOF && strcmp( stdcrc -> name, yourcrc -> name ) > 0) X youreof=readcrc( yourfile, yourcrc ); X if (youreof == EOF) X break; X if (strcmp( stdcrc -> name, yourcrc -> name ) == 0) { X if (crccmp( stdcrc, yourcrc) != 0) { X putc( '\t', stdout ); X writecrc( stdout, yourcrc ); X printf( "\t should be " ); X#ifdef MINIX X printf( "%05u %6D", stdcrc -> crc, stdcrc -> length ); X#else X printf( "%05u %6ld", stdcrc -> crc, stdcrc -> length ); X#endif /* !defined MINIX */ X putc( '\n', stdout ); X } X } X } X} X Xint readcrc( file, crc ) XFILE *file; Xcrc_t *crc; X{ X int fret; X char line[ MAXLINE ]; X X if (fgets( line, MAXLINE, file ) == NULL) X return( EOF ); X if (strlen( line ) == MAXLINE-1) { X fprintf( stderr, "Error line beginning %s, is too long.\n", line ); X exit( -1 ); X } X fret = sscanf( line, " %u %ld %100s", &crc->crc, &crc->length, crc->name ); X if (fret == 3) X return( 0 ); X fprintf( stderr, "Exiting from readcrc fret = %d.\n", fret ); X putc( '\t', stderr ); X writecrc( stderr, crc ); X putc( '\n', stderr ); X exit( -1 ); X} X Xvoid writecrc( file, crc ) XFILE *file; Xcrc_t *crc; X{ X#ifdef MINIX X fprintf( file, "%05u %6D", crc -> crc, crc -> length ); X#else X fprintf( file, "%05u %6ld", crc -> crc, crc -> length ); X#endif /* !defined MINIX */ X if (crc -> name) X fprintf( file, " %s", crc -> name); X} X Xint crccmp( c1, c2 ) Xcrc_t *c1, *c2; X/* returns 0 if the two structures are equal */ X{ X int neq = 0; X X neq |= c1->crc != c2->crc; X neq |= c1->length != c2->length; X neq |= strcmp( c1->name, c2->name) != 0; X return( neq ); X} END_OF_FILE if test 3688 -ne `wc -c <'chkcrcl.c'`; then echo shar: \"'chkcrcl.c'\" unpacked with wrong size! fi # end of 'chkcrcl.c' fi if test -f 'chklists' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'chklists'\" else echo shar: Extracting \"'chklists'\" \(344 characters\) sed "s/^X//" >'chklists' <<'END_OF_FILE' X#! /bin/sh X# a shell script to prepare two crclists for checking with chkcrcl X Xstdlist=stdlist$$ Xmylist=mylist$$ Xif test $# -ne 2 ; then X echo Usage: $0 stdcrclist yourcrclist X exit Xfi Xgrep '^[0-9][0-9][0-9]' "$1" | sort +2 > "$stdlist" Xgrep '^[0-9][0-9][0-9]' "$2" | sort +2 > "$mylist" Xchkcrcl "$stdlist" "$mylist" Xrm -f "$stdlist" "$mylist" END_OF_FILE if test 344 -ne `wc -c <'chklists'`; then echo shar: \"'chklists'\" unpacked with wrong size! fi chmod +x 'chklists' # end of 'chklists' fi if test -f 'crclist' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'crclist'\" else echo shar: Extracting \"'crclist'\" \(134 characters\) sed "s/^X//" >'crclist' <<'END_OF_FILE' X42760 1957 README X39040 3688 chkcrcl.c X64277 344 chklists X00000 0 crclist X00775 223 listcrcs X09374 427 listcrcs.old END_OF_FILE if test 134 -ne `wc -c <'crclist'`; then echo shar: \"'crclist'\" unpacked with wrong size! fi # end of 'crclist' fi if test -f 'listcrcs' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'listcrcs'\" else echo shar: Extracting \"'listcrcs'\" \(223 characters\) sed "s/^X//" >'listcrcs' <<'END_OF_FILE' X#! /bin/sh X# a shell script to list the crcs of the files in a directory X# and all its subdirectories X Xfor i in $*; do X find $i -type f -exec crc {} \; X# find $i -type f -print | xargs crc # faster if you have xargs Xdone END_OF_FILE if test 223 -ne `wc -c <'listcrcs'`; then echo shar: \"'listcrcs'\" unpacked with wrong size! fi chmod +x 'listcrcs' # end of 'listcrcs' fi if test -f 'listcrcs.old' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'listcrcs.old'\" else echo shar: Extracting \"'listcrcs.old'\" \(427 characters\) sed "s/^X//" >'listcrcs.old' <<'END_OF_FILE' X#! /bin/sh X# a shell script to list the crcs of the files in a directory X# and all its subdirectories X Xfiles='' Xdirs='' Xargs=$* Xfor i in $args; do X if test -d $i; then X dirs="$dirs $i" X else X files="$files $i" X fi; Xdone X X# do the files Xif test "$files" != ""; then X crc $files Xfi; X X# do the directories Xfor i in $dirs; do X echo X echo "================= Directory $i =======================" X files="$i"/* X "$0" $files Xdone END_OF_FILE if test 427 -ne `wc -c <'listcrcs.old'`; then echo shar: \"'listcrcs.old'\" unpacked with wrong size! fi chmod +x 'listcrcs.old' # end of 'listcrcs.old' fi echo shar: End of shell archive. exit 0 Switched Networks Research ACSnet: aumann@trlsasy.trl.oz Telecom Research Laboratories Internet: aumann@trlsasy.trl.oz.au Melbourne, AUSTRALIA Voice: +61 3 541 6221
meulenbr@cstw01.prl.philips.nl (Frans Meulenbroeks) (10/16/89)
What's wrong with: crc * | diff - distributed_crc_list_file (Ok. perhaps you have to say crc *.[ch] or something like that) Works for me all the time. Frans Meulenbroeks (meulenbr@cst.prl.philips.nl) Centre for Software Technology ( or try: ...!mcvax!phigate!prle!cst!meulenbr)