00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _SML_SUPPORT_H_
00023 #define _SML_SUPPORT_H_
00024
00027 typedef enum {
00029 TRACE_ENTRY,
00031 TRACE_EXIT,
00033 TRACE_INTERNAL,
00035 TRACE_ERROR,
00037 TRACE_EXIT_ERROR
00038 } SmlTraceType;
00039
00043 #define VA_STRING(param) param?param:"NULL"
00044
00045 void smlLog(const char *logname, const char *data, unsigned int size);
00046 void smlTrace(SmlTraceType type, const char *message, ...);
00047 char *smlPrintBinary(const char *data, int len);
00048 char *smlPrintHex(const char *data, int len);
00049 char *smlRandStr(int maxlength, SmlBool exact);
00050 void *smlTryMalloc0(long n_bytes, SmlError **error);
00051
00052 typedef struct SmlThread {
00053 GThread *thread;
00054 gboolean started;
00055 GCond *started_cond;
00056 GMutex *started_mutex;
00057 GMainContext *context;
00058 GMainLoop *loop;
00059 } SmlThread;
00060
00061 SmlThread *smlThreadNew(GMainContext *context, SmlError **error);
00062 void smlThreadFree(SmlThread *thread);
00063 void smlThreadStart(SmlThread *thread);
00064 void smlThreadStop(SmlThread *thread);
00065
00066 typedef SmlBool (* SmlThreadCallFunctionType) (
00067 gpointer data,
00068 SmlError **error);
00069
00070 SmlBool smlThreadCallFunction(
00071 SmlThread *thread,
00072 SmlThreadCallFunctionType func,
00073 gpointer data,
00074 SmlError **error);
00075
00076 void smlSafeFree(gpointer *address);
00077 void smlSafeCFree(char **address);
00078
00079 #endif //_SML_SUPPORT_H_