Strophe  0.8
XMPP client library
Data Structures | Defines | Typedefs | Enumerations | Functions
common.h File Reference

Internally used functions and structures. More...

Data Structures

struct  xmpp_connlist_t
struct  xmpp_ctx_t
struct  xmpp_send_queue_t
struct  xmpp_handlist_t
struct  xmpp_conn_t
struct  xmpp_stanza_t

Defines

#define SASL_MASK_PLAIN   0x01
#define SASL_MASK_DIGESTMD5   0x02
#define SASL_MASK_ANONYMOUS   0x04

Typedefs

typedef void(* xmpp_open_handler )(xmpp_conn_t *const conn)

Enumerations

enum  xmpp_loop_status_t { XMPP_LOOP_NOTSTARTED, XMPP_LOOP_RUNNING, XMPP_LOOP_QUIT }
 run-time context More...
enum  xmpp_conn_state_t { XMPP_STATE_DISCONNECTED, XMPP_STATE_CONNECTING, XMPP_STATE_CONNECTED }
 connection More...
enum  xmpp_stanza_type_t { XMPP_STANZA_UNKNOWN, XMPP_STANZA_TEXT, XMPP_STANZA_TAG }

Functions

void * xmpp_alloc (const xmpp_ctx_t *const ctx, const size_t size)
 Allocate memory in a Strophe context.
void * xmpp_realloc (const xmpp_ctx_t *const ctx, void *p, const size_t size)
 Reallocate memory in a Strophe context.
char * xmpp_strdup (const xmpp_ctx_t *const ctx, const char *const s)
 implement our own strdup that uses the ctx allocator
void xmpp_log (const xmpp_ctx_t *const ctx, const xmpp_log_level_t level, const char *const area, const char *const fmt, va_list ap)
 Write a log message to the logger.
void xmpp_error (const xmpp_ctx_t *const ctx, const char *const area, const char *const fmt,...)
 Write to the log at the ERROR level.
void xmpp_warn (const xmpp_ctx_t *const ctx, const char *const area, const char *const fmt,...)
 Write to the log at the WARN level.
void xmpp_info (const xmpp_ctx_t *const ctx, const char *const area, const char *const fmt,...)
 Write to the log at the INFO level.
void xmpp_debug (const xmpp_ctx_t *const ctx, const char *const area, const char *const fmt,...)
 Write to the log at the DEBUG level.
char * xmpp_jid_new (xmpp_ctx_t *ctx, const char *node, const char *domain, const char *resource)
 jid
char * xmpp_jid_bare (xmpp_ctx_t *ctx, const char *jid)
 Create a bare JID from a JID.
char * xmpp_jid_node (xmpp_ctx_t *ctx, const char *jid)
 Create a node string from a JID.
char * xmpp_jid_domain (xmpp_ctx_t *ctx, const char *jid)
 Create a domain string from a JID.
char * xmpp_jid_resource (xmpp_ctx_t *ctx, const char *jid)
 Create a resource string from a JID.
void conn_disconnect (xmpp_conn_t *const conn)
 Disconnect from the XMPP server.
void conn_disconnect_clean (xmpp_conn_t *const conn)
 Cleanly disconnect the connection.
void conn_open_stream (xmpp_conn_t *const conn)
 Send the opening <stream:stream> tag to the server.
void conn_prepare_reset (xmpp_conn_t *const conn, xmpp_open_handler handler)
void conn_parser_reset (xmpp_conn_t *const conn)
void handler_fire_stanza (xmpp_conn_t *const conn, xmpp_stanza_t *const stanza)
 Fire off all stanza handlers that match.
uint64_t handler_fire_timed (xmpp_ctx_t *const ctx)
 Fire off all timed handlers that are ready.
void handler_reset_timed (xmpp_conn_t *conn, int user_only)
 Reset all timed handlers.
void handler_add_timed (xmpp_conn_t *const conn, xmpp_timed_handler handler, const unsigned long period, void *const userdata)
 Add a timed system handler.
void handler_add_id (xmpp_conn_t *const conn, xmpp_handler handler, const char *const id, void *const userdata)
 Add an id based system stanza handler.
void handler_add (xmpp_conn_t *const conn, xmpp_handler handler, const char *const ns, const char *const name, const char *const type, void *const userdata)
 Add a system stanza handler.
void disconnect_mem_error (xmpp_conn_t *const conn)
 Disconnect the stream with a memory error.
void auth_handle_open (xmpp_conn_t *const conn)
 Set up handlers at stream start.
int xmpp_snprintf (char *str, size_t count, const char *fmt,...)
int xmpp_vsnprintf (char *str, size_t count, const char *fmt, va_list arg)

Detailed Description

