jabberdlib.h File Reference

#include <cstring>
#include <cstdlib>
#include <sys/types.h>
#include <stdio.h>
#include <setjmp.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
#include <syslog.h>
#include <strings.h>
#include <unistd.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <sys/time.h>
#include <stdarg.h>
#include <ctype.h>
#include <ctime>
#include <pth.h>
#include <expat.h>
#include <utility>
#include <list>
#include <map>
#include <glibmm.h>
#include <varargs.h>
#include <string>
#include <vector>
#include <sstream>
#include <stdexcept>
#include <set>
#include <pointer.tcc>

Go to the source code of this file.

Data Structures

class  xmppd::pointer< pointed_type >
class  xmppd::hash
class  xmppd::sha1
struct  pheap
struct  pfree
struct  pool_struct
class  xmppd::to_lower
class  xmppd::xhash< value_type >
struct  xmlnode_t
class  xmppd::ns_decl_list
struct  xstream_struct
struct  streamerr_struct
struct  j_SHA_CTX
class  xmppd::jabberid
class  xmppd::jabberid_pool
struct  jpacket_struct
struct  jlimit_struct
struct  karma
struct  terror_struct
struct  xterror_struct
class  xmppd::lwresc::invalid_packet
class  xmppd::lwresc::lwquery
class  xmppd::lwresc::rrsetbyname
class  xmppd::lwresc::rrecord
class  xmppd::lwresc::srv_record
class  xmppd::lwresc::aaaa_record
class  xmppd::lwresc::a_record
class  xmppd::lwresc::lwresult_rdata
class  xmppd::lwresc::lwresult_rrset
class  xmppd::lwresc::lwresult

Namespaces

namespace  xmppd
namespace  xmppd::lwresc

Defines

#define N_(n)   (n)
#define MAXSHORTSTR   203
#define QUAD_T   unsigned long long
#define VA_LOCAL_DECL   va_list ap;
#define VA_START(f)   va_start(ap)
#define VA_END   va_end(ap)
#define ZONE   zonestr(__FILE__,__LINE__)
#define pool_heap(i)   _pool_new_heap(i, NULL, 0)
#define pool_new()   _pool_new(NULL, 0)
#define MAXHOSTNAMELEN   64
#define NETSOCKET_SERVER   0
#define NETSOCKET_CLIENT   1
#define NETSOCKET_UDP   2
#define NTYPE_TAG   0
#define NTYPE_ATTRIB   1
#define NTYPE_CDATA   2
#define NTYPE_LAST   2
#define NTYPE_UNDEF   -1
#define XMLNS_SEPARATOR   ' '
#define XSTREAM_MAXNODE   1000000
#define XSTREAM_MAXDEPTH   100
#define XSTREAM_ROOT   0
#define XSTREAM_NODE   1
#define XSTREAM_CLOSE   2
#define XSTREAM_ERR   4
#define JID_RESOURCE   1
#define JID_USER   2
#define JID_SERVER   4
#define JPACKET_UNKNOWN   0x00
#define JPACKET_MESSAGE   0x01
#define JPACKET_PRESENCE   0x02
#define JPACKET_IQ   0x04
#define JPACKET_S10N   0x08
#define JPACKET__UNKNOWN   0
#define JPACKET__NONE   1
#define JPACKET__ERROR   2
#define JPACKET__CHAT   3
#define JPACKET__GROUPCHAT   4
#define JPACKET__GET   5
#define JPACKET__SET   6
#define JPACKET__RESULT   7
#define JPACKET__SUBSCRIBE   8
#define JPACKET__SUBSCRIBED   9
#define JPACKET__UNSUBSCRIBE   10
#define JPACKET__UNSUBSCRIBED   11
#define JPACKET__AVAILABLE   12
#define JPACKET__UNAVAILABLE   13
#define JPACKET__PROBE   14
#define JPACKET__HEADLINE   15
#define JPACKET__INVISIBLE   16
#define KARMA_READ_MAX(k)   (abs(k)*100)
#define KARMA_INIT   5
#define KARMA_HEARTBEAT   2
#define KARMA_MAX   10
#define KARMA_INC   1
#define KARMA_DEC   0
#define KARMA_PENALTY   -5
#define KARMA_RESTORE   5
#define KARMA_RESETMETER   0
#define TERROR_BAD   (terror){400,"Bad Request"}
#define TERROR_AUTH   (terror){401,"Unauthorized"}
#define TERROR_PAY   (terror){402,"Payment Required"}
#define TERROR_FORBIDDEN   (terror){403,"Forbidden"}
#define TERROR_NOTFOUND   (terror){404,"Not Found"}
#define TERROR_NOTALLOWED   (terror){405,"Not Allowed"}
#define TERROR_NOTACCEPTABLE   (terror){406,"Not Acceptable"}
#define TERROR_REGISTER   (terror){407,"Registration Required"}
#define TERROR_REQTIMEOUT   (terror){408,"Request Timeout"}
#define TERROR_CONFLICT   (terror){409,"Conflict"}
#define TERROR_INTERNAL   (terror){500,"Internal Server Error"}
#define TERROR_NOTIMPL   (terror){501,"Not Implemented"}
#define TERROR_EXTERNAL   (terror){502,"Remote Server Error"}
#define TERROR_UNAVAIL   (terror){503,"Service Unavailable"}
#define TERROR_EXTTIMEOUT   (terror){504,"Remote Server Timeout"}
#define TERROR_DISCONNECTED   (terror){510,"Disconnected"}
#define HAS_XTERROR
#define XTERROR_BAD   (xterror){400, N_("Bad Request"),"modify","bad-request"}
#define XTERROR_CONFLICT   (xterror){409, N_("Conflict"), "cancel", "conflict"}
#define XTERROR_NOTIMPL   (xterror){501, N_("Not Implemented"), "cancel", "feature-not-implemented"}
#define XTERROR_FORBIDDEN   (xterror){403, N_("Forbidden"), "auth", "forbidden"}
#define XTERROR_GONE   (xterror){302, N_("Gone"), "modify", "gone"}
#define XTERROR_INTERNAL   (xterror){500, N_("Internal Server Error"), "wait", "internal-server-error"}
#define XTERROR_NOTFOUND   (xterror){404, N_("Not Found"), "cancel", "item-not-found"}
#define XTERROR_JIDMALFORMED   (xterror){400, N_("Bad Request"), "modify", "jid-malformed"}
#define XTERROR_NOTACCEPTABLE   (xterror){406, N_("Not Acceptable"), "modify", "not-acceptable"}
#define XTERROR_NOTALLOWED   (xterror){405, N_("Not Allowed"), "cancel", "not-allowed"}
#define XTERROR_AUTH   (xterror){401, N_("Unauthorized"), "auth", "not-authorized"}
#define XTERROR_PAY   (xterror){402, N_("Payment Required"), "auth", "payment-required"}
#define XTERROR_RECIPIENTUNAVAIL   (xterror){404, N_("Recipient Is Unavailable"), "wait", "recipient-unavailable"}
#define XTERROR_REDIRECT   (xterror){302, N_("Redirect"), "modify", "redirect"}
#define XTERROR_REGISTER   (xterror){407, N_("Registration Required"), "auth", "registration-required"}
#define XTERROR_REMOTENOTFOUND   (xterror){404, N_("Remote Server Not Found"), "cancel", "remote-server-not-found"}
#define XTERROR_REMOTETIMEOUT   (xterror){504, N_("Remote Server Timeout"), "wait", "remote-server-timeout"}
#define XTERROR_RESCONSTRAINT   (xterror){500, N_("Resource Constraint"), "wait", "resource-constraint"}
#define XTERROR_UNAVAIL   (xterror){503, N_("Service Unavailable"), "cancel", "service-unavailable"}
#define XTERROR_SUBSCRIPTIONREQ   (xterror){407, N_("Subscription Required"), "auth", "subscription-required"}
#define XTERROR_UNDEF_CANCEL   (xterror){500, NULL, "cancel", "undefined-condition"}
#define XTERROR_UNDEF_CONTINUE   (xterror){500, NULL, "continue", "undefined-condition"}
#define XTERROR_UNDEF_MODIFY   (xterror){500, NULL, "modify", "undefined-condition"}
#define XTERROR_UNDEF_AUTH   (xterror){500, NULL, "auth", "undefined-condition"}
#define XTERROR_UNDEF_WAIT   (xterror){500, NULL, "wait", "undefined-condition"}
#define XTERROR_UNEXPECTED   (xterror){400, N_("Unexpected Request"), "wait", "unexpected-request"}
#define XTERROR_REQTIMEOUT   (xterror){408, N_("Request Timeout"), "wait", "remote-server-timeout"}
#define XTERROR_EXTERNAL   (xterror){502, N_("Remote Server Error"), "wait", "service-unavailable"}
#define XTERROR_EXTTIMEOUT   (xterror){504, N_("Remote Server Timeout"), "wait", "remote-server-timeout"}
#define XTERROR_DISCONNECTED   (xterror){510, N_("Disconnected"), "cancel", "service-unavailable"}
#define XTERROR_STORAGE_FAILED   (xterror){500, N_("Storage Failed"), "wait", "internal-server-error"}
#define NSCHECK(x, n)   (j_strcmp(xmlnode_get_namespace(x), n) == 0)
#define NS_STREAM   "http://etherx.jabber.org/streams"
#define NS_FLASHSTREAM   "http://www.jabber.com/streams/flash"
#define NS_CLIENT   "jabber:client"
#define NS_SERVER   "jabber:server"
#define NS_DIALBACK   "jabber:server:dialback"
#define NS_COMPONENT_ACCEPT   "jabber:component:accept"
#define NS_AUTH   "jabber:iq:auth"
#define NS_AUTH_CRYPT   "jabber:iq:auth:crypt"
#define NS_REGISTER   "jabber:iq:register"
#define NS_ROSTER   "jabber:iq:roster"
#define NS_OFFLINE   "jabber:x:offline"
#define NS_AGENT   "jabber:iq:agent"
#define NS_AGENTS   "jabber:iq:agents"
#define NS_DELAY   "jabber:x:delay"
#define NS_VERSION   "jabber:iq:version"
#define NS_TIME   "jabber:iq:time"
#define NS_VCARD   "vcard-temp"
#define NS_PRIVATE   "jabber:iq:private"
#define NS_SEARCH   "jabber:iq:search"
#define NS_OOB   "jabber:iq:oob"
#define NS_XOOB   "jabber:x:oob"
#define NS_FILTER   "jabber:iq:filter"
#define NS_AUTH_0K   "jabber:iq:auth:0k"
#define NS_BROWSE   "jabber:iq:browse"
#define NS_EVENT   "jabber:x:event"
#define NS_CONFERENCE   "jabber:iq:conference"
#define NS_SIGNED   "jabber:x:signed"
#define NS_ENCRYPTED   "jabber:x:encrypted"
#define NS_GATEWAY   "jabber:iq:gateway"
#define NS_LAST   "jabber:iq:last"
#define NS_ENVELOPE   "jabber:x:envelope"
#define NS_EXPIRE   "jabber:x:expire"
#define NS_PRIVACY   "jabber:iq:privacy"
#define NS_XHTML   "http://www.w3.org/1999/xhtml"
#define NS_DISCO_INFO   "http://jabber.org/protocol/disco#info"
#define NS_DISCO_ITEMS   "http://jabber.org/protocol/disco#items"
#define NS_DATA   "jabber:x:data"
#define NS_FLEXIBLE_OFFLINE   "http://jabber.org/protocol/offline"
#define NS_IQ_AUTH   "http://jabber.org/features/iq-auth"
#define NS_REGISTER_FEATURE   "http://jabber.org/features/iq-register"
#define NS_MSGOFFLINE   "msgoffline"
#define NS_BYTESTREAMS   "http://jabber.org/protocol/bytestreams"
#define NS_COMMAND   "http://jabber.org/protocol/commands"
#define NS_XDBNSLIST   "jabber:xdb:nslist"
#define NS_XMPP_STANZAS   "urn:ietf:params:xml:ns:xmpp-stanzas"
#define NS_XMPP_TLS   "urn:ietf:params:xml:ns:xmpp-tls"
#define NS_XMPP_STREAMS   "urn:ietf:params:xml:ns:xmpp-streams"
#define NS_XMPP_SASL   "urn:ietf:params:xml:ns:xmpp-sasl"
#define NS_XMPP_PING   "urn:xmpp:ping"
#define NS_JABBERD_STOREDPRESENCE   "http://jabberd.org/ns/storedpresence"
#define NS_JABBERD_STOREDPEERPRESENCE   "http://jabberd.org/ns/storedpeerpresence"
#define NS_JABBERD_STOREDREQUEST   "http://jabberd.org/ns/storedsubscriptionrequest"
#define NS_JABBERD_STOREDSTATE   "http://jabberd.org/ns/storedstate"
#define NS_JABBERD_HISTORY   "http://jabberd.org/ns/history"
#define NS_JABBERD_HASH   "http://jabberd.org/ns/hash"
#define NS_JABBERD_XDB   "http://jabberd.org/ns/xdb"
#define NS_JABBERD_WRAPPER   "http://jabberd.org/ns/wrapper"
#define NS_JABBERD_XDBSQL   "http://jabberd.org/ns/xdbsql"
#define NS_JABBERD_ACL   "http://jabberd.org/ns/acl"
#define NS_JABBERD_LOOPCHECK   "http://jabberd.org/ns/loopcheck"
#define NS_JABBERD_ERRMSG   "http://jabberd.org/ns/errmsg"
#define NS_SESSION   "http://jabberd.jabberstudio.org/ns/session/1.0"
#define NS_XMLNS   "http://www.w3.org/2000/xmlns/"
#define NS_XML   "http://www.w3.org/XML/1998/namespace"
#define NS_JABBERD_CONFIGFILE   "http://jabberd.org/ns/configfile"
#define NS_JABBERD_CONFIGFILE_REPLACE   "http://jabberd.org/ns/configfile/replace"
#define NS_JABBERD_CONFIGFILE_ROUTER   "http://xmppd.org/ns/configfile/router"
#define NS_JABBERD_CONFIG_XDBFILE   "jabber:config:xdb_file"
#define NS_JABBERD_CONFIG_DIALBACK   "jabber:config:dialback"
#define NS_JABBERD_CONFIG_DNSRV   "jabber:config:dnsrv"
#define NS_JABBERD_CONFIG_JSM   "jabber:config:jsm"
#define NS_JABBERD_CONFIG_PTHCSOCK   "jabber:config:pth-csock"
#define NS_JABBERD_CONFIG_XDBSQL   "jabber:config:xdb_sql"
#define NS_JABBERD_CONFIG_DYNAMICHOST   "http://xmppd.org/ns/dynamichost"

