Strophe 0.12
XMPP client library
Functions
Context objects

These functions create and manipulate Strophe context objects. More...

Functions

xmpp_log_t * xmpp_get_default_logger (xmpp_log_level_t level)
 Get a default logger with filtering. More...
 
xmpp_ctx_t * xmpp_ctx_new (const xmpp_mem_t *mem, const xmpp_log_t *log)
 Create and initialize a Strophe context object. More...
 
void xmpp_ctx_free (xmpp_ctx_t *ctx)
 Free a Strophe context object that is no longer in use. More...
 
void xmpp_ctx_set_verbosity (xmpp_ctx_t *ctx, int level)
 Set the verbosity level of a Strophe context. More...
 

Detailed Description

These functions create and manipulate Strophe context objects.

In order to support usage in a variety of environments, the Strophe library uses a runtime context object. This object contains the information on how to do memory allocation and logging. This allows the user to control how memory is allocated and what do to with log messages.

These issues do not affect programs in the common case, but many environments require special treatment. Abstracting these into a runtime context object makes it easy to use Strophe on embedded platforms.

Objects in Strophe are reference counted to ease memory management issues, but the context objects are not.

Function Documentation

◆ xmpp_get_default_logger()

xmpp_log_t * xmpp_get_default_logger ( xmpp_log_level_t  level)

Get a default logger with filtering.

The default logger provides a basic logging setup which writes log messages to stderr. Only messages where level is greater than or equal to the filter level will be logged.

Parameters
levelthe highest level the logger will log at
Returns
the log structure for the given level

◆ xmpp_ctx_new()

xmpp_ctx_t * xmpp_ctx_new ( const xmpp_mem_t *  mem,
const xmpp_log_t *  log 
)

Create and initialize a Strophe context object.

If mem is NULL, a default allocation setup will be used which wraps malloc(), free(), and realloc() from the standard library. If log is NULL, a default logger will be used which does no logging. Basic filtered logging to stderr can be done with the xmpp_get_default_logger() convenience function.

Parameters
mema pointer to an xmpp_mem_t structure or NULL
loga pointer to an xmpp_log_t structure or NULL
Returns
the allocated Strophe context object or NULL on an error

◆ xmpp_ctx_free()

void xmpp_ctx_free ( xmpp_ctx_t *  ctx)

Free a Strophe context object that is no longer in use.

Parameters
ctxa Strophe context object

◆ xmpp_ctx_set_verbosity()

void xmpp_ctx_set_verbosity ( xmpp_ctx_t *  ctx,
int  level 
)

Set the verbosity level of a Strophe context.

Parameters
ctxa Strophe context object
levelthe verbosity level