trim trailing spaces
This commit is contained in:
committed by
Dmitry Podgorny
parent
3feed16e2e
commit
abd1b08a97
@@ -1,7 +1,7 @@
|
||||
/* active.c
|
||||
** 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
|
||||
** or implied.
|
||||
@@ -32,7 +32,7 @@ int handle_reply(xmpp_conn_t * const conn,
|
||||
else {
|
||||
query = xmpp_stanza_get_child_by_name(stanza, "query");
|
||||
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))
|
||||
printf("\t %s\n", xmpp_stanza_get_attribute(item, "jid"));
|
||||
printf("END OF LIST\n");
|
||||
@@ -44,7 +44,7 @@ int handle_reply(xmpp_conn_t * const conn,
|
||||
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,
|
||||
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) {
|
||||
fprintf(stderr, "DEBUG: connected\n");
|
||||
|
||||
|
||||
/* create iq stanza for request */
|
||||
iq = xmpp_iq_new(ctx, "get", "active1");
|
||||
xmpp_stanza_set_to(iq, "xxxxxxxxx.com");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* bot.c
|
||||
** 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
|
||||
** or implied.
|
||||
@@ -10,7 +10,7 @@
|
||||
*/
|
||||
|
||||
/* simple bot example
|
||||
**
|
||||
**
|
||||
** This example was provided by Matthew Wild <mwild1@gmail.com>.
|
||||
**
|
||||
** 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 */
|
||||
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,
|
||||
void * const userdata)
|
||||
{
|
||||
@@ -178,7 +178,7 @@ int main(int argc, char **argv)
|
||||
/* initiate connection */
|
||||
xmpp_connect_client(conn, NULL, 0, conn_handler, ctx);
|
||||
|
||||
/* enter the event loop -
|
||||
/* enter the event loop -
|
||||
our connect handler will trigger an exit */
|
||||
xmpp_run(ctx);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* roster.c
|
||||
** 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
|
||||
** or implied.
|
||||
@@ -31,10 +31,10 @@ int handle_reply(xmpp_conn_t * const conn,
|
||||
else {
|
||||
query = xmpp_stanza_get_child_by_name(stanza, "query");
|
||||
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))
|
||||
if ((name = xmpp_stanza_get_attribute(item, "name")))
|
||||
printf("\t %s (%s) sub=%s\n",
|
||||
printf("\t %s (%s) sub=%s\n",
|
||||
name,
|
||||
xmpp_stanza_get_attribute(item, "jid"),
|
||||
xmpp_stanza_get_attribute(item, "subscription"));
|
||||
@@ -51,7 +51,7 @@ int handle_reply(xmpp_conn_t * const conn,
|
||||
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,
|
||||
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) {
|
||||
fprintf(stderr, "DEBUG: connected\n");
|
||||
|
||||
|
||||
/* create iq stanza for request */
|
||||
iq = xmpp_iq_new(ctx, "get", "roster1");
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ struct _xmpp_ctx_t {
|
||||
|
||||
/* convenience functions for accessing the context */
|
||||
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);
|
||||
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_trust;
|
||||
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 */
|
||||
int auth_legacy_enabled;
|
||||
int secured; /* set when stream is secured with TLS */
|
||||
@@ -207,7 +207,7 @@ struct _xmpp_conn_t {
|
||||
|
||||
/* user handlers only get called after authentication */
|
||||
int authenticated;
|
||||
|
||||
|
||||
/* connection events handler */
|
||||
xmpp_conn_handler conn_handler;
|
||||
void *userdata;
|
||||
@@ -238,7 +238,7 @@ struct _xmpp_stanza_t {
|
||||
xmpp_ctx_t *ctx;
|
||||
|
||||
xmpp_stanza_type_t type;
|
||||
|
||||
|
||||
xmpp_stanza_t *prev;
|
||||
xmpp_stanza_t *next;
|
||||
xmpp_stanza_t *children;
|
||||
|
||||
18
src/conn.c
18
src/conn.c
@@ -34,7 +34,7 @@
|
||||
#define DEFAULT_SEND_QUEUE_MAX 64
|
||||
#endif
|
||||
#ifndef DISCONNECT_TIMEOUT
|
||||
/** @def DISCONNECT_TIMEOUT
|
||||
/** @def DISCONNECT_TIMEOUT
|
||||
* The time to wait (in milliseconds) for graceful disconnection to
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return conn;
|
||||
}
|
||||
|
||||
/** Clone a Strophe connection object.
|
||||
*
|
||||
*
|
||||
* @param conn a Strophe connection object
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
*
|
||||
* @param conn a Strophe connection object
|
||||
*
|
||||
* @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.
|
||||
* If any password was previously set, it will be discarded. The function
|
||||
* will make a copy of the password string.
|
||||
*
|
||||
*
|
||||
* @param conn a Strophe connection object
|
||||
* @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.
|
||||
* @param conn a Strophe connection object
|
||||
*
|
||||
*
|
||||
* @return a Strophe context
|
||||
*
|
||||
*
|
||||
* @ingroup Connections
|
||||
*/
|
||||
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
|
||||
* 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
|
||||
* 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.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
void conn_disconnect(xmpp_conn_t * const conn)
|
||||
void conn_disconnect(xmpp_conn_t * const conn)
|
||||
{
|
||||
xmpp_debug(conn->ctx, "xmpp", "Closing socket.");
|
||||
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. */
|
||||
|
||||
/* Wrap stdlib routines malloc, free, and realloc for default memory
|
||||
* management.
|
||||
* management.
|
||||
*/
|
||||
static void *_malloc(const size_t size, void * const userdata)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* event.c
|
||||
** 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
|
||||
** or implied.
|
||||
|
||||
10
src/hash.c
10
src/hash.c
@@ -1,7 +1,7 @@
|
||||
/* hash.c
|
||||
** 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
|
||||
** or implied.
|
||||
@@ -44,7 +44,7 @@ struct _hash_iterator_t {
|
||||
hashentry_t *entry;
|
||||
int index;
|
||||
};
|
||||
|
||||
|
||||
/** allocate and initialize a new hash table */
|
||||
hash_t *hash_new(xmpp_ctx_t * const ctx, const int size,
|
||||
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 */
|
||||
result->ref = 1;
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ void hash_release(hash_t * const table)
|
||||
xmpp_ctx_t *ctx = table->ctx;
|
||||
hashentry_t *entry, *next;
|
||||
int i;
|
||||
|
||||
|
||||
if (table->ref > 1)
|
||||
table->ref--;
|
||||
else {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* jid.c
|
||||
** 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
|
||||
** or implied.
|
||||
@@ -63,7 +63,7 @@ char *xmpp_jid_new(xmpp_ctx_t *ctx, const char *node,
|
||||
}
|
||||
|
||||
/** Create a bare JID from a JID.
|
||||
*
|
||||
*
|
||||
* @param ctx the Strophe context object
|
||||
* @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.
|
||||
*
|
||||
*
|
||||
* @param ctx a Strophe context object
|
||||
* @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 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
|
||||
*/
|
||||
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)
|
||||
*/
|
||||
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;
|
||||
uint32_t in[16];
|
||||
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
in[i] = GET_32BIT_LSB_FIRST(inext + 4 * i);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* parser.c
|
||||
** 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
|
||||
** or implied.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* parser.c
|
||||
** 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
|
||||
** or implied.
|
||||
@@ -104,7 +104,7 @@ static void _free_cbattrs(parser_t *parser, char **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 *uri, int nnamespaces,
|
||||
const xmlChar **namespaces, int nattrs,
|
||||
@@ -118,7 +118,7 @@ static void _start_element(void *userdata,
|
||||
/* notify the owner */
|
||||
if (parser->startcb) {
|
||||
cbattrs = _convert_attrs(parser, nattrs, attrs);
|
||||
parser->startcb((char *)name, cbattrs,
|
||||
parser->startcb((char *)name, cbattrs,
|
||||
parser->userdata);
|
||||
_free_cbattrs(parser, cbattrs);
|
||||
}
|
||||
@@ -151,7 +151,7 @@ static void _start_element(void *userdata,
|
||||
|
||||
/* add child to parent */
|
||||
xmpp_stanza_add_child(parser->stanza, child);
|
||||
|
||||
|
||||
/* the child is owned by the toplevel stanza now */
|
||||
xmpp_stanza_release(child);
|
||||
|
||||
@@ -259,13 +259,13 @@ int parser_reset(parser_t *parser)
|
||||
{
|
||||
if (parser->xmlctx)
|
||||
xmlFreeParserCtxt(parser->xmlctx);
|
||||
if (parser->stanza)
|
||||
if (parser->stanza)
|
||||
xmpp_stanza_release(parser->stanza);
|
||||
|
||||
parser->stanza = NULL;
|
||||
parser->depth = 0;
|
||||
|
||||
parser->xmlctx = xmlCreatePushParserCtxt(&parser->handlers,
|
||||
parser->xmlctx = xmlCreatePushParserCtxt(&parser->handlers,
|
||||
parser, NULL, 0, NULL);
|
||||
|
||||
return parser->xmlctx ? 1 : 0;
|
||||
|
||||
30
src/sasl.c
30
src/sasl.c
@@ -1,7 +1,7 @@
|
||||
/* sasl.c
|
||||
** 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
|
||||
** or implied.
|
||||
@@ -43,7 +43,7 @@ char *sasl_plain(xmpp_ctx_t *ctx, const char *authid, const char *password) {
|
||||
size_t msglen;
|
||||
char *result = NULL;
|
||||
char *msg;
|
||||
|
||||
|
||||
/* our message is Base64(authzid,\0,authid,\0,password)
|
||||
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 */
|
||||
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)
|
||||
{
|
||||
int olen,nlen;
|
||||
@@ -230,7 +230,7 @@ char *sasl_digest_md5(xmpp_ctx_t *ctx, const char *challenge,
|
||||
char hex[32];
|
||||
char cnonce[13];
|
||||
|
||||
/* our digest response is
|
||||
/* our digest response is
|
||||
Hex( KD( HEX(MD5(A1)),
|
||||
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));
|
||||
value[5+strlen(domain)] = '\0';
|
||||
hash_add(table, "digest-uri", value);
|
||||
|
||||
|
||||
/* generate response */
|
||||
|
||||
/* construct MD5(node : realm : password) */
|
||||
@@ -341,16 +341,16 @@ char *sasl_digest_md5(xmpp_ctx_t *ctx, const char *challenge,
|
||||
/* construct reply */
|
||||
result = NULL;
|
||||
rlen = 0;
|
||||
result = _add_key(ctx, table, "username", 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, "cnonce", result, &rlen, 1);
|
||||
result = _add_key(ctx, table, "nc", 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, "response", result, &rlen, 0);
|
||||
result = _add_key(ctx, table, "username", 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, "cnonce", result, &rlen, 1);
|
||||
result = _add_key(ctx, table, "nc", 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, "response", result, &rlen, 0);
|
||||
result = _add_key(ctx, table, "charset", result, &rlen, 0);
|
||||
|
||||
|
||||
xmpp_free(ctx, node);
|
||||
xmpp_free(ctx, domain);
|
||||
hash_release(table); /* also frees value strings */
|
||||
|
||||
@@ -8,7 +8,7 @@ By Steve Reid <sreid@sea-to-sky.net>
|
||||
100% Public Domain
|
||||
|
||||
-----------------
|
||||
Modified 7/98
|
||||
Modified 7/98
|
||||
By James H. Brown <jbrown@burgoyne.com>
|
||||
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
|
||||
"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.
|
||||
|
||||
These changes should make no difference to any 32 bit implementations since
|
||||
@@ -57,7 +57,7 @@ Still 100% public domain
|
||||
Modified 4/01
|
||||
By Saul Kravitz <Saul.Kravitz@celera.com>
|
||||
Still 100% PD
|
||||
Modified to run on Compaq Alpha hardware.
|
||||
Modified to run on Compaq Alpha hardware.
|
||||
|
||||
-----------------
|
||||
Modified 07/2002
|
||||
@@ -232,7 +232,7 @@ void crypto_SHA1_Final(SHA1_CTX* context, uint8_t* digest)
|
||||
digest[i] = (uint8_t)
|
||||
((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
|
||||
}
|
||||
|
||||
|
||||
/* Wipe variables */
|
||||
memset(context->buffer, 0, 64);
|
||||
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:
|
||||
* gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm
|
||||
* and run snprintf for results.
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Michael Elkins <me@cs.hmc.edu> 03/05/98 for mutt 0.90.8
|
||||
@@ -85,7 +85,7 @@
|
||||
#define LDOUBLE double
|
||||
#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);
|
||||
static int fmtstr (char *buffer, size_t *currlen, size_t maxlen,
|
||||
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 total;
|
||||
size_t currlen;
|
||||
|
||||
|
||||
state = DP_S_DEFAULT;
|
||||
currlen = flags = cflags = min = 0;
|
||||
max = -1;
|
||||
@@ -152,17 +152,17 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args)
|
||||
if (ch == '\0')
|
||||
state = DP_S_DONE;
|
||||
|
||||
switch(state)
|
||||
switch(state)
|
||||
{
|
||||
case DP_S_DEFAULT:
|
||||
if (ch == '%')
|
||||
if (ch == '%')
|
||||
state = DP_S_FLAGS;
|
||||
else
|
||||
else
|
||||
total += dopr_outch (buffer, &currlen, maxlen, ch);
|
||||
ch = *format++;
|
||||
break;
|
||||
case DP_S_FLAGS:
|
||||
switch (ch)
|
||||
switch (ch)
|
||||
{
|
||||
case '-':
|
||||
flags |= DP_F_MINUS;
|
||||
@@ -190,49 +190,49 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args)
|
||||
}
|
||||
break;
|
||||
case DP_S_MIN:
|
||||
if (isdigit(ch))
|
||||
if (isdigit(ch))
|
||||
{
|
||||
min = 10*min + char_to_int (ch);
|
||||
ch = *format++;
|
||||
}
|
||||
else if (ch == '*')
|
||||
}
|
||||
else if (ch == '*')
|
||||
{
|
||||
min = va_arg (args, int);
|
||||
ch = *format++;
|
||||
state = DP_S_DOT;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
state = DP_S_DOT;
|
||||
break;
|
||||
case DP_S_DOT:
|
||||
if (ch == '.')
|
||||
if (ch == '.')
|
||||
{
|
||||
state = DP_S_MAX;
|
||||
ch = *format++;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
state = DP_S_MOD;
|
||||
break;
|
||||
case DP_S_MAX:
|
||||
if (isdigit(ch))
|
||||
if (isdigit(ch))
|
||||
{
|
||||
if (max < 0)
|
||||
max = 0;
|
||||
max = 10*max + char_to_int (ch);
|
||||
ch = *format++;
|
||||
}
|
||||
else if (ch == '*')
|
||||
}
|
||||
else if (ch == '*')
|
||||
{
|
||||
max = va_arg (args, int);
|
||||
ch = *format++;
|
||||
state = DP_S_MOD;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
state = DP_S_MOD;
|
||||
break;
|
||||
case DP_S_MOD:
|
||||
/* Currently, we don't support Long Long, bummer */
|
||||
switch (ch)
|
||||
switch (ch)
|
||||
{
|
||||
case 'h':
|
||||
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;
|
||||
break;
|
||||
case DP_S_CONV:
|
||||
switch (ch)
|
||||
switch (ch)
|
||||
{
|
||||
case 'd':
|
||||
case 'i':
|
||||
if (cflags == DP_C_SHORT)
|
||||
if (cflags == DP_C_SHORT)
|
||||
value = va_arg (args, int);
|
||||
else if (cflags == DP_C_LONG)
|
||||
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);
|
||||
break;
|
||||
case 'n':
|
||||
if (cflags == DP_C_SHORT)
|
||||
if (cflags == DP_C_SHORT)
|
||||
{
|
||||
short int *num;
|
||||
num = va_arg (args, short int *);
|
||||
*num = currlen;
|
||||
}
|
||||
else if (cflags == DP_C_LONG)
|
||||
}
|
||||
else if (cflags == DP_C_LONG)
|
||||
{
|
||||
long int *num;
|
||||
num = va_arg (args, long int *);
|
||||
*num = currlen;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
int *num;
|
||||
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 (currlen < maxlen - 1)
|
||||
if (currlen < maxlen - 1)
|
||||
buffer[currlen] = '\0';
|
||||
else
|
||||
else
|
||||
buffer[maxlen - 1] = '\0';
|
||||
}
|
||||
return total;
|
||||
@@ -394,7 +394,7 @@ static int fmtstr (char *buffer, size_t *currlen, size_t maxlen,
|
||||
int padlen, strln; /* amount to pad */
|
||||
int cnt = 0;
|
||||
int total = 0;
|
||||
|
||||
|
||||
if (value == 0)
|
||||
{
|
||||
value = "<NULL>";
|
||||
@@ -404,9 +404,9 @@ static int fmtstr (char *buffer, size_t *currlen, size_t maxlen,
|
||||
if (max >= 0 && max < strln)
|
||||
strln = max;
|
||||
padlen = min - strln;
|
||||
if (padlen < 0)
|
||||
if (padlen < 0)
|
||||
padlen = 0;
|
||||
if (flags & DP_F_MINUS)
|
||||
if (flags & DP_F_MINUS)
|
||||
padlen = -padlen; /* Left Justify */
|
||||
|
||||
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 caps = 0;
|
||||
int total = 0;
|
||||
|
||||
|
||||
if (max < 0)
|
||||
max = 0;
|
||||
|
||||
@@ -459,7 +459,7 @@ static int fmtint (char *buffer, size_t *currlen, size_t maxlen,
|
||||
if (flags & DP_F_SPACE)
|
||||
signvalue = ' ';
|
||||
}
|
||||
|
||||
|
||||
if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
|
||||
|
||||
do {
|
||||
@@ -480,7 +480,7 @@ static int fmtint (char *buffer, size_t *currlen, size_t maxlen,
|
||||
zpadlen = MAX(zpadlen, spadlen);
|
||||
spadlen = 0;
|
||||
}
|
||||
if (flags & DP_F_MINUS)
|
||||
if (flags & DP_F_MINUS)
|
||||
spadlen = -spadlen; /* Left Justifty */
|
||||
|
||||
#ifdef DEBUG_SNPRINTF
|
||||
@@ -489,18 +489,18 @@ static int fmtint (char *buffer, size_t *currlen, size_t maxlen,
|
||||
#endif
|
||||
|
||||
/* Spaces */
|
||||
while (spadlen > 0)
|
||||
while (spadlen > 0)
|
||||
{
|
||||
total += dopr_outch (buffer, currlen, maxlen, ' ');
|
||||
--spadlen;
|
||||
}
|
||||
|
||||
/* Sign */
|
||||
if (signvalue)
|
||||
if (signvalue)
|
||||
total += dopr_outch (buffer, currlen, maxlen, signvalue);
|
||||
|
||||
/* Zeros */
|
||||
if (zpadlen > 0)
|
||||
if (zpadlen > 0)
|
||||
{
|
||||
while (zpadlen > 0)
|
||||
{
|
||||
@@ -510,9 +510,9 @@ static int fmtint (char *buffer, size_t *currlen, size_t maxlen,
|
||||
}
|
||||
|
||||
/* Digits */
|
||||
while (place > 0)
|
||||
while (place > 0)
|
||||
total += dopr_outch (buffer, currlen, maxlen, convert[--place]);
|
||||
|
||||
|
||||
/* Left Justified spaces */
|
||||
while (spadlen < 0) {
|
||||
total += dopr_outch (buffer, currlen, maxlen, ' ');
|
||||
@@ -541,7 +541,7 @@ static LDOUBLE _snp_pow10 (int exp)
|
||||
result *= 10;
|
||||
exp--;
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -567,13 +567,13 @@ static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
|
||||
int iplace = 0;
|
||||
int fplace = 0;
|
||||
int padlen = 0; /* amount to pad */
|
||||
int zpadlen = 0;
|
||||
int zpadlen = 0;
|
||||
int caps = 0;
|
||||
int total = 0;
|
||||
long intpart;
|
||||
long fracpart;
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
* AIX manpage says the default is 0, but Solaris says the default
|
||||
* 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;
|
||||
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
if (max > 9)
|
||||
@@ -638,18 +638,18 @@ static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
|
||||
fconvert[fplace] = 0;
|
||||
|
||||
/* -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;
|
||||
if (zpadlen < 0)
|
||||
zpadlen = 0;
|
||||
if (padlen < 0)
|
||||
if (padlen < 0)
|
||||
padlen = 0;
|
||||
if (flags & DP_F_MINUS)
|
||||
if (flags & DP_F_MINUS)
|
||||
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);
|
||||
--padlen;
|
||||
@@ -666,10 +666,10 @@ static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
|
||||
total += dopr_outch (buffer, currlen, maxlen, ' ');
|
||||
--padlen;
|
||||
}
|
||||
if (signvalue)
|
||||
if (signvalue)
|
||||
total += dopr_outch (buffer, currlen, maxlen, signvalue);
|
||||
|
||||
while (iplace > 0)
|
||||
while (iplace > 0)
|
||||
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, '.');
|
||||
|
||||
while (fplace > 0)
|
||||
while (fplace > 0)
|
||||
total += dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]);
|
||||
}
|
||||
|
||||
@@ -690,7 +690,7 @@ static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
|
||||
--zpadlen;
|
||||
}
|
||||
|
||||
while (padlen < 0)
|
||||
while (padlen < 0)
|
||||
{
|
||||
total += dopr_outch (buffer, currlen, maxlen, ' ');
|
||||
++padlen;
|
||||
@@ -720,7 +720,7 @@ int xmpp_snprintf (char *str,size_t count,const char *fmt,...)
|
||||
{
|
||||
VA_LOCAL_DECL;
|
||||
int total;
|
||||
|
||||
|
||||
VA_START (fmt);
|
||||
total = xmpp_vsnprintf(str, count, fmt, ap);
|
||||
VA_END;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* sock.c
|
||||
** 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
|
||||
** 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)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return (error == WSAEINTR || error == WSAEWOULDBLOCK ||
|
||||
return (error == WSAEINTR || error == WSAEWOULDBLOCK ||
|
||||
error == WSAEINPROGRESS);
|
||||
#else
|
||||
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;
|
||||
}
|
||||
|
||||
return stanza;
|
||||
return stanza;
|
||||
}
|
||||
|
||||
/** Clone a stanza object.
|
||||
* This function increments the reference count of the stanza object.
|
||||
*
|
||||
*
|
||||
* @param stanza a Strophe stanza object
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
*
|
||||
* @param stanza a Strophe stanza object
|
||||
*
|
||||
* @return TRUE if the stanza is a text node, FALSE otherwise
|
||||
*
|
||||
*
|
||||
* @ingroup 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.
|
||||
*
|
||||
*
|
||||
* @param stanza a Strophe stanza object
|
||||
*
|
||||
* @return TRUE if the stanza is a tag node, FALSE otherwise
|
||||
*
|
||||
*
|
||||
* @ingroup 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
buffer[length - 1] = 0;
|
||||
|
||||
*buf = buffer;
|
||||
@@ -476,7 +476,7 @@ int xmpp_stanza_to_text(xmpp_stanza_t *stanza,
|
||||
}
|
||||
|
||||
/** Set the name of a stanza.
|
||||
*
|
||||
*
|
||||
* @param stanza a Strophe stanza object
|
||||
* @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
|
||||
*/
|
||||
int xmpp_stanza_set_name(xmpp_stanza_t *stanza,
|
||||
int xmpp_stanza_set_name(xmpp_stanza_t *stanza,
|
||||
const char * const name)
|
||||
{
|
||||
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.
|
||||
* 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.
|
||||
*
|
||||
* @param stanza a Strophe stanza object
|
||||
* @param attr the string array to populate
|
||||
* @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
|
||||
*
|
||||
* @ingroup Stanza
|
||||
@@ -577,7 +577,7 @@ int xmpp_stanza_get_attributes(xmpp_stanza_t * const stanza,
|
||||
}
|
||||
|
||||
/** Set an attribute for a stanza object.
|
||||
*
|
||||
*
|
||||
* @param stanza a Strophe stanza object
|
||||
* @param key a string with the attribute name
|
||||
* @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)
|
||||
{
|
||||
if (stanza->type == XMPP_STANZA_TAG) return XMPP_EINVOP;
|
||||
|
||||
|
||||
stanza->type = XMPP_STANZA_TEXT;
|
||||
|
||||
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
|
||||
*
|
||||
* @return XMPP_EOK (0) on success and a number less than 0 on failure
|
||||
*
|
||||
*
|
||||
* @ingroup 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.
|
||||
* This function searches all the immediate children of stanza for a child
|
||||
* stanza that matches the name. The first matching child is returned.
|
||||
*
|
||||
*
|
||||
* @param stanza a Strophe stanza object
|
||||
* @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
|
||||
*/
|
||||
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)
|
||||
{
|
||||
xmpp_stanza_t *child;
|
||||
|
||||
|
||||
for (child = stanza->children; child; child = child->next) {
|
||||
if (child->type == XMPP_STANZA_TAG &&
|
||||
(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
|
||||
* stanza that matches the namespace provided. The first matching child
|
||||
* is returned.
|
||||
*
|
||||
*
|
||||
* @param stanza a Strophe stanza object
|
||||
* @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)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return child;
|
||||
}
|
||||
|
||||
@@ -915,13 +915,13 @@ xmpp_stanza_t *xmpp_stanza_get_child_by_name_and_ns(xmpp_stanza_t * const 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;
|
||||
}
|
||||
|
||||
/** Get the next sibling of a stanza.
|
||||
*
|
||||
*
|
||||
* @param stanza a Strophe stanza object
|
||||
*
|
||||
* @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.
|
||||
* 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
|
||||
* allocation. The caller should not hold onto this pointer, and is
|
||||
* 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)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (!stanza->attributes)
|
||||
return NULL;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* tls_dummy.c
|
||||
** 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
|
||||
** or implied.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* tls.c
|
||||
** 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
|
||||
** or implied.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* tls_openssl.c
|
||||
** 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
|
||||
** or implied.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* tls_schannel.c
|
||||
** 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
|
||||
** or implied.
|
||||
@@ -298,7 +298,7 @@ int tls_start(tls_t *tls)
|
||||
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(tls->sock, &fds);
|
||||
|
||||
|
||||
select(tls->sock, &fds, NULL, NULL, &tv);
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ int tls_start(tls_t *tls)
|
||||
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(tls->sock, &fds);
|
||||
|
||||
|
||||
select(tls->sock, &fds, NULL, NULL, &tv);
|
||||
|
||||
inbytes = sock_read(tls->sock, p, tls->spi->cbMaxToken - len);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* util.c
|
||||
** 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
|
||||
** or implied.
|
||||
@@ -130,7 +130,7 @@ uint64_t time_elapsed(uint64_t t1, uint64_t t2)
|
||||
|
||||
/** 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
|
||||
* the Strophe library for terminating the connection because of a
|
||||
* memory error.
|
||||
*
|
||||
* @param conn a Strophe connection object
|
||||
|
||||
24
strophe.h
24
strophe.h
@@ -83,7 +83,7 @@ extern "C" {
|
||||
#define XMPP_EOK 0
|
||||
/** @def XMPP_EMEM
|
||||
* Memory related failure error code.
|
||||
*
|
||||
*
|
||||
* This is returned on allocation errors and signals that the host may
|
||||
* be out of memory.
|
||||
*/
|
||||
@@ -118,7 +118,7 @@ typedef struct _xmpp_log_t xmpp_log_t;
|
||||
/* opaque run time context containing the above hooks */
|
||||
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);
|
||||
void xmpp_ctx_free(xmpp_ctx_t * const ctx);
|
||||
|
||||
@@ -146,7 +146,7 @@ typedef enum {
|
||||
XMPP_COMPONENT
|
||||
} 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 char * const area,
|
||||
const char * const msg);
|
||||
@@ -219,7 +219,7 @@ typedef struct {
|
||||
xmpp_stanza_t *stanza;
|
||||
} 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 int 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_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,
|
||||
unsigned short altport,
|
||||
xmpp_conn_handler callback,
|
||||
@@ -270,16 +270,16 @@ void xmpp_disconnect(xmpp_conn_t * const conn);
|
||||
void xmpp_send(xmpp_conn_t * const conn,
|
||||
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, ...);
|
||||
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);
|
||||
|
||||
|
||||
/* handlers */
|
||||
|
||||
/* 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 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);
|
||||
|
||||
/* 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);
|
||||
|
||||
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);
|
||||
xmpp_stanza_t *xmpp_stanza_get_child_by_ns(xmpp_stanza_t * const stanza,
|
||||
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_name(xmpp_stanza_t * const stanza);
|
||||
/* 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 value);
|
||||
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,
|
||||
const char * const text);
|
||||
int xmpp_stanza_set_text_with_size(xmpp_stanza_t *stanza,
|
||||
const char * const text,
|
||||
const char * const text,
|
||||
const size_t size);
|
||||
int xmpp_stanza_del_attribute(xmpp_stanza_t * const stanza,
|
||||
const char * const name);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* check_parser.h
|
||||
** 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
|
||||
** implied.
|
||||
@@ -67,8 +67,8 @@ static void callbacks(void)
|
||||
int ret;
|
||||
|
||||
ctx = xmpp_ctx_new(NULL, NULL);
|
||||
parser = parser_new(ctx,
|
||||
cbtest_handle_start,
|
||||
parser = parser_new(ctx,
|
||||
cbtest_handle_start,
|
||||
cbtest_handle_end,
|
||||
cbtest_handle_stanza, NULL);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* test_ctx.c
|
||||
** 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
|
||||
** or implied.
|
||||
@@ -91,11 +91,11 @@ int main(int argc, char **argv)
|
||||
xmpp_ctx_free(ctx);
|
||||
|
||||
/* 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))
|
||||
return 1;
|
||||
if (mem_alloc_called != mem_free_called)
|
||||
return 1;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* test_hash.c
|
||||
** 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
|
||||
** or implied.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* test_sasl.c
|
||||
** 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
|
||||
** or implied.
|
||||
@@ -20,7 +20,7 @@ static const unsigned char jid[] = "foo@bar.com";
|
||||
static const char password[] = "secret";
|
||||
static const char response_plain[] = "AGZvb0BiYXIuY29tAHNlY3JldA==";
|
||||
|
||||
static const char challenge_md5[] =
|
||||
static const char challenge_md5[] =
|
||||
"cmVhbG09InNvbWVyZWFsbSIsbm9uY2U9Ik9BNk1HOXRFUUdtMmhoIixxb3A9ImF1dGgi"
|
||||
"LGNoYXJzZXQ9dXRmLTgsYWxnb3JpdGhtPW1kNS1zZXNzCg==";
|
||||
static const char response_md5[] =
|
||||
@@ -85,13 +85,13 @@ int main(int argc, char *argv[])
|
||||
xmpp_ctx_t *ctx;
|
||||
int ret;
|
||||
|
||||
printf("allocating context... ");
|
||||
printf("allocating context... ");
|
||||
ctx = xmpp_ctx_new(NULL, NULL);
|
||||
if (ctx == NULL) printf("failed to create context\n");
|
||||
if (ctx == NULL) return -1;
|
||||
printf("ok.\n");
|
||||
|
||||
printf("testing SASL PLAIN... ");
|
||||
printf("testing SASL PLAIN... ");
|
||||
ret = test_plain(ctx);
|
||||
if (ret) printf("failed!\n");
|
||||
if (ret) return ret;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* test_sock.c
|
||||
** 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
|
||||
** or implied.
|
||||
|
||||
Reference in New Issue
Block a user