.title BRKTHRU - Broadcast messages to users ; ; Libraries/macros ; .library "MACROS" setup $BRKDEF .psect $DATA, long,wrt,noexe,noshr ; ; CLI keywords ; cli_message: .ascid "MESSAGE" cli_cluster: .ascid "CLUSTER" cli_all: .ascid "ALL" cli_to: .ascid "TO" ; ; Message and username descriptors ; message_d: descriptor ,,,D message: descriptor username: descriptor ,,,D to_username: descriptor ,,,D err_msg: descriptor ,,,D ; ; Message buffer FAO string and output buffer ; esc = 27 bel = 7 cr = 13 msg_fao: .ascid "[1m""!69AS(!AS)""[m" msg_buf: descriptor 1$, 100 1$: .blkb 100 ; ; Other bits. ; iosb: .blkw 4 jpi_username: .long JPI$_USERNAME msg_code: .blkl .psect $CODE, nowrt,exe,shr .entry BRKTHRU, ^M ; ; Get our username for the message text ; call LIB$GETJPI, jpi_username,0,0,0, username status R0 call STR$TRIM, username, username status R0 ; ; Get message string to broadcast ; call CLI$GET_VALUE, cli_message, message_d status R0 ; ; Remove quotes, using a separate descriptor. Increment address (and decrement ; length accordingly) to remove initial quote, remove final quote (by ; decrementing length) only of initial one was found. ; movq message_d, message cmpb @message_d+4, #^A/"/ bneq 5$ incl message+4 decw message cvtwl message, R0 addl2 message+4, R0 cmpb -1(R0), #^A/"/ bneq 5$ decw message ; ; If /CLUSTER specified then broadcast throughout cluster ; 5$: movl #BRK$M_SCREEN!BRK$M_BOTTOM, R7 call CLI$PRESENT, cli_cluster blbc R0, 1$ addl2 #BRK$M_CLUSTER, R7 ; ; If /ALL was specified, then broadcast to all users. Set flag value ; and do it. ; 1$: call CLI$PRESENT, cli_all blbc R0, 6$ movl #BRK$C_ALLUSERS, R6 brw do_broadcast ; ; If /TO was specified, then get the username to send to from the command ; line, else use our own username. ; 6$: call CLI$PRESENT, cli_to blbc R0, 2$ call CLI$GET_VALUE, cli_to, to_username status R0 brb 3$ 2$: call LIB$SCOPY_DXDX, username, to_username status R0 3$: movl #BRK$C_USERNAME, R6 ; ; Format the message and send it ; do_broadcast: $FAO_S ctrstr=msg_fao, outbuf=msg_buf, outlen=msg_buf, - p1=#message, p2=#username status R0 $BRKTHRUW_S msgbuf=msg_buf, sendto=to_username, sndtyp=R6, - iosb=iosb, flags=R7, - reqid=#BRK$C_URGENT, timout=#5 ; ; Display results. ; Get message text if anything went wrong and display. ; blbc R0, 1$ cvtwl iosb, R0 1$: blbs iosb, 2$ movl R0, msg_code call LIB$SYS_GETMSG, msg_code, 0, err_msg status R0 call LIB$PUT_OUTPUT, err_msg status R0 ; ; Say how many terminals we hit. ; 2$: printf <"!UW terminal!%S notified">, iosb+2 ; ; And how many we missed, if any. ; tstw iosb+4 beql 3$ printf <"Timed out on !UW terminal!%S">, iosb+4 3$: ret .end BRKTHRU