Skip to content
This repository was archived by the owner on Oct 29, 2021. It is now read-only.

Commit a34397d

Browse files
committed
Merge remote-tracking branch 'upstream/master'
Conflicts: src/common.h src/ctx.c src/oocontext.cpp src/oostanza.cpp strophepp.h
2 parents e3db0e9 + 80a7ea0 commit a34397d

5 files changed

Lines changed: 341 additions & 341 deletions

File tree

src/common.h

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -54,33 +54,33 @@ struct _xmpp_ctx_t {
5454

5555
/* convenience functions for accessing the context */
5656
void *xmpp_alloc(const xmpp_ctx_t * const ctx, const size_t size);
57-
void *xmpp_realloc(const xmpp_ctx_t * const ctx, void *p,
58-
const size_t size);
57+
void *xmpp_realloc(const xmpp_ctx_t * const ctx, void *p,
58+
const size_t size);
5959
char *xmpp_strdup(const xmpp_ctx_t * const ctx, const char * const s);
6060

6161
void xmpp_log(const xmpp_ctx_t * const ctx,
62-
const xmpp_log_level_t level,
63-
const char * const area,
64-
const char * const fmt,
65-
va_list ap);
62+
const xmpp_log_level_t level,
63+
const char * const area,
64+
const char * const fmt,
65+
va_list ap);
6666

6767
/* wrappers for xmpp_log at specific levels */
6868
void xmpp_error(const xmpp_ctx_t * const ctx,
69-
const char * const area,
70-
const char * const fmt,
71-
...);
69+
const char * const area,
70+
const char * const fmt,
71+
...);
7272
void xmpp_warn(const xmpp_ctx_t * const ctx,
73-
const char * const area,
74-
const char * const fmt,
75-
...);
73+
const char * const area,
74+
const char * const fmt,
75+
...);
7676
void xmpp_info(const xmpp_ctx_t * const ctx,
77-
const char * const area,
78-
const char * const fmt,
79-
...);
77+
const char * const area,
78+
const char * const fmt,
79+
...);
8080
void xmpp_debug(const xmpp_ctx_t * const ctx,
81-
const char * const area,
82-
const char * const fmt,
83-
...);
81+
const char * const area,
82+
const char * const fmt,
83+
...);
8484

8585
/** connection **/
8686

@@ -107,26 +107,26 @@ struct _xmpp_handlist_t {
107107
void *handler;
108108
void *userdata;
109109
int enabled; /* handlers are added disabled and enabled after the
110-
* handler chain is processed to prevent stanzas from
111-
* getting processed by newly added handlers */
110+
* handler chain is processed to prevent stanzas from
111+
* getting processed by newly added handlers */
112112
xmpp_handlist_t *next;
113113

114114
union {
115-
/* timed handlers */
116-
struct {
117-
unsigned long period;
118-
uint64_t last_stamp;
119-
};
120-
/* id handlers */
121-
struct {
122-
char *id;
123-
};
124-
/* normal handlers */
125-
struct {
126-
char *ns;
127-
char *name;
128-
char *type;
129-
};
115+
/* timed handlers */
116+
struct {
117+
unsigned long period;
118+
uint64_t last_stamp;
119+
};
120+
/* id handlers */
121+
struct {
122+
char *id;
123+
};
124+
/* normal handlers */
125+
struct {
126+
char *ns;
127+
char *name;
128+
char *type;
129+
};
130130
};
131131
};
132132

