Google
 

Trailing-Edge - PDP-10 Archives - SRI_NIC_PERM_SRC_3_19910112 - utilities/dacces.mac
There are no other files named dacces.mac in the archive.
;<HELLIWELL>DACCES.MAC.12, 10-Mar-80 17:12:58, EDIT BY HELLIWELL
TITLE	DACCES - COMND JSYS PROGRAM TEMPLATE

SEARCH MONSYM,MACSYM
.REQUIRE SYS:MACREL
EXT <JSMSG0>

VGROUP==1
VMAJOR==3
VMINOR==0
VEDIT==4

DEFINE DATE<ASCIZ \10-March-80\>

A=1
B=2
C=3
D=4

;16 IS USED BY MACSYM

P=17

MAXJFN==^D20		;MAX 20 NESTED TAKES

MAXCHR==^D200

MAXLEN==<MAXCHR+5>/5

ABCHR==^D50

ABLEN==<ABCHR+5>/5

PDLLEN==20

DEFINE JCERR(TEXT)<
	ERCAL [	JSERR<TEXT>
		ret]>

DEFINE JRERR(TEXT)<
	ERJMP [	JSERR<TEXT>
		RET]>

DEFINE JSERR(TEXT)<
	CALL ERRDO
IFB<TEXT><HRROI A,[0]>
IFNB<TEXT><HRROI A,[ASCIZ \TEXT: \]>
	ESOUT
	CALL JSMSG0
>

DEFINE FMSG(TEXT,FJFN)<
IFB<FJFN><HRRZ A,OJFN>
IFNB<FJFN><HRRZ A,FJFN>
	HRROI B,[ASCIZ \TEXT\]
	SETZ C,
	SOUT
>

DEFINE FCHR(CHR,FJFN)<
IFB<FJFN><HRRZ A,OJFN>
IFNB<FJFN><HRRZ A,FJFN>
	MOVEI B,CHR
	BOUT
>
SUBTTL	MACROS

;LOAD A BLOCK WITH DATA AND ALLOCATE ENOUGH SPACE
;FOR LARGEST WORD

DEFINE LDBLK(LIST)<
..LEN==0
	IRP LIST,<LDWRD(LIST)>
	RELOC .+..LEN
>

;LOAD 1 WORD CHECK MAX LENGTH

DEFINE LDWRD(A)<.LDWRD(A)>

;USED TO STRIP OFF <>

DEFINE .LDWRD(A,B)<
	RELOC .+A
	IFB<B>,<0;>B
	RELOC .-A-1
IFGE A-..LEN,<..LEN==A+1>
>

;KEYWORD TABLE MACROS

DEFINE TABLE<
	...BEG==.
	BLOCK 1
>

DEFINE TEND<
...LEN==.-...BEG
.ORG ...BEG
	...LEN-1,,...LEN
.ORG .+...LEN
>

DEFINE T(TEXT,VALUE)<	[ASCIZ \TEXT\],,VALUE>

;LOAD A FUNCTION DESCRIPTOR BLOCK
;USE FLDDB. MACRO FROM MONSYM. ARGS AS FOLLOWS:
;FLDDB.(TYP,FLGS,DATA,HLPM,DEFM,LST)
;TYP	COMND FUNCTION CODE (I.E. .CMKEY)
;FLGS	FLAGS (I.E. CM%SDH, SUPPRESS DEFAULT HELP)
;DATA	ARG TO SPECIFIC FUNCTION (I.E. RADIX FOR .CMNUM)
;HLPM	USER SUPPLIED HELP STRING (AUTOMATICALLY SETS CM%HPP)
;DEFM	DEFAULT STRING (AUTOMATICALLY SETS CM%DPP)
;LST	POINTER TO NEXT FUNCTION DESCRIPTOR BLOCK

;LOAD A NOISE FUNCTION DESCRIPTOR BLOCK

DEFINE NOISE(TEXT)<FLDDB.(.CMNOI,,<-1,,[ASCIZ \TEXT\]>)>

;DEFINE SINGLE DATA WORD (OR WORDS)

DEFINE DATA(ADDR,SIZE)<
ADDR:	IFB<SIZE>,<BLOCK 1;>BLOCK SIZE
>

DEFINE CONFIRM(ERROR)<
	CALL DOCFM
IFB<ERROR>< JRST COMERR>
IFNB<ERROR>< JRST ERROR>
>


DEFINE NIY<
	TMSG <
?Not implemented yet.
>
	JRST COMLOP
>

DEFINE COMINI(TEXT)<
IFNB<TEXT><HRROI A,[ASCIZ \TEXT\]>
IFB<TEXT><HRROI A,CMBUF>
	CALL DOINI