Typedefs

typedef void(* pool_cleaner )(void *arg)
typedef struct pool_struct _pool
typedef struct pool_structpool
typedef unsigned int uint32
typedef xmppd::xhash< void * > * xht
typedef void(* xhash_walker )(xht h, const char *key, void *val, void *arg)
typedef struct xmlnode_t _xmlnode
typedef struct xmlnode_txmlnode
typedef std::vector< xmlnodexmlnode_vector
typedef void(* xstream_onNode )(int type, xmlnode x, void *arg)
typedef struct xstream_structxstream
typedef struct xstream_struct _xstream
typedef struct streamerr_structstreamerr
typedef struct streamerr_struct _streamerr
typedef xmppd::jabberid_pooljid
typedef struct jpacket_structjpacket
typedef struct jpacket_struct _jpacket
typedef struct jlimit_structjlimit
typedef struct jlimit_struct _jlimit
typedef struct terror_struct terror
typedef struct xterror_struct xterror

Enumerations

enum  streamerr_reason {
  unknown_error_type, bad_format, bad_namespace_prefix, conflict,
  connection_timeout, host_gone, host_unknown, improper_addressing,
  internal_server_error, invalid_from, invalid_id, invalid_namespace,
  invalid_xml, not_authorized, policy_violation, remote_connection_failed,
  resource_constraint, restricted_xml, see_other_host, system_shutdown,
  undefined_condition, unsupported_encoding, unsupported_stanza_type, unsupported_version,
  xml_not_well_formed
}
enum  streamerr_severity {
  normal, configuration, feature_lack, unknown,
  error
}

Functions