@@ -167,8 +167,8 @@ struct _xmpp_conn_t {
167167
int tls_mandatory;
168168
int tls_legacy_ssl;
169169
int tls_failed; /* set when tls fails, so we don't try again */
170-
int sasl_support; /* if true, field is a bitfield of supported
171-
mechanisms */
170+
int sasl_support; /* if true, field is a bitfield of supported
171+
mechanisms */
172172
int secured; /* set when stream is secured with TLS */
173173

174174
/* if server returns <bind/> or <session/> we must do them */
@@ -248,23 +248,23 @@ struct _xmpp_stanza_t {
248248

249249
/* handler management */
250250
void handler_fire_stanza(xmpp_conn_t * const conn,
251-
xmpp_stanza_t * const stanza);
251+
xmpp_stanza_t * const stanza);
252252
uint64_t handler_fire_timed(xmpp_ctx_t * const ctx);
253253
void handler_reset_timed(xmpp_conn_t *conn, int user_only);
254254
void handler_add_timed(xmpp_conn_t * const conn,
255-
xmpp_timed_handler handler,
256-
const unsigned long period,
257-
void * const userdata);
255+
xmpp_timed_handler handler,
256+
const unsigned long period,
257+
void * const userdata);
258258
void handler_add_id(xmpp_conn_t * const conn,
259-
xmpp_handler handler,
260-
const char * const id,
261-
void * const userdata);
259+
xmpp_handler handler,
260+
const char * const id,
261+
void * const userdata);
262262
void handler_add(xmpp_conn_t * const conn,
263-
xmpp_handler handler,
264-
const char * const ns,
265-
const char * const name,
266-
const char * const type,
267-
void * const userdata);
263+
xmpp_handler handler,
264+
const char * const ns,
265+
const char * const name,
266+
const char * const type,
267+
void * const userdata);
268268

269269
/* utility functions */
270270
void disconnect_mem_error(xmpp_conn_t * const conn);

src/ctx.c

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ void xmpp_shutdown(void)
101101
int xmpp_version_check(int major, int minor)
102102
{
103103
return (major == LIBXMPP_VERSION_MAJOR) &&
104-
(minor >= LIBXMPP_VERSION_MINOR);
104+
(minor >= LIBXMPP_VERSION_MINOR);
105105
}
106106

107107
/* We define the global default allocator, logger, and context here. */
108108

109109
/* Wrap stdlib routines malloc, free, and realloc for default memory
110-
* management.
110+
* management.
111111
*/
112112
static void *_malloc(const size_t size, void * const userdata)
113113
{
@@ -135,9 +135,9 @@ static xmpp_mem_t xmpp_default_mem = {
135135
/* log levels and names */
136136
static const char * const _xmpp_log_level_name[4] = {"DEBUG", "INFO", "WARN", "ERROR"};
137137
static const xmpp_log_level_t _xmpp_default_logger_levels[] = {XMPP_LEVEL_DEBUG,
138-
XMPP_LEVEL_INFO,
139-
XMPP_LEVEL_WARN,
140-
XMPP_LEVEL_ERROR};
138+
XMPP_LEVEL_INFO,
139+
XMPP_LEVEL_WARN,
140+
XMPP_LEVEL_ERROR};
141141

142142
/** Log a message.
143143
* The default logger writes to stderr.
@@ -149,20 +149,20 @@ static const xmpp_log_level_t _xmpp_default_logger_levels[] = {XMPP_LEVEL_DEBUG,
149149
* @param msg the log message
150150
*/
151151
static void xmpp_default_logger(void * const userdata,
152-
const xmpp_log_level_t level,
153-
const char * const area,
154-
const char * const msg)
152+
const xmpp_log_level_t level,
153+
const char * const area,
154+
const char * const msg)
155155
{
156156
xmpp_log_level_t filter_level = * (xmpp_log_level_t*)userdata;
157157
if (level >= filter_level)
158-
fprintf(stderr, "%s %s %s\n", area, _xmpp_log_level_name[level], msg);
158+
fprintf(stderr, "%s %s %s\n", area, _xmpp_log_level_name[level], msg);
159159
}
160160

