Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-08 - 43,50512/rmcswi.bli
There are no other files named rmcswi.bli in the archive.
MODULE SWITCH(!RMCOPY SWITCH OPTION ANALYSIS MODULE
		  IDENT = '10'
		  ) =
BEGIN


! COPYRIGHT (C) 1978
! DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASSACHUSETTS 01754
!
! THIS SOFTWARE IS FURNISHED  UNDER A LICENSE FOR USE ONLY ON A SINGLE
! COMPUTER  SYSTEM AND  MAY BE  COPIED ONLY WITH  THE INCLUSION OF THE
! ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE, OR ANY OTHER COPISE THEREOF,
! MAY NOT BE PROVIDED OR  OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON
! EXCEPT FOR USE ON SUCH SYSTEM AND TO ONE WHO AGREES TO THESE LICENSE
! TERMS.  TITLE TO AND  OWNERSHIP OF THE  SOFTWARE  SHALL AT ALL TIMES
! REMAIN IN DEC.
!
! THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE
! AND SHOULD  NOT BE CONSTRUED  AS A COMMITMENT  BY DIGITAL  EQUIPMENT
! CORPORATION.
!
! DEC ASSUMES  NO  RESPONSIBLILTY  FOR  THE USE OR  RELIABILITY OF ITS
! SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DEC.
!
!++
! FACILITY:
!	RMCOPY TRANSPORTABLE CODE
!
! ABSTRACT:
!	This module CONTAINS ALL THE ROUTINES NEEDED FOR CMD SELECTED OPTIONS
!	INTREPRETATION AND LEGALLY CHKS..
!
!
!
! ENVIRONMENT:
!	TRANSPORTABLE
!
! AUTHOR: JOHN DEROSE, CREATION DATE: FEB 1978
!
! MODIFIED BY:
!
!--
!
! TABLE OF CONTENTS:
!
FORWARD ROUTINE
	RMC_AFTER,			!AFTER SWITCH ROUTIME
	RMC_PROTECT,			!DAP PROTECT CODE ROUTINE
	TIME_SWITCH,			!TIME FUNCTION SWITCH ROUTINE
	B16_SWITCH,			!BINARY 16 SWITCH ROUTINE 
	L_SWITCH,			!LIST SWITCH ROUTINE
	RMC_SWITCH,
	RMC_SOPTION,
	MORE_CHK;			!MORE SWITCH CHECK ROUTINE

!
! DEFINITION LIBRARY FILES:
!
LIBRARY 'RMCOPY';	!The interface to the system-independent portion
!
!
! CONDITIONAL COMPILATION:
!
	%IF FTTOPS10 %THEN %INFORM ('RMCOPY FOR TOPS10') %FI
	%IF FTTOPS20 %THEN %INFORM ('RMCOPY FOR TOPS20') %FI
	%IF FTVAX %THEN %INFORM ('RMCOPY FOR VAX') %FI
!
!
! MACROS:
!
!
! EQUATED SYMBOLS:
!
!
! OWN STORAGE:
!
!
! EXTERNAL REFERENCES:
!
EXTERNAL ROUTINE 
	UDATE,				!UNIVERSAL DATE ROUTINE
	LOG_DEFAULT,			!LOG FILE DEFAULT SET ROUTINE 
	COMPRESS_BLANKS,		!COMPRESS BLANKS FROM TEXT STRING ROUTINE
	RMC_RDNUMA,			!RMC RADIX TEXT TO NUMBER CONVERTING ROUTINE
	QFUNC,				!QUEUE FUNCTION INTERFACE ROUTINE
	RMC_STRIPSTRING,		!RMC STRIP A STRING OUT OF A TEXT STRING ROUTINE
	TOPS10_PARSECHK,		!TOPS10 PARSER ROUTINE
	ZEROBLK,			!ZERO BLOCK ROUTINE
	FILE_SPEC,			!FILE SPEC ROUTINE
	CHK_NEXT_CHAR,			!CHECK NEXT CHAR ROUTINE
	RMC_MSG,			!RMC MSG TTY-OUTPUT ROUTINE
	FND_PATTERN,			!FIND PATTERN ROUTINE
	RMC_FPARSE,			!RMC FILE PARSER ROUTINE
	MSGERR;				!Message/error routine


EXTERNAL
	RMCOPTTAB,			!RMC OPTION TABLE
	RMCTIMETAB,			!RMC MONTH TIME TABLE
	TOTALCHARCOUNT,			!TOTAL COMMAND CHARACTER COUNT INDEX
	RMCDAYTAB,			!RMC DAY TIME TABLE
	RMCPROTAB,			!RMC PROTECTION OPTION TABLE
	LNSTRG:CH$SEQUENCE[MAX$NODESIZE],!LOCAL NODE TEXT STRING STORAGE
	STRG_1 :CH$SEQUENCE[MAX$CMDSIZE],!INPUT CMD STRING STORAGE
	SOURCE_FILE$BLK,		!FILE SPEC BLOCK
	EVALBLK: VECTOR[EVAL$SIZE],	!EVALUATION PTR/STATUS BLOCK
	SDRMCBLK: VECTOR[SD$SIZE];	!SEND RMC BLOCK
!
!
!






GLOBAL ROUTINE RMC_PROTECT(TEXTPTR,TEXTCNT,PROTECTADDR)=
BEGIN

LOCAL	PASTPTR,		!PAST PTR INTO COMMAND STRING
	PRESENTPTR,		!PRESENT PTR INTO COMMAND STRING
	PTR,			!WORKING PTR INTO COMMAND STRING
	CC;			!CURRENT WORKING CHAR COUNT
LOCAL BITTMP:BITVECTOR[SWFUNC$SIZE];
LOCAL PROTECTION:BITVECTOR[DAP$PRO$SIZE];
.PROTECTADDR=PROTECTION=-1;		!DEFAULT BITVECTOR TO NO ACCESS PROTECTION
!	IF NO SWITCHES ARE SPECIFIED THEN DEFAULT TO -1
!	I.E. NO ACCESS
IF .TEXTCNT EQL 0
THEN RETURN 0;

