	.TITLE	QMTPRS	PARSE QMT COMMAND LINE
	.IDENT	/1.0/
	.ENABLE	LC
;.begin.doc ************************** begin.doc
;  
; .c ;MODULE
; .c ;^&QMTPRS\&
; .nf
; .x QMTPRS>Defined
; Source:QMTPRS.MOD
; Designer           :EARL LAKIA
; Author             :
;             Inland Steel
;             Process Automation Department
;             3210 Watling St.  MS 2-465
;             East Chicago, IN  46312
;  
; Date of last update: 06-FEB-87
; Revision level     :1.0
;  
; .C ;Formal Parameter List
; Receives:
;  
;    MCR BUFFER                 BYTE (80)
;                               MCR COMMAND LINE FROM MCR
;  
; Returns:
;  
;    INDEX                      INTEGER*2
;                               STATUS OF THE PARSE.
;  
; Accesses common(s):
;  
; .X PARSE>Common
;    PARSE                      COMMON WHICH IS USED TO RETURN THE MASK
;                               WORD OF THE BITS SET (SWITCH) AND THE
;                               VALUES FOR THE SWITCHES.
;  
; Accesses file(s):
;  
; Other modules referenced:
; .SK
; .fill
; .SK
; Description:
; .sk    
;
; 	This subroutine parses the QMT MCR command line that
; was entered by the user.  The data is all passed back to the
; calling program (assumed to be "QMT") via the PARSE common.
; The following switches are avaiable:
; .sk
; .nofill
; SWITCH	C.MKW1 VALUE	SWITCH DESCRIPTION
;
; /CR:NNNN	   0000001	CREATE FILE WITH NNNN BLOCKS
;                               "CRVALUE" IN COMMON CONTAINS NNNN
; /LI              0000002	LISTING OF MESSAGE ID FILE
; /RE              0000004	RESET ALL PONITERS
; /IN              0000010      INSERT MESSAGE ID
; /ID:AAAAAAAAAA   0000020      MESSAGE ID
;                               "MESGID" IN COMMON CONTAINS THE ID
; /MX:NNNN         0000040      MAXIMUM NUMBER OF MESSAGES
;                               "MAXCNT" CONTAINS NNNN
; /UP              0000100      UPDATE MESSAGE ID MAX MESSAGES
; /DE              0000200      DELETE MESSAGE ID
; /MOU             0000400      MOUNT
; /DMO             0001000      DISMOUNT
; /DID             0002000      DUMP MESSAGE ID
; /DQH             0004000      DUMP QUEUE HEADER
; /CON		   0010000	QUEUE CONSISTENCY CHECK
; /DL		   0020000	DELETE MESSAGES FROM MSG ID
; 
;
; FORTRAN CALLING SEQUENCE
;
;	IST= QMTPRS(INDEX)
;
;	IST = 1		(SUCCESSFUL PARSE)
;	IST = -1	(BAD COMMAND LINE)
;	IST = -2	(ILLEGAL SWITCH  )
;	IST = -3	(AMBIGUOUS SWITCH)
;
; end.doc ****************************** end.doc  
	.PAGE
;
; SYSTEM MACRO CALLS 
;
;
	.MCALL	CSI$			; DEFINE COMMAND LINE CONTROL BLOCK
	.MCALL	CSI$1			; COMMAND LINE PRE PROCESSOR 
	.MCALL	CSI$2			; DECODE COMMAND LINE CALL
	.MCALL	CSI$SW			; SWITCH DESCRIPTOR 
	.MCALL	CSI$SV			; SWITCH VALUE DESCRIPTOR
	.MCALL	CSI$ND			; SWITCH DESCRIPTOR TABLE TERMINATOR
	.MCALL	GCMLB$			; DEFINE COMMAND LINE CONTROL BLK
	.MCALL	GCMLD$			;   "       "      "     "     "  OFST
	.MCALL	GCML$			; GET MCR COMMAND LINE
	.MCALL	CCML$			; CLOSE INDIRECT
;
	.MCALL	DIR$,QIOW$,EXIT$S	; THE STANDARD STUFF	
;
; NESTING DEPTH: 2, PROMPT= QMT, LUN=2 (DEFAULT SY:)
;
	.PSECT	$DATA,CON,LCL,RW,D
