26 Voice API for Linux Demo Guide — June 2005
Demo Details
When input is received from the caller, four things can happen: control is passed to another menu;
an action is performed; an action is performed and control is passed to another menu; an error
message is played (invalid input).
All menus provide the caller with options. In the example above, the first caller response
transferred the caller to another menu. The second response performed an action (recording a
message) and prompted the caller with the same menu. In another case, the caller might have been
transferred to a different menu.
A menu must obey the following rules:
A menu must always transfer control to a menu. This can be a different menu or the same
menu.
A menu is not required to perform an action. If the menu does perform an action, it still must
pass control to some menu.
Implementation
The menu system is implemented by using three data structures, namely DL_MENU,
DL_MNUOPTS, and DL_DATA, and three functions, namely menu_engine( ), gt_data( ), and
val_menu( ). These functions are defined in d4xtools.c. By defining the structures and using the
functions, a complete menu system for any voice application can be implemented.
To see how a menu system can be implemented, examine the code that defines d40demo's main
menu as examples. The definition for d40demo's only menu is located in the variables menu_1,
menu1_opts, and data_1, which are declared in d40demo.c.
DL_MENU Data Structure
The DL_MENU structure defines the menu. It uses a DL_MNUOPTS structure to define the
response options and a DL_DATA structure to define the termination conditions for a response.
typedef struct DL_MENU {
DL_MNUOPTS * me_opttbl; /* Pointer to menu's option table */
DL_MENU * me_defmenu; /* Default next menu for this menu */
DL_MNUOPTS * (*me_validfnc)(); /* Pointer to menu's validation function */
char * me_prompt; /* Pointer to menu's prompt message name */
char * me_retry; /* Pointer to menu's retry message name */
void (*me_error)(); /* Pointer to menu's error message name */
DL_DATA * me_data; /* Pointer to Data table for this menu */
} DL_MENU;
The fields are described as follows:
me_opttbl
Option Table - Pointer to a DL_MNUOPTS structure that defines the options for this menu.
me_defmenu
Default Menu - Pointer to the default next-menu. The menu system will transfer control to the
menu specified in this field after an action has taken place, but only if the mn_nxtmenu
structure specified in the option table is NULL. This field can contain a pointer to any valid
DL_MENU structure. In addition, the menu.h header file defines two DL_MENU structures