XML Library Functions
[Core Library]

Collaboration diagram for XML Library Functions:

Data Structures

struct  switch_xml
 A representation of an XML tree. More...

Defines

#define SWITCH_XML_BUFSIZE   1024
#define switch_xml_parse_str_dup(x)   switch_xml_parse_str_dynamic(x, SWITCH_TRUE)
 Parses a string into a switch_xml_t.
#define switch_xml_next(xml)   ((xml) ? xml->next : NULL)
 returns the next tag of the same name in the same section and depth or NULL \ if not found
#define switch_xml_name(xml)   ((xml) ? xml->name : NULL)
 returns the name of the given tag
#define switch_xml_txt(xml)   ((xml) ? xml->txt : "")
 returns the given tag's character content or empty string if none
#define switch_xml_new_d(name)   switch_xml_set_flag(switch_xml_new(strdup(name)), SWITCH_XML_NAMEM)
 wrapper for switch_xml_new() that strdup()s name
#define switch_xml_add_child_d(xml, name, off)   switch_xml_set_flag(switch_xml_add_child(xml, strdup(name), off), SWITCH_XML_NAMEM)
 wrapper for switch_xml_add_child() that strdup()s name
#define switch_xml_set_txt_d(xml, txt)   switch_xml_set_flag(switch_xml_set_txt(xml, strdup(txt)), SWITCH_XML_TXTM)
 wrapper for switch_xml_set_txt() that strdup()s txt \ sets the character content for the given tag and returns the tag
#define switch_xml_set_attr_d(xml, name, value)   switch_xml_set_attr(switch_xml_set_flag(xml, SWITCH_XML_DUP), strdup(name), strdup(switch_str_nil(value)))
 Wrapper for switch_xml_set_attr() that strdup()s name/value. Value cannot be NULL.
#define switch_xml_set_attr_d_buf(xml, name, value)   switch_xml_set_attr(switch_xml_set_flag(xml, SWITCH_XML_DUP), strdup(name), strdup(value))
#define switch_xml_move(xml, dest, off)   switch_xml_insert(switch_xml_cut(xml), dest, off)
 Moves an existing tag to become a subtag of dest at the given offset from \ the start of dest's character content. Returns the moved tag.
#define switch_xml_remove(xml)   switch_xml_free(switch_xml_cut(xml))
 removes a tag along with all its subtags
#define switch_xml_bind_search_function(_f, _s, _u)   switch_xml_bind_search_function_ret(_f, _s, _u, NULL)

Enumerations

enum  switch_xml_flag_t { SWITCH_XML_ROOT = (1 << 0), SWITCH_XML_NAMEM = (1 << 1), SWITCH_XML_TXTM = (1 << 2), SWITCH_XML_DUP = (1 << 3) }

Functions

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_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_parse_fd (int fd)
 A wrapper for switch_xml_parse_str() that accepts a file descriptor. First \ attempts to mem map the file. Failing that, reads the file into memory. \ Returns NULL on failure.
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_xml_t switch_xml_parse_file_simple (_In_z_ const char *file)
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 and then parses it. For xml files, use switch_xml_parse_file() \ or switch_xml_parse_fd().
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
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_find_child_multi (_In_ switch_xml_t node, _In_z_ const char *childname,...)
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. An index of 0 returns the tag given.
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
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_get (_In_ switch_xml_t xml,...)
 Traverses the switch_xml sturcture to retrieve a specific subtag. Takes a \ variable length list of tag names and indexes. The argument list must be \ terminated by either an index of -1 or an empty string tag name. Example: \ title = switch_xml_get(library, "shelf", 0, "book", 2, "title", -1); \ This retrieves the title of the 3rd book on the 1st shelf of library. \ Returns NULL if not found.
char * switch_xml_toxml (_In_ switch_xml_t xml, _In_ switch_bool_t prn_header)
 Converts an switch_xml structure back to xml. Returns a string of xml data that \ must be freed.
char * switch_xml_toxml_nolock (switch_xml_t xml, _In_ switch_bool_t prn_header)
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_pi (_In_ switch_xml_t xml, _In_z_ const char *target)
 returns a NULL terminated array of processing instructions for the given \ target
void switch_xml_free (_In_opt_ switch_xml_t xml)
 frees the memory allocated for an switch_xml structure
void switch_xml_free_in_thread (_In_ switch_xml_t xml, _In_ int stacksize)
const char * switch_xml_error (_In_ switch_xml_t xml)
 returns parser error message or empty string if none
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_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 character content. Returns the child tag.
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_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 specified attribute.
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_xml_t switch_xml_cut (_In_ switch_xml_t xml)
 removes a tag along with its subtags without freeing its memory
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_set_root (switch_xml_t new_main)
 set new core xml root
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.
switch_xml_t switch_xml_open_root (_In_ uint8_t reload, _Out_ const char **err)
 open the Core xml root
switch_status_t switch_xml_init (_In_ switch_memory_pool_t *pool, _Out_ const char **err)
 initilize the core XML backend
switch_status_t switch_xml_reload (const char **err)
switch_status_t switch_xml_destroy (void)
switch_xml_t switch_xml_root (void)
 retrieve the core XML root node
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_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)
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_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_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_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)
uint32_t switch_xml_clear_user_cache (const char *key, const char *user_name, const char *domain_name)
void switch_xml_merge_user (switch_xml_t user, switch_xml_t domain, switch_xml_t group)
switch_xml_t switch_xml_dup (switch_xml_t xml)
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
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
void switch_xml_set_binding_user_data (_In_ switch_xml_binding_t *binding, _In_opt_ void *user_data)
switch_xml_section_t switch_xml_get_binding_sections (_In_ switch_xml_binding_t *binding)
void * switch_xml_get_binding_user_data (_In_ switch_xml_binding_t *binding)
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_status_t switch_xml_unbind_search_function (_In_ switch_xml_binding_t **binding)
switch_status_t switch_xml_unbind_search_function_ptr (_In_ switch_xml_search_function_t function)
switch_xml_section_t switch_xml_parse_section_string (_In_opt_z_ const char *str)
 parse a string for a list of sections