char * zonestr (char const *file, int line)
pool _pool_new (char *zone, int line)
pool _pool_new_heap (int size, char *zone, int line)
void * pmalloc (pool p, int size)
void * pmalloc_x (pool p, int size, char c)
void * pmalloco (pool p, int size)
char * pstrdup (pool p, const char *src)
void pool_stat (int full)
char * pstrdupx (pool p, const char *src)
void pool_cleanup (pool p, pool_cleaner f, void *arg)
void pool_free (pool p)
int pool_size (pool p)
int make_netsocket (u_short port, char const *host, int type)
int make_netsocket2 (Glib::ustring servname, Glib::ustring nodename, int type)
struct in_addr * make_addr (char const *host)
char * j_strdup (const char *str)
char * j_strcat (char *dest, char *txt)
int j_strcmp (const char *a, const char *b)
int j_strcasecmp (const char *a, const char *b)
int j_strncmp (const char *a, const char *b, int i)
int j_strncasecmp (const char *a, const char *b, int i)
int j_strlen (const char *a)
int j_atoi (const char *a, int def)
void str_b64decode (char *str)
int base64_encode (unsigned char *source, size_t sourcelen, char *target, size_t targetlen)
size_t base64_decode (const char *source, unsigned char *target, size_t targetlen)
char * shahash (char const *str)
void shahash_r (const char *str, char hashbuf[41])
void shaBlock (unsigned char *dataIn, int len, unsigned char hashout[20])
void crc32_r (const char *str, char crc32buf[9])
xht xhash_new (int prime)
void xhash_put (xht h, const char *key, void *val)
void * xhash_get (xht h, const char *key)
void * xhash_get_by_domain (xht h, const char *domain)
void xhash_zap (xht h, const char *key)
void xhash_free (xht h)
void xhash_walk (xht h, xhash_walker w, void *arg)
char * strescape (pool p, char *buf)
char * strunescape (pool p, char *buf)
std::string strescape (std::string s)
xmlnode xmlnode_wrap (xmlnode x, const char *wrapper)
xmlnode xmlnode_wrap_ns (xmlnode x, const char *name, const char *prefix, const char *ns_iri)
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_insert_tag_node (xmlnode parent, xmlnode node)
void xmlnode_insert_node (xmlnode parent, xmlnode node)
xmlnode xmlnode_str (const char *str, int len)
xmlnode xmlnode_file (const char *file)
char const * xmlnode_file_borked (char const *file)
xmlnode xmlnode_dup (xmlnode x)
xmlnode xmlnode_dup_pool (pool p, xmlnode x)
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)
void xmlnode_free (xmlnode node)
xmlnode xmlnode_get_tag (xmlnode parent, const char *name)
char * xmlnode_get_tag_data (xmlnode parent, const char *name)
xmlnode_vector xmlnode_get_tags (xmlnode context_node, const char *path, xht namespaces)
xmlnode xmlnode_get_list_item (const xmlnode_vector &first, unsigned int i)
char * xmlnode_get_list_item_data (const xmlnode_vector &first, unsigned int i)
xmlnode xmlnode_select_by_lang (const xmlnode_vector &nodes, const char *lang)
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)
void xmlnode_put_expat_attribs (xmlnode owner, const char **atts, xmppd::ns_decl_list &nslist)
const char * xmlnode_get_lang (xmlnode node)
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)
char * xmlnode_get_data (xmlnode node)
int xmlnode_get_type (xmlnode node)
const char * xmlnode_get_localname (xmlnode node)
const char * xmlnode_get_namespace (xmlnode node)
const char * xmlnode_get_nsprefix (xmlnode node)
void xmlnode_change_namespace (xmlnode node, const char *ns_iri)
int xmlnode_has_children (xmlnode node)
char * xmlnode_serialize_string (xmlnode_t const *node, const xmppd::ns_decl_list &nslist, int stream_type)
int xmlnode2file (char const *file, xmlnode node)
int xmlnode2file_limited (char const *file, xmlnode node, size_t sizelimit)
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 xhash_to_xml (xht h)
xht xhash_from_xml (xmlnode hash, pool p)
xstream xstream_new (pool p, xstream_onNode f, void *arg)
int xstream_eat (xstream xs, char *buff, int len)
xmlnode xstream_header (const char *to, const char *from)
char * xstream_header_char (xmlnode x, int stream_type)
void xstream_format_error (std::ostream &out, streamerr errstruct)
streamerr_severity xstream_parse_error (pool p, xmlnode errnode, streamerr errstruct)
void shaInit (j_SHA_CTX *ctx)
void shaUpdate (j_SHA_CTX *ctx, unsigned char *dataIn, int len)
void shaFinal (j_SHA_CTX *ctx, unsigned char hashout[20])
void hmac_sha1_ascii_r (char const *secret, unsigned char const *message, size_t len, char hmac[41])
jid jid_new (pool p, const char *idstr)
void jid_set (jid id, const char *str, int item)
char * jid_full (jid id)
int jid_cmp (jid a, jid b)
int jid_cmpx (jid a, jid b, int parts)
jid jid_user (jid a)
jid jid_user_pool (jid a, pool p)
jid jid_append (jid a, jid b)
jpacket jpacket_new (xmlnode x)
jpacket jpacket_reset (jpacket p)
int jpacket_subtype (jpacket p)
jlimit jlimit_new (int maxt, int maxp)
void jlimit_free (jlimit r)
int jlimit_check (jlimit r, char *key, int points)
struct karmakarma_new (pool p)
void karma_copy (struct karma *new_instance, struct karma *old)
void karma_increment (struct karma *k)
void karma_decrement (struct karma *k, long bytes_read)
int karma_check (struct karma *k, long bytes_read)
xmlnode jutil_presnew (int type, char const *to, const char *status)
xmlnode jutil_iqnew (int type, char const *ns)
xmlnode jutil_msgnew (char const *type, char const *to, char const *subj, char const *body)
int jutil_priority (xmlnode x)
void jutil_tofrom (xmlnode x)
xmlnode jutil_iqresult (xmlnode x)
char * jutil_timestamp (void)
char * jutil_timestamp_ms (char *buffer)
void jutil_error (xmlnode x, terror E)
void jutil_error_xmpp (xmlnode x, xterror E)
void jutil_error_map (terror old, xterror *mapped)
void jutil_delay (xmlnode msg, char const *reason)
char * jutil_regkey (char *key, char *seed)
void messages_set_mapping (const char *lang, const char *locale_name)
const char * messages_get (const char *lang, const char *message)
std::ostream & xmppd::lwresc::operator<< (std::ostream &os, const lwquery &lwq)

Define Documentation

#define HAS_XTERROR
#define JID_RESOURCE   1
#define JID_SERVER   4
#define JID_USER   2
#define JPACKET__AVAILABLE   12

Referenced by jpacket_reset(), and js_online().

#define JPACKET__CHAT   3

Referenced by jpacket_subtype().

#define JPACKET__ERROR   2
#define JPACKET__GET   5
#define JPACKET__GROUPCHAT   4
#define JPACKET__HEADLINE   15
#define JPACKET__INVISIBLE   16
#define JPACKET__NONE   1

Referenced by jpacket_subtype().

#define JPACKET__PROBE   14

Referenced by jpacket_reset(), and jutil_presnew().

#define JPACKET__RESULT   7

Referenced by jpacket_subtype(), and jutil_iqnew().

#define JPACKET__SET   6
#define JPACKET__SUBSCRIBE   8

Referenced by jpacket_subtype(), and jutil_presnew().

#define JPACKET__SUBSCRIBED   9

Referenced by jpacket_subtype(), and jutil_presnew().

#define JPACKET__UNAVAILABLE   13
#define JPACKET__UNKNOWN   0

Referenced by jpacket_subtype().

#define JPACKET__UNSUBSCRIBE   10

Referenced by jpacket_subtype(), and jutil_presnew().

#define JPACKET__UNSUBSCRIBED   11

Referenced by jpacket_subtype(), and jutil_presnew().

#define JPACKET_IQ   0x04
#define JPACKET_MESSAGE   0x01
#define JPACKET_PRESENCE   0x02
#define JPACKET_S10N   0x08
#define JPACKET_UNKNOWN   0x00

Referenced by _js_session_from(), and jpacket_reset().

#define KARMA_DEC   0
#define KARMA_HEARTBEAT   2

Referenced by karma_increment(), and mio_init().

#define KARMA_INC   1
#define KARMA_INIT   5
#define KARMA_MAX   10
#define KARMA_PENALTY   -5
#define KARMA_READ_MAX (  )     (abs(k)*100)

Referenced by karma_decrement(), and karma_increment().

#define KARMA_RESETMETER   0
#define KARMA_RESTORE   5
#define MAXHOSTNAMELEN   64

Referenced by make_addr().

#define MAXSHORTSTR   203
#define N_ (  )     (n)
#define NETSOCKET_CLIENT   1

type of a connection socket

Referenced by make_netsocket().

#define NETSOCKET_SERVER   0

type of a local listening socket

Referenced by make_netsocket(), and mio_listen().

#define NETSOCKET_UDP   2

type of a UDP connection socket

Referenced by make_netsocket().

#define NS_AGENT   "jabber:iq:agent"
#define NS_AGENTS   "jabber:iq:agents"
#define NS_AUTH   "jabber:iq:auth"
#define NS_AUTH_0K   "jabber:iq:auth:0k"
#define NS_AUTH_CRYPT   "jabber:iq:auth:crypt"

Referenced by js_user().

#define NS_BROWSE   "jabber:iq:browse"

Referenced by jsm().

#define NS_BYTESTREAMS   "http://jabber.org/protocol/bytestreams"
#define NS_CLIENT   "jabber:client"
#define NS_COMMAND   "http://jabber.org/protocol/commands"

Referenced by jsm().

#define NS_COMPONENT_ACCEPT   "jabber:component:accept"
#define NS_CONFERENCE   "jabber:iq:conference"
#define NS_DATA   "jabber:x:data"

Referenced by jsm().

#define NS_DELAY   "jabber:x:delay"

Referenced by jsm(), and jutil_delay().

#define NS_DIALBACK   "jabber:server:dialback"
#define NS_DISCO_INFO   "http://jabber.org/protocol/disco#info"

Referenced by dialback(), and jsm().

#define NS_DISCO_ITEMS   "http://jabber.org/protocol/disco#items"
#define NS_ENCRYPTED   "jabber:x:encrypted"
#define NS_ENVELOPE   "jabber:x:envelope"
#define NS_EVENT   "jabber:x:event"
#define NS_EXPIRE   "jabber:x:expire"

Referenced by jsm().

#define NS_FILTER   "jabber:iq:filter"
#define NS_FLASHSTREAM   "http://www.jabber.com/streams/flash"
#define NS_FLEXIBLE_OFFLINE   "http://jabber.org/protocol/offline"
#define NS_GATEWAY   "jabber:iq:gateway"
#define NS_IQ_AUTH   "http://jabber.org/features/iq-auth"
#define NS_JABBERD_ACL   "http://jabberd.org/ns/acl"

namespace for access control lists

Referenced by acl_get_users().

#define NS_JABBERD_CONFIG_DIALBACK   "jabber:config:dialback"

namespace of dialback component configuration

Referenced by dialback().

#define NS_JABBERD_CONFIG_DNSRV   "jabber:config:dnsrv"

namespace of the dnsrv component configuration

Referenced by dnsrv(), and xmppd::resolver::resend_service::resend_service().

#define NS_JABBERD_CONFIG_DYNAMICHOST   "http://xmppd.org/ns/dynamichost"

namespace of the dynamic configuration of additional hosts for components

