!###################################################### !# HASHCK.BAS - "HASH CHECK" !# !# Checks hash totals from the following files: !# HASHCK.OLD HASHCK.NEW !# !# (See the .LOG - JAN '86 for details on using HASHCK) !# !# Also, grab HSHDSK.CMD and HSHDSK.DOC.... ok? !# !# by Dave Heyliger AMUS Staff !# !# last update: 11/16/85 !####################################################### MAP1 NEW'FILE,S,50,"" MAP1 NEW'NAME,S,10,"" MAP1 NEW'HASH,S,15,"" MAP1 NEW'EXT,S,3,"" MAP1 NEW'PPN,S,15,"" MAP1 OLD'FILE,S,50,"" MAP1 OLD'NAME,S,10,"" MAP1 OLD'HASH,S,15,"" MAP1 OLD'EXT,S,3,"" MAP1 OLD'PPN,S,15,"" INITIALIZE: !--- ! Open two files: HASHCK.OLD and HASKCK.NEW. It is in these two ! files that all comparisons will be made. Also, open the daily ! report file, HASHCK.RPT and establish starting P,PN. Grab first ! filenames and away we go. !--------------------------------------------------------------------- OPEN #2,"HASHCK.OLD",INPUT OPEN #1,"HASHCK.NEW",INPUT OPEN #3,"HASHCK.RPT",OUTPUT TOP: INPUT LINE #2,OLD'FILE INPUT LINE #1,NEW'FILE CK: !If both files are at the very end, quit. IF (EOF(1) = 1 AND EOF(2) = 1) THEN GOTO THE'END !If "Grand" on either file, read past it. IF MID$(OLD'FILE,1,5) = "Grand" & THEN INPUT LINE #2,OLD'FILE IF MID$(NEW'FILE,1,5) = "Grand" & THEN INPUT LINE #1,NEW'FILE !If "No such files" read past it. IF MID$(OLD'FILE,1,5) = "%No s" & THEN INPUT LINE #2,OLD'FILE IF MID$(NEW'FILE,1,5) = "%No s" & THEN INPUT LINE #1,NEW'FILE !If an old P,PN deleted at the END of the series. IF (EOF(1) = 1 AND EOF(2) <> 1) & THEN INPUT LINE #2,OLD'FILE :& ? MID$(OLD'FILE,36,14) : & ? #3,MID$(OLD'FILE,36,14) & " * DELETED *" : GOTO DELETED'PPN !If a new P,PN added at the END of the series. IF (EOF(2) = 1 AND EOF(1) <> 1) & THEN ? MID$(NEW'FILE,36,14) : & ? #3,MID$(NEW'FILE,36,14) & " ** NEW **" : GOTO ADDED'PPN NEXT'PPN: !--- ! Determine if P,PN is NEW, DELETED, or same ol' P,PN as last time !------------------------------------------------------------------------ OLD'PPN = MID$(OLD'FILE,36,15) NEW'PPN = MID$(NEW'FILE,36,15) IF OLD'PPN = NEW'PPN & THEN ? OLD'PPN : ? #3,OLD'PPN : GOTO BREAKDOWN IF OLD'PPN > NEW'PPN & THEN ? NEW'PPN : ? #3,NEW'PPN " ** NEW **" : GOTO ADDED'PPN IF OLD'PPN < NEW'PPN & THEN ? OLD'PPN : ? #3,OLD'PPN " * Deleted *" : GOTO DELETED'PPN ADDED'PPN: !--- ! This portion of the program will be called if a new P,PN has been ! added since the last run of HSHDSK (Hash disk). It will report that ! a new P,PN has been added, and will list the new files in this P,PN !--------------------------------------------------------------------------- IF MID$(NEW'FILE,1,2) = "To" & THEN INPUT LINE #1,NEW'FILE IF MID$(NEW'FILE,1,2) = " " & THEN INPUT LINE #1,NEW'FILE :& IF MID$(NEW'FILE,1,2) <> "Gr" & THEN ? #3, : GOTO CK & ELSE INPUT LINE #1,NEW'FILE : ? #3, : GOTO CK NEW'NAME = MID$(NEW'FILE,1,10) ? #3,NEW'NAME " has been added" INPUT LINE #1,NEW'FILE GOTO ADDED'PPN DELETED'PPN: !--- ! Similar to ADDED'PPN but here a deletion message is printed, along ! with a listing of the deleted files within this P,PN !--------------------------------------------------------------------------- IF MID$(OLD'FILE,1,2) = "To" & THEN INPUT LINE #2,OLD'FILE IF MID$(OLD'FILE,1,2) = " " & THEN INPUT LINE #2,OLD'FILE :& IF MID$(OLD'FILE,1,2) <> "Gr" & THEN ? #3, : GOTO CK & ELSE INPUT LINE #2,OLD'FILE : ? #3, : GOTO CK OLD'NAME = MID$(OLD'FILE,1,10) ? #3,OLD'NAME " has been deleted" INPUT LINE #2,OLD'FILE GOTO DELETED'PPN BREAKDOWN: !--- ! Break down the filename by name, ext, and hash total !--------------------------------------------------------------------- IF MID$(OLD'FILE,7,1) <> " " & THEN INPUT LINE #2,OLD'FILE : GOTO PPN'OLD'END IF MID$(NEW'FILE,7,1) <> " " & THEN INPUT LINE #1,NEW'FILE : GOTO PPN'NEW'END OLD'NAME = MID$(OLD'FILE,1,10) OLD'HASH = MID$(OLD'FILE,18,15) OLD'EXT = MID$(OLD'FILE,8,3) NEW'NAME = MID$(NEW'FILE,1,10) NEW'HASH = MID$(NEW'FILE,18,15) NEW'EXT = MID$(NEW'FILE,8,3) ANALYSE: !--- ! There are many different combinations of how run-time reading ! of the two input files can be interpreted, and so this attempts ! to decide just what the heck is going on! !---------------------------------------------------------------------- !Case #1: Non-blank equal filenames - only time hash totals are checked. IF OLD'NAME = NEW'NAME & THEN IF MID$(OLD'NAME,1,1) <> " " & THEN GOTO CHECK'HASH ELSE ? #3, : GOTO TOP !Case #2: P,PN use to have only ONE file in it, now it has TWO or more new. IF MID$(OLD'FILE,1,1) = " " & THEN ? #3,NEW'NAME " has been added" :& INPUT LINE #1, NEW'FILE : GOTO BREAKDOWN !Case #3: P,PN use to have TWO or more files in it, now it has only ONE. IF MID$(NEW'FILE,1,1) = " " & THEN ? #3,OLD'NAME " has been deleted" :& INPUT LINE #2,OLD'FILE : GOTO BREAKDOWN !See if extensions are same even though filenames are different. !If so, bypass this next series of cases #4-#5 IF OLD'EXT = NEW'EXT THEN GOTO C6 !Case #4: A file has been deleted from the P,PN IF OLD'EXT < NEW'EXT & THEN ? #3,OLD'NAME " has been deleted" :& INPUT LINE #2,OLD'FILE : GOTO BREAKDOWN !Case #5: New file has been added to the P,PN IF OLD'EXT > NEW'EXT & THEN ? #3,NEW'NAME " has been added" :& INPUT LINE #1,NEW'FILE : GOTO BREAKDOWN C6: !Case #6: Same extension, file deletion from P,PN IF OLD'NAME < NEW'NAME & THEN ? #3,OLD'NAME " has been deleted" :& INPUT LINE #2,OLD'FILE : GOTO BREAKDOWN !Case #7: Same extension, file addition into P,PN IF OLD'NAME > NEW'NAME & THEN ? #3,NEW'NAME " has been added" :& INPUT LINE #1,NEW'FILE : GOTO BREAKDOWN CHECK'HASH: !--- ! Examimes hash total only when names are identical !----------------------------------------------------------- IF OLD'HASH <> NEW'HASH & THEN IF MID$(OLD'NAME,1,6) <> "HASHCK" & THEN IF MID$(OLD'NAME,1,5) <> "START" & THEN ? #3,OLD'NAME " has a hash conflict: old = "; :& ? #3,MID$(OLD'FILE,18,15) " new = "; :& ? #3,MID$(NEW'FILE,18,15) INPUT LINE #2,OLD'FILE INPUT LINE #1,NEW'FILE GOTO BREAKDOWN PPN'OLD'END: !--- ! If the end of the OLD P,PN listing has occurred but not the NEW ! listing, then all remaining files in the NEW listing are new, and ! so write these files to the report file. !------------------------------------------------------------------------- IF MID$(NEW'FILE,1,2) = "To" & THEN INPUT LINE #1,NEW'FILE IF MID$(NEW'FILE,1,2) = " " & THEN ? #3, : GOTO TOP NEW'NAME = MID$(NEW'FILE,1,10) ? #3,NEW'NAME " has been added" INPUT LINE #1,NEW'FILE GOTO PPN'OLD'END PPN'NEW'END: !--- ! Similar to PPN'OLD'END but OLD listing is longer than NEW listing. !------------------------------------------------------------------------- IF MID$(OLD'FILE,1,2) = "To" & THEN INPUT LINE #2,OLD'FILE IF MID$(OLD'FILE,1,2) = " " & THEN ?#3, : GOTO TOP OLD'NAME = MID$(OLD'FILE,1,10) ? #3,OLD'NAME " has been deleted" INPUT LINE #2,OLD'FILE GOTO PPN'NEW'END THE'END: ? "Comparison is complete" CLOSE #1:CLOSE #2:CLOSE #3:END