.TITLE GETCMD - GET NEXT COMMAND .SBTTL GETCMD - TITLE PAGE .IDENT /V01.00/ .ENABL LC ; ; Input the next template command and resolve parameters ; ; Version: V01.00 ; ; Author: R.W. Stamerjohn ; ; Modification history: ; ; V01.00 RWS 14-Oct-1984 Initial version .SBTTL GETCMD - DECLARATIONS .DSABL GBL .DSABL CRF ; ; Macro library calls: ; ; Executive directives ; .MCALL GLUN$S ;Get lun information ; ; Define TPARS macros. ; .MCALL ISTAT$ ;Define initial state .MCALL STATE$ ;Define state transition .MCALL TRAN$ ;Define transition ; ; Global declarations: ; .GLOBL GETCMD ;Entry point ; ; Global references: ; ; CCS subroutines. ; .GLOBL CCSERR ;Declare CCS error and exit .GLOBL GETLIN ;Get next input line. ; ; System subroutines ; .GLOBL .TPARS ;Parse command line ; ; CCS data areas. ; .GLOBL CCSFLG ;Control flags .GLOBL OBUF ;Output command buffer .GLOBL OBUFL ;Length of current command .GLOBL OBUFB ;Pointer to end of current command .GLOBL PINDX ;Parameter index .GLOBL PNTR0 ;Start of parameters .GLOBL DEFUIC ;Default UIC string .GLOBL HOMUIC ;Home UIC string ; ; CCS symbols. ; .GLOBL OSIZ ;Size of output buffer .GLOBL TLUN ;Terminal lun .GLOBL CS.WAI ;Current command is wait task .GLOBL CS.MOR ;Current command is execute/continue .GLOBL CS.LST ;Current command is execute/last .GLOBL CS.DBG ;Current command has debug flag (%D) .GLOBL CS.PRT ;Current command has print flag (%P) .GLOBL CS.QUT ;Current command has quit flag (%Q) .GLOBL CS.NUL ;Current command has null flag (%N) .GLOBL CS.XIT ;Current command has exit flag (%$) .GLOBL CS.NON ;Required parameter not found ; ; .TPARS variables. ; .GLOBL .PSTCN ;Length of parsed string .GLOBL .PSTPT ;Address of parsed string .GLOBL .PCHAR ;Parsed character .ENABL CRF .SBTTL GETCMD - LOCAL VARIABLES ; ; Local symbols: ; ; None. ; ; Local data: ; LUNBUF: .BLKW 6 ;GLUN buffer ; ; Error messages. ; .NLIST BEX ERTINP: .ASCIZ /CCS - Error inputting template command/ ERTERR: .ASCIZ /CCS - Error processing template command/ .EVEN .LIST BEX .SBTTL GETCMD - PARSING TABLE ISTAT$ CMDTBL,CMDKEY STATE$ ST.01 ;Parse out command type TRAN$ <'->,ST.02,,CS.WAI,CCSFLG TRAN$ <'+>,ST.02,,CS.MOR,CCSFLG TRAN$ <'*>,ST.02,,CS.LST,CCSFLG STATE$ ST.02 ;Parse until a % TRAN$ $EOS,$EXIT TRAN$ <'%>,ST.03 TRAN$ $ANY,ST.02,PRCHR STATE$ ST.03 ;Dispatch on %type TRAN$ $DIGIT,ST.04,PRPRM TRAN$ <'A> ,ST.04,PRPRM TRAN$ <'B> ,ST.04,PRPRM TRAN$ <'C> ,ST.04,PRPRM TRAN$ <'H> ,ST.02,PRHOM TRAN$ <'U> ,ST.02,PRUIC TRAN$ <'G> ,ST.02,PRGRP TRAN$ <'M> ,ST.02,PROWN TRAN$ <'T> ,ST.02,PRTTY TRAN$ <'%> ,ST.02,PRCHR TRAN$ <'D> ,ST.02,,CS.DBG,CCSFLG TRAN$ <'P> ,ST.02,,CS.PRT,CCSFLG TRAN$ <'Q> ,ST.02,,CS.QUT,CCSFLG TRAN$ <'N> ,ST.02,,CS.NUL,CCSFLG TRAN$ <'$> ,ST.02,,CS.XIT,CCSFLG STATE$ ST.04 ;Dispatch on null/non-null TRAN$ $LAMDA,NL.00,PRNUL TRAN$ $LAMDA ; ; Process a parameter which is not null. ; STATE$ PM.00 ;Dispatch on %n? or option1 TRAN$ <'?>,PM.03 TRAN$ <',>,PM.01,PRCHR TRAN$ <'=>,PM.01,PRCHR TRAN$ $LAMDA STATE$ PM.01 ;Copy parameter into file TRAN$ $LAMDA,,PRCPY STATE$ PM.02 ;Check for option2 TRAN$ <'%>,ST.02 TRAN$ <'\>,PM.04 TRAN$ $ANY,PM.03,PRCHK TRAN$ $LAMDA,PM.04 STATE$ PM.03 ;Copy rest of option2 TRAN$ <'%>,ST.02 TRAN$ <'\>,PM.04 TRAN$ $ANY,PM.03,PRCHR STATE$ PM.04 ;Search for end of option TRAN$ <'%>,ST.02 TRAN$ $ANY,PM.04 ; ; Process a parameter which is null. ; STATE$ NL.00 ;Dispatch on %n? TRAN$ <'?>,NL.02 TRAN$ $LAMDA STATE$ NL.01 ;Parse until \ or % TRAN$ <'\>,NL.03 TRAN$ <'%>,ST.02 TRAN$ $ANY,NL.01 STATE$ NL.02 ;Parse until \ or % TRAN$ <'\>,NL.03 TRAN$ <'%>,ST.02,,CS.NON,CCSFLG TRAN$ $ANY,NL.02 STATE$ NL.03 ;Check for null default TRAN$ <'%>,ST.02,,CS.NON,CCSFLG TRAN$ $LAMDA STATE$ NL.04 ;Move default string TRAN$ <'%>,ST.02 TRAN$ $ANY,NL.04,PRCHR STATE$ .SBTTL GETCMD * SCAN FOR COMMAND ; ;+ ; This routine inputs the next command to execute and sets it up in the ; OBUF command buffer. ; ; Call by: JSR PC,GETCMD ; ; File open on input lun. ; ; Exit with: MCR command setup in OBUF buffer. Any errors detected in ; this routine are fatal to CCS and are handled by CCSERR. ;- GETCMD:: ;Ref. label MOV #OBUF,OBUFB ;Set pointer to command buffer MOV #OSIZ,OBUFL ;Set length of command buffer CLR CCSFLG ;Clear flags word 1000$: CALL GETLIN ;Get next line BCC 1100$ ; If CC - no errors CALL CCSERR ;Declare error and exit .WORD ERTINP ; *** Error inputting template *** 1100$: CMPB #<'$>,(R4) ;Is this a keyword line? BEQ 1000$ ; If EQ - yes, loop CMPB #<'?>,(R4) ;Is this a prompt line? BEQ 1000$ ; If EQ - yes, loop ; ; We have gotten to an MCR action line, parse into components. ; MOV #1,R1 ;Blanks are significate MOV #CMDKEY,R2 ;Set parsing keyword table MOV #CMDTBL,R5 ;Set starting parsing state CALL .TPARS ;Process command line BCC 9999$ ; If CC - no problems CALL CCSERR ;Output error and exit .WORD ERTERR ; *** Error processing template *** 9999$: RETURN ;Return to caller .SBTTL PR???? * ACTION ROUTINES ;+ ; These are the action routines for the keyword search. They assume the ; following .TPARS variables are setup. ; ; .PSTCN Count of characters matched ; .PSTPT Address of characters matched ; .PCHAR Last parsed character from $DIGIT ;- ; ; *** PRHOM *** Store home UIC string into output command buffer. ; PRHOM: MOV #HOMUIC,R0 ;Get string pointer MOV #9.,R1 ;Get string length BR PRMOV ; and continue in common ; ; *** PRUIC *** Store UIC string into output command buffer. ; PRUIC: MOV #DEFUIC,R0 ;Get string pointer MOV #9.,R1 ;Get string length BR PRMOV ; and continue in common ; ; *** PRGRP *** Store UIC group into output command buffer. ; PRGRP: MOV #DEFUIC+1,R0 ;Get string pointer MOV #3.,R1 ;Get string length BR PRMOV ; and continue in common ; ; *** PROWN *** Store UIC owner into output command buffer. ; PROWN: MOV #DEFUIC+5,R0 ;Get string pointer MOV #3.,R1 ;Get string length BR PRMOV ; and continue in common ; ; *** PRTTY ** Store terminal (Tnn) into command buffer. ; PRTTY: MOV #LUNBUF,R0 ;Get lun buffer address GLUN$S #TLUN,R0 ;Get our terminal information MOVB G.LUNU(R0),R2 ;Get the unit number BIC #177400,R2 ; and clear out any sign extension CMP #7,R2 ;Is terminal larger than 7 BLT 1100$ ; If LT - yes, continue ADD #<'0>,R2 ;Convert to ASCII MOVB R2,1(R0) ; and store as string MOV #2,R1 ;Set string length BR PRMOV ; and continue in common 1100$: MOV R2,R1 ;Copy number to R1 ASH #-3,R1 ;Drop out bottom digit MOVB #<'0>,-(SP) ;Preset octal conversion CMP #7,R1 ;Is this an octal digit? BGE 1110$ ; If EQ - yes, skip MOVB #<'A-10>,-(SP) ;Set alphabetic conversion 1110$: ADD (SP)+,R1 ;Convert to ASCII MOVB R1,1(R0) ; and store in string BIC #177770,R2 ;Get all but low digit ADD #<'0>,R2 ;Convert to ASCII MOVB R2,2(R0) ; and store as string MOV #3,R1 ;Set string length ; ; *** PRMOV *** Move string into output buffer. ; PRMOV: SUB R1,OBUFL ;Count characters in buffer BLE REJECT ; If LE - string does not fit 1000$: MOVB (R0)+,@OBUFB ;Move character to buffer INC OBUFB ;Advance buffer pointer SOB R1,1000$ ; and loop till done RETURN ;Return to parser ; ; *** PRCHR *** Store parsed character into output command buffer. ; PRCHR: MOVB .PCHAR,@OBUFB ;Store the character into output buffer INC OBUFB ;Move pointer in buffer DEC OBUFL ;Count character in buffer BEQ REJECT ; If EQ - no more room, error RETURN ;Return to parser ; ; *** PRPRM *** Set address of parameter string. ; PRPRM: MOV .PCHAR,R0 ;Get parsed character SUB #<'0>,R0 ;Get in binary CMP #9.,R0 ;Was it A,B,C? BGE 1000$ ; If GE - no, skip SUB #<'A-'0-10.>,R0 ;Get in binary 1000$: ASH #2,R0 ;Convert to parameter index ADD #PNTR0,R0 ;Form address of parameter MOV R0,PINDX ;Store as index RETURN ;Return to parser ; ; *** PRNUL *** Reject if not null. ; PRNUL: TST @PINDX ;Is parameter null? BNE REJECT ; If NE - yes, reject RETURN ;Return to paser ; ; *** PRCPY *** Copy parameter. ; PRCPY: MOV PINDX,R2 ;Get address of parameter MOV (R2)+,R1 ;Get length of parameter MOV (R2)+,R0 ;Get address of parameter BR PRMOV ;Copy to output ; ; *** PRCHK *** Check if test character in parameter. ; PRCHK: MOV PINDX,R2 ;Get address of parameter MOV (R2)+,R1 ;Get length of parameter MOV (R2)+,R0 ;Get address of parameter 1000$: CMPB .PCHAR,(R0)+ ;Is character in parameter BEQ REJECT ; If EQ - yes, reject test SOB R1,1000$ ;Continue search BR PRCHR ;Copy character to output buffer ; ; *** REJECT *** Reject transaction. ; REJECT: ADD #2,(SP) ;Take skip return RETURN ;Return to parser .END