Internally used functions and structures.


Define Documentation

#define SASL_MASK_PLAIN   0x01
#define SASL_MASK_DIGESTMD5   0x02
#define SASL_MASK_ANONYMOUS   0x04

Typedef Documentation

typedef void(* xmpp_open_handler)(xmpp_conn_t *const conn)

Enumeration Type Documentation

run-time context

Enumerator:
XMPP_LOOP_NOTSTARTED 
XMPP_LOOP_RUNNING 
XMPP_LOOP_QUIT 

connection

Enumerator:
XMPP_STATE_DISCONNECTED 
XMPP_STATE_CONNECTING 
XMPP_STATE_CONNECTED 
Enumerator:
XMPP_STANZA_UNKNOWN 
XMPP_STANZA_TEXT 
XMPP_STANZA_TAG 

Function Documentation

void* xmpp_alloc ( const xmpp_ctx_t *const  ctx,
const size_t  size 
)

Allocate memory in a Strophe context.

All Strophe functions will use this to allocate memory.

Parameters:
ctxa Strophe context object
sizethe number of bytes to allocate
Returns:
a pointer to the allocated memory or NULL on an error
void* xmpp_realloc ( const xmpp_ctx_t *const  ctx,
void *  p,
const size_t  size 
)

Reallocate memory in a Strophe context.

All Strophe functions will use this to reallocate memory.

Parameters:
ctxa Strophe context object
pa pointer to previously allocated memory
sizethe new size in bytes to allocate
Returns:
a pointer to the reallocated memory or NULL on an error
char* xmpp_strdup ( const xmpp_ctx_t *const  ctx,
const char *const  s 
)

implement our own strdup that uses the ctx allocator

Duplicate a string. This function replaces the standard strdup library call with a version that uses the Strophe context object's allocator.

Parameters:
ctxa Strophe context object
sa string
Returns:
a new allocates string with the same data as s or NULL on error
void xmpp_log ( const xmpp_ctx_t *const  ctx,
const xmpp_log_level_t  level,
const char *const  area,
const char *const  fmt,
va_list  ap 
)

Write a log message to the logger.

Write a log message to the logger for the context for the specified level and area. This function takes a printf-style format string and a variable argument list (in va_list) format. This function is not meant to be called directly, but is used via xmpp_error, xmpp_warn, xmpp_info, and xmpp_debug.

Parameters:
ctxa Strophe context object
levelthe level at which to log
areathe area to log for
fmta printf-style format string for the message
apvariable argument list supplied for the format string
void xmpp_error ( const xmpp_ctx_t *const  ctx,
const char *const  area,
const char *const  fmt,
  ... 
)

Write to the log at the ERROR level.

This is a convenience function for writing to the log at the ERROR level. It takes a printf-style format string followed by a variable list of arguments for formatting.

Parameters:
ctxa Strophe context object
areathe area to log for
fmta printf-style format string followed by a variable list of arguments to format
void xmpp_warn ( const xmpp_ctx_t *const  ctx,
const char *const  area,
const char *const  fmt,
  ... 
)

Write to the log at the WARN level.

This is a convenience function for writing to the log at the WARN level. It takes a printf-style format string followed by a variable list of arguments for formatting.

Parameters:
ctxa Strophe context object
areathe area to log for
fmta printf-style format string followed by a variable list of arguments to format
void xmpp_info ( const xmpp_ctx_t *const  ctx,
const char *const  area,
const char *const  fmt,
  ... 
)

Write to the log at the INFO level.

This is a convenience function for writing to the log at the INFO level. It takes a printf-style format string followed by a variable list of arguments for formatting.

Parameters:
ctxa Strophe context object
areathe area to log for
fmta printf-style format string followed by a variable list of arguments to format
void xmpp_debug ( const xmpp_ctx_t *const  ctx,
const char *const  area,
const char *const  fmt,
  ... 
)

Write to the log at the DEBUG level.

This is a convenience function for writing to the log at the DEBUG level. It takes a printf-style format string followed by a variable list of arguments for formatting.

Parameters:
ctxa Strophe context object
areathe area to log for
fmta printf-style format string followed by a variable list of arguments to format
char* xmpp_jid_new ( xmpp_ctx_t *  ctx,
const char *  node,
const char *  domain,
const char *  resource 
)

jid

jid

Parameters:
ctxthe Strophe context object
nodea string representing the node
domaina string representing the domain. Required.
resourcea string representing the resource
Returns:
an allocated string with the full JID or NULL if no domain is specified
char* xmpp_jid_bare ( xmpp_ctx_t *  ctx,
const char *  jid 
)

Create a bare JID from a JID.