!COMPRESS TEXT STRING ELIMINATING BLANKS
TEXTCNT=COMPRESS_BLANKS(.TEXTCNT,.TEXTPTR);

BITTMP[END$VAL]=BITTMP[START$VAL]=0;
PTR=.TEXTPTR;
BEGIN
WHILE 1 DO
BEGIN
PASTPTR=.PTR;		!REMEMBER OLD POINTER
CC=RMC_STRIPSTRING(PTR);
PRESENTPTR=.PTR;
IF .CC EQL 0 THEN TEXTCNT=.TEXTCNT-1
ELSE TEXTCNT=.TEXTCNT-(.CC+1);
	SELECTONE CH$RCHAR_A(PTR) OF 
	SET

	[%C'(']:BEGIN
		  IF .BITTMP[END$VAL] OR .BITTMP[START$VAL]
		  THEN RETURN -1
		  ELSE BITTMP[START$VAL]=1
		END;
	[%C',']:BEGIN 
		  IF (.BITTMP[END$VAL] OR NOT .BITTMP[START$VAL]) AND .CC NEQ 0
		  THEN RETURN -1
		  ELSE
		SELECTONE  (FND_PATTERN(.PASTPTR,.CC,RMCPROTAB)) OF
		SET
		[READ$SWITCH]:PROTECTION[DAP$PRO_RDV]=0;
		[WRITE$SWITCH]:PROTECTION[DAP$PRO_WRV]=0;
		[EXECUTE$SWITCH]:PROTECTION[DAP$PRO_EXE]=0;
		[DELETE$SWITCH]:PROTECTION[DAP$PRO_DLE]=0;
		[APPEND$SWITCH]:PROTECTION[DAP$PRO_APP]=0;
		[LIST$SWITCH]:PROTECTION[DAP$PRO_LST]=0;
		[UPDATE$SWITCH]:PROTECTION[DAP$PRO_UPD]=0;
		[CHANGE$SWITCH]:PROTECTION[DAP$PRO_CNG]=0;
		!NOTE: Modify and change switches do the same thing
		[EXTEND$SWITCH]:PROTECTION[DAP$PRO_EXT]=0;
		[OTHERWISE]:RETURN -1
		TES;
		END;

	[%C')']:BEGIN
		  IF (.BITTMP[START$VAL] AND NOT .BITTMP[END$VAL])
		  THEN IF .CC NEQ 0 THEN
		SELECTONE  (FND_PATTERN(.PASTPTR,.CC,RMCPROTAB)) OF
		SET
		[READ$SWITCH]:PROTECTION[DAP$PRO_RDV]=0;
		[WRITE$SWITCH]:PROTECTION[DAP$PRO_WRV]=0;
		[EXECUTE$SWITCH]:PROTECTION[DAP$PRO_EXE]=0;
		[DELETE$SWITCH]:PROTECTION[DAP$PRO_DLE]=0;
		[APPEND$SWITCH]:PROTECTION[DAP$PRO_APP]=0;
		[LIST$SWITCH]:PROTECTION[DAP$PRO_LST]=0;
		[UPDATE$SWITCH]:PROTECTION[DAP$PRO_UPD]=0;
		[CHANGE$SWITCH]:PROTECTION[DAP$PRO_CNG]=0;
		!NOTE: Modify and change switches do the same thing
		[EXTEND$SWITCH]:PROTECTION[DAP$PRO_EXT]=0;
		[OTHERWISE]:RETURN -1
		TES
		ELSE
		ELSE RETURN -1;
		BITTMP[START$VAL]=0;
		BITTMP[END$VAL]=1
		END;

	[%O'0',%C'/',%C'=']:
		BEGIN
		  IF (.BITTMP[START$VAL]) AND .CC NEQ 0 THEN
		SELECTONE  (FND_PATTERN(.PASTPTR,.CC,RMCPROTAB)) OF
		SET
		[READ$SWITCH]:PROTECTION[DAP$PRO_RDV]=0;
		[WRITE$SWITCH]:PROTECTION[DAP$PRO_WRV]=0;
		[EXECUTE$SWITCH]:PROTECTION[DAP$PRO_EXE]=0;
		[DELETE$SWITCH]:PROTECTION[DAP$PRO_DLE]=0;
		[APPEND$SWITCH]:PROTECTION[DAP$PRO_APP]=0;
		[LIST$SWITCH]:PROTECTION[DAP$PRO_LST]=0;
		[UPDATE$SWITCH]:PROTECTION[DAP$PRO_UPD]=0;
		[CHANGE$SWITCH]:PROTECTION[DAP$PRO_CNG]=0;
		!NOTE: Modify and change switches do the same thing
		[EXTEND$SWITCH]:PROTECTION[DAP$PRO_EXT]=0;
		[OTHERWISE]:RETURN -1
		TES
		ELSE IF .CC NEQ 0
		THEN RETURN -1;

		.PROTECTADDR=.PROTECTION;
		RETURN 0
		END;
	[OTHERWISE]:  RETURN -1
	TES;
	END;
    END;
END;



GLOBAL ROUTINE TIME_SWITCH(TEXTPTRADDR,CHARCOUNT)=
BEGIN
!	NOTE: ACSII BLANKS ARE ILLEGAL IN THIS ROUTINE
LOCAL	PASTPTR,		!PAST PTR INTO COMMAND STRING
	PRESENTPTR,		!PRESENT PTR INTO COMMAND STRING
	PTR;			!WORKING PTR INTO COMMAND STRING
LOCAL CC,MINUTES,TIMEVALUE;
LOCAL BITTMP:BITVECTOR[SWFUNC$SIZE];