int switch_xml_std_datetime_check (switch_xml_t xcond, int *offset)
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)


Define Documentation

#define switch_xml_add_child_d ( xml,
name,
off   )     switch_xml_set_flag(switch_xml_add_child(xml, strdup(name), off), SWITCH_XML_NAMEM)

wrapper for switch_xml_add_child() that strdup()s name

Parameters:
xml the xml node
name the name of the child
off the offset

Definition at line 267 of file switch_xml.h.

Referenced by add_xml_header(), comp_callback(), do_merge(), switch_event_xmlize(), switch_ivr_generate_xml_cdr(), switch_ivr_set_xml_chan_var(), and switch_ivr_set_xml_profile_data().

#define switch_xml_bind_search_function ( _f,
_s,
_u   )     switch_xml_bind_search_function_ret(_f, _s, _u, NULL)

Definition at line 413 of file switch_xml.h.

#define SWITCH_XML_BUFSIZE   1024

Definition at line 67 of file switch_xml.h.

Referenced by switch_xml_ampencode(), switch_xml_parse_fp(), switch_xml_str2utf8(), switch_xml_toxml(), switch_xml_toxml_buf(), switch_xml_toxml_nolock(), and switch_xml_toxml_r().

#define switch_xml_move ( xml,
dest,
off   )     switch_xml_insert(switch_xml_cut(xml), dest, off)

Moves an existing tag to become a subtag of dest at the given offset from \ the start of dest's character content. Returns the moved tag.

Definition at line 318 of file switch_xml.h.

#define switch_xml_name ( xml   )     ((xml) ? xml->name : NULL)

returns the name of the given tag

Parameters:
xml the xml node
Returns:
the name

Definition at line 182 of file switch_xml.h.

#define switch_xml_new_d ( name   )     switch_xml_set_flag(switch_xml_new(strdup(name)), SWITCH_XML_NAMEM)

wrapper for switch_xml_new() that strdup()s name

Parameters:
name the name of the root
Returns:
an xml node or NULL

Definition at line 253 of file switch_xml.h.

#define switch_xml_next ( xml   )     ((xml) ? xml->next : NULL)

returns the next tag of the same name in the same section and depth or NULL \ if not found

Parameters:
xml an xml node
Returns:
an xml node or NULL

Definition at line 170 of file switch_xml.h.

Referenced by switch_nat_republish().

#define switch_xml_parse_str_dup (  )     switch_xml_parse_str_dynamic(x, SWITCH_TRUE)

Parses a string into a switch_xml_t.

Parameters:
s The string to parse
Returns:
the switch_xml_t or NULL if an error occured

Definition at line 117 of file switch_xml.h.

Referenced by switch_nat_republish().

#define switch_xml_remove ( xml   )     switch_xml_free(switch_xml_cut(xml))

removes a tag along with all its subtags

Definition at line 321 of file switch_xml.h.

#define switch_xml_set_attr_d ( xml,
name,
value   )     switch_xml_set_attr(switch_xml_set_flag(xml, SWITCH_XML_DUP), strdup(name), strdup(switch_str_nil(value)))

Wrapper for switch_xml_set_attr() that strdup()s name/value. Value cannot be NULL.

Parameters:
xml the xml node
name the attribute name
value the attribute value
Returns:
an xml node or NULL

Definition at line 297 of file switch_xml.h.

Referenced by do_merge(), and switch_ivr_generate_xml_cdr().

#define switch_xml_set_attr_d_buf ( xml,
name,
value   )     switch_xml_set_attr(switch_xml_set_flag(xml, SWITCH_XML_DUP), strdup(name), strdup(value))

Definition at line 300 of file switch_xml.h.

Referenced by switch_ivr_generate_xml_cdr().

#define switch_xml_set_txt_d ( xml,
txt   )     switch_xml_set_flag(switch_xml_set_txt(xml, strdup(txt)), SWITCH_XML_TXTM)

wrapper for switch_xml_set_txt() that strdup()s txt \ sets the character content for the given tag and returns the tag

Parameters:
xml the xml node
txt the text
Returns:
an xml node or NULL

Definition at line 281 of file switch_xml.h.

Referenced by add_xml_header(), comp_callback(), switch_event_xmlize(), switch_ivr_generate_xml_cdr(), switch_ivr_set_xml_chan_var(), and switch_ivr_set_xml_profile_data().

#define switch_xml_txt ( xml   )     ((xml) ? xml->txt : "")

returns the given tag's character content or empty string if none

Parameters:
xml the xml node
Returns:
the content

Definition at line 187 of file switch_xml.h.


Enumeration Type Documentation

enum switch_xml_flag_t

Enumerator:
SWITCH_XML_ROOT 
SWITCH_XML_NAMEM 
SWITCH_XML_TXTM 
SWITCH_XML_DUP 

Definition at line 68 of file switch_xml.h.

00068                      {
00069         SWITCH_XML_ROOT = (1 << 0),     // root
00070         SWITCH_XML_NAMEM = (1 << 1),    // name is malloced
00071         SWITCH_XML_TXTM = (1 << 2),     // txt is malloced
00072         SWITCH_XML_DUP = (1 << 3)       // attribute name and value are strduped
00073 } switch_xml_flag_t;


