.Title Promptsub Executive mode routine for DCL prompts. ;++ ; PROMPTSUB ; ; Provides simple interface so that a program can read and write ; the DCL prompt. These routines use EXEC mode, and must be ; linked with SYS$SYSTEM:SYS.STB/SELECT. ; ; DESCRIPTION ; ; The DCL prompt is stored as a simple string in PRC_G_PROMPT. The ; length of this string is a byte stored in PRC_B_PROMPLEN. Simply ; transfer the data to or from our string descriptors. ; ; ROUTINES ; ; LIB_GET_PROMPT (str_desc, cntlptr) ; Passed the address of a string descriptor. The string is filled with ; the prompt, and the length of the descriptor is changed to the ; length of the prompt. Returns normal status codes. Cntlptr is the ; pointer to a longword. We set bit 0 of the longword iff Carriage ; control is in effect. ; ; LIB_SET_PROMPT (str_desc, cntrl) ; Passed the address of a string descriptor. The prompt is set to the ; string. If cntrl is set, carriage control is enabled. If str_desc ; has length 0, then the standard DCL prompt is turned on. ; ; BUGS ; None yet. ;-- PRC_B_PROMPTLEN = ^XF0 ; The length of the prompt. PRC_G_PROMPT = ^XF4 ; Start of the prompt. PPD$Q_CLIREG = ^X04 ; Per process data area. PRC_W_PMPTCTRL = ^XF1 ; Carriage control for process. PRC_V_CARRCNTL = ^X00 ; Carriage control bit. PRC_W_FLAGS = ^X68 ; Flag location. CLI$_STRTOOLNG = ^X388FA ; Error if more than 253 chars. DCL$C_PROMPTLEN = ^X05 ; Length of normal prompt. PROMPT_PADDING = ^X03 ; Padding to length. PRC_B_CONTINUE = ^XF3 ; Continuation loc. PROMPT_MAXLEN = ^X100 ; Length of prompt. DCL$CRLF: .byte ^X0A .byte ^X0D DCL$T_PROMPT: .ascii ' $ ' $ssdef LIB_SET_PROMPT:: .word ^M movl 4(ap), r9 ; Address of the descriptor. movl #1, r5 ; Assume carr cntrl. tstl 8(ap) ; Look at the second arg. bneq $60 ; No carriage cntrl? clrl r5 ; No carr cntrl. $60: movzwl (r9), r10 ; Length of the descriptor. addl #prompt_padding, r10 ; Add on the padding. cmpl r10, #prompt_maxlen ; How long is it? bgeq $9 ; Too long. moval ctl$ag_clidata, r11 ; Base address of CLI data. movl ppd$q_clireg+4(r11), r11 ; Get the per-process stuff. prober #3, #1, (r9) ; Can we read this? beql $10 ; Guess not. prober #3, r10, 4(r9) ; How about this? beql $10 ; Hey, no fair! movl #1, r2 ; Get a one. ashl #prc_v_carrcntl, #1, r2 ; Build a mask. $cmexec_s set ; Set it. movl #SS$_NORMAL, r0 ; Okay so far. brb $20 ; Go home. $9: movl #CLI$_STRTOOLNG, r0 ; Too long. brb $20 ; Exit. $10: movl #SS$_ACCVIO, r0 ; NOOOOOO!!!! $20: ret set: .word ^M<> ; Exec mode routine. tstl r5 ; Do we have carr cntrl? bgtr $100 ; No, so clrw prc_w_pmptctrl (r11) ; No control. bicw r2, prc_w_flags (r11) ; No flag. brb $101 ; Ok, now the prompt. $100: bisw r2, prc_w_flags (r11) ; Set the flag. movw dcl$crlf, prc_w_pmptctrl(r11) ; Put in the crlf. $101: movb r10, prc_b_promptlen(r11) ; Set the length. cmpl #prompt_padding, r10 ; Is this ok? blss $102 ; Yes. movl dcl$t_prompt, prc_b_continue (r11) ; Set the prompt. movb #dcl$c_promptlen, prc_b_promptlen (r11) ; And the length. brb $104 ; All done. $102: subl #prompt_padding, r10 ; Make it count. movl 4(r9), r9 ; Get the real address. movc3 r10, (r9), prc_g_prompt(r11) ; Set the prompt. $104: ret LIB_GET_PROMPT:: .word ^M movl 4(ap), r9 ; Address of the descriptor. movl 8(ap), r7 ; Address of the flag long. movzwl (r9), r10 ; Length of the string. moval ctl$ag_clidata, r11 ; Base of CLI data area. movl ppd$q_clireg+4(r11), r11 ; Get the process data area. clrl (r7) ; Clear it. ashl #prc_v_carrcntl, #1, r8 ; Build a mask. xorl3 #-1, r8, r8 ; Turn that off. bicl3 r8, prc_w_flags(r11), (r7) ; Set it if necessary. movzbl prc_b_promptlen(r11), r8 ; Get the length. subl #prompt_padding, r8 ; Take off the magic stuff. cmpl r8, r10 ; Have enough space? bleq $50 ; Yes. movl r10, r8 ; No. $50: movl 4(r9), r10 ; Pointer to the buffer. movc3 r8, prc_g_prompt(r11), (r10) ; Get it. movl #SS$_NORMAL, r0 ; Okay so far. movzbw r8, (r9) ; Save the new length. $40: ret .end