56 #ifndef FREESWITCH_XML_H
57 #define FREESWITCH_XML_H
67 #define SWITCH_XML_BUFSIZE 1024 // size of internal memory buffers
117 #define switch_xml_parse_str_dup(x) switch_xml_parse_str_dynamic(x, SWITCH_TRUE)
170 #define switch_xml_next(xml) ((xml) ? xml->next : NULL)
182 #define switch_xml_name(xml) ((xml) ? xml->name : NULL)
187 #define switch_xml_txt(xml) ((xml) ? xml->txt : "")
255 #define switch_xml_new_d(name) switch_xml_set_flag(switch_xml_new(strdup(name)), SWITCH_XML_NAMEM)
269 #define switch_xml_add_child_d(xml, name, off) \
270 switch_xml_set_flag(switch_xml_add_child(xml, strdup(name), off), SWITCH_XML_NAMEM)
283 #define switch_xml_set_txt_d(xml, txt) \
284 switch_xml_set_flag(switch_xml_set_txt(xml, strdup(txt)), SWITCH_XML_TXTM)
299 #define switch_xml_set_attr_d(xml, name, value) \
300 switch_xml_set_attr(switch_xml_set_flag(xml, SWITCH_XML_DUP), strdup(name), strdup(switch_str_nil(value)))
302 #define switch_xml_set_attr_d_buf(xml, name, value) \
303 switch_xml_set_attr(switch_xml_set_flag(xml, SWITCH_XML_DUP), strdup(name), strdup(value))
320 #define switch_xml_move(xml, dest, off) switch_xml_insert(switch_xml_cut(xml), dest, off)
323 #define switch_xml_remove(xml) switch_xml_free(switch_xml_cut(xml))
372 _In_z_ const
char *domain_name,
377 _In_z_ const
char *user_name,
378 _In_z_ const
char *domain_name,
415 #define switch_xml_bind_search_function(_f, _s, _u) switch_xml_bind_search_function_ret(_f, _s, _u, NULL)
432 #endif // _SWITCH_XML_H
void switch_xml_free(_In_opt_ switch_xml_t xml)
frees the memory allocated for an switch_xml structure
char * switch_xml_toxml_buf(_In_ switch_xml_t xml, _In_z_ char *buf, _In_ switch_size_t buflen, _In_ switch_size_t offset, _In_ switch_bool_t prn_header)
Converts an switch_xml structure back to xml using the buffer passed in the parameters.
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
switch_xml_t switch_xml_set_attr(switch_xml_t xml, const char *name, const char *value)
Sets the given tag attribute or adds a new attribute if not found. A value \ of NULL will remove the ...
switch_status_t switch_xml_locate_domain(_In_z_ const char *domain_name, _In_opt_ switch_event_t *params, _Out_ switch_xml_t *root, _Out_ switch_xml_t *domain)
char * switch_xml_toxml(_In_ switch_xml_t xml, _In_ switch_bool_t prn_header)
Converts an switch_xml structure back to xml in html format. Returns a string of html data that \ mus...
void switch_xml_set_binding_user_data(_In_ switch_xml_binding_t *binding, _In_opt_ void *user_data)
switch_xml_t switch_xml_parse_str_dynamic(_In_z_ char *s, _In_ switch_bool_t dup)
Parses a string into a switch_xml_t, ensuring the memory will be freed with switch_xml_free.
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
char * switch_xml_tohtml(_In_ switch_xml_t xml, _In_ switch_bool_t prn_header)
switch_xml_t switch_xml_find_child_multi(_In_ switch_xml_t node, _In_z_ const char *childname,...)
#define SWITCH_END_EXTERN_C
switch_xml_t switch_xml_add_child(_In_ switch_xml_t xml, _In_z_ const char *name, _In_ switch_size_t off)
Adds a child tag. off is the offset of the child tag relative to the start \ of the parent tag's char...
switch_status_t switch_xml_locate_language(switch_xml_t *root, switch_xml_t *node, switch_event_t *params, switch_xml_t *language, switch_xml_t *phrases, switch_xml_t *macros, const char *str_language)
switch_xml_t(* switch_xml_open_root_function_t)(uint8_t reload, const char **err, void *user_data)
const char ** switch_xml_pi(_In_ switch_xml_t xml, _In_z_ const char *target)
returns a NULL terminated array of processing instructions for the given \ target ...
switch_status_t switch_xml_locate_user_merged(const char *key, const char *user_name, const char *domain_name, const char *ip, switch_xml_t *user, switch_event_t *params)
switch_xml_t switch_xml_parse_fp(_In_ FILE *fp)
Wrapper for switch_xml_parse_str() that accepts a file stream. Reads the entire \ stream into memory ...
switch_xml_t switch_xml_set_flag(switch_xml_t xml, switch_xml_flag_t flag)
sets a flag for the given tag and returns the tag
switch_memory_pool_t * pool
void switch_xml_set_binding_sections(_In_ switch_xml_binding_t *binding, _In_ switch_xml_section_t sections)
bind a search function to an external gateway
Representation of an event.
switch_xml_section_t switch_xml_parse_section_string(_In_opt_z_ const char *str)
parse a string for a list of sections
switch_xml_t switch_xml_set_txt(switch_xml_t xml, const char *txt)
sets the character content for the given tag and returns the tag
switch_bool_t is_switch_xml_root_t
A representation of an XML tree.
switch_xml_t switch_xml_insert(_In_ switch_xml_t xml, _In_ switch_xml_t dest, _In_ switch_size_t off)
inserts an existing tag into an ezxml structure
switch_status_t switch_xml_reload(const char **err)
switch_xml_t switch_xml_parse_str(_In_z_ char *s, _In_ switch_size_t len)
Given a string of xml data and its length, parses it and creates an switch_xml \ structure. For efficiency, modifies the data by adding null terminators \ and decoding ampersand sequences. If you don't want this, copy the data and \ pass in the copy. Returns NULL on failure.
switch_xml_t switch_xml_dup(switch_xml_t xml)
switch_status_t switch_xml_locate_user(_In_z_ const char *key, _In_z_ const char *user_name, _In_z_ const char *domain_name, _In_opt_z_ const char *ip, _Out_ switch_xml_t *root, _Out_ switch_xml_t *domain, _Out_ switch_xml_t *user, _Out_opt_ switch_xml_t *ingroup, _In_opt_ switch_event_t *params)
switch_status_t switch_xml_locate_group(_In_z_ const char *group_name, _In_z_ const char *domain_name, _Out_ switch_xml_t *root, _Out_ switch_xml_t *domain, _Out_ switch_xml_t *group, _In_opt_ switch_event_t *params)
switch_xml_t switch_xml_open_root(_In_ uint8_t reload, _Out_ const char **err)
open the Core xml root
switch_byte_t switch_byte_t * buf
switch_status_t switch_xml_locate_user_in_domain(_In_z_ const char *user_name, _In_ switch_xml_t domain, _Out_ switch_xml_t *user, _Out_opt_ switch_xml_t *ingroup)
switch_status_t switch_xml_unbind_search_function_ptr(_In_ switch_xml_search_function_t function)
int switch_xml_std_datetime_check(switch_xml_t xcond, int *offset, const char *tzname)
uint32_t switch_xml_section_t
switch_xml_t switch_xml_new(_In_opt_z_ const char *name)
returns a new empty switch_xml structure with the given root tag name
switch_status_t switch_xml_locate(_In_z_ const char *section, _In_opt_z_ const char *tag_name, _In_opt_z_ const char *key_name, _In_opt_z_ const char *key_value, _Out_ switch_xml_t *root, _Out_ switch_xml_t *node, _In_opt_ switch_event_t *params, _In_ switch_bool_t clone)
locate an xml pointer in the core registry
switch_xml_section_t switch_xml_get_binding_sections(_In_ switch_xml_binding_t *binding)
switch_byte_t switch_byte_t uint32_t buflen
switch_status_t switch_xml_unbind_search_function(_In_ switch_xml_binding_t **binding)
void * switch_xml_get_binding_user_data(_In_ switch_xml_binding_t *binding)
switch_xml_t switch_xml_idx(_In_ switch_xml_t xml, _In_ int idx)
Returns the Nth tag with the same name in the same section at the same depth \ or NULL if not found...
switch_status_t switch_xml_destroy(void)
uint32_t switch_xml_clear_user_cache(const char *key, const char *user_name, const char *domain_name)
switch_xml_t switch_xml_cut(_In_ switch_xml_t xml)
removes a tag along with its subtags without freeing its memory
switch_status_t switch_xml_bind_search_function_ret(_In_ switch_xml_search_function_t function, _In_ switch_xml_section_t sections, _In_opt_ void *user_data, switch_xml_binding_t **ret_binding)
switch_xml_t switch_xml_parse_file(_In_z_ const char *file)
a wrapper for switch_xml_parse_fd() that accepts a file name
switch_status_t
Common return values.
switch_xml_t switch_xml_get(_In_ switch_xml_t xml,...)
Traverses the switch_xml structure to retrieve a specific subtag. Takes a \ variable length list of t...
switch_xml_t switch_xml_open_cfg(_In_z_ const char *file_path, _Out_ switch_xml_t *node, _In_opt_ switch_event_t *params)
open a config in the core registry
switch_status_t switch_xml_set_root(switch_xml_t new_main)
set new core xml root
char * switch_xml_toxml_nolock(switch_xml_t xml, _In_ switch_bool_t prn_header)
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 ...
void switch_xml_free_in_thread(_In_ switch_xml_t xml, _In_ int stacksize)
void switch_xml_merge_user(switch_xml_t user, switch_xml_t domain, switch_xml_t group)
const char * switch_xml_error(_In_ switch_xml_t xml)
returns parser error message or empty string if none
struct apr_pool_t switch_memory_pool_t
switch_xml_t switch_xml_parse_file_simple(_In_z_ const char *file)
switch_xml_t switch_xml_parse_fd(int fd)
A wrapper for switch_xml_parse_str() that accepts a file descriptor. First \ attempts to mem map the ...
switch_xml_t(* switch_xml_search_function_t)(const char *section, const char *tag_name, const char *key_name, const char *key_value, switch_event_t *params, void *user_data)
switch_status_t switch_xml_init(_In_ switch_memory_pool_t *pool, _Out_ const char **err)
initilize the core XML backend
#define SWITCH_BEGIN_EXTERN_C
switch_status_t switch_xml_set_open_root_function(switch_xml_open_root_function_t func, void *user_data)
Set and alternate function for opening xml root.