BITTMP[START$VAL]=BITTMP[COLON2$VAL]=0;
BITTMP[END$VAL]=BITTMP[COLON1$VAL]=0;
MINUTES=TIMEVALUE=0;
PTR=.TEXTPTRADDR;
BEGIN
WHILE 1 DO
BEGIN
PASTPTR=.PTR;		!REMEMBER OLD POINTER
CC=RMC_STRIPSTRING(PTR);
PRESENTPTR=.PTR;
IF .CC EQL 0 THEN CHARCOUNT=.CHARCOUNT-1
ELSE CHARCOUNT=.CHARCOUNT-(.CC+1);
	SELECTONE CH$RCHAR_A(PTR) OF 
	SET

	[%C':']:BEGIN
			IF NOT .BITTMP[END$VAL] 
			THEN IF NOT .BITTMP[COLON1$VAL]
			     THEN
			     BEGIN
				BITTMP[COLON1$VAL]=1;
				IF .CC NEQ 0
				THEN IF RMC_RDNUMA(.PASTPTR,10,.CC,TIMEVALUE) LSS 0
				     THEN RETURN -1
				     ELSE IF (.TIMEVALUE GTRU 23)
				!IF TIMEVALUE (HOURS) GTR 24 HOURS THEN ERROR
					THEN RETURN -1
					ELSE  MINUTES=.TIMEVALUE*60;
			    END
			ELSE RETURN -1
		END;
	[%O'0',%C'/',%C'=']:
		BEGIN
		  IF NOT .BITTMP[END$VAL]
		  THEN
		  BEGIN
			IF .CC GTR 0
			THEN BEGIN
				IF RMC_RDNUMA(.PASTPTR,10,.CC,TIMEVALUE) LSS 0
				THEN RETURN -1
				ELSE IF .BITTMP[COLON1$VAL]
					THEN
					 IF .TIMEVALUE GTRU 59
					THEN RETURN -1
					ELSE MINUTES=.TIMEVALUE+.MINUTES
				     ELSE IF (.TIMEVALUE GTRU 23)
				!IF TIMEVALUE (HOURS) GTR 24 HOURS THEN ERROR
					THEN RETURN -1
					ELSE  MINUTES=.TIMEVALUE*60;
				BITTMP[END$VAL]=1;
			    END
			ELSE
			END
			ELSE RETURN -1;
			RETURN .MINUTES
		END;
	[OTHERWISE]:  RETURN -1
	TES;
	END;
    END;
END;



GLOBAL ROUTINE RMC_AFTER(TEXTPTR,TEXTCNT)=
BEGIN
LABEL LOOP;



LOCAL	PASTPTR,		!PAST PTR INTO COMMAND STRING
	PRESENTPTR,		!PRESENT PTR INTO COMMAND STRING
	PTR,			!WORKING PTR INTO COMMAND STRING
	CC;			!CURRENT WORKING CHAR COUNT
LOCAL ARGTYPE,TIME,DAY,MONTH,YEAR;
LOCAL BITTMP:BITVECTOR[SWFUNC$SIZE];

!COMPRESS TEXT STRING ELIMINATING BLANKS
TEXTCNT=COMPRESS_BLANKS(.TEXTCNT,.TEXTPTR);
BITTMP[END$VAL]=BITTMP[DATE$VAL]=0;
ARGTYPE=TIME=DAY=MONTH=YEAR=0;
PTR=.TEXTPTR;
BEGIN
WHILE 1 DO
BEGIN
PASTPTR=.PTR;		!REMEMBER OLD POINTER
CC=RMC_STRIPSTRING(PTR);
PRESENTPTR=.PTR;
IF .CC EQL 0 THEN TEXTCNT=.TEXTCNT-1
ELSE TEXTCNT=.TEXTCNT-(.CC+1);
	SELECTONE CH$RCHAR_A(PTR) OF 
	SET

	[%C':']:BEGIN
		  IF .BITTMP[END$VAL]
		  THEN RETURN -1
		  ELSE IF .BITTMP[DATE$VAL]
		!AN ABS. DATE WAS BEING PROCESSED
			THEN BEGIN
				IF .MONTH EQL 0 
				THEN IF (MONTH =FND_PATTERN(.PASTPTR,.CC,RMCTIMETAB)) LSS 0
				  THEN RETURN -1
				ELSE
				  ELSE 
				IF .CC NEQ 0 THEN
				IF RMC_RDNUMA(.PASTPTR,10,.CC,YEAR) LSS 0
				THEN RETURN -1;
				IF(TIME=TIME_SWITCH(.PTR,.TEXTCNT)) LSS 0
				THEN RETURN -1;
				 ARGTYPE=UDATE$ABS;
			    END
			ELSE IF (RMC_RDNUMA(.PASTPTR,10,.CC,TIME)) LSS 0
			!MUST FIND OUT WHETHER DAY SWITCH OR HHMM
			THEN BEGIN
		SELECTONE  (DAY=FND_PATTERN(.PASTPTR,.CC,RMCDAYTAB)) OF
		SET
		[SUN$SWITCH TO SAT$SWITCH]:
			    BEGIN
				ARGTYPE=UDATE$DAY;
				TIME=23*60+59;	!DEFAULT TO 23:59 OF THE SELECTED DAY
			    END;
		[TOD$SWITCH]:BEGIN
				DAY=0;
				TIME=23*60+59;	!DEFAULT TO 23:59 OF TODAY
				ARGTYPE=UDATE$TODAY;
			      END;
		[TOM$SWITCH]:BEGIN
				DAY=0;
				TIME=23*60+59;	!DEFAULT TO 23:59 OF TOMORROW
				ARGTYPE=UDATE$TOMRW;
			      END;
		[NOW$SWITCH]:BEGIN
				DAY=0;
				TIME=0;	!DEFAULT TO IMMEDIATELY
				ARGTYPE=UDATE$TODAY;
			      END;
		[OTHERWISE]:RETURN -1
		TES;
		IF(TIME=TIME_SWITCH(.PTR,.TEXTCNT)) LSS 0
		THEN RETURN -1;
			END
			ELSE IF(TIME=TIME_SWITCH(.PASTPTR,.TEXTCNT+.CC+1)) LSS 0
				THEN RETURN -1;
		 BITTMP[END$VAL]=1;
		  IF .ARGTYPE EQL 0
		  THEN ARGTYPE=UDATE$HHMM;
		PTR=CH$PLUS(.PTR,.TEXTCNT)
		END;
	[%C'+']:BEGIN !PLUS TYPE FIELD
		  IF (.BITTMP[END$VAL] OR .BITTMP[DATE$VAL]) AND .CC NEQ 0
		  THEN RETURN -1
		  ELSE ARGTYPE=UDATE$PLUS
		END;
	[%C'-']:BEGIN
		  TIME=23*60+59;	!DEFAULT TO 23:59 OF SPECIFIED DAY
		  IF .BITTMP[END$VAL] 
		  THEN RETURN -1
		  ELSE IF .DAY EQL 0 AND NOT .BITTMP[DATE$VAL]
			THEN IF RMC_RDNUMA(.PASTPTR,10,.CC,DAY) LSS 0
			     THEN RETURN -1
			     ELSE BITTMP[DATE$VAL]=1
			ELSE IF .MONTH EQL 0 AND .BITTMP[DATE$VAL]
			     THEN IF (MONTH =FND_PATTERN(.PASTPTR,.CC,RMCTIMETAB)) LSS 0
				  THEN RETURN -1
				  ELSE 
			     ELSE RETURN -1
		END;
	[%O'0',%C'/',%C'=']:
		BEGIN
		  IF (NOT .BITTMP[DATE$VAL] AND NOT .BITTMP[END$VAL])
		  THEN
			IF (RMC_RDNUMA(.PASTPTR,10,.CC,TIME)) LSS 0
			!MUST FIND OUT WHETHER DAY SWITCH OR HHMM
			THEN BEGIN
		SELECTONE  (DAY=FND_PATTERN(.PASTPTR,.CC,RMCDAYTAB)) OF
		SET
		[SUN$SWITCH TO SAT$SWITCH]:
			    BEGIN
				ARGTYPE=UDATE$DAY;
				TIME=23*60+59;	!DEFAULT TO 23:59 OF TOMORROW
			    END;
		[TOD$SWITCH]:BEGIN
				DAY=0;
				TIME=23*60+59;	!DEFAULT TO 23:59 OF TODAY
				ARGTYPE=UDATE$TODAY;
			      END;
		[TOM$SWITCH]:BEGIN
				DAY=0;
				TIME=23*60+59;	!DEFAULT TO 23:59 OF TOMORROW
				ARGTYPE=UDATE$TOMRW;
			      END;
		[NOW$SWITCH]:BEGIN
				DAY=0;
				TIME=0;	!DEFAULT TO IMEDIATELY
				ARGTYPE=UDATE$TODAY;
			      END;
		[OTHERWISE]:RETURN -1
		TES;
		END
			ELSE IF(TIME=TIME_SWITCH(.PASTPTR,.TEXTCNT+.CC+1)) LSS 0
				THEN RETURN -1
				ELSE IF .ARGTYPE EQL 0 
					THEN  ARGTYPE=UDATE$HHMM
					ELSE
		  ELSE IF .BITTMP[DATE$VAL] AND .ARGTYPE EQL 0
		!AN ABS. DATE WAS BEING PROCESSED
			THEN BEGIN
				IF .MONTH EQL 0 
				THEN IF (MONTH =FND_PATTERN(.PASTPTR,.CC,RMCTIMETAB)) LSS 0
				  THEN RETURN -1
				  ELSE 
				  ELSE 
				IF .CC NEQ 0 THEN
				IF RMC_RDNUMA(.PASTPTR,10,.CC,YEAR) LSS 0
				THEN RETURN -1;
				 ARGTYPE=UDATE$ABS
			    END;
		RETURN (UDATE(.ARGTYPE,.TIME,.DAY,.MONTH,.YEAR))
		END;
	[OTHERWISE]:  RETURN -1
	TES;
	END;
    END;
