From: GWDVMS::MOELLER [moeller@gwdvms.dnet.gwdg.de]
Sent: Wednesday, September 08, 1999 7:53 PM
To: Info-VAX@Mvb.Saic.Com
Subject: Re: opendir/readdir system call alternates

Jan Vorbrueggen <jan@FSNIF.NEUROINFORMATIK.RUHR-UNI-BOCHUM.DE> writes:
>[...]
> LIB$FIND_FILE has been available for very long to do exactly that in an easy
> to use way. I can't really say whether it's been 15 or only 13 years.

For the record, here's a MACRO32 `subroutine' that did the job 
18 years ago, and still does it today (with the limitation stated), 
even on Alpha.

I checked, the source file's been unchanged since 1981 ... FORTRAN 
was my preferred HLL then, MACRO32 the preferred language for data 
structure definitions (like $FAB & friends), as required by e.g. RMS.
The LIB$ routines `invented' later, I found more difficult to use :-)

--------------------------------------------------------------------------------
	.title	filesearch	routine for wildcard lookup
;
;	w.j.m. nov 81
;
;	note: this is a non-reentrant routine, only 1 wildcard
;		may be active at a time
;
;	entries:
;		integer function filesearch0(instring)
;			= status (success, wildcard syntax, ...)
;
;		integer function filesearch1(outstring,len)
;			= status (success, rms$_nmf on end, ...)
;					outstring - used for resultant file
;					len	  - size returned by rms
;
;
	.psect	_quad,quad
;
nam:	$nam	esa=exfile,ess=nam$c_maxrss,-
		rsa=0-0,rss=0-0
fab:	$fab	nam=nam,-
		fna=0-0,fns=0-0
;
exfile:	.blkb	nam$c_maxrss
;
;
	.psect
;
;
;*****
;
	.entry	FILESEARCH0,^m<>
;
	movaq	@1*4(ap),r1		; r1 -> string descriptor
	moval	fab,r0			; r0 -> fab
	movl	4(r1),fab$l_fna(r0)
	movw	(r1),r1
	cmpw	#255,r1
	bgeq	5$
	movw	#255,r1
5$:	movb	r1,fab$b_fns(r0)
	$parse	fab=fab
	ret
;
;
;*****
;
	.entry	FILESEARCH1,^m<>
;
	movaq	@1*4(ap),r1		; r1 -> string descriptor
	moval	nam,r0			; r0 -> nam
	movl	4(r1),nam$l_rsa(r0)
	movw	(r1),r1
	cmpw	#nam$c_maxrss,r1
	bgeq	5$
	movw	#nam$c_maxrss,r1
5$:	movb	r1,nam$b_rss(r0)
	$search	fab=fab
	movzbl	nam+nam$b_rsl,@2*4(ap)
	ret
;
;
	.end
--------------------------------------------------------------------------------
Wolfgang J. Moeller, Tel. +49 551 2011516 or -510, moeller@gwdvms.dnet.gwdg.de
GWDG, D-37077 Goettingen, F.R.Germany   |       Disclaimer: No claim intended!
<moeller@decus.decus.de>  ----- <moeller@gwdg.de>  -----  <w.moeller@ieee.org>
