home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / ZCPR33 / A-R / PWD14.LBR / PWD14.ZZ0 / PWD14.Z80
Windows Setup INFormation  |  2000-06-30  |  12KB  |  477 lines

  1. ;
  2. ; Program: PWD
  3. ; Author: Richard Conn
  4. ; Version: 1.0
  5. ; Date: 5 Mar 84
  6. ;
  7. version    equ    14
  8.  
  9. ;
  10. ;    The purpose of PWD is to display the names of the named directories.
  11. ; If the option PASS (P) is given, then the passwords to the directories will
  12. ; be displayed as well IF the Wheel Byte is Available and Set.    If the Wheel
  13. ; Byte is not available, the passwords will be displayed without question.
  14. ;
  15. ; April 3, 1988 (v1.4)
  16. ; Type 3 format with safety header, smart help screen, made both RAS-oriented
  17. ; options patchable at 102H.  For a "normal" PWD command, 102H=00H, for BYE
  18. ; detection and obedience, 102H=80H, for hiding passworded directories from
  19. ; non-wheels, 102H=01H, for both RAS options, 102H=81H.
  20. ;                        Bruce Morgen
  21.  
  22. ; 11/21/86 (v1.3)
  23. ; Translated source to permit assembly with ZAS.  No other changes.
  24. ; - D.McCord
  25. ;
  26. ; 06/03/85
  27. ; Consolidated Jay's and Dave's separate PWD11s into a `universal' PWD for
  28. ; remote use.  Both mods work very well, Jay's - controlled by the `hidepw'
  29. ; equate - allows the sysop or privileged user see all passworded named
  30. ; directories and their passwords but keeps non-wheels in the dark, while
  31. ; Dave's - controlled by the `chkbye' equate - follows what BYE dictates and
  32. ; provides a more `absolute' kind of protection since no directory beyond
  33. ; what BYE allows shows up regardless of the state of the wheel byte.  The
  34. ; routines seem to co-exist with no conflict and may be chosen separately or
  35. ; together.  No new code has been added for PWD12.    Bruce Morgen
  36. ;
  37. ; 02/13/85 Jay Sage
  38. ; Modified to suppress display of directories that are passworded when the
  39. ; user is not a wheel.    changes marked with <JPS>.
  40. ; This is the second PWD11. - b/m
  41. ;
  42. ; 10-30-84
  43. ; Version 1.1 originated by D. McCord. Added findbye routine and other code
  44. ; so that when used in rcp/m application, users will only be shown directories
  45. ; that they have access to under BYE.
  46. ; This is the debugged (by the author) version of the first PWD11. - b/m
  47.  
  48. ;
  49. ; Basic Equates
  50. ;
  51. z3env    defl    0fe00h        ; Address of ZCPR3 Environment
  52. fcb    equ    5ch
  53. cr    equ    0dh
  54. lf    equ    0ah
  55. ;
  56. ; Conditional equates for remote use, setting both of these to 0 results in
  57. ; a `vanilla' PWD.COM - it will be essentially version 1.0. - b/m
  58. ;
  59. byechk    equ    80h    ; 80H = suppress display of all directories where
  60.             ; Login is disallowed by an active BYE, 0 = display
  61.             ; all named directories unless suppressed by the
  62.             ; next equate (DM)
  63. hidepw    equ    01h    ; 01H = suppress display of passworded directories
  64.             ; If not a wheel, 0 = do not suppress display of
  65.             ; passworded directories, but don't display passwords
  66.             ; (`P' option) unless wheel byte is set <JPS>
  67.  
  68. ;
  69. ; External References
  70. ;
  71.     extrn    z3init
  72.     extrn    cout,crlf,print,padc
  73.     extrn    qprint,qcrlf
  74.     extrn    getndr,getwhl,getefcb
  75.  
  76. ;
  77. ; Environment Definition
  78. ;
  79.  
  80. ; TYPE 3 HEADER
  81.  
  82. ; Code modified as suggested by Charles Irvine to function correctly with
  83. ; interrupts enabled.  Program will abort with an error message when not
  84. ; loaded to the correct address (attempt to run it under CP/M or Z30).
  85.  
  86. entry:
  87.     jr    start0        ; Must use relative jump
  88. option:    db    byechk+hidepw    ; Option byte
  89.     db    'Z3ENV',3    ; Type-3 environment
  90. z3eadr:
  91.     dw    z3env        ; Filled in by Z33
  92.     dw    entry        ; Intended load address
  93.  
  94. start0:
  95.     ld    hl,0        ; Point to warmboot entry
  96.     ld    a,(hl)        ; Save the byte there
  97.     di            ; Protect against interrupts
  98.     ld    (hl),0c9h    ; Replace warmboot with a return opcode
  99.     rst    0        ; Call address 0, pushing RETADDR
  100.                 ; Onto stack
  101. retaddr:
  102.     ld    (hl),a        ; Restore byte at 0
  103.     dec    sp        ; Get stack pointer to point
  104.     dec    sp        ; To the value of RETADDR
  105.     pop    hl        ; Get it into HL and restore stack
  106.     ei            ; We can allow interrupts again
  107.     ld    de,retaddr    ; This is where we should be
  108.     xor    a        ; Clear carry flag
  109.     push    hl        ; Save address again
  110.     sbc    hl,de        ; Subtract -- we should have 0 now
  111.     pop    hl        ; Restore value of RETADDR
  112.     jr    z,start        ; If addresses matched, begin real code
  113.  
  114.     ld    de,notz33msg-retaddr ; Offset to message
  115.     add    hl,de
  116.     ex    de,hl        ; Switch pointer to message into DE
  117.     ld    c,9
  118.     jp    0005h        ; Return via BDOS print string function
  119. notz33msg:
  120.     db    'Not Z33+$'    ; Abort message if not Z33-compatible
  121.  
  122. start:
  123.     ld    hl,(z3eadr)    ; Pt to ZCPR3 environment
  124. ;
  125. ; Start of Program -- Initialize ZCPR3 Environment
  126. ;
  127.     call    z3init        ; Initialize the ZCPR3 Env and the VLIB Env
  128. ;
  129. ; Print Banner
  130. ;
  131.     call    qprint        ; Check quiet flag
  132.     db    'PWD, Version '
  133.     db    [version/10]+'0','.',[version mod 10]+'0'
  134.     db    0
  135.     ld    a,(option)
  136.     or    a
  137.     jr    z,optchk
  138.     bit    0,a
  139.     jr    z,znodeb
  140.     call    getwhl
  141.     jr    z,znode
  142.     jr    optchk
  143. znodeb:    bit    7,a
  144.     jr    z,optchk
  145.     call    findbye
  146.     or    a
  147.     jr    z,optchk
  148. znode:    call    qprint
  149.     db    ' for Z-Node System' ; <JPS>
  150.     db    0
  151. ;
  152. ; Check for options
  153. ;
  154. optchk:    call    qcrlf
  155.     ld    hl,fcb+1    ; Pt to option char
  156.     ld    a,(hl)        ; Get option char
  157.     cp    '/'        ; Help?
  158.     jp    z,prhelp
  159.     cp    ' '        ; No option?
  160.     jr    z,namedir
  161.     cp    'P'        ; Passwords?
  162.     jp    nz,invopt    ; Bad option if not
  163. ;
  164. ; Prepare to process passwords - check for authorization
  165. ;
  166.     call    getwhl        ; Get wheel byte
  167.     jr    nz,namedir    ; Permission granted
  168.     call    print
  169.     db    ' Password Request Denied - Not Wheel',cr,lf,0
  170.     ld    (hl),' '    ; Clear option
  171. ;
  172. ; Print Named Directory Info
  173. ;
  174. namedir:
  175.     call    getndr        ; Get location of directory
  176.     jr    nz,ndir1
  177.     call    print
  178.     db    ' Named Directory Buffer Not Available',0
  179.     ret
  180. ;
  181. ; Print Names of Directory Elements
  182. ;
  183. ndir1:
  184.     ld    a,(fcb+1)    ; See if passwords included
  185.     cp    'P'
  186.     jr    z,ndir1p
  187. ;
  188. ; Print Header if Not Quiet for Non-Password Entries
  189. ;
  190.     ld    b,4        ; 4 times
  191. ndir1a:
  192.     call    qprint        ; Print banner (optional)
  193.     db    ' DU : DIR Name    ',0
  194.     djnz    ndir1a        ; Count down
  195.     call    qcrlf        ; New line
  196.     ld    b,4        ; 4 more times
  197. ndir1b:
  198.     call    qprint
  199.     db    '----  --------    ',0
  200.     djnz    ndir1b        ; Count down
  201.     call    qcrlf        ; New line
  202.     jr    ndir1z
  203. ;
  204. ; Print Header if Not Quiet for Password Entries
  205. ;
  206. ndir1p:
  207.     ld    b,2        ; 2 times
  208. ndir1c:
  209.     call    qprint
  210.     db    ' DU : DIR Name - Password    ',0
  211.     djnz    ndir1c        ; Count down
  212.     call    qcrlf
  213.     ld    b,2
  214. ndir1d:
  215.     call    qprint
  216.     db    '----  --------   --------    ',0
  217.     djnz    ndir1d        ; Count down
  218.     call    qcrlf
  219. ;
  220. ; Begin Output Processing
  221. ;
  222. ndir1z:
  223.     ld    a,(option)
  224.     call    nz,findbye
  225.  
  226.     ld    c,0        ; Set entry count
  227.     ld    b,1        ; Set disk 1
  228. ;
  229. ; Print Each Resident Command Name
  230. ;
  231. ;
  232. ndir2:
  233.     ld    a,(option)
  234.     bit    0,a
  235.     jr    z,ndir2a
  236. ;<JPS> block added
  237.     ex    de,hl        ; Address of NDR in DE
  238.     ld    hl,10        ; Offset to password
  239.     add    hl,de        ; Hl points to password
  240.     ex    de,hl        ; Hl as before, de=password
  241. ;<JPS> end of block
  242. ;
  243. ndir2a:
  244.     ld    a,(hl)        ; Get table entry
  245.     or    a        ; End of table?
  246.     ret    z        ; Exit
  247.     cp    b        ; Same disk?
  248.     jr    z,ndir3
  249. ;
  250. ; Advance to Next Set of Entries for New Disk
  251. ;
  252.     ld    b,a        ; Set new disk
  253.     ld    a,c        ; Get count
  254.     and    3        ; See if newline already given
  255.     call    nz,crlf        ; Complete current line
  256.     call    crlf        ; 1 additional line
  257.     ld    c,0        ; Reset count
  258. ndir3:
  259.     push    bc        ; Save counters
  260.  
  261. ;<JPS> block added
  262.     ld    a,(option)
  263.     bit    0,a
  264.     jr    z,ndir3a
  265.     call    getwhl
  266.     jr    nz,ndir3a    ; Skip all this if a wheel
  267.     ld    a,(de)        ; Check for presence of password
  268.     cp    ' '
  269.     jr    z,ndir3a    ; If not, go on as before
  270.     ld    bc,18        ; Skip this directory entry
  271.     add    hl,bc
  272.     pop    bc        ; Restore counter and drive value
  273.     jr    ndir2        ; Back for another try
  274. ndir3a:
  275. ;<JPS> end of block
  276. ;
  277. ;
  278. ; Print DU:
  279. ;
  280.     ld    b,(hl)        ; Get disk
  281. ;
  282. ; Here are the major Ver 1.1 changes (DM)
  283. ;
  284.     ld    a,(option)
  285.     bit    7,a
  286.     jr    z,bygone
  287.     ld    a,(byeflag)    ; Check if bye was found
  288.     or    a        ; Test for zero
  289.     jr    z,bygone    ; BYE not active if zero
  290.     ld    a,(maxdrive)    ; Get BYE max drive
  291.     cp    b        ; Compare them
  292.     ld    a,b        ; Restore sysndr drive back to A
  293.     jr    nc,drvok    ; If a is greater than or equal to b in cmp, then we
  294.                 ; Are OK
  295. notok:    ld    bc,18        ; Prepare to skip rest of entry
  296.     add    hl,bc        ; Make hl point to next entry
  297.     pop    bc        ; Make sure stack is right
  298.     jr    ndir2        ; Go back and get next entry
  299. drvok:    inc    hl        ; Let's look at user from sysndr
  300.     ld    b,(hl)        ; Put it in b
  301.     dec    hl        ; Restore hl
  302.     ld    a,(maxuser)    ; Get BYE maxuser
  303.     cp    b        ; Compare BYE maxuser and sysndr user
  304.     ld    a,(hl)        ; Put drive from sysndr back in A if we pass
  305.     jr    nc,usrok    ; If a was equal to or greater than b in cmp, we pass
  306.     jr    notok        ; We failed
  307. bygone:    ld    a,b
  308. usrok:
  309. ;
  310.     add    '@'        ; Convert to letter (A to P)
  311.     call    cout
  312.     inc    hl        ; Pt to user
  313.     ld    a,(hl)        ; Get user
  314.     call    padc        ; Print user number
  315.     call    print        ; Print separator
  316.     db    ': ',0
  317.     inc    hl        ; Pt to name
  318. ;
  319. ; Print DIR
  320. ;
  321.     call    prname        ; Print name of directory
  322.     ld    a,(fcb+1)    ; Check for password option
  323.     cp    'P'
  324.     jr    nz,ndir4
  325.     call    print
  326.     db    ' - ',0
  327.     call    prname        ; Print name of password
  328.     pop    bc        ; Get counters
  329.     inc    c        ; Another entry
  330.     push    bc        ; Save counters
  331.     jr    ndir5
  332. ;
  333. ; Advance to Next and Print Separator
  334. ;
  335. ndir4:
  336.     ld    bc,8        ; Skip over password
  337.     add    hl,bc
  338. ;
  339. ; Print Separator
  340. ;
  341. ndir5:
  342.     call    print        ; Print separator
  343.     db    '    ',0
  344.     pop    bc        ; Get counters
  345. ;
  346. ; New Line Counter
  347. ;
  348.     inc    c        ; Increment entry counter
  349.     ld    a,c        ; Check for done
  350.     and    3        ; Every 4
  351.     call    z,crlf        ; New line
  352.     jp    ndir2
  353. ;
  354. ; Print 8-char name (directory or password) and advance ptr
  355. ;
  356. prname:
  357.     ld    b,8        ; Print name
  358. prn1:
  359.     ld    a,(hl)        ; Get char
  360.     call    cout
  361.     inc    hl        ; Pt to next
  362.     djnz    prn1        ; Count down
  363.     ret
  364. ;
  365. ; Print Invalid Option and then Help Messages
  366. ;
  367. invopt:
  368.     call    print
  369.     db    cr,lf,'Invalid Option',cr,lf,0 ; Fall thru to PRHELP
  370. ;
  371. ; Print Help Message
  372. ;
  373. prhelp:
  374.     call    print
  375.     db    cr,lf,'PWD - Print Working Directories',cr,lf
  376.     db    cr,lf,'PWD Syntax:'
  377.     db    cr,lf,' ',0
  378.     call    comnam
  379.     call    getwhl
  380.     jr    z,nwhl1
  381.     call    print
  382.     db    ' or ',0
  383.     call    comnam
  384.     call    print
  385.     db    ' P',0
  386. nwhl1:    call    print
  387.     db    cr,lf
  388.     db    cr,lf,'"',0
  389.     call    comnam
  390.     call    print
  391.     db    '" prints the names of the directories',0
  392.     call    getwhl
  393.     ret    z
  394.     call    print
  395.     db    cr,lf,'and'
  396.     db    ' "',0
  397.     call    comnam
  398.     call    print
  399.     db    ' P[ASSWORD]" prints the names and'
  400.     db    cr,lf,'passwords of the directories'
  401.     db    cr,lf,'(if the user has Wheel Powers)',0
  402.     ret
  403.  
  404. comnam:    call    getefcb
  405.     jr    z,noefcb
  406.     ld    b,8
  407. cmnmlp:    inc    hl
  408.     ld    a,(hl)
  409.     and    7fh
  410.     cp    ' '
  411.     call    nz,cout
  412.     djnz    cmnmlp
  413.     ret
  414. noefcb:    call    print
  415.     db    'PWD',0
  416.     ret
  417. ;
  418. ; Added FINDBYE routine for use in RCP/M mode. This routine determines
  419. ; whether BYE is active or not, if it is, then extracts MAXUSR and MAXDRV
  420. ; from the BYE parameter block. (DM)
  421. ;
  422.  
  423. ;
  424. findbye:
  425.     push    de
  426.     push    hl
  427.     ld    hl,(1)        ; Get BYE or maybe warmboot vector
  428.     dec    hl        ; If BYE active,
  429.     ld    d,(hl)        ; Pick up pointer to BYE parameters
  430.     dec    hl
  431.     ld    e,(hl)
  432.     ld    hl,17        ; Skip over possible parameter block to check
  433.                 ; For string "BYE" or "Bye"
  434.                 ; (the value of 17 may vary in different versions
  435.                 ; Of BYE. 17 is valid for BYE3-26)
  436.     add    hl,de
  437.     ld    a,(hl)        ; Get letter
  438.     cp    'B'
  439.     jr    nz,nobye    ; BYE not active
  440.     inc    hl
  441.     ld    a,(hl)        ; Get second letter
  442.     and    5fh        ; Force upper case
  443.     cp    'Y'
  444.     jr    nz,nobye
  445.     inc    hl
  446.     ld    a,(hl)        ; Get third letter
  447.     and    5fh        ; Force upper case
  448.     cp    'E'
  449.     jr    nz,nobye
  450. ;
  451. ; If we get here, BYE is active, and the beginning address is in DE
  452. ;
  453.     ld    hl,6        ; Offset from beginning of BYE to MXUSR
  454.     add    hl,de
  455.     ld    a,(hl)        ; Get it into A
  456.     ld    (maxuser),a    ; Save it
  457.     inc    hl        ; Point to MXDRV
  458.     ld    a,(hl)        ; Get it
  459.     ld    (maxdrive),a    ; Save it
  460.     ld    a,0ffh        ;
  461.     ld    (byeflag),a    ; Indicate we found BYE
  462.     jr    endfind
  463. ;
  464. nobye:    xor    a        ; Zero a
  465.     ld    (byeflag),a
  466. endfind:
  467.     pop    hl
  468.     pop    de
  469.     ret
  470.  
  471.     dseg
  472. byeflag:    ds 1        ; Bye not active
  473. maxdrive:    ds 1        ; This gets changed anyway if BYE is active
  474. maxuser:    ds 1        ; And so does this
  475.  
  476.     end
  477.