END;





GLOBAL ROUTINE B16_SWITCH(TEXTPTRADDR,CHARCOUNT)=
BEGIN
LOCAL	PASTPTR,		!PAST PTR INTO COMMAND STRING
	PRESENTPTR,		!PRESENT PTR INTO COMMAND STRING
	PTR;			!WORKING PTR INTO COMMAND STRING
LOCAL CC,DUMBY;
LOCAL BITTMP:BITVECTOR[SWFUNC$SIZE];

BITTMP[START$VAL]=1;
BITTMP[END$VAL]=BITTMP[COLON1$VAL]=0;
DUMBY=0;
PTR=.TEXTPTRADDR;
BEGIN
WHILE 1 DO
BEGIN
PASTPTR=.PTR;		!REMEMBER OLD POINTER
CC=RMC_STRIPSTRING(PTR);
PRESENTPTR=.PTR;
IF .CC EQL 0 THEN CHARCOUNT=.CHARCOUNT-1
ELSE CHARCOUNT=.CHARCOUNT-(.CC+1);
	SELECTONE CH$RCHAR_A(PTR) OF 
	SET

	[%C' ']:BEGIN
			IF .BITTMP[START$VAL] AND .CC GTR 0
			THEN BEGIN
				  SELECTONE (DUMBY= FND_PATTERN(.PASTPTR,.CC,RMCOPTTAB)) OF
				  SET
				  [IMAGE$SWITCH]: BITTMP[END$VAL]=1;
				  [PACKED$SWITCH]: BITTMP[END$VAL]=1;
				  [OTHERWISE]:  RETURN -1
				  TES;
				BITTMP[START$VAL]=0;
				BITTMP[END$VAL]=1;
			    END
		END;

	[%O'0',%C'/',%C'=']:
		BEGIN
		  IF NOT .BITTMP[END$VAL] THEN
			IF .BITTMP[START$VAL] AND .CC GTR 0
			THEN BEGIN
				  SELECTONE (DUMBY= FND_PATTERN(.PASTPTR,.CC,RMCOPTTAB)) OF
				  SET
				  [IMAGE$SWITCH]: BITTMP[END$VAL]=1;
				  [PACKED$SWITCH]: BITTMP[END$VAL]=1;
				  [OTHERWISE]:  RETURN -1
				  TES;
				BITTMP[START$VAL]=0;
				BITTMP[END$VAL]=1;
			    END
			ELSE RETURN -1;
		  CHARCOUNT=.CHARCOUNT+1
		END;
	[OTHERWISE]:  RETURN -1
	TES;
	IF .CHARCOUNT EQL 0 THEN RETURN .DUMBY		  
	ELSE IF .CHARCOUNT LSS 0 THEN RETURN -1
	END;
    END;
END;




