@@ -101,13 +101,13 @@ void xmpp_shutdown(void)
101101int 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 */
112112static 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 */
136136static const char * const _xmpp_log_level_name [4 ] = {"DEBUG" , "INFO" , "WARN" , "ERROR" };
137137static 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 */
151151static 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
161161static 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 */
225225void * 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 */
244244void 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 */
387387xmpp_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 ;
0 commit comments