.TITLE SMPSRT DCN/MTP USER PROCESS HOST SORT .SBTTL SYSTEM AND MODULE DEFINITONS .NLIST BEX .ENABL LC ; ; Pdp11/dcn basic operating system - dcn/mtp user process host sort ; ; External symbols ; .GLOBL RDLIN,RDASC,RDDEC,HASH .GLOBL FLAGS .GLOBL ABOR,GHOST,STATE,FILFCB .GLOBL MRCTAB,MRCSIZ,ARGBLK,SRCRUT,OPNBLK ; ; Entry symbols ; .GLOBL SMPSRT ; ; System definitions ; .ASECT .MCALL .COM,.CHR ;dcnlib definitions .MCALL .READW ;rt-11 macros .MCALL DFCON,DFFCB,CALL,FORMAT ;netlib macros .COM ;define common data .CHR ;define ascii character codes DFCON ;define connection block DFFCB ;define file control block ; ; Module definitions ; ; Assembly parameters ; FILSIZ = 1 ;mail buffer size (blocks) RUTSIZ = 256. ;max route string length .PAGE .SBTTL SEARCH MAIL FILE AND CONSTRUCT INDEX TABLE ; .PSECT $BOSI,RO,I ; ; Search file for unsent messages ; SMPSRT: MOV #FMTBGN,R1 ;clear erasable storage 1$: CLR (R1)+ CMP R1,#FMTEND BLO 1$ MOV #FILBUF,FILFCB+FCBBUF ;set fcb info CLR FILFCB+FCBBLK MOV #4,STATE ;initialize other things MOV #MRCTAB,MRCPTR MOV #MRCTAB,MRCHDR SRC01: MOV FILBCT,R0 ;is text still in buffer BNE 1$ ;branch if yes .READW #ARGBLK,#0,FILFCB+FCBBUF,#FILSIZ*256.,FILFCB+FCBBLK BCS 2$ ;branch if error MOV R0,R1 ;update block number SWAB R1 BIC #^C377,R1 ADD R1,FILFCB+FCBBLK ASL R0 ;compute byte count MOV FILFCB+FCBBUF,FILPTR MOV R0,FILBCT 1$: MOV FILPTR,R1 ;get text pointer ADD STATE,PC ;go to state segment JMP . ;0 idle JMP SRC10 ;4 file header JMP SRC20 ;10 transport header JMP SRC30 ;14 message ; 2$: TSTB @#52 ;is status eof BEQ SRC05B ;branch if yes FORMAT #COM33,#FILFCB ;file read error BR SRC05A ; SRC05C: FORMAT #COM49 ;recipient table full SRC05B: CMP STATE,#4 ;eof. is this header scan BNE SRC05 ;branch if no CLR @MRCPTR ;yes. zero backstop JSR PC,SORT ;sort table RTS PC ; SRC05: FORMAT #COM34,#FILFCB ;invalid file format SRC05A: JSR PC,ABOR RTS PC ; SRC30: CMP R0,TXTCNT ;text. compute bytes skipped BLOS 1$ MOV TXTCNT,R0 1$: ADD R0,FILPOS+2 ;update pointers ADC FILPOS ADD R0,FILPTR SUB R0,FILBCT SUB R0,TXTCNT BNE 2$ ;branch if more TST RCPCNT ;were there any recipients BEQ 4$ ;branch if no MOV MRCHDR,R1 ;complete remaining fields 3$: MOV HDRPOS+2,10.(R1) ;compute text size SUB MSGPOS+2,10.(R1) MOV FILPOS+2,12.(R1) ;compute text offset SUB MSGPOS+2,12.(R1) ADD #16.,R1 DEC RCPCNT BNE 3$ 4$: MOV FILPOS,MSGPOS ;save position of next file header MOV FILPOS+2,MSGPOS+2 MOV #4,STATE CMP MRCPTR,#16.*MRCSIZ+MRCTAB ;did table overflow BHIS SRC05C ;branch if yes 2$: JMP SRC01 ; SRC10: CMPB #SUB,@R1 ;file header. is this end of file BEQ SRC05B ;branch if yes MOV HDRCNT,R0 ;no. copy text to buffer CMP R0,#RUTSIZ ;did it overflow BHIS SRC05 ;branch if yes ADD #HDRBUF,R0 ;no. stash byte MOVB @R1,@R0 ADD #1,FILPOS+2 ;update pointers ADC FILPOS INC FILPTR DEC FILBCT BICB #^C177,@R0 CMPB @R0,#040 BLO 1$ INC HDRCNT 1$: CMPB #LF,@R0 ;is header complete BNE 3$ ;branch if no CLRB @R0 ;yes. plant backstop CLR HDRCNT JSR PC,PRS10 ;parse file header 3$: JMP SRC01 ; SRC20: MOV HDRCNT,R0 ;transport header. copy text to buffer CMP R0,#RUTSIZ ;did it overflow BHIS SRC05D ;branch if yes ADD #HDRBUF,R0 ;no. stash byte MOVB @R1,@R0 ADD #1,FILPOS+2 ;update pointers ADC FILPOS INC FILPTR DEC FILBCT DEC TXTCNT ;is text long enough BEQ SRC05D ;branch if no BICB #^C177,@R0 CMPB @R0,#040 BLO 1$ INC HDRCNT 1$: CMPB #LF,@R0 ;is header complete BNE 3$ ;branch if no CLRB @R0 ;yes. plant backstop CLR HDRCNT JSR PC,PRS20 ;parse transport header 3$: JMP SRC01 ; SRC05D: JMP SRC05 ; ; Subroutine to parse file header line ; Arg = header line ; PRS10: MOV #HDRBUF,R0 ;decode header JSR PC,RDLIN 2$: JSR PC,RDASC ;scan to comma BEQ 1$ ;branch if bad format CMP R0,#', BNE 2$ ;branch if not found JSR PC,RDDEC ;get byte count MOV R0,TXTCNT JSR PC,RDDEC ;get flag bits MOV MRCPTR,MRCHDR MOV #10,STATE MOV FILPOS,HDRPOS MOV FILPOS+2,HDRPOS+2 1$: RTS PC ; ; Subroutine to parse transport header line ; Arg = header line ; PRS20: MOV #HDRBUF,R0 ;decode header JSR PC,RDLIN JSR PC,RDASC ;get line type CMP R0,#'R ;is it "return-path:" BNE 2$ ;branch if no MOV #14,STATE ;yes. upstate RTS PC ; 2$: CMP R0,#'M ;is it unsent BNE 4$ ;branch if no MOV SRCRUT,R0 ;yes. was source route specified BNE 3$ ;branch if yes JSR PC,GHOST ;yes. decode host address BCS 4$ ;branch if err0r 3$: CMP MRCPTR,#16.*MRCSIZ+MRCTAB ;did table overflow BHIS 4$ ;branch if yes INC RCPCNT MOV MRCPTR,R1 ;construct table entry MOV OPNBLK+CONRMT,(R1)+ ;0 internet address MOV OPNBLK+CONRMT+2,(R1)+ MOV MSGPOS,(R1)+ ;4 file header position MOV MSGPOS+2,(R1)+ MOV HDRPOS+2,@R1 ;8 mrcp header offset SUB MSGPOS+2,(R1)+ CLR (R1)+ ;10 text offset CLR (R1)+ ;12 end of text offset MOV R0,(R1)+ ;14 route string pointer MOV R1,MRCPTR 4$: MOV FILPOS,HDRPOS MOV FILPOS+2,HDRPOS+2 RTS PC ; ; Subroutine to sort table ; SORT: MOV R2,-(SP) ;make some yummy MOV R3,-(SP) MOV R4,-(SP) MOV #MRCTAB,R2 ;simple exchange sort 5$: MOV R2,R3 1$: CMPB @R2,@R3 ;compare entries BLO 2$ BHI 4$ CMPB 1(R2),1(R3) BLO 2$ BHI 4$ CMPB 2(R2),2(R3) BLO 2$ BHI 4$ CMPB 3(R2),3(R3) BLOS 2$ 4$: MOV R2,R0 ;exchange entries MOV R3,R1 MOV #8.,R4 3$: MOV @R0,-(SP) MOV @R1,(R0)+ MOV (SP)+,(R1)+ SOB R4,3$ 2$: ADD #16.,R3 ;advance to next entry CMP R3,MRCPTR BLO 1$ ;branch if not done ADD #16.,R2 ;advance ot next entry CMP R2,MRCPTR BLO 5$ ;branch if not done MOV (SP)+,R4 MOV (SP)+,R3 MOV (SP)+,R2 RTS PC .PAGE .SBTTL TABLES, TEXT STRINGS AND VARIABLES ; ; Data segment ; .PSECT $BOSD,RO,D ; ; Format strings ; COM33: .ASCIZ '?SMTP-F-Read error on file ^F' COM34: .ASCIZ '?SMTP-F-Invalid format on file ^F' COM49: .ASCIZ '?SMTP-W-Recipient table full' .EVEN ; .PSECT $ERAS,RW,I ; ; Variables ; FMTBGN = . ;beginning of erasable storage RCPCNT: .BLKW 1 ;recipients count FILPTR: .BLKW 1 ;buffer pointer FILBCT: .BLKW 1 ;buffer byte count remaining HDRCNT: .BLKW 1 ;header byte count TXTCNT: .BLKW 1 ;remaining byte count FILPOS: .BLKW 2 ;current position MSGPOS: .BLKW 2 ;file header position HDRPOS: .BLKW 2 ;header position MRCPTR: .BLKW 1 ;recipient table pointer MRCHDR: .BLKW 1 ;pointer to current message HDRBUF: .BLKB RUTSIZ ;header buffer .EVEN FILBUF: .BLKW FILSIZ*256. ;file buffer FMTEND = . ;end of erasable storage ; .END