GLOBAL ROUTINE L_SWITCH(TEXTPTRADDR,CHARCOUNT)=
BEGIN
LOCAL	PASTPTR,		!PAST PTR INTO COMMAND STRING
	PRESENTPTR,		!PRESENT PTR INTO COMMAND STRING
	PTR;			!WORKING PTR INTO COMMAND STRING
LOCAL CC,DUMBY;
LOCAL BITTMP:BITVECTOR[SWFUNC$SIZE];

BITTMP[START$VAL]=1;
BITTMP[NUMVAL$VAL]=BITTMP[LTBRAC$VAL]=0;
BITTMP[COMMA1$VAL]=0;
BITTMP[END$VAL]=BITTMP[COLON1$VAL]=0;
PTR=..TEXTPTRADDR;
BEGIN
WHILE 1 DO
BEGIN
PASTPTR=.PTR;		!REMEMBER OLD POINTER
CC=RMC_STRIPSTRING(PTR);
PRESENTPTR=.PTR;
IF .CC EQL 0 THEN CHARCOUNT=.CHARCOUNT-1
ELSE CHARCOUNT=.CHARCOUNT-(.CC+1);
	SELECTONE CH$RCHAR_A(PTR) OF 
	SET
	[%C'[']:BEGIN
			IF NOT .BITTMP[LTBRAC$VAL] AND NOT .BITTMP[END$VAL]
			THEN BEGIN
				.TEXTPTRADDR=.PTR;
				BITTMP[NUMVAL$VAL]=BITTMP[START$VAL]=1;
				BITTMP[LTBRAC$VAL]=1
			     END
			ELSE RETURN -1
		END;
	[%C',']:BEGIN
			IF NOT .BITTMP[COMMA1$VAL] AND .BITTMP[START$VAL]
			THEN BEGIN
				IF .BITTMP[NUMVAL$VAL]
				THEN IF RMC_RDNUMA(.PASTPTR,8,.CC,DUMBY) LSS 0
					THEN RETURN -1;
				BITTMP[COMMA1$VAL]=1
			     END
			ELSE RETURN -1
		END;

	[%C']']:BEGIN
			IF .BITTMP[START$VAL] AND .BITTMP[COMMA1$VAL]
			THEN BEGIN
				IF .BITTMP[NUMVAL$VAL]
				THEN IF RMC_RDNUMA(.PASTPTR,8,.CC,DUMBY) LSS 0
					THEN RETURN -1;
				BITTMP[START$VAL]=0;
				CH$WCHAR(%O'0',.PRESENTPTR);
				BITTMP[END$VAL]=1;
			    END
			ELSE RETURN -1
		END;
	[%C' ']:BEGIN
			IF .BITTMP[START$VAL] AND .CC GTR 0
			THEN BEGIN
				IF .BITTMP[NUMVAL$VAL]
				THEN IF RMC_RDNUMA(.PASTPTR,8,.CC,DUMBY) LSS 0
					THEN RETURN -1
				ELSE
				BEGIN
				  SELECTONE FND_PATTERN(.PASTPTR,.CC,RMCOPTTAB) OF
				  SET
				  [SELF$SWITCH]:
					BEGIN
					  BITTMP[END$VAL]=1;
					  BITTMP[NUMVAL$VAL]=0
					END;
				  [OTHERWISE]: RETURN -1
				TES;
				END;
				BITTMP[START$VAL]=0;
				CH$WCHAR(%O'0',.PRESENTPTR);
				BITTMP[END$VAL]=1;
			    END
		END;

	[%O'0']:
		BEGIN
		  IF NOT .BITTMP[END$VAL] THEN
			IF .BITTMP[START$VAL] AND .CC GTR 0
			THEN BEGIN
				BITTMP[START$VAL]=0;
				IF .BITTMP[NUMVAL$VAL]
				THEN	BEGIN
					IF RMC_RDNUMA(.PASTPTR,8,.CC,DUMBY) LSS 0
					THEN RETURN -1;
					END
				ELSE
				BEGIN
				  SELECTONE FND_PATTERN(.PASTPTR,.CC,RMCOPTTAB) OF
				  SET
				  [SELF$SWITCH]:  BITTMP[END$VAL]=1;
				  [OTHERWISE]:  RETURN -1;
				TES;
				END
			    END
			ELSE RETURN -1
		  ELSE IF .CC NEQ 0 THEN RETURN -1;
		  IF .CHARCOUNT+1 EQL 0 THEN RETURN .BITTMP[NUMVAL$VAL]
		  ELSE IF .CHARCOUNT LSS 0
		  THEN RETURN -1
		END;
	[OTHERWISE]:  RETURN -1
	TES;
	END;
    END;
END;


GLOBAL ROUTINE RMC_SWITCH(TEXTPTR,CHARCOUNT)=
BEGIN
!++
!
! FUNCTIONAL DESCRIPTION:
!
!
! FORMAL PARAMETERS:
!
! IMPLICIT INPUTS:
!
! IMPLICIT OUTPUTS:
!
! ROUTINE VALUE:
!
! SIDE EFFECTS:
!
!--



LOCAL 
	OPTION_CODE;	!SELECTED OPTION CODE OF SELECTED SWITCH

LOCAL	EVALPTR: REF EVAL_BLK,
	SDBKPTR: REF SD_RMCBLK;

EVALPTR=EVALBLK;
SDBKPTR=SDRMCBLK;

OPTION_CODE=FND_PATTERN(.TEXTPTR,.CHARCOUNT,RMCOPTTAB);