Referenced by jsm(), and mod_dynamic().

#define NS_JABBERD_CONFIG_JSM   "jabber:config:jsm"

namespace of the jsm component configuration

Referenced by js_config(), jsm(), and mod_presence().

#define NS_JABBERD_CONFIG_PTHCSOCK   "jabber:config:pth-csock"

namespace of the pthsock_client component configuration

Referenced by pthsock_client().

#define NS_JABBERD_CONFIG_XDBFILE   "jabber:config:xdb_file"

namespace of xdb_file component configuration

Referenced by main(), and xdb_file().

#define NS_JABBERD_CONFIG_XDBSQL   "jabber:config:xdb_sql"

namepace of the xdb_sql component configuration

Referenced by xdb_sql().

#define NS_JABBERD_CONFIGFILE   "http://jabberd.org/ns/configfile"
#define NS_JABBERD_CONFIGFILE_REPLACE   "http://jabberd.org/ns/configfile/replace"

namespace of replace and include commands

Referenced by main().

#define NS_JABBERD_CONFIGFILE_ROUTER   "http://xmppd.org/ns/configfile/router"

namespace for global router configuration

Referenced by deliver().

#define NS_JABBERD_ERRMSG   "http://jabberd.org/ns/errmsg"

namespace for session control error messages

Referenced by deliver_fail().

#define NS_JABBERD_HASH   "http://jabberd.org/ns/hash"

namespace for storing xhash data

Referenced by xhash_from_xml(), and xhash_to_xml().

#define NS_JABBERD_HISTORY   "http://jabberd.org/ns/history"

Referenced by _js_session_from(), and _js_session_to().

#define NS_JABBERD_LOOPCHECK   "http://jabberd.org/ns/loopcheck"

namespace for loopchecking of s2s connections

Referenced by dialback_in_read(), and dialback_out_read().

#define NS_JABBERD_STOREDPEERPRESENCE   "http://jabberd.org/ns/storedpeerpresence"
#define NS_JABBERD_STOREDPRESENCE   "http://jabberd.org/ns/storedpresence"
#define NS_JABBERD_STOREDREQUEST   "http://jabberd.org/ns/storedsubscriptionrequest"
#define NS_JABBERD_STOREDSTATE   "http://jabberd.org/ns/storedstate"

namespace to store internal state of jabberd

Referenced by jsm(), and jsm_serialize().

#define NS_JABBERD_WRAPPER   "http://jabberd.org/ns/wrapper"

namespace used to wrap various internal data

Referenced by dialback(), dialback_ip_set(), dialback_out_connection(), and jsm().

#define NS_JABBERD_XDB   "http://jabberd.org/ns/xdb"

namespace for the root element used by xdb_file to store data in files

Referenced by xdb_file(), xdb_file_load(), and xdb_file_phandler().

#define NS_JABBERD_XDBSQL   "http://jabberd.org/ns/xdbsql"

namespace for substitution in xdb_sql configuration

#define NS_LAST   "jabber:iq:last"

Referenced by _js_authreg_register().

#define NS_MSGOFFLINE   "msgoffline"
#define NS_OFFLINE   "jabber:x:offline"
#define NS_OOB   "jabber:iq:oob"
#define NS_PRIVACY   "jabber:iq:privacy"

Referenced by jsm().

#define NS_PRIVATE   "jabber:iq:private"

Referenced by jsm().

#define NS_REGISTER   "jabber:iq:register"
#define NS_REGISTER_FEATURE   "http://jabber.org/features/iq-register"
#define NS_ROSTER   "jabber:iq:roster"

Referenced by jsm().

#define NS_SEARCH   "jabber:iq:search"
#define NS_SERVER   "jabber:server"
#define NS_SESSION   "http://jabberd.jabberstudio.org/ns/session/1.0"
#define NS_SIGNED   "jabber:x:signed"
#define NS_STREAM   "http://etherx.jabber.org/streams"
#define NS_TIME   "jabber:iq:time"
#define NS_VCARD   "vcard-temp"

Referenced by jsm().

#define NS_VERSION   "jabber:iq:version"
#define NS_XDBNSLIST   "jabber:xdb:nslist"
#define NS_XHTML   "http://www.w3.org/1999/xhtml"
#define NS_XML   "http://www.w3.org/XML/1998/namespace"

namespace declared by the xml prefix, defined by 'Namespaces in XML' (W3C)

Referenced by xmppd::ns_decl_list::ns_decl_list(), xmlnode_get_lang(), xmlnode_put_attrib(), and xmlnode_wrap_ns().

#define NS_XMLNS   "http://www.w3.org/2000/xmlns/"
#define NS_XMPP_PING   "urn:xmpp:ping"
#define NS_XMPP_SASL   "urn:ietf:params:xml:ns:xmpp-sasl"
#define NS_XMPP_STANZAS   "urn:ietf:params:xml:ns:xmpp-stanzas"

Referenced by jutil_error_xmpp().

#define NS_XMPP_STREAMS   "urn:ietf:params:xml:ns:xmpp-streams"

Referenced by xstream_parse_error().

#define NS_XMPP_TLS   "urn:ietf:params:xml:ns:xmpp-tls"
#define NS_XOOB   "jabber:x:oob"

Referenced by jsm().

#define NSCHECK ( x,
 )     (j_strcmp(xmlnode_get_namespace(x), n) == 0)

Referenced by js_authreg(), and mod_presence().

#define NTYPE_ATTRIB   1
#define NTYPE_CDATA   2
#define NTYPE_LAST   2

highest possible value of xmlnode types

#define NTYPE_TAG   0
#define NTYPE_UNDEF   -1

xmlnode has no defined type

Referenced by xmlnode_get_type().

#define pool_heap (  )     _pool_new_heap(i, NULL, 0)
 
#define pool_new (  )     _pool_new(NULL, 0)
#define QUAD_T   unsigned long long
#define TERROR_AUTH   (terror){401,"Unauthorized"}
#define TERROR_BAD   (terror){400,"Bad Request"}
#define TERROR_CONFLICT   (terror){409,"Conflict"}
#define TERROR_DISCONNECTED   (terror){510,"Disconnected"}
#define TERROR_EXTERNAL   (terror){502,"Remote Server Error"}
#define TERROR_EXTTIMEOUT   (terror){504,"Remote Server Timeout"}
#define TERROR_FORBIDDEN   (terror){403,"Forbidden"}
#define TERROR_INTERNAL   (terror){500,"Internal Server Error"}
#define TERROR_NOTACCEPTABLE   (terror){406,"Not Acceptable"}
#define TERROR_NOTALLOWED   (terror){405,"Not Allowed"}
#define TERROR_NOTFOUND   (terror){404,"Not Found"}
#define TERROR_NOTIMPL   (terror){501,"Not Implemented"}
#define TERROR_PAY   (terror){402,"Payment Required"}
#define TERROR_REGISTER   (terror){407,"Registration Required"}
#define TERROR_REQTIMEOUT   (terror){408,"Request Timeout"}
#define TERROR_UNAVAIL   (terror){503,"Service Unavailable"}
#define VA_END   va_end(ap)
#define VA_LOCAL_DECL   va_list ap;
#define VA_START (  )     va_start(ap)
#define XMLNS_SEPARATOR   ' '

character used to separate NS IRI from local name in expat callbacks

Referenced by _mio_xstream_init(), expat_startElement(), xmlnode_file(), xmlnode_file_borked(), xmlnode_put_expat_attribs(), xmlnode_str(), and xstream_new().

#define XSTREAM_CLOSE   2
#define XSTREAM_ERR   4

Referenced by xstream_eat().

#define XSTREAM_MAXDEPTH   100
#define XSTREAM_MAXNODE   1000000

Referenced by xstream_eat().

#define XSTREAM_NODE   1
#define XSTREAM_ROOT   0
#define XTERROR_AUTH   (xterror){401, N_("Unauthorized"), "auth", "not-authorized"}

Referenced by _js_authreg_auth().

#define XTERROR_BAD   (xterror){400, N_("Bad Request"),"modify","bad-request"}

Referenced by _js_session_from(), and js_deliver().

#define XTERROR_CONFLICT   (xterror){409, N_("Conflict"), "cancel", "conflict"}
#define XTERROR_DISCONNECTED   (xterror){510, N_("Disconnected"), "cancel", "service-unavailable"}
#define XTERROR_EXTERNAL   (xterror){502, N_("Remote Server Error"), "wait", "service-unavailable"}

Referenced by deliver_fail().

#define XTERROR_EXTTIMEOUT   (xterror){504, N_("Remote Server Timeout"), "wait", "remote-server-timeout"}
#define XTERROR_FORBIDDEN   (xterror){403, N_("Forbidden"), "auth", "forbidden"}
#define XTERROR_GONE   (xterror){302, N_("Gone"), "modify", "gone"}
#define XTERROR_INTERNAL   (xterror){500, N_("Internal Server Error"), "wait", "internal-server-error"}
#define XTERROR_JIDMALFORMED   (xterror){400, N_("Bad Request"), "modify", "jid-malformed"}
#define XTERROR_NOTACCEPTABLE   (xterror){406, N_("Not Acceptable"), "modify", "not-acceptable"}

Referenced by _js_authreg_register(), and js_authreg().

#define XTERROR_NOTALLOWED   (xterror){405, N_("Not Allowed"), "cancel", "not-allowed"}
#define XTERROR_NOTFOUND   (xterror){404, N_("Not Found"), "cancel", "item-not-found"}

