.mcall .MODULE .MODULE ONLINE,comment=,release=V09,version=05 ; Copyright (c) 1985 Horizon Data Systems ; 1901 Wildflower Terrace ; Richmond, Va. ; Published in May 1985 TSX-Plus Newsletter, with ; permission to freely copy. ; This copy created, modified, and maintained by Bob Schor. ;**************************************************************; ; ; ; Copyright (c) 1986 Bob Schor ; ; Rockefeller University ; ; 1230 York Ave ; ; New York, NY 10021 ; ; ; ; All rights reserved. May not be copied without this notice. ; ; ; ;**************************************************************; ;**************************************************************; ; ; ; Copyright (c) 1989 Bob Schor ; ; Eye and Ear Institute ; ; 203 Lothrop St. ; ; Pittsburgh, PA 15213 ; ; ; ; All rights reserved. May not be copied without this notice. ; ; ; ;**************************************************************; ; ONLINE sends a user-defined message to all TSX-Plus time-sharing ; lines that are not presently logged on. It works by using an ; available extra CL unit to talk to each line in turn. ; Will use highest available CL line (CL0 - CL7), assumes it is ; "extra" (i.e. CLXTRA in TSGEN is >= 1). ; Requires terminal privilege to run (to assign CL lines). ; On invocation, you can be prompted for the single-line message ; to be sent to all un-logged terminals (if HELLO not defined) ; Note that if included in DETACH.TSX, this can notify all terminals ; that TSX is up and running. ; Conditional parameters -- ; V51C Flag for TSX version -- 5.1C allows interrogating ; CL units for message received. ; HELLO If defined, gives "standard" TSX message ; LINEID If defined, identifies lines in message ;b schor january, 1986 ;modifications -- ; feb, 1986 TSX 6.01 requires terminal privilege ; Looks for un-allocated CL unit ; mar, 1986 Bugs in feb mod fixed ; apr, 1986 Tests to fix mysterious CL hangs by clearing ; CL handler, checking for XOFF, etc. ; Use SUMAC package ; jun, 1988 .MODULE added ; may, 1989 Psects $CODE and $DATA added ;define our .psects before calling SUMAC to force ours low .psect $code ro,i,lcl,rel,con .psect $data rw,d,lcl,rel,con ;uses SUMAC for structured macro code .library /lib:sumac/ ;use external macro definition file .mcall SUMAC SUMAC ;initialization macro .dsabl gbl ;if undefined symbol, force error HEAD sysmac, .mcall .PRINT ;to announce identification .mcall .EXIT ;return to RT-11 on errors .mcall .GTLIN ;used if "general" message, hello=0 .mcall .LOOKUP, .PURGE, .WRITW ;for CL output HEAD const, v51c = 1 ; This is at least v5.1C hello = 1 ; Use pre-defined message lineid = 1 ; Identify line .iif ndf v51c v51c = 0 ; Default, turn off .iif ndf hello hello = 0 .iif ndf lineid lineid = 0 bell = 7 ; Ascii bell cr = 15 lf = 12 space = 40 maxchn = 15 ; Max channel for i/o errbyt = 52 ; Monitor error byte noline = 3 ; Line-not-present code .if ne v51c ; CL definitions for version 5.1c clear = 201 ; CL .SPFUN to clear handler clstat = 204 ; CL .SPFUN to get status clrio = 205 ; CL .SPFUN to terminate i/o outchk = 262 ; CL .SPFUN output check code offsnt = 1 ; CL status, XOFF has been sent offrcd = 2 ; CL status, XOFF has been received cardet = 4 ; CL status, carrier detect .endc tsxemt = emt+375 ; TSX emt code sezemt = 155*400 ; Seize EMT code .if eq v51c .mcall .TWAIT ; Early CL handler, need to "wait" .iff .mcall .SPFUN ; After TSX 5.1c, use CL .SPFUN .endc HEAD seize, .macro SEIZE line mov #sezemt, area ; Build emt arguments mov clunit, area+2 mov line, area+4 mov #area, r0 ; r0 points to arguments tsxemt ; Execute EMT .endm SEIZE .psect $code LABEL online, NOTE .PRINT #modnam ;identify module NOTE .if eq hello NOTE PNOTE mov #msgbuf, r3 ; Point to user message text .GTLIN r3 ; Get message WHILEB (r3), ne ; Look for terminal null inc r3 ENDWHILE .iff mov #msgbuf, r3 ; Point to user message text mov #welcom, r0 ; Point to default message REPEAT movb (r0)+, (r3)+ ; Copy string UNTILB eq dec r3 ; Back up over terminal null .endc mov #trail, r0 ; Point to trailing string REPEAT movb (r0)+, (r3)+ ; Copy string UNTILB eq ; Up to terminal null sub #msg, r3 ; Calculate length of message asr r3 ; Make word count ;first find free CL unit clr line ; Initialize line counter inc line ; Test first line mov #^d7, clunit ; Start testing CL units from the top REPEAT SEIZE line ; Seize the current line IF cc ; If successful, PNOTE TYP.8 clunit NOTE .PURGE chan ; Close channel SEIZE #0 ; Drop CL clr line ; Signal success ELSE CASEB @#errbyt, cpri: NOTE clr line ; Signal time to quit ENDEL cnoc: PNOTE TYP.8 clunit NOTE < invalid> dec clunit ; Try another cl unit ENDEL cdon: NOTE clr line ; Signal time to quit ENDEL cuna: PNOTE TYP.10 line PNOTE < assigned to CL unit > TYP.8 clunit NOTE dec clunit ; Try another unit ENDEL clog: PNOTE TYP.10 line PNOTE < accessed through CL unit > TYP.8 clunit NOTE clr line ; Success ENDEL cbus: PNOTE TYP.8 clunit NOTE < busy> dec clunit ; Try another unit ENDEL ENDCASE ENDIF UNTIL line, eq ; Loop until line-done signal add clunit, devblk ; Make .rad50 /CLn/ ;send message to each time-sharing line clr line ; Initialize line counter REPEAT inc line ; Test next line .iif ne lineid INVOKE encode ; Encode line number in message SEIZE line ; Seize the current line IF cc ; If successful, INVOKE lookup ; Open channel .if eq v51c .WRITW #area, chan, #msg, r3, #0 ; Msg .TWAIT #area, #time ; Time out wait .iff .SPFUN #area, chan, #clear ; Clear CL .SPFUN #area, chan, #clrio ; and buffer .SPFUN #area, chan, #clstat, #status ; Status bit #offrcd, status ; Check XOFF rec'd IF ne ; If so, .SPFUN #area, chan, #clear ; Re-clear .SPFUN #area, chan, #clrio ELSE .WRITW #area, chan, #msg, r3, #0 ; Msg REPEAT ; Check for done .SPFUN #area, chan, #outchk, #left UNTIL left, eq ; No more left ENDIF .endc .PURGE chan ; Close channel SEIZE #0 ; Drop CL PNOTE TYP.10 line NOTE < signalled> ELSE CASEB @#errbyt, priv: NOTE clr line ; Signal time to quit ENDEL nocl: PNOTE TYP.8 clunit NOTE < invalid> clr line ; Signal time to quit ENDEL done: NOTE clr line ; Signal time to quit ENDEL unav: PNOTE TYP.10 line NOTE < assigned to CL unit> ENDEL log: PNOTE TYP.10 line NOTE < logged on> ENDEL busy: PNOTE TYP.8 clunit NOTE < busy> clr line ; Signal time to quit ENDEL ENDCASE ENDIF UNTIL line, eq ; Loop until line-done signal .EXIT ; Return to TSX PROCED lookup, .LOOKUP #area, chan, #devblk ; Open channel IF cs ; If channel busy, dec chan ; Try next one IF ge br lookup ; Loop if legal channel ELSE NOTE .EXIT ENDIF ENDIF ENDPROC .if ne lineid PROCED encode, mov line, r1 ; Set up line number in r0 clr r0 ; Set up division div #^d10, r0 ; Divide by 10 add #'0, r1 ; Make characters IF r0, eq ; Supress leading blanks mov #space, r0 ELSE add #'0, r0 ENDIF mov #lnum, r2 ; Point to output area movb r0, (r2)+ ; Save two digits movb r1, (r2)+ ENDPROC .endc .psect $data HEAD var, line: .word 0 ; Current line number clunit: .word 0 ; Free CL unit number chan: .word maxchn ; Channel for i/o area: .blkw 6 ; EMT arguments here devblk: .word ^RCL0 ; Device name to look up CL0 .rad50 /TEMP TMP/ ; Dummy file name msg: .ascii ; Message header .if ne lineid .ascii /Line / ; Line id lnum: .ascii /nn -- / .endc msgbuf: .blkb 81. ; Message buffer .blkb 4. ; Room for trailer trail: .asciz ; Message trailer welcom: .asciz /TSX is now running/ ; Default message .even .if eq v51c time: .word 0, 60. ; One second timer block .iff left: .word 0 ; Number of bytes left to transfer status: .word 0 ; CL line status .endc LABEL modnam, .NLCSI ;generates .asciz module string .even ENDEND .end online