.MCALL .MODULE
.MODULE DIRMAN,VERSION=05,COMMENT=
,IDENT=NO,GLOBAL=.DIRMN
; Copyright (c) 1998 by Mentec, Inc., Nashua, NH.
; All rights reserved
;
; 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 copies 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 Mentec, Inc.
;
; The information in this document is subject to change without
; notice and should not be construed as a commitment by Digital
; Equipment Corporation, or Mentec, Inc.
;
; Digital and Mentec assume no responsibility for the use or
; reliability of its software on equipment which is not supplied
; by Digital or Mentec, and listed in the Software Product
; Description.
;
; DIR (RT-11 Directory Program)
;
.NLIST
.LIST
;+
;
; Module DIRMAN
; This module contains the main program driver (and start address) for DIR.
; It also contains the routines DECODE and EXECUT which decode and execute
; a command line
;
;-
.SBTTL DIRECT- Main driver
;+
;
; DIRECT
; This is the main driving routine for DIR. It collects the command line,
; and calls other routines to decode the line and execute the command.
; It does not set up any registers, and only destroys R0.
;
;-
XTERNL
XTERNL
GBLDAT
GBLDAT
GBLDAT
GBLDAT ;MG01
GBLDAT
S$JSW = 44 ;These must be defined here for MACRO-11
S$USRL = 46 ; to process the ".=X" construct correctly.
.ASECT
. = S$JSW
.WORD JS.REE ;Set the reenter bit in the JSW
. = S$USRL
.WORD DIRECT ;The USR can swap over us here
ORIGIN DIR ;CG09
.ENABL LSB
BR RETRY ;Reentry point
DIRECT::
MOV SP,SAVESP ;Save the initial stack pointer
RETRY::
.WAIT #ICHAN ;Wait for all I/O to finish. This is
; mainly for magtapes under SJ.
.CLOSE #ICHAN ;Close the channel.
1$: MOV SAVESP,SP ;Restore the initial stack value
CALL INIT ;Initialize everything
.GVAL #IOAREA,#S$VER ;Get the system version number
BIC #^C377,R0 ;Clear the update number
CMP R0,#5 ;Is it the right version?
BGE 10$ ;Branch if so
;+
;ERROR
$ERROR VER,LEVEL=FATAL,RETURN=YES
;-
CLR R0 ;Hard exit
.EXIT ;Get out quick
10$: .CSISPC #FSPEC,#DEFEXT,#0,#OBUF ;Get a command line
BCS 1$ ;Try again on errors
TST OBUF ;Did the user type anything?
BNE 2$ ;Branch if he did
.PRINT #VERSON ;Else print our version.
BR 1$ ; and get another line
2$: CALL FILCHK ;Check the filespecs
CALL DECODE ;Decode the command line
CALL FETCH ;Fetch handlers and determine device types
CALL DEFALT ;Set up some defaults
CALL FILES ;.ENTERs, .LOOKUPs, and VOL IDs are done here
CALL EXECUT ; and execute it.
BR RETRY ;Go get another line.
.DSABL LSB
.SBTTL DECODE- Command line decoder
;+
;
; DECODE
; This routine decodes the command line collected in DIRECT. It
; determines whether or not an option is valid, and if so, it dispatches
; to the routine defined by the SWITCH macro for further processing.
; The following information is passed to the switch processing routines:
;
; R0 = The switch value or 0
; R2 -> The switch flag word
; R3 = The switch word passed by CSI on the stack
;
; R4 and R5 must not be modified by the switch processing routines.
;
;-
;XTERNL
GBLDAT
.ENABL LSB
ERROPT::.BYTE 0,200
DECODE::
MOV (SP)+,R5 ;Save the return address
MOV (SP)+,R4 ;Get the number of switches
BEQ 4$ ;Branch if no switches
1$: MOV #SWLIST,R1 ;Point the the switch list
MOV #ACTLST,R2 ;Point the the switch action routine list
MOV (SP)+,R3 ;Get the switch
BMI 2$ ;Branch if a value was given
CLR -(SP) ;Else fake one.
2$: BICB #40,R3 ;Convert it to uppercase ;DBF
CMPB R3,(R1)+ ;Is this the switch
BEQ 3$ ;Branch if so
ADD #ACTSIZ,R2 ;Else bump the action routine pointer
TST @R2 ;Any more possible matches?
BNE 2$ ;Branch if so
MOVB R3,ERROPT ;Get switch into error area
;+
;ERROR
$ERROR ILO,LEVEL=FATAL,RETURN=NO,ASCII=#ERROPT ;Then it must be an error
;-
3$: MOV (SP)+,R0 ;Get the switch value
JSR PC,@(R2)+ ;Call the action routine
DEC R4 ;Decrement the switch counter
BNE 1$ ;If any more there, go do another
4$: MOV R5,-(SP) ;Restore the return value.
RETURN
.DSABL LSB
.SBTTL EXECUT- Execute a command line
;+
;
; EXECUT
; This routine is the command execution driver. It first outputs the date,
; (set up by INIT), and if requested, the volume id and owner name, (if FILES
; thoght they were valid). It then calls SETUP to format the input filenames
; for the match routines. Now it loops calling GETFIL, MATCH1, and CHEKIT
; until GETFIL indicates that there are no more directory entries. CLOSE
; is then called to finish up any output and to close the output channel.
;
; SWV has different meanings depending on its contents. The following ;MG02+
; table will help explain:
;
; SWV contents Meaning
; ------------ -------
; 0 VOL not requested; do DIR
; 1 VOL requested; do DIR
; -1 VOL requested, but bad; do DIR
; ^RONL (57774) VOL:ONL requested; don't do DIR
; -^RONL (-57774) VOL:ONL requested, but bad; don't do DIR ;MG02-
;
;-
XTERNL
GBLDAT
.ENABL LSB ;CG09
EXECUT::
MOV #BUFFER,R2 ;Point R2 at the line buffer
MOVB #BLANK,(R2)+ ;Store a blank
MOV #DAY,R0 ;Point to the converted system date
TST @R0 ;Is there a system date?
BEQ 1$ ;Branch if not
CALL OUTDAT ;Put it in the buffer
1$: TST SWO ;Is this to be in octal?
BEQ 2$ ;Branch if not
FORMAT ,< Octal> ;Remind the user
2$: FORMAT ,<[/> ;Put a in the buffer
PRTIT #BUFFER ;Print the date ;MG02+
TST SWV ;Does he want a VOLID?
BEQ 4$ ;Nope...just a DIRectory
BMI 30$ ;Yes...but VOLID is invalid
MOV #IBUF+1000,R1 ;R1->VOL/OWNER info
MOV R1,R2 ;R2->Same thing
3$: CMPB @R2,#200 ;Is this the end?
BEQ 4$ ;If so, we really don't want to print it
TSTB (R2)+ ;Are we at the end of the string?
BNE 3$ ;Branch if not
DEC R2 ;We don't want to print the Null ;BS
PRTIT ;FILES set it up for us, so print it
30$: BIT #1,SWV ;Does he still get a DIR?
BNE 4$ ;Yes...so give it to him
CALL CLRBUF ;Nope...dump the line if not TT:
BR 7$ ; and done. ;MG02-
4$: CALL SETUP ;Setup for match routines.
5$: CALL GETFIL ;Get a file from the directory
BCS 6$ ;Branch if done
CALL MATCH1 ;Try to match it against input files.
CALL CHEKIT ;Figure out what to do with it.
BR 5$ ;Try for another one.
6$: CALL CLOSE ;Finish up statistics and I/O
7$: RETURN
.DSABL LSB ;CG09
.SBTTL GETFIL- Get a directory entry
;+
; GETFIL
; This routine determines which of the directory entry routines
; should be used (NEXTDK, NEXTMT or NEXTCT). It then JMP's to
; the appropriate routine, which returns to the mainline code.
;-
XTERNL
GBLDAT
GETFIL::
TST DEVCT ;Input device a cassette?
BEQ 1$ ;Branch if not
JMP NEXTCT ;Else go to NEXTCT to get an entry
1$: TST DEVMT ;Input device a magtape?
BEQ 2$ ;Branch if not
JMP NEXTMT ;Go there to get an entry
2$: JMP NEXTDK ;Go to disk routine
.END DIRECT