Referenced by js_server_main().

#define XTERROR_NOTIMPL   (xterror){501, N_("Not Implemented"), "cancel", "feature-not-implemented"}
#define XTERROR_PAY   (xterror){402, N_("Payment Required"), "auth", "payment-required"}
#define XTERROR_RECIPIENTUNAVAIL   (xterror){404, N_("Recipient Is Unavailable"), "wait", "recipient-unavailable"}

Referenced by js_offline_main().

#define XTERROR_REDIRECT   (xterror){302, N_("Redirect"), "modify", "redirect"}
#define XTERROR_REGISTER   (xterror){407, N_("Registration Required"), "auth", "registration-required"}
#define XTERROR_REMOTENOTFOUND   (xterror){404, N_("Remote Server Not Found"), "cancel", "remote-server-not-found"}
#define XTERROR_REMOTETIMEOUT   (xterror){504, N_("Remote Server Timeout"), "wait", "remote-server-timeout"}
#define XTERROR_REQTIMEOUT   (xterror){408, N_("Request Timeout"), "wait", "remote-server-timeout"}
#define XTERROR_RESCONSTRAINT   (xterror){500, N_("Resource Constraint"), "wait", "resource-constraint"}
#define XTERROR_STORAGE_FAILED   (xterror){500, N_("Storage Failed"), "wait", "internal-server-error"}
#define XTERROR_SUBSCRIPTIONREQ   (xterror){407, N_("Subscription Required"), "auth", "subscription-required"}
#define XTERROR_UNAVAIL   (xterror){503, N_("Service Unavailable"), "cancel", "service-unavailable"}

Referenced by _js_authreg_register().

#define XTERROR_UNDEF_AUTH   (xterror){500, NULL, "auth", "undefined-condition"}
#define XTERROR_UNDEF_CANCEL   (xterror){500, NULL, "cancel", "undefined-condition"}
#define XTERROR_UNDEF_CONTINUE   (xterror){500, NULL, "continue", "undefined-condition"}
#define XTERROR_UNDEF_MODIFY   (xterror){500, NULL, "modify", "undefined-condition"}
#define XTERROR_UNDEF_WAIT   (xterror){500, NULL, "wait", "undefined-condition"}
#define XTERROR_UNEXPECTED   (xterror){400, N_("Unexpected Request"), "wait", "unexpected-request"}
#define ZONE   zonestr(__FILE__,__LINE__)

Referenced by _dialback_beat_idle(), _dialback_beat_in_idle(), _dialback_beat_out_idle(), _dialback_miod_hash_cleanup(), _js_authreg_auth(), _js_authreg_register(), _js_hosts_del(), _js_session_end(), _js_session_from(), _js_session_to(), _js_users_del(), _jsm_shutdown(), _mio_ssl_cleanup(), _mio_ssl_read(), _mio_ssl_write(), _mio_tls_cont_handshake_server(), _mio_write_dump(), _mio_xml_parser(), _xdb_file_purge(), _xdb_get_hashes(), acl_check_access(), base_accept(), base_connect(), base_dir(), base_file(), base_format(), base_importspool(), base_load(), base_stderr(), base_stdout(), base_syslog(), base_syslog_config(), base_to(), base_unsubscribe(), xmppd::proxy65::connected_sockets::connected_sockets(), deliver(), deliver_config_filter(), deliver_fail(), dialback(), dialback_beat_idle(), dialback_check_settings(), dialback_in_read(), dialback_in_read_db(), dialback_in_verify(), dialback_ip_get(), dialback_ip_set(), dialback_merlin(), dialback_miod_hash(), dialback_out_connect(), dialback_out_connection(), dialback_out_packet(), dialback_out_read(), dialback_out_read_db(), dnsrv(), dnsrv_child_main(), dnsrv_child_process_xstream_io(), dnsrv_lookup(), dnsrv_process_io(), dnsrv_process_xstream_io(), dnsrv_resend(), js_bounce_xmpp(), js_config(), js_deliver(), js_mapi_call2(), js_mapi_register(), js_mapi_session(), js_offline_main(), js_packet(), js_psend(), js_sc_session_new(), js_server_main(), js_session_end(), js_session_from(), js_session_new(), js_session_to(), js_user(), js_users_gc(), jsm(), jsm_shutdown(), log_generic(), logger(), main(), mio_close(), mio_listen(), mio_new(), mio_ssl_init(), mio_ssl_starttls(), mio_stop(), mio_write(), mio_xml_starttls(), mod_agents(), mod_auth_crypt(), mod_auth_digest(), mod_auth_plain(), mod_last(), mod_log(), mod_offline(), mod_presence(), mod_privacy(), mod_register(), mod_useridpolicy(), mtq_new(), mtq_send(), pthsock_client(), register_instance(), register_routing_update_callback(), xmppd::proxy65::socks5stub::socks5stub(), srv_lookup(), unregister_instance(), xdb_convert_spool(), xdb_file(), xdb_file_load(), xdb_file_phandler(), xdb_file_purge(), xdb_get(), and xdb_sql().


Typedef Documentation

typedef struct jlimit_struct _jlimit
typedef struct jpacket_struct _jpacket
typedef struct pool_struct _pool
typedef struct streamerr_struct _streamerr
typedef struct xmlnode_t _xmlnode
typedef struct xstream_struct _xstream
typedef struct jlimit_struct * jlimit
typedef struct jpacket_struct * jpacket
typedef struct pool_struct * pool
typedef void(* pool_cleaner)(void *arg)
typedef struct streamerr_struct * streamerr

structure that contains information about a stream error

typedef struct terror_struct terror
typedef unsigned int uint32
typedef void(* xhash_walker)(xht h, const char *key, void *val, void *arg)
typedef xmppd::xhash<void*>* xht
typedef struct xmlnode_t * xmlnode
typedef std::vector<xmlnode> xmlnode_vector

container, that contains a vector of xmlnodes

This has been a pointer to a special struct in former versions of jabberd14, but we are now using a standard container. Declaring this type to keep the syntax of the interface. So don't be confused by the name of this type, it is not a single item but the complete vector.

typedef struct xstream_struct * xstream
typedef void(* xstream_onNode)(int type, xmlnode x, void *arg)
typedef struct xterror_struct xterror

Enumeration Type Documentation

error cause types for streams, see section 4.7.3 of RFC 3920

Enumerator:
unknown_error_type 

no errror type found, especially legacy stream errors

bad_format 

XML cannot be processed

bad_namespace_prefix 

unsupported namespace prefix

conflict 

new stream has been initiated, that conflicts

connection_timeout 

no traffic on the stream for some time

host_gone 

hostname is no longer hosted on this server

host_unknown 

hostname is not known by this server

improper_addressing 

missing to or from attribute

internal_server_error 

missconfiguration or something like that

invalid_from 

from address is not authorzed

invalid_id 

invalid stream id

invalid_namespace 

wrong namespace for stream or dialback

invalid_xml 

invalid XML was found

not_authorized 

session not authorized

policy_violation 

local service policy violated

remote_connection_failed 

could not connect to a required remote entity for auth

resource_constraint 

server lacks system resources

restricted_xml 

received restricted XML features

see_other_host 

redirection to another host

system_shutdown 

server is being shut down

undefined_condition 

something else ...

unsupported_encoding 

stream is coded in an unsupported encoding

unsupported_stanza_type 

stanza is not supported

unsupported_version 

XMPP version requested is not supported

xml_not_well_formed 

received XML, that is not well formed

