97#if defined(__CYGWIN__)
105#if (defined(_WIN32) || defined(_WIN64)) && !defined(MSWIN)
109#if defined(__APPLE__) && !defined(APPLE)
114# include <winsock2.h>
117# include <sys/time.h>
119# include <netinet/in.h>
124#define __STDC_FORMAT_MACROS 1
126#include <sys/types.h>
130# if defined(CMUTIL_EXPORT)
131# define CMUTIL_API __declspec(dllexport)
133# define CMUTIL_API __declspec(dllimport)
144# if !defined(closesocket)
145# define closesocket close
147# if !defined(ioctlsocket)
148# define ioctlsocket ioctl
150# if !defined(SOCKET_ERROR)
151# define SOCKET_ERROR -1
153# if !defined(INVALID_SOCKET)
154# define INVALID_SOCKET -1
162# define __null (void*)0
169# define strcasecmp _stricmp
170# define strncasecmp _strnicmp
173# define usleep(x) Sleep(x / 1000)
188#if !defined(INT64_MAX)
189# define INT64_MAX i64(0x7FFFFFFFFFFFFFFF)
191#if !defined(UINT64_MAX)
192# define UINT64_MAX ui64(0xFFFFFFFFFFFFFFFF)
198#define CMUTIL_APPEND(a,b) a ## b
200# define i64(x) CMUTIL_APPEND(x, i64)
201# define ui64(x) CMUTIL_APPEND(x, ui64)
203# define i64(x) CMUTIL_APPEND(x, LL)
204# define ui64(x) CMUTIL_APPEND(x, ULL)
209typedef SSIZE_T ssize_t;
223CMUTIL_API
int __gettimeofday(
struct timeval *tv,
void *tz);
225#define gettimeofday(tv, tz) __gettimeofday(tv, tz)
248# define gethostbyname_r CMUTIL_NetworkGetHostByNameR
249# if !defined(CMUTIL_EXPORT)
250# define gethostbyname CMUTIL_NetworkGetHostByName
259CMUTIL_API
struct hostent *CMUTIL_NetworkGetHostByName(
const char *name);
275CMUTIL_API
int CMUTIL_NetworkGetHostByNameR(
276 const char *name,
struct hostent *ret,
char *buf,
size_t buflen,
277 struct hostent **result,
int *h_errnop);
283#define CMUTIL_UNUSED(a,...) CMUTIL_UnusedP((void*)(int64_t)(a), ## __VA_ARGS__)
337#if !defined(CMUTIL_CALL_NESTED)
338# if defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L
340# define CMUTIL_CALL_NESTED 1
341# elif defined(__cplusplus) && __cplusplus >= 202002L
342# define CMUTIL_CALL_NESTED 1
343# elif defined(_MSC_VER) && _MSC_VER >= 1929 && \
344 defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL == 0
346# define CMUTIL_CALL_NESTED 1
348# define CMUTIL_CALL_NESTED 0
380#if !defined(CMUTIL_CALL_SINGLE_EVAL)
381# if defined(__GNUC__)
382# define CMUTIL_CALL_SINGLE_EVAL 1
383# elif defined(__cplusplus) && (!defined(_MSC_VER) || \
384 (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL == 0))
387# define CMUTIL_CALL_SINGLE_EVAL 1
389# define CMUTIL_CALL_SINGLE_EVAL 0
393#if CMUTIL_CALL_SINGLE_EVAL && \
394 !defined(__GNUC__) && !defined(__cplusplus)
395# error "CMUTIL_CALL_SINGLE_EVAL needs a statement expression or a lambda"
402#define CMUTIL_CAT2__(a,b) a ## b
403#define CMUTIL_CAT__(a,b) CMUTIL_CAT2__(a,b)
408#if CMUTIL_CALL_SINGLE_EVAL
409# if defined(__GNUC__)
411# if CMUTIL_CALL_NESTED
412# define CMUTIL_CALL_EXPR__(o,a,b,...) __extension__ ({ \
413 __typeof__(a) o = (a); o->b(o __VA_OPT__(,) __VA_ARGS__); })
414# define CMUTIL_CALL__(a,b,...) CMUTIL_CALL_EXPR__( \
415 CMUTIL_CAT__(cmutil_self__,__COUNTER__), a, b __VA_OPT__(,) __VA_ARGS__)
417# define CMUTIL_CALL_EXPR__(o,a,b,...) __extension__ ({ \
418 __typeof__(a) o = (a); o->b(o, ## __VA_ARGS__); })
419# define CMUTIL_CALL__(a,b,...) CMUTIL_CALL_EXPR__( \
420 CMUTIL_CAT__(cmutil_self__,__COUNTER__), a, b, ## __VA_ARGS__)
424# if CMUTIL_CALL_NESTED
425# define CMUTIL_CALL_EXPR__(o,a,b,...) ([&]{ \
426 auto o = (a); return o->b(o __VA_OPT__(,) __VA_ARGS__); }())
427# define CMUTIL_CALL__(a,b,...) CMUTIL_CALL_EXPR__( \
428 CMUTIL_CAT__(cmutil_self__,__COUNTER__), a, b __VA_OPT__(,) __VA_ARGS__)
430# define CMUTIL_CALL_EXPR__(o,a,b,...) ([&]{ \
431 auto o = (a); return o->b(o, ## __VA_ARGS__); }())
432# define CMUTIL_CALL__(a,b,...) CMUTIL_CALL_EXPR__( \
433 CMUTIL_CAT__(cmutil_self__,__COUNTER__), a, b, ## __VA_ARGS__)
438# if CMUTIL_CALL_NESTED
439# define CMUTIL_CALL__(a,b,...) (a)->b((a) __VA_OPT__(,) __VA_ARGS__)
441# define CMUTIL_CALL__(a,b,...) (a)->b((a), ## __VA_ARGS__)
475#define CMCall CMUTIL_CALL__
477#define CMUTIL_CALL CMUTIL_CALL__
661#define CMAlloc CMUTIL_GetMem()->Alloc
667#define CMCalloc CMUTIL_GetMem()->Calloc
672#define CMRealloc CMUTIL_GetMem()->Realloc
677#define CMStrdup CMUTIL_GetMem()->Strdup
683#define CMFree CMUTIL_GetMem()->Free
866#define CMSync(a, ...) do { \
869 CMCall((a), Unlock); \
940 void*(*proc)(
void*),
void *udata,
const char *name);
1008 int pool_size,
const char *name);
1286 void *(*Find)(
const CMUTIL_Array *array,
const void *compval, uint32_t *index);
1384#define CMUTIL_ARRAY_DEFAULT 10
1391#define CMUTIL_ArrayCreate() \
1392 CMUTIL_ArrayCreateEx(CMUTIL_ARRAY_DEFAULT, NULL, NULL)
1406 size_t initcapacity,
1553 const char *tobeadded, uint32_t at,
size_t size);
1582 const char *fmt, va_list args);
1626 const CMUTIL_String *string, uint32_t offset,
size_t length);
1677 const char *needle,
const char *alter);
1694 const char *(*GetCString)(
1745#define CMUTIL_STRING_DEFAULT 32
1752#define CMUTIL_StringCreate() \
1753 CMUTIL_StringCreateEx(CMUTIL_STRING_DEFAULT, NULL)
1763 size_t initcapacity,
1764 const char *initcontent);
1906 const char *(*GetCString)(
1952#define CMUTIL_STRINGARRAY_DEFAULT 32
1958#define CMUTIL_StringArrayCreate() \
1959 CMUTIL_StringArrayCreateEx(CMUTIL_STRINGARRAY_DEFAULT)
1968 size_t initcapacity);
1981#define CMUTIL_StringArrayCreateWith(s, ...) \
1982 CMUTIL_StringArrayCreateWithEx(s, __VA_ARGS__, NULL)
1992 const char *str, ...);
2049 char *dest,
size_t buflen,
const char *src,
const char *delims);
2062 const char *src,
const char *spaces);
2075 const char *haystack,
const char *needle);
2122 const uint8_t *bytes,
2143 const uint8_t *bytes,
2184 const uint8_t *bytes,
2227 uint8_t *(*GetBytes)(
2282#define CMUTIL_BYTEBUFFER_DEFAULT 32
2287#define CMUTIL_ByteBufferCreate() \
2288 CMUTIL_ByteBufferCreateEx(CMUTIL_BYTEBUFFER_DEFAULT)
2297 size_t initcapacity);
2372 CMUTIL_Map *map,
const char* key,
void* value,
void** prev);
2561#define CMUTIL_MAP_DEFAULT 256
2566#define CMUTIL_MapCreate() CMUTIL_MapCreateEx(\
2567 CMUTIL_MAP_DEFAULT, CMFalse, NULL, 0.75f)
2718#define CMUTIL_ListCreate() CMUTIL_ListCreateEx(NULL)
2928 const char *xmlstr,
size_t len);
3031 const char *fromcs,
const char *tocs);
3107 CMUTIL_Timer *timer,
struct timeval *first,
long period,
3151#define CMUTIL_TIMER_PRECISION 1
3156#define CMUTIL_TIMER_THREAD 2
3167#define CMUTIL_TimerCreate() \
3168 CMUTIL_TimerCreateEx(CMUTIL_TIMER_PRECISION, CMUTIL_TIMER_THREAD)
3248typedef void* (*CMPoolItemCreateCB)(
void *udata);
3323 void *(*GetProcedure)(
3325 const char *proc_name);
3528 const char *(*GetName)(
3538 const char *(*GetFullPath)(
3679 const char *pattern,
CMBool recursive);
3851#define CMUTIL_LOG_CONFIG_DEFAULT "cmutil_log.jsonc"
3973 const char *(*GetName)(
4044 const char *pattern,
4059 const char *pattern);
4076 const char *rollpath,
4077 const char *pattern);
4091 const char *accept_host,
4093 const char *pattern);
4105 const char *file,
int line,
const char *fmt, ...);
4117#define CMUTIL_LogDefine(name) \
4118 static CMUTIL_Logger *l___logger = NULL; \
4119 static CMUTIL_LogSystem *s__lsys = NULL; \
4120 static CMUTIL_Logger *g__CMUTIL_GetLogger() { \
4121 if (l___logger == NULL || s__lsys != CMUTIL_LogSystemGet()) { \
4122 s__lsys = CMUTIL_LogSystemGet(); \
4123 if (s__lsys) l___logger = CMCall(s__lsys, GetLogger, name); \
4124 else l___logger = NULL; \
4126 return l___logger; \
4153#define CMLogIsEnabled(level) CMUTIL_LogIsEnabled(g__CMUTIL_GetLogger(),level)
4166#define CMUTIL_Log__(level,stack,f,...) do { \
4167 CMUTIL_Logger *g__logger = g__CMUTIL_GetLogger(); \
4169 g__logger->LogEx(g__logger, CMLogLevel_##level,__FILE__,__LINE__, \
4170 CM##stack,f,##__VA_ARGS__); \
4172 CMUTIL_LogFallback(CMLogLevel_##level, __FILE__, __LINE__, \
4173 f, ##__VA_ARGS__); \
4187#define CMUTIL_Log2__(level,stack,f,...) do { \
4188 CMUTIL_Logger *g__logger = g__CMUTIL_GetLogger(); \
4190 g__logger->LogEx(g__logger, level,__FILE__,__LINE__, \
4191 CM##stack,f,##__VA_ARGS__); \
4193 CMUTIL_LogFallback(level, __FILE__, __LINE__, \
4194 f, ##__VA_ARGS__); \
4206#define CMLogTrace(f,...) CMUTIL_Log__(Trace,False,f,##__VA_ARGS__)
4217#define CMLogTraceS(f,...) CMUTIL_Log__(Trace,True ,f,##__VA_ARGS__)
4228#define CMLogDebug(f,...) CMUTIL_Log__(Debug,False,f,##__VA_ARGS__)
4239#define CMLogDebugS(f,...) CMUTIL_Log__(Debug,True ,f,##__VA_ARGS__)
4250#define CMLogInfo(f,...) CMUTIL_Log__(Info ,False,f,##__VA_ARGS__)
4261#define CMLogInfoS(f,...) CMUTIL_Log__(Info ,True ,f,##__VA_ARGS__)
4272#define CMLogWarn(f,...) CMUTIL_Log__(Warn ,False,f,##__VA_ARGS__)
4283#define CMLogWarnS(f,...) CMUTIL_Log__(Warn ,True ,f,##__VA_ARGS__)
4294#define CMLogError(f,...) CMUTIL_Log__(Error,False,f,##__VA_ARGS__)
4305#define CMLogErrorS(f,...) CMUTIL_Log__(Error,True ,f,##__VA_ARGS__)
4316#define CMLogFatal(f,...) CMUTIL_Log__(Fatal,False,f,##__VA_ARGS__)
4327#define CMLogFatalS(f,...) CMUTIL_Log__(Fatal,True ,f,##__VA_ARGS__)
4339#define CMLog(l,f,...) CMUTIL_Log2__(l,False,f,##__VA_ARGS__)
4351#define CMLogS(l,f,...) CMUTIL_Log2__(l,True ,f,##__VA_ARGS__)
4450 const char *jsonfile);
4621 uint32_t size,
long timeout);
4638 uint32_t size,
long timeout);
4656 uint32_t offset, uint32_t length,
long timeout);
4799 const char *host,
int port,
long timeout);
4824 const char *ipc_path,
long timeout);
4840 const char *cert,
const char *key,
const char *ca,
4841 const char *servername,
4842 const char *host,
int port,
long timeout);
4857 const char *cert,
const char *key,
const char *ca,
4858 const char *servername,
4918 const char *host,
int port,
int qcnt,
CMBool silent);
4934 const char *ipc_path,
int qcnt,
CMBool silent);
4949 const char *cert,
const char *key,
const char *ca,
4950 const char *host,
int port,
int qcnt);
5167 const char *certfile,
5168 const char *keyfile,
5169 const char *cafile );
5358#define CMUTIL_JsonDestroy(a) CMCall((CMUTIL_Json*)(a), Destroy)
5440 const char *(*GetCString)(
5600 const char *(*GetCString)(
5814 const char *(*GetCString)(
6075#define CMUTIL_REST_DEFAULT_TIMEOUT 30000L
6347 const char *command,
6367#define CMUTIL_ProcessCreate(cwd, env, command, ...) \
6368 CMUTIL_ProcessCreateEx(cwd, env, command, ##__VA_ARGS__, NULL)
6393 const uint8_t *key,
const uint8_t *iv);
6406 const uint8_t *key,
const uint8_t *iv);
6424 const char *algo,
const char *mode,
const char *padding,
6470 const char *pem,
const uint8_t *passphrase);
6487 const char *file_path,
const uint8_t *passphrase);
6495 const char *file_path);
CMUTIL_List * CMUTIL_ListCreateEx(CMFreeCB freecb)
Create a new list with a custom free callback.
CMUTIL_Array * CMUTIL_ArrayCreateEx(size_t initcapacity, CMCompareCB comparator, CMFreeCB freecb)
Creates a dynamic array with capacity and optional comparator and free callback.
CMUTIL_Map * CMUTIL_MapCreateEx(uint32_t bucketsize, CMBool isucase, CMFreeCB freecb, float load_factor)
Create a new map with custom settings.
CMUTIL_Thread * CMUTIL_ThreadSelf(void)
Get the current thread context.
CMUTIL_ThreadPool * CMUTIL_ThreadPoolCreate(int pool_size, const char *name)
Creates a new threadpool object.
CMUTIL_RWLock * CMUTIL_RWLockCreate(void)
Create a read-write lock object.
CMUTIL_Semaphore * CMUTIL_SemaphoreCreate(int initcnt)
Creates a semaphore object.
CMUTIL_Thread * CMUTIL_ThreadCreate(void *(*proc)(void *), void *udata, const char *name)
Creates a thread object.
uint32_t CMUTIL_ThreadSelfId(void)
Get the ID of the current thread. This id is not system thread id, just an internal thread index.
CMUTIL_Cond * CMUTIL_CondCreate(CMBool manual_reset)
Creates a condition object.
uint64_t CMUTIL_ThreadSystemSelfId(void)
Get system dependent thread id.
CMUTIL_Mutex * CMUTIL_MutexCreate(void)
Creates a mutex object.
CMUTIL_Config * CMUTIL_ConfigCreate(void)
Create a new empty configuration object.
CMUTIL_Config * CMUTIL_ConfigLoad(const char *fconf)
Load a configuration from a file.
void CMUTIL_CryptoRandom(uint8_t *buf, size_t len)
Generates cryptographically strong random bytes.
CMUTIL_PublicKey * CMUTIL_PublicKeyCreateFromPEM(const char *pem)
Creates a public key object from a PEM-formatted string.
CMUTIL_RSAKey CMUTIL_PublicKey
An RSA key that can encrypt and verify.
Definition libcmutils.h:6447
CMUTIL_BlockCrypto * CMUTIL_BlockCryptoCreate(const char *algo, const char *mode, const char *padding, int key_bits)
Creates a new block crypto object.
CMUTIL_RSACrypto * CMUTIL_RSACryptoCreate(void)
Creates a new RSA crypto object.
CMUTIL_PublicKey * CMUTIL_PublicKeyCreateFromFile(const char *file_path)
Creates a public key object from a PEM-formatted file.
CMUTIL_PrivateKey * CMUTIL_PrivateKeyCreateFromPEM(const char *pem, const uint8_t *passphrase)
Creates a private key object from a PEM-formatted string.
CMUTIL_PrivateKey * CMUTIL_PrivateKeyCreateFromFile(const char *file_path, const uint8_t *passphrase)
Creates a private key object from a PEM-formatted file.
CMUTIL_RSAKey CMUTIL_PrivateKey
An RSA key that can decrypt and sign.
Definition libcmutils.h:6439
CMBool CMUTIL_PathCreate(const char *path, uint32_t mode)
Create directories recursively for the specified path.
CMUTIL_File * CMUTIL_FileCreate(const char *path)
Create a file or directory object for the specified path.
CMFileOpenMode
File open mode enumeration.
Definition libcmutils.h:3408
@ CMFileOpenRead
Definition libcmutils.h:3410
@ CMFileOpenAppend
Definition libcmutils.h:3414
@ CMFileOpenWrite
Definition libcmutils.h:3412
CMBool CMUTIL_Clear(void)
Clear allocated resource for this library.
CMMemOper
Memory operation types. Refer CMUTIL_Init function for details.
Definition libcmutils.h:530
void CMUTIL_Init(CMMemOper memoper)
Initialize this library. This function must be called before calling any function in this library.
CMUTIL_Mem * CMUTIL_GetMem(void)
Global memory operator structure. This object will be initialized with appropriate memory operators i...
@ CMMemRecycle
Definition libcmutils.h:534
@ CMMemSystem
Definition libcmutils.h:532
@ CMMemDebug
Definition libcmutils.h:536
CMUTIL_Json * CMUTIL_JsonParse(CMUTIL_String *jsonstr)
Parse a JSON string into a JSON object.
CMUTIL_JsonArray * CMUTIL_JsonArrayCreate(void)
Create a new JSON array.
CMUTIL_Json * CMUTIL_XmlToJson(CMUTIL_XmlNode *node)
Convert an XML node to a JSON object.
CMJsonValueType
JSON value types.
Definition libcmutils.h:5363
CMJsonType
JSON value types.
Definition libcmutils.h:5288
CMUTIL_JsonObject * CMUTIL_JsonObjectCreate(void)
Create a new JSON object.
CMUTIL_JsonValue * CMUTIL_JsonValueCreate(void)
Create a new JSON value object.
@ CMJsonValueNull
Definition libcmutils.h:5373
@ CMJsonValueBoolean
Definition libcmutils.h:5371
@ CMJsonValueString
Definition libcmutils.h:5369
@ CMJsonValueDouble
Definition libcmutils.h:5367
@ CMJsonValueLong
Definition libcmutils.h:5365
@ CMJsonTypeObject
Definition libcmutils.h:5292
@ CMJsonTypeValue
Definition libcmutils.h:5290
@ CMJsonTypeArray
Definition libcmutils.h:5294
CMUTIL_Library * CMUTIL_LibraryCreate(const char *path)
Create a dynamic library loader for the specified library path.
void CMUTIL_LogSystemSet(CMUTIL_LogSystem *lsys)
Set the global log system.
CMUTIL_LogSystem * CMUTIL_LogSystemConfigureFomJson(const char *jsonfile)
Configure the log system from a JSON configuration file.
CMBool CMUTIL_LogIsEnabled(CMUTIL_Logger *logger, CMLogLevel level)
Check if logging is enabled for the specified log level.
void CMUTIL_LogFallback(CMLogLevel level, const char *file, int line, const char *fmt,...)
Fallback logging function when no logger is available.
CMUTIL_LogAppender * CMUTIL_LogFileAppenderCreate(const char *name, const char *fpath, const char *pattern)
Create a file log appender.
CMUTIL_LogAppender * CMUTIL_LogConsoleAppenderCreate(const char *name, const char *pattern, CMBool use_stderr)
Create a console log appender.
CMLogTerm
Log rolling terms.
Definition libcmutils.h:3879
CMUTIL_LogSystem * CMUTIL_LogSystemGet(void)
Get the current global log system.
CMUTIL_LogAppender * CMUTIL_LogRollingFileAppenderCreate(const char *name, const char *fpath, CMLogTerm logterm, const char *rollpath, const char *pattern)
Create a rolling file log appender.
CMLogLevel
Log severity levels.
Definition libcmutils.h:3861
CMUTIL_LogAppender * CMUTIL_LogSocketAppenderCreate(const char *name, const char *accept_host, int listen_port, const char *pattern)
Create a socket log appender.
CMUTIL_LogSystem * CMUTIL_LogSystemCreate(void)
Create a new log system object.
@ CMLogTerm_Hour
Definition libcmutils.h:3887
@ CMLogTerm_Date
Definition libcmutils.h:3885
@ CMLogTerm_Year
Definition libcmutils.h:3881
@ CMLogTerm_Minute
Definition libcmutils.h:3889
@ CMLogTerm_Month
Definition libcmutils.h:3883
@ CMLogLevel_Info
Definition libcmutils.h:3867
@ CMLogLevel_Error
Definition libcmutils.h:3871
@ CMLogLevel_Warn
Definition libcmutils.h:3869
@ CMLogLevel_Fatal
Definition libcmutils.h:3873
@ CMLogLevel_Debug
Definition libcmutils.h:3865
@ CMLogLevel_Trace
Definition libcmutils.h:3863
CMUTIL_Socket * CMUTIL_SSLSocketConnect(const char *cert, const char *key, const char *ca, const char *servername, const char *host, int port, long timeout)
Create a new SSL socket which connected to the given endpoint.
CMSocketResult CMUTIL_SocketAddrSet(CMUTIL_SocketAddr *saddr, const char *host, int port)
Set the host and port in a socket address.
CMSocketResult CMUTIL_SocketAddrGet(const CMUTIL_SocketAddr *saddr, char *hostbuf, int *port)
Get the host and port from a socket address.
CMUTIL_Socket * CMUTIL_SocketConnect(const char *host, int port, long timeout)
Create a new socket which connected to the given endpoint.
CMUTIL_Socket * CMUTIL_SSLSocketConnectWithAddr(const char *cert, const char *key, const char *ca, const char *servername, const CMUTIL_SocketAddr *saddr, long timeout)
Create a new SSL socket which connected to the given socket address.
CMUTIL_Socket * CMUTIL_SocketConnectIPC(const char *ipc_path, long timeout)
Create a new socket which connected to the given ipc path.
CMUTIL_Socket * CMUTIL_SocketConnectWithAddr(const CMUTIL_SocketAddr *saddr, long timeout)
Create a new socket which connected to the given socket address.
CMUTIL_DGramSocket * CMUTIL_DGramSocketCreateBind(CMUTIL_SocketAddr *addr)
Create a new datagram socket and bind it to the given address.
CMUTIL_RestClient * CMUTIL_RestClientCreate(const char *urlprefix)
Create a REST client for the given URL prefix.
CMUTIL_DGramSocket * CMUTIL_DGramSocketCreate(void)
Create a new datagram socket.
CMUTIL_ServerSocket * CMUTIL_SSLServerSocketCreate(const char *cert, const char *key, const char *ca, const char *host, int port, int qcnt)
Create a new SSL server socket which listens on the given host and port.
CMSocketResult
Socket operation result codes.
Definition libcmutils.h:4547
CMUTIL_HttpClient * CMUTIL_HttpClientCreate(const char *urlprefix)
Create an HTTP client for the given URL prefix.
CMBool CMUTIL_SocketPair(CMUTIL_Socket **s1, CMUTIL_Socket **s2)
Create a pair of connected sockets.
CMUTIL_ServerSocket * CMUTIL_ServerSocketCreate(const char *host, int port, int qcnt, CMBool silent)
Create a new server socket which listens on the given host and port.
CMUTIL_ServerSocket * CMUTIL_ServerSocketCreateIPC(const char *ipc_path, int qcnt, CMBool silent)
Create a new server socket which listens on the given ipc path.
struct sockaddr_storage CMUTIL_SocketAddr
Socket address object.
Definition libcmutils.h:4573
@ CMSocketOk
Definition libcmutils.h:4549
@ CMSocketNotConnected
Definition libcmutils.h:4561
@ CMSocketSendFailed
Definition libcmutils.h:4557
@ CMSocketPollFailed
Definition libcmutils.h:4553
@ CMSocketBindFailed
Definition libcmutils.h:4565
@ CMSocketReceiveFailed
Definition libcmutils.h:4555
@ CMSocketTimeout
Definition libcmutils.h:4551
@ CMSocketUnsupported
Definition libcmutils.h:4559
@ CMSocketUnknownError
Definition libcmutils.h:4567
@ CMSocketConnectFailed
Definition libcmutils.h:4563
void *(* CMPoolItemCreateCB)(void *udata)
Callback type for creating a pool item.
Definition libcmutils.h:3248
CMBool(* CMPoolItemTestCB)(void *resource, void *udata)
Callback type for testing a pool item.
Definition libcmutils.h:3258
void(* CMPoolItemFreeCB)(void *resource, void *udata)
Callback type for freeing a pool item.
Definition libcmutils.h:3253
CMUTIL_Pool * CMUTIL_PoolCreate(int initcnt, int maxcnt, CMPoolItemCreateCB createproc, CMPoolItemFreeCB destroyproc, CMPoolItemTestCB testproc, long pinginterval, CMBool testonborrow, void *udata, CMUTIL_Timer *timer)
Create a resource pool with specified parameters.
CMProcStreamType
of process stream types.
Definition libcmutils.h:6099
CMUTIL_Process * CMUTIL_ProcessCreateEx(const char *cwd, CMUTIL_Map *env, const char *command,...)
Creates a new process with the specified command and arguments.
@ CMProcStreamWrite
Definition libcmutils.h:6116
@ CMProcStreamNone
Definition libcmutils.h:6104
@ CMProcStreamReadErr
Definition libcmutils.h:6129
@ CMProcStreamRead
Definition libcmutils.h:6110
@ CMProcStreamReadWrite
Definition libcmutils.h:6123
CMUTIL_StackWalker * CMUTIL_StackWalkerCreate(void)
Create a new stack walker object.
CMUTIL_String * CMUTIL_StringCreateEx(size_t initcapacity, const char *initcontent)
Creates a string object with initial capacity and content.
CMUTIL_StringArray * CMUTIL_StringArrayCreateEx(size_t initcapacity)
CMUTIL_StringArray * CMUTIL_StringSplit(const char *haystack, const char *needle)
Split the haystack string using the needle.
const char * CMUTIL_StrNextToken(char *dest, size_t buflen, const char *src, const char *delims)
Get the next token from src.
int CMUTIL_StringHexToBytes(uint8_t *dest, const char *src, int len)
Convert hex encoded string to bytes.
CMUTIL_CSConv * CMUTIL_CSConvCreate(const char *fromcs, const char *tocs)
Create a character set conversion object.
CMUTIL_ByteBuffer * CMUTIL_ByteBufferCreateEx(size_t initcapacity)
Creates CMUTIL_ByteBuffer object with initial capacity.
char * CMUTIL_StrLTrim(char *inp)
Trim the left side of a c-style string.
const char * CMUTIL_StrSkipSpaces(const char *src, const char *spaces)
Skip leading spaces.
char * CMUTIL_StrRTrim(char *inp)
Trim the right side of a c-style string.
CMUTIL_StringArray * CMUTIL_StringArrayCreateWithEx(const char *str,...)
Create a new CMUTIL_StringArray object with initial elements.
char * CMUTIL_StrTrim(char *inp)
Trim the both side of a c-style string.
CMUTIL_Timer * CMUTIL_TimerCreateEx(long precision, int threads)
Create a timer object with custom settings.
CMUTIL_XmlNode * CMUTIL_XmlParseString(const char *xmlstr, size_t len)
Parse an XML string into an XML node tree.
CMUTIL_XmlNode * CMUTIL_XmlParseFile(const char *fpath)
Parse an XML file into an XML node tree.
CMUTIL_XmlNode * CMUTIL_XmlParse(CMUTIL_String *str)
Parse an XML string into an XML node tree.
CMXmlNodeKind
The kind of XML node.
Definition libcmutils.h:2747
CMUTIL_XmlNode * CMUTIL_XmlNodeCreateWithLen(CMXmlNodeKind type, const char *tagname, size_t len)
Create a new XML node with the specified type and tag name of the given length.
CMUTIL_XmlNode * CMUTIL_XmlNodeCreate(CMXmlNodeKind type, const char *tagname)
Create a new XML node with the specified type and tag name.
@ CMXmlNodeTag
Definition libcmutils.h:2753
@ CMXmlNodeText
Definition libcmutils.h:2751
@ CMXmlNodeUnknown
Definition libcmutils.h:2749
CMBool
Boolean definition for this library.
Definition libcmutils.h:232
@ CMFalse
Definition libcmutils.h:236
@ CMTrue
Definition libcmutils.h:234
void(* CMFreeCB)(void *)
Callback type for memory deallocation.
Definition libcmutils.h:497
int(* CMCompareCB)(const void *, const void *)
Object comparison callback type.
Definition libcmutils.h:492
void CMUTIL_UnusedP(void *a,...)
Consumes its arguments so the compiler stops calling them unused.
CMUTIL_String * CMUTIL_CryptoToBase64(const uint8_t *data, size_t len)
Encodes data to Base64 string.
void(* CMProcCB)(void *)
Callback type for execution of some procedure.
Definition libcmutils.h:502
const char * CMUTIL_GetLibVersion(void)
Get a version string of this library.
CMUTIL_String * CMUTIL_CryptoFromBase64(const char *base64)
Decodes Base64-encoded data.
Dynamic array of any type element.
Definition libcmutils.h:1170
CMBool(* Push)(CMUTIL_Array *array, void *item)
Push an item to the end of this array like a stack operation.
Definition libcmutils.h:1310
void(* Clear)(CMUTIL_Array *array)
Clear this array object.
Definition libcmutils.h:1367
size_t(* GetSize)(const CMUTIL_Array *array)
The size of this array.
Definition libcmutils.h:1294
void(* Destroy)(CMUTIL_Array *array)
Destroy this array object.
Definition libcmutils.h:1378
CMBool(* Add)(CMUTIL_Array *array, void *item, void **ret)
Add a new element to this array.
Definition libcmutils.h:1189
Block cipher encryption/decryption object.
Definition libcmutils.h:6380
void(* Destroy)(CMUTIL_BlockCrypto *crypto)
Destroys the block crypto object.
Definition libcmutils.h:6411
Manipulation of bytes.
Definition libcmutils.h:2094
CMBool(* ShrinkTo)(CMUTIL_ByteBuffer *buffer, size_t size)
Function pointer for resizing a CMUTIL_ByteBuffer to a specified size.
Definition libcmutils.h:2240
size_t(* GetCapacity)(const CMUTIL_ByteBuffer *buffer)
Retrieves the total capacity of the specified byte buffer.
Definition libcmutils.h:2253
void(* Clear)(CMUTIL_ByteBuffer *buffer)
Function pointer for clearing the contents of a CMUTIL_ByteBuffer.
Definition libcmutils.h:2275
void(* Destroy)(CMUTIL_ByteBuffer *buffer)
Function pointer for destroying a CMUTIL_ByteBuffer instance.
Definition libcmutils.h:2264
int(* GetAt)(const CMUTIL_ByteBuffer *buffer, uint32_t index)
Retrieves the byte at a specific index in the byte buffer.
Definition libcmutils.h:2199
size_t(* GetSize)(const CMUTIL_ByteBuffer *buffer)
Retrieves the size of the given byte buffer.
Definition libcmutils.h:2213
Character set conversion object.
Definition libcmutils.h:2983
void(* Destroy)(CMUTIL_CSConv *conv)
Destroy the character set conversion object.
Definition libcmutils.h:3019
Platform independent condition definition for concurrency control.
Definition libcmutils.h:701
void(* Set)(CMUTIL_Cond *cond)
Sets this condition object.
Definition libcmutils.h:748
void(* Wait)(CMUTIL_Cond *cond)
Wait for this condition is set.
Definition libcmutils.h:709
CMBool(* TimedWait)(CMUTIL_Cond *cond, long millisec)
Waits with timeout.
Definition libcmutils.h:726
void(* Destroy)(CMUTIL_Cond *cond)
Destroys all resources related to this object.
Definition libcmutils.h:773
void(* Reset)(CMUTIL_Cond *cond)
Unsets this condition object.
Definition libcmutils.h:766
Logger configuration object.
Definition libcmutils.h:3901
void(* AddAppender)(const CMUTIL_ConfLogger *logger, CMUTIL_LogAppender *appender, CMLogLevel level)
Add a log appender to the logger configuration.
Definition libcmutils.h:3913
Configuration management object.
Definition libcmutils.h:3736
void(* SetDouble)(CMUTIL_Config *conf, const char *key, double value)
Set a configuration value as a double.
Definition libcmutils.h:3798
void(* SetLong)(CMUTIL_Config *conf, const char *key, long value)
Set a configuration value as a long integer.
Definition libcmutils.h:3780
long(* GetLong)(const CMUTIL_Config *conf, const char *key)
Get a configuration value as a long integer.
Definition libcmutils.h:3771
CMBool(* GetBoolean)(const CMUTIL_Config *conf, const char *key)
Get a configuration value as a boolean.
Definition libcmutils.h:3807
double(* GetDouble)(const CMUTIL_Config *conf, const char *key)
Get a configuration value as a double.
Definition libcmutils.h:3789
void(* Save)(const CMUTIL_Config *conf, const char *path)
Save the configuration to a file.
Definition libcmutils.h:3743
void(* SetBoolean)(CMUTIL_Config *conf, const char *key, CMBool value)
Set a configuration value as a boolean.
Definition libcmutils.h:3816
void(* Set)(CMUTIL_Config *conf, const char *key, const char *value)
Set a configuration value as a string.
Definition libcmutils.h:3762
void(* Destroy)(CMUTIL_Config *conf)
Destroy the configuration object and free its resources.
Definition libcmutils.h:3823
Datagram socket object.
Definition libcmutils.h:4966
CMSocketResult(* SendTo)(CMUTIL_DGramSocket *dsock, CMUTIL_ByteBuffer *buf, CMUTIL_SocketAddr *saddr, long timeout)
Send data to a specific address.
Definition libcmutils.h:5067
CMSocketResult(* GetLocalAddr)(CMUTIL_DGramSocket *dsock, CMUTIL_SocketAddr *saddr)
Get the local address of the datagram socket.
Definition libcmutils.h:5024
void(* Close)(CMUTIL_DGramSocket *dsock)
Close the datagram socket.
Definition libcmutils.h:5095
CMSocketResult(* Send)(CMUTIL_DGramSocket *dsock, CMUTIL_ByteBuffer *buf, long timeout)
Send data to the connected remote address.
Definition libcmutils.h:5038
void(* Disconnect)(CMUTIL_DGramSocket *dsock)
Disconnect the datagram socket.
Definition libcmutils.h:5003
CMSocketResult(* Bind)(CMUTIL_DGramSocket *dsock, const CMUTIL_SocketAddr *saddr)
Bind the datagram socket to a specific address.
Definition libcmutils.h:4974
CMBool(* IsConnected)(CMUTIL_DGramSocket *dsock)
Check if the datagram socket is connected.
Definition libcmutils.h:4995
CMSocketResult(* Recv)(CMUTIL_DGramSocket *dsock, CMUTIL_ByteBuffer *buf, long timeout)
Receive data from the connected remote address.
Definition libcmutils.h:5053
CMSocketResult(* RecvFrom)(CMUTIL_DGramSocket *dsock, CMUTIL_ByteBuffer *buf, CMUTIL_SocketAddr *saddr, long timeout)
Receive data from a specific address.
Definition libcmutils.h:5082
CMSocketResult(* GetRemoteAddr)(CMUTIL_DGramSocket *dsock, CMUTIL_SocketAddr *saddr)
Get the remote address of the datagram socket.
Definition libcmutils.h:5013
CMSocketResult(* Connect)(CMUTIL_DGramSocket *dsock, const CMUTIL_SocketAddr *saddr)
Connect the datagram socket to a specific address.
Definition libcmutils.h:4985
A list of files in a directory.
Definition libcmutils.h:3374
size_t(* Count)(const CMUTIL_FileList *flist)
Get the number of files in the list.
Definition libcmutils.h:3381
void(* Destroy)(CMUTIL_FileList *flist)
Destroy the file list and free its resources.
Definition libcmutils.h:3401
File stream object for reading and writing files.
Definition libcmutils.h:3421
ssize_t(* Write)(const CMUTIL_FileStream *fs, const CMUTIL_String *buffer, size_t offset, size_t size)
Write data from a buffer to the file stream.
Definition libcmutils.h:3450
void(* Close)(CMUTIL_FileStream *fs)
Close the file stream and free its resources.
Definition libcmutils.h:3461
ssize_t(* Read)(const CMUTIL_FileStream *fs, CMUTIL_String *buffer, size_t size)
Read data from the file stream into a buffer.
Definition libcmutils.h:3433
A file or directory object.
Definition libcmutils.h:3465
CMBool(* IsFile)(const CMUTIL_File *file)
Check if the file is a regular file.
Definition libcmutils.h:3491
CMBool(* IsExists)(const CMUTIL_File *file)
Check if the file exists.
Definition libcmutils.h:3509
time_t(* ModifiedTime)(const CMUTIL_File *file)
Get the last modified time of the file.
Definition libcmutils.h:3547
long(* Length)(const CMUTIL_File *file)
Get the length of the file in bytes.
Definition libcmutils.h:3518
void(* Destroy)(CMUTIL_File *file)
Destroy the file or directory object and free its resources.
Definition libcmutils.h:3698
CMBool(* Delete)(const CMUTIL_File *file)
Delete the file.
Definition libcmutils.h:3482
CMBool(* IsDirectory)(const CMUTIL_File *file)
Check if the file is a directory.
Definition libcmutils.h:3500
An HTTP/HTTPS client built on the socket layer.
Definition libcmutils.h:5129
void(* Destroy)(CMUTIL_HttpClient *client)
Destroy this client.
Definition libcmutils.h:5261
CMBool(* SetSSLCert)(CMUTIL_HttpClient *client, const char *certfile, const char *keyfile, const char *cafile)
Set the TLS certificates this client uses.
Definition libcmutils.h:5165
CMBool(* SetVerify)(CMUTIL_HttpClient *client, CMBool verify_host, CMBool verify_peer)
Set TLS verification for this client.
Definition libcmutils.h:5146
void(* SetKeepAlive)(CMUTIL_HttpClient *client, CMBool keepalive)
Whether to keep connections open between requests.
Definition libcmutils.h:5180
Iterator of collection members.
Definition libcmutils.h:1136
CMBool(* HasNext)(const CMUTIL_Iterator *iter)
Check iterator has the next element.
Definition libcmutils.h:1144
void(* Destroy)(CMUTIL_Iterator *iter)
Destroy this iterator.
Definition libcmutils.h:1161
JSON array type.
Definition libcmutils.h:5735
void(* AddString)(CMUTIL_JsonArray *jarr, const char *value)
Add a string value to the JSON array.
Definition libcmutils.h:5873
void(* Delete)(CMUTIL_JsonArray *jarr, uint32_t index)
Delete a JSON value from the JSON array by index.
Definition libcmutils.h:5919
void(* Add)(CMUTIL_JsonArray *jarr, CMUTIL_Json *json)
Add a JSON value to the JSON array.
Definition libcmutils.h:5839
void(* AddBoolean)(CMUTIL_JsonArray *jarr, CMBool value)
Add a boolean value to the JSON array.
Definition libcmutils.h:5884
void(* AddNull)(CMUTIL_JsonArray *jarr)
Add a null value to the JSON array.
Definition libcmutils.h:5894
void(* AddDouble)(CMUTIL_JsonArray *jarr, double value)
Add a double value to the JSON array.
Definition libcmutils.h:5861
CMBool(* GetBoolean)(const CMUTIL_JsonArray *jarr, uint32_t index)
Get a boolean value from the JSON array by index.
Definition libcmutils.h:5827
void(* AddLong)(CMUTIL_JsonArray *jarr, int64_t value)
Add a long integer value to the JSON array.
Definition libcmutils.h:5850
double(* GetDouble)(const CMUTIL_JsonArray *jarr, uint32_t index)
Get a double value from the JSON array by index.
Definition libcmutils.h:5786
int64_t(* GetLong)(const CMUTIL_JsonArray *jarr, uint32_t index)
Get a long integer value from the JSON array by index.
Definition libcmutils.h:5773
size_t(* GetSize)(const CMUTIL_JsonArray *jarr)
Get the size of the JSON array.
Definition libcmutils.h:5747
CMUTIL_Json parent
Definition libcmutils.h:5737
JSON object.
Definition libcmutils.h:5522
int64_t(* GetLong)(const CMUTIL_JsonObject *jobj, const char *key)
Get the long integer value associated with a key in the JSON object.
Definition libcmutils.h:5561
void(* PutDouble)(CMUTIL_JsonObject *jobj, const char *key, double value)
Put a double value into the JSON object with a key.
Definition libcmutils.h:5652
void(* PutBoolean)(CMUTIL_JsonObject *jobj, const char *key, CMBool value)
Put a boolean value into the JSON object with a key.
Definition libcmutils.h:5678
void(* Delete)(CMUTIL_JsonObject *jobj, const char *key)
Delete a key-value pair from the JSON object.
Definition libcmutils.h:5716
void(* PutNull)(CMUTIL_JsonObject *jobj, const char *key)
Put a null value into the JSON object with a key.
Definition libcmutils.h:5690
void(* PutLong)(CMUTIL_JsonObject *jobj, const char *key, int64_t value)
Put a long integer value into the JSON object with a key.
Definition libcmutils.h:5639
double(* GetDouble)(const CMUTIL_JsonObject *jobj, const char *key)
Get the double value associated with a key in the JSON object.
Definition libcmutils.h:5574
CMBool(* GetBoolean)(const CMUTIL_JsonObject *jobj, const char *key)
Get the boolean value associated with a key in the JSON object.
Definition libcmutils.h:5613
void(* Put)(CMUTIL_JsonObject *jobj, const char *key, CMUTIL_Json *json)
Put a JSON object into the JSON object with a key.
Definition libcmutils.h:5626
void(* PutString)(CMUTIL_JsonObject *jobj, const char *key, const char *value)
Put a string value into the JSON object with a key.
Definition libcmutils.h:5665
CMUTIL_Json parent
Definition libcmutils.h:5524
JSON value object.
Definition libcmutils.h:5382
void(* SetDouble)(CMUTIL_JsonValue *jval, double inval)
Set the double value of the JSON value.
Definition libcmutils.h:5473
CMBool(* GetBoolean)(const CMUTIL_JsonValue *jval)
Get the boolean value from the JSON value.
Definition libcmutils.h:5451
void(* SetLong)(CMUTIL_JsonValue *jval, int64_t inval)
Set the long integer value of the JSON value.
Definition libcmutils.h:5462
CMUTIL_Json parent
Definition libcmutils.h:5384
void(* SetBoolean)(CMUTIL_JsonValue *jval, CMBool inval)
Set the boolean value of the JSON value.
Definition libcmutils.h:5495
void(* SetString)(CMUTIL_JsonValue *jval, const char *inval)
Set the string value of the JSON value.
Definition libcmutils.h:5484
double(* GetDouble)(const CMUTIL_JsonValue *jval)
Get the double value from the JSON value.
Definition libcmutils.h:5418
int64_t(* GetLong)(const CMUTIL_JsonValue *jval)
Get the long integer value from the JSON value.
Definition libcmutils.h:5407
CMJsonValueType(* GetValueType)(const CMUTIL_JsonValue *jval)
Get the type of the JSON value.
Definition libcmutils.h:5396
void(* SetNull)(CMUTIL_JsonValue *jval)
Set the JSON value to null.
Definition libcmutils.h:5505
JSON base object.
Definition libcmutils.h:5301
CMJsonType(* GetType)(const CMUTIL_Json *json)
Get the type of the JSON object.
Definition libcmutils.h:5325
void(* Destroy)(CMUTIL_Json *json)
Destroy the JSON object.
Definition libcmutils.h:5347
void(* ToString)(const CMUTIL_Json *json, CMUTIL_String *buf, CMBool pretty)
Convert the JSON object to a string representation.
Definition libcmutils.h:5313
Dynamic library loader.
Definition libcmutils.h:3309
void(* Destroy)(CMUTIL_Library *lib)
Destroy the dynamic library loader and unload the library.
Definition libcmutils.h:3337
A doubly linked list type.
Definition libcmutils.h:2587
void(* MoveAll)(CMUTIL_List *dst, CMUTIL_List *src)
Move all items from one list to another.
Definition libcmutils.h:2708
void(* Destroy)(CMUTIL_List *list)
Destroy the list and free its resources.
Definition libcmutils.h:2697
void(* AddTail)(CMUTIL_List *list, void *data)
Add an item to the tail of the list.
Definition libcmutils.h:2609
void(* AddFront)(CMUTIL_List *list, void *data)
Add an item to the front of the list.
Definition libcmutils.h:2598
size_t(* GetSize)(const CMUTIL_List *list)
Get the size of the list.
Definition libcmutils.h:2675
Log appender object.
Definition libcmutils.h:3964
void(* Destroy)(CMUTIL_LogAppender *appender)
Destroy the log appender and free its resources.
Definition libcmutils.h:4030
void(* SetAsync)(CMUTIL_LogAppender *appender, size_t buffersz)
Set the log appender to operate in asynchronous mode.
Definition libcmutils.h:3985
void(* Append)(CMUTIL_LogAppender *appender, CMUTIL_Logger *logger, CMLogLevel level, CMUTIL_StringArray *stack, const char *file, int line, CMUTIL_String *logmsg)
Append a log message to the appender.
Definition libcmutils.h:4003
void(* Flush)(CMUTIL_LogAppender *appender)
Flush any buffered log messages.
Definition libcmutils.h:4020
Log system object.
Definition libcmutils.h:4357
void(* Destroy)(CMUTIL_LogSystem *logsys)
Destroy the log system and free its resources.
Definition libcmutils.h:4409
CMBool(* UpdateEnv)(CMUTIL_LogSystem *logsys)
Function for updating the environment of the log system.
Definition libcmutils.h:4423
void(* AddAppender)(const CMUTIL_LogSystem *logsys, CMUTIL_LogAppender *appender)
Add a log appender to the log system.
Definition libcmutils.h:4367
Logger object.
Definition libcmutils.h:3923
CMBool(* IsEnabled)(CMUTIL_Logger *logger, CMLogLevel level)
Check if logging is enabled for the specified log level.
Definition libcmutils.h:3959
void(* LogEx)(CMUTIL_Logger *logger, CMLogLevel level, const char *file, int line, CMBool printStack, const char *fmt,...)
Log a message with extended information.
Definition libcmutils.h:3939
Key-value pair for CMUTIL_Map.
Definition libcmutils.h:2313
Hashmap type with item order preserved.
Definition libcmutils.h:2348
CMBool(* Put)(CMUTIL_Map *map, const char *key, void *value, void **prev)
Inserts a key-value pair into the map.
Definition libcmutils.h:2371
void(* Clear)(CMUTIL_Map *map)
Clear the map.
Definition libcmutils.h:2485
void(* Destroy)(CMUTIL_Map *map)
Destroy the map object.
Definition libcmutils.h:2511
size_t(* GetSize)(const CMUTIL_Map *map)
Get the size of the map.
Definition libcmutils.h:2458
void(* PutAll)(CMUTIL_Map *map, const CMUTIL_Map *src)
Copies all key-value pairs from one map to another.
Definition libcmutils.h:2386
void(* ClearLink)(CMUTIL_Map *map)
Clear the map and free all key-value pairs.
Definition libcmutils.h:2499
void(* PrintTo)(const CMUTIL_Map *map, CMUTIL_String *out, const char *(*to_strcb)(void *))
Print the map to a string.
Definition libcmutils.h:2526
Definition libcmutils.h:580
void(* Free)(void *ptr)
Free memory.
Definition libcmutils.h:643
Platform independent mutex implementation.
Definition libcmutils.h:797
void(* Destroy)(CMUTIL_Mutex *mutex)
Destroys all resources related to this object.
Definition libcmutils.h:839
void(* Unlock)(CMUTIL_Mutex *mutex)
Unlock this mutex object.
Definition libcmutils.h:824
void(* Lock)(CMUTIL_Mutex *mutex)
Lock this mutex object.
Definition libcmutils.h:816
CMBool(* TryLock)(CMUTIL_Mutex *mutex)
Try to lock the given mutex object.
Definition libcmutils.h:833
Resource pool object.
Definition libcmutils.h:3194
void(* Destroy)(CMUTIL_Pool *pool)
Destroy the resource pool and free its resources.
Definition libcmutils.h:3242
void(* Release)(CMUTIL_Pool *pool, void *resource)
Release a resource back to the pool.
Definition libcmutils.h:3220
void(* AddResource)(CMUTIL_Pool *pool, void *resource)
Add a new resource to the pool.
Definition libcmutils.h:3231
structure for managing external processes.
Definition libcmutils.h:6136
CMBool(* PipeTo)(CMUTIL_Process *proc, CMUTIL_Process *target)
Establishes a unidirectional pipe between two processes.
Definition libcmutils.h:6251
void(* Resume)(CMUTIL_Process *proc)
Resumes the execution of the specified process.
Definition libcmutils.h:6233
pid_t(* GetPid)(CMUTIL_Process *proc)
Retrieves the process identifier (PID) of the specified process.
Definition libcmutils.h:6159
ssize_t(* ReadErr)(CMUTIL_Process *proc, CMUTIL_ByteBuffer *buf, size_t count)
Read data from the process's stderr.
Definition libcmutils.h:6327
void(* Suspend)(CMUTIL_Process *proc)
Suspends the execution of the specified process.
Definition libcmutils.h:6222
ssize_t(* Write)(CMUTIL_Process *proc, const void *buf, size_t count)
Write data to the process's stdin.
Definition libcmutils.h:6265
void(* Kill)(CMUTIL_Process *proc)
Terminates the specified process.
Definition libcmutils.h:6302
int(* Wait)(CMUTIL_Process *proc, long millis)
Waits for the specified process to complete.
Definition libcmutils.h:6292
void(* Destroy)(CMUTIL_Process *proc)
Frees resources associated with the specified process.
Definition libcmutils.h:6313
CMBool(* Start)(CMUTIL_Process *proc, CMProcStreamType type)
Start the process.
Definition libcmutils.h:6146
ssize_t(* Read)(CMUTIL_Process *proc, CMUTIL_ByteBuffer *buf, size_t count)
Read data from the process's stdout.
Definition libcmutils.h:6279
RSA encryption/decryption and signature object.
Definition libcmutils.h:6501
CMBool(* VerifySignature)(CMUTIL_RSACrypto *crypto, CMUTIL_String *plain, CMUTIL_String *signature, CMUTIL_PublicKey *pubKey)
Verifies a digital signature using an RSA public key.
Definition libcmutils.h:6565
void(* Destroy)(CMUTIL_RSACrypto *crypto)
Destroys the RSA crypto object.
Definition libcmutils.h:6574
RSA key object (can be either a private or public key).
Definition libcmutils.h:6448
void(* Destroy)(CMUTIL_RSAKey *key)
Destroys the RSA key object.
Definition libcmutils.h:6460
Platform independent read/write lock object.
Definition libcmutils.h:1063
void(* ReadUnlock)(CMUTIL_RWLock *rwlock)
Release read lock for this object.
Definition libcmutils.h:1082
void(* ReadLock)(CMUTIL_RWLock *rwlock)
Read lock for this object.
Definition libcmutils.h:1073
void(* WriteLock)(CMUTIL_RWLock *rwlock)
Write lock for this object.
Definition libcmutils.h:1097
void(* Destroy)(CMUTIL_RWLock *rwlock)
Destroy all resources related to this object.
Definition libcmutils.h:1113
void(* WriteUnlock)(CMUTIL_RWLock *rwlock)
Release write lock for this object.
Definition libcmutils.h:1106
A JSON layer over CMUTIL_HttpClient.
Definition libcmutils.h:5983
void(* Delete)(CMUTIL_RestClient *client, CMUTIL_Map *headers, const char *uri)
Perform a DELETE request, discarding the response.
Definition libcmutils.h:6044
void(* SetTimeout)(CMUTIL_RestClient *client, long timeout)
Set the timeout applied to every REST request.
Definition libcmutils.h:6058
CMBool(* Put)(CMUTIL_RestClient *client, CMUTIL_Map *headers, const char *uri, CMUTIL_Json *data)
Perform a PUT request with a JSON body, discarding the response.
Definition libcmutils.h:6031
CMUTIL_HttpClient base
Definition libcmutils.h:5988
int(* GetStatus)(const CMUTIL_RestClient *client)
The HTTP status of the most recent request on this client.
Definition libcmutils.h:6068
Platform independent semaphore object.
Definition libcmutils.h:1014
void(* Release)(CMUTIL_Semaphore *semaphore)
Release ownership to semaphore.
Definition libcmutils.h:1039
CMBool(* Acquire)(CMUTIL_Semaphore *semaphore, long millisec)
Acquire ownership from semaphore.
Definition libcmutils.h:1028
void(* Destroy)(CMUTIL_Semaphore *semaphore)
Destroy all resources related to this object.
Definition libcmutils.h:1046
Server socket object.
Definition libcmutils.h:4865
void(* Close)(CMUTIL_ServerSocket *server)
Close the server socket.
Definition libcmutils.h:4890
void(* SetSilent)(CMUTIL_ServerSocket *socket, CMBool silent)
Suppress this library's own error logging on this listener.
Definition libcmutils.h:4901
CMSocketResult(* Accept)(const CMUTIL_ServerSocket *server, CMUTIL_Socket **res, long timeout)
Accept a new connection on the server socket.
Definition libcmutils.h:4878
Socket object.
Definition libcmutils.h:4604
void(* Close)(CMUTIL_Socket *socket)
Close the socket.
Definition libcmutils.h:4735
CMSocketResult(* CheckReadBuffer)(const CMUTIL_Socket *socket, long timeout)
Check if the socket is ready for reading.
Definition libcmutils.h:4668
CMSocketResult(* WritePart)(const CMUTIL_Socket *socket, const void *data, uint32_t offset, uint32_t length, long timeout)
Write a specific part of data to the socket from a buffer.
Definition libcmutils.h:4654
void(* SetSilent)(CMUTIL_Socket *socket, CMBool silent)
Suppress this library's own error logging on this socket.
Definition libcmutils.h:4785
CMSocketResult(* GetRemoteAddr)(const CMUTIL_Socket *socket, CMUTIL_SocketAddr *addr)
Get the remote address of the socket.
Definition libcmutils.h:4725
CMSocketResult(* CheckWriteBuffer)(const CMUTIL_Socket *socket, long timeout)
Check if the socket is ready for writing.
Definition libcmutils.h:4681
SOCKET(* GetRawSocket)(const CMUTIL_Socket *socket)
Get the raw socket descriptor.
Definition libcmutils.h:4747
CMSocketResult(* WriteByte)(const CMUTIL_Socket *socket, uint8_t c, long timeout)
Write a single byte to the socket.
Definition libcmutils.h:4772
CMSocketResult(* WriteSocket)(const CMUTIL_Socket *socket, CMUTIL_Socket *tobesent, pid_t pid, long timeout)
Write a socket object to the current socket.
Definition libcmutils.h:4711
CMSocketResult(* Read)(const CMUTIL_Socket *socket, CMUTIL_ByteBuffer *buffer, uint32_t size, long timeout)
Read data from the socket into a buffer.
Definition libcmutils.h:4618
CMSocketResult(* Write)(const CMUTIL_Socket *socket, const void *data, uint32_t size, long timeout)
Write the given data to the socket into a buffer.
Definition libcmutils.h:4635
int(* ReadByte)(const CMUTIL_Socket *socket, long timeout)
Read a single byte from the socket.
Definition libcmutils.h:4759
Stack walker object.
Definition libcmutils.h:4486
void(* PrintStack)(const CMUTIL_StackWalker *walker, CMUTIL_String *outbuf, int skipdepth)
Print the current call stack to a string buffer.
Definition libcmutils.h:4511
void(* Destroy)(CMUTIL_StackWalker *walker)
Destroy the stack walker and free its resources.
Definition libcmutils.h:4523
Dynamic array of string objects.
Definition libcmutils.h:1771
void(* AddCString)(CMUTIL_StringArray *array, const char *string)
Add a new c-style string.
Definition libcmutils.h:1795
CMBool(* InsertAtCString)(CMUTIL_StringArray *array, const char *string, uint32_t index)
Insert a new c-style string at the given index.
Definition libcmutils.h:1827
CMBool(* InsertAt)(CMUTIL_StringArray *array, CMUTIL_String *string, uint32_t index)
Insert a string object to this array at the index.
Definition libcmutils.h:1812
void(* Destroy)(CMUTIL_StringArray *array)
Destroy this array object and it's contents.
Definition libcmutils.h:1932
size_t(* GetSize)(const CMUTIL_StringArray *array)
Get the number of items in this array.
Definition libcmutils.h:1915
void(* PrintTo)(const CMUTIL_StringArray *array, CMUTIL_String *out)
Function pointer used to format and output the contents of a string array.
Definition libcmutils.h:1944
void(* Add)(CMUTIL_StringArray *array, CMUTIL_String *string)
Add a string object to this array.
Definition libcmutils.h:1783
Multifunctional string type.
Definition libcmutils.h:1423
ssize_t(* InsertAnother)(CMUTIL_String *string, uint32_t idx, CMUTIL_String *tobeadded)
Insert another string object to this string object.
Definition libcmutils.h:1600
void(* Clear)(CMUTIL_String *string)
Clear the content of this string object.
Definition libcmutils.h:1716
ssize_t(* InsertPrint)(CMUTIL_String *string, uint32_t idx, const char *fmt,...)
Definition libcmutils.h:1566
void(* SelfTrim)(CMUTIL_String *string)
Trim spaces from both ends of this string object.
Definition libcmutils.h:1742
ssize_t(* AddAnother)(CMUTIL_String *string, const CMUTIL_String *tobeadded)
Add another string object to this string object.
Definition libcmutils.h:1510
ssize_t(* AddNString)(CMUTIL_String *string, const char *tobeadded, size_t size)
Add n bytes string to this string object.
Definition libcmutils.h:1455
void(* SelfToLower)(CMUTIL_String *string)
Converts this string to lower case.
Definition libcmutils.h:1643
ssize_t(* AddPrint)(CMUTIL_String *string, const char *fmt,...)
Add a formatted string to this string object.
Definition libcmutils.h:1480
ssize_t(* InsertVPrint)(CMUTIL_String *string, uint32_t idx, const char *fmt, va_list args)
Definition libcmutils.h:1580
ssize_t(* InsertString)(CMUTIL_String *string, const char *tobeadded, uint32_t at)
Insert a c-style string to this string object.
Definition libcmutils.h:1529
int(* GetChar)(const CMUTIL_String *string, uint32_t idx)
Function pointer to retrieve a character from a specified position in a string.
Definition libcmutils.h:1708
ssize_t(* InsertNString)(CMUTIL_String *string, const char *tobeadded, uint32_t at, size_t size)
Insert n bytes string to this string object.
Definition libcmutils.h:1551
void(* Destroy)(CMUTIL_String *string)
Destroy this string object.
Definition libcmutils.h:1734
ssize_t(* AddString)(CMUTIL_String *string, const char *tobeadded)
Add a c-style string to this string object.
Definition libcmutils.h:1437
ssize_t(* AddChar)(CMUTIL_String *string, char tobeadded)
Add a character to this string object.
Definition libcmutils.h:1467
void(* SelfToUpper)(CMUTIL_String *string)
Converts this string to the upper case.
Definition libcmutils.h:1661
ssize_t(* AddVPrint)(CMUTIL_String *string, const char *fmt, va_list args)
Add a formatted string to this string object.
Definition libcmutils.h:1493
void(* CutTailOff)(CMUTIL_String *string, size_t length)
Cut off the given number of characters from the tail of this string.
Definition libcmutils.h:1613
size_t(* GetSize)(const CMUTIL_String *string)
Get the size of this string object.
Definition libcmutils.h:1685
A threadpool object.
Definition libcmutils.h:965
void(* Wait)(CMUTIL_ThreadPool *tp)
Wait until all jobs are finished.
Definition libcmutils.h:985
void(* Destroy)(CMUTIL_ThreadPool *tp)
Destroy all resources related with this object.
Definition libcmutils.h:991
void(* Execute)(CMUTIL_ThreadPool *tp, CMProcCB runnable, void *udata)
Execute a job in this threadpool.
Definition libcmutils.h:978
Platform independent thread object.
Definition libcmutils.h:876
CMBool(* Start)(CMUTIL_Thread *thread)
Starts this thread.
Definition libcmutils.h:886
uint32_t(* GetId)(const CMUTIL_Thread *thread)
Get the ID of this thread. The returned ID is not the system thread ID, just an internal thread index...
Definition libcmutils.h:915
CMBool(* IsRunning)(const CMUTIL_Thread *thread)
This thread is running or not.
Definition libcmutils.h:907
Timer task handle.
Definition libcmutils.h:3047
void(* Cancel)(CMUTIL_TimerTask *task)
Cancel the scheduled timer task and destroy.
Definition libcmutils.h:3060
Timer object for scheduling tasks.
Definition libcmutils.h:3067
void(* Purge)(CMUTIL_Timer *timer)
Purge all scheduled tasks from the timer.
Definition libcmutils.h:3134
void(* Destroy)(CMUTIL_Timer *timer)
Destroy the timer object and free its resources.
Definition libcmutils.h:3145
XML node manipulation.
Definition libcmutils.h:2761
size_t(* ChildCount)(const CMUTIL_XmlNode *node)
Get the number of child nodes.
Definition libcmutils.h:2800
CMXmlNodeKind(* GetType)(const CMUTIL_XmlNode *node)
Get the text content of this node.
Definition libcmutils.h:2863
void(* Destroy)(CMUTIL_XmlNode *node)
Destroy this XML node and free its resources.
Definition libcmutils.h:2903
void(* AddChild)(CMUTIL_XmlNode *node, CMUTIL_XmlNode *child)
Add a child node to this node.
Definition libcmutils.h:2810
void(* SetAttribute)(CMUTIL_XmlNode *node, const char *key, const char *value)
Set the value of an attribute by key.
Definition libcmutils.h:2791
void(* SetUserData)(CMUTIL_XmlNode *node, void *udata, void(*freef)(void *))
Set user data associated with this node.
Definition libcmutils.h:2887
void(* SetName)(CMUTIL_XmlNode *node, const char *name)
Set the name of this node.
Definition libcmutils.h:2853