sml_support.h
/*
* libsyncml - A syncml protocol implementation
* Copyright (C) 2005 Armin Bauer <armin.bauer@opensync.org>
* Copyright (C) 2008 Michael Bell <michael.bell@opensync.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef _SML_SUPPORT_H_
#define _SML_SUPPORT_H_
typedef enum {
TRACE_ENTRY,
TRACE_EXIT,
TRACE_INTERNAL,
TRACE_ERROR,
TRACE_EXIT_ERROR
} SmlTraceType;
#define VA_STRING(param) param?param:"NULL"
void smlLog(const char *logname, const char *data, unsigned int size);
void smlTrace(SmlTraceType type, const char *message, ...);
char *smlPrintBinary(const char *data, int len);
char *smlPrintHex(const char *data, int len);
char *smlRandStr(int maxlength, SmlBool exact);
void *smlTryMalloc0(long n_bytes, SmlError **error);
typedef struct SmlThread {
GThread *thread;
gboolean started;
GCond *started_cond;
GMutex *started_mutex;
GMainContext *context;
GMainLoop *loop;
} SmlThread;
SmlThread *smlThreadNew(GMainContext *context, SmlError **error);
void smlThreadFree(SmlThread *thread);
void smlThreadStart(SmlThread *thread);
void smlThreadStop(SmlThread *thread);
typedef SmlBool (* SmlThreadCallFunctionType) (
gpointer data,
SmlError **error);
SmlBool smlThreadCallFunction(
SmlThread *thread,
SmlThreadCallFunctionType func,
gpointer data,
SmlError **error);
void smlSafeFree(gpointer *address);
void smlSafeCFree(char **address);
#endif //_SML_SUPPORT_H_
smlPrintHex
char * smlPrintHex(const char *data, int len)
Used for printing binary data in just hex.
Definition: sml_support.c:271
smlThreadCallFunction
SmlBool smlThreadCallFunction(SmlThread *thread, SmlThreadCallFunctionType func, gpointer data, SmlError **error)
Definition: sml_support.c:561
smlRandStr
char * smlRandStr(int maxlength, SmlBool exact)
Creates a random string.
Definition: sml_support.c:302
smlPrintBinary
char * smlPrintBinary(const char *data, int len)
Used for printing binary data.
Definition: sml_support.c:252
smlTrace
void smlTrace(SmlTraceType type, const char *message,...)
Used for tracing the application.
Definition: sml_support.c:120
smlTryMalloc0
void * smlTryMalloc0(long n_bytes, SmlError **error)
Safely mallocs.
Definition: sml_support.c:335
SmlThread
Definition: sml_support.h:52
SmlError
Represent an error.
Definition: sml_error_internals.h:29