#! /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 'crc.c' <<'END_OF_FILE' X/*% cc -O -K -dos % -o crc.exe X*/ X X/* X * Crc - 32 BIT ANSI X3.66 CRC checksum files X */ X#include X#define OK 0 X#define ERROR (-1) X#define LINT_ARGS X X/**********************************************************************\ X|* *| X|* Demonstration program to compute the 32-bit CRC used as the frame *| X|* check sequence in ADCCP (ANSI X3.66, also known as FIPS PUB 71 *| X|* and FED-STD-1003, the U.S. versions of CCITT's X.25 link-level *| X|* protocol). The 32-bit FCS was added via the Federal Register, *| X|* 1 June 1982, p.23798. I presume but don't know for certain that *| X|* this polynomial is or will be included in CCITT V.41, which *| X|* defines the 16-bit CRC (often called CRC-CCITT) polynomial. FIPS *| X|* PUB 78 says that the 32-bit FCS reduces otherwise undetected *| X|* errors by a factor of 10^-5 over 16-bit FCS. *| X|* *| X\**********************************************************************/ X X/* Need an unsigned type capable of holding 32 bits; */ Xtypedef unsigned long int UNS_32_BITS; X X/* X * Copyright (C) 1986 Gary S. Brown. You may use this program, or X * code or tables extracted from it, as desired without restriction. X */ X/* First, the polynomial itself and its table of feedback terms. The */ X/* polynomial is */ X/* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 */ X/* Note that we take it "backwards" and put the highest-order term in */ X/* the lowest-order bit. The X^32 term is "implied"; the LSB is the */ X/* X^31 term, etc. The X^0 term (usually shown as "+1") results in */ X/* the MSB being 1. */ X X/* Note that the usual hardware shift register implementation, which */ X/* is what we're using (we're merely optimizing it by doing eight-bit */ X/* chunks at a time) shifts bits into the lowest-order term. In our */ X/* implementation, that means shifting towards the right. Why do we */ X/* do it this way? Because the calculated CRC must be transmitted in */ X/* order from highest-order term to lowest-order term. UARTs transmit */ X/* characters in order from LSB to MSB. By storing the CRC this way, */ X/* we hand it to the UART in the order low-byte to high-byte; the UART */ X/* sends each low-bit to hight-bit; and the result is transmission bit */ X/* by bit from highest- to lowest-order term without requiring any bit */ X/* shuffling on our part. Reception works similarly. */ X X/* The feedback terms table consists of 256, 32-bit entries. Notes: */ X/* */ X/* 1. The table can be generated at runtime if desired; code to do so */ X/* is shown later. It might not be obvious, but the feedback */ X/* terms simply represent the results of eight shift/xor opera- */ X/* tions for all combinations of data and CRC register values. */ X/* */ X/* 2. The CRC accumulation logic is the same for all CRC polynomials, */ X/* be they sixteen or thirty-two bits wide. You simply choose the */ X/* appropriate table. Alternatively, because the table can be */ X/* generated at runtime, you can start by generating the table for */ X/* the polynomial in question and use exactly the same "updcrc", */ X/* if your application needn't simultaneously handle two CRC */ X/* polynomials. (Note, however, that XMODEM is strange.) */ X/* */ X/* 3. For 16-bit CRCs, the table entries need be only 16 bits wide; */ X/* of course, 32-bit entries work OK if the high 16 bits are zero. */ X/* */ X/* 4. The values must be right-shifted by eight bits by the "updcrc" */ X/* logic; the shift must be unsigned (bring in zeroes). On some */ X/* hardware you could probably optimize the shift in assembler by */ X/* using byte-swap instructions. */ X Xstatic UNS_32_BITS crc_32_tab[] = { /* CRC polynomial 0xedb88320 */ X0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, X0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, X0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, X0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, X0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, X0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, X0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, X0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, X0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, X0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, X0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, X0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, X0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, X0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, X0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, X0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, X0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, X0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, X0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, X0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, X0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, X0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, X0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, X0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, X0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, X0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, X0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, X0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, X0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, X0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, X0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, X0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d X}; X X#define UPDC32(octet, crc) (crc_32_tab[((crc) ^ (octet)) & 0xff] ^ ((crc) >> 8)) X Xmain(argc, argp) Xchar **argp; X{ X register errors = 0; X X while( --argc > 0) X errors |= crc32file( *++argp); X exit(errors != 0); X} X Xcrc32file(name) Xchar *name; X{ X register FILE *fin; X register unsigned long oldcrc32; X register unsigned long crc32; X register unsigned long oldcrc; X register c; X register long charcnt; X X oldcrc32 = 0xFFFFFFFF; charcnt = 0; X#ifdef M_I86SM X if ((fin=fopen(name, "rb"))==NULL) X#else X if ((fin=fopen(name, "r"))==NULL) X#endif X { X perror(name); X return ERROR; X } X while ((c=getc(fin))!=EOF) { X ++charcnt; X oldcrc32 = UPDC32(c, oldcrc32); X } X X if (ferror(fin)) { X perror(name); X charcnt = -1; X } X fclose(fin); X X crc32 = oldcrc32; oldcrc = oldcrc32 = ~oldcrc32; X X/* X crc32 = UPDC32((oldcrc32 & 0377), crc32); oldcrc32 >>=8; X crc32 = UPDC32((oldcrc32 & 0377), crc32); oldcrc32 >>=8; X crc32 = UPDC32((oldcrc32 & 0377), crc32); oldcrc32 >>=8; X crc32 = UPDC32((oldcrc32 & 0377), crc32); oldcrc32 >>=8; X printf("%08lX ", crc32); X*/ X X printf("%08lX %7ld %s\n", oldcrc, charcnt, name); X X return OK; X} X END_OF_FILE if test 8566 -ne `wc -c <'crc.c'`; then echo shar: \"'crc.c'\" unpacked with wrong size! fi # end of 'crc.c' fi if test -f 'crctab.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'crctab.c'\" else echo shar: Extracting \"'crctab.c'\" \(8737 characters\) sed "s/^X//" >'crctab.c' <<'END_OF_FILE' X/* X * Crc calculation stuff X */ X X/* crctab calculated by Mark G. Mendel, Network Systems Corporation */ Xstatic unsigned short crctab[256] = { X 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, X 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, X 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, X 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, X 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, X 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, X 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, X 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, X 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, X 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, X 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, X 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, X 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, X 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, X 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, X 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, X 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, X 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, X 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, X 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, X 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, X 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, X 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, X 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, X 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, X 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, X 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, X 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, X 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, X 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, X 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, X 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 X}; X X/* X * updcrc macro derived from article Copyright (C) 1986 Stephen Satchell. X * NOTE: First srgument must be in range 0 to 255. X * Second argument is referenced twice. X * X * Programmers may incorporate any or all code into their programs, X * giving proper credit within the source. Publication of the X * source routines is permitted so long as proper credit is given X * to Stephen Satchell, Satchell Evaluations and Chuck Forsberg, X * Omen Technology. X */ X X#define updcrc(cp, crc) ( crctab[((crc >> 8) & 255)] ^ (crc << 8) ^ cp) X X/* X * Copyright (C) 1986 Gary S. Brown. You may use this program, or X * code or tables extracted from it, as desired without restriction. X */ X X/* First, the polynomial itself and its table of feedback terms. The */ X/* polynomial is */ X/* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 */ X/* Note that we take it "backwards" and put the highest-order term in */ X/* the lowest-order bit. The X^32 term is "implied"; the LSB is the */ X/* X^31 term, etc. The X^0 term (usually shown as "+1") results in */ X/* the MSB being 1. */ X X/* Note that the usual hardware shift register implementation, which */ X/* is what we're using (we're merely optimizing it by doing eight-bit */ X/* chunks at a time) shifts bits into the lowest-order term. In our */ X/* implementation, that means shifting towards the right. Why do we */ X/* do it this way? Because the calculated CRC must be transmitted in */ X/* order from highest-order term to lowest-order term. UARTs transmit */ X/* characters in order from LSB to MSB. By storing the CRC this way, */ X/* we hand it to the UART in the order low-byte to high-byte; the UART */ X/* sends each low-bit to hight-bit; and the result is transmission bit */ X/* by bit from highest- to lowest-order term without requiring any bit */ X/* shuffling on our part. Reception works similarly. */ X X/* The feedback terms table consists of 256, 32-bit entries. Notes: */ X/* */ X/* The table can be generated at runtime if desired; code to do so */ X/* is shown later. It might not be obvious, but the feedback */ X/* terms simply represent the results of eight shift/xor opera- */ X/* tions for all combinations of data and CRC register values. */ X/* */ X/* The values must be right-shifted by eight bits by the "updcrc" */ X/* logic; the shift must be unsigned (bring in zeroes). On some */ X/* hardware you could probably optimize the shift in assembler by */ X/* using byte-swap instructions. */ X Xstatic long cr3tab[] = { /* CRC polynomial 0xedb88320 */ X0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, X0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, X0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, X0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, X0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, X0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, X0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, X0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, X0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, X0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, X0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, X0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, X0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, X0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, X0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, X0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, X0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, X0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, X0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, X0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, X0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, X0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, X0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, X0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, X0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, X0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, X0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, X0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, X0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, X0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, X0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, X0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d X}; X X#ifdef NFGM Xlong XUPDC32(b, c) Xlong c; X{ X return (cr3tab[((int)c ^ b) & 0xff] ^ ((c >> 8) & 0x00FFFFFF)); X} X X#else X X#define UPDC32(b, c) (cr3tab[((int)c ^ b) & 0xff] ^ ((c >> 8) & 0x00FFFFFF)) X#endif X X/* End of crctab.c */ END_OF_FILE if test 8737 -ne `wc -c <'crctab.c'`; then echo shar: \"'crctab.c'\" unpacked with wrong size! fi # end of 'crctab.c' fi if test -f 'rz.1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'rz.1'\" else echo shar: Extracting \"'rz.1'\" \(9419 characters\) sed "s/^X//" >'rz.1' <<'END_OF_FILE' X'\" Revision Level X'\" Last Delta 03-25-89 X.TH RZ 1 OMEN X.SH NAME Xrx, rb, rz \- XMODEM, YMODEM, ZMODEM (Batch) file receive X.SH SYNOPSIS X.B rz X.RB [\- "\ +abepqtuvy" ] X.br X.B rb X.RB [\- "\ +abqtuvy" ] X.br X.B rx X.RB [\- "\ abceqtuv" ] X.I file X.br X.B gz X.I "file ..." X.br X.RB [ \- ][ v ] rzCOMMAND X.SH DESCRIPTION XThis program uses error correcting protocols to receive Xfiles over a dial-in serial port from a variety of programs running under XPC-DOS, CP/M, X.SM Unix, Xand other operating systems. XIt is invoked from a shell prompt Xmanually, or automatically as a result of an X"sz file ..." command given to the calling program. X X X.B X.I Rz Xis not intended be called from X.I cu(1), Xor other communications programs. XUnix flavors of Omen Technology's XProfessional-YAM communications software Xare available for dial-out applications. X.R X X X.B Rz X(Receive ZMODEM) Xreceives files with the ZMODEM batch protocol. XPathnames are supplied by the sending program, Xand directories are made if necessary (and possible). XNormally, the X"rz" command is automatically issued by the calling ZMODEM program, Xbut some defective ZMODEM implementations may require starting X.I rz Xthe old fashioned way. X.I Rz Xdoes not support ZMODEM Crash Recovery, Xcompression, and other ZMODEM features. XUnix flavors of Professional-YAM may be linked to "rz" Xand used in place of this program Xto support these ZMODEM features. X X X.B Rb Xreceives file(s) with YMODEM, Xaccepting either standard 128 byte sectors or X1024 byte sectors X(YAM sb X.B -k Xoption). XThe user should determine when Xthe 1024 byte block length Xactually improves throughput without causing lost data Xor even system crashes. X XIf True YMODEM (Omen Technology trademark) file information (file length, etc.) Xis received, Xthe file length controls the number of bytes written to Xthe output dataset, Xand the modify time and file mode X(iff non zero) Xare set accordingly. X XIf no True YMODEM file information is received, Xslashes in the pathname are changed to underscore, Xand any trailing period in the pathname is eliminated. XThis conversion is useful for files received from CP/M systems. XWith YMODEM, each file name is converted to lower case Xunless it contains one or more lower case letters. X X X.B Rx Xreceives a single X.I file Xwith XMODEM or XMODEM-1k protocol. XThe user should determine when Xthe 1024 byte block length Xactually improves throughput without causing problems. XThe user must supply the file name to both sending and receiving programs. XUp to 1023 garbage characters may be added to the received file. X X.B Gz Xis a shell script which calls X.I sz Xto command Pro-YAM or ZCOMM to transmit the specified files. XPathnames used with X.I gz Xmust be escaped if they have special significance to the Unix shell. X.br XEXAMPLE: Xgz "-a C:*.c D:*.h" X X X.B Rz Xmay be invoked as X.B rzCOMMAND X(with an optional leading \- as generated by login(1)). XFor each received file, X.I rz Xwill pipe the file to ``COMMAND filename'' Xwhere filename is the name of the transmitted file Xwith the file contents as standard input. X XEach file transfer is acknowledged when COMMAND exits with 0 status. XA non zero exit status terminates transfers. X XA typical use for this form is X.I rzrmail Xwhich calls rmail(1) Xto post mail to the user specified by the transmitted file name. XFor example, sending the file "caf" from a PC-DOS system to X.I rzrmail Xon a X.SM Unix Xsystem Xwould result in the contents of the DOS file "caf" being mailed to user "caf". X XOn some X.SM Unix Xsystems, the login directory must contain a link to XCOMMAND as login sets SHELL=rsh which disallows absolute Xpathnames. XIf invoked with a leading ``v'', X.I rz Xwill report progress to /tmp/rzlog. XThe following entry works for X.SM Unix XSYS III/V: X.ce Xrzrmail::5:1::/bin:/usr/local/rzrmail XIf the SHELL environment variable includes X.I "rsh" Xor X.I "rksh" X(restricted shell), X.I rz Xwill not accept absolute pathnames Xor references to a parent directory, Xwill not modify an existing file, and Xremoves any files received in error. X XIf X.B rz Xis invoked with stdout and stderr to different datasets, XVerbose is set to 2, causing frame by frame progress reports Xto stderr. XThis may be disabled with the X.B q Xoption. X X.PP XThe meanings of the available options are: X.PP X.PD 0 X.TP X.B a XConvert files to X.SM Unix Xconventions by stripping carriage returns and all characters Xbeginning with the first Control Z (CP/M end of file). X.TP X.B b XBinary X(tell it like it is) Xfile transfer override. X.TP X.B c XRequest 16 bit CRC. XXMODEM file transfers default to 8 bit checksum. XYMODEM and ZMODEM normally use 16 bit CRC. X.TP X.B D XOutput file data to /dev/null; for testing. X(Unix only) X.TP X.B e XForce sender to escape all control characters; Xnormally XON, XOFF, DLE, CR-@-CR, and Ctrl-X are escaped. X.TP X.B p X(ZMODEM) Protect: skip file if destination file exists. X.TP X.B q XQuiet suppresses verbosity. X.TP X.B "t tim" XChange timeout to X.I tim Xtenths of seconds. X.TP X.B v XVerbose Xcauses a list of file Xnames to be appended to X/tmp/rzlog . XMore v's generate more output. X.TP X.B y XYes, clobber any existing files with the same name. X.PD X.ne 6 X.SH EXAMPLES X.RE X(Pro-YAM command) X.RS X.I X.br XPro-YAM Command: X.I "sz *.h *.c" X.br X(This automatically invokes X.I rz Xon the connected system.) X.RE X.SH SEE ALSO XZMODEM.DOC, XYMODEM.DOC, XProfessional-YAM, Xcrc(omen), Xsz(omen), Xusq(omen), Xundos(omen) X XCompile time options required Xfor various operating systems are described in the Xsource file. X.SH NOTES XZMODEM's support of XOFF/XON flow control allows proper Xoperation in many environments that do not support XMODEM uploads. XUnfortunately, not all timesharing systems support input flow control. XThe TTY input buffering on some systems may not adequately buffer long blocks Xor streaming input at high speed. XYou should suspect this problem when you Xcan't send data to the Unix system at high speeds using ZMODEM, Xbut YMODEM-1k or XMODEM-1k, Xwhen YMODEM with 128 byte blocks works properly. X XThe DSZ or Pro-YAM X.B "zmodem l" Xnumeric parameter may be set to a value between 64 and 1024 to limit the Xburst length ("zmodem pl128"). XAlthough this compromises ZMODEM's throughput, XZMODEM's superior reliability remains intact. X XIf a program that does not properly implement Xthe specified file transfer protocol Xcauses X.I rz Xto "hang" the port after a failed transfer, Xeither wait for X.I rz Xto time out or keyboard a dozen Ctrl-X characters. XEvery reported instance of this problem has been corrected by using XZCOMM, Pro-YAM, DSZ, or other program with a correct implementation Xof the specified protocol. X XMany programs claiming to support YMODEM only support XMODEM with 1k blocks, Xand they often don't get that quite right. X XIn the case of a few poorly designed microcomputers, Xsending serial data to a tty port Xat sustained high speeds Xhas been known to cause lockups, system halts, kernel panics, Xand occasional antisocial behaviour. XThis problem is not unique to X.I rz; XCRT terminals with block mode transmission and line noise Xhave the same effect. When experimenting with high speed Xinput to a system, consider rebooting the system if the file Xtransfers are not successful, especially if the personality of Xthe system appears altered. X XThe Unix "ulimit" parameter must be set high enough Xto permit large file transfers to Unix. X X32 bit CRC code courtesy Gary S. Brown. XDirectory creation code from John Gilmore's PD TAR program. X.SH BUGS X.I Rz Xis not intended be called from X.I cu(1), Xor other communications programs. XUnix flavors of Omen Technology's XProfessional-YAM communications software Xare available for dial-out applications. X X.I Rz Xdoes not support ZMODEM Crash Recovery, Xcompression, and other ZMODEM features. XUnix flavors of Professional-YAM may be linked to "rz" Xto support these features. X XPathnames are restricted to 127 characters. XIn XMODEM single file mode, the pathname given on the command line Xis still processed as described above. XThe ASCII option\'s CR/LF to NL translation merely deletes CR\'s; Xundos(omen) performs a more intelligent translation. X.SH "VMS VERSION" XThe VMS version does not set the file time. X XVMS C Standard I/O and RMS may interact to modify Xfile contents unexpectedly. X XThe VMS version does not support invocation as X.B rzCOMMAND . XThe current VMS version does not support XMODEM, XMODEM-1k, or YMODEM. X XAccording to the VMS documentation, Xthe buffered input routine used on the VMS version of X.I rz Xintroduces a delay Xof up to one second for each protocol transaction. XThis delay may be significant for very short files. XRemoving the "#define BUFREAD" line from rz.c will Xeliminate this delay at the expense of increased XCPU utilization. X XFor high speed operation, Xtry increasing the SYSGEN parameter TTY_TYPAHDSZ to 256. X XThe VMS version causes DCL to generate a random off the wall Xerror message under some error conditions; this is a result of Xthe incompatibility of the VMS "exit" function with the XUnix/MSDOS standard. X.SH "ZMODEM CAPABILITIES" X.I Rz Xsupports incoming ZMODEM binary (-b), ASCII (-a), Xprotect (-p), Xclobber (-y), Xand append (-+) Xrequests. XOther options sent by the sender are ignored. XThe default is protect (-p) and binary (-b). X XThe Unix versions support ZMODEM command execution. X.SH FILES Xrz.c, crctab.c, rbsb.c, zm.c, zmodem.h Unix source files. X Xrz.c, crctab.c, vrzsz.c, zm.c, zmodem.h, vmodem.h, vvmodem.c, XVMS source files. X X/tmp/rzlog stores debugging output generated with -vv option X(rzlog on VMS). END_OF_FILE if test 9419 -ne `wc -c <'rz.1'`; then echo shar: \"'rz.1'\" unpacked with wrong size! fi # end of 'rz.1' fi if test -f 'sz.1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'sz.1'\" else echo shar: Extracting \"'sz.1'\" \(12484 characters\) sed "s/^X//" >'sz.1' <<'END_OF_FILE' X'\" Revision Level X'\" Last Delta 04-22-89 X.TH SZ 1 OMEN X.SH NAME Xsx, sb, sz \- XMODEM, YMODEM, ZMODEM file send X.SH SYNOPSIS Xsz X.RB [\- +abdefkLlNnopqTtuvyYZ ] X.I file ... X.br Xsb X.RB [\- adfkqtuv ] X.I file ... X.br Xsx X.RB [\- akqtuv ] X.I file X.br Xsz X.RB [\- oqtv ] X.B "-c COMMAND" X.br Xsz X.RB [\- oqtv ] X.B "-i COMMAND" X.br Xsz -TT X.SH DESCRIPTION X.B Sz Xuses the ZMODEM, YMODEM or XMODEM error correcting protocol to send Xone or more files over a dial-in serial port to a variety of programs running under XPC-DOS, CP/M, Unix, VMS, and other operating systems. X X X.B X.I Sz Xis not intended be called from X.I cu(1) Xor other communications programs. XUnix flavors of Omen Technology's XProfessional-YAM communications software Xare available for dial-out applications. X.R X X X.B Sz Xsends one or more files with ZMODEM protocol. X XZMODEM Xgreatly simplifies file transfers compared to XMODEM. XIn addition to a friendly user interface, ZMODEM Xprovides Personal Computer and other users Xan efficient, accurate, and robust file transfer method. X XZMODEM provides complete X.B "END-TO-END" Xdata integrity between application programs. XZMODEM's 32 bit CRC catches errors Xthat sneak into even the most advanced networks. X XAdvanced file management features include XAutoDownload (Automatic file Download initiated without user intervention), XDisplay of individual and total file lengths and transmission time estimates, XCrash Recovery, Xselective file transfers, Xand preservation of Xexact file date and length. X XThe X.B -y Xoption instructs the receiver to open the file for writing unconditionally. XThe X.B -a Xoption Xcauses the receiver to convert Unix newlines to PC-DOS carriage returns Xand linefeeds. X X X.B Sb Xbatch sends one or more files with YMODEM or ZMODEM protocol. XThe initial ZMODEM initialization is not sent. XWhen requested by the receiver, X.B sb Xsupports X.B YMODEM-g Xwith "cbreak" tty mode, XON/XOFF flow control, Xand interrupt character set to CAN (^X). X.B YMODEM-g X(Professional-YAM X.B g Xoption) Xincreases throughput over error free channels X(direct connection, X.PC, etc.) Xby not acknowledging each transmitted sector. X XOn X.SM Unix Xsystems, additional information about the file is transmitted. XIf the receiving program uses this information, Xthe transmitted file length controls the exact number of bytes written to Xthe output dataset, Xand the modify time and file mode Xare set accordingly. X X X.B Sx Xsends a single X.I file Xwith X.B XMODEM Xor X.B XMODEM-1k Xprotocol X(sometimes incorrectly called "ymodem"). XThe user must supply the file name to both sending and receiving programs. X XIff X.B sz Xis invoked with $SHELL set and iff that variable contains the Xstring X.I "rsh" Xor X.I "rksh" X(restricted shell), X.B sz Xoperates in restricted mode. XRestricted mode restricts pathnames to the current directory and XPUBDIR (usually /usr/spool/uucppublic) and/or subdirectories Xthereof. X X XThe fourth form sends a single COMMAND to a ZMODEM receiver for execution. X.B Sz Xexits with the COMMAND return value. XIf COMMAND includes spaces or characters special to the shell, Xit must be quoted. X X XThe fifth form sends a single COMMAND to a ZMODEM receiver for execution. X.B Sz Xexits as soon as the receiver has correctly received the command, Xbefore it is executed. X X XThe sixth form (sz -TT) Xattempts to output all 256 code combinations to the terminal. XIn you are having difficulty sending files, Xthis command lets you see which character codes are being Xeaten by the operating system. X X XIf X.B sz Xis invoked with stdout and stderr to different datasets, XVerbose is set to 2, causing frame by frame progress reports Xto stderr. XThis may be disabled with the X.B q Xoption. X.PP XThe meanings of the available options are: X.PP X.PD 0 X.TP X\\ X(backslash) (VMS) Force the next option letter to upper case. X.TP X.B + XInstruct the receiver to append transmitted data to an existing file X(ZMODEM only). X.TP X.B a XConvert NL characters in the transmitted file to CR/LF. XThis is done by the sender for XMODEM and YMODEM, by the receiver Xfor ZMODEM. X.TP X.B b X(ZMODEM) Binary override: transfer file without any translation. X.TP X.B "c COMMAND" XSend COMMAND to the receiver for execution, return with COMMAND\'s exit status. X.TP X.B d XChange all instances of "." to "/" in the transmitted pathname. XThus, C.omenB0000 (which is unacceptable to MSDOS or CP/M) Xis transmitted as C/omenB0000. XIf the resultant filename has more than 8 characters in the stem, Xa "." is inserted to allow a total of eleven. X.TP X.B e XEscape all control characters; Xnormally XON, XOFF, DLE, CR-@-CR, and Ctrl-X are escaped. X.TP X.B f XSend Full pathname. XNormally directory prefixes are stripped from the transmitted Xfilename. X.TP X.B "i COMMAND" XSend COMMAND to the receiver for execution, return Immediately Xupon the receiving program's successful recption of the command. X.TP X.B k X(XMODEM/YMODEM) Send files using 1024 byte blocks Xrather than the default 128 byte blocks. X1024 byte packets speed file transfers at high bit rates. X(ZMODEM streams the data for the best possible throughput.) X.TP X.B "L N" XUse ZMODEM sub-packets of length N. XA larger N (32 <= N <= 1024) gives slightly higher throughput, Xa smaller N speeds error recovery. XThe default is 128 below 300 baud, 256 above 300 baud, or 1024 above 2400 baud. X.TP X.B "l N" XWait for the receiver to acknowledge correct data every X.B N X(32 <= N <= 1024) Xcharacters. XThis may be used to avoid network overrun when XOFF flow control is lacking. X.TP X.B n X(ZMODEM) Send each file if Xdestination file does not exist. XOverwrite destination file if Xsource file is newer than the destination file. X.TP X.B N X(ZMODEM) Send each file if Xdestination file does not exist. XOverwrite destination file if Xsource file is newer or longer than the destination file. X.TP X.B o X(ZMODEM) Disable automatic selection of 32 bit CRC. X.TP X.B p X(ZMODEM) Protect existing destination files by skipping transfer if the Xdestination file exists. X.TP X.B q XQuiet suppresses verbosity. X.TP X.B r X(ZMODEM) Resume interrupted file transfer. XIf the source file is longer than the destination file, Xthe transfer commences at the offset in the source file that equals Xthe length of the destination file. X.TP X.B rr XAs above, but compares the files (the portion common to sender and reciever) Xbefore resuming the transfer. X.TP X.B "t tim" XChange timeout to X.I tim Xtenths of seconds. X.TP X.B u XUnlink the file after successful transmission. X.TP X.B "w N" XLimit the transmit window size to N bytes (ZMODEM). X.TP X.B v XVerbose Xcauses a list of file Xnames to be appended to X/tmp/szlog . XMore v's generate more output. X.TP X.B y XInstruct a ZMODEM receiving program to overwrite any existing file Xwith the same name. X.TP X.B Y XInstruct a ZMODEM receiving program to overwrite any existing file Xwith the same name, Xand to skip any source files that do have a file with the same Xpathname on the destination system. X.TP X.B Z XUse ZMODEM file compression to speed file transfer. X.PD X.SH EXAMPLES X.ne 7 X.B "ZMODEM File Transfer" X(Unix to DSZ/ZCOMM/Professional-YAM) X.br X.B "% sz \-a *.c" X.br XThis single command transfers all .c files in the current Unix directory Xwith conversion X.RB ( \-a ) Xto end of line conventions appropriate to the receiving environment. XWith ZMODEM AutoDownload enabled, Professional-YAM and ZCOMM Xwill automatically recieve Xthe files after performing a security check. X X.br X.B "% sz \-Yan *.c *.h" X.br XSend only the .c and .h files that exist on both systems, Xand are newer on the sending system than the Xcorresponding version on the receiving system, converting Unix to XDOS text format. X.br X.B X$ sz -\\Yan file1.c file2.c file3.c foo.h baz.h X.R X(for VMS) X.br X X.B "ZMODEM Command Download" X(Unix to Professional-YAM) X.br X cpszall:all X sz \-c "c:;cd /yam/dist" X sz \-ya $(YD)/*.me X sz \-yqb y*.exe X sz \-c "cd /yam" X sz \-i "!insms" X.br XThis Makefile fragment uses X.B sz Xto issue commands to Professional-YAM to change current disk and directory. XNext, X.B sz Xtransfers the X.I .me Xfiles from the $YD directory, commanding the receiver to overwrite the old files Xand to convert from Unix end of line conventions to PC-DOS conventions. XThe third line transfers some X.I .exe Xfiles. XThe fourth and fifth lines command Pro-YAM to Xchange directory and execute a PC-DOS batch file X.I insms . XSince the batch file takes considerable time, the X.B "\-i" Xform is used to allow X.B sz Xto exit immediately. X X.B "XMODEM File Transfer" X(Unix to Crosstalk) X.br X% X.B "sx \-a foo.c" X.br X.B "ESC" X.br X.B "rx foo.c" X.br XThe above three commands transfer a single file Xfrom Unix to a PC and Crosstalk with X.I sz Xtranslating Unix newlines to DOS CR/LF. XThis combination is much slower and far less reliable than ZMODEM. X.SH ERROR MESSAGES X"Caught signal 99" Xindicates the program was not properly compiled, Xrefer to "bibi(99)" in rbsb.c for details. X.SH SEE ALSO Xrz(omen), XZMODEM.DOC, XYMODEM.DOC, XProfessional-YAM, Xcrc(omen), Xsq(omen), Xtodos(omen), Xtocpm(omen), Xtomac(omen), Xyam(omen) X XCompile time options required for various operating systems are described in Xthe source file. X.SH "VMS VERSION" XThe VMS version does not support wild cards. XBecause of VMS DCL, upper case option letters muse be represented Xby \\ proceding the letter. X XThe current VMS version does not support XMODEM, XMODEM-1k, or YMODEM. X XVMS C Standard I/O and RMS may interact to modify the file contents. X.SH FILES X32 bit CRC code courtesy Gary S. Brown. X Xsz.c, crctab.c, rbsb.c, zm.c, zmodem.h Unix source files X Xsz.c, crctab.c, vrzsz.c, zm.c, zmodem.h, vmodem.h, vvmodem.c, XVMS source files. X X/tmp/szlog stores debugging output (sz -vv) X(szlog on VMS). X.SH "TESTING FEATURE" XThe command "sz -T file" Xexercises the X.B Attn Xsequence error recovery by commanding Xerrors with unterminated packets. XThe receiving program should complain five times about Xbinary data packets being too long. XEach time X.B sz Xis interrupted, Xit should send a ZDATA header followed by another defective packet. XIf the receiver does not detect five long data packets, Xthe X.B Attn Xsequence is not interrupting the sender, and the X.B Myattn Xstring in X.B sz.c Xmust be modified. X XAfter 5 packets, X.B sz Xstops the "transfer" and Xprints the total number of characters "sent" (Tcount). XThe difference between Tcount and 5120 represents the number of characters Xstored in various buffers when the Attn sequence is generated. X.SH NOTES X.I Sz Xis not intended be called from X.I cu(1) Xor other communications programs. XUnix flavors of Omen Technology's XProfessional-YAM communications software Xare available for dial-out applications. X X XIf a program that does not properly implement Xthe specified file transfer protocol Xcauses X.I sb Xto "hang" the port after a failed transfer, Xeither wait for X.I sb Xto time out or keyboard a dozen Ctrl-X characters. XEvery reported instance of this problem has been corrected by using XZCOMM, Pro-YAM, DSZ, or other program with a correct implementation Xof the specified protocol. X XMany programs claiming to support YMODEM only support XMODEM with 1k blocks, Xand they often don't get that quite right. XXMODEM transfers add up to 127 garbage bytes per file. XXMODEM-1k and YMODEM-1k transfers use 128 byte blocks Xto avoid extra padding. X XYMODEM programs use the file length transmitted at the beginning of the Xtransfer to prune the file to the correct length; this may cause problems with Xsource files that grow during the course of the transfer. XThis problem does not pertain to ZMODEM transfers, which preserve the exact Xfile length unconditionally. X XMost ZMODEM options are merely passed to the receiving program; Xsome programs do not implement all of these options. X XCircular buffering and a ZMODEM sliding window should be used Xwhen input is from pipes instead of acknowledging frames each 1024 bytes. XIf no files can be opened, X.B sz Xsends a ZMODEM command to echo a suitable complaint; Xperhaps it should check for the presence of at least one accessible file before Xgetting hot and bothered. X XA few high speed modems have a firmware bug that drops characters when the Xdirection of high speed transmissson is reversed. XThe environment variable ZNULLS may be used to specify the number of nulls to Xsend before a ZDATA frame. XValues of 101 for a 4.77 mHz PC and 124 for an AT are typical. X.SH BUGS XOn at least one BSD system, sz would abend it got within Xa few kilobytes of the end of file. XUsing the "-w 8192" flag fixed the problem. XThe real cause is unknown, perhaps a bug in the kernel TTY output routines. X XThe test mode leaves a zero length file on the receiving system. END_OF_FILE if test 12484 -ne `wc -c <'sz.1'`; then echo shar: \"'sz.1'\" unpacked with wrong size! fi # end of 'sz.1' fi echo shar: End of archive 2 \(of 4\). cp /dev/null ark2isdone MISSING="" for I in 1 2 3 4 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 4 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 .