severity of stream error (well all stream errors are unrecoverable, but we might log them different

Enumerator:
normal 

something that is just normal to happen (e.g. connection timeout)

configuration 

something that seems to be caused by configuration errors (e.g. host gone)

feature_lack 

something caused by features not supported by the other end (e.g. unsupported version)

unknown 

absolutely no clue

error 

something that shut not happen in any case and seems to be an implementation error (e.g. xml_not_well_formed)


Function Documentation

pool _pool_new ( char *  zone,
int  line 
)

make an empty pool

Use the macro pool_new() instead of a direct call to this function. The macro will create the parameters for you.

Parameters:
zone the file in which the pool_new macro is called
line the line in the file in which the pool_new macro is called
Returns:
the new allocated memory pool

References _retried__malloc(), pool_struct::cleanup, pool_struct::heap, pool_struct::size, xhash_new(), and xhash_put().

Referenced by _pool_new_heap().

pool _pool_new_heap ( int  size,
char *  zone,
int  line 
)

create a new memory pool and set the initial heap size

Note:
you should not call this function but use the macro pool_heap instead which fills zone and line automatically
Parameters:
size the initial size of the memory pool
zone the file where this function is called (for debugging)
line the line in the file where this function is called
Returns:
the new memory pool

References _pool_heap(), _pool_new(), and pool_struct::heap.

size_t base64_decode ( const char *  source,
unsigned char *  target,
size_t  targetlen 
)

decode base64 encoded data

Parameters:
source the encoded data (zero terminated)
target pointer to the target buffer
targetlen length of the target buffer
Returns:
length of converted data on success, -1 otherwise

Referenced by dialback_in_read_db(), and str_b64decode().

int base64_encode ( unsigned char *  source,
size_t  sourcelen,
char *  target,
size_t  targetlen 
)

encode an array of bytes using Base64 (RFC 3548)

Parameters:
source the source buffer
sourcelen the length of the source buffer
target the target buffer
targetlen the length of the target buffer
Returns:
1 on success, 0 otherwise

Referenced by dialback_out_read().

void crc32_r ( const char *  str,
char  crc32buf[9] 
)

calculate a 32 bit CRC value with the polynom c(x) = 1+x+x^2+x^4+x^5+x^7+x^8+x^10+x^11+x^12+x^16+x^22+x^23+x^26+x^32 on a given string. We are initializing with zero and we are not inverting the result

Parameters:
str the string for which we calculate the CRC
crc32buf where to put the result

References CRC32_UPDATE.

Referenced by _xdb_get_hashes().

void expat_charData ( void *  userdata,
const char *  s,
int  len 
)

callback function for CDATA nodes

This function will insert CDATA in an xmlnode

Parameters:
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.

Parameters:
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.

Parameters:
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(), j_strcmp(), _expat_callback_data::ns, NS_DIALBACK, NS_STREAM, _expat_callback_data::parse_pool, pstrdup(), _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().

void hmac_sha1_ascii_r ( char const *  secret,
unsigned char const *  message,
size_t  len,
char  hmac[41] 
)

Calculate the HMAC-SHA1 for a given block of data, the result a string containing the hmac as hex value

Parameters:
secret the key to use
message the message to calculate the HMAC-SHA1 for
len the length of the message in bytes
hmac where to place the result

Referenced by dialback_get_loopcheck_token(), and dialback_merlin().

int j_atoi ( const char *  a,
int  def 
)
int j_strcasecmp ( const char *  a,
const char *  b 
)

NULL pointer save version of strcasecmp()

If one of the parameters contains a NULL pointer, the string is considered to be unequal

Parameters:
a the one string
b the other string
Returns:
0 if the strings are equal, non zero else

Referenced by dialback_in_read_db(), dialback_out_read(), and xmlnode_select_by_lang().

char* j_strcat ( char *  dest,
char *  txt 
)

NULL pointer save version of strcat()

Note:
the return value of j_strcat() is not compatible with the return value of strcat()
Todo:
check if the behaviour of the return value is intended
Parameters:
dest where to append the string
txt what to append
Returns:
dest if txt contains a NULL pointer, pointer to the terminating zero byte of the result else
int j_strcmp ( const char *  a,
const char *  b 
)
char* j_strdup ( const char *  str  ) 

NULL pointer save version of strdup()

Parameters:
str the string the should be duplicated
Returns:
the duplicated string
int j_strlen ( const char *  a  ) 

NULL pointer save version of strlen

If the parameter contains a NULL pointer, 0 is returned

Parameters:
a the string for which the length should be calculated
Returns:
0 if a==NULL, length of the string else

Referenced by dialback_in_read_db(), js_session_get(), jutil_msgnew(), jutil_presnew(), log_generic(), logger(), main(), srv_lookup(), xdb_file_phandler(), and xmlnode2file_limited().

int j_strncasecmp ( const char *  a,
const char *  b,
int  i 
)

NULL pointer save version of strncasecmp()

If one of the parameters contains a NULL pointer, the string is considered to be unequal

Parameters:
a the first string
b the second string
i how many characters to compare at most
Returns:
0 if the strings are equal (within the given length limitation), non zero else
int j_strncmp ( const char *  a,
const char *  b,
int  i 
)

NULL pointer save version of strncmp()

If one of the parameters contains a NULL pointer, the string is considered to be unequal

Parameters:
a the first string
b the second string
i how many characters to compare at most
Returns:
0 if the strings are equal (within the given length limitation), non zero else

Referenced by dialback_check_settings(), js_session_get(), xmlnode_get_attrib(), xmlnode_hide_attrib(), and xmlnode_put_attrib().

jid jid_append ( jid  a,
jid  b 
)
int jid_cmp ( jid  a,
jid  b 
)

Referenced by _js_session_from(), and jid_append().

int jid_cmpx ( jid  a,
jid  b,
int  parts 
)
char* jid_full ( jid  id  ) 
jid jid_new ( pool  p,
const char *  idstr 
)
void jid_set ( jid  id,
const char *  str,
int  item 
)
jid jid_user ( jid  a  ) 
jid jid_user_pool ( jid  a,
pool  p 
)

Returns the same jid but without the resource.

Returns the jid, if it does not contain a resource, else a new jid is created.

If memory needs to be allocated, the given memory pool is used.

Parameters:
a the original jid
p the memory pool to use
Returns:
the jid without the resource

References xmppd::jabberid::get_user(), and jid_new().

Referenced by _js_session_from(), and jid_user().

int jlimit_check ( jlimit  r,
char *  key,
int  points 
)

update/check a key in a jlimit instance

Each jlimit instance can track many limits (that have the same setup). The limit is selected by the key, which can be an IP address.

Parameters:
r the jlimit instance
key for which key the limit should be checked
points how many points of the limit should be consumed
Returns:
1 if limit reached, 0 if we are still within the rate limit

References j_strcmp(), jlimit_struct::key, jlimit_struct::maxp, jlimit_struct::maxt, jlimit_struct::points, and jlimit_struct::start.

void jlimit_free ( jlimit  r  ) 

free a jlimit instance

Parameters:
r the jlimit instance that should be freed

References jlimit_struct::key, jlimit_struct::p, and pool_free().

Referenced by mio_rate().

jlimit jlimit_new ( int  maxt,
int  maxp 
)

create a new instance of jlimit that is used to limit events

limit the events to maxp points per maxt seconds

Parameters:
maxt time interval (in seconds) after which the points are cleared
maxp maximum number of points available for the time interval given in maxt
Returns:
new instance of jlimit (has to be freed with jlimit_free if not used anymore)

References jlimit_struct::key, jlimit_struct::maxp, jlimit_struct::maxt, jlimit_struct::p, pmalloc(), jlimit_struct::points, pool_new, and jlimit_struct::start.

Referenced by mio_rate().

jpacket jpacket_new ( xmlnode  x  ) 

create a new jpacket by wrapping an xmlnode

Parameters:
x the xmlnode that should be wrapped
Returns:
the newly created jpacket (NULL on failure)

References jpacket_reset(), pmalloc(), jpacket_struct::x, and xmlnode_pool().

Referenced by _js_routed_packet(), dialback_miod_read(), js_bounce_xmpp(), js_mapi_create_additional_iq_result(), js_packet(), and xmppd::instance_base::on_stanza_packet().

jpacket jpacket_reset ( jpacket  p  ) 
int jpacket_subtype ( jpacket  p  ) 
void jutil_delay ( xmlnode  msg,
char const *  reason 
)
void jutil_error ( xmlnode  x,
terror  E 
)

wrapper around jutil_error_xmpp for compatibility with modules for jabberd up to version 1.4.3

Deprecated:
use jutil_error_xmpp instead!
Parameters:
x the xmlnode that should become an stanza error message
E the strucutre that holds the error information

References jutil_error_map(), and jutil_error_xmpp().

void jutil_error_map ( terror  old,
xterror mapped 
)

map a terror structure to a xterror structure

terror structures have been used in jabberd14 up to version 1.4.3 but are not able to hold XMPP compliant stanza errors. The xterror structure has been introduced to be XMPP compliant. This function is to ease writting wrappers that accept terror structures and call the real functions that require now xterror structures

Parameters:
old the terror struct that should be converted
mapped pointer to the xterror struct that should be filled with the converted error

References terror_struct::code, xterror_struct::code, xterror_struct::condition, xterror_struct::msg, terror_struct::msg, and xterror_struct::type.

Referenced by jutil_error().

void jutil_error_xmpp ( xmlnode  x,
xterror  E 
)
xmlnode jutil_iqnew ( int  type,
char const *  ns 
)
xmlnode jutil_iqresult ( xmlnode  x  ) 

change and xmlnode to be the result xmlnode for the original iq query

Parameters:
x the xmlnode that should become the result for itself
Returns:
the result xmlnode (same as given as parameter x)

References jutil_tofrom(), xmlnode_get_firstchild(), xmlnode_get_nextsibling(), xmlnode_hide(), and xmlnode_put_attrib_ns().

Referenced by js_bounce_xmpp(), and js_mapi_create_additional_iq_result().

xmlnode jutil_msgnew ( char const *  type,
char const *  to,
char const *  subj,
char const *  body 
)

utility for making message stanzas

Parameters:
type the type of the message (as a string!)
to the recipient of the message
subj the subject of the message (NULL for no subject element)
body the body of the message
Returns:
the xmlnode containing the new message stanza

References j_strlen(), NS_SERVER, xmlnode_insert_cdata(), xmlnode_insert_tag_ns(), xmlnode_new_tag_ns(), and xmlnode_put_attrib_ns().

xmlnode jutil_presnew ( int  type,
char const *  to,
char const *  status 
)

utility for making presence stanzas

Parameters:
type the type of the presence (one of the JPACKET__* contants)
to to whom the presence should be sent, NULL for a broadcast presence
status optional status (CDATA for the <status/> element, NULL for no <status/> element)
Returns:
the xmlnode containing the created presence stanza

References j_strlen(), JPACKET__INVISIBLE, JPACKET__PROBE, JPACKET__SUBSCRIBE, JPACKET__SUBSCRIBED, JPACKET__UNAVAILABLE, JPACKET__UNSUBSCRIBE, JPACKET__UNSUBSCRIBED, NS_SERVER, xmlnode_insert_cdata(), xmlnode_insert_tag_ns(), xmlnode_new_tag_ns(), and xmlnode_put_attrib_ns().

Referenced by js_sc_session_new(), js_session_end(), and js_session_new().

int jutil_priority ( xmlnode  x  ) 

returns the priority on an available presence packet

Parameters:
x the xmlnode containing the presence packet
Returns:
the presence priority, -129 for unavailable presences and errors

References NS_SERVER, xhash_free(), xhash_new(), xhash_put(), xmlnode_get_attrib_ns(), xmlnode_get_data(), xmlnode_get_list_item(), and xmlnode_get_tags().

char* jutil_regkey ( char *  key,
char *  seed 
)

create or validate a key value for stone-age jabber protocols

Before dialback had been introduced for s2s (and therefore only in jabberd 1.0), Jabber used these keys to protect some iq requests. A client first had to request a key with a IQ get and use it inside the IQ set request. By being able to receive the key in the IQ get response, the client (more or less) proved to be who he claimed to be.

The implementation of this function uses a static array with KEYBUF entries (default value of KEYBUF is 100). Therefore a key gets invalid at the 100th key that is created afterwards. It is also invalidated after it has been validated once.

Deprecated:
This function is not really used anymore. jabberd14 does not check any keys anymore and only creates them in the jsm's mod_register.c for compatibility. This function is also used in mod_groups.c and the key is even checked there, but I do not know if mod_groups.c still works at all.
Parameters:
key for validation the key the client sent, for generation of a new key NULL
seed the seed for generating the key, must stay the same for the same user
Returns:
the new key when created, the key if the key has been validated, NULL if the key is invalid

References j_strcmp(), KEYBUF, and shahash().

char* jutil_timestamp ( void   ) 

get the present time as a textual timestamp in the format YYYYMMDDTHH:MM:SS

Note:
this function is not thread safe
Returns:
pointer to a static (!) buffer containing the timestamp (or NULL on failure)

Referenced by jutil_delay().

char* jutil_timestamp_ms ( char *  buffer  ) 
void jutil_tofrom ( xmlnode  x  ) 
int karma_check ( struct karma k,
long  bytes_read 
)

check the karma for a connection

Parameters:
k the karma that should be checked
bytes_read the number of bytes, that have been read on a connection, that is karma controlled
Returns:
0 on okay check, 1 on bad check

References karma_decrement(), karma_increment(), and karma::val.

void karma_copy ( struct karma new_instance,
struct karma old 
)

make a copy of a karma structure

Parameters:
new_instance pointer to the destination (the structure must already exist)
old pointer to the values, that should be copied

References karma::bytes, karma::dec, karma::inc, karma::last_update, karma::max, karma::penalty, karma::reset_meter, karma::restore, and karma::val.

Referenced by mio_karma2().

void karma_decrement ( struct karma k,
long  bytes_read 
)

update karma: there was traffic, that has to be considered for karma calculations

Traffic reduces karma, passed time increments karma

Parameters:
k the karma structure to update
bytes_read the ammount of bytes that have been read on a connection, that is karma controlled

References karma::bytes, karma::dec, KARMA_READ_MAX, karma::penalty, and karma::val.

Referenced by karma_check().

void karma_increment ( struct karma k  ) 

update karma: if karma is incremented, it means that additional bytes are now possible in the configured bandwidth

Traffic reduces karma, passed time increments karma

Parameters:
k the karma structure

References karma::bytes, karma::inc, KARMA_HEARTBEAT, KARMA_READ_MAX, karma::last_update, karma::max, karma::reset_meter, karma::restore, and karma::val.

Referenced by karma_check().

struct karma* karma_new ( pool  p  )  [read]

create a new karma structure

Parameters:
p memory pool to allocate the memory on
Returns:
pointer to the newly allocated karam structure

References karma::bytes, karma::dec, karma::inc, KARMA_DEC, KARMA_INC, KARMA_INIT, KARMA_MAX, KARMA_PENALTY, KARMA_RESETMETER, KARMA_RESTORE, karma::last_update, karma::max, karma::penalty, pmalloco(), karma::reset_meter, karma::restore, and karma::val.

Referenced by mio_init(), and pthsock_client().

struct in_addr* make_addr ( char const *  host  )  [read]

convert an IPv4 address or hostname to a in_addr structure

Parameters:
host the IPv4 address or hostname to convert, on NULL, the hostname is used
Returns:
the in_addr struct that holds the result (pointer to a static structure, overwritten on next call!)

References MAXHOSTNAMELEN.

Referenced by make_netsocket().

int make_netsocket ( u_short  port,
char const *  host,
int  type 
)

Simple wrapper to make socket creation easy.

Parameters:
port port number of the socket
host hostname where to connect to or listen on
type type of socket (NETSOCKET_SERVER, NETSOCKET_CLIENT; or NETSOCKET_UDP)
Returns:
file handle of the new socket (-1 or error)

References make_addr(), NETSOCKET_CLIENT, NETSOCKET_SERVER, and NETSOCKET_UDP.

Referenced by make_netsocket2(), and mio_listen().

int make_netsocket2 ( Glib::ustring  servname,
Glib::ustring  nodename,
int  type 
)

Simple wrapper to create sockets

Todo:
Currently servname has to be already numeric. It should be possible to provide service names that are resolved in /etc/services
Parameters:
servname the service name (currently this has to be a numeric port number)
nodename the hostname where to connect to or listen on
type type of socket (NETSOCKET_SERVER, NETSOCKET_CLIENT, or NETSOCKET_UDP)
Returns:
file handle of the new socket (-1 or error)

References make_netsocket().

const char* messages_get ( const char *  lang,
const char *  message 
)

get a translated message from the static messages instance

Parameters:
lang the language (XML language token) to get the message for
message the message to get a translation for
Returns:
the translated message (if available), or same as message

References messages::get().

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(), and jutil_error_xmpp().

void messages_set_mapping ( const char *  lang,
const char *  locale_name 
)

define a mapping from a language token in XML to a system locale for the static messages instance

Parameters:
lang the XML language token
locale_name the system locale name

References messages::set_mapping().

Referenced by configurate().

void* pmalloc ( pool  p,
int  size 
)

allocate memory from a memory pool

Parameters:
p the pool to use
size how much memory to allocate
Returns:
pointer to the allocated memory

References _pool__free, _pool_cleanup_append(), _pool_free(), _pool_heap(), _retried__malloc(), pheap::block, pool_struct::heap, pool_struct::size, pheap::size, and pheap::used.

Referenced by jlimit_new(), jpacket_new(), pmalloc_x(), pmalloco(), pstrdup(), strescape(), strunescape(), and xmlnode_insert_cdata().

void* pmalloc_x ( pool  p,
int  size,
char  c 
)

allocate memory and initialize the memory with the given char c

Deprecated:
jabberd does use pmalloco instead, this function will be removed
Parameters:
p which pool to use
size the size of the allocation
c the initialization character
Returns:
pointer to the allocated memory

References pmalloc().

void* pmalloco ( pool  p,
int  size 
)
void pool_cleanup ( pool  p,
pool_cleaner  f,
void *  arg 
)
void pool_free ( pool  p  ) 
int pool_size ( pool  p  ) 

get the size of a memory pool

Parameters:
p the pool
Returns:
the size

References pool_struct::size.

Referenced by xstream_eat().

void pool_stat ( int  full  ) 

dummy implementation: print memory pool statistics (for debugging purposes, real implementation if POOL_DEBUG is defined)

Parameters:
full make a full report? (0 = no, 1 = yes)

Referenced by main().

char* pstrdup ( pool  p,
const char *  src 
)
char* pstrdupx ( pool  p,
const char *  src 
)

when pstrdup() is moved to "const char*", this one would actually return a new block

References pstrdup().

void shaBlock ( unsigned char *  dataIn,
int  len,
unsigned char  hashout[20] 
)
void shaFinal ( j_SHA_CTX ctx,
unsigned char  hashout[20] 
)
char* shahash ( char const *  str  ) 

References shahash_r().

Referenced by jutil_regkey().

void shahash_r ( const char *  str,
char  hashbuf[41] 
)
void shaInit ( j_SHA_CTX ctx  ) 
void shaUpdate ( j_SHA_CTX ctx,
unsigned char *  dataIn,
int  len 
)
void str_b64decode ( char *  str  ) 

decode a base64 string and put the result in the same buffer as the source

This function does not handle decoded data that contains the null byte very well as the size of the decoded data is not returned.

The result will be zero terminated.

Deprecated:
use base64_decode instead
Parameters:
str buffer for the source and the result

References base64_decode().

std::string strescape ( std::string  s  ) 

escape a string to be print as XML

Parameters:
s the original string
Returns:
the string with &, ', , < and > replaced with their entity representation
char* strescape ( pool  p,
char *  buf 
)

References pmalloc().

Referenced by xstream_header_char().

char* strunescape ( pool  p,
char *  buf 
)

References pmalloc().

void xhash_free ( xht  h  ) 
xht xhash_from_xml ( xmlnode  hash,
pool  p 
)

convert the xmlnode representation of an xhash back to an xhash

Note:
the result has to be freed by the caller using xhash_free()
Parameters:
hash the xhash in xml notation
Returns:
xhash that has been created

References j_atoi(), NS_JABBERD_HASH, pstrdup(), xhash_free(), xhash_new(), xhash_put(), xmlnode_get_attrib_ns(), xmlnode_get_data(), xmlnode_get_list_item(), and xmlnode_get_tags().

Referenced by xdb_file_phandler().

void* xhash_get ( xht  h,
const char *  key 
)
void* xhash_get_by_domain ( xht  h,
const char *  domain 
)

retrive a value from a xhash ... considering the key to be a domain

In contrast to xhash_get() this function interprets the key as a domain and checks all higher level domains, if the key is not found in the hash. If now higher level domains are found either, the key '*' is tried.

Example: For the domain 'a.example.com' the following lookups are done in this order until there is the first match: 'a.example.com', 'example.com', 'com', and '*'.

Parameters:
h the xhash to get the value from
domain the domain which should be used as the key

References xmppd::xhash< value_type >::get_by_domain().

Referenced by dialback_check_settings(), dialback_in_read(), dialback_in_read_db(), and dialback_out_read().

xht xhash_new ( int  prima  ) 
void xhash_put ( xht  h,
const char *  key,
void *  val 
)
xmlnode xhash_to_xml ( xht  h  ) 

write the contents of an xhash to an xmlnode

Note:
the result has to be freed by the caller using xmlnode_free()
Parameters:
h the xhash to be converted
Returns:
xmlnode tree containing the content of the xhash

References NS_JABBERD_HASH, xhash_walk(), and xmlnode_new_tag_ns().

void xhash_walk ( xht  h,
xhash_walker  w,
void *  arg 
)

iterate over a xhash strucutre

Parameters:
h the xhash to iterave over
w which function should be called for each value
arg what to pass to the optional argument of the xhash_walker function

Referenced by _js_hosts_del(), _jsm_shutdown(), deliver(), deliver_routed_hosts(), dialback_beat_idle(), dialback_out_beat_packets(), dnsrv_beat_packets(), instance_shutdown(), js_users_gc(), jsm_serialize(), jsm_shutdown(), xdb_file_purge(), and xhash_to_xml().

void xhash_zap ( xht  h,
const char *  key 
)

remove an entry from the xhash

Parameters:
h the xhash where a value should be removed
key the key of the value, that should be removed

Referenced by _dialback_miod_hash_cleanup(), _dnsrv_beat_packets(), _js_users_del(), _xdb_file_purge(), dialback_in_dbic_cleanup(), dialback_out_connection_cleanup(), dnsrv_deliver(), dnsrv_process_xstream_io(), instance_shutdown(), js_session_end(), pool_free(), unregister_instance(), and xdb_file_phandler().

int xmlnode2file ( char const *  file,
xmlnode  node 
)

write an xmlnode to a file (without a size limit)

Parameters:
file the target file
node the xmlnode that should be written
Returns:
1 on success, -1 on failure

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

Parameters:
file the target file
node the xmlnode that should be written
sizelimit the maximum length of the file to be written
Returns:
1 on success, 0 if failed due to size limit, -1 on failure

References j_strlen(), and xmlnode_serialize_string().

Referenced by xdb_file_phandler(), and xmlnode2file().

void xmlnode_change_namespace ( xmlnode  node,
const char *  ns_iri 
)

change the namespace of a node

Parameters:
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().

xmlnode xmlnode_dup ( xmlnode  x  ) 

produce full duplicate of x with a new pool

Note:
x must be a tag!
Parameters:
x xmlnode (tag) that should be duplicated using a new memory pool
Returns:
pointer to the duplicated tree, or NULL on error

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().

xmlnode xmlnode_dup_pool ( pool  p,
xmlnode  x 
)

produce a full duplicate of a x using the specified memory pool

Note:
this is nearly the same as xmlnode_dup(), with the difference, that you can specify which memory pool to use
Parameters:
p memory pool to use
x xmlnode (tag) that should be duplicated
Returns:
pointer to the duplicated tree, or NULL on error

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().

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

Parameters:
file the filename
Returns:
the graph of xmlnodes that represent the parsed document, NULL on failure

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.

Parameters:
file the filename
Returns:
pointer to a message why parsing failed, NULL if parsing did not fail

References XMLNS_SEPARATOR.

Referenced by configurate(), and main().

void xmlnode_free ( xmlnode  node  ) 
char* xmlnode_get_attrib ( xmlnode  owner,
const char *  name 
)

get an attribute value

Deprecated:
This function is not aware of namespaces, use xmlnode_get_attrib_ns() instead
Parameters:
owner element where to look for the attribute
name name of the attribute of which the value should be returned
Returns:
value of the attribute, or NULL if no such attribute

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 
)
char* xmlnode_get_data ( xmlnode  node  ) 
xmlnode xmlnode_get_firstattrib ( xmlnode  parent  ) 

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

