RTS API Documentation  1.10.11
switch_xml.h
Go to the documentation of this file.
1 /*
2  * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
3  * Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
4  *
5  * Version: MPL 1.1
6  *
7  * The contents of this file are subject to the Mozilla Public License Version
8  * 1.1 (the "License"); you may not use this file except in compliance with
9  * the License. You may obtain a copy of the License at
10  * http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
18  *
19  * The Initial Developer of the Original Code is
20  * Anthony Minessale II <anthm@freeswitch.org>
21  * Portions created by the Initial Developer are Copyright (C)
22  * the Initial Developer. All Rights Reserved.
23  *
24  * Contributor(s):
25  *
26  * Anthony Minessale II <anthm@freeswitch.org>
27  *
28  *
29  * switch_xml.h -- XML PARSER
30  *
31  * Derived from EZXML http://ezxml.sourceforge.net
32  * Original Copyright
33  *
34  * Copyright 2004, 2005 Aaron Voisine <aaron@voisine.org>
35  *
36  * Permission is hereby granted, free of charge, to any person obtaining
37  * a copy of this software and associated documentation files (the
38  * "Software"), to deal in the Software without restriction, including
39  * without limitation the rights to use, copy, modify, merge, publish,
40  * distribute, sublicense, and/or sell copies of the Software, and to
41  * permit persons to whom the Software is furnished to do so, subject to
42  * the following conditions:
43  *
44  * The above copyright notice and this permission notice shall be included
45  * in all copies or substantial portions of the Software.
46  *
47  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
48  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
49  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
50  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
51  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
52  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
53  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
54  */
55 
56 #ifndef FREESWITCH_XML_H
57 #define FREESWITCH_XML_H
58 #include <switch.h>
59 
60 /* Use UTF-8 as the general encoding */
61 #define USE_UTF_8_ENCODING SWITCH_TRUE
62 
63 struct switch_xml_binding;
64 
65 ///\defgroup xml1 XML Library Functions
66 ///\ingroup core1
67 ///\{
69 #define SWITCH_XML_BUFSIZE 1024 // size of internal memory buffers
70  typedef enum {
71  SWITCH_XML_ROOT = (1 << 0), // root
72  SWITCH_XML_NAMEM = (1 << 1), // name is malloced
73  SWITCH_XML_TXTM = (1 << 2), // txt is malloced
74  SWITCH_XML_DUP = (1 << 3), // attribute name and value are strduped
75  SWITCH_XML_CDATA = (1 << 4) // body is in CDATA
77 
78 /*! \brief A representation of an XML tree */
79 struct switch_xml {
80  /*! tag name */
81  char *name;
82  /*! tag attributes { name, value, name, value, ... NULL } */
83  char **attr;
84  /*! tag character content, empty string if none */
85  char *txt;
86  /*! path to free on destroy */
87  char *free_path;
88  /*! tag offset from start of parent tag character content */
90  /*! next tag with same name in this section at this depth */
92  /*! next tag with different name in same section and depth */
94  /*! next tag, same section and depth, in original order */
96  /*! head of sub tag list, NULL if none */
98  /*! parent tag, NULL if current tag is root tag */
100  /*! flags */
101  uint32_t flags;
102  /*! is_switch_xml_root bool */
104  uint32_t refs;
105  /*! pointer to end of opening tag, '>', in the original parsed text */
106  const char *open;
107  /*! pointer to start of closing tag, '<', in the original parsed text */
108  const char *close;
109 };
110 
111 /*!
112  * \brief Parses a string into a switch_xml_t, ensuring the memory will be freed with switch_xml_free
113  * \param s The string to parse
114  * \param dup true if you want the string to be strdup()'d automatically
115  * \return the switch_xml_t or NULL if an error occured
116  */
118 
119 /*!
120  * \brief Parses a string into a switch_xml_t
121  * \param s The string to parse
122  * \return the switch_xml_t or NULL if an error occured
123  */
124 #define switch_xml_parse_str_dup(x) switch_xml_parse_str_dynamic(x, SWITCH_TRUE)
125 
126 ///\brief Given a string of xml data and its length, parses it and creates an switch_xml
127 ///\ structure. For efficiency, modifies the data by adding null terminators
128 ///\ and decoding ampersand sequences. If you don't want this, copy the data and
129 ///\ pass in the copy. Returns NULL on failure.
130 ///\param s a string
131 ///\param len the length of the string
132 ///\return a formated xml node or NULL
134 
135 ///\brief A wrapper for switch_xml_parse_str() that accepts a file descriptor. First
136 ///\ attempts to mem map the file. Failing that, reads the file into memory.
137 ///\ Returns NULL on failure.
138 ///\param fd
139 ///\return a formated xml node or NULL
141 
142 ///\brief a wrapper for switch_xml_parse_fd() that accepts a file name
143 ///\param file a file to parse
144 ///\return a formated xml node or NULL
146 
148 
149 ///\brief Wrapper for switch_xml_parse_str() that accepts a file stream. Reads the entire
150 ///\ stream into memory and then parses it. For xml files, use switch_xml_parse_file()
151 ///\ or switch_xml_parse_fd()
152 ///\param fp a FILE pointer to parse
153 ///\return an xml node or NULL
155 
156 ///\brief returns the first child tag (one level deeper) with the given name or NULL
157 ///\ if not found
158 ///\param xml an xml node
159 ///\param name the name of the child tag
160 ///\return an xml node or NULL
162 
163 ///\brief find a child tag in a node called 'childname' with an attribute 'attrname' which equals 'value'
164 ///\param node the xml node
165 ///\param childname the child tag name
166 ///\param attrname the attribute name
167 ///\param value the value
168 ///\return an xml node or NULL
169 SWITCH_DECLARE(switch_xml_t) switch_xml_find_child(_In_ switch_xml_t node, _In_z_ const char *childname, _In_opt_z_ const char *attrname,
170  _In_opt_z_ const char *value);
172 
173 ///\brief returns the next tag of the same name in the same section and depth or NULL
174 ///\ if not found
175 ///\param xml an xml node
176 ///\return an xml node or NULL
177 #define switch_xml_next(xml) ((xml) ? xml->next : NULL)
178 
179 ///\brief Returns the Nth tag with the same name in the same section at the same depth
180 ///\ or NULL if not found. An index of 0 returns the tag given.
181 ///\param xml the xml node
182 ///\param idx the index
183 ///\return an xml node or NULL
185 
186 ///\brief returns the name of the given tag
187 ///\param xml the xml node
188 ///\return the name
189 #define switch_xml_name(xml) ((xml) ? xml->name : NULL)
190 
191 ///\brief returns the given tag's character content or empty string if none
192 ///\param xml the xml node
193 ///\return the content
194 #define switch_xml_txt(xml) ((xml) ? xml->txt : "")
195 
196 ///\brief returns the value of the requested tag attribute, or NULL if not found
197 ///\param xml the xml node
198 ///\param attr the attribute
199 ///\return the value
200 SWITCH_DECLARE(const char *) switch_xml_attr(_In_opt_ switch_xml_t xml, _In_opt_z_ const char *attr);
201 
202 ///\brief returns the value of the requested tag attribute, or "" if not found
203 ///\param xml the xml node
204 ///\param attr the attribute
205 ///\return the value
206 SWITCH_DECLARE(const char *) switch_xml_attr_soft(_In_ switch_xml_t xml, _In_z_ const char *attr);
207 
208 ///\brief Traverses the switch_xml structure to retrieve a specific subtag. Takes a
209 ///\ variable length list of tag names and indexes. The argument list must be
210 ///\ terminated by either an index of -1 or an empty string tag name. Example:
211 ///\ title = switch_xml_get(library, "shelf", 0, "book", 2, "title", -1);
212 ///\ This retrieves the title of the 3rd book on the 1st shelf of library.
213 ///\ Returns NULL if not found.
214 ///\param xml the xml node
215 ///\return an xml node or NULL
217 
218 ///\brief Converts an switch_xml structure back to xml in html format. Returns a string of html data that
219 ///\ must be freed.
220 ///\param xml the xml node
221 ///\param prn_header add <?xml version..> header too
222 ///\param use_utf8_encoding encoding into ampersand entities for UTF-8 chars
223 ///\return the ampersanded html text string to display xml
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)
227 
228 SWITCH_DECLARE(char *) switch_xml_toxml_ex(_In_ switch_xml_t xml, _In_ switch_bool_t prn_header, switch_bool_t use_utf8_encoding);
229 SWITCH_DECLARE(char *) switch_xml_toxml_nolock_ex(switch_xml_t xml, _In_ switch_bool_t prn_header, switch_bool_t use_utf8_encoding);
230 SWITCH_DECLARE(char *) switch_xml_tohtml_ex(_In_ switch_xml_t xml, _In_ switch_bool_t prn_header, switch_bool_t use_utf8_encoding);
231 
232 ///\brief Converts an switch_xml structure back to xml using the buffer passed in the parameters.
233 ///\param xml the xml node
234 ///\param buf buffer to use
235 ///\param buflen size of buffer
236 ///\param offset offset to start at
237 ///\param prn_header add <?xml version..> header too
238 ///\param use_utf8_encoding encoding into ampersand entities for UTF-8 chars
239 ///\return the xml text string
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);
242  _In_ switch_bool_t prn_header, switch_bool_t use_utf8_encoding);
243 
244 
245 ///\brief returns a NULL terminated array of processing instructions for the given
246 ///\ target
247 ///\param xml the xml node
248 ///\param target the instructions
249 ///\return the array
250 SWITCH_DECLARE(const char **) switch_xml_pi(_In_ switch_xml_t xml, _In_z_ const char *target);
251 
252 ///\brief frees the memory allocated for an switch_xml structure
253 ///\param xml the xml node
254 ///\note in the case of the root node the readlock will be lifted
257 
258 ///\brief returns parser error message or empty string if none
259 ///\param xml the xml node
260 ///\return the error string or nothing
262 
263 ///\brief returns a new empty switch_xml structure with the given root tag name
264 ///\param name the name of the new root tag
266 
267 ///\brief wrapper for switch_xml_new() that strdup()s name
268 ///\param name the name of the root
269 ///\return an xml node or NULL
270 #define switch_xml_new_d(name) switch_xml_set_flag(switch_xml_new(strdup(name)), SWITCH_XML_NAMEM)
271 
272 ///\brief Adds a child tag. off is the offset of the child tag relative to the start
273 ///\ of the parent tag's character content. Returns the child tag.
274 ///\param xml the xml node
275 ///\param name the name of the tag
276 ///\param off the offset
277 ///\return an xml node or NULL
279 
280 ///\brief wrapper for switch_xml_add_child() that strdup()s name
281 ///\param xml the xml node
282 ///\param name the name of the child
283 ///\param off the offset
285 
286 ///\brief sets the character content for the given tag and returns the tag
287 ///\param xml the xml node
288 ///\param txt the text
289 ///\return an xml node or NULL
291 
292 ///\brief wrapper for switch_xml_set_txt() that strdup()s txt
293 ///\ sets the character content for the given tag and returns the tag
294 ///\param xml the xml node
295 ///\param txt the text
296 ///\return an xml node or NULL
298 
299 ///\brief Sets the given tag attribute or adds a new attribute if not found. A value
300 ///\ of NULL will remove the specified attribute.
301 ///\param xml the xml node
302 ///\param name the attribute name
303 ///\param value the attribute value
304 ///\return the tag given
305 SWITCH_DECLARE(switch_xml_t) switch_xml_set_attr(switch_xml_t xml, const char *name, const char *value);
306 
307 ///\brief Wrapper for switch_xml_set_attr() that strdup()s name/value. Value cannot be NULL
308 ///\param xml the xml node
309 ///\param name the attribute name
310 ///\param value the attribute value
311 ///\return an xml node or NULL
313 
314 ///\brief Wrapper for switch_xml_set_attr() that strdup()s name/value. Value cannot be NULL
315 ///\param xml the xml node
316 ///\param name the attribute name
317 ///\param value the attribute value
318 ///\return an xml node or NULL
320 
321 ///\brief sets a flag for the given tag and returns the tag
322 ///\param xml the xml node
323 ///\param flag the flag to set
324 ///\return an xml node or NULL
326 
327 ///\brief removes a tag along with its subtags without freeing its memory
328 ///\param xml the xml node
330 
331 ///\brief inserts an existing tag into an ezxml structure
333 
334 ///\brief Moves an existing tag to become a subtag of dest at the given offset from
335 ///\ the start of dest's character content. Returns the moved tag.
336 #define switch_xml_move(xml, dest, off) switch_xml_insert(switch_xml_cut(xml), dest, off)
337 
338 ///\brief removes a tag along with all its subtags
339 #define switch_xml_remove(xml) switch_xml_free(switch_xml_cut(xml))
340 
341 ///\brief set new core xml root
343 
344 ///\brief Set and alternate function for opening xml root
346 
347 ///\brief open the Core xml root
348 ///\param reload if it's is already open close it and open it again as soon as permissable (blocking)
349 ///\param err a pointer to set error strings
350 ///\return the xml root node or NULL
351 SWITCH_DECLARE(switch_xml_t) switch_xml_open_root(_In_ uint8_t reload, _Out_ const char **err);
352 
353 ///\brief initilize the core XML backend
354 ///\param pool a memory pool to use
355 ///\param err a pointer to set error strings
356 ///\return SWITCH_STATUS_SUCCESS if successful
358 
360 
362 
363 ///\brief retrieve the core XML root node
364 ///\return the xml root node
365 ///\note this will cause a readlock on the root until it's released with \see switch_xml_free
367 
368 ///\brief locate an xml pointer in the core registry
369 ///\param section the section to look in
370 ///\param tag_name the type of tag in that section
371 ///\param key_name the name of the key
372 ///\param key_value the value of the key
373 ///\param root a pointer to point at the root node
374 ///\param node a pointer to the requested node
375 ///\param params optional URL formatted params to pass to external gateways
376 ///\return SWITCH_STATUS_SUCCESS if successful root and node will be assigned
378  _In_opt_z_ const char *tag_name,
379  _In_opt_z_ const char *key_name,
380  _In_opt_z_ const char *key_value,
381  _Out_ switch_xml_t *root,
383 
385  _Out_ switch_xml_t *domain);
386 
388  _In_z_ const char *domain_name,
389  _Out_ switch_xml_t *root,
390  _Out_ switch_xml_t *domain, _Out_ switch_xml_t *group, _In_opt_ switch_event_t *params);
391 
393  _In_z_ const char *user_name,
394  _In_z_ const char *domain_name,
395  _In_opt_z_ const char *ip,
396  _Out_ switch_xml_t *root, _Out_ switch_xml_t *domain, _Out_ switch_xml_t *user,
397  _Out_opt_ switch_xml_t *ingroup, _In_opt_ switch_event_t *params);
398 
400  _Out_opt_ switch_xml_t *ingroup);
401 
402 
403 SWITCH_DECLARE(switch_status_t) switch_xml_locate_user_merged(const char *key, const char *user_name, const char *domain_name,
404  const char *ip, switch_xml_t *user, switch_event_t *params);
405 SWITCH_DECLARE(uint32_t) switch_xml_clear_user_cache(const char *key, const char *user_name, const char *domain_name);
407 
409 
410 ///\brief open a config in the core registry
411 ///\param file_path the name of the config section e.g. modules.conf
412 ///\param node a pointer to point to the node if it is found
413 ///\param params optional URL formatted params to pass to external gateways
414 ///\return the root xml node associated with the current request or NULL
416 
417 ///\brief bind a search function to an external gateway
418 ///\param function the search function to bind
419 ///\param sections a bitmask of sections you wil service
420 ///\param user_data a pointer to private data to be used during the callback
421 ///\return SWITCH_STATUS_SUCCESS if successful
422 ///\note gateway functions will be executed in the order they were binded until a success is found else the root registry will be used
423 
428 
430  _In_opt_ void *user_data, switch_xml_binding_t **ret_binding);
431 #define switch_xml_bind_search_function(_f, _s, _u) switch_xml_bind_search_function_ret(_f, _s, _u, NULL)
432 
433 
436 
437 ///\brief parse a string for a list of sections
438 ///\param str a | delimited list of section names
439 ///\return the section mask
441 
442 SWITCH_DECLARE(int) switch_xml_std_datetime_check(switch_xml_t xcond, int *offset, const char *tzname);
443 
444 SWITCH_DECLARE(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);
445 
447 ///\}
448 #endif // _SWITCH_XML_H
449 /* For Emacs:
450  * Local Variables:
451  * mode:c
452  * indent-tabs-mode:t
453  * tab-width:4
454  * c-basic-offset:4
455  * End:
456  * For VIM:
457  * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
458  */
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.
Definition: switch_xml.c:3085
switch_xml_t sibling
Definition: switch_xml.h:93
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
uint32_t refs
Definition: switch_xml.h:104
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
char * name
Definition: switch_xml.h:81
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 ...
Definition: switch_xml.c:3013
switch_size_t off
Definition: switch_xml.h:89
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 &#39;childname&#39; with an attribute &#39;attrname&#39; which equals &#39;value&#39; ...
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.
Definition: switch_xml.c:3077
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_flag_t
Definition: switch_xml.h:70
switch_xml_t switch_xml_find_child_multi(_In_ switch_xml_t node, _In_z_ const char *childname,...)
#define SWITCH_END_EXTERN_C
Definition: switch.h:43
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&#39;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)
Definition: switch_xml.c:3356
switch_xml_t child
Definition: switch_xml.h:97
switch_bool_t
Definition: switch_types.h:437
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)
Definition: switch_xml.c:2145
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
Definition: switch_xml.c:2281
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
Definition: switch_xml.c:3092
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.
Definition: switch_event.h:80
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
Definition: switch_xml.c:2993
const char *const const char *const const cJSON *const value
switch_bool_t is_switch_xml_root_t
Definition: switch_xml.h:103
A representation of an XML tree.
Definition: switch_xml.h:79
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)
Definition: switch_xml.c:2436
const char * open
Definition: switch_xml.h:106
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...
Definition: switch_xml.c:3005
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&#39;t want this, copy the data and \ pass in the copy. Returns NULL on failure.
char * txt
Definition: switch_xml.h:85
switch_xml_t switch_xml_dup(switch_xml_t xml)
Definition: switch_xml.c:1970
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)
#define _Out_opt_
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_xml_t next
Definition: switch_xml.h:91
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)
Definition: switch_xml.c:3138
uint32_t switch_xml_section_t
Definition: switch_types.h:643
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
#define _In_opt_
switch_xml_section_t switch_xml_get_binding_sections(_In_ switch_xml_binding_t *binding)
uintptr_t switch_size_t
switch_xml_t ordered
Definition: switch_xml.h:95
switch_byte_t switch_byte_t uint32_t buflen
#define _In_z_
switch_status_t switch_xml_unbind_search_function(_In_ switch_xml_binding_t **binding)
switch_xml_t parent
Definition: switch_xml.h:99
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)
Definition: switch_xml.c:2473
uint32_t switch_xml_clear_user_cache(const char *key, const char *user_name, const char *domain_name)
Definition: switch_xml.c:2028
switch_xml_t switch_xml_cut(_In_ switch_xml_t xml)
removes a tag along with its subtags without freeing its memory
#define _Out_
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)
char * free_path
Definition: switch_xml.h:87
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)
char * ip
Definition: switch_msrp.c:60
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
Definition: switch_xml.c:2330
Main Library Header.
const char * close
Definition: switch_xml.h:108
#define SWITCH_DECLARE(type)
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)
Definition: switch_xml.c:2012
char ** attr
Definition: switch_xml.h:83
const char * switch_xml_error(_In_ switch_xml_t xml)
returns parser error message or empty string if none
char * key
Definition: switch_msrp.c:64
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 ...
Definition: switch_xml.c:1241
#define _In_opt_z_
uint32_t flags
Definition: switch_xml.h:101
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 _In_
#define SWITCH_BEGIN_EXTERN_C
Definition: switch.h:42
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: switch_xml.c:2356