Parameters:
ctxthe Strophe context object
jidthe JID
Returns:
an allocated string with the bare JID or NULL on an error
char* xmpp_jid_node ( xmpp_ctx_t *  ctx,
const char *  jid 
)

Create a node string from a JID.

Parameters:
ctxa Strophe context object
jidthe JID
Returns:
an allocated string with the node or NULL if no node is found or an error occurs
char* xmpp_jid_domain ( xmpp_ctx_t *  ctx,
const char *  jid 
)

Create a domain string from a JID.

Parameters:
ctxthe Strophe context object
jidthe JID
Returns:
an allocated string with the domain or NULL on an error
char* xmpp_jid_resource ( xmpp_ctx_t *  ctx,
const char *  jid 
)

Create a resource string from a JID.

Parameters:
ctxa Strophe context object
jidthe JID
Returns:
an allocated string with the resource or NULL if no resource is found or an error occurs
void conn_disconnect ( xmpp_conn_t *const  conn)

Disconnect from the XMPP server.

This function immediately disconnects from the XMPP server, and should not be used outside of the Strophe library.

Parameters:
conna Strophe connection object
void conn_disconnect_clean ( xmpp_conn_t *const  conn)

Cleanly disconnect the connection.

This function is only called by the stream parser when </stream:stream> is received, and it not intended to be called by code outside of Strophe.

Parameters:
conna Strophe connection object
void conn_open_stream ( xmpp_conn_t *const  conn)

Send the opening <stream:stream> tag to the server.

This function is used by Strophe to begin an XMPP stream. It should not be used outside of the library.

Parameters:
conna Strophe connection object
void conn_prepare_reset ( xmpp_conn_t *const  conn,
xmpp_open_handler  handler 
)
void conn_parser_reset ( xmpp_conn_t *const  conn)
void handler_fire_stanza ( xmpp_conn_t *const  conn,
xmpp_stanza_t *const  stanza 
)

Fire off all stanza handlers that match.

This function is called internally by the event loop whenever stanzas are received from the XMPP server.

Parameters:
conna Strophe connection object
stanzaa Strophe stanza object
uint64_t handler_fire_timed ( xmpp_ctx_t *const  ctx)

Fire off all timed handlers that are ready.

This function is called internally by the event loop.

Parameters:
ctxa Strophe context object
Returns:
the time in milliseconds until the next handler will be ready
void handler_reset_timed ( xmpp_conn_t *  conn,
int  user_only 
)

Reset all timed handlers.

This function is called internally when a connection is successful.

Parameters:
conna Strophe connection object
user_onlywhether to reset all handlers or only user ones
void handler_add_timed ( xmpp_conn_t *const  conn,
xmpp_timed_handler  handler,
const unsigned long  period,
void *const  userdata 
)

Add a timed system handler.

This function is used to add internal timed handlers and should not be used outside of the library.

Parameters:
conna Strophe connection object
handlera function pointer to a timed handler
periodthe time in milliseconds between firings
userdataan opaque data pointer that will be passed to the handler
void handler_add_id ( xmpp_conn_t *const  conn,
xmpp_handler  handler,
const char *const  id,
void *const  userdata 
)

Add an id based system stanza handler.

This function is used to add internal id based stanza handlers and should not be used outside of the library.

Parameters:
conna Strophe connection object
handlera function pointer to a stanza handler
ida string with the id
userdataan opaque data pointer that will be passed to the handler
void handler_add ( xmpp_conn_t *const  conn,
xmpp_handler  handler,
const char *const  ns,
const char *const  name,
const char *const  type,
void *const  userdata 
)

Add a system stanza handler.

This function is used to add internal stanza handlers and should not be used outside of the library.

Parameters:
conna Strophe connection object
handlera function pointer to a stanza handler
nsa string with the namespace to match
namea string with the stanza name to match
typea string with the 'type' attribute value to match
userdataan opaque data pointer that will be passed to the handler
void disconnect_mem_error ( xmpp_conn_t *const  conn)

Disconnect the stream with a memory error.

This is a convenience function used internally by various parts of the Strophe library for terminating the connection because of a memory error.

Parameters:
conna Strophe connection object
void auth_handle_open ( xmpp_conn_t *const  conn)

Set up handlers at stream start.

This function is called internally to Strophe for handling the opening of an XMPP stream. It's called by the parser when a stream is opened or reset, and adds the initial handlers for <stream:error/> and <stream:features/>. This function is not intended for use outside of Strophe.

Parameters:
conna Strophe connection object
int xmpp_snprintf ( char *  str,
size_t  count,
const char *  fmt,
  ... 
)
int xmpp_vsnprintf ( char *  str,
size_t  count,
const char *  fmt,
va_list  arg 
)