; TITLE "SFNAME - Syslib 4.0" NAME ('FNAME') ;================================================================= ; The Libraries, Version 4, (C) 1989 by Alpha Systems Corp. ;----------------------------------------------------------------- ; Author : Harold F. Bower ; Derived from SFNAME.Z80 Ver 1.1 by Richard Conn ; Date : 17 Sep 89 ; Version : 1.2 ; Module : SFNAME ; Abstract: This module contains the routine FNAME which is a ; file name scanner. It parses a character string for ; Drive letter, User number and Filename/Type where any ; of these parameters is optional, and fills a File Control ; Block (FCB) with the pertinent information. It also ; returns the Drive and User (if specified) in registers ; for the user to manipulate. ; Revision: ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Module Entry Points PUBLIC FNAME ; From SYSLIB Get.. EXT CAPS ; Definitions MAXDISK EQU 16 ; Max Number of Disks MAXUSER EQU 31 ; Max User Number .Z80 CSEG ;=============================================================== ; NAME - FNAME ; Entry: HL - Points to first byte of string ; DE - Points to FCB to be filled (36 bytes) ; Exit : A = 0FFH and Zero Flag Reset (NZ) if Ok ; A = 0 and Zero Flag Set (Z) if Error ; BC = DU: as B = Disk Number (A = 1), C = User (0..31) ; HL - Points to terminating character ; Uses : AF,BC,HL ; Special Requirements: None ;=============================================================== FNAME: PUSH DE ; Save DE LD BC,0FFFFH ; Set Default Disk and User LD (USER),BC LD B,36 ; Init FCB PUSH DE ; Save ptr XOR A ; A = 0 CALL FILLDE ; Fill the FCB with Zeros POP DE ; Get ptr back ; Scan for Colon in String PUSH HL ; Save ptr COLON: LD A,(HL) ; Scan for Colon or space INC HL ; Pt to next CP ':' ; Colon Found? JR Z,COLON1 CP ',' ; Comma Found? JR Z,GETF1 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 CALL CAPS ; Capitalize 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 1 for A LD (DISK),A ; Save Flag INC HL ; Pt to next char ; Check for User USERCK: LD A,(HL) ; Get possible User Number CP ':' ; No user number JR Z,GETFILE CP '?' ; All User Numbers? JR NZ,USERC1 LD (USER),A ; Set value INC HL ; Pt to after LD A,(HL) ; Must be colon CP ':' JR Z,GETFILE JR ERREXIT ; Fatal error if not colon after ? USERC1: XOR A ; Zero User Number LD B,A ; B = Accumulator for user number USRLOOP: LD A,(HL) ; Get digit INC HL ; Pt 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 ptr to byte GETFILE:LD A,(HL) ; Pting to colon? CP ':' JR NZ,GFILE1 INC HL ; Skip over colon GFILE1: LD A,(HL) ; Get next char CP ',' ; Delim? JR Z,GFQUES CP ' '+1 ; Not a delimiter? JR NC,GFILE2 GFQUES: INC DE ; Fill with '?' LD B,11 ; 11 Bytes LD A,'?' CALL FILLDE ; Load ambiguous name & type FNDONE: LD BC,(USER) ; Load User in C, Disk in B POP DE ; Restore Regs OR 0FFH ; ..Set No Error flags RET ; Get File Name Fields GFILE2: INC DE ; Point past drive location 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 ; Pt 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 CP '*' ; ? Fill? JR NZ,SCANF1 LD A,'?' ; Place '?' JR SCANF2 SCANF1: INC HL ; Pt to next position SCANF2: LD (DE),A ; Place Char INC DE ; ..bump destination pointer DJNZ SCANF ; Count down SCANF3: CALL DELCK ; "B" chars or more - Skip to delimiter RET Z INC HL ; Pt to next JR SCANF3 SCANF4: LD A,' ' ; Fill FILLDE: LD (DE),A ; Store char INC DE ; Pt to next DJNZ FILLDE ; Count Down RET ; Check char pted to by HL for a Delimiter ; Ret with Z flag Set if Delimiter DELCK: LD A,(HL) ; Get char CALL CAPS ; Capitalize OR A ; 0 = Delim RET Z CP ' '+1 ; + 1 JR C,DELCK1 ; or Less CP '=' RET Z CP 5FH ; Underscore RET Z CP '.' RET Z CP ':' RET Z CP ';' RET Z CP ',' RET Z CP '<' RET Z CP '>' RET DELCK1: CP (HL) ; Compare with self for Ok RET ; Data Storage/Buffers DSEG ; Put in Data Segment USER: DEFS 1 ; User Number DISK: DEFS 1 ; Disk Number END