28 Voice API for Linux Demo Guide — June 2005
Demo Details
menu are implemented as a NULL-terminated array of DL_MNUOPTS structures. An array of
DL_MNUOPTS structures allows a menu to have an arbitrary amount of options.
typedef struct DL_MNUOPTS {
char * mo_rspstr; /* Response string to this option */
void (*mo_fcnt)(); /* Next function for this option */
DL_MENU * mo_nxtmenu; /* Next menu for this option */
} DL_MNUOPTS;
The fields are defined as follows:
mo_rspstr
Response String - This is the digit string that the caller must press to initiate this action.
mo_fcnt
Next Function - This is the name of the void function that will be called if the digits in
mn_rspstr were received.
mo_nxtmenu
Next Menu - This is a pointer to the next menu. If the digit specified by mn_rspstr transfers
control to another menu, this field points to that menu. If this field is NULL the control is
transferred to the menu pointed to by me_defmenu in the DL_MSG structure that contains the
option table.
The options available in a menu are:
transfer control to another menu
execute a function
do both
do neither
All menus must provide a pointer to the next menu at one of two levels. The next menu can be tied
to the response and be specified in the mn_nxtmnu field of the DL_MNUOPTS structure. If this
field is NULL, the next menu defaults to a higher level. The default next menu for all options in a
menu is defined in the me_defmenu field of the DL_MENU structure. The action specified in the
mn_fcnt field of the DL_MNUOPTS structure isn't required for every menu option.
The next menu for a response must be specified as either a next menu (mo_nxtmnu) in the
DL_MNUOPTS structure or the default menu (mo_fcnt) in the DL_MENU structure for all the
options not specifying a next menu.
The menu1_opts variable is the NULL-terminated array for the root menu in d40demo.c. It is
initialized as:
DL_MNUOPTS menu1_opts[] = {
{"1",enterord,NULL},
{"2",chekord,NULL},
{"3",canord,NULL},
{"*",goodby,NULL},
{NULL,NULL,NULL}
};
All the options for d40demo use the default next menu. The four possible inputs for d40demo
(1,2,3, or *) are defined in the menu1_opts array. For example, the first table entry in menu1_opts
defines the following: if the caller presses the digit 1, call the void function enterord( ).