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

Commit d2c1daf

Browse files
committed
Fix spacing in ctx.c and common.h
1 parent d1a41c9 commit d2c1daf

2 files changed

Lines changed: 111 additions & 111 deletions

File tree

src/common.h

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* common.h
22
** strophe XMPP client library -- internal common structures
33
**
4-
** Copyright (C) 2005-2009 Collecta, Inc.
4+
** Copyright (C) 2005-2009 Collecta, Inc.
55
**
66
** This software is provided AS-IS with no warranty, either express or
77
** implied.
@@ -56,32 +56,32 @@ struct _xmpp_ctx_t {
5656
/* convenience functions for accessing the context */
5757
void *xmpp_alloc(const xmpp_ctx_t * const ctx, const size_t size);
5858
void *xmpp_realloc(const xmpp_ctx_t * const ctx, void *p,
59-
const size_t size);
59+
const size_t size);
6060
char *xmpp_strdup(const xmpp_ctx_t * const ctx, const char * const s);
6161

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

6868
/* wrappers for xmpp_log at specific levels */
6969
void xmpp_error(const xmpp_ctx_t * const ctx,
70-
const char * const area,
71-
const char * const fmt,
72-
...);
70+
const char * const area,
71+
const char * const fmt,
72+
...);
7373
void xmpp_warn(const xmpp_ctx_t * const ctx,
74-
const char * const area,
75-
const char * const fmt,
76-
...);
74+
const char * const area,
75+
const char * const fmt,
76+
...);
7777
void xmpp_info(const xmpp_ctx_t * const ctx,
78-
const char * const area,
79-
const char * const fmt,
80-
...);
78+
const char * const area,
79+
const char * const fmt,
80+
...);
8181
void xmpp_debug(const xmpp_ctx_t * const ctx,
82-
const char * const area,
83-
const char * const fmt,
84-
...);
82+
const char * const area,
83+
const char * const fmt,
84+
...);
8585

8686
/** connection **/
8787

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

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

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

174174
/* if server returns <bind/> or <session/> we must do them */
@@ -196,7 +196,7 @@ struct _xmpp_conn_t {
196196
/* timeouts */
197197
unsigned int connect_timeout;
198198

199-
/* event handlers */
199+
/* event handlers */
200200

201201
/* stream open handler */
202202
xmpp_open_handler open_handler;
@@ -247,23 +247,23 @@ struct _xmpp_stanza_t {
247247

248248
/* handler management */
249249
void handler_fire_stanza(xmpp_conn_t * const conn,
250-
xmpp_stanza_t * const stanza);
250+
xmpp_stanza_t * const stanza);
251251
uint64_t handler_fire_timed(xmpp_ctx_t * const ctx);
252252
void handler_reset_timed(xmpp_conn_t *conn, int user_only);
253253
void handler_add_timed(xmpp_conn_t * const conn,
254-
xmpp_timed_handler handler,
255-
const unsigned long period,
256-
void * const userdata);
254+
xmpp_timed_handler handler,
255+
const unsigned long period,
256+
void * const userdata);
257257
void handler_add_id(xmpp_conn_t * const conn,
258-
xmpp_handler handler,
259-
const char * const id,
260-
void * const userdata);
258+
xmpp_handler handler,
259+
const char * const id,
260+
void * const userdata);
261261
void handler_add(xmpp_conn_t * const conn,
262-
xmpp_handler handler,
263-
const char * const ns,
264-
const char * const name,
265-
const char * const type,
266-
void * const userdata);
262+
xmpp_handler handler,
263+
const char * const ns,
264+
const char * const name,
265+
const char * const type,
266+
void * const userdata);
267267

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

src/ctx.c

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* ctx.c
22
** strophe XMPP client library -- run-time context implementation
33
**
4-
** Copyright (C) 2005-2009 Collecta, Inc.
4+
** Copyright (C) 2005-2009 Collecta, Inc.
55
**
6-
** This software is provided AS-IS with no warranty, either express
6+
** This software is provided AS-IS with no warranty, either express
77
** or implied.
88
**
99
** This program is dual licensed under the MIT and GPLv3 licenses.
@@ -36,7 +36,7 @@
3636
* result in strange (and platform dependent) behavior.
3737
*
3838
* Specifically, the socket library on Win32 platforms must be initialized
39-
* before use (although this is not the case on POSIX systems). The TLS
39+
* before use (although this is not the case on POSIX systems). The TLS
4040
* subsystem must also seed the random number generator.
4141
*/
4242

