handling of XML documents in a DOM like way More...
#include <jabberdlib.h>#include <map>#include <list>#include <sstream>#include <stdexcept>Namespaces | |
| namespace | xmppd |
Functions | |
| xmlnode | xmlnode_new_tag (const char *name) |
| xmlnode | xmlnode_new_tag_ns (const char *name, const char *prefix, const char *ns_iri) |
| xmlnode | xmlnode_new_tag_pool (pool p, const char *name) |
| xmlnode | xmlnode_new_tag_pool_ns (pool p, const char *name, const char *prefix, const char *ns_iri) |
| xmlnode | xmlnode_insert_tag (xmlnode parent, const char *name) |
| xmlnode | xmlnode_insert_tag_ns (xmlnode parent, const char *name, const char *prefix, const char *ns_iri) |
| xmlnode | xmlnode_insert_cdata (xmlnode parent, const char *CDATA, unsigned int size) |
| xmlnode | xmlnode_get_tag (xmlnode parent, const char *name) |
| xmlnode_vector | xmlnode_get_tags (xmlnode context_node, const char *_path, xht namespaces) |
| char * | xmlnode_get_tag_data (xmlnode parent, const char *name) |
| char * | xmlnode_get_list_item_data (const xmlnode_vector &first, unsigned int i) |
| void | xmlnode_change_namespace (xmlnode node, const char *ns_iri) |
| void | xmlnode_put_attrib (xmlnode owner, const char *name, const char *value) |
| void | xmlnode_put_attrib_ns (xmlnode owner, const char *name, const char *prefix, const char *ns_iri, const char *value) |
| char * | xmlnode_get_attrib (xmlnode owner, const char *name) |
| char * | xmlnode_get_attrib_ns (xmlnode owner, const char *name, const char *ns_iri) |
| xmlnode | xmlnode_get_firstattrib (xmlnode parent) |
| xmlnode | xmlnode_get_firstchild (xmlnode parent) |
| xmlnode | xmlnode_get_lastchild (xmlnode parent) |
| xmlnode | xmlnode_get_nextsibling (xmlnode sibling) |
| xmlnode | xmlnode_get_prevsibling (xmlnode sibling) |
| xmlnode | xmlnode_get_parent (xmlnode node) |
| char * | xmlnode_get_name (xmlnode node) |
| const char * | xmlnode_get_localname (xmlnode node) |
| const char * | xmlnode_get_namespace (xmlnode node) |
| const char * | xmlnode_get_nsprefix (xmlnode node) |
| char * | xmlnode_get_data (xmlnode node) |
| int | xmlnode_get_type (xmlnode node) |
| int | xmlnode_has_children (xmlnode node) |
| pool | xmlnode_pool (xmlnode node) |
| void | xmlnode_hide (xmlnode child) |
| void | xmlnode_hide_attrib (xmlnode parent, const char *name) |
| void | xmlnode_hide_attrib_ns (xmlnode parent, const char *name, const char *ns_iri) |
| char * | xmlnode_serialize_string (xmlnode_t const *node, const xmppd::ns_decl_list &nslist, int stream_type) |
| xmlnode | xmlnode_insert_tag_node (xmlnode parent, xmlnode node) |
| void | xmlnode_insert_node (xmlnode parent, xmlnode node) |
| xmlnode | xmlnode_dup (xmlnode x) |
| xmlnode | xmlnode_dup_pool (pool p, xmlnode x) |
| xmlnode | xmlnode_wrap (xmlnode x, const char *wrapper) |
| xmlnode | xmlnode_wrap_ns (xmlnode x, const char *name, const char *prefix, const char *ns_iri) |
| void | xmlnode_free (xmlnode node) |
| const char * | xmlnode_get_lang (xmlnode node) |
| xmlnode | xmlnode_get_list_item (const xmlnode_vector &first, unsigned int i) |
| xmlnode | xmlnode_select_by_lang (const xmlnode_vector &nodes, const char *lang) |
| void | xmlnode_stat () |
handling of XML documents in a DOM like way
| void xmlnode_change_namespace | ( | xmlnode | node, | |
| const char * | ns_iri | |||
| ) |
change the namespace of a node
| node | the node to change the namespace for | |
| ns_iri | the new namespace of the node |
References xmlnode_t::ns_iri, NS_XMLNS, xmlnode_t::prefix, pstrdup(), xmlnode_get_attrib_ns(), xmlnode_pool(), and xmlnode_put_attrib_ns().
Referenced by xdb_file_load().
produce full duplicate of x with a new pool
| x | xmlnode (tag) that should be duplicated using a new memory pool |
References xmlnode_t::name, xmlnode_t::ns_iri, xmlnode_t::prefix, xmlnode_get_firstattrib(), xmlnode_get_firstchild(), xmlnode_has_children(), xmlnode_insert_node(), and xmlnode_new_tag_ns().
Referenced by dialback_out_connection_cleanup(), dialback_out_read(), dpacket_copy(), and js_mapi_create_additional_iq_result().
produce a full duplicate of a x using the specified memory pool
| p | memory pool to use | |
| x | xmlnode (tag) that should be duplicated |
References xmlnode_t::name, xmlnode_t::ns_iri, xmlnode_t::prefix, xmlnode_get_firstattrib(), xmlnode_get_firstchild(), xmlnode_has_children(), xmlnode_insert_node(), and xmlnode_new_tag_pool_ns().
| void xmlnode_free | ( | xmlnode | node | ) |
free the memory allocated by an xmlnode tree
No nodes inside the xmlnode tree can be used afterwards, as they are all freed by this function
| node | one of the elements inside a tree of xmlnodes that should be freed |
References xmlnode_t::p, and pool_free().
Referenced by _js_authreg_register(), _js_routed_error_packet(), _js_routed_packet(), _js_session_end(), _js_session_from(), _js_session_to(), _mio_xstream_cleanup(), _xdb_file_purge(), configurate(), dialback(), dialback_in_read(), dialback_in_read_db(), dialback_in_verify(), dialback_ip_set(), dialback_miod_read(), dialback_out_packet(), dialback_out_read(), dialback_out_read_db(), dialback_packets(), dnsrv(), dnsrv_child_process_xstream_io(), dnsrv_deliver(), dnsrv_process_xstream_io(), dpacket_new(), js_bounce_xmpp(), js_deliver(), js_mapi_call2(), js_packet(), js_session_end(), js_user(), jsm(), jsm_deserialize(), jsm_serialize(), main(), mio_write_root(), mod_auth_crypt(), mod_auth_digest(), mod_auth_plain(), mod_dynamic(), mod_last(), mod_log(), mod_offline(), mod_presence(), mod_version(), mod_xml(), xmppd::instance_base::on_subscription_stanza(), xdb_file(), xdb_file_phandler(), xdb_get(), xdb_sql(), xmlnode_file(), and xmlnode_str().
| char* xmlnode_get_attrib | ( | xmlnode | owner, | |
| const char * | name | |||
| ) |
get an attribute value
| owner | element where to look for the attribute | |
| name | name of the attribute of which the value should be returned |
References j_strcmp(), j_strncmp(), NS_XMLNS, and xmlnode_get_attrib_ns().
Referenced by dnsrv_deliver(), js_bounce_xmpp(), xdb_file_phandler(), and xmlnode_get_tag().
| char* xmlnode_get_attrib_ns | ( | xmlnode | owner, | |
| const char * | name, | |||
| const char * | ns_iri | |||
| ) |
get an attribute value
| owner | element where to look for the attribute | |
| name | local name of the attribute of which the value should be returned | |
| ns_iri | namespace IRI of the attribute of which the value should be returned |
References xmlnode_t::data, xmlnode_t::firstattrib, and NTYPE_ATTRIB.
Referenced by _js_authreg_register(), _js_routed_auth_packet(), _js_routed_packet(), _js_routed_session_control_packet(), _js_session_from(), _js_session_to(), acl_get_users(), configurate(), deliver(), deliver_config_filter(), deliver_fail(), dialback(), dialback_in_read(), dialback_in_read_db(), dialback_in_verify(), dialback_ip_get(), dialback_ip_set(), dialback_out_packet(), dialback_out_read(), dialback_packets(), dnsrv(), dnsrv_deliver(), dnsrv_process_xstream_io(), dnsrv_resend(), dpacket_new(), jpacket_reset(), jpacket_subtype(), js_authreg(), js_sc_session_new(), js_session_end(), js_session_new(), jsm(), jutil_delay(), jutil_priority(), jutil_tofrom(), mio_init(), mio_ssl_init(), mio_write_root(), mod_dynamic(), pthsock_client(), xmppd::resolver::resend_service::resend_service(), xdb_file_phandler(), xdb_sql(), xhash_from_xml(), xmlnode_change_namespace(), xmlnode_get_attrib(), xmlnode_get_lang(), and xstream_header_char().
| char* xmlnode_get_data | ( | xmlnode | node | ) |
return the text inside the element given as node
| node | the node to search for text nodes inside |
References xmlnode_t::data, xmlnode_t::next, NTYPE_CDATA, NTYPE_TAG, xmlnode_get_firstchild(), xmlnode_get_nextsibling(), and xmlnode_get_type().
Referenced by _js_authreg_register(), acl_get_users(), deliver(), deliver_config_filter(), dialback(), dialback_in_read_db(), dialback_out_read(), dnsrv(), dnsrv_child_process_xstream_io(), dnsrv_process_xstream_io(), js_packet(), jsm(), jutil_priority(), main(), mio_init(), mio_ssl_init(), mod_log(), mod_presence(), mod_version(), xmppd::ns_decl_list::ns_decl_list(), pthsock_client(), xmppd::resolver::resend_service::resend_service(), xdb_file(), xdb_file_phandler(), xdb_sql(), xhash_from_xml(), xmlnode_get_list_item_data(), xmlnode_get_tag(), xmlnode_get_tag_data(), xmlnode_insert_node(), and xstream_parse_error().
get the first attribute node of an element
iteration on all attributes is possible by using xmlnode_get_nextsibling() using the result of this function as the start
| parent | element for which the first attribute node should be returned |
References xmlnode_t::firstattrib.
Referenced by xmppd::ns_decl_list::ns_decl_list(), xmlnode_dup(), xmlnode_dup_pool(), xmlnode_get_tags(), and xmlnode_insert_tag_node().
get the first child node of a node
iteration on all childs is possible using xmlnode_get_nextsibling() using the result of this function as the start
| parent | element for which the first child should be returned |
References xmlnode_t::firstchild.
Referenced by _js_routed_error_packet(), _js_routed_packet(), configo(), deliver_fail(), dialback_in_read_db(), dialback_out_connection_cleanup(), dialback_out_read(), dialback_packets(), dnsrv_deliver(), xmppd::instance_base::get_instance_config(), jpacket_reset(), jutil_iqresult(), main(), mio_ssl_init(), mod_dynamic(), mod_log(), mod_presence(), pthsock_client(), xdb_file_phandler(), xdb_get(), xmlnode_dup(), xmlnode_dup_pool(), xmlnode_get_data(), xmlnode_get_tags(), xmlnode_insert_tag_node(), and xstream_parse_error().
| const char* xmlnode_get_lang | ( | xmlnode | node | ) |
get the declared language of a node
| node | the node to get the language for |
References NS_XML, NTYPE_TAG, xmlnode_t::parent, xmlnode_t::type, xmlnode_get_attrib_ns(), and xmlnode_get_lang().
Referenced by _dialback_out_beat_packets(), _js_routed_session_control_packet(), _js_routed_session_packet(), deliver_fail(), dialback_out_connection_cleanup(), js_session_end(), js_session_route(), jutil_delay(), jutil_error_xmpp(), xmlnode_get_lang(), xmlnode_select_by_lang(), xmlnode_wrap_ns(), and xstream_parse_error().
get the last child node of a node
(backwards) iteration on all childs is possible using xmlnode_get_prevsibling() using the result of this function as the start
| parent | element for which the last child should be returned |
References xmlnode_t::lastchild.
Referenced by dnsrv().
| xmlnode xmlnode_get_list_item | ( | const xmlnode_vector & | first, | |
| unsigned int | i | |||
| ) |
get the (i+1)-th element in a list of xmlnodes
| first | first list item | |
| i | which item to get (we start counting at zero) |
Referenced by _js_authreg_register(), _js_session_from(), _js_session_to(), dialback(), dialback_in_verify(), dialback_out_read(), dialback_packets(), jsm(), jutil_priority(), main(), mio_init(), mod_offline(), mod_version(), pthsock_client(), register_instance(), xdb_file(), xdb_file_phandler(), xdb_sql(), and xhash_from_xml().
| char* xmlnode_get_list_item_data | ( | const xmlnode_vector & | first, | |
| unsigned int | i | |||
| ) |
get that text wrapped by the (i+1)-th element in a list of xmlnodes
| first | pointer to the first list item | |
| i | which item to use |
References xmlnode_get_data().
Referenced by dialback(), and xdb_file().
| const char* xmlnode_get_localname | ( | xmlnode | node | ) |
get the local name of a node
| node | the node to get the local name for |
References xmlnode_t::name.
Referenced by _js_routed_packet(), dialback_in_read_db(), dialback_out_packet(), dialback_out_read(), dialback_out_read_db(), dnsrv(), dpacket_new(), jpacket_reset(), js_bounce_xmpp(), main(), mio_ssl_init(), mod_dynamic(), mod_log(), mod_presence(), xmppd::ns_decl_list::ns_decl_list(), pthsock_client(), and xstream_parse_error().
| char* xmlnode_get_name | ( | xmlnode | node | ) |
get the name of a node
| node | the node to get the name for |
References xmlnode_t::name, xmlnode_t::p, xmlnode_t::prefix, and pstrdup().
Referenced by configo(), dialback_packets(), and xmlnode_get_tag().
| const char* xmlnode_get_namespace | ( | xmlnode | node | ) |
get the namespace IRI of a node
| node | the node to get the namespace IRI for |
References xmlnode_t::ns_iri.
Referenced by _js_routed_packet(), deliver_fail(), dialback_in_read_db(), dialback_out_packet(), dialback_out_read(), dialback_out_read_db(), dialback_packets(), dnsrv(), xmppd::instance_base::get_instance_config(), jpacket_reset(), js_bounce_xmpp(), main(), mio_ssl_init(), mod_dynamic(), xmppd::ns_decl_list::ns_decl_list(), pthsock_client(), xdb_file_load(), and xstream_parse_error().
return the next sibling
this can be used together with xmlnode_get_firstchild() to iterate over the childrens of a node
| sibling | the node to get the next sibling for |
References xmlnode_t::next.
Referenced by _js_routed_packet(), configo(), dialback_out_connection_cleanup(), dialback_out_read(), xmppd::instance_base::get_instance_config(), jpacket_reset(), jutil_iqresult(), mio_ssl_init(), mod_dynamic(), mod_log(), mod_presence(), xmppd::ns_decl_list::ns_decl_list(), xdb_get(), xmlnode_get_data(), xmlnode_get_tag(), xmlnode_get_tags(), xmlnode_insert_node(), and xstream_parse_error().
| const char* xmlnode_get_nsprefix | ( | xmlnode | node | ) |
get the namespace prefix of a node
| node | the node to get the namespace prefix for |
References xmlnode_t::prefix.
Referenced by main().
get the parent node for a node
| node | the node for which the parent node should be returned |
References xmlnode_t::parent.
Referenced by expat_endElement(), main(), and xmlnode_get_tags().
return the previous sibling
this can be used together with xmlnode_get_lastchild() to iterate backwards over the childrens of a node
| sibling | the node to get the previous sibling for |
References xmlnode_t::prev.
Referenced by dnsrv().
find given tag in an xmlnode tree
| parent | pointer to the parent tag | |
| name | "name" for the child tag of that name, "name/name" for a sub child (recurses), "?attrib" to match the first tag with that attrib defined, "?attrib=value" to match the first tag with that attrib and value, "=cdata" to match the text node contents of the child, or any combination: "name/name/?attrib", "name=cdata", etc |
References xmlnode_t::firstchild, j_strcmp(), NTYPE_TAG, xmlnode_get_attrib(), xmlnode_get_data(), xmlnode_get_name(), xmlnode_get_nextsibling(), xmlnode_get_tag(), and xmlnode_get_type().
Referenced by jsm(), xdb_file_phandler(), xmlnode_get_tag(), and xmlnode_get_tag_data().
| char* xmlnode_get_tag_data | ( | xmlnode | parent, | |
| const char * | name | |||
| ) |
return the text wrapped inside the element found by the name parameter
this equals xmlnode_get_data(xmlnode_get_tag(parent, name))
| parent | the element where to search for the element defined by the name parameter | |
| name | search query for the element whichs textual content should be returned |
References xmlnode_get_data(), and xmlnode_get_tag().
| xmlnode_vector xmlnode_get_tags | ( | xmlnode | context_node, | |
| const char * | _path, | |||
| xht | namespaces | |||
| ) |
at all xmlnodes that match a path
The valid paths are a very small subset of xpath.
The only predicates we support is for existence of attributes, or for attribute values, we only support steps in the axis child and the axis must be ommited, we support text() as a step.
Examples:
| context_node | the xmlnode where to start the path | |
| path | the path (xpath like syntax, but only a small subset) | |
| namespaces | hashtable mapping namespace prefixes to namespace IRIs | |
| p | memory pool to use |
References j_strcmp(), xmlnode_t::name, xmlnode_t::ns_iri, NTYPE_CDATA, xmlnode_t::type, xhash_get(), xmlnode_get_firstattrib(), xmlnode_get_firstchild(), xmlnode_get_nextsibling(), and xmlnode_get_parent().
Referenced by _js_authreg_register(), _js_session_from(), _js_session_to(), acl_get_users(), configurate(), deliver(), deliver_config_filter(), dialback(), dialback_in_verify(), dialback_out_read(), dialback_packets(), js_config(), jsm(), jsm_deserialize(), jutil_priority(), main(), mio_init(), mod_offline(), mod_version(), mod_xml(), pthsock_client(), register_instance(), xmppd::resolver::resend_service::resend_service(), xdb_file(), xdb_file_phandler(), xdb_sql(), and xhash_from_xml().
| int xmlnode_get_type | ( | xmlnode | node | ) |
get the type of the node
| node | the node to get the type for |
References NTYPE_UNDEF, and xmlnode_t::type.
Referenced by _js_routed_packet(), configo(), dialback_out_read(), xmppd::instance_base::get_instance_config(), mod_dynamic(), mod_log(), mod_presence(), xdb_get(), xmlnode_get_data(), xmlnode_get_tag(), xmlnode_insert_node(), and xstream_parse_error().
| int xmlnode_has_children | ( | xmlnode | node | ) |
check if a node has child nodes
| node | the node to check |
References xmlnode_t::firstchild.
Referenced by xmlnode_dup(), xmlnode_dup_pool(), xmlnode_insert_tag_node(), and xstream_header_char().
| void xmlnode_hide | ( | xmlnode | child | ) |
hide (remove) a node from a document
| child | the xmlnode that should be hidden |
References xmlnode_t::firstattrib, xmlnode_t::firstchild, xmlnode_t::lastattrib, xmlnode_t::lastchild, xmlnode_t::next, NTYPE_ATTRIB, xmlnode_t::parent, xmlnode_t::prev, and xmlnode_t::type.
Referenced by deliver_fail(), dialback_in_read_db(), dialback_in_verify(), dialback_out_read(), jutil_iqresult(), main(), and xdb_file_phandler().
| void xmlnode_hide_attrib | ( | xmlnode | parent, | |
| const char * | name | |||
| ) |
hide (remove) an attribute of an element
| parent | the element for which an attribute should be hidden | |
| name | name of the attribute, that should be hidden |
References j_strncmp(), NS_XMLNS, and xmlnode_hide_attrib_ns().
| void xmlnode_hide_attrib_ns | ( | xmlnode | parent, | |
| const char * | name, | |||
| const char * | ns_iri | |||
| ) |
hide (remove) a namespaced attribute of an element
| parent | the element for which an attribute should be hidden | |
| name | local name of the attribute, that should be hidden | |
| ns_iri | namespace IRI of the attribute, that should be hidden |
References xmlnode_t::firstattrib, xmlnode_t::lastattrib, xmlnode_t::next, NTYPE_ATTRIB, and xmlnode_t::prev.
Referenced by _js_routed_packet(), _js_session_from(), _js_session_to(), dialback_out_packet(), dialback_out_read(), dialback_packets(), jpacket_reset(), js_authreg(), xdb_file_phandler(), and xmlnode_hide_attrib().
insert a text node as child to an existing xmlnode
| parent | where to insert the new text node | |
| CDATA | content of the text node to insert | |
| size | size of the string in CDATA, or -1 for auto-detection on null-terminated strings |
References xmlnode_t::data, xmlnode_t::data_sz, NTYPE_CDATA, xmlnode_t::p, and pmalloc().
Referenced by _mio_xstream_CDATA(), configurate(), dialback_in_read(), dialback_out_connection(), dialback_out_read(), dnsrv_lookup(), expat_charData(), js_bounce_xmpp(), jutil_delay(), jutil_error_xmpp(), jutil_msgnew(), jutil_presnew(), log_generic(), logger(), main(), xmlnode_insert_node(), and xstream_eat().
places copy of node and node's siblings in parent
| parent | where to place the copy to | |
| node | what to copy |
References xmlnode_t::name, xmlnode_t::ns_iri, NTYPE_ATTRIB, NTYPE_CDATA, NTYPE_TAG, xmlnode_t::prefix, xmlnode_get_data(), xmlnode_get_nextsibling(), xmlnode_get_type(), xmlnode_insert_cdata(), xmlnode_insert_tag_node(), and xmlnode_put_attrib_ns().
Referenced by dialback_in_read_db(), main(), xmlnode_dup(), xmlnode_dup_pool(), and xmlnode_insert_tag_node().
append a child tag to a tag
| parent | the xmlnode where the new element should be inserted | |
| name | name of the child tag |
References xmlnode_t::ns_iri, NTYPE_TAG, pmalloco(), xmlnode_t::prefix, and xmlnode_pool().
copy an element node as a child to an other node
| parent | where to insert the xmlnode | |
| node | node to insert |
References xmlnode_t::name, xmlnode_t::ns_iri, xmlnode_t::prefix, xmlnode_get_firstattrib(), xmlnode_get_firstchild(), xmlnode_has_children(), xmlnode_insert_node(), and xmlnode_insert_tag_ns().
Referenced by configurate(), dialback_in_read_db(), dialback_out_packet(), xdb_file_phandler(), and xmlnode_insert_node().
| xmlnode xmlnode_insert_tag_ns | ( | xmlnode | parent, | |
| const char * | name, | |||
| const char * | prefix, | |||
| const char * | ns_iri | |||
| ) |
append a child tag to a tag, including namespace declaration
| parent | the xmlnode where the new element should be inserted | |
| name | local name of the child tag | |
| prefix | namespace prefix of the child tag | |
| ns_iri | namespace IRI of the child tag |
References j_strcmp(), NS_CLIENT, NS_COMPONENT_ACCEPT, NS_SERVER, NS_XMLNS, NTYPE_TAG, xmlnode_t::prefix, and xmlnode_put_attrib_ns().
Referenced by _dialback_walk_in_connecting(), _dialback_walk_in_established(), _dialback_walk_out_connecting(), _dialback_walk_out_established(), _js_authreg_auth(), _js_authreg_register(), configurate(), deliver_fail(), dialback_in_read(), expat_startElement(), js_bounce_xmpp(), js_mapi_create_additional_iq_result(), js_session_route(), jutil_delay(), jutil_error_xmpp(), jutil_iqnew(), jutil_msgnew(), jutil_presnew(), xdb_file_phandler(), and xmlnode_insert_tag_node().
| xmlnode xmlnode_new_tag | ( | const char * | name | ) |
create a tag node
Automatically creates a memory pool for the node. The namespace is declared to be 'jabber:server'.
| name | name of the tag |
References pool_heap, and xmlnode_new_tag_pool().
| xmlnode xmlnode_new_tag_ns | ( | const char * | name, | |
| const char * | prefix, | |||
| const char * | ns_iri | |||
| ) |
create a tag node, including a namespace declaration
Automatically creates a memory pool for the node.
| name | local name of the tag | |
| prefix | the namespace prefix of the tag (NULL for the default prefix) | |
| ns_iri | the namespace IRI of the tag |
References pool_heap, and xmlnode_new_tag_pool_ns().
Referenced by dialback_in_read(), dialback_in_read_db(), dialback_ip_set(), dialback_out_connection(), dialback_out_read(), expat_startElement(), js_session_route(), jsm_serialize(), jutil_iqnew(), jutil_msgnew(), jutil_presnew(), log_generic(), logger(), xdb_file_load(), xhash_to_xml(), xmlnode_dup(), xstream_eat(), and xstream_header().
create a tag node within given pool
The namespace is declared to be 'jabber:server'.
| p | previously created memory pool | |
| name | name of the tag |
References j_strcmp(), NS_DIALBACK, NS_SERVER, NS_STREAM, NTYPE_TAG, pmalloco(), and pool_cleanup().
Referenced by xmlnode_new_tag().
| xmlnode xmlnode_new_tag_pool_ns | ( | pool | p, | |
| const char * | name, | |||
| const char * | prefix, | |||
| const char * | ns_iri | |||
| ) |
create a tag node within a given pool, including a namespace declaration
| p | previously created memory pool | |
| name | local name of the tag | |
| prefix | the namespace prefix of the tag (NULL for the default prefix) | |
| ns_iri | the namespace IRI of the tag |
References j_strcmp(), NS_CLIENT, NS_COMPONENT_ACCEPT, NS_SERVER, NS_XMLNS, NTYPE_TAG, pool_cleanup(), and xmlnode_put_attrib_ns().
Referenced by dialback_in_read_db(), dialback_in_verify(), dialback_out_connection(), dnsrv_lookup(), xmlnode_dup_pool(), xmlnode_new_tag_ns(), and xmlnode_wrap_ns().
get the memory pool of an xmlnode
| node | the node to get the memory pool from |
References xmlnode_t::p.
Referenced by _js_routed_packet(), deliver(), dialback(), dialback_in_read(), dialback_in_read_db(), dialback_in_verify(), dialback_out_connection(), dialback_out_packet(), dialback_out_read(), dialback_packets(), dnsrv(), dpacket_new(), jpacket_new(), jpacket_reset(), jsm_deserialize(), mio_write(), pthsock_client(), xdb_file(), xdb_file_load(), xdb_sql(), xmlnode_change_namespace(), xmlnode_insert_tag(), xmlnode_put_expat_attribs(), xmlnode_serialize_string(), xstream_eat(), xstream_header_char(), and xstream_parse_error().
| void xmlnode_put_attrib | ( | xmlnode | owner, | |
| const char * | name, | |||
| const char * | value | |||
| ) |
add an attribute to an xmlnode element
| owner | element to add the attribute to | |
| name | name of the attribute | |
| value | value of the attribute |
References j_strcmp(), j_strncmp(), NS_CLIENT, NS_COMPONENT_ACCEPT, xmlnode_t::ns_iri, NS_SERVER, NS_XML, NS_XMLNS, xmlnode_t::p, xmlnode_t::prefix, pstrdup(), and xmlnode_put_attrib_ns().
Referenced by dnsrv_process_xstream_io().
| void xmlnode_put_attrib_ns | ( | xmlnode | owner, | |
| const char * | name, | |||
| const char * | prefix, | |||
| const char * | ns_iri, | |||
| const char * | value | |||
| ) |
add an namespaced attribute to an xmlnode element
| owner | element to add the attribute to | |
| name | local name of the attribute | |
| prefix | namespace prefix of the attribute | |
| ns_iri | namespace IRI of the attribute | |
| value | the value to set for the attribute |
References xmlnode_t::data, xmlnode_t::data_sz, xmlnode_t::firstattrib, j_strcmp(), xmlnode_t::lastattrib, NS_CLIENT, NS_COMPONENT_ACCEPT, NS_SERVER, NTYPE_ATTRIB, xmlnode_t::p, xmlnode_t::parent, and pstrdup().
Referenced by _dialback_walk_in_connecting(), _dialback_walk_in_established(), _dialback_walk_out_connecting(), _dialback_walk_out_established(), _js_authreg_auth(), _js_authreg_register(), _js_routed_auth_packet(), _js_routed_session_control_packet(), _js_routed_session_packet(), _js_session_from(), _js_session_to(), base_syslog_config(), configurate(), deliver_fail(), dialback_in_read(), dialback_in_read_db(), dialback_in_verify(), dialback_ip_set(), dialback_out_connection(), dialback_out_packet(), dialback_out_read(), dialback_packets(), dnsrv_child_process_xstream_io(), dnsrv_resend(), js_authreg(), js_bounce_xmpp(), js_sc_session_new(), js_session_end(), js_session_new(), js_session_route(), jutil_delay(), jutil_error_xmpp(), jutil_iqnew(), jutil_iqresult(), jutil_msgnew(), jutil_presnew(), jutil_tofrom(), log_generic(), logger(), main(), xdb_file_phandler(), xmlnode_change_namespace(), xmlnode_insert_node(), xmlnode_insert_tag_ns(), xmlnode_new_tag_pool_ns(), xmlnode_put_attrib(), xmlnode_put_expat_attribs(), xmlnode_wrap_ns(), and xstream_header().
| xmlnode xmlnode_select_by_lang | ( | const xmlnode_vector & | nodes, | |
| const char * | lang | |||
| ) |
select one note from a list of notes by language
This picks the first node in the list with the specified language, if no such node exists, the language in general is searched (e.g. if lang is fr-FR, we then look for fr). If even no such node exists, the first node without a language is selected, if no nodes without a language are in the list, the first list item is returned.
| nodes | pointer to the first entry in the list of nodes | |
| lang | language to prefere (if NULL, the first node without language is prefered) |
References j_strcasecmp(), and xmlnode_get_lang().
Referenced by js_config().
| char* xmlnode_serialize_string | ( | xmlnode_t const * | node, | |
| const xmppd::ns_decl_list & | nslist, | |||
| int | stream_type | |||
| ) |
serialize a given xmlnode to a string
This function can be used to serialize a stanza. As a stanza is typically written to an XML stream, there might be namespaces, that are already declared by the stream root element. These namespaces do not need to be declared again, when the stanza is serialized. This is what nslist_first and nslist_last is for. These two pointers point to the begin and end of a list of already declared namespace prefixes. If all namespaces should be declared, than you can just pass NULL as these two arguments.
Do not pass the 'jabber:client', or 'jabber:component:accept' namespace in the list of already declared namespaces, but pass always the namespace 'jabber:server' instead. This is because xmlnode represents all these namespaces as 'jabber:server'.
| node | the base xmlnode of the tree, that should be serialized | |
| nslist | list of already declared namespaces | |
| stream_type | 0 for a 'jabber:server' stream, 1 for a 'jabber:client' stream, 2 for a 'jabber:component:accept' stream |
References pstrdup(), and xmlnode_pool().
Referenced by _js_routed_packet(), deliver(), deliver_fail(), dialback_in_read(), dialback_in_read_db(), dialback_in_verify(), dialback_miod_read(), dialback_out_packet(), dialback_out_read(), dnsrv(), dnsrv_child_process_xstream_io(), dnsrv_deliver(), dnsrv_lookup(), dnsrv_process_xstream_io(), dpacket_new(), js_bounce_xmpp(), js_deliver(), js_offline_main(), js_packet(), js_server_main(), log_generic(), logger(), main(), mio_init(), mio_write(), mod_dynamic(), xdb_file(), xdb_file_phandler(), xmlnode2file_limited(), and xstream_header_char().
| void xmlnode_stat | ( | ) |
Referenced by main().
wrap a xmlnode in a new element
this function creates a new element with the name specified as the wrapper parameter, the xmlnode x becomes a child of this new element
| x | the xmlnode that gets wrapped | |
| wrapper | name of the wrapping element (that is to be created) |
References NS_SERVER, xmlnode_t::p, pmalloco(), xmlnode_t::prefix, and xmlnode_wrap_ns().
wrap an xmlnode in a new namespaced element
this function creates a new element with the specified namespace and name, the xmlnode x becomes a child of this new element
| x | the xmlnode that gets wrapped | |
| name | the local name of the wrapper element (that is to be created) | |
| prefix | the namespace prefix of the wrapper element | |
| ns_iri | the namespace IRI of the wrapper element |
References xmlnode_t::firstchild, xmlnode_t::lastchild, NS_XML, xmlnode_t::p, xmlnode_t::parent, xmlnode_get_lang(), xmlnode_new_tag_pool_ns(), and xmlnode_put_attrib_ns().
Referenced by dialback_in_read_db(), dnsrv_resend(), js_authreg(), js_session_route(), and xmlnode_wrap().
1.6.1