]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix missing strdup in switch_ivr_menu_bind_function
authorMichael Jerris <mike@jerris.com>
Wed, 14 Feb 2007 17:28:42 +0000 (17:28 +0000)
committerMichael Jerris <mike@jerris.com>
Wed, 14 Feb 2007 17:28:42 +0000 (17:28 +0000)
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

src/include/switch_core.h
src/include/switch_ivr.h
src/include/switch_xml.h
src/mod/applications/mod_dptools/mod_dptools.c
src/switch_core.c
src/switch_ivr.c
src/switch_xml.c

index 02f011408ab4b6a7d3ca09acf6c1b331bd521c20..5f852fd4eb542e3b567d8d773cae4bf1676012b0 100644 (file)
@@ -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
index 2dbb9919fbc220ce254771f4d6ae0768a11b09aa..63df8ab914d7762608a5dedc2dbe9d5b655ffa5c 100644 (file)
@@ -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);
 
 
 /*!
index a63e3c8e68a8c627129ae297ced77267032082de..a79a54db9a4a9fad26c627cb78556fcd87ae2fcb 100644 (file)
@@ -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
index 764dfb23d91fe79fcb755f2daa40bf39c5e7a6b7..bfacdf89a62b10b1eb1c33f4e21b82bb7e64169c 100644 (file)
@@ -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);
                }
index 4c473d01865d3bfd7e7cecb7ef64477d2e3cb383..c4187b459b638eafc341f0eb267d772e89a68cb2 100644 (file)
@@ -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;
index a0c5b29136ed474427c08098f7a7cd84b9beed70..8f61739b06b27b84bb3cedf95ad8a20ba9570c14 100644 (file)
@@ -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;
index d68d2f50d18ab28516be233a74370f1badeaacd0..303007006421c24eb531f3aa7d4c84b0b5ada7da 100644 (file)
@@ -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;