home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / d / drcpas10.zip / CRCTEST.PAS < prev    next >
Pascal/Delphi Source File  |  1992-11-17  |  935b  |  47 lines

  1. {$A+,B-,D-,E-,F-,I+,L-,N-,O-,R-,S+,V-}
  2. {$M 16384,0,655360}
  3. program crctest;
  4.  
  5. (* compute CRC of a file as an example of crc32.pas *)
  6.  
  7. uses dos, crc32, tools, dostools;
  8.  
  9. const
  10.   BUFSIZE = 16384;
  11.  
  12. type
  13.   buftype = array[1..BUFSIZE] of byte;
  14.  
  15. var
  16.   name : pathstr;
  17.   crc : longint;
  18.   buf : buftype;
  19.   count : word;
  20.   f : file;
  21. begin
  22.   writeln ('CRC-32   Turbo Pascal source by David Conrad');
  23.   writeln;
  24.   if paramcount = 0 then
  25.     begin
  26.       writeln ('crctest <file>');
  27.       halt (1);
  28.     end;
  29.   name := upperstr(paramstr(1));
  30.   if not exist(name) then
  31.     begin
  32.       writeln (name, ' not found');
  33.       halt (2);
  34.     end;
  35.   assign (f, name);
  36.   filemode := 0;
  37.   reset (f, 1);
  38.   crc := INITCRC;
  39.   repeat
  40.     blockread (f, buf, BUFSIZE, count);
  41.     crc := addbfcrc (buf, count, crc);
  42.   until count = 0;
  43.   crc := not crc;
  44.   close (f);
  45.   writeln (' ', lowerstr(hexl(crc)), ' : ', name);
  46. end.
  47.