Voice API for Linux Demo Guide — June 2005 31

Demo Details

menu_engine( ) then transfers control to the next menu indicated in the mo_nxtmenu field. If the

value of the field is NULL, control is passed to the default menu, specified in the me_defmenu

field. A value of DM_PREV in me_defmenu sets the current menu to be the previous menu, and

loops back to the gt_data( ) call at the beginning of the loop. The value of DM_CURR loops back,

leaving the current menu the same.

The menu_engine( ) function relies on other system routines defined in d4xtools.c for playing the

prompts, handling errors, and validating responses.

gt_data( ) function

The gt_data( ) function gets the caller's response to a voice prompt.

void * gt_data(digbufp,validfnc,prompt,retry,error,datap)
char * digbufp;
void * (*validfnc)();
char * prompt;
char * retry;
void (*error)();
DL_DATA * datap;
{
unsigned short numretry; /* Number of allowed retries */
void * rp; /* general return ptr from valid fn */
DV_DIGIT digit;
DV_TPT dattpt[MAXTERMS];
(void)memcpy(dattp,def_dg_tpt,(MAXTERMS*sizeof(DV_TPT)));
dattpt[DX_MAXDTMF-1].tp_length=datap->da_recvdig;
dattpt[DX_MAXTIME-1].tp_length=datap->da_time;
dattpt[DX_DIGMASK-1].tp_length=bld_tdig_msk(datap->)da_digit;
numretry = datap->da_numretry; /* Set the retry count */
/*
* Continue to prompt for this input until an acceptable response is
* entered or the retry count has been exhausted
*/
do {
/*
* Play the prompt message
*/
playmsg(prompt);
/*
* Get the user's response (DTMF digits)
*/
if(dx_getdig(devhandle, (DV_TPT *)dattpt,&digit,EV_SYNC) == -1) {
disperr("Failed on get digits");
}
/* Copy the digits to our buffer */
strcpy(digbufp,digit.dg_value);
check_term(); /* check for fatal errors)
/* If a response was given, validate it */
/* NOSTRICT */
if ((rp= (*validfnc)(digbufp)) != NULL) {
return (rp);