Function Documentation

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 character content. Returns the child tag.

Parameters:
xml the xml node
name the name of the tag
off the offset
Returns:
an xml node or NULL

Referenced by switch_xml_open_tag().

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

Parameters:
xml the xml node
attr the attribute
Returns:
the value

Referenced by do_merge(), switch_ivr_check_presence_mapping(), switch_ivr_menu_stack_xml_build(), switch_ivr_phrase_macro_event(), switch_ivr_say(), switch_ivr_say_string(), switch_ivr_set_user(), switch_load_network_lists(), switch_load_timezones(), switch_xml_attr_soft(), switch_xml_find_child(), switch_xml_find_child_multi(), switch_xml_locate(), switch_xml_locate_user_merged(), switch_xml_std_datetime_check(), and switch_xml_toxml_r().

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

Parameters:
xml the xml node
attr the attribute
Returns:
the value

Referenced by console_xml_config(), switch_event_import_xml(), switch_ivr_menu_stack_xml_build(), switch_ivr_phrase_macro_event(), switch_load_core_config(), and switch_loadable_module_init().

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_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

Parameters:
xml an xml node
name the name of the child tag
Returns:
an xml node or NULL

Referenced by console_xml_config(), do_merge(), switch_core_session_request_xml(), switch_ivr_check_presence_mapping(), switch_ivr_menu_stack_xml_build(), switch_ivr_phrase_macro_event(), switch_ivr_set_user(), switch_load_core_config(), switch_load_network_lists(), switch_load_timezones(), switch_loadable_module_init(), switch_nat_republish(), switch_xml_config_parse_module_settings(), switch_xml_find_child(), switch_xml_find_child_multi(), switch_xml_locate(), switch_xml_locate_group(), switch_xml_locate_language(), switch_xml_locate_user(), switch_xml_locate_user_in_domain(), switch_xml_vget(), and xml_find_var().

uint32_t switch_xml_clear_user_cache ( const char *  key,
const char *  user_name,
const char *  domain_name 
)

Definition at line 1841 of file switch_xml.c.

References CACHE_HASH, CACHE_MUTEX, switch_core_hash_delete(), switch_core_hash_find(), switch_hash_first(), switch_hash_this(), switch_mutex_lock(), switch_mutex_unlock(), switch_snprintf(), and switch_xml_free().

Referenced by switch_xml_destroy().

01842 {
01843         switch_hash_index_t *hi;
01844         void *val;
01845         const void *var;
01846         char mega_key[1024];
01847         int r = 0;
01848         switch_xml_t lookup;
01849 
01850         switch_mutex_lock(CACHE_MUTEX);
01851 
01852         if (key && user_name && domain_name) {
01853                 switch_snprintf(mega_key, sizeof(mega_key), "%s%s%s", key, user_name, domain_name);
01854 
01855                 if ((lookup = switch_core_hash_find(CACHE_HASH, mega_key))) {
01856                         switch_core_hash_delete(CACHE_HASH, mega_key);
01857                         switch_xml_free(lookup);
01858                         r++;
01859                 }
01860                 
01861         } else {
01862                 
01863                 while ((hi = switch_hash_first(NULL, CACHE_HASH))) {
01864                         switch_hash_this(hi, &var, NULL, &val);
01865                         switch_xml_free(val);
01866                         switch_core_hash_delete(CACHE_HASH, var);
01867                         r++;
01868                 }
01869         }
01870 
01871         switch_mutex_unlock(CACHE_MUTEX);
01872                 
01873         return r;
01874         
01875 }

switch_xml_t switch_xml_cut ( _In_ switch_xml_t  xml  ) 

removes a tag along with its subtags without freeing its memory

Parameters:
xml the xml node

switch_status_t switch_xml_destroy ( void   ) 

Definition at line 2198 of file switch_xml.c.