@@ -103,12 +103,12 @@ void xmpp_shutdown(void)
103103
int xmpp_version_check(int major, int minor)
104104
{
105105
return (major == LIBXMPP_VERSION_MAJOR) &&
106-
(minor >= LIBXMPP_VERSION_MINOR);
106+
(minor >= LIBXMPP_VERSION_MINOR);
107107
}
108108

109109
/* We define the global default allocator, logger, and context here. */
110110

111-
/* Wrap stdlib routines malloc, free, and realloc for default memory
111+
/* Wrap stdlib routines malloc, free, and realloc for default memory
112112
* management.
113113
*/
114114
static void *_malloc(const size_t size, void * const userdata)
@@ -137,9 +137,9 @@ static xmpp_mem_t xmpp_default_mem = {
137137
/* log levels and names */
138138
static const char * const _xmpp_log_level_name[4] = {"DEBUG", "INFO", "WARN", "ERROR"};
139139
static const xmpp_log_level_t _xmpp_default_logger_levels[] = {XMPP_LEVEL_DEBUG,
140-
XMPP_LEVEL_INFO,
141-
XMPP_LEVEL_WARN,
142-
XMPP_LEVEL_ERROR};
140+
XMPP_LEVEL_INFO,
141+
XMPP_LEVEL_WARN,
142+
XMPP_LEVEL_ERROR};
143143

144144
/** Log a message.
145145
* The default logger writes to stderr.
@@ -151,20 +151,20 @@ static const xmpp_log_level_t _xmpp_default_logger_levels[] = {XMPP_LEVEL_DEBUG,
151151
* @param msg the log message
152152
*/
153153
static void xmpp_default_logger(void * const userdata,
154-
const xmpp_log_level_t level,
155-
const char * const area,
156-
const char * const msg)
154+
const xmpp_log_level_t level,
155+
const char * const area,
156+
const char * const msg)
157157
{
158158
xmpp_log_level_t filter_level = * (xmpp_log_level_t*)userdata;
159159
if (level >= filter_level)
160-
fprintf(stderr, "%s %s %s\n", area, _xmpp_log_level_name[level], msg);
160+
fprintf(stderr, "%s %s %s\n", area, _xmpp_log_level_name[level], msg);
161161
}
162162

163163
static const xmpp_log_t _xmpp_default_loggers[] = {
164-
{&xmpp_default_logger, (void*)&_xmpp_default_logger_levels[XMPP_LEVEL_DEBUG]},
165-
{&xmpp_default_logger, (void*)&_xmpp_default_logger_levels[XMPP_LEVEL_INFO]},
166-
{&xmpp_default_logger, (void*)&_xmpp_default_logger_levels[XMPP_LEVEL_WARN]},
167-
{&xmpp_default_logger, (void*)&_xmpp_default_logger_levels[XMPP_LEVEL_ERROR]}
164+
{&xmpp_default_logger, (void*)&_xmpp_default_logger_levels[XMPP_LEVEL_DEBUG]},
165+
{&xmpp_default_logger, (void*)&_xmpp_default_logger_levels[XMPP_LEVEL_INFO]},
166+
{&xmpp_default_logger, (void*)&_xmpp_default_logger_levels[XMPP_LEVEL_WARN]},
167+
{&xmpp_default_logger, (void*)&_xmpp_default_logger_levels[XMPP_LEVEL_ERROR]}
168168
};
169169

170170
/** Get a default logger with filtering.
@@ -192,7 +192,7 @@ static xmpp_log_t xmpp_default_log = { NULL, NULL };
192192
/* convenience functions for accessing the context */
193193

