home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 June / SIMTEL_0692.cdr / msdos / trojanpr / filecrc.arc / COMPARE.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1988-05-30  |  22.7 KB  |  730 lines

  1.  
  2. {   PROGRAM TO COMPARE THE CRC'S OF THE FILE LISTS IN  }
  3. {   CHECK$$$.NEW AND CHECK$$$.CRC                      }
  4. {   To be used with program Filecrc                    }
  5. {   More extensive notes are included in FILECRC.PAS   }
  6.  
  7. {Version 1.00:  13 August 1986.  First Production Version.
  8.          1.01:  1 September 1986.  Allowed CRC of hidden system files.
  9.                 First Version to Usenet.
  10.          1.02:  12 September 1986.  Fixed bug in handling of hidden files.
  11.          1.10:  30 May 1988.  Eliminated chaining.  Added sensitive list.
  12.          1.11:  15 June 1988.  Fixed some minor printing bugs.
  13. }
  14.  
  15. {  The following compiler directives allow for I/O redirection (G,P & D),
  16. suppresses interrupts except when writing (U), and allows range
  17. checking (R) }
  18.  
  19. {$G1,P1,D-,U-,R+ }
  20.  
  21. Program Compare;
  22.  
  23. TYPE
  24.   string255 = string[255];
  25.   string64 = string[64];
  26.   string12 = string[12];
  27.   string77 = string[77];
  28.  
  29.   Changed_Type = (deleted,updated,created,modified);
  30.  
  31.   Registers = record
  32.                 ax, bx, cx, dx, bp, si, di, ds, es, flags : integer;
  33.               end;
  34.   Months = array [1..12] of string[3];
  35.  
  36.   Directory_record = record
  37.                        directory : string64;
  38.                        FileNum   : integer;
  39.                      end;
  40.  
  41.   File_Rec = record
  42.                name                : string12;
  43.                time_of_day, date   : integer;
  44.                low_size,high_size  : integer;
  45.                attribute           : byte;
  46.                crc                 : integer;
  47.                found               : boolean;
  48.              end;
  49.  
  50.  
  51. CONST
  52.   month : Months = ('JAN','FEB','MAR','APR','MAY','JUN',
  53.                     'JUL','AUG','SEP','OCT','NOV','DEC');
  54.   Version = 1.11;
  55.   Version_Date = '15 June 1988';
  56.  
  57.   {  The next three variables may need to be changed to fit your
  58.      specific situation.  Unfortunately, Turbo-Pascal is limited in the
  59.      amount of data space allowed.  In order for you to keep within
  60.      the limitations, you must have
  61.      MAX_FILE * 24 + MAX_DIR * 66 + MAX_SENS * 77 < 57000
  62.   }
  63.   MAX_FILE = 1750;  {  Maximum number of files  }
  64.   MAX_DIR = 200;  {  Maximum number of directories  }
  65.   MAX_SENS = 30;  {  Maximum number of sensitive files  }
  66.  
  67. VAR
  68.  
  69.   {  File Creation time and date  }
  70.   TimeOfDay, FileDate : integer;
  71.   directory_number, file_number : integer;
  72.   sensitive_end : integer;
  73.  
  74.   {  Number of files in each category  }
  75.   Old_file, New_file, Del_file, OK_file,
  76.      Update_file, Mod_file, S_file         : integer;
  77.  
  78.   old_filename, new_filename : string64;
  79.   infile : TEXT[$0800];  { file for reading file lists }
  80.   outfile : TEXT;  {  copy of screen text  }
  81.   sens_file : TEXT;  {  file for reading sensitive file  }
  82.   newfile : TEXT; { file for writing names of new files created }
  83.   delfile : TEXT; { file for writing names of deleted files }
  84.   modfile : TEXT; { file for writing names of modified files }
  85.   updatefile : TEXT; { file for writing names of updated files }
  86.   tempfile : file; { used in renaming files }
  87.  
  88.   CRC_value : Integer;
  89.  
  90.   filename : string12;
  91.   Name_of_File, CRC_string, instring : string255;
  92.  
  93.   attribute : byte;
  94.   lowsize, highsize : integer;
  95.   new, new_dir : boolean;
  96.  
  97.   number_directories, direct_count : integer;
  98.  
  99.   this_directory, current_directory : string64;
  100.  
  101.   directories : array [1..MAX_DIR] of directory_record;
  102.   fileinfo : array [1..MAX_FILE] of file_rec;
  103.   sensitive_file : array [1..MAX_SENS] of string77;
  104.  
  105. function get_string  : string255;
  106. {
  107.   This function returns a string up to the first space from infile
  108. }
  109. var
  110.   inchar : char;
  111.   temp_string : string255;
  112.  
  113. begin
  114.   {  Ignore any leading blanks  }
  115.   Repeat
  116.     read(infile, inchar);
  117.   Until inchar <> ' ';
  118.  
  119.   temp_string := '';
  120.  
  121.   {  Now, add on to temp_string until a blank is found  }
  122.   Repeat
  123.     temp_string := temp_string + inchar;
  124.     read(infile, inchar);
  125.   Until inchar = ' ';
  126.  
  127.   get_string := temp_string;
  128.  
  129. end;
  130.  
  131. procedure read_sensitive;
  132. {
  133.   Procedure to read in the list of sensitive files
  134.  
  135. }
  136.  
  137. begin
  138.   Reset (sens_file);  {  Set to read Old List of Files  }
  139.   sensitive_end := 0;  {  Number of files in the list  }
  140.   While not eof(sens_file) do
  141.   begin
  142.     sensitive_end := sensitive_end + 1;
  143.     Readln(sens_file,sensitive_file[sensitive_end]);
  144.   end;
  145.   Close (sens_file);
  146. end;
  147.  
  148.  
  149. procedure read_old_file;
  150. {
  151.   Procedure to read in the old list of files and set up the list of
  152.   directories (variable directories), and the list of files along with
  153.   the various data (variable fileinfo).
  154.   On return,
  155.   old_file has the number of files in the list and
  156.   number_directories has the number of directories.
  157.  
  158.   The variables directories and fileinfo have the following information:
  159.   directories  directory : Name of the directory (up to 64 characters)
  160.                FileNum   : Number of the name in fileinfo that contains
  161.                            the information for the first file in this
  162.                            directory.
  163.  
  164.   fileinfo     name        : Name of the file
  165.                time_of_day : Time of day in DOS format
  166.                date        : Date in DOS format
  167.                low_size    : Low byte of the file size
  168.                high_size   : High byte of the file size
  169.                attribute   : Attribute of the file
  170.                crc         : CRC of the file
  171.                found       : Boolean -- Has this file been found?
  172.                                All those file where found=FALSE have been
  173.                                deleted.
  174.  
  175. }
  176.  
  177. begin
  178.   Reset (infile);  {  Set to read Old List of Files  }
  179.   old_file := 0;  {  Number of files in the list  }
  180.   number_directories := 0;  {  Number of directories in the list  }
  181.   While not eof(infile) do
  182.   begin
  183.     old_file := old_file + 1;  {  Another file  }
  184.     this_directory := get_string;  {  Get the directory name  }
  185.     fileinfo[old_file].name := get_string;  {  Get the file name  }
  186.     if this_directory <> current_directory then
  187.     begin
  188.       current_directory := this_directory;
  189.       number_directories := number_directories + 1;
  190.       directories[number_directories].directory := this_directory;
  191.       directories[number_directories].FileNum := old_file;
  192.     end;
  193.     With fileinfo[old_file] do
  194.       begin
  195.         found := FALSE;
  196.         Readln(infile,attribute, Time_of_day, date, low_size, high_size, crc);
  197.       end;
  198.   end;
  199.   directories[number_directories + 1].FileNum := old_file + 1;
  200.   Close (infile);
  201. end;
  202.  
  203.  
  204. function get_time(date1,date2 : integer) : string64;
  205. {
  206.   This function returns the time and date of file creation.
  207.   date1 is the time of day in DOS format
  208.   date2 is the date of creation in DOS format
  209.  
  210.   get_time is a string with the time and date (e.g., 14:31:42  8 AUG 1986)
  211. }
  212.  
  213. var
  214.   hour, minute, second : integer;
  215.   temp, time : string64;
  216.   year, n_month, day : integer;
  217.  
  218. begin
  219.  
  220.   if date2 <> 0 then
  221.   begin
  222.     hour := date1 shr 11;
  223.     minute := (date1 shr 5) - (hour shl 6);
  224.     second := (date1 - (minute shl 5) - (hour shl 11))*2;
  225.     year := date2 shr 9;
  226.     n_month := (date2 shr 5) - (year shl 4);
  227.     day := date2 - (n_month shl 5) - (year shl 9);
  228.     Str(hour:2,temp);
  229.     time := temp + ':';
  230.     Str(minute:2,temp);
  231.     if temp[1] = ' ' then temp[1] := '0';
  232.     time := time + temp + ':';
  233.     Str(second:2,temp);
  234.     if temp[1] = ' ' then temp[1] := '0';
  235.     time := time + temp + '   ';
  236.     Str(day:2,temp);
  237.     time := time + temp + ' ' + month[n_month] + ' ';
  238.     Str(year + 1980:4,temp);
  239.     get_time := time + temp;
  240.   end
  241.   else
  242.     get_time := '                      ';
  243.  
  244. end;
  245.  
  246. procedure write_old_file ( file_number : integer);
  247. {
  248.   Procedure to write the attribute, size and CRC for a file from
  249.   the old list
  250.  
  251.   file_number is the number of the file name
  252.  
  253. }
  254.  
  255. var
  256.   filesize : real;
  257. begin
  258.   with fileinfo[file_number] do
  259.   begin
  260.     if low_size < 0 then
  261.       filesize := int(high_size)*65536.0 + 32768.0 + int(low_size and $7FFF)
  262.     else
  263.       filesize := int(high_size)*65536.0 + int(low_size);
  264.     Write ('  Attribute = ',attribute:3,', Size = ',filesize:10:0);
  265.     Write (outfile,'  Attribute = ',attribute:3,', Size = ',filesize:10:0);
  266.     Writeln (', CRC = ',CRC);
  267.     Writeln (outfile,', CRC = ',CRC);
  268.   end;
  269. end;
  270.  
  271.  
  272. procedure write_new_file;
  273. {
  274.   Procedure to write the attribute, size and CRC for a file from
  275.   the new list
  276.  
  277. }
  278.  
  279. var
  280.   filesize : real;
  281. begin
  282.   if lowsize < 0 then
  283.     filesize := int(highsize)*65536.0 + 32768.0 + int(lowsize and $7FFF)
  284.   else
  285.     filesize := int(highsize)*65536.0 + int(lowsize);
  286.   Write ('  Attribute = ',attribute:3,', Size = ',filesize:10:0);
  287.   Write (outfile,'  Attribute = ',attribute:3,', Size = ',filesize:10:0);
  288.   Writeln (', CRC = ', CRC_value);
  289.   Writeln (outfile,', CRC = ', CRC_value)
  290. end;
  291.  
  292.  
  293. procedure find_directory( var number : integer; var newdir : boolean);
  294. {
  295.   Procedure to find the directory from the old list that matches the
  296.   directory name from the new list
  297.  
  298.   If the directory name is the same as the current directory, then
  299.   number and newdir are unchanged.
  300.  
  301.   If the directory name is not the same, and it exists on the old list,
  302.   number will be the number of the old directory, and newdir is FALSE.
  303.   The current directory will be updated.
  304.  
  305.   If the directory name is not the same, and it does not exist on the
  306.   old list, newdir is FALSE.  Number is number of directories + 1, but
  307.   is never used.
  308.  
  309. }
  310. begin
  311.   {  If the directory is the same, then the status of number and newdir  }
  312.   {  will not change                                                     }
  313.   if this_directory <> current_directory then
  314.   begin  {  search from the beginning  --  nothing fancy  }
  315.     number := 0;
  316.     Repeat
  317.       number := number + 1;
  318.     Until (number > number_directories) or
  319.       (this_directory = directories[number].directory);
  320.     newdir := (number > number_directories);
  321.     current_directory := this_directory;
  322.   end;
  323. end;
  324.  
  325. procedure find_file( var number : integer; var new : boolean;
  326.                     number_begin, number_end : integer);
  327. {
  328.   Procedure to find the file name.  The directory name has been
  329.   found prior to this time, so the starting point in the search
  330.   has been found.  The search will continue until the first file
  331.    name in the next directory.
  332.  
  333. }
  334. begin
  335.   number := number_begin -1;
  336.   Repeat
  337.     number := number + 1;
  338.   Until (number = number_end) or (filename = fileinfo[number].name);
  339.   new := (filename <> fileinfo[number].name);
  340.   if not new then
  341.     fileinfo[number].found := TRUE;     {  Mark file as found  }
  342. end;
  343.  
  344. procedure sensitive (check_file : string255; changed : Changed_Type);
  345. {
  346.   Check changed files to see if they are in the sensitive list.
  347. }
  348.  
  349. var
  350.   sensitive_number : integer;
  351.   temp : string64;
  352. begin
  353.   sensitive_number := 1;
  354.   While sensitive_number <= sensitive_end do
  355.   begin
  356.     If check_file = sensitive_file[sensitive_number] then
  357.       begin
  358.         Write ('Sensitive File: ',check_file,' has been ');
  359.         Write (outfile,'Sensitive File: ',check_file,' has been ');
  360.         Case changed of
  361.           created : begin
  362.                       Writeln ('created.');
  363.                       Writeln (outfile,'created.');
  364.                     end;
  365.           updated : begin
  366.                       Writeln ('updated.');
  367.                       Writeln (outfile,'updated.');
  368.                     end;
  369.           deleted : begin
  370.                       Writeln ('deleted.');
  371.                       Writeln (outfile,'deleted.');
  372.                     end;
  373.           modified: begin
  374.                       Writeln ('modified.');
  375.                       Writeln (outfile,'modified.');
  376.                     end;
  377.         end;
  378.         S_file := S_file + 1;
  379.       end;
  380.     sensitive_number := sensitive_number + 1;
  381.   end;
  382. end;
  383.  
  384. procedure find_deleted;
  385. {  Procedure to find all those files that were deleted.
  386.    Del_file is the counter for the number of deleted files.
  387. }
  388. Var
  389.   filesize  : real;
  390.   dir_number, file_number : integer;
  391.  
  392. Begin
  393.   dir_number := 0;
  394.   For dir_number := 1 to number_directories do
  395.     For file_number := directories[dir_number].Filenum to
  396.                        directories[dir_number+1].Filenum - 1 do
  397.       If not fileinfo[file_number].found then
  398.         begin
  399.           Del_file := Del_file + 1;
  400.           With fileinfo[file_number] do
  401.           begin
  402.             sensitive (this_directory + '\' + name,deleted);
  403.             Write (delfile,this_directory + '\' + name);
  404.             Writeln (delfile,' Date: ',get_time(time_of_day,date));
  405.             if lowsize < 0 then
  406.               filesize := int(highsize)*65536.0 + 32768.0 +
  407.                             int(lowsize and $7FFF)
  408.             else
  409.               filesize := int(highsize)*65536.0 + int(lowsize);
  410.             Writeln (delfile,' Attr = ',attribute:3,
  411.                        ', Size = ',filesize:10:0,', CRC = ', CRC);
  412.           end;
  413.         end;
  414. end;
  415.  
  416. procedure file_new;
  417. {
  418.   This procedure processes the new files.  new_file is the counter
  419.   for the number of new files.  The file name and information is
  420.   written to the file assigned to newfile.
  421. }
  422.  
  423. var
  424.   filesize : real;
  425.  
  426. begin
  427.   new_file := new_file + 1;
  428.   sensitive (this_directory + '\' + filename,created);
  429.   Write (newfile,this_directory + '\' + filename);
  430.   Writeln (newfile,' Date: ',get_time(TimeOfDay, FileDate));
  431.   if lowsize < 0 then
  432.     filesize := int(highsize)*65536.0 + 32768.0 + int(lowsize and $7FFF)
  433.   else
  434.     filesize := int(highsize)*65536.0 + int(lowsize);
  435.   Writeln (newfile,'  Attribute = ',attribute:3,
  436.            ', Size = ',filesize:10:0,', CRC = ', CRC_value);
  437. end;
  438.  
  439. procedure file_updated;
  440. {
  441.   This procedure processes the updated files.  Update_file is the counter
  442.   for the number of updated files.
  443. }
  444.  
  445. var
  446.   filesize : real;
  447.  
  448. begin
  449.   Update_file := Update_file + 1;
  450.   sensitive (this_directory + '\' + filename,updated);
  451.   Writeln (updatefile,this_directory + '\' + filename);
  452.   With fileinfo[file_number] do
  453.   Begin
  454.     Write (updatefile,'Old Date: ',get_time(time_of_day,date));
  455.     if lowsize < 0 then
  456.       filesize := int(highsize)*65536.0 + 32768.0 + int(lowsize and $7FFF)
  457.     else
  458.       filesize := int(highsize)*65536.0 + int(lowsize);
  459.     Writeln (updatefile,' Attr = ',attribute:3,
  460.            ', Size = ',filesize:10:0,', CRC = ', CRC);
  461.   End;
  462.   Write (updatefile,'New Date: ',get_time(TimeOfDay, FileDate));
  463.   if lowsize < 0 then
  464.     filesize := int(highsize)*65536.0 + 32768.0 + int(lowsize and $7FFF)
  465.   else
  466.     filesize := int(highsize)*65536.0 + int(lowsize);
  467.   Writeln (updatefile,' Attr = ',attribute:3,
  468.            ', Size = ',filesize:10:0,', CRC = ', CRC_value);
  469. end;
  470.  
  471. procedure file_OK;
  472. {
  473.   This procedure processes the files that have not been changed, modified
  474.   or deleted.  OK_file is the counter for the number of such files.
  475. }
  476.  
  477. begin
  478.   OK_file := OK_file + 1;
  479. end;
  480.  
  481. procedure bad_CRC;
  482. {
  483.   This procedure processes the files that have been modified without
  484.   changing the directory entry date or time.  Mod_file is the counter for
  485.   the number of such files.  In normal operations, this should not happen,
  486.   so for such files, the name and date information is shown on the console
  487.   and sent to the file assigned to modfile.
  488. }
  489.  
  490. begin
  491.   Mod_file := Mod_file + 1;
  492.   sensitive (this_directory + '\' + filename,modified);
  493.   Writeln ('CRC''s do not match!  File: ',this_directory + '\' + filename);
  494.   Writeln ('Date: ',get_time(TimeOfDay, FileDate));
  495.   Write ('Old file:');
  496.   Writeln (outfile,'CRC''s do not match!  File: ',this_directory+'\'+filename);
  497.   Writeln (outfile,'Date: ',get_time(TimeOfDay, FileDate));
  498.   Write (outfile,'Old file:');
  499.   write_old_file(file_number);
  500.   Write ('New file:');
  501.   Write (outfile,'New file:');
  502.   write_new_file;
  503.   Write (modfile, this_directory + '\' + filename);
  504.   Writeln (modfile,' Date: ', get_time(TimeOfDay, FileDate));
  505. end;
  506.  
  507. procedure read_new_file;
  508. {
  509.   Procedure to read the list of new files, and compare them to the
  510.   old files.  The various comparison types are processed according to
  511.   the preceeding routines.
  512. }
  513.  
  514. begin
  515.   current_directory := '';
  516.   new_dir := FALSE;
  517.  
  518.   Assign (infile, new_filename);
  519.   Reset (infile);
  520.  
  521.   While not eof(infile) do
  522.   begin
  523.     this_directory := get_string;  {  First is the directory name  }
  524.     filename := get_string;  {  Next is the file name  }
  525.     Readln(infile, attribute, TimeOfDay, FileDate, lowsize,
  526.            highsize, crc_value);  {  Then the file parameters  }
  527.     {  Find the entry in the list of old files with the same name  }
  528.     find_directory(directory_number,new_dir);
  529.     if not new_dir then
  530.       find_file(file_number,new,
  531.                 directories[directory_number].FileNum,
  532.                 directories[directory_number + 1].FileNum-1);
  533.     if (new_dir or new) then  {  New directory means new file  }
  534.       file_new
  535.     else  {  Existing file, compare the two  }
  536.       if (fileinfo[file_number].Time_of_day <> TimeOfDay)
  537.         or (fileinfo[file_number].date <> FileDate) then
  538.           file_updated
  539.       else
  540.         if (fileinfo[file_number].crc <> CRC_value) then bad_CRC
  541.         else
  542.           file_OK;
  543.   end;
  544.   Close (infile);
  545. end;
  546.  
  547. procedure set_in_out;
  548. {  Set up the input and output files  }
  549. begin
  550.   {  See if any command line file names, and modify accordingly  }
  551.  
  552.   Case ParamCount of
  553.     0 : begin  {  No command line parameters, use default names  }
  554.           old_filename := 'CHECK$$$.CRC';
  555.           new_filename := 'CHECK$$$.NEW';
  556.         end;
  557.     1 : begin  {  File name with listing of new files has been given  }
  558.           old_filename := 'CHECK$$$.CRC';
  559.           new_filename := ParamStr(1);
  560.         end;
  561.     else
  562.         begin  {  Both file names have been given  }
  563.           old_filename := ParamStr(2);
  564.           new_filename := ParamStr(1);
  565.         end;
  566.   end;
  567.  
  568.   {  Set up the various input and output files  }
  569.  
  570.   Assign (infile,old_filename);
  571.   Assign (newfile,'FILES$$$.NEW');
  572.   Rewrite (newfile);
  573.   Writeln (newfile,'New files created on this disk');
  574.   Assign (delfile,'FILES$$$.DEL');
  575.   Rewrite (delfile);
  576.   Writeln (delfile,'Files that were deleted');
  577.   Assign (modfile,'FILES$$$.MOD');
  578.   Rewrite (modfile);
  579.   Writeln (modfile,'Files that were modified without updating the directory');
  580.   Assign (updatefile,'FILES$$$.UPD');
  581.   Rewrite (updatefile);
  582.   Writeln (updatefile,'Files that were updated on this disk');
  583. end;
  584.  
  585.  
  586. procedure initialize;
  587. {  Initialize various pointers and numbers  }
  588. begin
  589.  
  590.   {  Set up the directory and file name pointers  }
  591.   number_directories := 1;
  592.   current_directory := '';
  593.   directories[1].directory := current_directory;
  594.   directories[1].FileNum := 1;
  595.  
  596.   {  Reset the counters for the various comparisons  }
  597.  
  598.   Del_file := 0;
  599.   New_file := 0;
  600.   OK_file := 0;
  601.   Update_file := 0;
  602.   Mod_file := 0;
  603.   S_file := 0;
  604. end;
  605.  
  606.  
  607.  
  608. BEGIN  {  Compare  }
  609.  
  610.   Writeln('CRC file integrity comparison program');
  611.   Writeln('Version ',version:5:2,', ',version_date);
  612.   Write('Written by Ted H. Emigh -- ');
  613.   Writeln('emigh@ncsugn.uucp or NEMIGH@TUCC.BITNET');
  614.  
  615.   Assign (outfile,'FILECRC.OUT');
  616.   Rewrite (outfile);
  617.   Writeln(outfile,'CRC file integrity comparison program');
  618.   Writeln(outfile,'Version ',version:5:2,', ',version_date);
  619.   Write(outfile,'Written by Ted H. Emigh -- ');
  620.   Writeln(outfile,'emigh@ncsugn.uucp or NEMIGH@TUCC.BITNET');
  621.  
  622.   {  Initialize various pointers and numbers  }
  623.  
  624.   initialize;
  625.  
  626.   {  Set up the input and output files  }
  627.  
  628.   set_in_out;
  629.  
  630.   {  Read in the file containing the old CRC list  }
  631.  
  632.   Writeln ('Reading old CRC list, please wait ...');
  633.   read_old_file;
  634.  
  635.   {  If the file SENSITIV exists, read in the list of sensitive files  }
  636.  
  637.   Assign (sens_file, 'SENSITIV');
  638.   {$I-}
  639.   Reset (sens_file);  {  See if the file exists  }
  640.   {$I+}
  641.   if IOresult <> 0 then
  642.     sensitive_end := 0  { Sensitive list does not exist }
  643.   else
  644.   begin
  645.     Writeln ('Reading sensitive file list, please wait ...');
  646.     read_sensitive;
  647.   end;
  648.  
  649.   {  Read the new CRC list and check against the old list  }
  650.   {
  651.   This procedure will check for all differences except if the
  652.   file has been deleted -- that will be checked after all files
  653.   have been processed
  654.   }
  655.   Writeln ('Reading new CRC list and checking, please wait ...');
  656.   read_new_file;
  657.  
  658.   {  Now, check for those files that were deleted -- they will have
  659.      fileinfo[].found = FALSE
  660.   }
  661.   find_deleted;
  662.  
  663.   {  Print the summary numbers for this check  }
  664.  
  665.   Writeln;
  666.   Writeln ('Number of Files in the last CRC check:           ',old_file);
  667.   Writeln ('Number of Files that are the same as last time:  ',OK_file);
  668.   Writeln ('Number of New Files:                             ',new_file);
  669.   Writeln ('Number of Deleted Files:                         ',
  670.             old_file - update_file - OK_file - Mod_file);
  671.   Writeln ('Number of Updated Files:                         ',update_file);
  672.   Writeln ('Number of Invalidly Modified Files:              ',Mod_file);
  673.   Writeln ('Number of Sensitive Files Changed:               ',S_file);
  674.   Writeln;
  675.   Writeln;
  676.  
  677.   Writeln (outfile);
  678.   Writeln (outfile,'Number of Files in the last CRC check:           ',
  679.             old_file);
  680.   Writeln (outfile,'Number of Files that are the same as last time:  ',
  681.             OK_file);
  682.   Writeln (outfile,'Number of New Files:                             ',
  683.             new_file);
  684.   Writeln (outfile,'Number of Deleted Files:                         ',
  685.             old_file - update_file - OK_file - Mod_file);
  686.   Writeln (outfile,'Number of Updated Files:                         ',
  687.             update_file);
  688.   Writeln (outfile,'Number of Invalidly Modified Files:              ',
  689.             Mod_file);
  690.   Writeln (outfile,'Number of Sensitive Files Changed:               ',
  691.             S_file);
  692.   Writeln (outfile);
  693.   Writeln (outfile);
  694.   Close (outfile);
  695.  
  696.   {  Erase the output files if they are empty  }
  697.  
  698.   Close (newfile);
  699.   if new_file = 0 then Erase (newfile);
  700.   Close (delfile);
  701.   if del_file = 0 then Erase (delfile);
  702.   Close (modfile);
  703.   if Mod_file = 0 then Erase (modfile);
  704.   Close (updatefile);
  705.   if update_file = 0 then Erase (updatefile);
  706.  
  707.   {  No command line parameters  --  Rename the files with the file lists  }
  708.  
  709.   if ParamCount = 0 then
  710.   begin
  711.     Assign (tempfile, 'CHECK$$$.OLD');
  712.     {$I-}
  713.     Reset (tempfile);  {  See if the file already exists  }
  714.     {$I+}
  715.     if IOresult = 0 then
  716.       Erase (tempfile);  {  Yes, it exists -- delete it  }
  717.     Close (tempfile);
  718.     Assign (tempfile, 'CHECK$$$.CRC');
  719.     Rename (tempfile, 'CHECK$$$.OLD');
  720.     Assign (tempfile, 'CHECK$$$.NEW');
  721.     Rename (tempfile, 'CHECK$$$.CRC');
  722.     Writeln ('Old CRC file is now CHECK$$$.OLD');
  723.     Writeln ('New CRC file is now CHECK$$$.CRC');
  724.     Writeln;
  725.   end;
  726.  
  727.  
  728.  
  729. end.
  730.