jabberd2  2.3.2
Functions
sx.c File Reference
#include "sx.h"

Go to the source code of this file.

Functions

sx_t sx_new (sx_env_t env, int tag, sx_callback_t cb, void *arg)
 
void sx_free (sx_t s)
 
void sx_auth (sx_t s, const char *auth_method, const char *auth_id)
 force advance into auth state More...
 
void _sx_reset (sx_t s)
 utility; reset stream state More...
 
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 garbage, to be overwritten by caller. More...
 
void _sx_buffer_free (sx_buf_t buf)
 utility: kill a buffer More...
 
void _sx_buffer_clear (sx_buf_t buf)
 utility: clear out a buffer, but don't deallocate it More...
 
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 More...
 
void _sx_buffer_set (sx_buf_t buf, char *newdata, int newlength, char *newheap)
 utility: reset a sx_buf_t's contents. More...
 
void __sx_debug (const char *file, int line, const char *msgfmt,...)
 debug macro helpers More...
 
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 More...
 

Function Documentation

sx_t sx_new ( sx_env_t  env,
int  tag,
sx_callback_t  cb,
void *  arg 
)
void sx_free ( sx_t  s)
void sx_auth ( sx_t  s,
const char *  auth_method,
const char *  auth_id 
)

force advance into auth state

authenticate the stream and move to the auth'd state

Definition at line 141 of file sx.c.

References _sx_debug, _sx_event, _sx_state, _sx_st::auth_id, _sx_st::auth_method, event_OPEN, state_OPEN, and ZONE.

Referenced by _router_process_handshake(), _sx_sasl_open(), and c2s_router_sx_callback().

void _sx_reset ( sx_t  s)
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 garbage, to be overwritten by caller.

otherwise, data pointed to by 'data' will be copied into buf

Definition at line 222 of file sx.c.

References _sx_buf_st::data, _sx_buf_st::heap, _sx_buf_st::len, _sx_buf_st::notify, and _sx_buf_st::notify_arg.

Referenced by _sx_ack_process(), _sx_close(), _sx_compress_new(), _sx_compress_process(), _sx_error(), _sx_error_extended(), _sx_get_pending_write(), _sx_nad_write(), _sx_process_read(), _sx_raw_write(), _sx_server_element_start(), _sx_server_notify_header(), _sx_ssl_process(), _sx_ssl_wio(), sx_can_read(), sx_client_init(), sx_compress_client_compress(), and sx_ssl_client_starttls().

void _sx_buffer_free ( sx_buf_t  buf)

utility: kill a buffer

Definition at line 246 of file sx.c.

References _sx_buf_st::heap.

Referenced by _sx_compress_free(), _sx_get_pending_write(), _sx_process_read(), _sx_ssl_free(), _sx_ssl_wio(), sx_can_read(), sx_can_write(), and sx_free().

void _sx_buffer_clear ( sx_buf_t  buf)

utility: clear out a buffer, but don't deallocate it

Definition at line 254 of file sx.c.

References _sx_buf_st::data, _sx_buf_st::heap, and _sx_buf_st::len.

Referenced by _sx_buffer_set(), _sx_compress_rio(), _sx_compress_wio(), _sx_ssl_rio(), and _sx_ssl_wio().

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

Definition at line 264 of file sx.c.

References _sx_buf_st::data, _sx_buf_st::heap, and _sx_buf_st::len.

Referenced by _s2s_db_header(), _sx_ack_header(), _sx_buffer_set(), _sx_compress_rio(), _sx_compress_wio(), _sx_ssl_rio(), and _sx_ssl_wio().

void _sx_buffer_set ( sx_buf_t  buf,
char *  newdata,
int  newlength,
char *  newheap 
)

utility: reset a sx_buf_t's contents.

If newheap is non-NULL it is assumed to be 'data's malloc block and ownership of the block is taken by the buffer. If newheap is NULL then the data is copied.

Definition at line 301 of file sx.c.

References _sx_buffer_alloc_margin(), _sx_buffer_clear(), _sx_buf_st::data, _sx_buf_st::heap, and _sx_buf_st::len.

Referenced by _sx_sasl_rio(), and _sx_sasl_wio().

void __sx_debug ( const char *  file,
int  line,
const char *  msgfmt,
  ... 
)

debug macro helpers

helper functions for macros when we're debugging

Definition at line 319 of file sx.c.

References MAX_DEBUG.

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

Definition at line 338 of file sx.c.

References _sx_debug, _sx_st::cb, _sx_st::cb_arg, _sx_st::reentry, and _sx_st::tag.