
#ifdef TPLTER

ExpandArgs = {

    SHORT = {{ expand wildcards }};

    DESCRIPTION = {{
	Does wildcard expansion of all arguments,
	that contain wildcards and passing of all
	other arguments.

    RESULT
	-/-
    }};

    BUGS = {{
	ExpandArgs breaks on the first error
    }};
	//'ExpandArgs test c:b#? xyz' produced one guru
	//$80000004 when compiled w/ OPTIMIZE !???


    TODO = {{
	!TESTING!
    }};

    EXAMPLES = {{
	> ExpandArgs c:f#? xyz
	c:Filenote
	xyz
    }};

    SEEALSO = {{
	dos.library/MatchFirst, dos.library/MatchNext
    }};

    HISTORY = {{
	12-02-95 b_noll created
	20-02-95 b_noll restructured source
	21-02-95 b_noll added version/format-prefix/offset
	20-03-95 b_noll added args diagnostics
	19-08-95 b_noll created .data file
	30-08-95 b_noll 1.3 added breakcheck
    }};


    Template = "/A/M";
    Arguments = {{
	STRPTR *par;

#	define MYFLAGS		/* (APF_DOWILD|) APF_DODOT| APF_FollowHLinks| */ 0
#	define LFORMAT "%s\n"
    }};

    version = "1.3";

    body = {{
	    BPTR stdout;
	    LONG   error;
	    STRPTR pat;
	    //STRPTR lformat = LFORMAT;
#	    define lformat LFORMAT
	    int    i;
	    struct AnchorPath  *ap;
	    UBYTE  apb[sizeof (*ap) + 8 + MAXPATHLEN];
	    //UBYTE  buffer[MAXPATHLEN];

	    retval = RETURN_OK;
	    stdout = Output();

	    ap		      = (void *)(((ULONG)apb + 7) & ~7);
	    ap->ap_Strlen     = MAXPATHLEN;
	    ap->ap_BreakBits  = 0;
	    ap->ap_FoundBreak = 0;
	    //ap->ap_ = ;


	    for (i = 0; (pat = argv->par[i]) && !BREAKCHECK(); i++) {

		ap->ap_Flags  = MYFLAGS;

		for (error = MatchFirst(pat, ap); error == 0; error = MatchNext(ap)) {
		    FPrintf (stdout, lformat, ap->ap_Buf);
	//FPrintf(Output(), "%ld\n", j++);
		} /* for */
		MatchEnd(ap);

		if (error != ERROR_NO_MORE_ENTRIES) { /* abnormal error */
		    if ((error == ERROR_OBJECT_NOT_FOUND) && !(ap->ap_Flags & APF_ITSWILD)) {
			FPrintf (stdout, lformat, pat);
		    } else {
			retval = RETURN_ERROR;
			break;
		    } /* if */
		} /* if */
	    } /* for */

    }};

};

#endif


