trim trailing spaces
This commit is contained in:
committed by
Dmitry Podgorny
parent
3feed16e2e
commit
abd1b08a97
@@ -1,7 +1,7 @@
|
|||||||
/* active.c
|
/* active.c
|
||||||
** libstrophe XMPP client library -- basic usage example
|
** libstrophe XMPP client library -- basic usage example
|
||||||
**
|
**
|
||||||
** Copyright (C) 2005-2009 Collecta, Inc.
|
** Copyright (C) 2005-2009 Collecta, Inc.
|
||||||
**
|
**
|
||||||
** This software is provided AS-IS with no warranty, either express
|
** This software is provided AS-IS with no warranty, either express
|
||||||
** or implied.
|
** or implied.
|
||||||
@@ -32,7 +32,7 @@ int handle_reply(xmpp_conn_t * const conn,
|
|||||||
else {
|
else {
|
||||||
query = xmpp_stanza_get_child_by_name(stanza, "query");
|
query = xmpp_stanza_get_child_by_name(stanza, "query");
|
||||||
printf("Active Sessions:\n");
|
printf("Active Sessions:\n");
|
||||||
for (item = xmpp_stanza_get_children(query); item;
|
for (item = xmpp_stanza_get_children(query); item;
|
||||||
item = xmpp_stanza_get_next(item))
|
item = xmpp_stanza_get_next(item))
|
||||||
printf("\t %s\n", xmpp_stanza_get_attribute(item, "jid"));
|
printf("\t %s\n", xmpp_stanza_get_attribute(item, "jid"));
|
||||||
printf("END OF LIST\n");
|
printf("END OF LIST\n");
|
||||||
@@ -44,7 +44,7 @@ int handle_reply(xmpp_conn_t * const conn,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void conn_handler(xmpp_conn_t * const conn, const xmpp_conn_event_t status,
|
void conn_handler(xmpp_conn_t * const conn, const xmpp_conn_event_t status,
|
||||||
const int error, xmpp_stream_error_t * const stream_error,
|
const int error, xmpp_stream_error_t * const stream_error,
|
||||||
void * const userdata)
|
void * const userdata)
|
||||||
{
|
{
|
||||||
@@ -53,7 +53,7 @@ void conn_handler(xmpp_conn_t * const conn, const xmpp_conn_event_t status,
|
|||||||
|
|
||||||
if (status == XMPP_CONN_CONNECT) {
|
if (status == XMPP_CONN_CONNECT) {
|
||||||
fprintf(stderr, "DEBUG: connected\n");
|
fprintf(stderr, "DEBUG: connected\n");
|
||||||
|
|
||||||
/* create iq stanza for request */
|
/* create iq stanza for request */
|
||||||
iq = xmpp_iq_new(ctx, "get", "active1");
|
iq = xmpp_iq_new(ctx, "get", "active1");
|
||||||
xmpp_stanza_set_to(iq, "xxxxxxxxx.com");
|
xmpp_stanza_set_to(iq, "xxxxxxxxx.com");
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* bot.c
|
/* bot.c
|
||||||
** libstrophe XMPP client library -- basic usage example
|
** libstrophe XMPP client library -- basic usage example
|
||||||
**
|
**
|
||||||
** Copyright (C) 2005-2009 Collecta, Inc.
|
** Copyright (C) 2005-2009 Collecta, Inc.
|
||||||
**
|
**
|
||||||
** This software is provided AS-IS with no warranty, either express
|
** This software is provided AS-IS with no warranty, either express
|
||||||
** or implied.
|
** or implied.
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* simple bot example
|
/* simple bot example
|
||||||
**
|
**
|
||||||
** This example was provided by Matthew Wild <mwild1@gmail.com>.
|
** This example was provided by Matthew Wild <mwild1@gmail.com>.
|
||||||
**
|
**
|
||||||
** This bot responds to basic messages and iq version requests.
|
** This bot responds to basic messages and iq version requests.
|
||||||
@@ -115,7 +115,7 @@ int message_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* define a handler for connection events */
|
/* define a handler for connection events */
|
||||||
void conn_handler(xmpp_conn_t * const conn, const xmpp_conn_event_t status,
|
void conn_handler(xmpp_conn_t * const conn, const xmpp_conn_event_t status,
|
||||||
const int error, xmpp_stream_error_t * const stream_error,
|
const int error, xmpp_stream_error_t * const stream_error,
|
||||||
void * const userdata)
|
void * const userdata)
|
||||||
{
|
{
|
||||||
@@ -178,7 +178,7 @@ int main(int argc, char **argv)
|
|||||||
/* initiate connection */
|
/* initiate connection */
|
||||||
xmpp_connect_client(conn, NULL, 0, conn_handler, ctx);
|
xmpp_connect_client(conn, NULL, 0, conn_handler, ctx);
|
||||||
|
|
||||||
/* enter the event loop -
|
/* enter the event loop -
|
||||||
our connect handler will trigger an exit */
|
our connect handler will trigger an exit */
|
||||||
xmpp_run(ctx);
|
xmpp_run(ctx);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* roster.c
|
/* roster.c
|
||||||
** libstrophe XMPP client library -- handler example
|
** libstrophe XMPP client library -- handler example
|
||||||
**
|
**
|
||||||
** Copyright (C) 2005-2009 Collecta, Inc.
|
** Copyright (C) 2005-2009 Collecta, Inc.
|
||||||
**
|
**
|
||||||
** This software is provided AS-IS with no warranty, either express
|
** This software is provided AS-IS with no warranty, either express
|
||||||
** or implied.
|
** or implied.
|
||||||
@@ -31,10 +31,10 @@ int handle_reply(xmpp_conn_t * const conn,
|
|||||||
else {
|
else {
|
||||||
query = xmpp_stanza_get_child_by_name(stanza, "query");
|
query = xmpp_stanza_get_child_by_name(stanza, "query");
|
||||||
printf("Roster:\n");
|
printf("Roster:\n");
|
||||||
for (item = xmpp_stanza_get_children(query); item;
|
for (item = xmpp_stanza_get_children(query); item;
|
||||||
item = xmpp_stanza_get_next(item))
|
item = xmpp_stanza_get_next(item))
|
||||||
if ((name = xmpp_stanza_get_attribute(item, "name")))
|
if ((name = xmpp_stanza_get_attribute(item, "name")))
|
||||||
printf("\t %s (%s) sub=%s\n",
|
printf("\t %s (%s) sub=%s\n",
|
||||||
name,
|
name,
|
||||||
xmpp_stanza_get_attribute(item, "jid"),
|
xmpp_stanza_get_attribute(item, "jid"),
|
||||||
xmpp_stanza_get_attribute(item, "subscription"));
|
xmpp_stanza_get_attribute(item, "subscription"));
|
||||||
@@ -51,7 +51,7 @@ int handle_reply(xmpp_conn_t * const conn,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void conn_handler(xmpp_conn_t * const conn, const xmpp_conn_event_t status,
|
void conn_handler(xmpp_conn_t * const conn, const xmpp_conn_event_t status,
|
||||||
const int error, xmpp_stream_error_t * const stream_error,
|
const int error, xmpp_stream_error_t * const stream_error,
|
||||||
void * const userdata)
|
void * const userdata)
|
||||||
{
|
{
|
||||||
@@ -60,7 +60,7 @@ void conn_handler(xmpp_conn_t * const conn, const xmpp_conn_event_t status,
|
|||||||
|
|
||||||
if (status == XMPP_CONN_CONNECT) {
|
if (status == XMPP_CONN_CONNECT) {
|
||||||
fprintf(stderr, "DEBUG: connected\n");
|
fprintf(stderr, "DEBUG: connected\n");
|
||||||
|
|
||||||
/* create iq stanza for request */
|
/* create iq stanza for request */
|
||||||
iq = xmpp_iq_new(ctx, "get", "roster1");
|
iq = xmpp_iq_new(ctx, "get", "roster1");
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ struct _xmpp_ctx_t {
|
|||||||
|
|
||||||
/* convenience functions for accessing the context */
|
/* convenience functions for accessing the context */
|
||||||
void *xmpp_alloc(const xmpp_ctx_t * const ctx, const size_t size);
|
void *xmpp_alloc(const xmpp_ctx_t * const ctx, const size_t size);
|
||||||
void *xmpp_realloc(const xmpp_ctx_t * const ctx, void *p,
|
void *xmpp_realloc(const xmpp_ctx_t * const ctx, void *p,
|
||||||
const size_t size);
|
const size_t size);
|
||||||
char *xmpp_strdup(const xmpp_ctx_t * const ctx, const char * const s);
|
char *xmpp_strdup(const xmpp_ctx_t * const ctx, const char * const s);
|
||||||
|
|
||||||
@@ -170,7 +170,7 @@ struct _xmpp_conn_t {
|
|||||||
int tls_legacy_ssl;
|
int tls_legacy_ssl;
|
||||||
int tls_trust;
|
int tls_trust;
|
||||||
int tls_failed; /* set when tls fails, so we don't try again */
|
int tls_failed; /* set when tls fails, so we don't try again */
|
||||||
int sasl_support; /* if true, field is a bitfield of supported
|
int sasl_support; /* if true, field is a bitfield of supported
|
||||||
mechanisms */
|
mechanisms */
|
||||||
int auth_legacy_enabled;
|
int auth_legacy_enabled;
|
||||||
int secured; /* set when stream is secured with TLS */
|
int secured; /* set when stream is secured with TLS */
|
||||||
@@ -207,7 +207,7 @@ struct _xmpp_conn_t {
|
|||||||
|
|
||||||
/* user handlers only get called after authentication */
|
/* user handlers only get called after authentication */
|
||||||
int authenticated;
|
int authenticated;
|
||||||
|
|
||||||
/* connection events handler */
|
/* connection events handler */
|
||||||
xmpp_conn_handler conn_handler;
|
xmpp_conn_handler conn_handler;
|
||||||
void *userdata;
|
void *userdata;
|
||||||
@@ -238,7 +238,7 @@ struct _xmpp_stanza_t {
|
|||||||
xmpp_ctx_t *ctx;
|
xmpp_ctx_t *ctx;
|
||||||
|
|
||||||
xmpp_stanza_type_t type;
|
xmpp_stanza_type_t type;
|
||||||
|
|
||||||
xmpp_stanza_t *prev;
|
xmpp_stanza_t *prev;
|
||||||
xmpp_stanza_t *next;
|
xmpp_stanza_t *next;
|
||||||
xmpp_stanza_t *children;
|
xmpp_stanza_t *children;
|
||||||
|
|||||||
18
src/conn.c
18
src/conn.c
@@ -34,7 +34,7 @@
|
|||||||
#define DEFAULT_SEND_QUEUE_MAX 64
|
#define DEFAULT_SEND_QUEUE_MAX 64
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISCONNECT_TIMEOUT
|
#ifndef DISCONNECT_TIMEOUT
|
||||||
/** @def DISCONNECT_TIMEOUT
|
/** @def DISCONNECT_TIMEOUT
|
||||||
* The time to wait (in milliseconds) for graceful disconnection to
|
* The time to wait (in milliseconds) for graceful disconnection to
|
||||||
* complete before the connection is reset. The default is 2 seconds.
|
* complete before the connection is reset. The default is 2 seconds.
|
||||||
*/
|
*/
|
||||||
@@ -183,12 +183,12 @@ xmpp_conn_t *xmpp_conn_new(xmpp_ctx_t * const ctx)
|
|||||||
else conn->ctx->connlist = item;
|
else conn->ctx->connlist = item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Clone a Strophe connection object.
|
/** Clone a Strophe connection object.
|
||||||
*
|
*
|
||||||
* @param conn a Strophe connection object
|
* @param conn a Strophe connection object
|
||||||
*
|
*
|
||||||
* @return the same conn object passed in with its reference count
|
* @return the same conn object passed in with its reference count
|
||||||
@@ -336,7 +336,7 @@ int xmpp_conn_release(xmpp_conn_t * const conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Get the JID which is or will be bound to the connection.
|
/** Get the JID which is or will be bound to the connection.
|
||||||
*
|
*
|
||||||
* @param conn a Strophe connection object
|
* @param conn a Strophe connection object
|
||||||
*
|
*
|
||||||
* @return a string containing the full JID or NULL if it has not been set
|
* @return a string containing the full JID or NULL if it has not been set
|
||||||
@@ -399,7 +399,7 @@ const char *xmpp_conn_get_pass(const xmpp_conn_t * const conn)
|
|||||||
/** Set the password used to authenticate the connection.
|
/** Set the password used to authenticate the connection.
|
||||||
* If any password was previously set, it will be discarded. The function
|
* If any password was previously set, it will be discarded. The function
|
||||||
* will make a copy of the password string.
|
* will make a copy of the password string.
|
||||||
*
|
*
|
||||||
* @param conn a Strophe connection object
|
* @param conn a Strophe connection object
|
||||||
* @param pass the password
|
* @param pass the password
|
||||||
*
|
*
|
||||||
@@ -413,9 +413,9 @@ void xmpp_conn_set_pass(xmpp_conn_t * const conn, const char * const pass)
|
|||||||
|
|
||||||
/** Get the strophe context that the connection is associated with.
|
/** Get the strophe context that the connection is associated with.
|
||||||
* @param conn a Strophe connection object
|
* @param conn a Strophe connection object
|
||||||
*
|
*
|
||||||
* @return a Strophe context
|
* @return a Strophe context
|
||||||
*
|
*
|
||||||
* @ingroup Connections
|
* @ingroup Connections
|
||||||
*/
|
*/
|
||||||
xmpp_ctx_t* xmpp_conn_get_context(xmpp_conn_t * const conn)
|
xmpp_ctx_t* xmpp_conn_get_context(xmpp_conn_t * const conn)
|
||||||
@@ -428,7 +428,7 @@ xmpp_ctx_t* xmpp_conn_get_context(xmpp_conn_t * const conn)
|
|||||||
* process to the XMPP server, and notifications of connection state changes
|
* process to the XMPP server, and notifications of connection state changes
|
||||||
* will be sent to the callback function. The domain and port to connect to
|
* will be sent to the callback function. The domain and port to connect to
|
||||||
* are usually determined by an SRV lookup for the xmpp-client service at
|
* are usually determined by an SRV lookup for the xmpp-client service at
|
||||||
* the domain specified in the JID. If SRV lookup fails, altdomain and
|
* the domain specified in the JID. If SRV lookup fails, altdomain and
|
||||||
* altport will be used instead if specified.
|
* altport will be used instead if specified.
|
||||||
*
|
*
|
||||||
* @param conn a Strophe connection object
|
* @param conn a Strophe connection object
|
||||||
@@ -686,7 +686,7 @@ void conn_disconnect_clean(xmpp_conn_t * const conn)
|
|||||||
*
|
*
|
||||||
* @param conn a Strophe connection object
|
* @param conn a Strophe connection object
|
||||||
*/
|
*/
|
||||||
void conn_disconnect(xmpp_conn_t * const conn)
|
void conn_disconnect(xmpp_conn_t * const conn)
|
||||||
{
|
{
|
||||||
xmpp_debug(conn->ctx, "xmpp", "Closing socket.");
|
xmpp_debug(conn->ctx, "xmpp", "Closing socket.");
|
||||||
conn->state = XMPP_STATE_DISCONNECTED;
|
conn->state = XMPP_STATE_DISCONNECTED;
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ int xmpp_version_check(int major, int minor)
|
|||||||
/* We define the global default allocator, logger, and context here. */
|
/* We define the global default allocator, logger, and context here. */
|
||||||
|
|
||||||
/* Wrap stdlib routines malloc, free, and realloc for default memory
|
/* Wrap stdlib routines malloc, free, and realloc for default memory
|
||||||
* management.
|
* management.
|
||||||
*/
|
*/
|
||||||
static void *_malloc(const size_t size, void * const userdata)
|
static void *_malloc(const size_t size, void * const userdata)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* event.c
|
/* event.c
|
||||||
** strophe XMPP client library -- event loop and management
|
** strophe XMPP client library -- event loop and management
|
||||||
**
|
**
|
||||||
** Copyright (C) 2005-2009 Collecta, Inc.
|
** Copyright (C) 2005-2009 Collecta, Inc.
|
||||||
**
|
**
|
||||||
** This software is provided AS-IS with no warranty, either express
|
** This software is provided AS-IS with no warranty, either express
|
||||||
** or implied.
|
** or implied.
|
||||||
|
|||||||
10
src/hash.c
10
src/hash.c
@@ -1,7 +1,7 @@
|
|||||||
/* hash.c
|
/* hash.c
|
||||||
** strophe XMPP client library -- hash table implementation
|
** strophe XMPP client library -- hash table implementation
|
||||||
**
|
**
|
||||||
** Copyright (C) 2005-2009 Collecta, Inc.
|
** Copyright (C) 2005-2009 Collecta, Inc.
|
||||||
**
|
**
|
||||||
** This software is provided AS-IS with no warranty, either express
|
** This software is provided AS-IS with no warranty, either express
|
||||||
** or implied.
|
** or implied.
|
||||||
@@ -44,7 +44,7 @@ struct _hash_iterator_t {
|
|||||||
hashentry_t *entry;
|
hashentry_t *entry;
|
||||||
int index;
|
int index;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** allocate and initialize a new hash table */
|
/** allocate and initialize a new hash table */
|
||||||
hash_t *hash_new(xmpp_ctx_t * const ctx, const int size,
|
hash_t *hash_new(xmpp_ctx_t * const ctx, const int size,
|
||||||
hash_free_func free_func)
|
hash_free_func free_func)
|
||||||
@@ -67,7 +67,7 @@ hash_t *hash_new(xmpp_ctx_t * const ctx, const int size,
|
|||||||
/* give the caller a reference */
|
/* give the caller a reference */
|
||||||
result->ref = 1;
|
result->ref = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ void hash_release(hash_t * const table)
|
|||||||
xmpp_ctx_t *ctx = table->ctx;
|
xmpp_ctx_t *ctx = table->ctx;
|
||||||
hashentry_t *entry, *next;
|
hashentry_t *entry, *next;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (table->ref > 1)
|
if (table->ref > 1)
|
||||||
table->ref--;
|
table->ref--;
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* jid.c
|
/* jid.c
|
||||||
** strophe XMPP client library -- helper functions for parsing JIDs
|
** strophe XMPP client library -- helper functions for parsing JIDs
|
||||||
**
|
**
|
||||||
** Copyright (C) 2005-2009 Collecta, Inc.
|
** Copyright (C) 2005-2009 Collecta, Inc.
|
||||||
**
|
**
|
||||||
** This software is provided AS-IS with no warranty, either express
|
** This software is provided AS-IS with no warranty, either express
|
||||||
** or implied.
|
** or implied.
|
||||||
@@ -63,7 +63,7 @@ char *xmpp_jid_new(xmpp_ctx_t *ctx, const char *node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Create a bare JID from a JID.
|
/** Create a bare JID from a JID.
|
||||||
*
|
*
|
||||||
* @param ctx the Strophe context object
|
* @param ctx the Strophe context object
|
||||||
* @param jid the JID
|
* @param jid the JID
|
||||||
*
|
*
|
||||||
@@ -85,7 +85,7 @@ char *xmpp_jid_bare(xmpp_ctx_t *ctx, const char *jid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Create a node string from a JID.
|
/** Create a node string from a JID.
|
||||||
*
|
*
|
||||||
* @param ctx a Strophe context object
|
* @param ctx a Strophe context object
|
||||||
* @param jid the JID
|
* @param jid the JID
|
||||||
*
|
*
|
||||||
@@ -145,7 +145,7 @@ char *xmpp_jid_domain(xmpp_ctx_t *ctx, const char *jid)
|
|||||||
* @param ctx a Strophe context object
|
* @param ctx a Strophe context object
|
||||||
* @param jid the JID
|
* @param jid the JID
|
||||||
*
|
*
|
||||||
* @return an allocated string with the resource or NULL if no resource
|
* @return an allocated string with the resource or NULL if no resource
|
||||||
* is found or an error occurs
|
* is found or an error occurs
|
||||||
*/
|
*/
|
||||||
char *xmpp_jid_resource(xmpp_ctx_t *ctx, const char *jid)
|
char *xmpp_jid_resource(xmpp_ctx_t *ctx, const char *jid)
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, uint32_t len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Final wrapup - pad to 64-byte boundary with the bit pattern
|
* Final wrapup - pad to 64-byte boundary with the bit pattern
|
||||||
* 1 0* (64-bit count of bits processed, MSB-first)
|
* 1 0* (64-bit count of bits processed, MSB-first)
|
||||||
*/
|
*/
|
||||||
void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
|
void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
|
||||||
@@ -183,7 +183,7 @@ static void MD5Transform(uint32_t buf[4], const unsigned char inext[64])
|
|||||||
{
|
{
|
||||||
register uint32_t a, b, c, d, i;
|
register uint32_t a, b, c, d, i;
|
||||||
uint32_t in[16];
|
uint32_t in[16];
|
||||||
|
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
in[i] = GET_32BIT_LSB_FIRST(inext + 4 * i);
|
in[i] = GET_32BIT_LSB_FIRST(inext + 4 * i);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* parser.c
|
/* parser.c
|
||||||
** strophe XMPP client library -- xml parser handlers and utility functions
|
** strophe XMPP client library -- xml parser handlers and utility functions
|
||||||
**
|
**
|
||||||
** Copyright (C) 2005-2009 Collecta, Inc.
|
** Copyright (C) 2005-2009 Collecta, Inc.
|
||||||
**
|
**
|
||||||
** This software is provided AS-IS with no warranty, either express
|
** This software is provided AS-IS with no warranty, either express
|
||||||
** or implied.
|
** or implied.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* parser.c
|
/* parser.c
|
||||||
** strophe XMPP client library -- xml parser handlers and utility functions
|
** strophe XMPP client library -- xml parser handlers and utility functions
|
||||||
**
|
**
|
||||||
** Copyright (C) 2005-2009 Collecta, Inc.
|
** Copyright (C) 2005-2009 Collecta, Inc.
|
||||||
**
|
**
|
||||||
** This software is provided AS-IS with no warranty, either express
|
** This software is provided AS-IS with no warranty, either express
|
||||||
** or implied.
|
** or implied.
|
||||||
@@ -104,7 +104,7 @@ static void _free_cbattrs(parser_t *parser, char **attrs)
|
|||||||
xmpp_free(parser->ctx, attrs);
|
xmpp_free(parser->ctx, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _start_element(void *userdata,
|
static void _start_element(void *userdata,
|
||||||
const xmlChar *name, const xmlChar *prefix,
|
const xmlChar *name, const xmlChar *prefix,
|
||||||
const xmlChar *uri, int nnamespaces,
|
const xmlChar *uri, int nnamespaces,
|
||||||
const xmlChar **namespaces, int nattrs,
|
const xmlChar **namespaces, int nattrs,
|
||||||
@@ -118,7 +118,7 @@ static void _start_element(void *userdata,
|
|||||||
/* notify the owner */
|
/* notify the owner */
|
||||||
if (parser->startcb) {
|
if (parser->startcb) {
|
||||||
cbattrs = _convert_attrs(parser, nattrs, attrs);
|
cbattrs = _convert_attrs(parser, nattrs, attrs);
|
||||||
parser->startcb((char *)name, cbattrs,
|
parser->startcb((char *)name, cbattrs,
|
||||||
parser->userdata);
|
parser->userdata);
|
||||||
_free_cbattrs(parser, cbattrs);
|
_free_cbattrs(parser, cbattrs);
|
||||||
}
|
}
|
||||||
@@ -151,7 +151,7 @@ static void _start_element(void *userdata,
|
|||||||
|
|
||||||
/* add child to parent */
|
/* add child to parent */
|
||||||
xmpp_stanza_add_child(parser->stanza, child);
|
xmpp_stanza_add_child(parser->stanza, child);
|
||||||
|
|
||||||
/* the child is owned by the toplevel stanza now */
|
/* the child is owned by the toplevel stanza now */
|
||||||
xmpp_stanza_release(child);
|
xmpp_stanza_release(child);
|
||||||
|
|
||||||
@@ -259,13 +259,13 @@ int parser_reset(parser_t *parser)
|
|||||||
{
|
{
|
||||||
if (parser->xmlctx)
|
if (parser->xmlctx)
|
||||||
xmlFreeParserCtxt(parser->xmlctx);
|
xmlFreeParserCtxt(parser->xmlctx);
|
||||||
if (parser->stanza)
|
if (parser->stanza)
|
||||||
xmpp_stanza_release(parser->stanza);
|
xmpp_stanza_release(parser->stanza);
|
||||||
|
|
||||||
parser->stanza = NULL;
|
parser->stanza = NULL;
|
||||||
parser->depth = 0;
|
parser->depth = 0;
|
||||||
|
|
||||||
parser->xmlctx = xmlCreatePushParserCtxt(&parser->handlers,
|
parser->xmlctx = xmlCreatePushParserCtxt(&parser->handlers,
|
||||||
parser, NULL, 0, NULL);
|
parser, NULL, 0, NULL);
|
||||||
|
|
||||||
return parser->xmlctx ? 1 : 0;
|
return parser->xmlctx ? 1 : 0;
|
||||||
|
|||||||
30
src/sasl.c
30
src/sasl.c
@@ -1,7 +1,7 @@
|
|||||||
/* sasl.c
|
/* sasl.c
|
||||||
** strophe XMPP client library -- SASL authentication helpers
|
** strophe XMPP client library -- SASL authentication helpers
|
||||||
**
|
**
|
||||||
** Copyright (C) 2005-2009 Collecta, Inc.
|
** Copyright (C) 2005-2009 Collecta, Inc.
|
||||||
**
|
**
|
||||||
** This software is provided AS-IS with no warranty, either express
|
** This software is provided AS-IS with no warranty, either express
|
||||||
** or implied.
|
** or implied.
|
||||||
@@ -43,7 +43,7 @@ char *sasl_plain(xmpp_ctx_t *ctx, const char *authid, const char *password) {
|
|||||||
size_t msglen;
|
size_t msglen;
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
char *msg;
|
char *msg;
|
||||||
|
|
||||||
/* our message is Base64(authzid,\0,authid,\0,password)
|
/* our message is Base64(authzid,\0,authid,\0,password)
|
||||||
if there is no authzid, that field is left empty */
|
if there is no authzid, that field is left empty */
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ static void _digest_to_hex(const char *digest, char *hex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** append 'key="value"' to a buffer, growing as necessary */
|
/** append 'key="value"' to a buffer, growing as necessary */
|
||||||
static char *_add_key(xmpp_ctx_t *ctx, hash_t *table, const char *key,
|
static char *_add_key(xmpp_ctx_t *ctx, hash_t *table, const char *key,
|
||||||
char *buf, int *len, int quote)
|
char *buf, int *len, int quote)
|
||||||
{
|
{
|
||||||
int olen,nlen;
|
int olen,nlen;
|
||||||
@@ -230,7 +230,7 @@ char *sasl_digest_md5(xmpp_ctx_t *ctx, const char *challenge,
|
|||||||
char hex[32];
|
char hex[32];
|
||||||
char cnonce[13];
|
char cnonce[13];
|
||||||
|
|
||||||
/* our digest response is
|
/* our digest response is
|
||||||
Hex( KD( HEX(MD5(A1)),
|
Hex( KD( HEX(MD5(A1)),
|
||||||
nonce ':' nc ':' cnonce ':' qop ':' HEX(MD5(A2))
|
nonce ':' nc ':' cnonce ':' qop ':' HEX(MD5(A2))
|
||||||
))
|
))
|
||||||
@@ -271,7 +271,7 @@ char *sasl_digest_md5(xmpp_ctx_t *ctx, const char *challenge,
|
|||||||
memcpy(value+5, domain, strlen(domain));
|
memcpy(value+5, domain, strlen(domain));
|
||||||
value[5+strlen(domain)] = '\0';
|
value[5+strlen(domain)] = '\0';
|
||||||
hash_add(table, "digest-uri", value);
|
hash_add(table, "digest-uri", value);
|
||||||
|
|
||||||
/* generate response */
|
/* generate response */
|
||||||
|
|
||||||
/* construct MD5(node : realm : password) */
|
/* construct MD5(node : realm : password) */
|
||||||
@@ -341,16 +341,16 @@ char *sasl_digest_md5(xmpp_ctx_t *ctx, const char *challenge,
|
|||||||
/* construct reply */
|
/* construct reply */
|
||||||
result = NULL;
|
result = NULL;
|
||||||
rlen = 0;
|
rlen = 0;
|
||||||
result = _add_key(ctx, table, "username", result, &rlen, 1);
|
result = _add_key(ctx, table, "username", result, &rlen, 1);
|
||||||
result = _add_key(ctx, table, "realm", result, &rlen, 1);
|
result = _add_key(ctx, table, "realm", result, &rlen, 1);
|
||||||
result = _add_key(ctx, table, "nonce", result, &rlen, 1);
|
result = _add_key(ctx, table, "nonce", result, &rlen, 1);
|
||||||
result = _add_key(ctx, table, "cnonce", result, &rlen, 1);
|
result = _add_key(ctx, table, "cnonce", result, &rlen, 1);
|
||||||
result = _add_key(ctx, table, "nc", result, &rlen, 0);
|
result = _add_key(ctx, table, "nc", result, &rlen, 0);
|
||||||
result = _add_key(ctx, table, "qop", result, &rlen, 0);
|
result = _add_key(ctx, table, "qop", result, &rlen, 0);
|
||||||
result = _add_key(ctx, table, "digest-uri", result, &rlen, 1);
|
result = _add_key(ctx, table, "digest-uri", result, &rlen, 1);
|
||||||
result = _add_key(ctx, table, "response", result, &rlen, 0);
|
result = _add_key(ctx, table, "response", result, &rlen, 0);
|
||||||
result = _add_key(ctx, table, "charset", result, &rlen, 0);
|
result = _add_key(ctx, table, "charset", result, &rlen, 0);
|
||||||
|
|
||||||
xmpp_free(ctx, node);
|
xmpp_free(ctx, node);
|
||||||
xmpp_free(ctx, domain);
|
xmpp_free(ctx, domain);
|
||||||
hash_release(table); /* also frees value strings */
|
hash_release(table); /* also frees value strings */
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ By Steve Reid <sreid@sea-to-sky.net>
|
|||||||
100% Public Domain
|
100% Public Domain
|
||||||
|
|
||||||
-----------------
|
-----------------
|
||||||
Modified 7/98
|
Modified 7/98
|
||||||
By James H. Brown <jbrown@burgoyne.com>
|
By James H. Brown <jbrown@burgoyne.com>
|
||||||
Still 100% Public Domain
|
Still 100% Public Domain
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ Since the file IO in main() reads 16K at a time, any file 8K or larger would
|
|||||||
be guaranteed to generate the wrong hash (e.g. Test Vector #3, a million
|
be guaranteed to generate the wrong hash (e.g. Test Vector #3, a million
|
||||||
"a"s).
|
"a"s).
|
||||||
|
|
||||||
I also changed the declaration of variables i & j in SHA1Update to
|
I also changed the declaration of variables i & j in SHA1Update to
|
||||||
unsigned long from unsigned int for the same reason.
|
unsigned long from unsigned int for the same reason.
|
||||||
|
|
||||||
These changes should make no difference to any 32 bit implementations since
|
These changes should make no difference to any 32 bit implementations since
|
||||||
@@ -57,7 +57,7 @@ Still 100% public domain
|
|||||||
Modified 4/01
|
Modified 4/01
|
||||||
By Saul Kravitz <Saul.Kravitz@celera.com>
|
By Saul Kravitz <Saul.Kravitz@celera.com>
|
||||||
Still 100% PD
|
Still 100% PD
|
||||||
Modified to run on Compaq Alpha hardware.
|
Modified to run on Compaq Alpha hardware.
|
||||||
|
|
||||||
-----------------
|
-----------------
|
||||||
Modified 07/2002
|
Modified 07/2002
|
||||||
@@ -232,7 +232,7 @@ void crypto_SHA1_Final(SHA1_CTX* context, uint8_t* digest)
|
|||||||
digest[i] = (uint8_t)
|
digest[i] = (uint8_t)
|
||||||
((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
|
((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wipe variables */
|
/* Wipe variables */
|
||||||
memset(context->buffer, 0, 64);
|
memset(context->buffer, 0, 64);
|
||||||
memset(context->state, 0, 20);
|
memset(context->state, 0, 20);
|
||||||
|
|||||||
116
src/snprintf.c
116
src/snprintf.c
@@ -35,9 +35,9 @@
|
|||||||
* original. Also, there is now a builtin-test, just compile with:
|
* original. Also, there is now a builtin-test, just compile with:
|
||||||
* gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm
|
* gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm
|
||||||
* and run snprintf for results.
|
* and run snprintf for results.
|
||||||
*
|
*
|
||||||
* Thomas Roessler <roessler@guug.de> 01/27/98 for mutt 0.89i
|
* Thomas Roessler <roessler@guug.de> 01/27/98 for mutt 0.89i
|
||||||
* The PGP code was using unsigned hexadecimal formats.
|
* The PGP code was using unsigned hexadecimal formats.
|
||||||
* Unfortunately, unsigned formats simply didn't work.
|
* Unfortunately, unsigned formats simply didn't work.
|
||||||
*
|
*
|
||||||
* Michael Elkins <me@cs.hmc.edu> 03/05/98 for mutt 0.90.8
|
* Michael Elkins <me@cs.hmc.edu> 03/05/98 for mutt 0.90.8
|
||||||
@@ -85,7 +85,7 @@
|
|||||||
#define LDOUBLE double
|
#define LDOUBLE double
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int dopr (char *buffer, size_t maxlen, const char *format,
|
static int dopr (char *buffer, size_t maxlen, const char *format,
|
||||||
va_list args);
|
va_list args);
|
||||||
static int fmtstr (char *buffer, size_t *currlen, size_t maxlen,
|
static int fmtstr (char *buffer, size_t *currlen, size_t maxlen,
|
||||||
char *value, int flags, int min, int max);
|
char *value, int flags, int min, int max);
|
||||||
@@ -140,7 +140,7 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args)
|
|||||||
int cflags;
|
int cflags;
|
||||||
int total;
|
int total;
|
||||||
size_t currlen;
|
size_t currlen;
|
||||||
|
|
||||||
state = DP_S_DEFAULT;
|
state = DP_S_DEFAULT;
|
||||||
currlen = flags = cflags = min = 0;
|
currlen = flags = cflags = min = 0;
|
||||||
max = -1;
|
max = -1;
|
||||||
@@ -152,17 +152,17 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args)
|
|||||||
if (ch == '\0')
|
if (ch == '\0')
|
||||||
state = DP_S_DONE;
|
state = DP_S_DONE;
|
||||||
|
|
||||||
switch(state)
|
switch(state)
|
||||||
{
|
{
|
||||||
case DP_S_DEFAULT:
|
case DP_S_DEFAULT:
|
||||||
if (ch == '%')
|
if (ch == '%')
|
||||||
state = DP_S_FLAGS;
|
state = DP_S_FLAGS;
|
||||||
else
|
else
|
||||||
total += dopr_outch (buffer, &currlen, maxlen, ch);
|
total += dopr_outch (buffer, &currlen, maxlen, ch);
|
||||||
ch = *format++;
|
ch = *format++;
|
||||||
break;
|
break;
|
||||||
case DP_S_FLAGS:
|
case DP_S_FLAGS:
|
||||||
switch (ch)
|
switch (ch)
|
||||||
{
|
{
|
||||||
case '-':
|
case '-':
|
||||||
flags |= DP_F_MINUS;
|
flags |= DP_F_MINUS;
|
||||||
@@ -190,49 +190,49 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DP_S_MIN:
|
case DP_S_MIN:
|
||||||
if (isdigit(ch))
|
if (isdigit(ch))
|
||||||
{
|
{
|
||||||
min = 10*min + char_to_int (ch);
|
min = 10*min + char_to_int (ch);
|
||||||
ch = *format++;
|
ch = *format++;
|
||||||
}
|
}
|
||||||
else if (ch == '*')
|
else if (ch == '*')
|
||||||
{
|
{
|
||||||
min = va_arg (args, int);
|
min = va_arg (args, int);
|
||||||
ch = *format++;
|
ch = *format++;
|
||||||
state = DP_S_DOT;
|
state = DP_S_DOT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
state = DP_S_DOT;
|
state = DP_S_DOT;
|
||||||
break;
|
break;
|
||||||
case DP_S_DOT:
|
case DP_S_DOT:
|
||||||
if (ch == '.')
|
if (ch == '.')
|
||||||
{
|
{
|
||||||
state = DP_S_MAX;
|
state = DP_S_MAX;
|
||||||
ch = *format++;
|
ch = *format++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
state = DP_S_MOD;
|
state = DP_S_MOD;
|
||||||
break;
|
break;
|
||||||
case DP_S_MAX:
|
case DP_S_MAX:
|
||||||
if (isdigit(ch))
|
if (isdigit(ch))
|
||||||
{
|
{
|
||||||
if (max < 0)
|
if (max < 0)
|
||||||
max = 0;
|
max = 0;
|
||||||
max = 10*max + char_to_int (ch);
|
max = 10*max + char_to_int (ch);
|
||||||
ch = *format++;
|
ch = *format++;
|
||||||
}
|
}
|
||||||
else if (ch == '*')
|
else if (ch == '*')
|
||||||
{
|
{
|
||||||
max = va_arg (args, int);
|
max = va_arg (args, int);
|
||||||
ch = *format++;
|
ch = *format++;
|
||||||
state = DP_S_MOD;
|
state = DP_S_MOD;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
state = DP_S_MOD;
|
state = DP_S_MOD;
|
||||||
break;
|
break;
|
||||||
case DP_S_MOD:
|
case DP_S_MOD:
|
||||||
/* Currently, we don't support Long Long, bummer */
|
/* Currently, we don't support Long Long, bummer */
|
||||||
switch (ch)
|
switch (ch)
|
||||||
{
|
{
|
||||||
case 'h':
|
case 'h':
|
||||||
cflags = DP_C_SHORT;
|
cflags = DP_C_SHORT;
|
||||||
@@ -252,11 +252,11 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args)
|
|||||||
state = DP_S_CONV;
|
state = DP_S_CONV;
|
||||||
break;
|
break;
|
||||||
case DP_S_CONV:
|
case DP_S_CONV:
|
||||||
switch (ch)
|
switch (ch)
|
||||||
{
|
{
|
||||||
case 'd':
|
case 'd':
|
||||||
case 'i':
|
case 'i':
|
||||||
if (cflags == DP_C_SHORT)
|
if (cflags == DP_C_SHORT)
|
||||||
value = va_arg (args, int);
|
value = va_arg (args, int);
|
||||||
else if (cflags == DP_C_LONG)
|
else if (cflags == DP_C_LONG)
|
||||||
value = va_arg (args, long int);
|
value = va_arg (args, long int);
|
||||||
@@ -336,19 +336,19 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args)
|
|||||||
max, flags);
|
max, flags);
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
if (cflags == DP_C_SHORT)
|
if (cflags == DP_C_SHORT)
|
||||||
{
|
{
|
||||||
short int *num;
|
short int *num;
|
||||||
num = va_arg (args, short int *);
|
num = va_arg (args, short int *);
|
||||||
*num = currlen;
|
*num = currlen;
|
||||||
}
|
}
|
||||||
else if (cflags == DP_C_LONG)
|
else if (cflags == DP_C_LONG)
|
||||||
{
|
{
|
||||||
long int *num;
|
long int *num;
|
||||||
num = va_arg (args, long int *);
|
num = va_arg (args, long int *);
|
||||||
*num = currlen;
|
*num = currlen;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int *num;
|
int *num;
|
||||||
num = va_arg (args, int *);
|
num = va_arg (args, int *);
|
||||||
@@ -380,9 +380,9 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args)
|
|||||||
}
|
}
|
||||||
if (buffer != NULL && maxlen > 0)
|
if (buffer != NULL && maxlen > 0)
|
||||||
{
|
{
|
||||||
if (currlen < maxlen - 1)
|
if (currlen < maxlen - 1)
|
||||||
buffer[currlen] = '\0';
|
buffer[currlen] = '\0';
|
||||||
else
|
else
|
||||||
buffer[maxlen - 1] = '\0';
|
buffer[maxlen - 1] = '\0';
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
@@ -394,7 +394,7 @@ static int fmtstr (char *buffer, size_t *currlen, size_t maxlen,
|
|||||||
int padlen, strln; /* amount to pad */
|
int padlen, strln; /* amount to pad */
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
int total = 0;
|
int total = 0;
|
||||||
|
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
{
|
{
|
||||||
value = "<NULL>";
|
value = "<NULL>";
|
||||||
@@ -404,9 +404,9 @@ static int fmtstr (char *buffer, size_t *currlen, size_t maxlen,
|
|||||||
if (max >= 0 && max < strln)
|
if (max >= 0 && max < strln)
|
||||||
strln = max;
|
strln = max;
|
||||||
padlen = min - strln;
|
padlen = min - strln;
|
||||||
if (padlen < 0)
|
if (padlen < 0)
|
||||||
padlen = 0;
|
padlen = 0;
|
||||||
if (flags & DP_F_MINUS)
|
if (flags & DP_F_MINUS)
|
||||||
padlen = -padlen; /* Left Justify */
|
padlen = -padlen; /* Left Justify */
|
||||||
|
|
||||||
while (padlen > 0)
|
while (padlen > 0)
|
||||||
@@ -440,7 +440,7 @@ static int fmtint (char *buffer, size_t *currlen, size_t maxlen,
|
|||||||
int zpadlen = 0; /* amount to zero pad */
|
int zpadlen = 0; /* amount to zero pad */
|
||||||
int caps = 0;
|
int caps = 0;
|
||||||
int total = 0;
|
int total = 0;
|
||||||
|
|
||||||
if (max < 0)
|
if (max < 0)
|
||||||
max = 0;
|
max = 0;
|
||||||
|
|
||||||
@@ -459,7 +459,7 @@ static int fmtint (char *buffer, size_t *currlen, size_t maxlen,
|
|||||||
if (flags & DP_F_SPACE)
|
if (flags & DP_F_SPACE)
|
||||||
signvalue = ' ';
|
signvalue = ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
|
if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@@ -480,7 +480,7 @@ static int fmtint (char *buffer, size_t *currlen, size_t maxlen,
|
|||||||
zpadlen = MAX(zpadlen, spadlen);
|
zpadlen = MAX(zpadlen, spadlen);
|
||||||
spadlen = 0;
|
spadlen = 0;
|
||||||
}
|
}
|
||||||
if (flags & DP_F_MINUS)
|
if (flags & DP_F_MINUS)
|
||||||
spadlen = -spadlen; /* Left Justifty */
|
spadlen = -spadlen; /* Left Justifty */
|
||||||
|
|
||||||
#ifdef DEBUG_SNPRINTF
|
#ifdef DEBUG_SNPRINTF
|
||||||
@@ -489,18 +489,18 @@ static int fmtint (char *buffer, size_t *currlen, size_t maxlen,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Spaces */
|
/* Spaces */
|
||||||
while (spadlen > 0)
|
while (spadlen > 0)
|
||||||
{
|
{
|
||||||
total += dopr_outch (buffer, currlen, maxlen, ' ');
|
total += dopr_outch (buffer, currlen, maxlen, ' ');
|
||||||
--spadlen;
|
--spadlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sign */
|
/* Sign */
|
||||||
if (signvalue)
|
if (signvalue)
|
||||||
total += dopr_outch (buffer, currlen, maxlen, signvalue);
|
total += dopr_outch (buffer, currlen, maxlen, signvalue);
|
||||||
|
|
||||||
/* Zeros */
|
/* Zeros */
|
||||||
if (zpadlen > 0)
|
if (zpadlen > 0)
|
||||||
{
|
{
|
||||||
while (zpadlen > 0)
|
while (zpadlen > 0)
|
||||||
{
|
{
|
||||||
@@ -510,9 +510,9 @@ static int fmtint (char *buffer, size_t *currlen, size_t maxlen,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Digits */
|
/* Digits */
|
||||||
while (place > 0)
|
while (place > 0)
|
||||||
total += dopr_outch (buffer, currlen, maxlen, convert[--place]);
|
total += dopr_outch (buffer, currlen, maxlen, convert[--place]);
|
||||||
|
|
||||||
/* Left Justified spaces */
|
/* Left Justified spaces */
|
||||||
while (spadlen < 0) {
|
while (spadlen < 0) {
|
||||||
total += dopr_outch (buffer, currlen, maxlen, ' ');
|
total += dopr_outch (buffer, currlen, maxlen, ' ');
|
||||||
@@ -541,7 +541,7 @@ static LDOUBLE _snp_pow10 (int exp)
|
|||||||
result *= 10;
|
result *= 10;
|
||||||
exp--;
|
exp--;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -567,13 +567,13 @@ static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
|
|||||||
int iplace = 0;
|
int iplace = 0;
|
||||||
int fplace = 0;
|
int fplace = 0;
|
||||||
int padlen = 0; /* amount to pad */
|
int padlen = 0; /* amount to pad */
|
||||||
int zpadlen = 0;
|
int zpadlen = 0;
|
||||||
int caps = 0;
|
int caps = 0;
|
||||||
int total = 0;
|
int total = 0;
|
||||||
long intpart;
|
long intpart;
|
||||||
long fracpart;
|
long fracpart;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* AIX manpage says the default is 0, but Solaris says the default
|
* AIX manpage says the default is 0, but Solaris says the default
|
||||||
* is 6, and sprintf on AIX defaults to 6
|
* is 6, and sprintf on AIX defaults to 6
|
||||||
*/
|
*/
|
||||||
@@ -597,8 +597,8 @@ static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
|
|||||||
|
|
||||||
intpart = ufvalue;
|
intpart = ufvalue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sorry, we only support 9 digits past the decimal because of our
|
* Sorry, we only support 9 digits past the decimal because of our
|
||||||
* conversion method
|
* conversion method
|
||||||
*/
|
*/
|
||||||
if (max > 9)
|
if (max > 9)
|
||||||
@@ -638,18 +638,18 @@ static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
|
|||||||
fconvert[fplace] = 0;
|
fconvert[fplace] = 0;
|
||||||
|
|
||||||
/* -1 for decimal point, another -1 if we are printing a sign */
|
/* -1 for decimal point, another -1 if we are printing a sign */
|
||||||
padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);
|
padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);
|
||||||
zpadlen = max - fplace;
|
zpadlen = max - fplace;
|
||||||
if (zpadlen < 0)
|
if (zpadlen < 0)
|
||||||
zpadlen = 0;
|
zpadlen = 0;
|
||||||
if (padlen < 0)
|
if (padlen < 0)
|
||||||
padlen = 0;
|
padlen = 0;
|
||||||
if (flags & DP_F_MINUS)
|
if (flags & DP_F_MINUS)
|
||||||
padlen = -padlen; /* Left Justifty */
|
padlen = -padlen; /* Left Justifty */
|
||||||
|
|
||||||
if ((flags & DP_F_ZERO) && (padlen > 0))
|
if ((flags & DP_F_ZERO) && (padlen > 0))
|
||||||
{
|
{
|
||||||
if (signvalue)
|
if (signvalue)
|
||||||
{
|
{
|
||||||
total += dopr_outch (buffer, currlen, maxlen, signvalue);
|
total += dopr_outch (buffer, currlen, maxlen, signvalue);
|
||||||
--padlen;
|
--padlen;
|
||||||
@@ -666,10 +666,10 @@ static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
|
|||||||
total += dopr_outch (buffer, currlen, maxlen, ' ');
|
total += dopr_outch (buffer, currlen, maxlen, ' ');
|
||||||
--padlen;
|
--padlen;
|
||||||
}
|
}
|
||||||
if (signvalue)
|
if (signvalue)
|
||||||
total += dopr_outch (buffer, currlen, maxlen, signvalue);
|
total += dopr_outch (buffer, currlen, maxlen, signvalue);
|
||||||
|
|
||||||
while (iplace > 0)
|
while (iplace > 0)
|
||||||
total += dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]);
|
total += dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -680,7 +680,7 @@ static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
|
|||||||
{
|
{
|
||||||
total += dopr_outch (buffer, currlen, maxlen, '.');
|
total += dopr_outch (buffer, currlen, maxlen, '.');
|
||||||
|
|
||||||
while (fplace > 0)
|
while (fplace > 0)
|
||||||
total += dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]);
|
total += dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -690,7 +690,7 @@ static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
|
|||||||
--zpadlen;
|
--zpadlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (padlen < 0)
|
while (padlen < 0)
|
||||||
{
|
{
|
||||||
total += dopr_outch (buffer, currlen, maxlen, ' ');
|
total += dopr_outch (buffer, currlen, maxlen, ' ');
|
||||||
++padlen;
|
++padlen;
|
||||||
@@ -720,7 +720,7 @@ int xmpp_snprintf (char *str,size_t count,const char *fmt,...)
|
|||||||
{
|
{
|
||||||
VA_LOCAL_DECL;
|
VA_LOCAL_DECL;
|
||||||
int total;
|
int total;
|
||||||
|
|
||||||
VA_START (fmt);
|
VA_START (fmt);
|
||||||
total = xmpp_vsnprintf(str, count, fmt, ap);
|
total = xmpp_vsnprintf(str, count, fmt, ap);
|
||||||
VA_END;
|
VA_END;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* sock.c
|
/* sock.c
|
||||||
** strophe XMPP client library -- socket abstraction implementation
|
** strophe XMPP client library -- socket abstraction implementation
|
||||||
**
|
**
|
||||||
** Copyright (C) 2005-2009 Collecta, Inc.
|
** Copyright (C) 2005-2009 Collecta, Inc.
|
||||||
**
|
**
|
||||||
** This software is provided AS-IS with no warranty, either express
|
** This software is provided AS-IS with no warranty, either express
|
||||||
** or implied.
|
** or implied.
|
||||||
@@ -198,7 +198,7 @@ int sock_write(const sock_t sock, const void * const buff, const size_t len)
|
|||||||
int sock_is_recoverable(const int error)
|
int sock_is_recoverable(const int error)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return (error == WSAEINTR || error == WSAEWOULDBLOCK ||
|
return (error == WSAEINTR || error == WSAEWOULDBLOCK ||
|
||||||
error == WSAEINPROGRESS);
|
error == WSAEINPROGRESS);
|
||||||
#else
|
#else
|
||||||
return (error == EAGAIN || error == EINTR);
|
return (error == EAGAIN || error == EINTR);
|
||||||
|
|||||||
46
src/stanza.c
46
src/stanza.c
@@ -51,12 +51,12 @@ xmpp_stanza_t *xmpp_stanza_new(xmpp_ctx_t *ctx)
|
|||||||
stanza->attributes = NULL;
|
stanza->attributes = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return stanza;
|
return stanza;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Clone a stanza object.
|
/** Clone a stanza object.
|
||||||
* This function increments the reference count of the stanza object.
|
* This function increments the reference count of the stanza object.
|
||||||
*
|
*
|
||||||
* @param stanza a Strophe stanza object
|
* @param stanza a Strophe stanza object
|
||||||
*
|
*
|
||||||
* @return the stanza object with it's reference count incremented
|
* @return the stanza object with it's reference count incremented
|
||||||
@@ -202,11 +202,11 @@ xmpp_ctx_t *xmpp_stanza_get_context(const xmpp_stanza_t * const stanza)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Determine if a stanza is a text node.
|
/** Determine if a stanza is a text node.
|
||||||
*
|
*
|
||||||
* @param stanza a Strophe stanza object
|
* @param stanza a Strophe stanza object
|
||||||
*
|
*
|
||||||
* @return TRUE if the stanza is a text node, FALSE otherwise
|
* @return TRUE if the stanza is a text node, FALSE otherwise
|
||||||
*
|
*
|
||||||
* @ingroup Stanza
|
* @ingroup Stanza
|
||||||
*/
|
*/
|
||||||
int xmpp_stanza_is_text(xmpp_stanza_t * const stanza)
|
int xmpp_stanza_is_text(xmpp_stanza_t * const stanza)
|
||||||
@@ -215,11 +215,11 @@ int xmpp_stanza_is_text(xmpp_stanza_t * const stanza)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Determine if a stanza is a tag node.
|
/** Determine if a stanza is a tag node.
|
||||||
*
|
*
|
||||||
* @param stanza a Strophe stanza object
|
* @param stanza a Strophe stanza object
|
||||||
*
|
*
|
||||||
* @return TRUE if the stanza is a tag node, FALSE otherwise
|
* @return TRUE if the stanza is a tag node, FALSE otherwise
|
||||||
*
|
*
|
||||||
* @ingroup Stanza
|
* @ingroup Stanza
|
||||||
*/
|
*/
|
||||||
int xmpp_stanza_is_tag(xmpp_stanza_t * const stanza)
|
int xmpp_stanza_is_tag(xmpp_stanza_t * const stanza)
|
||||||
@@ -466,7 +466,7 @@ int xmpp_stanza_to_text(xmpp_stanza_t *stanza,
|
|||||||
return XMPP_EMEM;
|
return XMPP_EMEM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer[length - 1] = 0;
|
buffer[length - 1] = 0;
|
||||||
|
|
||||||
*buf = buffer;
|
*buf = buffer;
|
||||||
@@ -476,7 +476,7 @@ int xmpp_stanza_to_text(xmpp_stanza_t *stanza,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Set the name of a stanza.
|
/** Set the name of a stanza.
|
||||||
*
|
*
|
||||||
* @param stanza a Strophe stanza object
|
* @param stanza a Strophe stanza object
|
||||||
* @param name a string with the name of the stanza
|
* @param name a string with the name of the stanza
|
||||||
*
|
*
|
||||||
@@ -485,7 +485,7 @@ int xmpp_stanza_to_text(xmpp_stanza_t *stanza,
|
|||||||
*
|
*
|
||||||
* @ingroup Stanza
|
* @ingroup Stanza
|
||||||
*/
|
*/
|
||||||
int xmpp_stanza_set_name(xmpp_stanza_t *stanza,
|
int xmpp_stanza_set_name(xmpp_stanza_t *stanza,
|
||||||
const char * const name)
|
const char * const name)
|
||||||
{
|
{
|
||||||
if (stanza->type == XMPP_STANZA_TEXT) return XMPP_EINVOP;
|
if (stanza->type == XMPP_STANZA_TEXT) return XMPP_EINVOP;
|
||||||
@@ -533,14 +533,14 @@ int xmpp_stanza_get_attribute_count(xmpp_stanza_t * const stanza)
|
|||||||
|
|
||||||
/** Get all attributes for a stanza object.
|
/** Get all attributes for a stanza object.
|
||||||
* This function populates the array with attributes from the stanza. The
|
* This function populates the array with attributes from the stanza. The
|
||||||
* attr array will be in the format: attr[i] = attribute name,
|
* attr array will be in the format: attr[i] = attribute name,
|
||||||
* attr[i+1] = attribute value.
|
* attr[i+1] = attribute value.
|
||||||
*
|
*
|
||||||
* @param stanza a Strophe stanza object
|
* @param stanza a Strophe stanza object
|
||||||
* @param attr the string array to populate
|
* @param attr the string array to populate
|
||||||
* @param attrlen the size of the array
|
* @param attrlen the size of the array
|
||||||
*
|
*
|
||||||
* @return the number of slots used in the array, which will be 2 times the
|
* @return the number of slots used in the array, which will be 2 times the
|
||||||
* number of attributes in the stanza
|
* number of attributes in the stanza
|
||||||
*
|
*
|
||||||
* @ingroup Stanza
|
* @ingroup Stanza
|
||||||
@@ -577,7 +577,7 @@ int xmpp_stanza_get_attributes(xmpp_stanza_t * const stanza,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Set an attribute for a stanza object.
|
/** Set an attribute for a stanza object.
|
||||||
*
|
*
|
||||||
* @param stanza a Strophe stanza object
|
* @param stanza a Strophe stanza object
|
||||||
* @param key a string with the attribute name
|
* @param key a string with the attribute name
|
||||||
* @param value a string with the attribute value
|
* @param value a string with the attribute value
|
||||||
@@ -703,7 +703,7 @@ int xmpp_stanza_set_text(xmpp_stanza_t *stanza,
|
|||||||
const char * const text)
|
const char * const text)
|
||||||
{
|
{
|
||||||
if (stanza->type == XMPP_STANZA_TAG) return XMPP_EINVOP;
|
if (stanza->type == XMPP_STANZA_TAG) return XMPP_EINVOP;
|
||||||
|
|
||||||
stanza->type = XMPP_STANZA_TEXT;
|
stanza->type = XMPP_STANZA_TEXT;
|
||||||
|
|
||||||
if (stanza->data) xmpp_free(stanza->ctx, stanza->data);
|
if (stanza->data) xmpp_free(stanza->ctx, stanza->data);
|
||||||
@@ -723,7 +723,7 @@ int xmpp_stanza_set_text(xmpp_stanza_t *stanza,
|
|||||||
* @param size the length of the text
|
* @param size the length of the text
|
||||||
*
|
*
|
||||||
* @return XMPP_EOK (0) on success and a number less than 0 on failure
|
* @return XMPP_EOK (0) on success and a number less than 0 on failure
|
||||||
*
|
*
|
||||||
* @ingroup Stanza
|
* @ingroup Stanza
|
||||||
*/
|
*/
|
||||||
int xmpp_stanza_set_text_with_size(xmpp_stanza_t *stanza,
|
int xmpp_stanza_set_text_with_size(xmpp_stanza_t *stanza,
|
||||||
@@ -822,7 +822,7 @@ const char *xmpp_stanza_get_from(xmpp_stanza_t * const stanza)
|
|||||||
/** Get the first child of stanza with name.
|
/** Get the first child of stanza with name.
|
||||||
* This function searches all the immediate children of stanza for a child
|
* This function searches all the immediate children of stanza for a child
|
||||||
* stanza that matches the name. The first matching child is returned.
|
* stanza that matches the name. The first matching child is returned.
|
||||||
*
|
*
|
||||||
* @param stanza a Strophe stanza object
|
* @param stanza a Strophe stanza object
|
||||||
* @param name a string with the name to match
|
* @param name a string with the name to match
|
||||||
*
|
*
|
||||||
@@ -830,11 +830,11 @@ const char *xmpp_stanza_get_from(xmpp_stanza_t * const stanza)
|
|||||||
*
|
*
|
||||||
* @ingroup Stanza
|
* @ingroup Stanza
|
||||||
*/
|
*/
|
||||||
xmpp_stanza_t *xmpp_stanza_get_child_by_name(xmpp_stanza_t * const stanza,
|
xmpp_stanza_t *xmpp_stanza_get_child_by_name(xmpp_stanza_t * const stanza,
|
||||||
const char * const name)
|
const char * const name)
|
||||||
{
|
{
|
||||||
xmpp_stanza_t *child;
|
xmpp_stanza_t *child;
|
||||||
|
|
||||||
for (child = stanza->children; child; child = child->next) {
|
for (child = stanza->children; child; child = child->next) {
|
||||||
if (child->type == XMPP_STANZA_TAG &&
|
if (child->type == XMPP_STANZA_TAG &&
|
||||||
(strcmp(name, xmpp_stanza_get_name(child)) == 0))
|
(strcmp(name, xmpp_stanza_get_name(child)) == 0))
|
||||||
@@ -848,7 +848,7 @@ xmpp_stanza_t *xmpp_stanza_get_child_by_name(xmpp_stanza_t * const stanza,
|
|||||||
* This function searches all the immediate children of a stanza for a child
|
* This function searches all the immediate children of a stanza for a child
|
||||||
* stanza that matches the namespace provided. The first matching child
|
* stanza that matches the namespace provided. The first matching child
|
||||||
* is returned.
|
* is returned.
|
||||||
*
|
*
|
||||||
* @param stanza a Strophe stanza object
|
* @param stanza a Strophe stanza object
|
||||||
* @param ns a string with the namespace to match
|
* @param ns a string with the namespace to match
|
||||||
*
|
*
|
||||||
@@ -867,7 +867,7 @@ xmpp_stanza_t *xmpp_stanza_get_child_by_ns(xmpp_stanza_t * const stanza,
|
|||||||
if (child_ns && strcmp(ns, child_ns) == 0)
|
if (child_ns && strcmp(ns, child_ns) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -915,13 +915,13 @@ xmpp_stanza_t *xmpp_stanza_get_child_by_name_and_ns(xmpp_stanza_t * const stanza
|
|||||||
*
|
*
|
||||||
* @ingroup Stanza
|
* @ingroup Stanza
|
||||||
*/
|
*/
|
||||||
xmpp_stanza_t *xmpp_stanza_get_children(xmpp_stanza_t * const stanza)
|
xmpp_stanza_t *xmpp_stanza_get_children(xmpp_stanza_t * const stanza)
|
||||||
{
|
{
|
||||||
return stanza->children;
|
return stanza->children;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the next sibling of a stanza.
|
/** Get the next sibling of a stanza.
|
||||||
*
|
*
|
||||||
* @param stanza a Strophe stanza object
|
* @param stanza a Strophe stanza object
|
||||||
*
|
*
|
||||||
* @return the next sibling stanza or NULL if there are no more siblings
|
* @return the next sibling stanza or NULL if there are no more siblings
|
||||||
@@ -982,7 +982,7 @@ char *xmpp_stanza_get_text(xmpp_stanza_t * const stanza)
|
|||||||
|
|
||||||
/** Get the text data pointer for a text stanza.
|
/** Get the text data pointer for a text stanza.
|
||||||
* This function copies returns the raw pointer to the text data in the
|
* This function copies returns the raw pointer to the text data in the
|
||||||
* stanza. This should only be used in very special cases where the
|
* stanza. This should only be used in very special cases where the
|
||||||
* caller needs to translate the datatype as this will save a double
|
* caller needs to translate the datatype as this will save a double
|
||||||
* allocation. The caller should not hold onto this pointer, and is
|
* allocation. The caller should not hold onto this pointer, and is
|
||||||
* responsible for allocating a copy if it needs one.
|
* responsible for allocating a copy if it needs one.
|
||||||
@@ -1087,7 +1087,7 @@ const char *xmpp_stanza_get_attribute(xmpp_stanza_t * const stanza,
|
|||||||
{
|
{
|
||||||
if (stanza->type != XMPP_STANZA_TAG)
|
if (stanza->type != XMPP_STANZA_TAG)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!stanza->attributes)
|
if (!stanza->attributes)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* tls_dummy.c
|
/* tls_dummy.c
|
||||||
** strophe XMPP client library -- TLS abstraction dummy impl.
|
** strophe XMPP client library -- TLS abstraction dummy impl.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2005-2009 Collecta, Inc.
|
** Copyright (C) 2005-2009 Collecta, Inc.
|
||||||
**
|
**
|
||||||
** This software is provided AS-IS with no warranty, either express
|
** This software is provided AS-IS with no warranty, either express
|
||||||
** or implied.
|
** or implied.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* tls.c
|
/* tls.c
|
||||||
** strophe XMPP client library -- TLS abstraction header
|
** strophe XMPP client library -- TLS abstraction header
|
||||||
**
|
**
|
||||||
** Copyright (C) 2005-2009 Collecta, Inc.
|
** Copyright (C) 2005-2009 Collecta, Inc.
|
||||||
**
|
**
|
||||||
** This software is provided AS-IS with no warranty, either express
|
** This software is provided AS-IS with no warranty, either express
|
||||||
** or implied.
|
** or implied.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* tls_openssl.c
|
/* tls_openssl.c
|
||||||
** strophe XMPP client library -- TLS abstraction openssl impl.
|
** strophe XMPP client library -- TLS abstraction openssl impl.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2005-008 Collecta, Inc.
|
** Copyright (C) 2005-008 Collecta, Inc.
|
||||||
**
|
**
|
||||||
** This software is provided AS-IS with no warranty, either express
|
** This software is provided AS-IS with no warranty, either express
|
||||||
** or implied.
|
** or implied.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* tls_schannel.c
|
/* tls_schannel.c
|
||||||
** strophe XMPP client library -- TLS abstraction schannel impl.
|
** strophe XMPP client library -- TLS abstraction schannel impl.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2005-2009 Collecta, Inc.
|
** Copyright (C) 2005-2009 Collecta, Inc.
|
||||||
**
|
**
|
||||||
** This software is provided AS-IS with no warranty, either express
|
** This software is provided AS-IS with no warranty, either express
|
||||||
** or implied.
|
** or implied.
|
||||||
@@ -298,7 +298,7 @@ int tls_start(tls_t *tls)
|
|||||||
|
|
||||||
FD_ZERO(&fds);
|
FD_ZERO(&fds);
|
||||||
FD_SET(tls->sock, &fds);
|
FD_SET(tls->sock, &fds);
|
||||||
|
|
||||||
select(tls->sock, &fds, NULL, NULL, &tv);
|
select(tls->sock, &fds, NULL, NULL, &tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,7 +311,7 @@ int tls_start(tls_t *tls)
|
|||||||
|
|
||||||
FD_ZERO(&fds);
|
FD_ZERO(&fds);
|
||||||
FD_SET(tls->sock, &fds);
|
FD_SET(tls->sock, &fds);
|
||||||
|
|
||||||
select(tls->sock, &fds, NULL, NULL, &tv);
|
select(tls->sock, &fds, NULL, NULL, &tv);
|
||||||
|
|
||||||
inbytes = sock_read(tls->sock, p, tls->spi->cbMaxToken - len);
|
inbytes = sock_read(tls->sock, p, tls->spi->cbMaxToken - len);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* util.c
|
/* util.c
|
||||||
** strophe XMPP client library -- various utility functions
|
** strophe XMPP client library -- various utility functions
|
||||||
**
|
**
|
||||||
** Copyright (C) 2005-2009 Collecta, Inc.
|
** Copyright (C) 2005-2009 Collecta, Inc.
|
||||||
**
|
**
|
||||||
** This software is provided AS-IS with no warranty, either express
|
** This software is provided AS-IS with no warranty, either express
|
||||||
** or implied.
|
** or implied.
|
||||||
@@ -130,7 +130,7 @@ uint64_t time_elapsed(uint64_t t1, uint64_t t2)
|
|||||||
|
|
||||||
/** Disconnect the stream with a memory error.
|
/** Disconnect the stream with a memory error.
|
||||||
* This is a convenience function used internally by various parts of
|
* This is a convenience function used internally by various parts of
|
||||||
* the Strophe library for terminating the connection because of a
|
* the Strophe library for terminating the connection because of a
|
||||||
* memory error.
|
* memory error.
|
||||||
*
|
*
|
||||||
* @param conn a Strophe connection object
|
* @param conn a Strophe connection object
|
||||||
|
|||||||
24
strophe.h
24
strophe.h
@@ -83,7 +83,7 @@ extern "C" {
|
|||||||
#define XMPP_EOK 0
|
#define XMPP_EOK 0
|
||||||
/** @def XMPP_EMEM
|
/** @def XMPP_EMEM
|
||||||
* Memory related failure error code.
|
* Memory related failure error code.
|
||||||
*
|
*
|
||||||
* This is returned on allocation errors and signals that the host may
|
* This is returned on allocation errors and signals that the host may
|
||||||
* be out of memory.
|
* be out of memory.
|
||||||
*/
|
*/
|
||||||
@@ -118,7 +118,7 @@ typedef struct _xmpp_log_t xmpp_log_t;
|
|||||||
/* opaque run time context containing the above hooks */
|
/* opaque run time context containing the above hooks */
|
||||||
typedef struct _xmpp_ctx_t xmpp_ctx_t;
|
typedef struct _xmpp_ctx_t xmpp_ctx_t;
|
||||||
|
|
||||||
xmpp_ctx_t *xmpp_ctx_new(const xmpp_mem_t * const mem,
|
xmpp_ctx_t *xmpp_ctx_new(const xmpp_mem_t * const mem,
|
||||||
const xmpp_log_t * const log);
|
const xmpp_log_t * const log);
|
||||||
void xmpp_ctx_free(xmpp_ctx_t * const ctx);
|
void xmpp_ctx_free(xmpp_ctx_t * const ctx);
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ typedef enum {
|
|||||||
XMPP_COMPONENT
|
XMPP_COMPONENT
|
||||||
} xmpp_conn_type_t;
|
} xmpp_conn_type_t;
|
||||||
|
|
||||||
typedef void (*xmpp_log_handler)(void * const userdata,
|
typedef void (*xmpp_log_handler)(void * const userdata,
|
||||||
const xmpp_log_level_t level,
|
const xmpp_log_level_t level,
|
||||||
const char * const area,
|
const char * const area,
|
||||||
const char * const msg);
|
const char * const msg);
|
||||||
@@ -219,7 +219,7 @@ typedef struct {
|
|||||||
xmpp_stanza_t *stanza;
|
xmpp_stanza_t *stanza;
|
||||||
} xmpp_stream_error_t;
|
} xmpp_stream_error_t;
|
||||||
|
|
||||||
typedef void (*xmpp_conn_handler)(xmpp_conn_t * const conn,
|
typedef void (*xmpp_conn_handler)(xmpp_conn_t * const conn,
|
||||||
const xmpp_conn_event_t event,
|
const xmpp_conn_event_t event,
|
||||||
const int error,
|
const int error,
|
||||||
xmpp_stream_error_t * const stream_error,
|
xmpp_stream_error_t * const stream_error,
|
||||||
@@ -245,7 +245,7 @@ int xmpp_conn_is_connecting(xmpp_conn_t * const conn);
|
|||||||
int xmpp_conn_is_connected(xmpp_conn_t * const conn);
|
int xmpp_conn_is_connected(xmpp_conn_t * const conn);
|
||||||
int xmpp_conn_is_disconnected(xmpp_conn_t * const conn);
|
int xmpp_conn_is_disconnected(xmpp_conn_t * const conn);
|
||||||
|
|
||||||
int xmpp_connect_client(xmpp_conn_t * const conn,
|
int xmpp_connect_client(xmpp_conn_t * const conn,
|
||||||
const char * const altdomain,
|
const char * const altdomain,
|
||||||
unsigned short altport,
|
unsigned short altport,
|
||||||
xmpp_conn_handler callback,
|
xmpp_conn_handler callback,
|
||||||
@@ -270,16 +270,16 @@ void xmpp_disconnect(xmpp_conn_t * const conn);
|
|||||||
void xmpp_send(xmpp_conn_t * const conn,
|
void xmpp_send(xmpp_conn_t * const conn,
|
||||||
xmpp_stanza_t * const stanza);
|
xmpp_stanza_t * const stanza);
|
||||||
|
|
||||||
void xmpp_send_raw_string(xmpp_conn_t * const conn,
|
void xmpp_send_raw_string(xmpp_conn_t * const conn,
|
||||||
const char * const fmt, ...);
|
const char * const fmt, ...);
|
||||||
void xmpp_send_raw(xmpp_conn_t * const conn,
|
void xmpp_send_raw(xmpp_conn_t * const conn,
|
||||||
const char * const data, const size_t len);
|
const char * const data, const size_t len);
|
||||||
|
|
||||||
|
|
||||||
/* handlers */
|
/* handlers */
|
||||||
|
|
||||||
/* if the handle returns false it is removed */
|
/* if the handle returns false it is removed */
|
||||||
typedef int (*xmpp_timed_handler)(xmpp_conn_t * const conn,
|
typedef int (*xmpp_timed_handler)(xmpp_conn_t * const conn,
|
||||||
void * const userdata);
|
void * const userdata);
|
||||||
|
|
||||||
void xmpp_timed_handler_add(xmpp_conn_t * const conn,
|
void xmpp_timed_handler_add(xmpp_conn_t * const conn,
|
||||||
@@ -336,11 +336,11 @@ int xmpp_stanza_is_text(xmpp_stanza_t * const stanza);
|
|||||||
int xmpp_stanza_is_tag(xmpp_stanza_t * const stanza);
|
int xmpp_stanza_is_tag(xmpp_stanza_t * const stanza);
|
||||||
|
|
||||||
/* marshall a stanza into text for transmission or display */
|
/* marshall a stanza into text for transmission or display */
|
||||||
int xmpp_stanza_to_text(xmpp_stanza_t *stanza,
|
int xmpp_stanza_to_text(xmpp_stanza_t *stanza,
|
||||||
char ** const buf, size_t * const buflen);
|
char ** const buf, size_t * const buflen);
|
||||||
|
|
||||||
xmpp_stanza_t *xmpp_stanza_get_children(xmpp_stanza_t * const stanza);
|
xmpp_stanza_t *xmpp_stanza_get_children(xmpp_stanza_t * const stanza);
|
||||||
xmpp_stanza_t *xmpp_stanza_get_child_by_name(xmpp_stanza_t * const stanza,
|
xmpp_stanza_t *xmpp_stanza_get_child_by_name(xmpp_stanza_t * const stanza,
|
||||||
const char * const name);
|
const char * const name);
|
||||||
xmpp_stanza_t *xmpp_stanza_get_child_by_ns(xmpp_stanza_t * const stanza,
|
xmpp_stanza_t *xmpp_stanza_get_child_by_ns(xmpp_stanza_t * const stanza,
|
||||||
const char * const ns);
|
const char * const ns);
|
||||||
@@ -363,7 +363,7 @@ char *xmpp_stanza_get_text(xmpp_stanza_t * const stanza);
|
|||||||
const char *xmpp_stanza_get_text_ptr(xmpp_stanza_t * const stanza);
|
const char *xmpp_stanza_get_text_ptr(xmpp_stanza_t * const stanza);
|
||||||
const char *xmpp_stanza_get_name(xmpp_stanza_t * const stanza);
|
const char *xmpp_stanza_get_name(xmpp_stanza_t * const stanza);
|
||||||
/* set_attribute adds/replaces attributes */
|
/* set_attribute adds/replaces attributes */
|
||||||
int xmpp_stanza_set_attribute(xmpp_stanza_t * const stanza,
|
int xmpp_stanza_set_attribute(xmpp_stanza_t * const stanza,
|
||||||
const char * const key,
|
const char * const key,
|
||||||
const char * const value);
|
const char * const value);
|
||||||
int xmpp_stanza_set_name(xmpp_stanza_t *stanza,
|
int xmpp_stanza_set_name(xmpp_stanza_t *stanza,
|
||||||
@@ -371,7 +371,7 @@ int xmpp_stanza_set_name(xmpp_stanza_t *stanza,
|
|||||||
int xmpp_stanza_set_text(xmpp_stanza_t *stanza,
|
int xmpp_stanza_set_text(xmpp_stanza_t *stanza,
|
||||||
const char * const text);
|
const char * const text);
|
||||||
int xmpp_stanza_set_text_with_size(xmpp_stanza_t *stanza,
|
int xmpp_stanza_set_text_with_size(xmpp_stanza_t *stanza,
|
||||||
const char * const text,
|
const char * const text,
|
||||||
const size_t size);
|
const size_t size);
|
||||||
int xmpp_stanza_del_attribute(xmpp_stanza_t * const stanza,
|
int xmpp_stanza_del_attribute(xmpp_stanza_t * const stanza,
|
||||||
const char * const name);
|
const char * const name);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* check_parser.h
|
/* check_parser.h
|
||||||
** strophe XMPP client library -- parser tests
|
** strophe XMPP client library -- parser tests
|
||||||
**
|
**
|
||||||
** Copyright (C) 2005-2009 Collecta, Inc.
|
** Copyright (C) 2005-2009 Collecta, Inc.
|
||||||
**
|
**
|
||||||
** This software is provided AS-IS with no warranty, either express or
|
** This software is provided AS-IS with no warranty, either express or
|
||||||
** implied.
|
** implied.
|
||||||
@@ -67,8 +67,8 @@ static void callbacks(void)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ctx = xmpp_ctx_new(NULL, NULL);
|
ctx = xmpp_ctx_new(NULL, NULL);
|
||||||
parser = parser_new(ctx,
|
parser = parser_new(ctx,
|
||||||
cbtest_handle_start,
|
cbtest_handle_start,
|
||||||
cbtest_handle_end,
|
cbtest_handle_end,
|
||||||
cbtest_handle_stanza, NULL);
|
cbtest_handle_stanza, NULL);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* test_ctx.c
|
/* test_ctx.c
|
||||||
** libstrophe XMPP client library -- test routines for the library run-time context
|
** libstrophe XMPP client library -- test routines for the library run-time context
|
||||||
**
|
**
|
||||||
** Copyright (C) 2005-2009 Collecta, Inc.
|
** Copyright (C) 2005-2009 Collecta, Inc.
|
||||||
**
|
**
|
||||||
** This software is provided AS-IS with no warranty, either express
|
** This software is provided AS-IS with no warranty, either express
|
||||||
** or implied.
|
** or implied.
|
||||||
@@ -91,11 +91,11 @@ int main(int argc, char **argv)
|
|||||||
xmpp_ctx_free(ctx);
|
xmpp_ctx_free(ctx);
|
||||||
|
|
||||||
/* check for test failure */
|
/* check for test failure */
|
||||||
if (!(log_called && mem_alloc_called && mem_realloc_called &&
|
if (!(log_called && mem_alloc_called && mem_realloc_called &&
|
||||||
mem_free_called))
|
mem_free_called))
|
||||||
return 1;
|
return 1;
|
||||||
if (mem_alloc_called != mem_free_called)
|
if (mem_alloc_called != mem_free_called)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* test_hash.c
|
/* test_hash.c
|
||||||
** libstrophe XMPP client library -- self-test for the hash-table implementation
|
** libstrophe XMPP client library -- self-test for the hash-table implementation
|
||||||
**
|
**
|
||||||
** Copyright (C) 2005-2009 Collecta, Inc.
|
** Copyright (C) 2005-2009 Collecta, Inc.
|
||||||
**
|
**
|
||||||
** This software is provided AS-IS with no warranty, either express
|
** This software is provided AS-IS with no warranty, either express
|
||||||
** or implied.
|
** or implied.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* test_sasl.c
|
/* test_sasl.c
|
||||||
** libstrophe XMPP client library -- test routines for the SASL implementation
|
** libstrophe XMPP client library -- test routines for the SASL implementation
|
||||||
**
|
**
|
||||||
** Copyright (C) 2005-2009 Collecta, Inc.
|
** Copyright (C) 2005-2009 Collecta, Inc.
|
||||||
**
|
**
|
||||||
** This software is provided AS-IS with no warranty, either express
|
** This software is provided AS-IS with no warranty, either express
|
||||||
** or implied.
|
** or implied.
|
||||||
@@ -20,7 +20,7 @@ static const unsigned char jid[] = "foo@bar.com";
|
|||||||
static const char password[] = "secret";
|
static const char password[] = "secret";
|
||||||
static const char response_plain[] = "AGZvb0BiYXIuY29tAHNlY3JldA==";
|
static const char response_plain[] = "AGZvb0BiYXIuY29tAHNlY3JldA==";
|
||||||
|
|
||||||
static const char challenge_md5[] =
|
static const char challenge_md5[] =
|
||||||
"cmVhbG09InNvbWVyZWFsbSIsbm9uY2U9Ik9BNk1HOXRFUUdtMmhoIixxb3A9ImF1dGgi"
|
"cmVhbG09InNvbWVyZWFsbSIsbm9uY2U9Ik9BNk1HOXRFUUdtMmhoIixxb3A9ImF1dGgi"
|
||||||
"LGNoYXJzZXQ9dXRmLTgsYWxnb3JpdGhtPW1kNS1zZXNzCg==";
|
"LGNoYXJzZXQ9dXRmLTgsYWxnb3JpdGhtPW1kNS1zZXNzCg==";
|
||||||
static const char response_md5[] =
|
static const char response_md5[] =
|
||||||
@@ -85,13 +85,13 @@ int main(int argc, char *argv[])
|
|||||||
xmpp_ctx_t *ctx;
|
xmpp_ctx_t *ctx;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
printf("allocating context... ");
|
printf("allocating context... ");
|
||||||
ctx = xmpp_ctx_new(NULL, NULL);
|
ctx = xmpp_ctx_new(NULL, NULL);
|
||||||
if (ctx == NULL) printf("failed to create context\n");
|
if (ctx == NULL) printf("failed to create context\n");
|
||||||
if (ctx == NULL) return -1;
|
if (ctx == NULL) return -1;
|
||||||
printf("ok.\n");
|
printf("ok.\n");
|
||||||
|
|
||||||
printf("testing SASL PLAIN... ");
|
printf("testing SASL PLAIN... ");
|
||||||
ret = test_plain(ctx);
|
ret = test_plain(ctx);
|
||||||
if (ret) printf("failed!\n");
|
if (ret) printf("failed!\n");
|
||||||
if (ret) return ret;
|
if (ret) return ret;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* test_sock.c
|
/* test_sock.c
|
||||||
** libstrophe XMPP client library -- test routines for the socket abstraction
|
** libstrophe XMPP client library -- test routines for the socket abstraction
|
||||||
**
|
**
|
||||||
** Copyright (C) 2005-2009 Collecta, Inc.
|
** Copyright (C) 2005-2009 Collecta, Inc.
|
||||||
**
|
**
|
||||||
** This software is provided AS-IS with no warranty, either express
|
** This software is provided AS-IS with no warranty, either express
|
||||||
** or implied.
|
** or implied.
|
||||||
|
|||||||
Reference in New Issue
Block a user