title MSDOS 2.00 Function Library for Lattice C
include mc.ash
.MODEL SMALL
.CODE
;
;ret= _find(path,flag,xfbuf);
;
;Find the Nth occurence of pathname. Returns
;0 when no match. Only the filename portion
;can contain wildcards. The returned filename
;does not contain the path portion of the 
;input string.
; We cheat here. The search-attribute is the 
;first element in the structure.
;
func __find 
	mov	dx,arg2		;XFBUF ptr,
	mov	bx,dx
	mov	cl,[bx]		;get attrib
	mov	ch,0		;into CX,
	push	cx		;save it,
	mov	ah,26		;set DMA addr
	int	21h		;to buffer,
	pop	cx		;CX == attrib
	mov	dx,arg0		;pathname
	mov	ax,arg1		;iteration flag
	or	ax,ax
	jz	f0
	mov	al,1		;make 0,1

f0:	mov	ah,78		;search first
	cmp	al,0		;if AL == 0,
	je	f1
	mov	ah,79		;else search next
f1:	int	21h		;DOS call,
	mov	ax,-1		;make 0 == not found
	adc	ax,0
endf __find 

	end