References CACHE_HASH, MAIN_XML_ROOT, REFLOCK, switch_core_hash_destroy(), switch_mutex_lock(), switch_mutex_unlock(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_xml_clear_user_cache(), switch_xml_free(), destroy_xml::xml, and XML_LOCK.

Referenced by switch_core_destroy().

02199 {
02200         switch_status_t status = SWITCH_STATUS_FALSE;
02201 
02202 
02203         switch_mutex_lock(XML_LOCK);
02204         switch_mutex_lock(REFLOCK);
02205 
02206         if (MAIN_XML_ROOT) {
02207                 switch_xml_t xml = MAIN_XML_ROOT;
02208                 MAIN_XML_ROOT = NULL;
02209                 switch_xml_free(xml);
02210                 status = SWITCH_STATUS_SUCCESS;
02211         }
02212 
02213         switch_mutex_unlock(XML_LOCK);
02214         switch_mutex_unlock(REFLOCK);
02215 
02216         switch_xml_clear_user_cache(NULL, NULL, NULL);
02217 
02218         switch_core_hash_destroy(&CACHE_HASH);
02219 
02220         return status;
02221 }

switch_xml_t switch_xml_dup ( switch_xml_t  xml  ) 

Definition at line 1790 of file switch_xml.c.

References SWITCH_FALSE, switch_xml_parse_str_dynamic(), and switch_xml_toxml().

Referenced by switch_xml_locate_user_cache(), switch_xml_locate_user_merged(), and switch_xml_user_cache().

01791 {
01792         char *x = switch_xml_toxml(xml, SWITCH_FALSE);
01793         return switch_xml_parse_str_dynamic(x, SWITCH_FALSE); 
01794 }

const char* switch_xml_error ( _In_ switch_xml_t  xml  ) 

returns parser error message or empty string if none

Parameters:
xml the xml node
Returns:
the error string or nothing

Referenced by __switch_xml_open_root(), and switch_xml_locate().

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'

Parameters:
node the xml node
childname the child tag name
attrname the attribute name
value the value
Returns:
an xml node or NULL

Referenced by switch_ivr_menu_stack_xml_build(), switch_ivr_phrase_macro_event(), switch_nat_republish(), switch_xml_locate(), switch_xml_locate_group(), and switch_xml_locate_language().

switch_xml_t switch_xml_find_child_multi ( _In_ switch_xml_t  node,
_In_z_ const char *  childname,
  ... 
)

Referenced by find_user_in_tag().

void switch_xml_free ( _In_opt_ switch_xml_t  xml  ) 

frees the memory allocated for an switch_xml structure

Parameters:
xml the xml node
Note:
in the case of the root node the readlock will be lifted

Referenced by __switch_xml_open_root(), console_xml_config(), destroy_thread(), CoreSession::getXMLCDR(), Event::serialize(), switch_core_session_reporting_state(), switch_ivr_check_presence_mapping(), switch_ivr_generate_xml_cdr(), switch_ivr_multi_threaded_bridge(), switch_ivr_phrase_macro_event(), switch_ivr_say(), switch_ivr_say_string(), switch_ivr_set_user(), switch_load_core_config(), switch_load_network_lists(), switch_load_timezones(), switch_loadable_module_init(), switch_nat_republish(), switch_xml_clear_user_cache(), switch_xml_config_parse_module_settings(), switch_xml_destroy(), switch_xml_free(), switch_xml_init(), switch_xml_locate(), switch_xml_locate_language(), switch_xml_locate_user(), switch_xml_locate_user_merged(), switch_xml_reload(), switch_xml_set_root(), and switch_xml_user_cache().

void switch_xml_free_in_thread ( _In_ switch_xml_t  xml,
_In_ int  stacksize 
)

switch_xml_t switch_xml_get ( _In_ switch_xml_t  xml,
  ... 
)

Traverses the switch_xml sturcture to retrieve a specific subtag. Takes a \ variable length list of tag names and indexes. The argument list must be \ terminated by either an index of -1 or an empty string tag name. Example: \ title = switch_xml_get(library, "shelf", 0, "book", 2, "title", -1); \ This retrieves the title of the 3rd book on the 1st shelf of library. \ Returns NULL if not found.

Parameters:
xml the xml node
Returns:
an xml node or NULL

switch_xml_section_t switch_xml_get_binding_sections ( _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. An index of 0 returns the tag given.

Parameters:
xml the xml node
idx the index
Returns:
an xml node or NULL

Referenced by switch_xml_vget().

switch_status_t switch_xml_init ( _In_ switch_memory_pool_t pool,
_Out_ const char **  err 
)

initilize the core XML backend

Parameters:
pool a memory pool to use
err a pointer to set error strings
Returns:
SWITCH_STATUS_SUCCESS if successful

Referenced by switch_core_init().

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

Referenced by switch_xml_add_child().

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

Parameters:
section the section to look in
tag_name the type of tag in that section
key_name the name of the key
key_value the value of the key
root a pointer to point at the root node
node a pointer to the requested node
params optional URL formatted params to pass to external gateways
Returns:
SWITCH_STATUS_SUCCESS if successful root and node will be assigned

Referenced by switch_xml_locate_domain(), switch_xml_locate_language(), and switch_xml_open_cfg().

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 
)

Referenced by switch_load_network_lists(), switch_xml_locate_group(), and switch_xml_locate_user().

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_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 
)

Definition at line 2975 of file switch_xml.c.

References SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, switch_log_printf(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, SWITCH_TRUE, switch_xml_child(), switch_xml_find_child(), switch_xml_free(), and switch_xml_locate().

Referenced by switch_ivr_phrase_macro_event(), switch_ivr_say(), and switch_ivr_say_string().

02975                                                                                                                                                                                                                           {
02976         switch_status_t status = SWITCH_STATUS_FALSE;
02977 
02978         if (switch_xml_locate("languages", NULL, NULL, NULL, root, node, params, SWITCH_TRUE) != SWITCH_STATUS_SUCCESS) {
02979                 switch_xml_t sub_macros;
02980 
02981                 if (switch_xml_locate("phrases", NULL, NULL, NULL, root, node, params, SWITCH_TRUE) != SWITCH_STATUS_SUCCESS) {
02982                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of languages and phrases failed.\n");
02983                         goto done;
02984                 }
02985                 if (!(sub_macros = switch_xml_child(*node, "macros"))) {
02986                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find macros tag.\n");
02987                         switch_xml_free(*root);
02988                         *root = NULL;
02989                         *node = NULL;
02990                         goto done;
02991                 }
02992                 if (!(*language = switch_xml_find_child(sub_macros, "language", "name", str_language))) {
02993                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find language %s.\n", str_language);
02994                         switch_xml_free(*root);
02995                         *root = NULL;
02996                         *node = NULL;
02997                         goto done;
02998                 }
02999                 *macros = *language;
03000         } else {
03001                 if (!(*language = switch_xml_find_child(*node, "language", "name", str_language))) {
03002                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find language %s.\n", str_language);
03003                         switch_xml_free(*root);
03004                         *root = NULL;
03005                         goto done;
03006                 }
03007                 if (!(*phrases = switch_xml_child(*language, "phrases"))) {
03008                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find phrases tag.\n");
03009                         switch_xml_free(*root);
03010                         *root = NULL;
03011                         *node = NULL;
03012                         *language = NULL;
03013                         goto done;
03014                 }
03015 
03016                 if (!(*macros = switch_xml_child(*phrases, "macros"))) {
03017                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find macros tag.\n");
03018                         switch_xml_free(*root);
03019                         *root = NULL;
03020                         *node = NULL;
03021                         *language = NULL;
03022                         *phrases = NULL;
03023                         goto done;
03024                 }
03025         }
03026         status = SWITCH_STATUS_SUCCESS;
03027 
03028 done:
03029         return status;
03030 }

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 
)

