; Module name: FNAMZ ; Author: Terry Hazen ; Date: 03/14/91 ; Version: 1.0 public fnamz ; ; FNAMZ is a file name scanner. Pointing to the first character ; of a file name specification of the form 'du:filename.typ', ; terminated by a space or 0 and where any part of the ; specification is optional, this routine initializes the fcb ; fn and ft (file name and file type) fields if 'filename.typ' ; or any part thereof is present, and initializes the drive and ; user bytes in the fcb. No wildcards are accepted. ; » It is a modifieä anä simplifieä versioî oæ the sysliâ modulå ; SFNAMÅ foò uså with a z-parseä fcâ thaô jusô needó a new du and ; filename. The dir: form is not accepted and no initialization ; of the fcb is done. Primarily used to fill the fcb from a ; default filename buffer. ; ; basic equates ; maxdisk:equ 16 ; Max number of disks maxuser:equ 31 ; Max user number cpm: equ 0 ; Cp/m entry cr: equ 0dh lf: equ 0ah ; ; Entry: DE points to 36 byte fcb to be filled ; HL points to first byte of target string ; ; Exit: HL points to terminating char ; A=0FFh and NZ if ok ; A=0 and Z set if error in disk or user numbers ; ; Uses: AF,HL ; fnamz: push de ; Save DE ld a,0ffh ; Set default user and disk ld (user),a ld (disk),a ; ; scan for colon in string ; push hl ; Save pointer ; colon: ld a,(hl) ; Scan for colon or space inc hl ; Point to next cp ':' ; Colon found? jr z,colon1 ; cp ' '+1 ; Delim? jr c,getf1 jr colon ; Continue if not end of line ; colon1: pop hl ; Clear stack ld a,(hl) ; Save possible drive spec cp 'A' ; Digit if less than 'A' jr c,userck ; Process user number ; sub 'A' ; Convert to 0-15 cp maxdisk ; Within bounds? jr c,svdisk ; errexit:xor a ; Error indicator pop de ; Restore DE ret ; ; log in specified disk ; svdisk: inc a ; Adjust to A=1 ld (disk),a ; Save flag inc hl ; Point to next char ; ; check for user ; userck: ld a,(hl) ; Get possible user number cp ':' ; No user number jr z,getfile ; xor a ; Zero user number ld b,a ; B=accumulator for user number ; usrloop:ld a,(hl) ; Get digit inc hl ; Point to next cp ':' ; Done? jr z,usrdn ; sub '0' ; Convert to binary jr c,errexit ; User number error? ; cp 10 jr nc,errexit ; ld c,a ; Next digit in c ld a,b ; Old number in a add a,a ; *2 add a,a ; *4 add a,b ; *5 add a,a ; *10 add a,c ; *10+new digit ld b,a ; Result in b jr usrloop ; usrdn: ld a,b ; Get new user number cp maxuser+1 ; Within range? jr nc,errexit ; ld (user),a ; Save in flag jr getfile ; ; extract file name ; getf1: pop hl ; Get pointer to byte ; getfile:ld a,(hl) ; Pointing to colon? cp ':' jr nz,gfile1 ; inc hl ; Skip over colon ; gfile1: ld a,(hl) ; Get next char cp ' '+1 ; Not a delimiter? jr nc,gfile2 ; gfques: inc de ; Fill with '?' ld b,11 ; 11 bytes ld a,'?' ; gffill: ld (de),a ; Put ? inc de ; Point to next djnz gffill ; Count down ; fndone: pop de ; Restore fcb pointer ld a,(disk) ; Get disk number inc a jr z,setusr ; Default ; dec a ; Else restore disk ld (de),a ; Put it in fcb ; setusr: ld a,(user) ; Get user number inc a ; If default, we're done jr z,fndun ; dec a ; Restore user ld hl,13 ; Point to user byte add hl,de ld (hl),a ; Save it in fcb ; fndun: or 0ffh ; Set no error ret ; ; get file name fields ; gfile2: ld b,8 ; At most 8 bytes for fn call scanf ; Scan and fill ld b,3 ; At most 3 bytes for ft ld a,(hl) ; Get delimiter cp '.' ; Fn ending in '.'? jr nz,gfile3 ; inc hl ; Point to char after '.' call scanf ; Scan and fill jr fndone ; Done ... return args ; gfile3: call scanf4 ; Fill with jr fndone ; ; scanner routine ; scanf: call delck ; Check for delimiter jr z,scanf4 ; fill if found ; inc de ; Point to next byte in fn ; scanf1: ld (de),a ; Place char inc hl ; Point to next position ; scanf2: djnz scanf ; Count down ; scanf3: call delck ; "B" chars or more - skip to delimiter ret z ; inc hl ; Point to next jr scanf3 ; scanf4: inc de ; Point to next fn or ft ld a,' ' ; fill ld (de),a djnz scanf4 ; Count down ret ; ; check char pointed to by HL for a delimiter ; ret with z flag set if delimiter ; delck: ld a,(hl) ; Get char or a ; 0=delim ret z ; cp ' '+1 ; +1 jr c,delck1 ; or less ; cp '.' ret z ; cp ':' ret ; delck1: cp (hl) ; Compare with self for ok ret dseg ; ; buffers ; disk: ds 1 ; Disk number user: ds 1 ; User number end