mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-02 11:19:28 +00:00
fix missing strdup in switch_ivr_menu_bind_function
change most char * values in ivr_menu functions to const char * change switch_core_strdup to get passed const char * instead of char * change switch_xml_find_child to get passed const char * instead of char * change the ivr dialplan application to free the xml config as soon as it is done building the xml menu and not hold it until the menu is done being run, so that you can do a reloadxml while someone is in a menu without blocking. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4260 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
81dcb65cd5
commit
251723ba41
@ -391,7 +391,7 @@ SWITCH_DECLARE(char *) switch_core_session_strdup(switch_core_session_t *session
|
||||
\param todup the string to duplicate
|
||||
\return a pointer to the newly duplicated string
|
||||
*/
|
||||
SWITCH_DECLARE(char *) switch_core_strdup(switch_memory_pool_t *pool, char *todup);
|
||||
SWITCH_DECLARE(char *) switch_core_strdup(switch_memory_pool_t *pool, const char *todup);
|
||||
|
||||
/*!
|
||||
\brief Retrieve the memory pool from a session
|
||||
|
@ -540,13 +540,13 @@ typedef struct switch_ivr_menu_action switch_ivr_menu_action_t;
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t **new_menu,
|
||||
switch_ivr_menu_t *main,
|
||||
char *name,
|
||||
char *greeting_sound,
|
||||
char *short_greeting_sound,
|
||||
char *exit_sound,
|
||||
char *invalid_sound,
|
||||
char *tts_engine,
|
||||
char *tts_voice,
|
||||
const char *name,
|
||||
const char *greeting_sound,
|
||||
const char *short_greeting_sound,
|
||||
const char *exit_sound,
|
||||
const char *invalid_sound,
|
||||
const char *tts_engine,
|
||||
const char *tts_voice,
|
||||
int timeout,
|
||||
int max_failures,
|
||||
switch_memory_pool_t *pool);
|
||||
@ -559,7 +559,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t **new_men
|
||||
*\param bind KeyStrokes to bind the action to.
|
||||
*\return SWUTCH_STATUS_SUCCESS if the action was binded
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_action(switch_ivr_menu_t *menu, switch_ivr_action_t ivr_action, char *arg, char *bind);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_action(switch_ivr_menu_t *menu, switch_ivr_action_t ivr_action, const char *arg, const char *bind);
|
||||
|
||||
|
||||
/*!
|
||||
@ -573,7 +573,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_action(switch_ivr_menu_t *m
|
||||
*\note The function returns an switch_ivr_action_t enum of what you want to do. and looks to your buffer for args.
|
||||
*\return SWUTCH_STATUS_SUCCESS if the function was binded
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_function(switch_ivr_menu_t *menu, switch_ivr_menu_action_function_t *function, char *arg, char *bind);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_function(switch_ivr_menu_t *menu, switch_ivr_menu_action_function_t *function, const char *arg, const char *bind);
|
||||
|
||||
|
||||
/*!
|
||||
|
@ -143,7 +143,7 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_child(switch_xml_t xml, const char *name
|
||||
///\param attrname the attribute name
|
||||
///\param value the value
|
||||
///\return an xml node or NULL
|
||||
SWITCH_DECLARE(switch_xml_t) switch_xml_find_child(switch_xml_t node, char *childname, char *attrname, char *value);
|
||||
SWITCH_DECLARE(switch_xml_t) switch_xml_find_child(switch_xml_t node, const char *childname, const char *attrname, const char *value);
|
||||
|
||||
///\brief returns the next tag of the same name in the same section and depth or NULL
|
||||
///\ if not found
|
||||
|
@ -453,17 +453,19 @@ static void ivr_application_function(switch_core_session_t *session, char *data)
|
||||
#endif
|
||||
&& switch_ivr_menu_stack_xml_build(xml_ctx,&menu_stack,xml_menus,xml_menu) == SWITCH_STATUS_SUCCESS)
|
||||
{
|
||||
switch_xml_free(cxml);
|
||||
switch_channel_pre_answer(channel);
|
||||
switch_ivr_menu_execute(session,menu_stack,params,NULL);
|
||||
switch_ivr_menu_stack_free(menu_stack);
|
||||
} else {
|
||||
switch_xml_free(cxml);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to create menu '%s'\n", params);
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to find menu '%s'\n", params);
|
||||
}
|
||||
}
|
||||
switch_xml_free(cxml);
|
||||
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", ivr_cf_name);
|
||||
}
|
||||
|
@ -1489,7 +1489,7 @@ SWITCH_DECLARE(char *) switch_core_session_strdup(switch_core_session_t *session
|
||||
}
|
||||
|
||||
|
||||
SWITCH_DECLARE(char *) switch_core_strdup(switch_memory_pool_t *pool, char *todup)
|
||||
SWITCH_DECLARE(char *) switch_core_strdup(switch_memory_pool_t *pool, const char *todup)
|
||||
{
|
||||
char *duped = NULL;
|
||||
switch_size_t len;
|
||||
|
@ -3987,7 +3987,7 @@ struct switch_ivr_menu_action {
|
||||
struct switch_ivr_menu_action *next;
|
||||
};
|
||||
|
||||
static switch_ivr_menu_t *switch_ivr_menu_find(switch_ivr_menu_t *stack, char *name) {
|
||||
static switch_ivr_menu_t *switch_ivr_menu_find(switch_ivr_menu_t *stack, const char *name) {
|
||||
switch_ivr_menu_t *ret;
|
||||
for(ret = stack; ret ; ret = ret->next) {
|
||||
if (!name || !strcmp(ret->name, name))
|
||||
@ -4012,13 +4012,13 @@ static void switch_ivr_menu_stack_add(switch_ivr_menu_t **top, switch_ivr_menu_t
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t **new_menu,
|
||||
switch_ivr_menu_t *main,
|
||||
char *name,
|
||||
char *greeting_sound,
|
||||
char *short_greeting_sound,
|
||||
char *invalid_sound,
|
||||
char *exit_sound,
|
||||
char *tts_engine,
|
||||
char *tts_voice,
|
||||
const char *name,
|
||||
const char *greeting_sound,
|
||||
const char *short_greeting_sound,
|
||||
const char *invalid_sound,
|
||||
const char *exit_sound,
|
||||
const char *tts_engine,
|
||||
const char *tts_voice,
|
||||
int timeout,
|
||||
int max_failures,
|
||||
switch_memory_pool_t *pool)
|
||||
@ -4097,7 +4097,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t **new_men
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_action(switch_ivr_menu_t *menu, switch_ivr_action_t ivr_action, char *arg, char *bind)
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_action(switch_ivr_menu_t *menu, switch_ivr_action_t ivr_action, const char *arg, const char *bind)
|
||||
{
|
||||
switch_ivr_menu_action_t *action;
|
||||
uint32_t len;
|
||||
@ -4118,13 +4118,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_action(switch_ivr_menu_t *m
|
||||
return SWITCH_STATUS_MEMERR;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_function(switch_ivr_menu_t *menu, switch_ivr_menu_action_function_t *function, char *arg, char *bind)
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_function(switch_ivr_menu_t *menu, switch_ivr_menu_action_function_t *function, const char *arg, const char *bind)
|
||||
{
|
||||
switch_ivr_menu_action_t *action;
|
||||
uint32_t len;
|
||||
|
||||
if ((action = switch_core_alloc(menu->pool, sizeof(*action)))) {
|
||||
action->bind = bind;
|
||||
action->bind = switch_core_strdup(menu->pool,bind);
|
||||
action->next = menu->actions;
|
||||
action->arg = switch_core_strdup(menu->pool, arg);
|
||||
len = (uint32_t)strlen(action->bind) + 1;
|
||||
@ -4495,15 +4495,15 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
|
||||
if (xml_menu_ctx != NULL && menu_stack != NULL && xml_menu != NULL) {
|
||||
char *menu_name = (char *)switch_xml_attr_soft(xml_menu,"name"); // if the attr doesn't exist, return ""
|
||||
char *greet_long = (char *)switch_xml_attr(xml_menu,"greet-long"); // if the attr doesn't exist, return NULL
|
||||
char *greet_short = (char *)switch_xml_attr(xml_menu,"greet-short"); // if the attr doesn't exist, return NULL
|
||||
char *invalid_sound = (char *)switch_xml_attr(xml_menu,"invalid-sound"); // if the attr doesn't exist, return NULL
|
||||
char *exit_sound = (char *)switch_xml_attr(xml_menu,"exit-sound"); // if the attr doesn't exist, return NULL
|
||||
char *tts_engine = (char *)switch_xml_attr(xml_menu,"tts-engine"); // if the attr doesn't exist, return NULL
|
||||
char *tts_voice = (char *)switch_xml_attr(xml_menu,"tts-voice"); // if the attr doesn't exist, return NULL
|
||||
char *timeout = (char *)switch_xml_attr_soft(xml_menu,"timeout"); // if the attr doesn't exist, return ""
|
||||
char *max_failures = (char *)switch_xml_attr_soft(xml_menu,"max-failures"); // if the attr doesn't exist, return ""
|
||||
const char *menu_name = switch_xml_attr_soft(xml_menu,"name"); // if the attr doesn't exist, return ""
|
||||
const char *greet_long = switch_xml_attr(xml_menu,"greet-long"); // if the attr doesn't exist, return NULL
|
||||
const char *greet_short = switch_xml_attr(xml_menu,"greet-short"); // if the attr doesn't exist, return NULL
|
||||
const char *invalid_sound = switch_xml_attr(xml_menu,"invalid-sound"); // if the attr doesn't exist, return NULL
|
||||
const char *exit_sound = switch_xml_attr(xml_menu,"exit-sound"); // if the attr doesn't exist, return NULL
|
||||
const char *tts_engine = switch_xml_attr(xml_menu,"tts-engine"); // if the attr doesn't exist, return NULL
|
||||
const char *tts_voice = switch_xml_attr(xml_menu,"tts-voice"); // if the attr doesn't exist, return NULL
|
||||
const char *timeout = switch_xml_attr_soft(xml_menu,"timeout"); // if the attr doesn't exist, return ""
|
||||
const char *max_failures = switch_xml_attr_soft(xml_menu,"max-failures"); // if the attr doesn't exist, return ""
|
||||
switch_ivr_menu_t *menu = NULL;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "building menu '%s'\n",menu_name);
|
||||
@ -4530,9 +4530,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_
|
||||
|
||||
// build menu entries
|
||||
for(xml_kvp = switch_xml_child(xml_menu, "entry"); xml_kvp != NULL && status == SWITCH_STATUS_SUCCESS; xml_kvp = xml_kvp->next) {
|
||||
char *action = (char *)switch_xml_attr(xml_kvp, "action");
|
||||
char *digits = (char *)switch_xml_attr(xml_kvp, "digits");
|
||||
char *param = (char *)switch_xml_attr_soft(xml_kvp, "param");
|
||||
const char *action = switch_xml_attr(xml_kvp, "action");
|
||||
const char *digits = switch_xml_attr(xml_kvp, "digits");
|
||||
const char *param = switch_xml_attr_soft(xml_kvp, "param");
|
||||
|
||||
if (!switch_strlen_zero(action) && !switch_strlen_zero(digits)) {
|
||||
switch_ivr_menu_xml_map_t *xml_map = xml_menu_ctx->map;
|
||||
|
@ -169,7 +169,7 @@ SWITCH_DECLARE(switch_status_t) switch_xml_bind_search_function(switch_xml_searc
|
||||
}
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_xml_t) switch_xml_find_child(switch_xml_t node, char *childname, char *attrname, char *value)
|
||||
SWITCH_DECLARE(switch_xml_t) switch_xml_find_child(switch_xml_t node, const char *childname, const char *attrname, const char *value)
|
||||
{
|
||||
switch_xml_t p = NULL;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user