78 #define MENU_EVENT_ENTER "menu::enter"
79 #define MENU_EVENT_EXIT "menu::exit"
95 for (ret = stack; ret; ret = ret->
next) {
96 if (!name || !strcmp(ret->
name, name))
106 for (ptr = *top; ptr && ptr->
next; ptr = ptr->
next);
119 const
char *greeting_sound,
120 const
char *short_greeting_sound,
121 const
char *invalid_sound,
122 const
char *exit_sound,
123 const
char *transfer_sound,
124 const
char *confirm_macro,
125 const
char *confirm_key,
126 const
char *tts_engine,
127 const
char *tts_voice,
128 int confirm_attempts,
153 if (!confirm_attempts) {
154 confirm_attempts = 3;
157 if (!inter_timeout) {
158 inter_timeout = timeout / 2;
165 if (!
zstr(greeting_sound)) {
169 if (!
zstr(short_greeting_sound)) {
173 if (!
zstr(invalid_sound)) {
177 if (!
zstr(transfer_sound)) {
181 if (!
zstr(exit_sound)) {
185 if (!
zstr(confirm_key)) {
189 if (!
zstr(confirm_macro)) {
193 if (!
zstr(tts_engine)) {
197 if (!
zstr(tts_voice)) {
203 menu->
inlen = digit_len;
205 if (max_failures > 0) {
211 if (max_timeouts > 0) {
252 if (*action->
bind ==
'/') {
255 len = (uint32_t) strlen(action->
bind);
256 if (len > menu->inlen) {
263 for(ap = menu->actions; ap && ap->
next; ap = ap->
next);
266 menu->actions = action;
285 if (*action->
bind ==
'/') {
288 len = (uint32_t) strlen(action->
bind);
289 if (len > menu->inlen) {
297 for(ap = menu->actions; ap && ap->
next; ap = ap->
next);
300 menu->actions = action;
313 if (stack != NULL && stack->pool != NULL) {
334 char *sound_expanded = sound;
336 const char *terminator_str =
"#";
338 if (!session || !menu ||
zstr(sound)) {
346 terminator_str = tmp;
357 len = (uint32_t) menu->
inlen + 1;
365 if (sound_expanded != sound) {
373 menu_buf_len = strlen(menu->
buf);
375 menu->
ptr += menu_buf_len;
376 if (menu_buf_len < need) {
408 "approving digits '%s' via confirm key %s\n", menu->
buf, menu->
confirm_key);
433 char *data = strchr(app,
' ');
434 char *expanded = NULL;
444 if (expanded && expanded != data) {
452 int reps = 0, errs = 0, timeouts = 0, match = 0,
running = 1;
453 char *greeting_sound = NULL, *aptr = NULL;
461 if (++stack->stack_count > 12) {
466 if (!session || !stack ||
zstr(name)) {
489 char digit_buffer[128] =
"";
530 memset(arg, 0,
sizeof(arg));
539 if (*menu->
buf !=
'\0') {
543 char substituted[1024];
544 char *use_arg = ap->
arg;
557 use_arg = substituted;
563 ok = !strcmp(menu->
buf, ap->
bind);
571 "IVR function on menu '%s' matched '%s' param '%s'\n", menu->
name, menu->
buf, use_arg);
572 todo = ap->
function(menu, use_arg, arg,
sizeof(arg), obj);
578 "IVR action on menu '%s' matched '%s' param '%s'\n", menu->
name, menu->
buf, aptr);
591 if (!strcmp(aptr, menu->
name)) {
604 char *app_arg = NULL;
610 if ((app_arg = strchr(app_name,
' '))) {
672 if (stack->stack_count == 1) {
681 stack->stack_count--;
710 while (map != NULL && (rc = strcasecmp(map->
name, name)) != 0) {
714 return (rc == 0 ? map : NULL);
731 if (map->
name != NULL) {
769 if (!
zstr(action_name)) {
775 if (!strcasecmp(
iam[i].name, action_name)) {
795 if (!strcmp(
iam[i].name, action)) {
816 if (xml_menu_ctx != NULL && pool != NULL) {
818 if (*xml_menu_ctx != NULL) {
819 (*xml_menu_ctx)->pool =
pool;
820 (*xml_menu_ctx)->autocreated = autocreated;
821 (*xml_menu_ctx)->map = NULL;
851 if (xml_menu_ctx != NULL && menu_stack != NULL && xml_menu != NULL) {
855 const char *invalid_sound =
switch_xml_attr(xml_menu,
"invalid-sound");
857 const char *transfer_sound =
switch_xml_attr(xml_menu,
"transfer-sound");
861 const char *exec_on_max_fail =
switch_xml_attr(xml_menu,
"exec-on-max-failures");
862 const char *exec_on_max_timeout =
switch_xml_attr(xml_menu,
"exec-on-max-timeouts");
863 const char *confirm_macro =
switch_xml_attr(xml_menu,
"confirm-macro");
876 if (
zstr(max_timeouts)) {
877 max_timeouts = max_failures;
894 atoi(confirm_attempts),
898 strlen(max_failures) ? atoi(max_failures) : 0, strlen(max_timeouts) ? atoi(max_timeouts) : 0, xml_menu_ctx->
pool);
901 if (!
zstr(exec_on_max_fail)) {
905 if (!
zstr(exec_on_max_timeout)) {
910 if (
zstr(prompt_pin_file)) {
911 prompt_pin_file =
"ivr/ivr-please_enter_pin_followed_by_pound.wav";
913 if (
zstr(bad_pin_file)) {
914 bad_pin_file =
"conference/conf-bad-pin.wav";
925 if (xml_menu_ctx->autocreated) {
944 while (xml_map != NULL && !found) {
945 if (!(found = (strcasecmp(xml_map->
name, action) == 0))) {
946 xml_map = xml_map->
next;
950 if (found && xml_map != NULL) {
961 "binding menu caller control '%s'/'%s' to '%s'\n", xml_map->
name, param, digits);
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
#define switch_regex_safe_free(re)
#define switch_core_new_memory_pool(p)
Create a new sub memory pool from the core's master pool.
A module interface to implement an application.
const char * switch_xml_attr_soft(_In_ switch_xml_t xml, _In_z_ const char *attr)
returns the value of the requested tag attribute, or "" if not found
char * switch_core_session_sprintf(_In_ switch_core_session_t *session, _In_z_ _Printf_format_string_ const char *fmt,...)
printf-style style printing routine. The data is output to a string allocated from the session ...
#define SWITCH_CHANNEL_SESSION_LOG(x)
#define switch_set_flag(obj, flag)
Set a flag on an arbitrary object.
#define SWITCH_CHANNEL_LOG
switch_xml_t switch_xml_find_child(_In_ switch_xml_t node, _In_z_ const char *childname, _In_opt_z_ const char *attrname, _In_opt_z_ const char *value)
find a child tag in a node called 'childname' with an attribute 'attrname' which equals 'value' ...
const char * switch_xml_attr(_In_opt_ switch_xml_t xml, _In_opt_z_ const char *attr)
returns the value of the requested tag attribute, or NULL if not found
switch_status_t switch_play_and_get_digits(switch_core_session_t *session, uint32_t min_digits, uint32_t max_digits, uint32_t max_tries, uint32_t timeout, const char *valid_terminators, const char *audio_file, const char *bad_input_audio_file, const char *var_name, char *digit_buffer, uint32_t digit_buffer_length, const char *digits_regex, uint32_t digit_timeout, const char *transfer_on_failure)
Play a sound and gather digits with the number of retries specified if the user doesn't give digits i...
#define SWITCH_STATUS_IS_BREAK(x)
void switch_perform_substitution(switch_regex_t *re, int match_count, const char *data, const char *field_data, char *substituted, switch_size_t len, int *ovector)
void switch_channel_event_set_data(_In_ switch_channel_t *channel, _In_ switch_event_t *event)
Add information about a given channel to an event object.
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
#define switch_core_destroy_memory_pool(p)
Returns a subpool back to the main pool.
switch_memory_pool_t * pool
Representation of an event.
#define switch_channel_ready(_channel)
switch_status_t switch_core_session_exec(_In_ switch_core_session_t *session, _In_ const switch_application_interface_t *application_interface, _In_opt_z_ const char *arg)
Execute an application on a session.
switch_status_t switch_ivr_play_file(switch_core_session_t *session, switch_file_handle_t *fh, const char *file, switch_input_args_t *args)
play a file from the disk to the session
A representation of an XML tree.
struct real_pcre switch_regex_t
#define switch_event_create_subclass(_e, _eid, _sn)
#define switch_core_session_execute_application(_a, _b, _c)
Execute an application on a session.
_Ret_ switch_channel_t * switch_core_session_get_channel(_In_ switch_core_session_t *session)
Retrieve a pointer to the channel object associated with a given session.
#define UNPROTECT_INTERFACE(_it)
#define switch_clear_flag(obj, flag)
Clear a flag on an arbitrary object while locked.
int main(int argc, char *argv[])
switch_status_t switch_ivr_collect_digits_count(switch_core_session_t *session, char *buf, switch_size_t buflen, switch_size_t maxdigits, const char *terminators, char *terminator, uint32_t first_timeout, uint32_t digit_timeout, uint32_t abs_timeout)
Wait for specified number of DTMF digits, untile terminator is received or until the channel hangs up...
switch_byte_t switch_byte_t * buf
switch_application_interface_t * switch_loadable_module_get_application_interface(const char *name)
Retrieve the application interface by it's registered name.
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
#define switch_channel_get_variable(_c, _v)
switch_status_t switch_event_add_header_string(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data)
Add a string header to an event.
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
switch_ivr_action_t action
int switch_regex_perform(const char *field, const char *expression, switch_regex_t **new_re, int *ovector, uint32_t olen)
#define switch_str_nil(s)
Make a null string a blank string instead.
#define switch_channel_expand_variables(_channel, _in)
switch_status_t
Common return values.
#define switch_goto_status(_status, _label)
switch_xml_t switch_xml_child(_In_ switch_xml_t xml, _In_z_ const char *name)
returns the first child tag (one level deeper) with the given name or NULL \ if not found ...
struct apr_pool_t switch_memory_pool_t
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session's pool.
#define switch_channel_set_variable(_channel, _var, _val)