Parameters:
parent element for which the first attribute node should be returned
Returns:
attribute node

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().

xmlnode xmlnode_get_firstchild ( xmlnode  parent  ) 
const char* xmlnode_get_lang ( xmlnode  node  ) 
xmlnode xmlnode_get_lastchild ( xmlnode  parent  ) 

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

Parameters:
parent element for which the last child should be returned
Returns:
last child node

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

Parameters:
first first list item
i which item to get (we start counting at zero)
Returns:
the node of the list item, NULL if no such item

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

Parameters:
first pointer to the first list item
i which item to use
Returns:
textual content, or NULL if no textual content, or item not found

References xmlnode_get_data().

Referenced by dialback(), and xdb_file().

const char* xmlnode_get_localname ( xmlnode  node  ) 
char* xmlnode_get_name ( xmlnode  node  ) 

get the name of a node

Deprecated:
This function mimics the jabberd 1.4.x xmlnode_get_name() where the name including the prefix is returned. You probably do not want to use this in a namespace aware application. You might want to use xmlnode_get_localname(), and xmlnode_get_namespace() instead.
Parameters:
node the node to get the name for
Returns:
name of the node

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  ) 
xmlnode xmlnode_get_nextsibling ( xmlnode  sibling  ) 
const char* xmlnode_get_nsprefix ( xmlnode  node  ) 

