.TITLE LOGFIL - OPEN A LOG FILE FOR RSXNET .IDENT /03.3/ .ENABL LC ;+ ; ; Free software BY ; Project Software & Development, Inc. ; ; This software is furnished for free and may be used and copied as ; desired. This software or any other copies thereof may be provided or ; otherwise made available to any other person. No title to and ; ownership of the software is hereby transferred or allowed. ; ; The information in this software is subject to change without notice ; and should not be construed as a commitment by PROJECT SOFTWARE ; AND DEVELOPMENT, INC. ; ; PROJECT SOFTWARE assumes no responsibility for the use or reliability ; of this software on any equipment whatsoever. ; ; Project Software & Development, Inc. ; 14 Story St. ; Cambridge, Ma. 02138 ; 617-661-1444 ; ; ; Title: LOGFIL ; Author: Robin Miller ; Date: February 18, 1982 ; ; Description: ; ; Modification History: ; ;- .ENABL AMA .NLIST BEX .MCALL ALUN$, DIR$, EXIT$S, QIO$, QIOW$, QIOW$S .MCALL FSRSZ$, FDBDF$, FDAT$A, FDOP$A, FDRC$A, FDBF$A .MCALL CLOSE$, GET$, PUT$, NMBLK$ ; ; Local/Global Equates. ; NULL = 0 ; ASCII FOR NULL LF = 12 ; ASCII FOR LINE FEED FF = 14 ; ASCII FOR FORM FEED CR = 15 ; ASCII FOR CARRIAGE RETURN ESC = 33 ; ASCII FOR ESCAPE SPACE = 40 ; ASCII FOR SPACE CMDSIZ = 80. ; MAXIMUM SIZE OF COMMANDS FILSIZ == 512. ; MAXIMUM INPUT RECORD SIZE LOGSIZ == 512. ; MAXIMUM LOGFILE RECORD SIZE ; Storage area: FILNAM::.BLKB 50. ; STORAGE FOR ASCII FILE NAME FILLEN::.WORD 0 ; LENGTH OF FILE NAME IN BYTES LOGNAM::.BLKB 50. ; STORAGE FOR LOG FILE NAME SOFNAM::.WORD 0 ; START OF FILE NAME SOFUIC::.WORD 0 ; START OF UIC ; Messages: LOGQ: .ASCIZ %Enter the name of the logfile (RSXNET.LOG): % LOGH: .ASCIZ %LOG_FILE% OPENQ: .ASCIZ %The log file is already open, open a new file (Yes) ? % OPENH: .ASCIZ %LOG_FILE OPEN% LOCALQ: .ASCIZ %Do you want local output in the logfile (Yes) ? % LOCALH: .ASCIZ %LOG_FILE LOCAL_OUTPUT% .EVEN ; File Descriptor Blocks. FSRSZ$ 3 ; MAXIMUM OF 3 FILES OPEN INFDB:: FDBDF$ ; FDB FOR INPUT FILE FDAT$A R.VAR,FD.CR,,, ; VARIABLE LENGTH RECORDS FDRC$A ,LBUFF,FILSIZ ; BUFFER ADDR / MAX SIZE FDOP$A INLUN,,SYSDNB,FO.RD!FA.SHR ; OPEN FOR SHARED READ FDBF$A INEFN,FILSIZ,, ; EFN / BUFFER SIZE OUTFDB:: FDBDF$ ; FDB FOR OUTPUT FILE FDAT$A R.VAR,FD.CR,,-10.,-10. ; VARIABLE LENGTH RECORDS FDRC$A ,RBUFF,FILSIZ ; BUFFER ADDR / MAX SIZE FDOP$A OUTLUN,,SYSDNB,FO.WRT!FA.NSP ; OPEN FOR WRITE FDBF$A OUTEFN,FILSIZ,, ; EFN / BUFFER SIZE SYSDNB: NMBLK$ ,,,SY,0 ; DEFAULT TO DEVICE SY0: CMDFDB:: FDBDF$ ; FDB FOR COMMAND FILE FDAT$A R.VAR,FD.CR,,, ; VARIABLE LENGTH RECORDS FDRC$A ,INCMD,CMDSIZ ; BUFFER ADDR / MAX SIZE FDOP$A CMDLUN,,CMDDNB,FO.RD!FA.SHR ; OPEN FOR SHARED READ FDBF$A CMDEFN,FILSIZ,, ; EFN / BUFFER SIZE CMDDNB: NMBLK$ ,CMD,,SY,0 ; DEFAULT FOR COMMAND FILES LOGFDB:: FDBDF$ ; FDB FOR LOG FILE FDAT$A R.VAR,,,-10.,-10. ; VARIABLE LENGTH RECORDS FDRC$A FD.PLC,LOGBUF,LOGSIZ ; LOCATE MODE FDOP$A LOGLUN,,LOGDNB,FO.WRT!FA.NSP ; OPEN FOR WRITE FDBF$A LOGEFN,LOGSIZ,, ; INIT BLOCK BUFFER SECTION LOGDNB: NMBLK$ RSXNET,LOG,,SY,0 ; DEFAULT LOG FILE NAME LOGCNT::.WORD 0 ; # OF BYTES IN LOG BUFFER LOGBUF::.BLKB LOGSIZ ; LOG FILE BUFFER ;+ ; ; Open a logfile for RSXNET. ; ;- LOGFIL:: CALL $SAVAL ; SAVE ALL REGISTERS MOV #INCMD,R1 ; SET UP THE INPUT ADDRESS CALL GETINI ; ELSE GET THE COMMAND LINE BCC 50$ ; IF CC, OK CONTINUE 10$: TST LOGFDB+F.BDB ; IS THE LOGFILE OPEN ? BEQ 40$ ; IF EQ, NO (CONTINUE) ; Logfile already open, ask if a new logfile should be open. 20$: CALL CLOINI ; CLOSE THE LOGFILE IF OPEN MOV #INCMD,R1 ; ADDRESS FOR RESPONSE MOV #OPENQ,R2 ; ADDRESS OF PROMPT MOV #OPENH,HLPADR ; ADDRESS OF HELP STRING CALL PROMPT ; ASK THE QUESTION TSTB BCKFLG ; WANT TO BACKUP QUESTION ? BNE 100$ ; IF NE, YES (RETURN) 30$: CMPB (R1),#'N ; DID USER TYPE "NO" ? BEQ 100$ ; IF EQ, YES (RETURN) CALL FLUSH ; FLUSH THE LOGFILE BUFFER CALL CLOLOG ; AND CLOSE THE LOGFILE ; See if local output should go to logfile. 40$: MOV #INCMD,R1 ; ADDRESS FOR USER INPUT MOV #LOCALQ,R2 ; ADRRESS OF QUESTION MOV #LOCALH,HLPADR ; ADDRESS OF HELP STRING CALL PROMPT ; PROMPT THE USER TSTB BCKFLG ; DID USER ASK TO BACKUP ? BNE 100$ ; IF EQ, YES (RETURN) 50$: MOV #-1,LOCFLG ; INITIALIZE FLAG TO TRUE CMPB (R1),#'N ; DISABLE LOCAL OUTPUT ? BNE 60$ ; IF NE, NO (CONTINUE) CLR LOCFLG ; YES, RESET THE FLAG ; Ask the user for the logfile name. 60$: CALL GETINI ; TRY TO READ FROM .INI FILE BCC 80$ ; IF CC, GOT A COMMAND LINE 70$: CALL CLOINI ; CLOSE THE .INI FILE (IF OPEN) MOV #INCMD,R1 ; ADDRESS OF FILE SPEC BUFFER MOV #LOGQ,R2 ; LOG FILE QUESTION ADDRESS MOV #LOGH,HLPADR ; ADDRESS OF HELP STRING CALL PROMPT ; GET FILE SPECIFICATION TSTB BCKFLG ; WANT TO BACKUP QUESTION ? BNE 40$ ; IF NE, YES ; Try to open the log file. 80$: MOV #LOGFDB,R0 ; ADDRESS OF LOG FILE FDB MOV #LOGFDB+F.FNB,R1 ; ADDRESS OF LOG FILE FNB MOV #INCMD,R2 ; ADDRESS OF LOG FILE NAME MOV #'W,R3 ; SPECIFY OPEN FOR WRITE CALL OPEN ; GO OPEN THE FILE BCC 90$ ; IF CC, SUCCESS CALL FILERR ; ELSE REPORT THE ERROR BR 70$ ; AND TRY AGAIN ; Log file open, now save the log file name. 90$: CALL MAKNAM ; MAKE THE FILE NAME MOV #LOGNAM,R0 ; STORE LOG FILE NAME HERE MOV #FILNAM,R1 ; ADDRESS OF THE FILE NAME CALL MOVE ; MOVE FROM FILNAM TO LOGNAM 100$: RETURN .SBTTL MAKNAM - MAKE EXPANDED FILE NAME ;+ ; ; MAKNAM - Make expanded file name. ; ; This routine is called BEFORE openning a file to make a fully ; expanded file name in the FILNAM buffer. ; ; Inputs: ; R0 = The FDB address. ; ; Outputs: ; File name stored in FILNAM buffer. ; ;- MAKNAM:: CALL $SAVAL ; SAVE R0 - R5 MOV R0,R4 ; SAVE THE FDB ADDRESS ADD #F.FNB,R0 ; POINT TO THE FNB MOV R0,R5 ; COPY THE FNB ADDRESS MOV #FILNAM,R0 ; STORE FILE NAME HERE ; Device name and unit number. MOV N.DVNM(R5),(R0)+ ; COPY THE DEVICE NAME MOV N.UNIT(R5),R1 ; GET BINARY UNIT NUMBER CLR R2 ; SET FOR ZERO SUPRESSION CALL $CBTMG ; CONVERT IT TO OCTAL ASCII MOVB #':,(R0)+ ; MOVE IN A COLON MOV R0,SOFUIC ; SAVE POINTER TO UIC ; Copy the UIC. MOV F.DSPT(R4),R3 ; THE DATASET DESCRIPTOR BEQ 20$ ; IF EQ, THERE IS NONE MOV 4(R3),R2 ; GET THE UIC BYTE COUNT BEQ 20$ ; IF EQ, THERE IS NONE MOV 6(R3),R3 ; COPY THE STRING ADDRESS 10$: MOVB (R3)+,(R0)+ ; MOVE UIC TO BUFFER SOB R2,10$ ; BR TILL DONE BR 40$ ; AND CONTINUE ; No UIC specified, so use the default UIC. 20$: CALL .RDFUI ; READ DEFAULT UIC 30$: MOV R0,R2 ; COPY OUTPUT ADDRESS MOV R1,R3 ; COPY BINARY UIC CLR R4 ; LEADING ZEROS/SEPARATORS CALL .PPASC ; CONVERT BINARY UIC TO ASCII MOV R2,R0 ; COPY NEW BUFFER POINTER ; File name, type, and version. 40$: MOV R0,SOFNAM ; SAVE POINTER TO FILE NAME MOV N.FNAM(R5),R1 ; GET 1ST PART OF FILE NAME CALL $C5TA ; CONVERT RADIX-50 TO ASCII MOV N.FNAM+2(R5),R1 ; GET 2ND PART OF FILE NAME BEQ 50$ ; IF EQ, DONE CALL $C5TA ; CONVERT IT TO ASCII MOV N.FNAM+4(R5),R1 ; GET 3RD PART OF FILE NAME BEQ 50$ ; IF EQ, DONE CALL $C5TA ; CONVERT IT TO ASCII 50$: CMPB #SPACE,-(R0) ; LAST CHARACTER A SPACE ? BEQ 50$ ; IF EQ, YES INC R0 ; NO, ADJUST POINTER MOVB #'.,(R0)+ ; MOVE IN A PERIOD MOV N.FTYP(R5),R1 ; GET FILE TYPE BEQ 60$ ; IF EQ, NONE CALL $C5TA ; AND CONVERT TO ASCII 60$: CMPB #SPACE,-(R0) ; LAST CHARACTER A SPACE ? BEQ 60$ ; IF EQ, YES INC R0 ; NO, ADJUST POINTER MOV N.FVER(R5),R1 ; GET FILE VERSION BEQ 70$ ; IF EQ, NONE MOVB #';,(R0)+ ; MOVE IN A SEMI-COLON CLR R2 ; SUPPRESS 0'S CALL $CBOMG ; VERSION # IS OCTAL 70$: MOVB #CR,(R0)+ ; MOVE IN THE MOVB #LF,(R0)+ ; CARRIAGE CONTROL CLRB (R0) ; TERMINATE THE STRING SUB #FILNAM,R0 ; CALCULATE THE BYTE COUNT MOV R0,FILLEN ; AND STORE IT RETURN .SBTTL WRTLOG - RSXNET LOGFILE WRITE ;+ ; ; WRTLOG - WRITE THE CURRENT RSXNET SESSION TO A LOGFILE ; ; ; Inputs: ; R2 = Address of the buffer to be written. ; R3 = Byte count. ; ; Outputs: ; All registers are preserved. ; ;- WRTLOG:: CALL $SAVAL TST LOGFDB+F.BDB ; IS THE LOGFILE OPEN ? BEQ 40$ ; IF EQ, NO (SKIP IT) TST R3 ; ANYTHING TO MOVE BEQ 40$ ; IF EQ, NO MOV #LOGBUF,R4 ; POINT TO LOGFILE BUFFER MOV LOGCNT,R5 ; COPY CURRENT COUNT ADD R5,R4 ; POINT TO NEXT AVAILABLE BYTE 10$: MOVB (R2)+,(R4)+ ; COPY DATA TO LOG FILE INC R5 ; COUNT THIS BYTE CMP R5,#LOGSIZ ; IS THE BUFFER FULL ? BLT 20$ ; IF LT, NO MOV R5,LOGCNT ; SET NEW BUFFER COUNT CLR R5 ; CLEAR THE COUNT CALL FLUSH ; WRITE THIS BUFFER BCS 30$ ; IF CS, PUT ERROR MOV #LOGBUF,R4 ; START OF BUFFER AGAIN 20$: DEC R3 ; DECREMENT THE COUNT BNE 10$ ; IF NE, MORE TO GO 30$: MOV R5,LOGCNT ; UPDATE THE LOG BUFFER COUNT 40$: RETURN .SBTTL FLUSH - WRITE THE BUFFER TO THE LOGFILE ;+ ; ; FLUSH - Write the output buffer to the logfile ; ;- FLUSH:: CALL $SAVAL ; SAVE ALL REGISTERS TST LOGFDB+F.BDB ; IS THE LOGFILE OPEN ? BEQ 10$ ; IF EQ, NO (SKIP IT) TST LOGCNT ; ANYTHING TO WRITE ? BEQ 10$ ; IF EQ, NO PUT$ #LOGFDB,#LOGBUF,LOGCNT ; WRITE THE BUFFER TO THE LOG FILE BCC 10$ ; IF CC, OK CALL FILERR ; ELSE ERROR 10$: CLR LOGCNT ; BYTE COUNT OF THE OUTPUT BUFFER RETURN .SBTTL CLOLOG - CLOSE THE LOG FILE ;+ ; ; CLOLOG - Close and truncate the logfile (if open). ; ;- CLOLOG:: MOV R0,-(SP) ; SAVE R0 FIRST MOV #LOGFDB,R0 ; ADDRESS OF LOGFILE FDB TST F.BDB(R0) ; IS THE LOGFILE OPEN ? BEQ 10$ ; IF EQ, NO (SKIP IT) CALL .TRNCL ; CLOSE AND TRUNCATE FILE CLRB LOGNAM ; SHOW NO LOGFILE NAME 10$: MOV (SP)+,R0 ; RESTORE R0 RETURN .END