BEGIN SELECTONE .OPTION_CODE  OF
	SET
	[LOG$SWITCH]:	BEGIN
			  IF .SDBKPTR[RMC$O_CODE] OR .EVALPTR[EVAL$S_NOLOG]
			!THIS OPTION SWITCH IS ALREADY SET
			!OR NOLOG HAS BEEN SPECIFIED
			  THEN OPTION_CODE=-1
			  ELSE
			    BEGIN
				SDBKPTR[RMC$O_CODE]=1;
				EVALPTR[EVAL$SWTCHFUNCT]=.OPTION_CODE
			    END
			END;
	[NOLOG$SWITCH]:	BEGIN
			!THIS OPTION STOPS THE LOG FILE
				SDBKPTR[RMC$O_CODE]=0;
				EVALPTR[EVAL$S_NOLOG]=1
			END;
	[WAIT$SWITCH]:	BEGIN
			  IF .SDBKPTR[RMC$O_WAIT]
			!THIS OPTION SWITCH IS ALREADY SET
			  THEN OPTION_CODE=-1
			  ELSE EVALPTR[EVAL$SWTCHFUNCT]=.OPTION_CODE
			END;
	[PRIOR$SWITCH]:	BEGIN
			  IF .SDBKPTR[SD$PRIOR] NEQ 10
			  !THIS OPTION SWITCH IS ALREADY SET
			  THEN OPTION_CODE=-1
			  ELSE EVALPTR[EVAL$SWTCHFUNCT]=.OPTION_CODE
			END;
	[OPR$SWITCH]:	SDBKPTR[RMC$O_OPR]=1;
	[BIN16$SWITCH]:	BEGIN
			  IF .SDBKPTR[RMC$O_B11I] OR .SDBKPTR[RMC$O_B11P]
			!THIS OPTION SWITCH IS ALREADY SET
			  THEN OPTION_CODE=-1
			  ELSE
			    BEGIN
				SDBKPTR[RMC$O_B11P]=1;
				!MAKE THE BIN16 SWITCH DEFAULT 'PACKED'
				EVALPTR[EVAL$SWTCHFUNCT]=.OPTION_CODE
			    END
			END;
	[REN$SWITCH]:	BEGIN
			  IF .SDBKPTR[SD$RMCFUN] EQL RMC$F_REN
			  !THIS OPTION SWITCH IS ALREADY SET
			  THEN OPTION_CODE=-1
			  ELSE
			    BEGIN
				IF .SDBKPTR[SD$RMCFUN] EQL 0 OR
				.SDBKPTR[SD$RMCFUN] EQL RMC$F_SEND OR
 				.SDBKPTR[SD$RMCFUN] EQL RMC$F_GET 
				THEN SDBKPTR[SD$RMCFUN]= RMC$F_REN
				ELSE OPTION_CODE=-4
			    END
			END;
	[APPEND$SWITCH]: SDBKPTR[RMC$O_APPD]=1;
	[DIRECT$SWITCH]:  !THIS SWITCH NOT IMPLEMENTED
			  OPTION_CODE=-2;
	[SUPER$SWITCH]: SDBKPTR[RMC$O_SU]=1;
	[CONTIG$SWITCH]:  !THIS SWITCH NOT IMPLEMENTED
			  OPTION_CODE=-2;
	[BLOCK$SWITCH]: SDBKPTR[RMC$O_ASCB]=SDBKPTR[RMC$O_ASC]=1;
	[ACCT$SWITCH]:  !THIS SWITCH NOT IMPLEMENTED
			  OPTION_CODE=-2;
	[DELETE$SWITCH]:BEGIN
			  IF .EVALPTR[EVAL$S_SIDE]
			!IF TRUE THEN DEL IS ON RIGHT SIDE OF CMD STRG
			!(DELETE SOURCE FILE AFTER TRANSFER)
			  THEN SDBKPTR[RMC$O_DE]=1
			!ELSE LEFT SIDE
			  ELSE IF .SDBKPTR[SD$RMCFUN] NEQ 0
				THEN OPTION_CODE=-4
				ELSE SDBKPTR[SD$RMCFUN]=RMC$F_DEL
			END;
	[SIXBIT$SWITCH]: SDBKPTR[RMC$O_SBIT]=1;
	[BIN36$SWITCH]: SDBKPTR[RMC$O_B36]=1;
	[AFTER$SWITCH]:	BEGIN
			  IF .EVALPTR[EVAL$S_AFTERFLG]
			  !THIS OPTION SWITCH IS ALREADY SET
			  THEN OPTION_CODE=-1
			  ELSE EVALPTR[EVAL$SWTCHFUNCT]=.OPTION_CODE
			END;
	[ASCII$SWITCH]:  SDBKPTR[RMC$O_ASC]=1;
	[RTS$SWITCH]:	  !THIS SWITCH NOT IMPLEMENTED
			  OPTION_CODE=-2;
	[ENCRYPT$SWITCH]:  !THIS SWITCH NOT IMPLEMENTED
			  OPTION_CODE=-2;
	[CHKSUM$SWITCH]:  !THIS SWITCH NOT IMPLEMENTED
			  OPTION_CODE=-2;
	[LIST$SWITCH]:BEGIN
			IF .SDBKPTR[SD$RMCFUN] EQL 0 
			THEN  EVALPTR[EVAL$SWTCHFUNCT]=.OPTION_CODE
			ELSE OPTION_CODE=-4
		    END;
	[LIMIT$SWITCH]: EVALPTR[EVAL$SWTCHFUNCT]=.OPTION_CODE;
	[KILL$SWITCH]:BEGIN
			IF .SDBKPTR[SD$RMCFUN] EQL 0 
			THEN EVALPTR[EVAL$SWTCHFUNCT]=.OPTION_CODE
			ELSE OPTION_CODE=-4
		    END;
	[PROTECT$SWITCH]: EVALPTR[EVAL$SWTCHFUNCT]=0;
	[SYSTEM$SWITCH]: EVALPTR[EVAL$SWTCHFUNCT]=.OPTION_CODE;
	[OWNER$SWITCH]: EVALPTR[EVAL$SWTCHFUNCT]=.OPTION_CODE;
	[GROUP$SWITCH]: EVALPTR[EVAL$SWTCHFUNCT]=.OPTION_CODE;
	[WORLD$SWITCH]: EVALPTR[EVAL$SWTCHFUNCT]=.OPTION_CODE;
	[OTHERWISE]:	OPTION_CODE=-3
	TES;
END;
SELECTONE .OPTION_CODE OF 
	SET
	[-1]:	OPTION_CODE=RMC_MSG(RMCSAS,S$SEVERE_HOLD);
	[-2]:	OPTION_CODE=RMC_MSG(RMCSNI,S$SEVERE_HOLD);
	[-3]:	OPTION_CODE=RMC_MSG(RMCISS,S$SEVERE_HOLD);
	[-4]:	OPTION_CODE=RMC_MSG(RMCICS,S$SEVERE_HOLD);
	[OTHERWISE]: RETURN EVALPTR[EVAL$S_SWITCH]=0
	TES;
	MSGERR(.TEXTPTR,S$MSGCRLF);
	RETURN .OPTION_CODE