194194
/** Allocate memory in a Strophe context.
195-
* All Strophe functions will use this to allocate memory.
195+
* All Strophe functions will use this to allocate memory.
196196
*
197197
* @param ctx a Strophe context object
198198
* @param size the number of bytes to allocate
@@ -225,7 +225,7 @@ void xmpp_free(const xmpp_ctx_t * const ctx, void *p)
225225
* @return a pointer to the reallocated memory or NULL on an error
226226
*/
227227
void *xmpp_realloc(const xmpp_ctx_t * const ctx, void *p,
228-
const size_t size)
228+
const size_t size)
229229
{
230230
return ctx->mem->realloc(p, size, ctx->mem->userdata);
231231
}
@@ -234,7 +234,7 @@ void *xmpp_realloc(const xmpp_ctx_t * const ctx, void *p,
234234
* Write a log message to the logger for the context for the specified
235235
* level and area. This function takes a printf-style format string and a
236236
* variable argument list (in va_list) format. This function is not meant
237-
* to be called directly, but is used via xmpp_error, xmpp_warn, xmpp_info,
237+
* to be called directly, but is used via xmpp_error, xmpp_warn, xmpp_info,
238238
* and xmpp_debug.
239239
*
240240
* @param ctx a Strophe context object
@@ -244,10 +244,10 @@ void *xmpp_realloc(const xmpp_ctx_t * const ctx, void *p,
244244
* @param ap variable argument list supplied for the format string
245245
*/
246246
void xmpp_log(const xmpp_ctx_t * const ctx,
247-
const xmpp_log_level_t level,
248-
const char * const area,
249-
const char * const fmt,
250-
va_list ap)
247+
const xmpp_log_level_t level,
248+
const char * const area,
249+
const char * const fmt,
250+
va_list ap)
251251
{
252252
int oldret, ret;
253253
char smbuf[1024];
@@ -257,23 +257,23 @@ void xmpp_log(const xmpp_ctx_t * const ctx,
257257
va_copy(copy, ap);
258258
ret = xmpp_vsnprintf(smbuf, sizeof(smbuf), fmt, ap);
259259
if (ret >= (int)sizeof(smbuf)) {
260-
buf = (char *)xmpp_alloc(ctx, ret + 1);
261-
if (!buf) {
262-
buf = NULL;
263-
xmpp_error(ctx, "log", "Failed allocating memory for log message.");
264-
va_end(copy);
265-
return;
266-
}
267-
oldret = ret;
268-
ret = xmpp_vsnprintf(buf, ret + 1, fmt, copy);
269-
if (ret > oldret) {
270-
xmpp_error(ctx, "log", "Unexpected error");
271-
xmpp_free(ctx, buf);
272-
va_end(copy);
273-
return;
274-
}
260+
buf = (char *)xmpp_alloc(ctx, ret + 1);
261+
if (!buf) {
262+
buf = NULL;
263+
xmpp_error(ctx, "log", "Failed allocating memory for log message.");
264+
va_end(copy);
265+
return;
266+
}
267+
oldret = ret;
268+
ret = xmpp_vsnprintf(buf, ret + 1, fmt, copy);
269+
if (ret > oldret) {
270+
xmpp_error(ctx, "log", "Unexpected error");
271+
xmpp_free(ctx, buf);
272+
va_end(copy);
273+
return;
274+
}
275275
} else {
276-
buf = smbuf;
276+
buf = smbuf;
277277
}
278278
va_end(copy);
279279

@@ -286,7 +286,7 @@ void xmpp_log(const xmpp_ctx_t * const ctx,
286286

287287
/** Write to the log at the ERROR level.
288288
* This is a convenience function for writing to the log at the
289-
* ERROR level. It takes a printf-style format string followed by a
289+
* ERROR level. It takes a printf-style format string followed by a
290290
* variable list of arguments for formatting.
291291
*
292292
* @param ctx a Strophe context object
@@ -386,34 +386,34 @@ void xmpp_debug(const xmpp_ctx_t * const ctx,
386386
*
387387
* @ingroup Context
388388
*/
389-
xmpp_ctx_t *xmpp_ctx_new(const xmpp_mem_t * const mem,
390-
const xmpp_log_t * const log)
389+
xmpp_ctx_t *xmpp_ctx_new(const xmpp_mem_t * const mem,
390+
const xmpp_log_t * const log)
391391
{
392392
xmpp_ctx_t *ctx = NULL;
393393

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

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

419419
return ctx;

0 commit comments

Comments
 (0)