; .TITLE LDSK: LOG IN DISK ; .SBTTL WHBJR 12/11/85 ETB 12/23/85 ; Wilson H. Bent, Jr. ; 39 Maple Ave. ; Fair Haven, NJ 07701 ; Work: (201) 949-1277 ; UN*X: ... ihnp4!vax135!hoh-2!whb ; RCP/M: Lillipute: (312) 649-1730 Chicago ; Voorhees: (609) 428-8864 So. NJ ; ; Earl T. Boone ; 5812 Pepper Ridge Ct. ; Wilmington, DE 19808 ; Home (302) 239-5708 ; ; LDSK logs in disk directories as follows: ; First the Named Directory Buffer is copied, ; clearing entries for the current disk. Then ; the disk is searched for files of the form: ; -???????.??? ; (i.e, an initial dash), which are assumed to ; be names of directories. Using these, a new ; NDBuff is built, which replaces the old one. ; Also prints out User Number & Name. ; Note that the extent of the file is ignored. ; NDBuff entries are: ; Disk: 1 byte (A = 1, B = 2, M = 0Dh) ; User: 1 byte ; Name: 8 bytes (space-filled) ; Pass: 8 bytes (ditto) ; The password entry is optional, and cleared ; by LDSK to spaces. ; Lower-case names are allowed, but how're ; y'gonna make a file with'em? ; 14 names max, extras are dumped. ; ZSIG release version, 11/1/86, changed PRINT calls ; to the smaller EPRINT and took remaining JR oppor- ; tunities. Restored Zilog mnemonics (with the ori- ; ginal author's consent). ; VERSION HISTORY: ; 2.0 - Installed 'veto' code to permit discarding ; dash files that would otherwise be logged. ; Added code to permit processing several disks ; in one run and to permit omitting the colon ; after the disk letter even if only one disk ; is specified. Example: LDSK AEC would log in ; the dash files on disks a, e and c. ; Added test to be sure the specified disks ; are between A and the max disk specified in ; the environment file. ; Made the 'dash' symbol a parameter so that ; by reassembling, any legal character can be ; used instead of '-', eg, #, or %, etc. ; Added code to permit un-logging a disk. ; Added help via LDSK // as all good little ; z3 utilities should. ; Modified to USE LIBRARY ROUTINES. So There. ; ETB ; 1.3 - Now re-runnable using 'GO' command. ; Checks for # of entries allowed. ; Also fixed a few bugs (THANKS to Jay Sage). ; 1.2 - Fixed bug: getnew marks end-of-buff, ; thus we're sure we've reached the end ; 1.1 - Sorts names on re-write to NDBuffer, ; checks for too many names. ; 1.0 - Initial version. ; Later Fix: multiple dash-files in a user area ; add to the name count, but are not copied out ; (thus should not count) - check in copyin? ; NOTE This does NOT use the Z3 Library, BUT: ; It IS designed to look like an installable ; Z3 Utility, with Resident Z3ENV. So there. ; EXT Z3INIT,GETNDR,CODEND,RETUD,LOGUD,GETMDISK EXT PA3DC,COUT,CRLF,EPRINT,CAPS ; MYZ3 EQU 0FE00H ; NAOG/ZSIG ; 0DD00H ; ETB ; 0E200h ; WHBjr DASH EQU '-' ; Character to identify 'dash' files ; BDOS Equates BDOS EQU 5 CONOUT EQU 2 PRNTSTG EQU 9 SELDISK EQU 14 ; E SERFRST EQU 17 ; 11 SERNEXT EQU 18 ; 12 CRNTDSK EQU 25 ; 19 SETDMA EQU 26 ; 1A DEFFCB EQU 5CH DEFDMA EQU 80H CMDTAIL EQU 80H ENTLEN EQU 18 ; Entry Len = 18 bytes LDSK: JP MAIN ; Faked Z3 Stuff here DB 'Z3ENV' DB 1 ; Use Internal Z3 Stuff Z3EADR: DW MYZ3 ; Changed when Z3INS'd MAIN: LD (STAK),SP ; Save old stack LD SP, STAK ; Set up stack LD HL,(Z3EADR) CALL Z3INIT CALL EPRINT DB 'LDSK 2.0 ETB 12/22/85',0DH,0AH,0 CALL CODEND ; Find available memory LD (OURNDBP),HL ; To use for local NDB CALL INITARG ; Initialize arguments CALL GETNDB LD A,(ARGLIST+2) CP '/' JR NZ,MLOOP LD A,(ARGLIST+3) CP '/' JP Z,HELP MLOOP: CALL CHECKARG JR C,NXTARG CALL COPYIN CALL GETNEW CALL COPYOUT NXTARG: LD HL,(ARGPTR) LD A,(HL) OR A JR NZ,MLOOP EXIT: LD SP,(STAK) RET ; No warm boot ; getndb: ; gets Named Directory pointer, ; exits with error if none GETNDB: CALL GETNDR JR Z,NONDB ; Exit if none LD (Z3NDB),HL ; Store it LD (Z3NDSIZ),A RET NONDB: CALL EPRINT DB 'No Memory Resident Named Directory!' DB 0DH,0AH,0 JR EXIT ; ERROR EXIT Z3NDB: DW 0 Z3NDSIZ:DB 0 INITARG: ; Initialize argument list LD HL,CMDTAIL LD DE,ARGLIST ARGLOOP:LD A,(HL) ; Copy command line tail LD (DE),A INC HL INC DE OR A JR NZ,ARGLOOP LD A,(ARGLIST) ; Null list? OR A JR NZ,ARGX CALL RETUD ; Find out cur disk LD A,B ADD 'A' ; Create argument list LD (ARGLIST+2),A XOR A LD (ARGLIST+3),A ARGX: LD HL,ARGLIST+2 LD (ARGPTR),HL RET ; ; ; checkarg: do another disk? ; If so, switch & announce ; CHECKARG: XOR A LD (DELFLG),A ; Clear delete flag CALL GETMDISK ; Get max legal disk ADD 'A'-1 ; Convert to letter LD (MDISK),A INC A LD C,A ; Save it in reg c CHKA1: LD HL,(ARGPTR) ; Pointer to next arg LD A,(HL) ; Get arg INC HL ; Increment ptr LD (ARGPTR),HL OR A JR Z,EXIT CP ' ' JR Z,CHKA1 ; Skip blanks CP ',' ; And commas JR Z,CHKA1 CP ':' ; And colons JR Z,CHKA1 CP '-' ; Delete cmd? JR NZ,CHKA2 LD (DELFLG),A ; Set delete flag JR CHKA1 CHKA2: CALL CAPS ; Capitalize LD (DSTR),A ; Put in print string CALL EPRINT ; Announce it DB 13,10,'Drive: ' DSTR: DB 'x',13,10,0 CP 'A' JR C,BADARG ; Must be between A & P CP C JR NC,BADARG SUB 'A'-1 LD (CDISK),A ; Save current disk DEC A LD B,A ; Disk LD C,0 ; User=0 CALL LOGUD ; Log in to the disk OR A ; Clear carry RET ; BADARG: CALL EPRINT DB 'Disk not between A and ' MDISK: DB 'P',13,10,0 SCF ; Set carry RET ; CDISK: DB 0 DELFLG: DB 0 ARGPTR: DW ARGLIST ARGLIST:DS 40 ; ; copyin: copy the existing NDBuff into ; ourndb, deleting current-disk entries COPYIN: LD HL,(Z3NDB) ; Prepare copying LD DE,(OURNDBP) JR CHECKEND CPIN01: LD BC, ENTLEN LD A,(CDISK) ; Check for curr.disk CP (HL) JR Z,NOLOAD LDIR JR CHECKEND NOLOAD: ADD HL,BC ; Incr. source addr CHECKEND: ; Disk == 0 means end XOR A OR (HL) JR NZ,CPIN01 RET ; getnew: search the directory for ; dash-files, putting them in ourndb ; Entry: DE = Location to start adding entries ; Abort if too many entries GETNEW: PUSH DE LD DE, DEFDMA ; Just in case LD C, SETDMA CALL BDOS LD A,(DELFLG) ; Check delete flag OR A JP NZ,GTNW99 LD HL,DASHFCB LD DE,DASHFCB+1 LD BC,11 LD (HL), '?' ; Fix up FCB LDIR LD DE, DASHFCB ; Look for -files LD C, SERFRST GTNW01: CALL BDOS CP 0FFH ; Done? JR Z,GTNW99 AND 3 ; Clear carry RRCA ; Mult by 32 RRCA RRCA LD D, 0 ; Add to DefDMA LD E, A ; To get addr of LD HL, DEFDMA ; Dir entry ADD HL,DE ; BOGUS ROUTINE: ; If the DN entry (byte 0) in the FCB is 0, ; only files in the current user area are ; reported. If it's ?, ALL files are reported! ; -Thus we take all, and carefully check (sigh) LD A,(HL) ; Get User Num CP 0E5H ; Erased? JR Z,GTNW02 ; Yes, skip INC HL LD A,(HL) ; Check for dash AND 7FH ; Y'never know... CP DASH JR NZ,GTNW02 ; Not dash, skip ; Okay, so it's a dash name ; insert user code here to veto the file if desired PUSH BC ; Example of 'user own code' PUSH DE ; To veto the insertion PUSH HL ; Of names starting with INC HL ; 2 dashes into the NDR LD A,(HL) AND 7FH CP '-' POP HL POP DE POP BC JR Z,GTNW02 ; end of veto code DEC HL ; Restore addr POP DE ; Get back dest PUSH DE ; And save again PUSH HL CALL CKSPAC POP HL ; HL = FCB for dashfile POP DE ; DE = dest JR NC,GTNW98 ; NC = No Space! LD A,(CDISK) ; Get curr disk LD (DE),A ; And store INC DE LD A,(HL) ; Get user num CALL PA3DC LD (DE),A ; And store INC DE INC HL ; Skip dash INC HL CALL FNAMEOUT ; Print name ; HL points to -File Entry: post-dash ; DE points to OurNDB Entry: Name LD BC, 7 ; Not 8: skipped dash LDIR LD HL, SPACE ; Clear Passwd LD BC, 9 LDIR PUSH DE ; Save dest GTNW02: LD C, SERNEXT JR GTNW01 ; gtnw98: out of space ERROR GTNW98: PUSH DE ; Fix stack for gtnw99 CALL EPRINT DB 'Warning: Too many names!' DB 0DH,0AH,0 GTNW99: POP HL ; Restore pointer XOR A ; And clear end LD (HL), A RET ; CkSpac: is ourndb full yet? ; Entry: DE = ptr to next load ; Exit: Carry = Space OK CKSPAC: LD HL,(Z3NDSIZ) ; Get the size LD H, 0 ; (it's a byte) CALL MULT18 EX DE,HL ; Get dest into hl OR A ; Clear carry SBC HL,DE ; Wanted: LD DE,(OURNDBP) SBC HL,DE ; LESS THAN ourndb RET DASHFCB:DB '?','-???????','???' DS 24 SPACE: DB ' ' ; I see no value in sorting the entries in NDR ; but I'll leave the code here just in case ; ETB ; ; copyout: copy ourndb into NDBuff COPYOUT: ; Pass 1: Scan Entries LD HL,(OURNDBP) LD BC, ENTLEN-1 ; Entry offset LD DE, 0 ; D=maxusr, E=maxdsk CPOT01: LD A,(HL) ; Check Disk entry OR A ; Zero? JR Z,CPOT03 ; Yes, done CP E ; No, check vs. max JR C,CPOT02 ; (hl) GT maxdsk? LD E, A ; Yes, save (hl) CPOT02: INC HL ; Point to User LD A,(HL) CP D ; Check vs. max JR C,CPOT04 ; (hl) GT maxusr? LD D, A ; Yes, save (hl) CPOT04: ADD HL,BC ; Point to next entry JR CPOT01 ; And repeat ; Pass 2: Move Entries In Order CPOT03: LD (MAXDSK),DE ; Save max D&U LD DE,(Z3NDB) ; Get dest LD B, 1 ; Disk counter (A=1) CPOT05: LD C, 0 ; User counter CPOT5A: LD HL,(OURNDBP) CPOT06: LD A,(HL) ; Get entry.dsk OR A ; == Zero? JR Z,CPOT9A ; Yes, next user CP B ; Compare to current JR NZ,CPOT08 ; NG, next entry INC HL ; Right disk, LD A,(HL) ; Get entry.usr CP C ; Compare to current DEC HL ; Adjust ptr JR NZ,CPOT08 ; NG, next entry CPOT07: PUSH BC ; Save currents LD BC, ENTLEN ; & move entry LDIR POP BC ; Restore curr. CPOT9A: INC C ; Next usr LD A,(MAXUSR) ; Time for next disk? CP C ; (max vs. curr) JR NC,CPOT5A ; No, jump CPOT09: INC B ; Next dsk LD A,(MAXDSK) ; Done yet? CP B ; (max vs. curr) JR NC,CPOT05 ; No, loop JR CPOT99 ; Yes, exit CPOT08: PUSH BC ; Save currents LD BC, ENTLEN ; & get next entry ADD HL,BC POP BC ; Restore currents JR CPOT06 ; & check this entry ; exit: fill remainder of NDBuff with 0 CPOT99: PUSH DE ; Save dest LD HL,(Z3NDSIZ) ; Get Buffsiz LD H, 0 ; (it's a byte) CALL MULT18 LD DE,(Z3NDB) ADD HL,DE ; HL = end of NDB POP DE ; DE = next NDB Entry SBC HL,DE ; HL = size of rest of NDB LD A, H ; Did we fill the NDB? OR L RET Z ; Z = NDB full LD B, H ; Copy size into BC LD C, L DEC BC ; And adjust LD H, D ; Copy dest LD L, E INC DE ; Boost dest XOR A ; Clear source LD (HL), A LDIR ; Play chase RET ; These MUST be adjacent and in order! MAXDSK: DB 0 ; Maximum Dsk MAXUSR: DB 0 ; Maximum Usr ; fnameout: print 7-char file name ; entry: HL points to name ; saves: DE, HL FNAMEOUT: PUSH DE ; Save regs PUSH HL LD A,' ' CALL COUT LD B, 7 ; 7 chars FNO01: LD A,(HL) CALL COUT INC HL DJNZ FNO01 ; Done? CALL CRLF POP HL ; Restore regs POP DE RET ; mult18: multiply HL by 18 (== ENTLEN) MULT18: PUSH DE ; Save ADD HL,HL ; X2 LD D,H ; Store LD E,L ADD HL,HL ; X4 ADD HL,HL ; X8 ADD HL,HL ; X16 ADD HL,DE ; X18 POP DE ; Restore RET ; HELP: CALL EPRINT DB 13,10,10 DB ' Examples of correct usage',13,10,10 DB 'LDSK add dash names from current' DB ' disk to NDR (log A)',13,10 DB 'LDSK BC add dash names from' DB ' disks B and C (log B and C)',13,10 DB 'LDSK -A delete names from' DB ' disk A from NDR (unlog A)',13,10 DB 'LDSK -BA unlog disk B, then log disk A',13,10 DB 0 JP EXIT STAK_SPACE: DS 32 ; This seems enough STAK: DW 0 ; This is last because there is the possibility ; of it running over the allocated size ; (Usually need 14 * 18 = 252) OURNDBP:DW $ END