[Freeswitch-svn] [commit] r4260 - in freeswitch/trunk/src: . include mod/applications/mod_dptools
Freeswitch SVN
mikej at freeswitch.org
Wed Feb 14 12:28:42 EST 2007
Author: mikej
Date: Wed Feb 14 12:28:42 2007
New Revision: 4260
Modified:
freeswitch/trunk/src/include/switch_core.h
freeswitch/trunk/src/include/switch_ivr.h
freeswitch/trunk/src/include/switch_xml.h
freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
freeswitch/trunk/src/switch_core.c
freeswitch/trunk/src/switch_ivr.c
freeswitch/trunk/src/switch_xml.c
Log:
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.
Modified: freeswitch/trunk/src/include/switch_core.h
==============================================================================
--- freeswitch/trunk/src/include/switch_core.h (original)
+++ freeswitch/trunk/src/include/switch_core.h Wed Feb 14 12:28:42 2007
@@ -391,7 +391,7 @@
\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
Modified: freeswitch/trunk/src/include/switch_ivr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_ivr.h (original)
+++ freeswitch/trunk/src/include/switch_ivr.h Wed Feb 14 12:28:42 2007
@@ -540,13 +540,13 @@
*/
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 @@
*\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 @@
*\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);
/*!
Modified: freeswitch/trunk/src/include/switch_xml.h
==============================================================================
--- freeswitch/trunk/src/include/switch_xml.h (original)
+++ freeswitch/trunk/src/include/switch_xml.h Wed Feb 14 12:28:42 2007
@@ -143,7 +143,7 @@
///\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
Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Wed Feb 14 12:28:42 2007
@@ -453,17 +453,19 @@
#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);
}
Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c (original)
+++ freeswitch/trunk/src/switch_core.c Wed Feb 14 12:28:42 2007
@@ -1489,7 +1489,7 @@
}
-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;
Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c (original)
+++ freeswitch/trunk/src/switch_ivr.c Wed Feb 14 12:28:42 2007
@@ -3987,7 +3987,7 @@
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 @@
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 @@
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 @@
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_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 @@
// 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;
Modified: freeswitch/trunk/src/switch_xml.c
==============================================================================
--- freeswitch/trunk/src/switch_xml.c (original)
+++ freeswitch/trunk/src/switch_xml.c Wed Feb 14 12:28:42 2007
@@ -169,7 +169,7 @@
}
-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;
More information about the Freeswitch-svn
mailing list