>

DEFINE FIELD(FDB,ERROR)<
	MOVEI B,FDB
	CALL DOCOM
IFB<ERROR>< JRST COMERR>
IFNB<ERROR>< JRST ERROR>
>

DEFINE RFIELD(FDB)<
	MOVEI B,FDB
	MOVEI A,CMSTAT
	COMND
	 ERJMP ERSCAN
	TXNE A,CM%NOP
	JRST ERSCAN
>

DEFINE GETSTR(FI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 /CMD/]>>,<.GJNAM,<-1,,[ASCIZ /DACCES/]>>>)
TAKLEN==.-TAKBLK

COMCFM:	FLDDB.(.CMCFM)

;SAMPLES OF OTHER BLOCKS
;NOISE:	NOISE(<NOISE WORDS>)
;IFILE:	FLDDB.(.CMIFI)
;OFILE:	FLDDB.(.CMOFI)
;ARBFIL:FLDDB.(.CMFIL)
;FILBLK:	LDBLK(<<.GJGEN,GJ%OLD>,<.GJEXT,<-1,,[ASCIZ /EXT/]>>,<.GJNAM,<-1,,[ASCIZ /NAME/]>>>)
;FILLEN==.-FILBLK

DATA	REPPDL
DATA	REPPC
DATA	SYSCOM
DATA	CMJFNS
DATA	CMJFNP
DATA	JFNSTK,MAXJFN
DATA	OJFN
DATA	ACCFLG
DATA	DEVSAV,ABLEN
DATA	DEVDES
DATA	DIR,<2*<<^D39+5>/5>>

ACDIR:	LDBLK(<<.ACDIR,<-1,,DIR>>,<.ACPSW,0>,<.ACJOB,-1>>)
ACLEN==.-ACDIR

FILINI:	PUSH P,A
	SETZM CMGJFN
	MOVE A,[CMGJFN,,CMGJFN+1]
	BLT A,CMGJFN+15
	POP P,A
	HRRZ B,A
	HRRI A,CMGJFN
	BLT A,CMGJFN-1(B)
	RET
SUBTTL	STARTUP
STRT:	RESET
	MOVE P,[IOWD PDLLEN,PDL]
	MOVE A,[-MAXJFN,,JFNSTK-1]
	MOVEM A,CMJFNP
	SETOM SYSCOM
	SETZM CMJFNS
	SETZM OJFN
	SETZ A,
	RSCAN
	 ERJMP ERSCAN
	JUMPE A,ERSCAN
	COMINI()
	RFIELD(DACCES)		;MUST START WITH PROGRAM NAME, OR NO ERRORS
	MOVEI B,COMCFM
	MOVEI A,CMSTAT
	COMND
	 ERJMP REPAR1
	TXNE A,CM%NOP
	JRST REPAR1
;PROGRAM NAME<CR>, MAKE IT LOOK LIKE "R PROGRAM".
ERSCAN:	SETZM SYSCOM
	MOVEI A,.PRIOU
	CALL VERPNT
	TMSG <Type "HELP" for help.
>
COMLOP:	MOVE P,[IOWD PDLLEN,PDL]
	CALL CLEAN
	SKIPE CMJFNS			;DON'T EXIT DURING TAKE
	JRST COMLP1
	SKIPE SYSCOM
	HALTF
	SETZM SYSCOM
COMLP1:	HRROI A,[ASCIZ /DACCES>/]
	CALL DOINI
	CALL CLEAN
REPAR1:
;SETUP COMMAND DEFAULTS
	FIELD(COMAND,CMEOFC)
	HRRZ B,(B)
	JRST (B)

COMDON:	HRRZ A,OJFN
	JUMPE A,COMLOP
	CLOSF
	 JCERR <Failed to close output file>
	SETZM OJFN
	JRST COMLOP

REPARS:	MOVE P,REPPDL
	MOVE A,REPPC
	MOVEM A,(P)
	RET

DOINI:	MOVEM A,CMSTAT+.CMRTY
	MOVE A,(P)
	MOVEM A,REPPC
	MOVEM P,REPPDL
	SKIPN A,CMJFNS
	MOVE A,[.PRIIN,,.PRIOU]
	MOVEM A,CMSTAT+.CMIOJ
	MOVEI A,CMSTAT
	MOVEI B,INIBLK
	COMND
	 ERJMP FATAL
	TXNN A,CM%NOP
	RET
FATAL:	JSHLT

