; Program: CD ; Version: 3.0 ; Author: Richard Conn ; Date: 12 Apr 84 ; Previous Versions: None ; Derivation: In Concept from CD 2.4 for ZCPR2 VERSION EQU 33 ; There was still a problem with the way directories were logged in under ; BGii, because BGii, unlike Z33, will not accept the command DIR: to log ; in a password-protected directory that is within the allowed DU range and ; can be logged in using DU:. Now I use the DU: form in this case. ;VERSION EQU 32 ; Unfortunately, Bruce's code fails in an annoying way if the selected ; directory cannot be logged in using the forms DU: or DIR: (this is often ; the reason for using CD in the first place). In such cases, the user will ; be asked to repeat a password that has already been entered correctly. ; I have modified the code to check for this situation. If ZCPR33 is running, ; then its method of changing the default drive/user is used instead. If not, ; then the code checks to see if DU: or DIR: will be accepted. If so, that ; command line is prefixed to the multiple command line buffer. Otherwise, ; the old login method using a warm boot is used. The code now also checks ; for a completely illegal directory (e.g., a named directory with a nonloggable ; user number above 15). In that case, the multiple command line is flushed. ; Jay Sage, August 30, 1987 ; For ZCPR 3.3 & BGii compatilbility, ; Also deleted vestigial (this ain't ; CP/M 2 anymore...) messing with the ; CPR user/drive byte and annoying ; Warm Boots. ; @20:56:07 April 10, 1987 ; Bruce Morgen ;VERSION EQU 31 ; Responds to quiet flag. ; ??/??/8? Joe Wright Z3ENV DEFL 0FE00H ; CD is used to log into a new directory by name or DU (DIR or DU forms) ; and to automatically run ST once there if it is available. ; ; Syntax: ; CD or CD // <-- Print Help ; CD dir: <-- Log In and Run ST.COM ; OS and ASCII Equates FCB EQU 5CH CR EQU 0DH LF EQU 0AH ; Library Functions: SYSLIB, Z3LIB, Z33LIB EXTRN Z3INIT,Z3LOG,GETQUIET,PUTCL,DUTDIR,GETCL2,GETMDISK,GETMUSER EXTRN RETUD,EPRINT,EPSTR,COUT EXTRN MAFDC,PAFDC,INITFCB,F$EXIST EXTRN HIGHUSER,PDEFDU,Z33CHK,FCB1CHK ; Environment Definition IF Z3ENV NE 0 ; External ZCPR3 Environment Descriptor JP START DB 'Z3ENV' ; This is a ZCPR3 Utility DB 1 ; External Environment Descriptor Z3EADR: DW Z3ENV START: LD HL,(Z3EADR) ; Pt to ZCPR3 environment ELSE ; Internal ZCPR3 Environment Descriptor MACLIB Z3BASE.LIB MACLIB SYSENV.LIB Z3EADR: JP START SYSENV START: LD HL,Z3EADR ; Pt to ZCPR3 environment ENDIF ; Start of Program -- Initialize ZCPR3 Environment CALL Z3INIT ; Initialize the ZCPR3 Env LD A,(FCB+1) ; Check for help CP '/' ; Help? JP NZ,CD ; Skip ahead if not CALL EPRINT DB 'CD, Version ' DB [VERSION/10]+'0','.',[VERSION MOD 10]+'0' DB CR,LF,'Syntax:' DB CR,LF,' CD dir: or CD du: <-- Change Directory' DB 0 RET ; Log into DU converted by ZCPR3 CD: CALL Z33CHK ; See if we have ZCPR33 JP NZ,CD0 ; If not, skip directory validity test CALL FCB1CHK ; See if value directory given JP Z,CD0 ; If OK, skip message CALL EPRINT DEFB ' Illegal directory specification.',0 RET CD0: LD DE,FCB ; Point to FCB CALL Z3LOG ; Login to DU ; Validate the directory if above user 15 LD A,(FCB+13) ; Get user number CP 10H JP C,CD1 ; If in range 0..15, skip ahead CALL HIGHUSER ; See if Z33 and high users allowed JP NZ,CD1 ; If allowed, skip ahead CALL EPRINT ; Display error message DEFB ' Illegal user area ',0 LD A,(FCB+13) CALL PAFDC CALL EPRINT DEFB CR,LF,' All commands aborted.',0 CALL GETCL2 ; Terminate pending commands LD (HL),0 RET CD1: ; Add the ":ST" command to the command line if ST.COM exists in target ; directory LD DE,STFCB ; Point to FCB for ST.COM CALL INITFCB CALL F$EXIST ; Does ST.COM exist? JP Z,CD2 ; If not, proceed with login of directory LD HL,STCL ; Point to ":ST" command line CALL PUTCL ; Add it to multiple command line JP Z,CLERR ; Branch if overflow CD2: ; Log into the new directory CALL WRITEDU ; Form command of form DU:<0> CALL GETQUIET ; Display messages only if not quiet flag JP NZ,QUIET1 CALL EPRINT DB ' Logging Into ',0 LD HL,LOGCL ; Point to "DU:" string CALL EPSTR QUIET1: CALL RETUD ; Get user/drive CALL DUTDIR ; Convert DU to DIR JP Z,LOG ; Branch if directory has no name LD DE,LOGCL ; Copy directory name into LOGCL LD B,8 ; Maximum of 8 characters in name PRTNAME: LD A,(HL) ; Get character from NDR CP ' ' ; Done? JP Z,LOG LD (DE),A CALL GETQUIET LD A,(DE) ; Restore character CALL Z,COUT INC HL ; Point to next INC DE DEC B ; Count down JP NZ,PRTNAME LOG: EX DE,HL ; Switch LOGCL pointer to HL LD (HL),':' ; Add colon to command line INC HL LD (HL),0 ; Terminate LOGCL ; Log in directory: This is done either by putting drive/user into the ; message buffer (if Z33) or by putting DU: or DIR: in the command line (if ; allowed) or by putting drive/user into page 0 and warm booting (if nothing ; else will do the job). CALL RETUD ; Check for ZCPR33 CALL Z33CHK JP NZ,NOTZ33 CALL PDEFDU ; Make current DU the default RET ; That's all! ; Check whether directory can be logged into ; ..using DU: or DIR: forms. NOTZ33: CALL DUTDIR JP Z,CHKDU ; If no name, check the DU value LD DE,8 ; Offset to password ADD HL,DE LD A,(HL) ; See if there is a password CP ' ' JP Z,USECL ; If not, we can use the DIR: command line CHKDU: CALL WRITEDU ; Get "DU:<0>" back into LOGCL CALL GETMDISK ; See if drive in range DEC A ; Shift to range 0..15 CP B JP C,BOOTLOG ; If out of range, no choice but to warm boot CALL GETMUSER ; See if user in range CP C JP C,BOOTLOG ; If not, no choice but to warm boot USECL: LD HL,LOGCL ; Point to command line of form DU: or DIR: CALL PUTCL ; Store it in ZCPR3 CL Buffer RET NZ ; If no overflow, we are done CLERR: CALL GETQUIET RET NZ CALL EPRINT ; Print error message DB ' Command Line Overflow',0 RET BOOTLOG: LD A,C ; Shift user into high nibble RLCA RLCA RLCA RLCA OR B ; Join with drive in low nibble LD (4),A ; Store in user/drive byte in page 0 JP 0 ; Warm boot to log it in ; Subroutine to write "DU:<0>" into the LOGCL buffer WRITEDU: CALL RETUD ; Get DU into BC LD DE,LOGCL ; Point to destination LD A,B ; Get drive ADD A,'A' ; Convert to letter LD (DE),A INC DE LD A,C ; Get user number CALL MAFDC EX DE,HL LD (HL),':' ; Put in the colon INC HL LD (HL),0 ; And the null RET DSEG ; Buffers LOGCL: DS 10 ; Enough for any DU: or DIR: and null STCL: DB ':ST',0 STFCB: DB 0,'ST COM' ; Default command FCB DS 24 END