get the namespace prefix of a node

Note:
normally you will not need this. To compare two nodes, just compare the namespace (xmlnode_get_namespace()) and the localname (xmlnode_get_localname())
Parameters:
node the node to get the namespace prefix for
Returns:
namespace prefix of the node, NULL for the default prefix

References xmlnode_t::prefix.

Referenced by main().

xmlnode xmlnode_get_parent ( xmlnode  node  ) 

get the parent node for a node

Parameters:
node the node for which the parent node should be returned
Returns:
parent node

References xmlnode_t::parent.

Referenced by expat_endElement(), main(), and xmlnode_get_tags().

xmlnode xmlnode_get_prevsibling ( xmlnode  sibling  ) 

return the previous sibling

this can be used together with xmlnode_get_lastchild() to iterate backwards over the childrens of a node

Parameters:
sibling the node to get the previous sibling for
Returns:
previous sibling

References xmlnode_t::prev.

Referenced by dnsrv().

xmlnode xmlnode_get_tag ( xmlnode  parent,
const char *  name 
)

find given tag in an xmlnode tree

Deprecated:
This function is not aware of namespaces, use xmlnode_get_tags(), and xmlnode_get_list_item() instead
Parameters:
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
Returns:
a pointer to the tag matching search criteria, or NULL if search was unsuccessfull

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

Deprecated:
This function is not aware of namespaces, use xmlnode_get_tags(), and xmlnode_get_list_item_data() instead
Parameters:
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
Returns:
textual content, or NULL if no textual content

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:

  • foo/bar/text()
  • foo/bar[@baz='true']/text()
  • foobar
  • foobar[@attribute]
  • *[@attribute='value']
Parameters:
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
Returns:
first item in the list of xmlnodes, or NULL if no xmlnode matched the path

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  ) 
int xmlnode_has_children ( xmlnode  node  ) 

check if a node has child nodes

Parameters:
node the node to check
Returns:
1 if the node has childrens, 0 else

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

Note:
the root element of a document cannot be hidden with this function
Parameters:
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

Deprecated:
This function is not aware of namespaces. Use xmlnode_hide_attrib_ns() instead.
Parameters:
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

Parameters:
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().

xmlnode xmlnode_insert_cdata ( xmlnode  parent,
const char *  CDATA,
unsigned int  size 
)

insert a text node as child to an existing xmlnode

Parameters:
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
Returns:
a pointer to the new child node, or NULL if it was unsuccessfull

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().

void xmlnode_insert_node ( xmlnode  parent,
xmlnode  node 
)
xmlnode xmlnode_insert_tag ( xmlnode  parent,
const char *  name 
)

append a child tag to a tag

Deprecated:
This function is not aware of namespaces, use xmlnode_insert_tag_ns() instead
Parameters:
parent the xmlnode where the new element should be inserted
name name of the child tag
Returns:
pointer to the child tag node, or NULL if it was unsuccessfull

References xmlnode_t::ns_iri, NTYPE_TAG, pmalloco(), xmlnode_t::prefix, and xmlnode_pool().

xmlnode xmlnode_insert_tag_node ( xmlnode  parent,
xmlnode  node 
)

copy an element node as a child to an other node

Parameters:
parent where to insert the xmlnode
node node to insert
Returns:
pointer to the copied xmlnode

References xmlnode_t::name, xmlnode_t::ns_iri, xmlnode_t::prefix, xmlnode_get_firstattrib(), xmlnode_get_firstchild(),