END;





GLOBAL ROUTINE RMC_SOPTION=
BEGIN
!++
!
! FUNCTIONAL DESCRIPTION:
!
!
! FORMAL PARAMETERS:
!
! IMPLICIT INPUTS:
!
! IMPLICIT OUTPUTS:
!
! ROUTINE VALUE:
!
! SIDE EFFECTS:
!
!--

LABEL LOOP;

LOCAL
	TEXTPTR,
	TEXTCNT,
	ERRORCODE;


LOCAL	EVALPTR: REF EVAL_BLK,
	SDBKPTR: REF SD_RMCBLK;

ERRORCODE=0;		!ZERO ERRORCODE FOR RETURN VALUE

EVALPTR=EVALBLK;
SDBKPTR=SDRMCBLK;

TEXTPTR=.EVALPTR[EVAL$FILESPCPTR];
TEXTCNT=.EVALPTR[EVAL$FILESPECCC];

IF .TEXTCNT NEQ 0 AND (CH$RCHAR(.TEXTPTR) EQL %C':')
THEN BEGIN
	  TEXTPTR=CH$PLUS(.TEXTPTR,1); 	!MUST BYPASS SWITCH ':'
	 TEXTCNT=.TEXTCNT-1
     END;
LOOP:BEGIN
SELECTONE .EVALPTR[EVAL$SWTCHFUNCT] OF
	SET
	
	[LOG$SWITCH]:	BEGIN
			  IF .TEXTCNT GTR 0
			  THEN 
			  BEGIN
			  IF (ERRORCODE=RMC_FPARSE(.SDBKPTR[SD$LDAP_NOD],.TEXTPTR,TEXTCNT)) LSS 0
			  THEN RETURN .ERRORCODE;
			  END
			  ELSE TEXTCNT =0;
			  SDBKPTR[SD$CNT_LOG]=.TEXTCNT;
			  SDBKPTR[SD$PTR_LOG]=.TEXTPTR;
			!THE FINAL LOG FILE SET UP WILL BE PERFORMED
			!IN THE RMCSEM MODULE
			END;

	[WAIT$SWITCH]:	BEGIN
			    IF (SDBKPTR[SD$WAIT]=ERRORCODE=RMC_AFTER(.TEXTPTR,.TEXTCNT)) LSS 0
			    THEN LEAVE LOOP
			    ELSE SDBKPTR[RMC$O_WAIT]=1
			END;

	[AFTER$SWITCH]:	BEGIN
			  IF .TEXTCNT NEQ 0
			  THEN
			    IF (SDBKPTR[SD$AFTER]=ERRORCODE=RMC_AFTER(.TEXTPTR,.TEXTCNT)) LSS 0
			    THEN BEGIN
				  LEAVE LOOP
				END
			    ELSE EVALPTR[EVAL$S_AFTERFLG]=1

			  ELSE BEGIN
				  LEAVE LOOP
				END;
			END;

	[LIST$SWITCH]:	BEGIN
			  LOCAL PARAMVAL,PTRVAL,PPNPTR;
			  PPNPTR=0;	!SET PPN FIELD TO ZERO
			  EVALPTR[EVAL$S_LIST]=1;	!SET LIST FLAG
			  PARAMVAL=QFN$NONE;
			  IF .TEXTCNT NEQ 0
			  THEN BEGIN
				IF (ERRORCODE=L_SWITCH(TEXTPTR,.TEXTCNT)) LSS 0
				THEN LEAVE LOOP
				ELSE BEGIN
					PTRVAL=.TEXTPTR;
					IF .ERRORCODE EQL 0
					THEN PARAMVAL=QFN$SELF
					ELSE PARAMVAL=QFN$PPN
				     END;
				END;
			  SELECTONE QFUNC(QFN$LIST,.PARAMVAL,.PTRVAL,.PPNPTR) OF
			  SET
			[QFN$OK]:  0;
			[QFN$ILP]:RETURN RMC_MSG(RMCI26,S$SEVERE);
			[QFN$ILF]:RETURN RMC_MSG(RMCI27,S$SEVERE);
			[OTHERWISE]:RETURN RMC_MSG(RMCI28,S$SEVERE)
			TES;
			END;

	[PRIOR$SWITCH]:BEGIN
			  LOCAL NUM;
			  IF .TEXTCNT GTR 0
			  THEN BEGIN
				 IF (ERRORCODE=RMC_RDNUMA(.TEXTPTR,10,.TEXTCNT,NUM)) LSS 0
				 THEN 
				 ELSE IF .NUM LSSU 63
				!62 IS THE MAX PRIORITY ALLOW
					THEN SDBKPTR[SD$PRIOR]=.NUM
					ELSE ERRORCODE=-1
				END
			END;


	[LIMIT$SWITCH]:BEGIN
			  LOCAL NUM;
			  IF .TEXTCNT GTR 0
			  THEN BEGIN
				 IF (ERRORCODE=RMC_RDNUMA(.TEXTPTR,10,.TEXTCNT,NUM)) LSS 0
				 THEN
				 ELSE SDBKPTR[SD$LIMIT]=.NUM;
				  EVALPTR[EVAL$S_LIMIT]=1	!SET LIMIT FLAG
				END
			END;
	[SYSTEM$SWITCH]:BEGIN
				 IF (ERRORCODE=RMC_PROTECT(.TEXTPTR,.TEXTCNT,SDBKPTR[SD$SYSPROTECT])) LSS 0
				 THEN LEAVE LOOP
			END;
	[OWNER$SWITCH]:	BEGIN
				 IF (ERRORCODE=RMC_PROTECT(.TEXTPTR,.TEXTCNT,SDBKPTR[SD$OWNPROTECT])) LSS 0
				 THEN LEAVE LOOP
			END;
	[WORLD$SWITCH]:	BEGIN
				 IF (ERRORCODE=RMC_PROTECT(.TEXTPTR,.TEXTCNT,SDBKPTR[SD$WORPROTECT])) LSS 0
				 THEN LEAVE LOOP
			END;
	[GROUP$SWITCH]:	BEGIN
				 IF (ERRORCODE=RMC_PROTECT(.TEXTPTR,.TEXTCNT,SDBKPTR[SD$GRPPROTECT])) LSS 0
				 THEN LEAVE LOOP
			END;
	[KILL$SWITCH]:	BEGIN
			  LOCAL PARAMVAL,PTRVAL,PPNPTR;
			  PPNPTR=0;	!SET PPN FIELD TO ZERO
			  EVALPTR[EVAL$S_KILL]=1;	!SET KILL FLAG
			  ERRORCODE=-1;	!SET DEFAULT TO ERROR
			  IF .TEXTCNT NEQ 0
			  THEN BEGIN
			  LOCAL FILEPTR:	REF FILE$ARG;
			  FILEPTR=SOURCE_FILE$BLK;
			!CHK THE LEGALITY OF SYNTAX 
			  IF (TOPS10_PARSECHK(.TEXTPTR,TEXTCNT)) LSS 0
			  THEN LEAVE LOOP;
			  ZEROBLK(SOURCE_FILE$BLK,FILE$SIZE_ARG);

			  FILE_SPEC(.TEXTPTR,.TEXTCNT,.FILEPTR);
			  IF .FILEPTR[DSK$CNT] NEQ 0 AND .FILEPTR[FILE$CNT] EQL 0
			  THEN LEAVE LOOP;
			  IF .FILEPTR[SFD$CNT] NEQ 0 OR .FILEPTR[EXT$CNT] NEQ 0
			  THEN LEAVE LOOP;
			  IF .FILEPTR[DSK$CNT] NEQ 0
		  	THEN SELECTONE (FND_PATTERN(.FILEPTR[DSK$PTR],.FILEPTR[DSK$CNT],RMCOPTTAB)) OF
			SET
			[SEQ$SWITCH]:BEGIN
				IF RMC_RDNUMA(.FILEPTR[FILE$PTR],10,.FILEPTR[FILE$CNT],PTRVAL) LSS 0
				THEN LEAVE LOOP;
				IF .FILEPTR[PPN$CNT] EQL 0
				THEN PARAMVAL=QFN$SEQ
				ELSE PARAMVAL=QFN$SEQPPN;
				PTRVAL=.FILEPTR[FILE$PTR]
				!SET PTRVAL TO SEQUENCE NUMBER STRING
			    END;

			[OTHERWISE]: LEAVE LOOP
			TES
			ELSE IF .FILEPTR[FILE$CNT] NEQ 0
			THEN BEGIN
				IF .FILEPTR[PPN$CNT] EQL 0
				THEN PARAMVAL=QFN$JOB
				ELSE PARAMVAL=QFN$JOBPPN;
				!SET PTRVAL TO JOBNAME STRING
				PTRVAL=.FILEPTR[FILE$PTR]
			     END
				ELSE LEAVE LOOP;	!JUST A PPN NO SEQ/JOB
			PPNPTR=.FILEPTR[PPN$PTR];

			  SELECTONE QFUNC(QFN$KILL,.PARAMVAL,.PTRVAL,.PPNPTR) OF
			  SET
			[QFN$OK]:0;
			[QFN$ILP]:RETURN RMC_MSG(RMCI26,S$SEVERE);
			[QFN$ILF]:RETURN RMC_MSG(RMCI27,S$SEVERE);
			[OTHERWISE]: RETURN RMC_MSG(RMCI28,S$SEVERE);
			TES;
			ERRORCODE=0;	!CLEAR ERROR STATE
			END;
			END;

	[BIN16$SWITCH]:	BEGIN
			IF .TEXTCNT NEQ 0
			  THEN SELECTONE B16_SWITCH(.TEXTPTR,.TEXTCNT) OF
			  SET
				[ZERO]: SDBKPTR[RMC$O_B11P]=1;
				[IMAGE$SWITCH]: SDBKPTR[RMC$O_B11I]=1;
				[PACKED$SWITCH]: SDBKPTR[RMC$O_B11P]=1;
				[OTHERWISE]:	ERRORCODE=-1;
			  TES
			  ELSE SDBKPTR[RMC$O_B11P]=1;
			END;

	[OTHERWISE]:	BEGIN
				ERRORCODE=-1
			END
	TES;
	END;	!END_OF_LOOP
