WILDIR WILdcard DIRectory look up Rev 4/87 (beta) Introduction Have you ever written a good assembly language utility that would be even better if you could pass it a command line with a wildcard spec- ification for the input? Like, search all the .MAC files for "textstring" and output the results to a device or file? But RT-11 gave you no means of doing a directory wildcard lookup. (Even MS-DOS has system calls to do that!!) Well, so have I. For years I have been writing and rewriting the same code for each program to do wildcard .LOOKUP's. Finally I have time that is not required on 'work' (terri- ble word), and took the time to 'can' this code. This module is the result. Right now, I'm only making the object code available for beta testing. When the code becomes frozen, I will then make the source available on here. Please direct all comments, moans, groans, bitches and complaints to: Jim Stutt [73277,1355] This code was written using the basic LSI-11 instructions. No EIS, FIS, FPU instructions were used (not even the 'infamous' SOB). So this 'should' run on a LSI-11/03. JS 1 General Information This module contains two GLOBAL entry points, FFILE and FNFILE. These are, Find FILE name and Find Next FILE name. Using these two routines, the programmer can perform EXPLICIT wildcard file .LOOKUP's in his pro- grams. The wildcard characters are * (star), % (percent), and ? (questionmark). NOTE Questionmark is used for historical reasons, as well as com- patibility with other operating systems. Percent is standard for DEC RT-11. JS The * (star) character terminates all remaining characters for that field, i.e. "FIL*AM.EXT" will disregard the two characters AM, and look for matches for "DK:FIL .EXT". The % (percent) and ? (questionmark) are synonymous. Both can be used interchangably to denote a "don't care" for a specific character posi- tion, i.e. "FI%?AM.EXT" will look for matches for "DK:FI AM.EXT". NOTE If no DEV: is specified, it will default to DK:. FFILE must be called to find the first file name. It creats the expanded file name model to look for, opens the I/O channel, and reads in the first directory segment. There after, call FNFILE to return the next matching file name found in the directory being searched. Upon not finding a match, both FFILE and FNFILE will return with the carry bit SET to signify no match, and the I/O channel will be closed and re- turned to RT-11. Technical Information This module uses I/O channel 14(8) to perform the directory reads on. This module occupies 900. words total, of code and data space, and must be linked in the root section of an overlaid program. Also, since using .CSIGEN requires supplying an address of where non-resident hand- lers may be loaded, it is suggested that you order your link command to place WILDIR in the lower part of your program. The reason for this is that of the 547. words of data space used, 512. words are used as the current directory segment buffer. If this buffer gets over written, LOOK OUT!!! ('nuff said). 2 Calling Conventions FFILE expects two arguments to be passed to it. R0 contains the ad- dress of the .ASCIZ wildcard specification string, and R1 contains the address of a 12. word block of memory for the returned file name. The file name is returned as a RAD50 encoded name suitible for use with .LOOKUP, and an ASCIZ string suitable for copying and using as an input to CSIGEN. They are returned in the user supplied 12. word area as: 0 1 2 3 4 5 6 7 8 9 10 11 word offset 0 2 4 6 8 10 12 14 16 18 22 22 byte offset RAD RAD RAD RAD ASC ASC ASC ASC ASC ASC ASC NULL description ------------------------------------------------- dev fil nam ext de v: fi ln am .e xt 0 contents Calling sequence: FFILE R0 = address of wildcard ASCIZ string to find. R1 = address of where to put the returned RAD50 & ASCIZ name found. ***** Destroys ALL registers ***** MOV #WILD,R0 ; where WILD is pointing to a form: *.*, etc MOV #FNAME,R1 ; FNAME is pointing to a 12. word area. CALL FFILE ; try to find the first matching name. BCC FOUND ; carry clear if a name is found. .PRINT #FNF ; print file not found message and loop. BR START Calling sequence: FNFILE R1 = address of where to put the returned ASCIZ name found. ***** Destroys ALL registers ***** MOV #FNAME,R1 CALL FNFILE BCS START ; no more matching file names. Examples of Use .R *=*.MAC *=TEST*.MAC *=SY:TEST1%.MAC *=FILE*.T* *=*.* *=DY1:??????.MAC 3 Example Program Using FFILE & FNFILE I have uploaded the source code for a UNIX (tm) like CAT utility that demonstrates the use of these two subroutines. See CAT.MAC and CAT.DOC. Bon appetite --- Jim Stutt Apr 87 4