56 #ifndef FREESWITCH_XML_H 57 #define FREESWITCH_XML_H 61 #define USE_UTF_8_ENCODING SWITCH_TRUE 69 #define SWITCH_XML_BUFSIZE 1024 // size of internal memory buffers 124 #define switch_xml_parse_str_dup(x) switch_xml_parse_str_dynamic(x, SWITCH_TRUE) 177 #define switch_xml_next(xml) ((xml) ? xml->next : NULL) 189 #define switch_xml_name(xml) ((xml) ? xml->name : NULL) 194 #define switch_xml_txt(xml) ((xml) ? xml->txt : "") 224 #define switch_xml_toxml(xml, prn_header) switch_xml_toxml_ex(xml, prn_header, USE_UTF_8_ENCODING) 225 #define switch_xml_toxml_nolock(xml, prn_header) switch_xml_toxml_nolock_ex(xml, prn_header, USE_UTF_8_ENCODING) 226 #define switch_xml_tohtml(xml, prn_header) switch_xml_tohtml_ex(xml, prn_header, USE_UTF_8_ENCODING) 240 #define switch_xml_toxml_buf(xml, buf, buflen, offset, prn_header) switch_xml_toxml_buf_ex(xml, buf, buflen, offset, prn_header, USE_UTF_8_ENCODING); 270 #define switch_xml_new_d(name) switch_xml_set_flag(switch_xml_new(strdup(name)), SWITCH_XML_NAMEM) 336 #define switch_xml_move(xml, dest, off) switch_xml_insert(switch_xml_cut(xml), dest, off) 339 #define switch_xml_remove(xml) switch_xml_free(switch_xml_cut(xml)) 388 _In_z_ const char *domain_name,
393 _In_z_ const char *user_name,
394 _In_z_ const char *domain_name,
431 #define switch_xml_bind_search_function(_f, _s, _u) switch_xml_bind_search_function_ret(_f, _s, _u, NULL) 448 #endif // _SWITCH_XML_H switch_xml_t switch_xml_set_attr_d_buf(switch_xml_t xml, const char *name, const char *value)
Wrapper for switch_xml_set_attr() that strdup()s name/value. Value cannot be NULL.
switch_xml_t switch_xml_add_child_d(_In_ switch_xml_t xml, _In_z_ const char *name, _In_ switch_size_t off)
wrapper for switch_xml_add_child() that strdup()s name
void switch_xml_free(_In_opt_ switch_xml_t xml)
frees the memory allocated for an switch_xml structure
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)
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' ...
switch_xml_t switch_xml_set_attr_d(switch_xml_t xml, const char *name, const char *value)
Wrapper for switch_xml_set_attr() that strdup()s name/value. Value cannot be NULL.
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
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_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)
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_root(void)
retrieve the core XML root node
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
const char *const const char *const const cJSON *const value
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_set_txt_d(switch_xml_t xml, const char *txt)
wrapper for switch_xml_set_txt() that strdup()s txt \ sets the character content for the given tag an...
char * switch_xml_toxml_ex(_In_ switch_xml_t xml, _In_ switch_bool_t prn_header, switch_bool_t use_utf8_encoding)
char * switch_xml_toxml_buf_ex(_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, switch_bool_t use_utf8_encoding)
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)
switch_xml_t(* switch_xml_open_root_function_t)(uint8_t reload, const char **err, void *user_data)
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
char * switch_xml_tohtml_ex(_In_ switch_xml_t xml, _In_ switch_bool_t prn_header, switch_bool_t use_utf8_encoding)
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...
const cJSON *const target
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
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
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 ...
char * switch_xml_toxml_nolock_ex(switch_xml_t xml, _In_ switch_bool_t prn_header, switch_bool_t use_utf8_encoding)
struct fspr_pool_t switch_memory_pool_t
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.