home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / uploads / zf11src.lbr / ZFSUBS3.ZZ0 / ZFSUBS3.Z80
Encoding:
Text File  |  1992-09-09  |  9.3 KB  |  339 lines

  1. .printx    Reading ZFSUBS3.Z80
  2. ;===========================================================================
  3. ;
  4. ; ZFSUBS3.Z80 - file name and mask processing
  5. ;
  6. ;===========================================================================
  7.  
  8.  
  9. ; Get file name from user and process into FCB pted to by DE
  10. ;    returns:    B = disk number
  11. ;            C = user number
  12.  
  13. filename:
  14.     push    de        ; Save fcb ptr
  15.     call    getfspec    ; Get file specification from user
  16.     jr    z,fnamer    ; Exit on null input line.
  17.     pop    de        ; Restore fcb ptr.
  18.     call    fname        ; Call syslib routine.
  19.     ld    a,(hl)        ; Get terminating character.
  20.     cp    ' '        ; Terminated by space?
  21.     ret    z
  22.     or    a        ; Terminated by null?
  23.     ret    z
  24. fnamer:
  25.     call    erclr        ; Clear error message line.
  26.     jp    loop        ; Error - restart command.
  27.  
  28.  
  29. ;---------------------------------------------------------------------------
  30.  
  31. ; Get File specification/Command line from user
  32. ;    On exit - HL -> first character in command line
  33. ;          A   = first non-space character in command line
  34. ;          E   = first entered character in command line (may be space)
  35. ;          Z   = Z if null command line,
  36. ;            NZ if significant characters.
  37.  
  38. getfspec:            ; Get file specification
  39.     ld    b,20        ; Length of file specification
  40.     jr    getline        ; Get line from user.
  41.  
  42. getzcmd:            ; Get zcpr3 command
  43.     ld    b,253        ; Maximum length of zcpr3 command line
  44.  
  45. getline:            ; Common code - user line input
  46.     ld    hl,(cmdbuf)    ; Get command line location
  47.     ld    (hl),b        ; Set command line length
  48.     inc    hl        ; Init actual count.
  49.     ld    (hl),0
  50.     push    hl        ; Save ptr to actual count.
  51.     ex    de,hl        ; De pts to buffer
  52.     dec    de        ; Beginning
  53.     ld    c,rdbuf        ; Read line from user
  54.     call    bdosptr
  55.  
  56.     pop    hl        ; Pt to actual count.
  57.     ld    e,(hl)        ; Get actual count in de
  58.     ld    d,0        ; (zero high-order offset)
  59.  
  60.     inc    hl        ; Pt to first char
  61.     push    hl        ; Save current ptr for later
  62.     add    hl,de        ; Pt to end of string
  63.     ld    (hl),0        ; Store ending zero
  64.  
  65.     pop    hl        ; Pt to first char of command line
  66.     ld    d,(hl)        ; Save true first character in D
  67.     call    sksp        ; Ignore leading spaces.
  68.     ld    a,(hl)        ; Get 1st significant character.
  69.     or    a        ; Test for empty line.
  70.     ret
  71.  
  72.  
  73. ;---------------------------------------------------------------------------
  74.  
  75. ; FILEMASK - GET/PUT File Selection mask (in system file 4 or on stack)
  76. ;    on entry, A = 0 to PUT file mask from FCB.
  77. ;         otherwise GET file mask to FCB.
  78. ;
  79. ; The option flags are no longer encoded as high bits on the file mask,
  80. ; which limited NOPT to 11.  The routine has therefore been simplified.
  81. ; <rdf>
  82.  
  83. maskoff    equ    19        ; Shell stack offset
  84.  
  85. filemask:
  86.  
  87.      if    usestk        ; If using stack for file mask
  88.  
  89.     push    af        ; Save get/put flag
  90.  
  91.     call    getsh2        ; Get data on shell stack
  92.     ld    de,maskoff    ; Offset into stack entry
  93.     add    hl,de
  94.  
  95.     ld    de,fcb+1    ; Pt to fcb
  96.     ld    b,11        ; Repeat for 11 characters
  97.  
  98.     pop    af        ; Restore get/put flag
  99.     or    a        ; See if get or put
  100.     jr    nz,getmask
  101.     ex    de,hl        ; Putmask
  102. getmask:
  103.     call    jchk        ; Check for no file spec and set pointer
  104.     call    smoveb
  105.     ret
  106.     
  107. jchk:
  108.     ld    a,(hl)        ; Check first character of source file name
  109.     cp    ' '        ; Is it blank?
  110.     jr    z,jchk1
  111.     cp    '/'        ; Help specifier?
  112.     ret    nz        ; Neither, then leave pointer as it is
  113. jchk1:
  114.     ld    hl,joker    ; Else, use joker '????????.???' as file
  115.     ret
  116.  
  117.       else    ; not usestk
  118.  
  119.     push    af        ; Save get/put flag
  120.  
  121.     call    getfn2        ; Pt to first system file name
  122.     ld    de,11*3        ; Pt to 4th file name
  123.     add    hl,de
  124.     ld    de,fcb+1    ; Pt to fcb
  125.  
  126.     pop    af        ; Restore get/put flag
  127.     or    a        ; Test it.
  128.  
  129.     jr    nz,fmask1    ; Br if get.
  130.     ex    de,hl        ; Swap pointers for put.
  131.  
  132. fmask1:
  133.     ld    b,11        ; 11 bytes
  134.     call    smoveb
  135.  
  136.     ld    hl,joker    ; Treat as '*.*' with 'joker'..
  137.     ld    b,11        ; # of characters to move
  138.     ld    a,(de)        ; Get first char of file name
  139.     cp    ' '        ; If space, fill with *.*
  140.     call    z,smoveb    ; Set file id to *.*
  141.  
  142.     ld    a,(de)        ; Get first char of file name
  143.     cp    '/'        ; If opt, fill with *.*
  144.     call    z,smoveb
  145.     ret
  146.     
  147.      endif    ; usestk
  148.  
  149. ;---------------------------------------------------------------------------
  150.  
  151. ; VFY$D$U - Resolve DU or DIR and verify Access
  152. ;    on entry, HL -> file specification
  153. ;    on exit,  HL is unchanged
  154. ;          BC =    DU for DU/DIR
  155. ;          Z  = Z if DU/DIR resolution error,
  156. ;               NZ if DU/DIR resolved ok.
  157. ;          C  = C if access denied,
  158. ;               NC if no password or password OK
  159.  
  160. vfy$d$u:
  161.     push    hl        ; Save file spec pointer
  162.     ld    a,1        ; Look for DIR:, then DU:
  163.     call    dnscan        ; Resolve DIR: or DU: form and return DU
  164.     jr    nz,vfydu1    ; Branch if resolved
  165.                 ; If not resolved
  166.     pop    hl        ; ..restore file spec pointer
  167.     scf            ; ..return with Z, NC
  168.     ccf
  169.     ret
  170.  
  171. vfydu1:
  172.                 ; See if DU form is enabled
  173.     call    getduok
  174.     jr    z,vfydu1a    ; If not, go right to named directory checking
  175.  
  176.     call    getmdisk    ; Get maximum disk (a=1) from environment
  177.     dec    a        ; Offset to du format (drive a = 0)
  178.     cp    b        ; Compare to requested drive.
  179.     jr    c,vfydu1a    ; If drive access denied by ENV, try DIR access
  180.  
  181.     call    getmuser    ; Get maximum disk (0-31)
  182.     cp    c        ; Compare to requested user.
  183.     jr    nc,vfydu3    ; If access allowed, proceed to vfydu3
  184.  
  185.                 ; Access not allowed by DU -- see if access
  186.                 ; ..allowed by named directory
  187. vfydu1a:
  188.     call    dutdir        ; Convert DU value to a named directory
  189.     jr    z,vfydu4    ; No DIR found, so deny access
  190.  
  191.                 ; DIR found -- check password
  192.     ld    de,8        ; Point to password
  193.     add    hl,de
  194.     ld    a,(hl)        ; Get 1st char of password
  195.     cp    ' '        ; No password?
  196.     jr    z,vfydu3    ; Branch if no check required
  197.  
  198.     ld    a,(z33opt+2)    ; Get option byte with password options
  199. ;<rdf>
  200. ;    bit    7,a        ; See if password checking is enabled in CPR
  201.     bit    6,a
  202.     jr    z,vfydu3    ; If not, accept the directory
  203. ;    bit    5,a        ; See if pw checking disabled when wheel is set
  204.     bit    3,a
  205.     jr    nz,vfydu1b    ; If not, proceed to check password
  206.     call    getwhl        ; Otherwise see if wheel is set
  207.     jr    nz,vfydu3    ; If wheel is set, skip on ahead
  208. vfydu1b:
  209.     push    bc        ; Save user/drive
  210.     push    hl        ; Save pointer to valid password
  211.     ld    hl,msg109    ; "Password: "
  212.     call    cprmpt2        ; Prompt to get password
  213.     call    getfspec    ; Use file spec entry routine
  214.     ex    de,hl        ; Switch user input pointer to DE
  215.     pop    hl        ; Restore NDR password pointer to HL
  216.     jr    z,vfydu4a    ; If no password entered, deny access
  217.     call    chkpwd        ; Check for password match
  218.      jr    nz,vfydu4a    ; If NZ, deny access
  219.     pop    bc        ; Else restore du and fall through to vfydu3
  220.  
  221. vfydu3:
  222.     pop    hl        ; Restore file spec pointer.
  223.     or    0ffh        ; Resolved ok, access allowed.
  224.     ret            ; Return with nz, nc
  225.  
  226. vfydu4a:
  227.     pop    bc        ; Restore du value
  228. vfydu4:
  229.     pop    hl        ; Restore file spec pointer.
  230.     or    0ffh        ; Access denied - return with nz, c
  231.     scf
  232.     ret
  233.  
  234. chkpwd:                ; Check for password match and return
  235.                 ; ..Z if matched
  236.     ld    b,8        ; Maximum number of characters to check
  237. chkpwd1:
  238.     ld    a,(de)        ; Get user response character
  239.     or    a        ; See if ending null
  240.     jr    nz,chkpwd2    ; If not, branch
  241.     ld    a,(hl)        ; NDR must have a blank to match
  242.     cp    ' '
  243.     ret            ; Return with zero flag showing status
  244. chkpwd2:
  245.     call    caps        ; User input to upper case
  246.     cp    (hl)        ; Compare to NDR character
  247.     ret    nz        ; Return NZ if bad password
  248.     inc    de        ; Bump pointers up
  249.     inc    hl
  250.     djnz    chkpwd1        ; Loop back if more characters to check
  251.                 ; 8 matches found, must be end of user input
  252.     ld    a,(de)        ; Get next user input character
  253.     or    a        ; Set Z flag if ending null
  254.     ret
  255.  
  256. ;---------------------------------------------------------------------------
  257.  
  258. ; Get pointer to system file name #2
  259.  
  260. sysfn2:
  261.     call    getfn2        ; Get address of system file #1
  262.     ld    de,11
  263.     add    hl,de        ; Now HL points to file #2
  264.     ret
  265.  
  266. ;---------------------------------------------------------------------------
  267.  
  268. ; Record current file pointer and options settings
  269.  
  270. putopt:
  271.     ld    a,(initflag)    ; If initflag set, do not save
  272.     or    a        ; ..file pointer
  273.     jr    nz,putopt0
  274.  
  275.     call    sysfn2        ; Get pointer to system file #2
  276.     ex    de,hl        ; Put pointer into DE
  277.     ld    hl,(ringpos)    ; Point to current file
  278.     inc    hl        ; Increment pointer to file name position
  279.     ld    b,11        ; Copy 11 bytes
  280.     call    movea
  281.     ld    a,0ffh        ; Fool system into using system file #2
  282.     ld    (initflag),a    ; ..as the pointer on next screen update
  283.  
  284. ; SAVE OPTIONS
  285. ;
  286. ; These routines save and restore the options on the shell stack using
  287. ; the last two bytes of the shell stack entry.  The maximum number of
  288. ; options, NOPT, is therefore 16.  
  289. ; This routine is used regardless of USESTK equate.
  290. ; <rdf>
  291.  
  292. putopt0:
  293.     ld    de,options        ; Start of options
  294.     ld    b,16            ; Fill 16 bits
  295. putopt1:
  296.     ld    a,(de)            ; Get flag
  297.     inc    de            ; Point to next one
  298.     rla                ; Move high bit into carry
  299.     rl    l            ; Move it into L
  300.     rl    h            ; Move carry from L into H
  301.     djnz    putopt1            ; Loop
  302.  
  303.     push    hl            ; Save bit encoded flags
  304.     call    getsh2
  305.     dec    de
  306.     add    hl,de            ; Last byte of shell stack entry
  307.     pop    de            ; Recover flags
  308.     ld    (hl),e
  309.     dec    hl
  310.     ld    (hl),d
  311.     ret
  312.  
  313. ;---------------------------------------------------------------------------
  314.  
  315. ; Retrieve current options settings
  316.  
  317. getopt:
  318.     call    getsh2            ; Get stored flag bits
  319.     dec    de
  320.     add    hl,de            ; Last byte of shell stack entry
  321.     ld    e,(hl)
  322.     dec    hl
  323.     ld    d,(hl)
  324.     ld    b,nopt            ; Flags to copy
  325.     ld    hl,options        ; Start of list
  326. getopts1:
  327.     xor    a            ; Initialize A
  328.     rl    e            ; Shift a bit left out of DE into carry
  329.     rl    d
  330.     jr    nc,getopts2
  331.     dec    a            ; If CY, flag is 0FFh
  332. getopts2:
  333.     ld    (hl),a            ; Put result into flag byte
  334.     inc    hl            ; Point to next character
  335.     djnz    getopts1        ; Loop
  336.     ret
  337.  
  338. ; End of ZFSUBS3.Z80
  339.