.TITLE WILDSCAN - Return a wildcard sequence of files .IDENT /1.00/ ;++ ; Title: ; WILDSCAN - Return a wildcard sequence of files ; ; Facility: ; Utility routine. ; ; Abstract: ; Simple routine to return a wildcard sequence of files. ; Also provides for sticky file spec processing if the ; FAB supplied has a related file NAM block. ; Adapted from FMG$FILESCAN from VMS V2.0 CLIUTIL module. ; Must be assembled with DEV$SSG:[SSG.SOURCE.SMAC]SMAC.MLB. ; ; Environment: ; Native Mode. No other considerations. ; ; Author: ; Gary L. Grebus, Creation date: 11-Mar-1982 ; Battelle Columbus Labs ; ; Modified by: ; ;-- .PAGE .SBTTL Symbol definitions ; System symbols $FABDEF ; RMS File access block $NAMDEF ; RMS name block $DEVDEF ; Device characteristics .PAGE .SBTTL WILDSCAN - File scan entry point ;++ ; Functional Description: ; This routine is called with a FAB set up to describe a wildcard ; operation. The FAB must have a NAM block with ESA and RSA fields ; filled in. The caller must supply two action routines, one to be ; called when a matching file is found, and one called whenever an ; error is encountered. The action routines are called with the ; same parameter list as this routine. ; This routine returns when the wildcard scan ; has been completed. If the NAM block has a related file, this ; routine will set the first file found to be the related file. ; ; Calling Sequence: ; CALLS #3, WILDSCAN ; ; Input Parameters: ; 4(ap) - Address of FAB ; 8(ap) - Address of success action routine ; 12(ap) - Address of error action routine ; ; Output Parameters: NONE ; ; Implicit Inputs: NONE ; ; Implicit Outputs: NONE ; ; Procedures called: ; SYS$PARSE, SYS$SEARCH, specified action routines. ; ; Completion Status: NONE ; ; Side Effects: NONE ; ;-- .PSECT CODE RD,NOWRT,EXE,SHR,LONG ; Read only data VERSION: .ASCII ';*' .ENTRY WILDSCAN,^M ; Register usage ; R0-R1 - Scratch ; R2 - Address of FAB ; R3 - Address of NAM MOVL 4(AP),R2 ; Get pointer to FAB MOVL FAB$L_NAM(R2),R3 ; and to NAM BISL2 #^X80000000,- NAM$L_WCC(R3) ; Mysterious signal to RMS $PARSE (R2) ; Parse the file spec IF THEN IF THEN ; Error other than No More Files BSBW ERROR_ACTION ; call error action routine ENDIF RET ENDIF BISL2 #FAB$M_NAM,- FAB$L_FOP(R2) ; Make sure NAM bit set in FAB ; If supplied, handle related file processing. IF AND - THEN MOVL NAM$L_RLF(R3),R0 ; Get address of resultant file NAM ; block MOVB NAM$B_ESL(R3),- NAM$B_RSL(R0) ; Set length of related file spec MOVL NAM$L_ESA(R3),- NAM$L_RSA(R0) ; and its address CLRB FAB$B_DNS(R2) ; Forget any other defaults IF THEN ; If wildcard version specified, include it as a default. This is because ; related file processing does not propagate version numbers. MOVB #2,FAB$B_DNS(R2) ; Length of ";*" is 2 MOVAB VERSION,FAB$L_DNA(R2) ; Point to ";*" string ENDIF ENDIF IF AND - THEN ; If device is not file structured, no need to do search BSBW SUCCESS_ACTION ; Call success action routine ELSE REPEAT $SEARCH (R2) ; Search for next wildcard file MOVL R0,R4 ; Preserve $SEARCH STS MOVL FAB$L_STV(R2),R5 ; and STV BREAK IF ; Break out when all done IF THEN BSBW SUCCESS_ACTION ; If one found, call success routine ELSE BSBW ERROR_ACTION ; If not, call error routine ENDIF IF THEN ; Map any $SEARCH failures due to NOPRIV to success MOVL #RMS$_NORMAL,R4 ENDIF UNTIL OR ENDIF RET SUCCESS_ACTION: IF THEN ; If action routine supplied CALLG (AP),@8(AP) ; call it ENDIF RSB ERROR_ACTION: IF THEN ; If action routine supplied CALLG (AP),@12(AP) ; call it ENDIF RSB .END