/*======================================================================* * DOSshell program to calculate a CRC checksum on a file. * *======================================================================*/ #version $50 #reserve 6 #copyright "Crc.cmd Copyright 1995 K-Products" #address $7000 #include runtime.h #include bbs_pro.h #define MAXBUFF 17408 #define DISK2 2 #define DISK4 4 char buffer [MAXBUFF]; main() { heading(); if (length (parm1) == 0) { echose("Usage: CRC filename.ext"); return; } crc_file(); } heading() { cr_lf(); echose("BBS Express! Pro CRC v5.0"); echose(" (c) 1995 K-Products"); cr_lf(); } crc_file() { int crc, bytesin; echos("Reading, "); zero (buffer, sizeof(buffer)); MIOsuspend(); if (open (DISK2, parm1, 4, 0) != OK) { /* open input file? */ MIOresume(); echose("Unable to open input file!"); return; } bytesin = blockread (DISK2, buffer, sizeof(buffer)); if (IOresult (DISK2) != 136) { MIOresume(); cr_lf(); cr_lf(); echose("Unable to read file (too big?)"); return; } close (DISK2); MIOresume(); echos("calculating, "); crc = calc_CRC (buffer, bytesin); /* use xmodem's routine */ echos ("CRC is $"); hexword (crc); cr_lf(); } hexword (int i) { hexbyte(i >> 8); hexbyte(i & $ff); } hexbyte (char c) { char hexdig [20]; strcpy(hexdig,"0123456789ABCDEF"); echo (hexdig [c >> 4 + 1]); echo (hexdig [c & $0f + 1]); }