161161
static const xmpp_log_t _xmpp_default_loggers[] = {
162-
{&xmpp_default_logger, (void*)&_xmpp_default_logger_levels[XMPP_LEVEL_DEBUG]},
163-
{&xmpp_default_logger, (void*)&_xmpp_default_logger_levels[XMPP_LEVEL_INFO]},
164-
{&xmpp_default_logger, (void*)&_xmpp_default_logger_levels[XMPP_LEVEL_WARN]},
165-
{&xmpp_default_logger, (void*)&_xmpp_default_logger_levels[XMPP_LEVEL_ERROR]}
162+
{&xmpp_default_logger, (void*)&_xmpp_default_logger_levels[XMPP_LEVEL_DEBUG]},
163+
{&xmpp_default_logger, (void*)&_xmpp_default_logger_levels[XMPP_LEVEL_INFO]},
164+
{&xmpp_default_logger, (void*)&_xmpp_default_logger_levels[XMPP_LEVEL_WARN]},
165+
{&xmpp_default_logger, (void*)&_xmpp_default_logger_levels[XMPP_LEVEL_ERROR]}
166166
};
167167

168168
/** Get a default logger with filtering.
@@ -223,7 +223,7 @@ void xmpp_free(const xmpp_ctx_t * const ctx, void *p)
223223
* @return a pointer to the reallocated memory or NULL on an error
224224
*/
225225
void *xmpp_realloc(const xmpp_ctx_t * const ctx, void *p,
226-
const size_t size)
226+
const size_t size)
227227
{
228228
return ctx->mem->realloc(p, size, ctx->mem->userdata);
229229
}
@@ -242,10 +242,10 @@ void *xmpp_realloc(const xmpp_ctx_t * const ctx, void *p,
242242
* @param ap variable argument list supplied for the format string
243243
*/
244244
void xmpp_log(const xmpp_ctx_t * const ctx,
245-
const xmpp_log_level_t level,
246-
const char * const area,
247-
const char * const fmt,
248-
va_list ap)
245+
const xmpp_log_level_t level,
246+
const char * const area,
247+
const char * const fmt,
248+
va_list ap)
249249
{
250250
int oldret, ret;
251251
char smbuf[1024];
@@ -255,23 +255,23 @@ void xmpp_log(const xmpp_ctx_t * const ctx,
255255
va_copy(copy, ap);
256256
ret = xmpp_vsnprintf(smbuf, sizeof(smbuf), fmt, ap);
257257
if (ret >= (int)sizeof(smbuf)) {
258-
buf = (char *)xmpp_alloc(ctx, ret + 1);
259-
if (!buf) {
260-
buf = NULL;
261-
xmpp_error(ctx, "log", "Failed allocating memory for log message.");
262-
va_end(copy);
263-
return;
264-
}
265-
oldret = ret;
266-
ret = xmpp_vsnprintf(buf, ret + 1, fmt, copy);
267-
if (ret > oldret) {
268-
xmpp_error(ctx, "log", "Unexpected error");
269-
xmpp_free(ctx, buf);
270-
va_end(copy);
271-
return;
272-
}
258+
buf = (char *)xmpp_alloc(ctx, ret + 1);
259+
if (!buf) {
260+
buf = NULL;
261+
xmpp_error(ctx, "log", "Failed allocating memory for log message.");
262+
va_end(copy);
263+
return;
264+
}
265+
oldret = ret;
266+
ret = xmpp_vsnprintf(buf, ret + 1, fmt, copy);
267+
if (ret > oldret) {
268+
xmpp_error(ctx, "log", "Unexpected error");
269+
xmpp_free(ctx, buf);
270+
va_end(copy);
271+
return;
272+
}
273273
} else {
274-
buf = smbuf;
274+
buf = smbuf;
275275
}
276276
va_end(copy);
277277

@@ -385,33 +385,33 @@ void xmpp_debug(const xmpp_ctx_t * const ctx,
385385
* @ingroup Context
386386
*/
387387
xmpp_ctx_t *xmpp_ctx_new(const xmpp_mem_t * const mem,
388-
const xmpp_log_t * const log)
388+
const xmpp_log_t * const log)
389389
{
390390
xmpp_ctx_t *ctx = NULL;
391391

392392
if (mem == NULL)
393-
ctx = xmpp_default_mem.alloc(sizeof(xmpp_ctx_t), NULL);
393+
ctx = xmpp_default_mem.alloc(sizeof(xmpp_ctx_t), NULL);
394394
else
395-
ctx = mem->alloc(sizeof(xmpp_ctx_t), mem->userdata);
395+
ctx = mem->alloc(sizeof(xmpp_ctx_t), mem->userdata);
396396

397397
if (ctx != NULL) {
398-
if (mem != NULL)
399-
ctx->mem = mem;
400-
else
401-
ctx->mem = &xmpp_default_mem;
402-
403-
if (log == NULL)
404-
ctx->log = &xmpp_default_log;
405-
else
406-
ctx->log = log;
407-
408-
ctx->connlist = NULL;
409-
ctx->loop_status = XMPP_LOOP_NOTSTARTED;
410-
ctx->rand = xmpp_rand_new(ctx);
411-
if (ctx->rand == NULL) {
412-
xmpp_free(ctx, ctx);
413-
ctx = NULL;
414-
}
398+
if (mem != NULL)
399+
ctx->mem = mem;
400+
else
401+
ctx->mem = &xmpp_default_mem;
402+
403+
if (log == NULL)
404+
ctx->log = &xmpp_default_log;
405+
else
406+
ctx->log = log;
407+
408+
ctx->connlist = NULL;
409+
ctx->loop_status = XMPP_LOOP_NOTSTARTED;
410+
ctx->rand = xmpp_rand_new(ctx);
411+
if (ctx->rand == NULL) {
412+
xmpp_free(ctx, ctx);
413+
ctx = NULL;
414+
}
415415
}
416416

417417
return ctx;

src/event.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ void xmpp_run_once(xmpp_ctx_t *ctx, const unsigned long timeout)
9696
ret = tls_clear_pending_write(conn->tls);
9797

9898
if (ret < 0 && !tls_is_recoverable(tls_error(conn->tls))) {
99-
/* an error occured */
100-
xmpp_debug(ctx, "xmpp", "Send error occured, disconnecting.");
99+
/* an error occurred */
100+
xmpp_debug(ctx, "xmpp", "Send error occurred, disconnecting.");
101101
conn->error = ECONNABORTED;
102102
conn_disconnect(conn);
103103
}
@@ -112,7 +112,7 @@ void xmpp_run_once(xmpp_ctx_t *ctx, const unsigned long timeout)
112112
ret = tls_write(conn->tls, &sq->data[sq->written], towrite);
113113

114114
if (ret < 0 && !tls_is_recoverable(tls_error(conn->tls))) {
115-
/* an error occured */
115+
/* an error occurred */
116116
conn->error = tls_error(conn->tls);
117117
break;
118118
} else if (ret < towrite) {
@@ -125,7 +125,7 @@ void xmpp_run_once(xmpp_ctx_t *ctx, const unsigned long timeout)
125125
ret = sock_write(conn->sock, &sq->data[sq->written], towrite);
126126

127127
if (ret < 0 && !sock_is_recoverable(sock_error())) {
128-
/* an error occured */
128+
/* an error occurred */
129129
conn->error = sock_error();
130130
break;
131131
} else if (ret < towrite) {
@@ -152,7 +152,7 @@ void xmpp_run_once(xmpp_ctx_t *ctx, const unsigned long timeout)
152152
if (conn->error) {
153153
/* FIXME: need to tear down send queues and random other things
154154
* maybe this should be abstracted */
155-
xmpp_debug(ctx, "xmpp", "Send error occured, disconnecting.");
155+
xmpp_debug(ctx, "xmpp", "Send error occurred, disconnecting.");
156156
conn->error = ECONNABORTED;
157157
conn_disconnect(conn);
158158
}

0 commit comments

Comments
 (0)