CMEOFC:	SKIPN CMJFNS
	JRST COMERR
	MOVEI A,.FHSLF
	GETER
	 ERJMP COMERR
	HRRZ B,B
	CAIE B,IOX4
	JRST COMERR
	TMSG <%End of >
	MOVEI A,.PRIOU
	HLRZ B,CMJFNS
	SETZ C,
	JFNS
	 JCERR<>
	TMSG <
>
	CALL TAKFIN
	JRST COMLOP

DOCFM:	MOVEI B,COMCFM
DOCOM:	MOVEI A,CMSTAT
	COMND
	 ERJMP R
	TXNE A,CM%NOP
	RET
	RETSKP

COMERR:	CALL ERRET
	JRST COMLOP

ERRET:	JSERR <Command error>
	RET

ERRDO:	SKIPN CMJFNS
	RET
	TMSG <%Error reading >
	MOVEI A,.PRIOU
	HLRZ B,CMJFNS
	SETZ C,
	JFNS
	 JCERR<>
	TMSG <, command file input terminated.
>
	CALL TAKFIN
	JRST ERRDO

TAKFIN:	HLRZ A,CMJFNS
	MOVE B,CMJFNP
	POP B,CMJFNS
	MOVEM B,CMJFNP
	CLOSF
	 JCERR <Error closing command file>
	RET

CLEAN:	MOVX A,CZ%ABT
	HRR A,OJFN
	TRNE A,-1
	CLOSF
	 JFCL
	SETZM OJFN
	HRROI A,[0]
	RSCAN
	 ERJMP .+1
	MOVX A,CZ%NCL!FLD(.FHSLF,CZ%PRH)
	CLZFF
	 JCERR <Failed to release unopened JFNs>
	RET

VERPNT:	HRROI B,[ASCIZ /DACCES version /]
	SETZ C,
	SOUT
	LDB B,[POINT 9,JOBVER,11]	;MAJOR
	MOVEI C,10
	NOUT
	 JCERR
	LDB B,[POINT 6,JOBVER,17]	;MINOR
	JUMPE B,NOMINR
	SUBI B,1
	IDIVI B,^D26
	JUMPE B,NOMINF
	MOVEI B,"A"-1(B)
	BOUT
NOMINF:	MOVEI B,"A"(C)
	BOUT
NOMINR:	HRRZ C,JOBVER			;EDIT
	JUMPE C,NOEDIT
	MOVEI B,"("
	BOUT
	MOVE B,C
	MOVEI C,10
	NOUT
	 JCERR
	MOVEI B,")"
	BOUT
NOEDIT:	LDB C,[POINT 3,JOBVER,2]
	JUMPE C,NOGRP
	MOVEI B,"-"
	BOUT
	MOVE B,C
	MOVEI C,10
	NOUT
	 JCERR
NOGRP:	HRROI B,[ASCIZ /, /]
	SETZ C,
	SOUT
	HRROI B,[DATE]
	SOUT
	HRROI B,[ASCIZ /
/]
	SOUT
	RET
SUBTTL	COMMAND HANDLERS
DOACC:	SKIPA A,[AC%OWN+ACLEN]
DOEACC:	MOVX A,AC%REM+ACLEN
	MOVEM A,ACCFLG
	FIELD(GETDEV)
	HRROI A,DEVSAV
	HRROI B,ABBUF
	SETZ C,
	SOUT
	MOVE A,[LOGBLK,,LOGLEN]
	CALL FILINI
	FIELD(LOGFIL)
	MOVEM B,OJFN
	CONFIRM
	HRRZ A,OJFN
	MOVX B,<FLD(7,OF%BSZ)!OF%WR>
	OPENF
	 ERJMP [JSERR <OPENF failed for output file>
		JRST COMLOP]
	HRROI A,DEVSAV
	STDEV
	 ERJMP NXDEV
	MOVEM B,DEVDES
	MOVE A,ACCFLG
	TXNE A,AC%REM
	JRST MNTD
	MOVEI A,.MSIMC
	HRLI A,1
	MOVEI B,C
	HRROI C,DEVSAV
	MSTR			;ATTEMPT MOUNT
	 ERJMP [MOVEI A,.FHSLF
		GETER
		HRRZ B,B
		CAIN B,MSTX31
		JRST MNTD
		JSERR <MSTR to mount device failed>
		JRST COMLOP]
	FMSG <%Structure ">
	HRROI B,DEVSAV
	SOUT
	FMSG <:" mounted.
