jabberd14 1.6.2
Functions
xstream.cc File Reference

handling of incoming XML stream based events More...

#include <jabberdlib.h>
#include <iostream>

Functions

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)

Detailed Description

handling of incoming XML stream based events

xstream is a way to have a consistent method of handling incoming XML stream based events ... if doesn't handle the generation of an XML stream, but provides some facilities to help doing that

Currently this is only used by base_stdout.c and the stream used by dnsrv to communicate with the co-process. Other XML streams (c2s, s2s, components, ...) use XML streaming implemented in mio_xml.c.


Function Documentation

int xstream_eat ( xstream  xs,
char *  buff,
int  len 
)

attempts to parse the buff onto this stream firing events to the handler

Parameters:
xsthe xstream to parse the data on
buffthe new data
lenlength of the data
Returns:
last known xstream status

References xstream_struct::arg, xstream_struct::cdata_len, xstream_struct::f, xstream_struct::node, NS_SERVER, xstream_struct::parser, pool_size(), xstream_struct::status, xmlnode_insert_cdata(), xmlnode_new_tag_ns(), xmlnode_pool(), XSTREAM_ERR, and XSTREAM_MAXNODE.

Referenced by dnsrv_child_main(), and dnsrv_process_io().

void xstream_format_error ( std::ostream &  out,
streamerr  errstruct 
)
xmlnode xstream_header ( const char *  to,
const char *  from 
)

give a standard template xmlnode to work from

Parameters:
towhere the stream is sent to
fromwhere we are (source of the stream)
Returns:
the xmlnode that has been generated as the template

References NS_SERVER, NS_STREAM, NS_XMLNS, shahash_r(), xmlnode_new_tag_ns(), and xmlnode_put_attrib_ns().

Referenced by dialback_in_read(), and dialback_out_read().

char* xstream_header_char ( xmlnode  x,
int  stream_type 
)

trim the xmlnode to only the opening header :)

Note:
NO CHILDREN ALLOWED
this function does ignore most explicit declarations of namespace prefixes. The only exceptions are explicit declarations of the default namespace, or the namespace defined by the prefix 'db'
Parameters:
xthe xmlnode
stream_type0 for 'jabber:server', 1 for 'jabber:client', 2 for 'jabber:component:accept'
Returns:
string representation of the start tag

References NS_CLIENT, NS_COMPONENT_ACCEPT, NS_SERVER, NS_XMLNS, pstrdup(), strescape(), xmlnode_get_attrib_ns(), xmlnode_has_children(), xmlnode_pool(), and xmlnode_serialize_string().

Referenced by mio_write_root().

xstream xstream_new ( pool  p,
xstream_onNode  f,
void *  arg 
)

creates a new xstream with given pool, xstream will be cleaned up w/ pool

Parameters:
pthe memory pool to use for the stream
ffunction pointer to the event handler function
argparameter to pass to the event handler function
Returns:
the created xstream

References xstream_struct::arg, xstream_struct::f, xstream_struct::p, xstream_struct::parser, pmalloco(), pool_cleanup(), and XMLNS_SEPARATOR.

Referenced by dnsrv_child_main(), and dnsrv_process_io().

streamerr_severity xstream_parse_error ( pool  p,
xmlnode  errnode,
streamerr  errstruct 
)