28 #include "ac-stdint.h"
36 # ifdef JABBERD2_EXPORTS
37 # define JABBERD2_API __declspec(dllexport)
39 # define JABBERD2_API __declspec(dllimport)
42 # define JABBERD2_API extern
93 #define SX_SUCCESS (0x00)
94 #define SX_ERR_STREAM (0x01)
95 #define SX_ERR_AUTH (0x02)
96 #define SX_ERR_XML_PARSE (0x03)
106 #define _sx_gen_error(e,c,g,s) do { e.code = c; e.generic = g; e.specific = s; } while(0);
124 #define stream_err_BAD_FORMAT (0)
125 #define stream_err_BAD_NAMESPACE_PREFIX (1)
126 #define stream_err_CONFLICT (2)
127 #define stream_err_CONNECTION_TIMEOUT (3)
128 #define stream_err_HOST_GONE (4)
129 #define stream_err_HOST_UNKNOWN (5)
130 #define stream_err_IMPROPER_ADDRESSING (6)
131 #define stream_err_INTERNAL_SERVER_ERROR (7)
132 #define stream_err_INVALID_FROM (8)
133 #define stream_err_INVALID_ID (9)
134 #define stream_err_INVALID_NAMESPACE (10)
135 #define stream_err_INVALID_XML (11)
136 #define stream_err_NOT_AUTHORIZED (12)
137 #define stream_err_POLICY_VIOLATION (13)
138 #define stream_err_REMOTE_CONNECTION_FAILED (14)
139 #define stream_err_RESTRICTED_XML (15)
140 #define stream_err_RESOURCE_CONSTRAINT (16)
141 #define stream_err_SEE_OTHER_HOST (17)
142 #define stream_err_SYSTEM_SHUTDOWN (18)
143 #define stream_err_UNDEFINED_CONDITION (19)
144 #define stream_err_UNSUPPORTED_ENCODING (20)
145 #define stream_err_UNSUPPORTED_STANZA_TYPE (21)
146 #define stream_err_UNSUPPORTED_VERSION (22)
147 #define stream_err_XML_NOT_WELL_FORMED (23)
148 #define stream_err_LAST (24)
158 JABBERD2_API void sx_client_init(sx_t s,
unsigned int flags,
const char *ns,
const char *to,
const char *from,
const char *version);
167 #define sx_nad_write(s,nad) sx_nad_write_elem(s, nad, 0)
197 #ifdef HAVE_XML_STOPPARSER
198 JABBERD2_API void _sx_entity_declaration(
void *arg,
const char *entityName,
199 int is_parameter_entity,
const char *value,
200 int value_length,
const char *base,
201 const char *systemId,
const char *publicId,
202 const char *notationName);
353 void (*
new)(sx_t s, sx_plugin_t p);
354 void (*free)(sx_t s, sx_plugin_t p);
356 void (*client)(sx_t s, sx_plugin_t p);
357 void (*server)(sx_t s, sx_plugin_t p);
360 int (*wio)(sx_t s, sx_plugin_t p, sx_buf_t buf);
361 int (*rio)(sx_t s, sx_plugin_t p, sx_buf_t buf);
364 int (*wnad)(sx_t s, sx_plugin_t p,
nad_t nad,
int elem);
365 int (*rnad)(sx_t s, sx_plugin_t p,
nad_t nad);
367 void (*header)(sx_t s, sx_plugin_t p, sx_buf_t buf);
368 void (*stream)(sx_t s, sx_plugin_t p);
370 void (*features)(sx_t s, sx_plugin_t p,
nad_t nad);
373 int (*process)(sx_t s, sx_plugin_t p,
nad_t nad);
375 void (*unload)(sx_plugin_t p);
385 #define ZONE __FILE__,__LINE__
392 #define _sx_event(s,e,data) __sx_event(ZONE, s, e, data)
397 #define _sx_debug if(get_debug_flag()) __sx_debug
400 #define _sx_state(s,st) do { _sx_debug(ZONE, "%d state change from %d to %d", s->tag, s->state, st); s->state = st; } while(0)
405 #define _sx_debug if(0) __sx_debug
406 #define _sx_state(s,st) s->state = st
JABBERD2_API int sx_can_read(sx_t s)
we can read
JABBERD2_API void sx_raw_write(sx_t s, const char *buf, int len)
sending raw data
JABBERD2_API void sx_kill(sx_t s)
JABBERD2_API int _sx_chain_io_write(sx_t s, sx_buf_t buf)
JABBERD2_API sx_t sx_new(sx_env_t env, int tag, sx_callback_t cb, void *arg)
if you change these, reflect your changes in the table in error.c
JABBERD2_API int __sx_event(const char *file, int line, sx_t s, sx_event_t e, void *data)
helper and internal macro for firing the callback
JABBERD2_API int _sx_chain_nad_write(sx_t s, nad_t nad, int elem)
JABBERD2_API void _sx_nad_process(sx_t s, nad_t nad)
main nad processor
error info for event_ERROR
JABBERD2_API int sx_can_write(sx_t s)
_sx_state_t
connection states
JABBERD2_API void _sx_chain_nad_plugin(sx_t s, sx_plugin_t p)
JABBERD2_API void _sx_buffer_clear(sx_buf_t buf)
utility: clear out a buffer, but don't deallocate it
int(* sx_callback_t)(sx_t s, sx_event_t e, void *data, void *arg)
event callback
JABBERD2_API void sx_env_free(sx_env_t env)
struct _sx_error_st sx_error_t
error info for event_ERROR
JABBERD2_API void _sx_cdata(void *arg, const char *str, int len)
JABBERD2_API void _sx_error_extended(sx_t s, int err, const char *content)
JABBERD2_API void sx_client_init(sx_t s, unsigned int flags, const char *ns, const char *to, const char *from, const char *version)
JABBERD2_API sx_plugin_t sx_env_plugin(sx_env_t env, sx_plugin_init_t init,...)
load a plugin into the environment
JABBERD2_API sx_buf_t _sx_buffer_new(const char *data, int len, _sx_notify_t notify, void *notify_arg)
utility: make a new buffer if len>0 but data is NULL, the buffer will contain that many bytes of garb...
JABBERD2_API void sx_error(sx_t s, int err, const char *text)
JABBERD2_API void _sx_close(sx_t s)
close a stream
holds the state for a single stream
_sx_type_t
connection types
JABBERD2_API int _sx_chain_io_read(sx_t s, sx_buf_t buf)
JABBERD2_API void sx_error_extended(sx_t s, int err, const char *content)
JABBERD2_API void _sx_namespace_start(void *arg, const char *prefix, const char *uri)
JABBERD2_API void _sx_process_read(sx_t s, sx_buf_t buf)
processor for incoming wire data
struct _sx_plugin_st * sx_plugin_t
JABBERD2_API char * _sx_flags(sx_t s)
show sx flags as string - for logging
struct _sx_buf_st * sx_buf_t
utility: buffer
JABBERD2_API void sx_nad_write_elem(sx_t s, nad_t nad, int elem)
sending a nad
void(* _sx_notify_t)(sx_t s, void *arg)
prototype for the write notify function
JABBERD2_API void _sx_element_start(void *arg, const char *name, const char **atts)
primary expat callbacks
int(* sx_plugin_init_t)(sx_env_t env, sx_plugin_t p, va_list args)
plugin init
JABBERD2_API void _sx_buffer_set(sx_buf_t buf, char *newdata, int newlength, char *newheap)
utility: reset a sx_buf_t's contents.
JABBERD2_API void sx_auth(sx_t s, const char *auth_method, const char *auth_id)
authenticate the stream and move to the auth'd state
JABBERD2_API sx_env_t sx_env_new(void)
JABBERD2_API void _sx_chain_io_plugin(sx_t s, sx_plugin_t p)
JABBERD2_API void _sx_buffer_free(sx_buf_t buf)
utility: kill a buffer
sx_event_t
things that can happen
struct _sx_env_st * sx_env_t
JABBERD2_API int _sx_nad_write(sx_t s, nad_t nad, int elem)
sending a nad (internal)
JABBERD2_API void _sx_reset(sx_t s)
reset stream state without informing the app
JABBERD2_API void __sx_debug(const char *file, int line, const char *msgfmt,...)
helper functions for macros when we're debugging
JABBERD2_API void sx_close(sx_t s)
JABBERD2_API int _sx_chain_nad_read(sx_t s, nad_t nad)
JABBERD2_API void _sx_error(sx_t s, int err, const char *text)
send an error
JABBERD2_API void sx_free(sx_t s)
JABBERD2_API void _sx_element_end(void *arg, const char *name)
JABBERD2_API void sx_server_init(sx_t s, unsigned int flags)
JABBERD2_API void _sx_buffer_alloc_margin(sx_buf_t buf, int before, int after)
utility: ensure a certain amount of allocated space adjacent to buf->data
struct _sx_chain_st * _sx_chain_t
read/write plugin chain