;*************************** AMUS Program Label ****************************** ; Filename: SNITCH Date: 6/10/92 ; Category: UTIL Hash Code: 306-164-764-207 Version: 1.0(103) ; Initials: GR/AM Name: JAMES A. JARBOE IV ; Company: EDUCATIONAL VIDEO NETWORK Telephone #: 4092955767 ; Related Files: SNITCH.HLP, SNITCH.ON ; Min. Op. Sys.: 1.3 Expertise Level: INT ; Special: SNITCH.ON must be located in OPR: account. ; Description: Snitches to designated users, the name(s) of files that have ; exceeded a predetermined maximum block size as defined in a SNITCH.ON file ; located in OPR: account. Include SNITCH command in standard logon procedure. ;***************************************************************************** ;*; Updated on 04-Apr-92 at 9:24 PM by James A. Jarboe I V; edit time: 4:15:21 ;*************************************************************************** ;* * ;* SNITCH.M68 * ;* * ;* Written By: James A. Jarboe IV * ;* 1401 19th Street * ;* Huntsville, TX 77340 * ;* 409-295-5767 * ;* * ;* 04-Apr-92 * ;* GR/AM * ;*************************************************************************** ;* Copyright (c) 1992 - James A. Jarboe IV * ;* Unpublished - All rights reserved. * ;*************************************************************************** ; ; Description: Reports to a specified list of users (determined by ; the JOBUSN ) that a specified list of files have exceeded ; a predetermined file size. ; ; Additional files: ; SNITCH.HLP - Help file. ; SNITCH.ON - Designation file. ; ; Notes: See SNITCH.HLP, SNITCH.ON ; ; Uses a OPR:SNITCH.ON file to designate a list of users to ; report to and a list of designated files to report about. ; The layout of SNITCH.ON is: ; ; *User Name ; Same user name used by MUSER but preceded ; ; by the * character in the SNITCH.ON file. ; FILEN.AME ; Partial or full files pecification. ; ; See: SNITCH.ON file which should be located in OPR: account. ; ; Option: ; User can designate an optional list file to use for designation ; list by including it as a file specification on the command line. ; Example: ; SNITCH CHECK.ME ; ; Where SNITCH will use CHECK.ME as the file specification to ; process for user and file designations. ; ; Edit History: ; ; [103] 04-Apr-92 Made so user name comparison is NOT case sensitive. ; ; [102] 23-Mar-92 Make so SNITCH reports even if in a command or do file ; under silent mode. Always resets Command processor to ; original state. ; ; [101] 11-Feb-92 Added fun comments when user does not Press RETURN. ; ; [100] 03-Jan-92 Written by James A. Jarboe IV ; ASMMSG " " ASMMSG "+-------------------------------------+" ASMMSG "| |" ASMMSG "| SNITCH |" ASMMSG "| |" ASMMSG "| Snitches on files that grow to big. |" ASMMSG "| |" ASMMSG "| By: James A. Jarboe IV |" ASMMSG "| |" ASMMSG "+-------------------------------------+" ASMMSG " " PAGE ;*************************************************************************** ; * ; S Y M B O L I C S * ; * ;*************************************************************************** ; SEARCH SYS ; Amos Standard symbolic. SEARCH SYSSYM ; Amos Standard symbolic. SEARCH TRM ; Amos Standard symbolic. PAGE ;*************************************************************************** ; * ; C U R R E N T V E R S I O N * ; * ;*************************************************************************** ; VMAJOR = 1. ; Current Release. VMINOR = 0 ; VEDIT = 103. ; 04-Apr-92 by JAJIV VWHO = 0 ; PAGE ;*************************************************************************** ; * ; P R O G R A M M A C R O S * ; * ;*************************************************************************** ; ; Print tab. ; DEFINE PRTTAB ROW,COL MOVW #, D1 TCRT ENDM ; Fun comment table set up. ; DEFINE FNCMT NUM, TEXT WORD NUM WORD 1$$-. ASCII /TEXT/ BYTE 0 EVEN 1$$=. ENDM PAGE ;*************************************************************************** ; * ; B U F F E R S I Z E S A N D E Q U A T E S * ; * ;*************************************************************************** ; S..IOB = 512. ; Size of Buffer. S..USN = 19. ; Size of JOBUSN (User name). ; 20 char field null terminated. S..CMT = 12. ; Max number of fun comments. SN$USF = '* ; User flag in SNITCH.ON. SN$EXT = [ON ] ; Default file extension. $LF = 10. ; Linefeed. $CR = 13. ; CR. $SPACE = 32. ; Space. PAGE ;*************************************************************************** ; * ; P R O G R A M I M P U R E A R E A * ; * ;*************************************************************************** ; .OFINI ; Initialize impure area. .OFDEF IN.DDB, D.DDB ; Input DDB. .OFDEF SN.DDB, D.DDB ; File to check. .OFDEF SN.BUF, S..IOB ; Snitch buffer. .OFDEF SN.SZZ, 4 ; Max size of file in question. .OFDEF SN.FLG, 4 ; Snitch flag values. SN%SEZ = 0 ; Sez already on screen flag. SN%USN = 1 ; User name match flag. SN%ANY = 2 ; Processed a filespec flag. .OFDEF SN.CMS, 2 ; Command file status. .OFSIZ S..PIA ; Size of Program Impure Area. PAGE ;*************************************************************************** ; * ; S T A R T O F P R O G R A M C O D E * ; * ;*************************************************************************** ; ;+************************+ ; SNITCH * ;+************************+ ; ; Snitches on files that have exceeded a predetermined size. ; SNITCH: PHDR -1, 0, PH$REU!PH$REE ; Allocate local impure area. ; GETIMP S..PIA, A5 ; Get impure memory area. ; Init all DDB's needed. ; INIT IN.DDB(A5) ; Initialize DDB INIT SN.DDB(A5) ; ORB #, IN.DDB+D.FLG(A5) ; no exit, no report. ORB #, SN.DDB+D.FLG(A5) ; no exit, no report. ; So that SNITCH can properly report errors, even in a command or do file. ; we set the command processor status to not be in silent mode. ; This value is reset to its original value just before the program exits. ; All EXITS are at ALLDUN: ; JOBIDX ; Index job. MOVW JOBCMS(A6), SN.CMS(A5) ; Save command status. BCLR #C%SIL, JOBCMS(A6) ; Turn off Silent mode if set. BYP ; Bypass junk. LIN ; Anything there? BNE 10$ ; No..use default. LEA A2, DATFIL ; Index data filespec. 10$: MOV #SN$EXT, D6 ; Set default extension. FSPEC IN.DDB(A5) ; Get filespec. JNE FIL.ER ; Bad filespec. CLR IN.DDB+D.DVR(A5) ; Preclear driver address. LOOKUP IN.DDB(A5) ; Is file there? BEQ 20$ ; Yes..use it. NEGB IN.DDB+D.ERR(A5) ; Make usable. JMP FIL.ER ; No..report. 20$: OPENI IN.DDB(A5) ; Open file for input. JNE FIL.ER ; Something wrong on open. CALL CHKOUT ; Check out files. PAGE ;+************************+ ; ALLDUN * ;+************************+ ; Clean up and end out of program. ; ALLDUN: BTST #SN%SEZ, SN.FLG(A5) ; We report anything? BEQ 10$ ; No..never mind. CALL PAUSE ; Yes..let user see it. CRLF ; Bump line. 10$: JOBIDX ; Index this job. MOVW SN.CMS(A5), JOBCMS(A6) ; Reset command processor. EXIT ; Exit. PAGE ;+************************+ ; CHKOUT * ;+************************+ ; Check out each line in the designation file . ; Returns to caller when finished processing the designation file. ; ; Incoming: ; A5 -> Indexes impure area. ; During: ; A2 -> Indexes top of input buffer. ; Outgoing: ; Finish with processing. ; CHKOUT: 10$: CALL GETLIN ; Get a line JNE 99$ ; End of file. TSTB @A2 ; Line empty? BEQ 10$ ; Yes..get another. CMPB @A2, #SN$USF ; Is this a user spec? BNE 20$ ; No..must be filespec. CALL CHKUSR ; Yes..check user for match. BR 10$ ; Get next line 20$: BTST #SN%USN, SN.FLG(A5) ; Got a user match? BEQ 10$ ; No..try again. CALL CHKFIL ; Check file size BSET #SN%ANY, SN.FLG(A5) ; Set we tried a file BR 10$ ; Try again. 99$: RTN ; Return to main PAGE ;+************************+ ; CHKFIL * ;+************************+ ; Process an input line to see if the designated specification has ; exceeded the predetermined file size. ; All checking and reporting is handled by this routine. ; Will report when an input line from the SNITCH.ON file is incorrectly ; formatted. ; Returns to calling module. ; ; CHKFIL: LEA A2, SN.BUF(A5) ; Index filename buffer. CLR D.DVR+SN.DDB(A5) ; Preclear driver address. FSPEC SN.DDB(A5) ; Get file specification JNE FOT.ER ; Report file spec error. ; Find the file designated in the SNITCH.DO file. ; LOOKUP SN.DDB(A5) ; Does requested file exist? BEQ 10$ ; Yes..use it. NEGB D.ERR+SN.DDB(A5) ; Set readable file error. CMPB D.ERR+SN.DDB(A5), #D$EFNF ; Is it not found? BEQ 99$ ; Yes..never mind. JMP FOT.ER ; Output error. (return to caller.) 10$: BYP ; Bypass junk. NUM ; Is it a number? JNE NUM.ER ; No..report error. GTDEC ; Get max file size. JMI NUM.ER ; Report errors. (return to caller). MOV D1, SN.SZZ(A5) ; Save max size. CMP D1, SN.DDB+D.FSZ(A5) ; Past max size yet? BHIS 99$ ; No..never mind. CALL SEZ ; Output sez or bypass if already done. CALL REPFIL ; Report file size to big. 99$: RTN ; Return to caller. PAGE ;+************************+ ; REPFIL * ;+************************+ ; Reports to designated users terminal, the file name and the number ; of blocks that the file has exceeded. ; ; Incoming: ; SN.DDB contains offending file name. ; SN.SZZ contains number of blocks that file has exceeded. ; A5 -> Indexes impure area. ; ; REPFIL: PRTTAB -1,12. OFILE SN.DDB(A5),OT$TRM!OT$OFD!OT$OFN!OT$OFP PRTTAB -1,11. TYPE < is > PRTTAB -1,12. TYPE PRTTAB -1,11. TYPE PRTTAB -1,12. MOV SN.SZZ(A5), D1 ; Get maximum size exceeded. DCVT 0,OT$TRM!OT$TSP ; Display it. TYPE CMP D1, #1 ; Was it singular? BEQ 30$ ; Yes..use proper english. TYPE 30$: PRTTAB -1,11. TYPE <.> PRTTAB -1,12. CRLF ; Bump line. RTN ; Return to caller. ;+************************+ ; CHKUSR * ;+************************+ ; Sets up to compare current job user name with data in buffer. ; ; Incoming: ; A5 -> Indexes impure area. ; A2 -> Indexes top of buffer to compare with. ; During: ; D0 =: Size of JOBUSN buffer. ; Outgoing: ; SN.FLG - SN%USN Bit set if match. ; - SN%USN Bit cleared if no match. ; SN.FLG - SN%ANY flag cleared if SN%USN flag set. ; CHKUSR: BTST #SN%USN, SN.FLG(A5) ; Got a user match yet? BEQ 10$ ; No..set up for a match. ; Here we have already had a user match, so now we check to see if ; we have processed any file specs yet. If we haven't processed any files ; yet and we do have a previous user match then we bypass this alternate ; user name and proceed to process some file specs. If we run across any ; more User name designations after we have processed some file specs, ; then we are at a point that a new user name list is indicated. Thus ; we need to check to see if we have another user match before processing ; any more files. ; BTST #SN%ANY, SN.FLG(A5) ; Done any files yet? BEQ 99$ ; No..don' try another name yet. 10$: JOBIDX ; Index this job. LEA A6, JOBUSN(A6) ; Set JOBUSN buffer address. MOV #S..USN, D0 ; Set size of JOBUSN buffer. BCLR #SN%USN, SN.FLG(A5) ; Clear user name match flag. ADD #1, A2 ; Bypass *. CALL CMPBUF ; Got a matching buffer? BNE 99$ ; No..never mind. BSET #SN%USN, SN.FLG(A5) ; Yes..set got a name match. BCLR #SN%ANY, SN.FLG(A5) ; Reset done any files yet flag. 99$: RTN ; Return to caller. ;+************************+ ; GETLIN * ;+************************+ ; Fills a buffer with valid data from input file. ; Packs buffer so that first character is valid. ; Also converts all characters to upper case value. ; ; Incoming: ; A5 -> Indexes impure area. ; During: ; A2 -> Indexes input buffer. ; Outgoing: ; A2 -> Indexes top of input buffer. ; Z flag - Set when valid buffer. ; Cleared when reached end of file. ; Destroys A0, D1 ; GETLIN: 10$: CALL LODBUF ; Load buffer with input line. BNE 99$ ; Finished. LEA A2, SN.BUF(A5) ; Index buffer CMPB @A2, #'; ; First character a comment? BEQ 10$ ; Yes..get next line. TSTB @A2 ; Empty? BEQ 10$ ; Yes..try again. MOV A2, A0 ; Save index. BYP ; Bypass any junk 20$: LIN ; Terminating character? BEQ 30$ ; Yes..must be finished. MOVB (A2)+, D1 ; Get character. UCS ; Make it upper case. MOVB D1, (A0)+ ; Readjust buffer as upper case. BR 20$ ; Try again. 30$: LEA A2, SN.BUF(A5) ; Reindex buffer. CLRB @A0 ; Terminate adjusted buffer. 99$: RTN ; Return to caller. ;+************************+ ; LODBUF * ;+************************+ ; Inputs data from input file to buffer. ; ; Incoming: ; A5 -> Indexes impure area. ; During: ; A2 -> Indexes input buffer. ; Outgoing: ; A2 -> Indexes end of input buffer. ; Z flag - Set if still processing input file. ; - Cleared if reached End of File. ; Destroys D1 ; LODBUF: LEA A2, SN.BUF(A5) ; Index buffer. 10$: FILINB IN.DDB(A5) ; Get a byte. TST D.SIZ+IN.DDB(A5) ; End of file? BEQ 99$ ; Yes.. CMPB D1, #$LF ; End of line? BEQ 20$ ; Yes. MOVB D1, (A2)+ ; Set char in buffer. BR 10$ ; Try again. CLRB @A2 ; Clear end of buffer. 20$: LCC #PS.Z ; Set good flag. RTN ; Return to caller. 99$: LCC #0 ; Set bad flag. RTN ; Return to caller. ;+************************+ ; CMPBUF * ;+************************+ ; Compares two buffers for a match. ; This version pre-converts the buffer we must match with to upper case. ; ; Incoming: ; D0 =: Size of buffer we must match with. ; A2 -> Buffer to compare with. ; A5 -> Indexes impure area. ; A6 -> Buffer we must match with. ; During: ; A0 -> Indexes buffer we must match with. ; D0 =: Decreasing buffer size. ; D1 =: Used to convert to upper case. ; D6 =: Used to indicate match and sets or clears Z. ; Outgoing: ; A2 -> Top of buffer to compare. ; A6 -> Top of buffer we must match with. ; Z flag - Set if a match. ; - Cleared if no match. ; CMPBUF: SAVE A0, A2, D0, D1 ; Save what we use. MOV #-1, D6 ; Preset no match MOV A6, A0 ; Set address we are going to use. 10$: TSTB @A0 ; End of must match buffer? BEQ 30$ ; Yes..check for sure. TSTB @A2 ; End of match buffer? BEQ 99$ ; Yes..no match. MOVB (A0)+, D1 ; Get char. UCS ; Make upper case. CMPB D1, (A2)+ ; Buffers match? BNE 99$ ; No.. SOB D0, 10$ ; Try entire buffer. TST D0 ; End of count? BEQ 40$ ; Yes..got a match. 30$: TSTB @A2 ; End of input buffer? BEQ 40$ ; Yes..must be a match. CMPB (A2)+, #$SPACE ; Is char > than space? BHI 99$ ; Yes..no match. SOB D0, 30$ ; Do rest of buffer. 40$: CLR D6 ; Set match 99$: REST A0, A2, D0, D1 ; Restore what we used. TST D6 ; Set match flag. RTN ; Return to caller. ;+************************+ ; SEZ * ;+************************+ ; Prompts the user that we have a condition. ; Only does this once no matter how many times it is called. ; ; Incoming: ; A5 -> Indexes impure area. ; During: ; Sets SN.FLG if prompt has never been displayed. ; ; Destroys D1 ; SEZ: BTST #SN%SEZ, SN.FLG(A5) ; Sez already been done? BNE 99$ ; Yes..never mind. CALL DING ; Ring bell CRLF ; Bump line. TYPECR ; CRLF ; Bump line. BSET #SN%SEZ, SN.FLG(A5) ; Set we did sez. 99$: RTN ; Return to caller. ;+************************+ ; DING * ;+************************+ ; Rings terminal bell. ; ; Destroys D1 ; DING: MOV #7, D1 ; Set bell. TTY ; Ring bell. RTN ; Return to caller. ;+************************+ ; PAUSE * ;+************************+ ; Pauses program progress until user presses CR. ; ; Incoming: ; A5 -> Indexes impure area. ; ; During: ; D2 =: Random number . ; Outgoing: ; Exits only when user presses RETURN. ; PAUSE: JOBIDX ; Index this job. MOV JOBCPU(A6), D2 ; Get CPU time. AND #^C<^H0FFFFFFF0>, D2 ; Strip CPU time. CMP D2, #S..CMT ; Greater than max comment. BLE 5$ ; No..use it as comment seed. SUB #S..CMT, D2 ; Subtract max comment size. 5$: CRLF ; Bump line 10$: CALL DING ; Ring da bell. PRTTAB -1,11. ; Dim. TYPE PRTTAB -1, 12. ; Bright. TYPE ; PRTTAB -1, 11. TYPE TRMRST D7 ; Get TRM status. ORW #, D7 ; Set image, noecho, data mode. TRMWST D7 ; Set TRM status. KBD ; Get input. CMPB D1, #$CR ; Was it a CR? BEQ 99$ ; Good..finish up. PRTTAB -1,12. ; Bright. PRTTAB -1,3 ; Move up one line. CRLF ; Then bump a line to column 1. PRTTAB -1,9. ; Clear line. CALL ENTERR ; Output comment. JMP 10$ ; Try again. 99$: RTN ; Return to caller. ;+************************+ ; FOT.ER * ;+************************+ ; Reports an error in designation file. (SNITCH.ON) ; Displays error and offending line. ; ; Incoming: ; A5 -> Indexes impure area. ; During: ; A6 -> Indexes DDB error. ; FOT.ER: CALL SEZ ; See if SNITCH has said yet. TYPE <** > OFILE IN.DDB(A5),OT$TRM!OT$OFD!OT$OFN!OT$OFP TYPE < > LEA A6, D.ERR+SN.DDB(A5) ; Index checking DDb. CALL DDBERR ; Display error. TYPECR TTYL SN.BUF(A5) ; Output offending line. CRLF ; Bump line. RTN ; Return to caller. ;+************************+ ; FIL.ER * ;+************************+ ; Reports an error with input file processing. ; Displays offending file name and error. ; ; Incoming: ; A5 -> Indexes impure area. ; During: ; A6 -> Indexes DDB error flag. FIL.ER: CALL SEZ ; See if SNITCH has said yet. OFILE IN.DDB(A5),OT$TRM!OT$OFD!OT$OFN!OT$OFP TYPE < > LEA A6, D.ERR+IN.DDB(A5) ; Index error. CALL DDBERR ; Output error. CRLF ; Bump line. JMP ALLDUN ; Quit. ;+************************+ ; DDBERR * ;+************************+ ; Displays standard DDB error. ; ; Incoming: ; A6 -> Indexes DDB error flag. ; DDBERR: ERRMSG @A6, OT$TRM ; Display DDB error. RTN ; Return to caller. ;+************************+ ; NUM.ER * ;+************************+ ; Reports an numeric error in designation file. (SNITCH.ON) ; Displays error and offending line. ; ; Incoming: ; A5 -> Indexes impure area. NUM.ER: CALL SEZ ; See if SNITCH has said yet. TYPECR TTYL SN.BUF(A5) ; Output offending buffer. RTN ; Return to caller. ;+************************+ ; DATFIL * ;+************************+ ; Default ASCII input file name. ; DATFIL: ASCIZ /OPR:SNITCH/ EVEN ;+************************+ ; ENTERR * ;+************************+ ; Outputs semi random list of remarks. ; ; Incoming: ; D2 =: Seeded with a starting number 1 - max count. ; During: ; D3 =: Maximum comment count. ; A6 -> Indexes comment table. ; Outgoing: ; Random comment displayed. ; ENTERR: CLR D3 ; Clear comparison holder. LEA A6, ERRTBL ; Index error table. MOVW (A6)+, D3 ; Get number of comments. TST D2 ; We at 0? BEQ 10$ ; Yes..set to one. CMP D2, D3 ; Count greater than maximum num. BLOS 30$ ; No..onward. 10$: MOV #1, D2 ; Set to start count. 30$: TSTW @A6 ; End of table. BEQ 99$ ; Yes..then quit. CMMW (A6)+, D2 ; Table match count? BEQ 40$ ; Yes..display comment. ADDW @A6, A6 ; No..offset to next comment. BR 30$ ; Try to match. 40$: ADD #2, A6 ; Bump to comment. TTYL @A6 ; Output comment. TYPE <..> ; Spacer. INC D2 ; Bump count for next try. 99$: RTN ; Return to caller. EVEN ;+************************+ ; ERRTBL * ;+************************+ ; Table of comments. ; First word is number of valid comments. ; ; Rest of table is: ; ; WORD - Number to match with. ; WORD - Bytes to next comment offset. ; ASCII - Comment. ; ; Table is terminate by null word. ; ERRTBL: WORD S..CMT ; Max number of comments. FNCMT 1, FNCMT 2, FNCMT 3, FNCMT 4, FNCMT 5, FNCMT 6, FNCMT 7., FNCMT 8., FNCMT 9., FNCMT 10., FNCMT 11., FNCMT 12., FNCMT 0, EVEN END .