Referenced by switch_ivr_set_user(), and switch_xml_locate_user_merged().

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_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 
)

Definition at line 1911 of file switch_xml.c.

References SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_true(), switch_xml_attr(), switch_xml_dup(), switch_xml_free(), switch_xml_locate_user(), switch_xml_locate_user_cache(), switch_xml_merge_user(), and switch_xml_user_cache().

01913 {
01914         switch_xml_t xml, domain, group, x_user, x_user_dup;
01915         switch_status_t status = SWITCH_STATUS_FALSE;
01916 
01917         if ((status = switch_xml_locate_user_cache(key, user_name, domain_name, &x_user)) == SWITCH_STATUS_SUCCESS) {
01918                 *user = x_user;
01919         } else if ((status = switch_xml_locate_user(key, user_name, domain_name, ip, &xml, &domain, &x_user, &group, params)) == SWITCH_STATUS_SUCCESS) {
01920                 x_user_dup = switch_xml_dup(x_user);
01921                 switch_xml_merge_user(x_user_dup, domain, group);
01922                 if (switch_true(switch_xml_attr(x_user_dup, "cacheable"))) {
01923                         switch_xml_user_cache(key, user_name, domain_name, x_user_dup);
01924                 }
01925                 *user = x_user_dup;
01926                 switch_xml_free(xml);
01927         }
01928 
01929         return status;
01930 
01931 }

void switch_xml_merge_user ( switch_xml_t  user,
switch_xml_t  domain,
switch_xml_t  group 
)

Definition at line 1832 of file switch_xml.c.

References do_merge().

Referenced by switch_xml_locate_user_merged().

01833 {
01834 
01835         do_merge(user, group, "params", "param");
01836         do_merge(user, group, "variables", "variable");
01837         do_merge(user, domain, "params", "param");
01838         do_merge(user, domain, "variables", "variable");
01839 }

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

Parameters:
name the name of the new root tag

Referenced by switch_event_xmlize(), switch_ivr_generate_xml_cdr(), and switch_xml_parse_str().

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

Parameters:
file_path the name of the config section e.g. modules.conf
node a pointer to point to the node if it is found
params optional URL formatted params to pass to external gateways
Returns:
the root xml node associated with the current request or NULL

Referenced by console_xml_config(), switch_ivr_check_presence_mapping(), switch_load_core_config(), switch_load_network_lists(), switch_load_timezones(), switch_loadable_module_init(), and switch_xml_config_parse_module_settings().

switch_xml_t switch_xml_open_root ( _In_ uint8_t  reload,
_Out_ const char **  err 
)

open the Core xml root

Parameters:
reload if it's is already open close it and open it again as soon as permissable (blocking)
err a pointer to set error strings
Returns:
the xml root node or NULL

Referenced by switch_xml_init(), and switch_xml_reload().

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 file. Failing that, reads the file into memory. \ Returns NULL on failure.

Parameters:
fd 
Returns:
a formated xml node or NULL

Definition at line 1156 of file switch_xml.c.

References switch_xml_root::dynamic, switch_xml_parse_str(), and switch_xml_root::xml.

Referenced by switch_xml_parse_file().

01157 {
01158         switch_xml_root_t root;
01159         struct stat st;
01160         switch_size_t l;
01161         void *m;
01162 
01163         if (fd < 0)
01164                 return NULL;
01165         fstat(fd, &st);
01166 
01167         if (!st.st_size) {
01168                 return NULL;
01169         }
01170 
01171         m = malloc(st.st_size);
01172         if (!m)
01173                 return NULL;
01174         l = read(fd, m, st.st_size);
01175         if (!l || !(root = (switch_xml_root_t) switch_xml_parse_str((char *) m, l))) {
01176                 free(m);
01177                 return NULL;
01178         }
01179         root->dynamic = 1;              /* so we know to free s in switch_xml_free() */
01180 
01181         return &root->xml;
01182 }

switch_xml_t switch_xml_parse_file ( _In_z_ const char *  file  ) 

a wrapper for switch_xml_parse_fd() that accepts a file name

Parameters:
file a file to parse
Returns:
a formated xml node or NULL

Referenced by __switch_xml_open_root().

switch_xml_t switch_xml_parse_file_simple ( _In_z_ const char *  file  ) 

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 and then parses it. For xml files, use switch_xml_parse_file() \ or switch_xml_parse_fd().

Parameters:
fp a FILE pointer to parse
Returns:
an xml node or NULL

switch_xml_section_t switch_xml_parse_section_string ( _In_opt_z_ const char *  str  ) 

parse a string for a list of sections

Parameters:
str a | delimited list of section names
Returns:
the section mask

Referenced by switch_xml_locate().

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.

Parameters:
s a string
len the length of the string
Returns:
a formated xml node or NULL

Referenced by switch_xml_parse_fd(), switch_xml_parse_file_simple(), switch_xml_parse_fp(), and switch_xml_parse_str_dynamic().

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.

