home *** CD-ROM | disk | FTP | other *** search
- .printx Reading ZFSUBS3.Z80
- ;===========================================================================
- ;
- ; ZFSUBS3.Z80 - file name and mask processing
- ;
- ;===========================================================================
-
-
- ; Get file name from user and process into FCB pted to by DE
- ; returns: B = disk number
- ; C = user number
-
- filename:
- push de ; Save fcb ptr
- call getfspec ; Get file specification from user
- jr z,fnamer ; Exit on null input line.
- pop de ; Restore fcb ptr.
- call fname ; Call syslib routine.
- ld a,(hl) ; Get terminating character.
- cp ' ' ; Terminated by space?
- ret z
- or a ; Terminated by null?
- ret z
- fnamer:
- call erclr ; Clear error message line.
- jp loop ; Error - restart command.
-
-
- ;---------------------------------------------------------------------------
-
- ; Get File specification/Command line from user
- ; On exit - HL -> first character in command line
- ; A = first non-space character in command line
- ; E = first entered character in command line (may be space)
- ; Z = Z if null command line,
- ; NZ if significant characters.
-
- getfspec: ; Get file specification
- ld b,20 ; Length of file specification
- jr getline ; Get line from user.
-
- getzcmd: ; Get zcpr3 command
- ld b,253 ; Maximum length of zcpr3 command line
-
- getline: ; Common code - user line input
- ld hl,(cmdbuf) ; Get command line location
- ld (hl),b ; Set command line length
- inc hl ; Init actual count.
- ld (hl),0
- push hl ; Save ptr to actual count.
- ex de,hl ; De pts to buffer
- dec de ; Beginning
- ld c,rdbuf ; Read line from user
- call bdosptr
-
- pop hl ; Pt to actual count.
- ld e,(hl) ; Get actual count in de
- ld d,0 ; (zero high-order offset)
-
- inc hl ; Pt to first char
- push hl ; Save current ptr for later
- add hl,de ; Pt to end of string
- ld (hl),0 ; Store ending zero
-
- pop hl ; Pt to first char of command line
- ld d,(hl) ; Save true first character in D
- call sksp ; Ignore leading spaces.
- ld a,(hl) ; Get 1st significant character.
- or a ; Test for empty line.
- ret
-
-
- ;---------------------------------------------------------------------------
-
- ; FILEMASK - GET/PUT File Selection mask (in system file 4 or on stack)
- ; on entry, A = 0 to PUT file mask from FCB.
- ; otherwise GET file mask to FCB.
- ;
- ; The option flags are no longer encoded as high bits on the file mask,
- ; which limited NOPT to 11. The routine has therefore been simplified.
- ; <rdf>
-
- maskoff equ 19 ; Shell stack offset
-
- filemask:
-
- if usestk ; If using stack for file mask
-
- push af ; Save get/put flag
-
- call getsh2 ; Get data on shell stack
- ld de,maskoff ; Offset into stack entry
- add hl,de
-
- ld de,fcb+1 ; Pt to fcb
- ld b,11 ; Repeat for 11 characters
-
- pop af ; Restore get/put flag
- or a ; See if get or put
- jr nz,getmask
- ex de,hl ; Putmask
- getmask:
- call jchk ; Check for no file spec and set pointer
- call smoveb
- ret
-
- jchk:
- ld a,(hl) ; Check first character of source file name
- cp ' ' ; Is it blank?
- jr z,jchk1
- cp '/' ; Help specifier?
- ret nz ; Neither, then leave pointer as it is
- jchk1:
- ld hl,joker ; Else, use joker '????????.???' as file
- ret
-
- else ; not usestk
-
- push af ; Save get/put flag
-
- call getfn2 ; Pt to first system file name
- ld de,11*3 ; Pt to 4th file name
- add hl,de
- ld de,fcb+1 ; Pt to fcb
-
- pop af ; Restore get/put flag
- or a ; Test it.
-
- jr nz,fmask1 ; Br if get.
- ex de,hl ; Swap pointers for put.
-
- fmask1:
- ld b,11 ; 11 bytes
- call smoveb
-
- ld hl,joker ; Treat as '*.*' with 'joker'..
- ld b,11 ; # of characters to move
- ld a,(de) ; Get first char of file name
- cp ' ' ; If space, fill with *.*
- call z,smoveb ; Set file id to *.*
-
- ld a,(de) ; Get first char of file name
- cp '/' ; If opt, fill with *.*
- call z,smoveb
- ret
-
- endif ; usestk
-
- ;---------------------------------------------------------------------------
-
- ; VFY$D$U - Resolve DU or DIR and verify Access
- ; on entry, HL -> file specification
- ; on exit, HL is unchanged
- ; BC = DU for DU/DIR
- ; Z = Z if DU/DIR resolution error,
- ; NZ if DU/DIR resolved ok.
- ; C = C if access denied,
- ; NC if no password or password OK
-
- vfy$d$u:
- push hl ; Save file spec pointer
- ld a,1 ; Look for DIR:, then DU:
- call dnscan ; Resolve DIR: or DU: form and return DU
- jr nz,vfydu1 ; Branch if resolved
- ; If not resolved
- pop hl ; ..restore file spec pointer
- scf ; ..return with Z, NC
- ccf
- ret
-
- vfydu1:
- ; See if DU form is enabled
- call getduok
- jr z,vfydu1a ; If not, go right to named directory checking
-
- call getmdisk ; Get maximum disk (a=1) from environment
- dec a ; Offset to du format (drive a = 0)
- cp b ; Compare to requested drive.
- jr c,vfydu1a ; If drive access denied by ENV, try DIR access
-
- call getmuser ; Get maximum disk (0-31)
- cp c ; Compare to requested user.
- jr nc,vfydu3 ; If access allowed, proceed to vfydu3
-
- ; Access not allowed by DU -- see if access
- ; ..allowed by named directory
- vfydu1a:
- call dutdir ; Convert DU value to a named directory
- jr z,vfydu4 ; No DIR found, so deny access
-
- ; DIR found -- check password
- ld de,8 ; Point to password
- add hl,de
- ld a,(hl) ; Get 1st char of password
- cp ' ' ; No password?
- jr z,vfydu3 ; Branch if no check required
-
- ld a,(z33opt+2) ; Get option byte with password options
- ;<rdf>
- ; bit 7,a ; See if password checking is enabled in CPR
- bit 6,a
- jr z,vfydu3 ; If not, accept the directory
- ; bit 5,a ; See if pw checking disabled when wheel is set
- bit 3,a
- jr nz,vfydu1b ; If not, proceed to check password
- call getwhl ; Otherwise see if wheel is set
- jr nz,vfydu3 ; If wheel is set, skip on ahead
- vfydu1b:
- push bc ; Save user/drive
- push hl ; Save pointer to valid password
- ld hl,msg109 ; "Password: "
- call cprmpt2 ; Prompt to get password
- call getfspec ; Use file spec entry routine
- ex de,hl ; Switch user input pointer to DE
- pop hl ; Restore NDR password pointer to HL
- jr z,vfydu4a ; If no password entered, deny access
- call chkpwd ; Check for password match
- jr nz,vfydu4a ; If NZ, deny access
- pop bc ; Else restore du and fall through to vfydu3
-
- vfydu3:
- pop hl ; Restore file spec pointer.
- or 0ffh ; Resolved ok, access allowed.
- ret ; Return with nz, nc
-
- vfydu4a:
- pop bc ; Restore du value
- vfydu4:
- pop hl ; Restore file spec pointer.
- or 0ffh ; Access denied - return with nz, c
- scf
- ret
-
- chkpwd: ; Check for password match and return
- ; ..Z if matched
- ld b,8 ; Maximum number of characters to check
- chkpwd1:
- ld a,(de) ; Get user response character
- or a ; See if ending null
- jr nz,chkpwd2 ; If not, branch
- ld a,(hl) ; NDR must have a blank to match
- cp ' '
- ret ; Return with zero flag showing status
- chkpwd2:
- call caps ; User input to upper case
- cp (hl) ; Compare to NDR character
- ret nz ; Return NZ if bad password
- inc de ; Bump pointers up
- inc hl
- djnz chkpwd1 ; Loop back if more characters to check
- ; 8 matches found, must be end of user input
- ld a,(de) ; Get next user input character
- or a ; Set Z flag if ending null
- ret
-
- ;---------------------------------------------------------------------------
-
- ; Get pointer to system file name #2
-
- sysfn2:
- call getfn2 ; Get address of system file #1
- ld de,11
- add hl,de ; Now HL points to file #2
- ret
-
- ;---------------------------------------------------------------------------
-
- ; Record current file pointer and options settings
-
- putopt:
- ld a,(initflag) ; If initflag set, do not save
- or a ; ..file pointer
- jr nz,putopt0
-
- call sysfn2 ; Get pointer to system file #2
- ex de,hl ; Put pointer into DE
- ld hl,(ringpos) ; Point to current file
- inc hl ; Increment pointer to file name position
- ld b,11 ; Copy 11 bytes
- call movea
- ld a,0ffh ; Fool system into using system file #2
- ld (initflag),a ; ..as the pointer on next screen update
-
- ; SAVE OPTIONS
- ;
- ; These routines save and restore the options on the shell stack using
- ; the last two bytes of the shell stack entry. The maximum number of
- ; options, NOPT, is therefore 16.
- ; This routine is used regardless of USESTK equate.
- ; <rdf>
-
- putopt0:
- ld de,options ; Start of options
- ld b,16 ; Fill 16 bits
- putopt1:
- ld a,(de) ; Get flag
- inc de ; Point to next one
- rla ; Move high bit into carry
- rl l ; Move it into L
- rl h ; Move carry from L into H
- djnz putopt1 ; Loop
-
- push hl ; Save bit encoded flags
- call getsh2
- dec de
- add hl,de ; Last byte of shell stack entry
- pop de ; Recover flags
- ld (hl),e
- dec hl
- ld (hl),d
- ret
-
- ;---------------------------------------------------------------------------
-
- ; Retrieve current options settings
-
- getopt:
- call getsh2 ; Get stored flag bits
- dec de
- add hl,de ; Last byte of shell stack entry
- ld e,(hl)
- dec hl
- ld d,(hl)
- ld b,nopt ; Flags to copy
- ld hl,options ; Start of list
- getopts1:
- xor a ; Initialize A
- rl e ; Shift a bit left out of DE into carry
- rl d
- jr nc,getopts2
- dec a ; If CY, flag is 0FFh
- getopts2:
- ld (hl),a ; Put result into flag byte
- inc hl ; Point to next character
- djnz getopts1 ; Loop
- ret
-
- ; End of ZFSUBS3.Z80
-