|
jabberd14 1.6.2
|
reading/writing xmlnodes from/to files, reading xmlnodes from strings More...
#include <jabberdlib.h>Data Structures | |
| struct | _expat_callback_data |
Typedefs | |
| typedef struct _expat_callback_data * | expat_callback_data |
Functions | |
| void | expat_startElement (void *userdata, const char *name, const char **atts) |
| void | expat_endElement (void *userdata, const char *name) |
| void | expat_charData (void *userdata, const char *s, int len) |
| xmlnode | xmlnode_str (const char *str, int len) |
| xmlnode | xmlnode_file (const char *file) |
| char const * | xmlnode_file_borked (char const *file) |
| int | xmlnode2file (char const *file, xmlnode node) |
| int | xmlnode2file_limited (char const *file, xmlnode node, size_t sizelimit) |
| void | xmlnode_put_expat_attribs (xmlnode owner, const char **atts, xmppd::ns_decl_list &nslist) |
reading/writing xmlnodes from/to files, reading xmlnodes from strings
This file implements some tools for the xmlnode implementation in xmlnode.c
The name of this file is confusing. This file does not contain the expat implementation. It contains some code that uses expat to parse XML and build xmlnodes.
| typedef struct _expat_callback_data * expat_callback_data |
| void expat_charData | ( | void * | userdata, |
| const char * | s, | ||
| int | len | ||
| ) |
callback function for CDATA nodes
This function will insert CDATA in an xmlnode
| userdata | pointer to the current xmlnode |
| s | pointer to the CDATA string (not zero terminated!) |
| len | length of the CDATA string |
References _expat_callback_data::x, and xmlnode_insert_cdata().
Referenced by xmlnode_file(), and xmlnode_str().
| void expat_endElement | ( | void * | userdata, |
| const char * | name | ||
| ) |
callback function used for end elements
This function is used internally by expat.c as a callback function given to expat. It will complete an xmlnode and update the userdata pointer to point to the node that is parent of the next starting element.
| userdata | pointer to the current xmlnode |
| name | name of the ending element (ignored by this function) |
References _expat_callback_data::x, and xmlnode_get_parent().
Referenced by xmlnode_file(), and xmlnode_str().
| void expat_startElement | ( | void * | userdata, |
| const char * | name, | ||
| const char ** | atts | ||
| ) |
callback function used for start elements
This function is used internally by expat.c as a callback function given to expat. It will create a new xmlnode and add it to the already created xmlnode tree.
| userdata | pointer to the parent xmlnode instance (NULL if this function is called for the root note) |
| name | name of the starting element |
| atts | attributes that are contained in the start element |
References xmppd::ns_decl_list::get_nsprefix(), _expat_callback_data::ns, NS_DIALBACK, NS_SERVER, NS_STREAM, _expat_callback_data::x, xmlnode_insert_tag_ns(), xmlnode_new_tag_ns(), xmlnode_put_expat_attribs(), and XMLNS_SEPARATOR.
Referenced by xmlnode_file(), and xmlnode_str().
| int xmlnode2file | ( | char const * | file, |
| xmlnode | node | ||
| ) |
write an xmlnode to a file (without a size limit)
| file | the target file |
| node | the xmlnode that should be written |
References xmlnode2file_limited().
Referenced by jsm_serialize(), and main().
| int xmlnode2file_limited | ( | char const * | file, |
| xmlnode | node, | ||
| size_t | sizelimit | ||
| ) |
write an xmlnode to a file, limited by size
| file | the target file |
| node | the xmlnode that should be written |
| sizelimit | the maximum length of the file to be written |
References j_strlen(), and xmlnode_serialize_string().
Referenced by xdb_file_phandler(), and xmlnode2file().
| xmlnode xmlnode_file | ( | const char * | file | ) |
create an xmlnode instance (possibly including other xmlnode instances) by parsing a file
This function will parse a file containing an XML document and create an xmlnode graph
| file | the filename |
References expat_charData(), expat_endElement(), expat_startElement(), _expat_callback_data::ns, _expat_callback_data::parse_pool, pool_free(), pool_new, _expat_callback_data::x, xmlnode_free(), and XMLNS_SEPARATOR.
Referenced by configurate(), jsm_deserialize(), main(), and xdb_file_load().
| char const* xmlnode_file_borked | ( | char const * | file | ) |
get message why parsing of a file failed
This function can be used to get a textual message why parsing an XML file failed.
| file | the filename |
References XMLNS_SEPARATOR.
Referenced by configurate(), and main().
| void xmlnode_put_expat_attribs | ( | xmlnode | owner, |
| const char ** | atts, | ||
| xmppd::ns_decl_list & | nslist | ||
| ) |
append attributes in the expat format to an existing xmlnode
| owner | where to add the attributes |
| atts | the attributes in expat format (even indexes are the attribute names, odd indexes the values) |
| nslist | list of currently defined prefixes for namespace IRIs |
References xmppd::ns_decl_list::get_nsprefix(), NS_DIALBACK, NS_STREAM, xmlnode_put_attrib_ns(), and XMLNS_SEPARATOR.
Referenced by expat_startElement().
| xmlnode xmlnode_str | ( | const char * | str, |
| int | len | ||
| ) |
create an xmlnode instance (possibly including other xmlnode instances) by parsing a string
This function will parse a string containing an XML document and create an xmlnode graph
| str | the string containing the XML document (not necessarily zero terminated) |
| len | the length of the string (without the zero byte, if present) |
References expat_charData(), expat_endElement(), expat_startElement(), _expat_callback_data::ns, _expat_callback_data::parse_pool, pool_free(), pool_new, _expat_callback_data::x, xmlnode_free(), and XMLNS_SEPARATOR.
Referenced by main(), and xdb_file_phandler().
1.7.4