Parameters:
s The string to parse
dup true if you want the string to be strdup()'d automatically
Returns:
the switch_xml_t or NULL if an error occured

Referenced by switch_xml_dup().

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

Parameters:
xml the xml node
target the instructions
Returns:
the array

switch_status_t switch_xml_reload ( const char **  err  ) 

Definition at line 2161 of file switch_xml.c.

References SWITCH_STATUS_GENERR, SWITCH_STATUS_SUCCESS, switch_xml_free(), and switch_xml_open_root().

02162 {
02163         switch_xml_t xml_root;
02164         
02165         if ((xml_root = switch_xml_open_root(1, err))) {
02166                 switch_xml_free(xml_root);
02167                 return SWITCH_STATUS_SUCCESS;
02168         }
02169 
02170         return SWITCH_STATUS_GENERR;
02171 }

switch_xml_t switch_xml_root ( void   ) 

retrieve the core XML root node

Returns:
the xml root node
Note:
this will cause a readlock on the root until it's released with
See also:
switch_xml_free

Definition at line 2010 of file switch_xml.c.

References MAIN_XML_ROOT, REFLOCK, switch_xml::refs, switch_mutex_lock(), and switch_mutex_unlock().

Referenced by __switch_xml_open_root().

02011 {
02012         switch_xml_t xml;
02013 
02014         switch_mutex_lock(REFLOCK);
02015         xml = MAIN_XML_ROOT;
02016         xml->refs++;
02017         switch_mutex_unlock(REFLOCK);
02018         
02019         return xml;
02020 }

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 specified attribute.

Parameters:
xml the xml node
name the attribute name
value the attribute value
Returns:
the tag given

Definition at line 2737 of file switch_xml.c.

References switch_xml::attr, SWITCH_XML_DUP, SWITCH_XML_NAMEM, SWITCH_XML_NIL, and SWITCH_XML_TXTM.

02738 {
02739         int l = 0, c;
02740 
02741         if (!xml)
02742                 return NULL;
02743         while (xml->attr[l] && strcmp(xml->attr[l], name))
02744                 l += 2;
02745         if (!xml->attr[l]) {            /* not found, add as new attribute */
02746                 if (!value)
02747                         return xml;                     /* nothing to do */
02748                 if (xml->attr == SWITCH_XML_NIL) {      /* first attribute */
02749                         xml->attr = (char **) malloc(4 * sizeof(char *));
02750                         if (!xml->attr)
02751                                 return NULL;
02752                         xml->attr[1] = strdup("");      /* empty list of malloced names/vals */
02753                 } else {
02754                         char **tmp = (char **) realloc(xml->attr, (l + 4) * sizeof(char *));
02755                         if (!tmp)
02756                                 return xml;
02757                         xml->attr = tmp;
02758                 }
02759 
02760                 xml->attr[l] = (char *) name;   /* set attribute name */
02761                 xml->attr[l + 2] = NULL;        /* null terminate attribute list */
02762                 xml->attr[l + 3] = (char *) realloc(xml->attr[l + 1], (c = (int) strlen(xml->attr[l + 1])) + 2);
02763                 strcpy(xml->attr[l + 3] + c, " ");      /* set name/value as not malloced */
02764                 if (xml->flags & SWITCH_XML_DUP)
02765                         xml->attr[l + 3][c] = SWITCH_XML_NAMEM;
02766         } else if (xml->flags & SWITCH_XML_DUP)
02767                 free((char *) name);    /* name was strduped */
02768 
02769         for (c = l; xml->attr[c]; c += 2);      /* find end of attribute list */
02770         if (xml->attr[c + 1][l / 2] & SWITCH_XML_TXTM)
02771                 free(xml->attr[l + 1]); /* old val */
02772         if (xml->flags & SWITCH_XML_DUP)
02773                 xml->attr[c + 1][l / 2] |= SWITCH_XML_TXTM;
02774         else
02775                 xml->attr[c + 1][l / 2] &= ~SWITCH_XML_TXTM;
02776 
02777         if (value)
02778                 xml->attr[l + 1] = (char *) value;      /* set attribute value */
02779         else {                                          /* remove attribute */
02780                 char **tmp;
02781                 if (xml->attr[c + 1][l / 2] & SWITCH_XML_NAMEM)
02782                         free(xml->attr[l]);
02783                 memmove(xml->attr + l, xml->attr + l + 2, (c - l + 2) * sizeof(char *));
02784                 tmp = (char **) realloc(xml->attr, (c + 2) * sizeof(char *));
02785                 if (!tmp)
02786                         return xml;
02787                 xml->attr = tmp;
02788                 memmove(xml->attr[c + 1] + (l / 2), xml->attr[c + 1] + (l / 2) + 1, (c / 2) - (l / 2)); /* fix list of which name/vals are malloced */
02789         }
02790         xml->flags &= ~SWITCH_XML_DUP;  /* clear strdup() flag */
02791 
02792         return xml;
02793 }

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

Parameters:
function the search function to bind
sections a bitmask of sections you wil service
user_data a pointer to private data to be used during the callback
Returns:
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

void switch_xml_set_binding_user_data ( _In_ switch_xml_binding_t binding,
_In_opt_ void *  user_data 
)

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

Parameters:
xml the xml node
flag the flag to set
Returns:
an xml node or NULL

Definition at line 2796 of file switch_xml.c.

References switch_xml::flags.

Referenced by switch_xml_char_content().

02797 {
02798         if (xml)
02799                 xml->flags |= flag;
02800         return xml;
02801 }

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.

Definition at line 2085 of file switch_xml.c.

