/******************************************************************************

	ZPWild()

	This function presets the wildcard lookup file specification.  It is
called when the user executes an ENfilespec$ command.  Later executions of
the EN$ command will cause the ZSWild function to be called to return
successive wildcard matches.

*****************************************************************************/

#include "ZPort.h"		/* define portability identifiers */
#include "DefTeco.h"		/* define general identifiers */
#include "DefError.h"		/* define identifiers for error messages */

EXTERN	char	WBfBeg[];	/* beginning of wildcard filespec buffer */
EXTERN	char	*WBfPtr;	/* pointer into wildcard filespec buffer */



#ifdef UNKNOWN
DEFAULT ZPWild()		/* preset the wildcard lookup filespec */
{
	puts("Terminating in function ZPWild.\n");
	exit(1);
}
#endif



#ifdef vax11c
#include "DefChars.h"	/* define identifiers for characters */
#include fab		/* define RMS file access block structures */
#include rmsdef		/* define RMS return status identifiers */
#include ssdef		/* define system service return identifiers */

VOID	lib$stop();	/* terminate image with stack dump */
int	sys$putmsg();	/* VAX/VMS "put message" system service */
int	sys$parse();	/* RMS PARSE service */
VOID	ZDspCh();	/* display a character on the terminal */

EXTERN	struct	message_vector msgvec;
EXTERN	struct	FAB WFab;	/* wildcard RMS file access block */


DEFAULT ZPWild()		/* preset the wildcard lookup filespec */
{
	int	status;

#if DEBUGGING
DbgInd+=2;if(DbgLvl>=1){DbgMsg();DbgDBf("ZPWild: called with \"");
TypBuf(WBfBeg,WBfPtr);DbgDBf("\"\015\012");DbgROf();}
#endif

	WFab.fab$b_fns = WBfPtr - WBfBeg;	/* file name size */

	status = sys$parse(&WFab);
	if (status != RMS$_NORMAL)
		{
		msgvec.msgcod = status;
		msgvec.rmsstv = WFab.fab$l_stv;
		status = sys$putmsg(	&msgvec,/* message vector */
					0,	/* action routine */
					0);	/* facility name */
		if (status != SS$_NORMAL)
			lib$stop(status);
		ZDspCh(LINEFD);
#if DEBUGGING
if(DbgLvl>=1)
{DbgMsg();DbgDBf("ZPWild: returning FAILURE.\015\012");DbgROf();}DbgInd-=2;
#endif
		return(FAILURE);
		}

#if DEBUGGING
if(DbgLvl>=1)
{DbgMsg();DbgDBf("ZPWild: returning SUCCESS.\015\012");DbgROf();}DbgInd-=2;
#endif
	return(SUCCESS);
}
#endif



#ifdef XENIX
DEFAULT ZPWild()		/* preset the wildcard lookup filespec */
{
	ErrMsg(ERR_NYI);
	return(FAILURE);
}
#endif