>
MNTD:	HRROI A,DIR
	MOVE B,DEVDES
	DEVST
	 ERJMP [JSERR <DEVST failed on previously scanned device>
		JRST COMLOP]
	HRROI B,[ASCIZ /:[/]
	SETZ C,
	SOUT
	PUSH P,A
	MOVNI A,1
	HRROI B,C
	MOVEI C,.JIUNO
	GETJI
	 ERJMP [JSERR <GETJI failed to get logged in user number>
		JRST COMLOP]
	MOVE B,C
	POP P,A
	DIRST
	 ERJMP [JSERR <DIRST failed on logged in user name>
		JRST COMDON]
	MOVEI B,"]"
	IDPB B,A
	SETZ B,
	IDPB B,A
	MOVE A,ACCFLG
	TXNN A,AC%REM
	JRST DOACC1
	FMSG < Ending ACCESs to >
	JRST DOACC2

DOACC1:	FMSG < ACCESsing >
DOACC2:	MOVE A,OJFN
	HRROI B,DIR
	SETZ C,
	SOUT
	MOVE A,ACCFLG
	MOVEI B,ACDIR
	ACCES
	 ERJMP [JSERR <ACCES failed>
		JRST COMDON]
	FMSG < [OK]
>
	JRST COMDON

NXDEV:	MOVEI A,.FHSLF
	GETER
	HRRZ B,B
	CAIE B,STDVX1
	JRST [	JSERR <STDEV failed on device>
		JRST COMLOP]
	FMSG <%No such device as ">
	MOVE A,OJFN
	HRROI B,DEVSAV
	SETZ C,
	SOUT
	FMSG <", ACCESS aborted.
>
	JRST COMDON
SUBTTL	COMMAND HANDLERS
LEAVE:	CONFIRM
	HALTF
	JRST COMLOP

PNTHLP:	MOVE A,[HLPBLK,,HLPLEN]
	CALL FILINI
	FIELD(HLPFIL)
	MOVEM B,OJFN
	CONFIRM
	HRRZ A,OJFN
	MOVX B,<FLD(7,OF%BSZ)!OF%WR>
	OPENF
	 ERJMP [JSERR <OPENF failed for output file>
		JRST COMLOP]
	HRRZ A,OJFN
	CALL VERPNT
	HRRZ A,OJFN
	HRROI B,HLPMES
	SETZ C,
	SOUT
	JRST COMDON

HLPMES:	ASCIZ \
This program is designed to allow access to a structure via the user's
logged in directory name. This is useful in batch files when the user who
submitted the file is not always known. The following commands exist:

ACCESS <device> <output filespec>
	Does the equivalent of the "ACCESS device:<dir>" EXEC command.
	The user's logged in directory name is substituted for <dir>.
	One error is handled specially, if there is no such device as the
	one specified, the message:

	%No such device as "device", ACCESS aborted.

	is issued. If the structure is available, but not mounted the
	program will mount it for you. The <output filespec> defaults to
	TTY:. All normal processing message go to this file. Error messages
	will always go to TTY:.

END-ACCESS <device> <output filespec>
	Will relinquish access to same directory as ACCESS command above.
	If some other directory was accessed, this command will fail. Same
	errors may occur as for ACCESS command. Again, normal output goes
	to the <output filespec>, default TTY:.

EXIT
	Exit to EXEC.

HELP
	Type this text.

TAKE <filespec>
	Take commands from file. "TAKE" commands may be nested. When EOF
	is reached, the message "%End of filespec." is printed. If you
	Say "TAKE" with no filespec, input is terminated with no message.

In addition, the program may be given a command on the EXEC command line
as in:

DACCES command line

If "DACCES" is successfully parsed, the command will exit upon completion
of the command. If a TAKE is done, the program will not exit until all
take files are completed.
\

DOTAKE:	MOVE A,[TAKBLK,,TAKLEN]
	CALL FILINI
	FIELD(TAKFIL)
	HRRZ C,C
	CAIN C,COMCFM
	JRST DOTAK1
	MOVE D,B
	CONFIRM
	MOVE A,CMJFNP
	AOBJP A,[CALL ERRDO
		TMSG <?Too many nested "TAKE" commands.
>
		JRST COMLOP]
	MOVE A,D
	MOVX B,<FLD(7,OF%BSZ)!OF%RD>
	OPENF
	 ERJMP [JSERR <Error opening command input file.
>
		JRST COMLOP]
	MOVE A,CMJFNP
	PUSH A,CMJFNS
	MOVEM A,CMJFNP
	HRLI D,.NULIO
	MOVSM D,CMJFNS
	JRST COMLOP

DOTAK1:	SKIPE CMJFNS
	CALL TAKFIN
	JRST COMLOP

END XWD EVL,EV