References switch_mutex_lock(), switch_mutex_unlock(), SWITCH_STATUS_SUCCESS, XML_LOCK, XML_OPEN_ROOT_FUNCTION, and XML_OPEN_ROOT_FUNCTION_USER_DATA.

02086 {
02087         if (XML_LOCK) {
02088                 switch_mutex_lock(XML_LOCK);
02089         }
02090         
02091         XML_OPEN_ROOT_FUNCTION = func;
02092         XML_OPEN_ROOT_FUNCTION_USER_DATA = user_data;
02093 
02094         if (XML_LOCK) {
02095                 switch_mutex_unlock(XML_LOCK);
02096         }
02097         return SWITCH_STATUS_SUCCESS;
02098 }

switch_status_t switch_xml_set_root ( switch_xml_t  new_main  ) 

set new core xml root

Definition at line 2059 of file switch_xml.c.

References MAIN_XML_ROOT, REFLOCK, switch_xml::refs, switch_mutex_lock(), switch_mutex_unlock(), switch_set_flag, SWITCH_STATUS_SUCCESS, switch_xml_free(), and SWITCH_XML_ROOT.

Referenced by __switch_xml_open_root().

02060 {
02061         switch_xml_t old_root = NULL;
02062         
02063         switch_mutex_lock(REFLOCK);
02064 
02065         old_root = MAIN_XML_ROOT;
02066         MAIN_XML_ROOT = new_main;
02067         switch_set_flag(MAIN_XML_ROOT, SWITCH_XML_ROOT);
02068         MAIN_XML_ROOT->refs++;
02069                         
02070         if (old_root) {
02071                 if (old_root->refs) {
02072                         old_root->refs--;
02073                 }
02074 
02075                 if (!old_root->refs) {
02076                         switch_xml_free(old_root);
02077                 }
02078         }
02079 
02080         switch_mutex_unlock(REFLOCK);
02081 
02082         return SWITCH_STATUS_SUCCESS;
02083 }

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

Parameters:
xml the xml node
txt the text
Returns:
an xml node or NULL

Definition at line 2724 of file switch_xml.c.

References SWITCH_XML_TXTM.

02725 {
02726         if (!xml)
02727                 return NULL;
02728         if (xml->flags & SWITCH_XML_TXTM)
02729                 free(xml->txt);                 /* existing txt was malloced */
02730         xml->flags &= ~SWITCH_XML_TXTM;
02731         xml->txt = (char *) txt;
02732         return xml;
02733 }

int switch_xml_std_datetime_check ( switch_xml_t  xcond,
int *  offset 
)

Definition at line 2842 of file switch_xml.c.

References SWITCH_CHANNEL_LOG, switch_dow_cmp(), switch_dow_int2str(), switch_fulldate_cmp(), switch_is_number(), SWITCH_LOG_DEBUG, SWITCH_LOG_DEBUG9, switch_log_printf(), switch_micro_time_now(), switch_number_cmp(), switch_snprintf(), switch_strftime(), switch_time_exp_lt(), switch_time_exp_tz(), switch_tod_cmp(), switch_xml_attr(), switch_time_exp_t::tm_hour, switch_time_exp_t::tm_mday, switch_time_exp_t::tm_min, switch_time_exp_t::tm_mon, switch_time_exp_t::tm_sec, switch_time_exp_t::tm_wday, switch_time_exp_t::tm_yday, switch_time_exp_t::tm_year, and zstr.

