]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add removable xml hook bindings
authorAnthony Minessale <anthony.minessale@gmail.com>
Mon, 7 Jul 2008 17:10:17 +0000 (17:10 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Mon, 7 Jul 2008 17:10:17 +0000 (17:10 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8905 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_types.h
src/include/switch_xml.h
src/switch_xml.cpp

index 9c7e1f4499fce181ca6795c0426736ce1d0d8cb1..86694401aed48b74d455c109a29dc4e715c30159 100644 (file)
@@ -1233,7 +1233,7 @@ typedef struct switch_management_interface switch_management_interface_t;
 typedef struct switch_core_port_allocator switch_core_port_allocator_t;
 typedef struct switch_media_bug switch_media_bug_t;
 typedef switch_bool_t (*switch_media_bug_callback_t) (switch_media_bug_t *, void *, switch_abc_type_t);
-
+typedef struct switch_xml_binding switch_xml_binding_t;
 
 typedef switch_status_t (*switch_core_codec_encode_func_t) (switch_codec_t *codec,
                                                                                                                        switch_codec_t *other_codec,
index 55f24107e8801486fa6c004f7ca13e27582f0a9f..237f24969b5f375ed3dd31a31149a3c7aaf4b19e 100644 (file)
@@ -58,6 +58,8 @@
 #include <switch.h>
 
 
+struct switch_xml_binding;
+
 ///\defgroup xml1 XML Library Functions
 ///\ingroup core1
 ///\{
@@ -349,6 +351,18 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_open_cfg(const char *file_path, switch_x
 ///\note gateway functions will be executed in the order they were binded until a success is found else the root registry will be used
 SWITCH_DECLARE(switch_status_t) switch_xml_bind_search_function(switch_xml_search_function_t function, switch_xml_section_t sections, void *user_data);
 
+///\brief bind a search function to an external gateway
+///\param function the search function to bind
+///\param sections a bitmask of sections you wil service
+///\param user_data a pointer to private data to be used during the callback
+///\param binding a handle to use to later unbind.
+///\return SWITCH_STATUS_SUCCESS if successful
+///\note gateway functions will be executed in the order they were binded until a success is found else the root registry will be used
+SWITCH_DECLARE(switch_status_t) switch_xml_bind_search_function_removable(switch_xml_search_function_t function, 
+                                                                                                                                                 switch_xml_section_t sections, void *user_data, switch_xml_binding_t **binding);
+
+SWITCH_DECLARE(switch_status_t) switch_xml_unbind_search_function(switch_xml_binding_t **binding);
+
 ///\brief parse a string for a list of sections
 ///\param str a | delimited list of section names
 ///\return the section mask
index 00a1d5aa607e0e84dd699459f980e78d2b1f5823..804dfbfb7bad439e03ab0cec1be15b4e6bc8895d 100644 (file)
@@ -97,7 +97,7 @@ struct switch_xml_binding {
        struct switch_xml_binding *next;
 };
 
-typedef struct switch_xml_binding switch_xml_binding_t;
+
 static switch_xml_binding_t *BINDINGS = NULL;
 static switch_xml_t MAIN_XML_ROOT = NULL;
 static switch_memory_pool_t *XML_MEMORY_POOL;
@@ -143,6 +143,28 @@ SWITCH_DECLARE(switch_xml_section_t) switch_xml_parse_section_string(const char
        return (switch_xml_section_t) sections;
 }
 
+SWITCH_DECLARE(switch_status_t) switch_xml_unbind_search_function(switch_xml_binding_t **binding)
+{
+       switch_xml_binding_t *ptr, *last = NULL;
+       switch_status_t status = SWITCH_STATUS_FALSE;
+
+       switch_mutex_lock(XML_LOCK);
+       for (ptr = BINDINGS; ptr; ptr = ptr->next) {
+               if (ptr == *binding) {
+                       if (last) {
+                               last->next = (*binding)->next;
+                       } else {
+                               BINDINGS = (*binding)->next;
+                       }
+                       status = SWITCH_STATUS_SUCCESS;
+                       break;
+               }
+       }
+       switch_mutex_unlock(XML_LOCK);
+
+       return status;
+}
+
 SWITCH_DECLARE(switch_status_t) switch_xml_bind_search_function(switch_xml_search_function_t function, switch_xml_section_t sections, void *user_data)
 {
        switch_xml_binding_t *binding = NULL, *ptr = NULL;