IF .ERRORCODE LSS 0
THEN BEGIN
	ERRORCODE= RMC_MSG(RMCISV,S$SEVERE_HOLD);
	MSGERR(.TEXTPTR,S$MSGCRLF);
	RETURN .ERRORCODE
    END
ELSE
!CLEAR TEMPERORAY FILE SPEC PTR/CNT
EVALPTR[EVAL$FILESPCPTR]=0;
EVALPTR[EVAL$FILESPECCC]=0;

EVALPTR[EVAL$SWTCHFUNCT]=0

END;






GLOBAL ROUTINE MORE_CHK(WORKINGPTR)=
BEGIN

!AN ASSUMPTION IN THIS ROUTINE IS THAT A
!CONTINUATION SWITCH CAN OCCURR ONLY ONCE IN AN INPUT 
!STRING BUT MANY TIMES IN THE COMPLETE CMD STRING.

LOCAL CHARCOUNT,TMPPTR;


BEGIN
  TMPPTR=.WORKINGPTR;
  CHARCOUNT=RMC_STRIPSTRING(TMPPTR);
  IF .CHARCOUNT GTR 0
  THEN IF FND_PATTERN(.WORKINGPTR,.CHARCOUNT,RMCOPTTAB) EQL MORE$SWITCH
  THEN BEGIN
	 TOTALCHARCOUNT=.TOTALCHARCOUNT-(.CHARCOUNT+1);
	IF CHK_NEXT_CHAR(.TMPPTR) NEQ C_N_C$NULL
	THEN RETURN RMC_MSG(RMCMSE,S$SEVERE)
	 ELSE	RETURN M_CHK$MORE
       END
  ELSE RETURN M_CHK$OK
	
  END;
END;







END
ELUDOM