CMDBL:	GCMLB$	2,QMT,,2		; DEFINE CONTROL BLOCK
	.PAGE
;
; DEFINE THE COMMAND LINE INTERPRETER CONTROL BLOCK
;
	CSI$	DEF$G			; DEFINE OFFSETS 
	.EVEN
CSIBLK:
	.BLKB	C.SIZE			; INPUT  CSI CONTROL BLOCK
CSOBLK:
	.BLKB	C.SIZE			; OUTPUT CSI CONTROL BLOCK
;
;
; DEFINE THE SWITCH DESCRIPTOR TABLE
;
SWTTBL:
	CSI$SW	CR,1,,SET,,CRVALUE	; /CR:NNNNN
	CSI$SW	LI,2,,SET,,,		; /LI
	CSI$SW	RE,4,,SET,,,		; /RE
	CSI$SW	IN,10,,SET,,		; /IN
	CSI$SW	ID,20,,SET,,MESGID	; /ID:< 16 CHARACTER NAME >
	CSI$SW	MX,40,,SET,,MAXCNT	; /MX:NNNN
	CSI$SW	UP,100,,SET,,		; /UP
	CSI$SW	DE,200,,SET,,		; /DE
	CSI$SW	MOU,400,,SET,,		; /MOU
	CSI$SW	DMO,1000,,SET,,		; /DMO
	CSI$SW	DID,2000,,SET,,		; /DID
	CSI$SW	DQH,4000,,SET,,		; /DQH
	CSI$SW	CON,10000,,SET,,	; /CON
	CSI$SW	DL,20000,,SET,,		; /DL
;
NOSW=.-SWTTBL/10			; NUMBER OF SWITCHES
	CSI$ND
;
; SWITCH VALUE DESCRIPTOR TABLE
;
CRVALUE:
	CSI$SV	DECIMAL,QUESIZ,2	; 
	CSI$ND
MESGID:
	CSI$SV	ASCII,IDNAME,16		; 16 CHRACTER MESSAGE ID NAME
	CSI$ND
;
MAXCNT:
	CSI$SV	DECIMAL,IDCNT,2		; NUMBER OF MESSAGES
	CSI$ND
	.PAGE
;
; COMMUNICATION REGION WITH THE CALLER VIA NAMED COMMON
;
	.PSECT	PARSE,D,RW,OVR,GBL
IDCNT:
	.BLKW	1	; NUMBER IDS
IDNAME:
	.BLKB	16.	; MESSAGE ID
QUESIZ:
	.BLKW	1	; SIZE OF QUEUE
SWITCH:
	.BLKW	1	; BIT MASK OF SWITCHES ENTERED
	.PAGE
;
; DETERMINE IF CORRECT NUMBER OF PARAMETERS PASSED
;
	.PSECT	$QMT,RO,CON,I,LCL
	.GLOBL	QMTPRS
QMTPRS:
	CMP	#1,(R5)+		; DID HE PASS 1 PARAMETERS
	BEQ	10$			; YES, STORE OUR LUNS
	TRAP	<80.+128.>		; TRAP 80, INVALID NUMBER OF PARAMETERS
	RETURN
;
10$:
;
; PARSE COMMAND LINE
;
20$:	GCML$	#CMDBL			; GET MCR COMMAND LINE
	BCC	30$			; CARRY CLEAR IF SUCCESSFUL
	MOV	#-1,R0
	RETURN				; RETURN STATUS
;
; SHOULD HAVE A COMMAND LINE
;
30$:	MOV	CMDBL+G.CMLD,R1		; LENGTH OF COMMAND LINE
	CSI$1	#CSOBLK,CMDBL+G.CMLD+2,R1	; PRE PROCESS THE COMMAND LINE
	BCC	40$
	MOV	#-2,R0		; BAD COMMAND LINE
	RETURN
40$:	CSI$2	#CSOBLK,OUTPUT,#SWTTBL	; PARSE OUTPUT SIDE OF COMMAND LINE
	BCC	70$			; COMMAND LINE OK
	MOV	#-3,R0		; ILLEGAL SWITCH
	RETURN
;
; EVERYTHING SHOULD BE PARSED
; 
70$:
	MOV	CSOBLK+C.MKW1,SWITCH	; GET BIT WORD FROM PARSE
	MOV	#1,R0			; RETURN GOOD STATUS
	RETURN
	.END