02843 {
02844 
02845         const char *xdt = switch_xml_attr(xcond, "date-time");
02846         const char *xyear = switch_xml_attr(xcond, "year");
02847         const char *xyday = switch_xml_attr(xcond, "yday");
02848         const char *xmon = switch_xml_attr(xcond, "mon");
02849         const char *xmday = switch_xml_attr(xcond, "mday");
02850         const char *xweek = switch_xml_attr(xcond, "week");
02851         const char *xmweek = switch_xml_attr(xcond, "mweek");
02852         const char *xwday = switch_xml_attr(xcond, "wday");
02853         const char *xhour = switch_xml_attr(xcond, "hour");
02854         const char *xminute = switch_xml_attr(xcond, "minute");
02855         const char *xminday = switch_xml_attr(xcond, "minute-of-day");
02856         const char *xtod = switch_xml_attr(xcond, "time-of-day");
02857         const char *tzoff = switch_xml_attr(xcond, "tz-offset");
02858         int loffset = 0;
02859 
02860         switch_time_t ts = switch_micro_time_now();
02861         int time_match = -1;
02862         switch_time_exp_t tm;
02863 
02864         if (!zstr(tzoff) && switch_is_number(tzoff)) {
02865                 loffset = atoi(tzoff);
02866                 offset = &loffset;
02867         }
02868 
02869 
02870         if (offset) {
02871                 switch_time_exp_tz(&tm, ts, *offset);
02872         } else {
02873                 switch_time_exp_lt(&tm, ts);
02874         }
02875 
02876         if (time_match && xdt) {
02877                 char tmpdate[80];
02878                 switch_size_t retsize;
02879                 switch_strftime(tmpdate, &retsize, sizeof(tmpdate), "%Y-%m-%d %H:%M:%S", &tm);
02880                 time_match = switch_fulldate_cmp(xdt, &ts);
02881                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
02882                                 "XML DateTime Check: date time[%s] =~ %s (%s)\n", tmpdate, xdt, time_match ? "PASS" : "FAIL");
02883         }
02884 
02885         if (time_match && xyear) {
02886                 int test = tm.tm_year + 1900;
02887                 time_match = switch_number_cmp(xyear, test);
02888                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9,
02889                                 "XML DateTime Check: year[%d] =~ %s (%s)\n", test, xyear, time_match ? "PASS" : "FAIL");
02890         }
02891 
02892         if (time_match && xyday) {
02893                 int test = tm.tm_yday + 1;
02894                 time_match = switch_number_cmp(xyday, test);
02895                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9,
02896                                 "XML DateTime Check: day of year[%d] =~ %s (%s)\n", test, xyday, time_match ? "PASS" : "FAIL");
02897         }
02898 
02899         if (time_match && xmon) {
02900                 int test = tm.tm_mon + 1;
02901                 time_match = switch_number_cmp(xmon, test);
02902                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9,
02903                                 "XML DateTime Check: month[%d] =~ %s (%s)\n", test, xmon, time_match ? "PASS" : "FAIL");
02904         }
02905 
02906         if (time_match && xmday) {
02907                 int test = tm.tm_mday;
02908                 time_match = switch_number_cmp(xmday, test);
02909                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9,
02910                                 "XML DateTime Check: day of month[%d] =~ %s (%s)\n", test, xmday, time_match ? "PASS" : "FAIL");
02911         }
02912 
02913         if (time_match && xweek) {
02914                 int test = (int) (tm.tm_yday / 7 + 1);
02915                 time_match = switch_number_cmp(xweek, test);
02916                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9,
02917                                 "XML DateTime Check: week of year[%d] =~ %s (%s)\n", test, xweek, time_match ? "PASS" : "FAIL");
02918         }
02919         if (time_match && xweek) {
02920                 int test = (int) (tm.tm_yday / 7 + 1);
02921                 time_match = switch_number_cmp(xweek, test);
02922                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9,
02923                                 "XML DateTime Check: week of year[%d] =~ %s (%s)\n", test, xweek, time_match ? "PASS" : "FAIL");
02924         }
02925 
02926         if (time_match && xmweek) {
02927                 /* calculate the day of the week of the first of the month (0-6) */
02928                 int firstdow = (int) (7 - (tm.tm_mday - (tm.tm_wday + 1)) % 7) % 7;
02929                 /* calculate the week of the month (1-6)*/
02930                 int test = (int) ceil((tm.tm_mday + firstdow) / 7.0);
02931                 time_match = switch_number_cmp(xmweek, test);
02932                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9,
02933                                 "XML DateTime: week of month[%d] =~ %s (%s)\n", test, xmweek, time_match ? "PASS" : "FAIL");
02934         }
02935 
02936         if (time_match && xwday) {
02937                 int test = tm.tm_wday + 1;
02938                 time_match = switch_dow_cmp(xwday, test);
02939                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9,
02940                                 "XML DateTime Check: day of week[%s] =~ %s (%s)\n", switch_dow_int2str(test), xwday, time_match ? "PASS" : "FAIL");
02941         }
02942         if (time_match && xhour) {
02943                 int test = tm.tm_hour;
02944                 time_match = switch_number_cmp(xhour, test);
02945                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9,
02946                                 "XML DateTime Check: hour[%d] =~ %s (%s)\n", test, xhour, time_match ? "PASS" : "FAIL");
02947         }
02948 
02949         if (time_match && xminute) {
02950                 int test = tm.tm_min;
02951                 time_match = switch_number_cmp(xminute, test);
02952                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9,
02953                                 "XML DateTime Check: minute[%d] =~ %s (%s)\n", test, xminute, time_match ? "PASS" : "FAIL");
02954         }
02955 
02956         if (time_match && xminday) {
02957                 int test = (tm.tm_hour * 60) + (tm.tm_min + 1);
02958                 time_match = switch_number_cmp(xminday, test);
02959                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9,
02960                                 "XML DateTime Check: minute of day[%d] =~ %s (%s)\n", test, xminday, time_match ? "PASS" : "FAIL");
02961         }
02962 
02963         if (time_match && xtod) {
02964                 int test = (tm.tm_hour * 60 * 60) + (tm.tm_min * 60) + tm.tm_sec;
02965                 char tmpdate[10];
02966                 switch_snprintf(tmpdate, 10, "%d:%d:%d", tm.tm_hour, tm.tm_min, tm.tm_sec);
02967                 time_match = switch_tod_cmp(xtod, test);
02968                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG9,
02969                                 "XML DateTime Check: time of day[%s] =~ %s (%s)\n", tmpdate, xtod, time_match ? "PASS" : "FAIL");
02970         }
02971 
02972         return time_match;
02973 }

char* switch_xml_toxml ( _In_ switch_xml_t  xml,
_In_ switch_bool_t  prn_header 
)

Converts an switch_xml structure back to xml. Returns a string of xml data that \ must be freed.

Parameters:
xml the xml node
prn_header add <?xml version..> header too
Returns:
the xml text string

Referenced by CoreSession::getXMLCDR(), Event::serialize(), switch_core_session_reporting_state(), switch_ivr_multi_threaded_bridge(), and switch_xml_dup().

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.

Parameters:
xml the xml node
buf buffer to use
buflen size of buffer
offset offset to start at
prn_header add <?xml version..> header too
Returns:
the xml text string

Referenced by switch_xml_toxml(), and switch_xml_toxml_nolock().

char* switch_xml_toxml_nolock ( switch_xml_t  xml,
_In_ switch_bool_t  prn_header 
)

switch_status_t switch_xml_unbind_search_function ( _In_ switch_xml_binding_t **  binding  ) 

switch_status_t switch_xml_unbind_search_function_ptr ( _In_ switch_xml_search_function_t  function  ) 


Generated on Wed May 16 04:00:20 2012 for FreeSWITCH API Documentation by  doxygen 1.4.7