libcmutils 0.6.5
Multi-platform C99 utility library
Loading...
Searching...
No Matches
libcmutils.h
Go to the documentation of this file.
1/*
2MIT License
3
4Copyright (c) 2020 Dennis Soungjin Park<xcomart@gmail.com>
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in all
14copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22SOFTWARE.
23 */
24
90#ifndef LIBCMUTILS_H__
91#define LIBCMUTILS_H__
92
93#ifdef __cplusplus
94extern "C" {
95#endif
96
97#if defined(__CYGWIN__) /* CYGWIN implements a UNIX API */
98# undef WIN
99# undef _WIN
100# undef _WIN32
101# undef _WIN64
102# undef MSWIN
103#endif
104
105#if (defined(_WIN32) || defined(_WIN64)) && !defined(MSWIN)
106# define MSWIN
107#endif
108
109#if defined(__APPLE__) && !defined(APPLE)
110# define APPLE
111#endif
112
113#if defined(_MSC_VER)
114# include <winsock2.h>
115# include <windows.h>
116#else
117# include <sys/time.h>
118# include <unistd.h>
119# include <netinet/in.h>
120#endif
121#include <stdarg.h>
122#include <stdint.h>
123
124#define __STDC_FORMAT_MACROS 1 /* for 64bit integer-related macros */
125#include <inttypes.h>
126#include <sys/types.h>
127
128#ifndef CMUTIL_API
129# if defined(MSWIN)
130# if defined(CMUTIL_EXPORT)
131# define CMUTIL_API __declspec(dllexport)
132# else
133# define CMUTIL_API __declspec(dllimport)
134# endif
135# else
136# define CMUTIL_API
137# endif
138#endif
139
140#if !defined(MSWIN)
141# if !defined(SOCKET)
142# define SOCKET int
143# endif
144# if !defined(closesocket)
145# define closesocket close
146# endif
147# if !defined(ioctlsocket)
148# define ioctlsocket ioctl
149# endif
150# if !defined(SOCKET_ERROR)
151# define SOCKET_ERROR -1
152# endif
153# if !defined(INVALID_SOCKET)
154# define INVALID_SOCKET -1
155# endif
156#endif
157
158/*
159 * to remove a noisy warning in qtcreator
160 */
161#ifndef __null
162# define __null (void*)0
163#endif
164
165/*
166 * MSVC compatible definitions.
167 */
168#if defined(_MSC_VER)
169# define strcasecmp _stricmp
170# define strncasecmp _strnicmp
171# define stat _stat
172# define pid_t DWORD
173# define usleep(x) Sleep(x / 1000)
174#endif
175
176
188#if !defined(INT64_MAX)
189# define INT64_MAX i64(0x7FFFFFFFFFFFFFFF)
190#endif
191#if !defined(UINT64_MAX)
192# define UINT64_MAX ui64(0xFFFFFFFFFFFFFFFF)
193#endif
194
198#define CMUTIL_APPEND(a,b) a ## b
199#if defined(_MSC_VER)
200# define i64(x) CMUTIL_APPEND(x, i64)
201# define ui64(x) CMUTIL_APPEND(x, ui64)
202#else
203# define i64(x) CMUTIL_APPEND(x, LL)
204# define ui64(x) CMUTIL_APPEND(x, ULL)
205#endif
206
207#if defined(_MSC_VER)
208# include <BaseTsd.h>
209typedef SSIZE_T ssize_t;
210#endif
211
212#if defined(_MSC_VER)
223CMUTIL_API int __gettimeofday(struct timeval *tv, void *tz);
224
225#define gettimeofday(tv, tz) __gettimeofday(tv, tz)
226#endif
227
228
232typedef enum CMBool {
236 CMFalse = 0
238
243#if defined(APPLE)
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);
260# endif
275CMUTIL_API int CMUTIL_NetworkGetHostByNameR(
276 const char *name, struct hostent *ret, char *buf, size_t buflen,
277 struct hostent **result, int *h_errnop);
278#endif
279
283#define CMUTIL_UNUSED(a,...) CMUTIL_UnusedP((void*)(int64_t)(a), ## __VA_ARGS__)
292CMUTIL_API void CMUTIL_UnusedP(void *a, ...);
293
337#if !defined(CMUTIL_CALL_NESTED)
338# if defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L
339 /* C23, and the C2x drafts that already carried __VA_OPT__ */
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
345 /* the conforming preprocessor, /Zc:preprocessor */
346# define CMUTIL_CALL_NESTED 1
347# else
348# define CMUTIL_CALL_NESTED 0
349# endif
350#endif
351
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))
385 /* MSVC only with /Zc:preprocessor - the traditional one mangles
386 * __VA_ARGS__ on its way into the inner macro. */
387# define CMUTIL_CALL_SINGLE_EVAL 1
388# else
389# define CMUTIL_CALL_SINGLE_EVAL 0
390# endif
391#endif
392
393#if CMUTIL_CALL_SINGLE_EVAL && \
394 !defined(__GNUC__) && !defined(__cplusplus)
395# error "CMUTIL_CALL_SINGLE_EVAL needs a statement expression or a lambda"
396#endif
397
402#define CMUTIL_CAT2__(a,b) a ## b
403#define CMUTIL_CAT__(a,b) CMUTIL_CAT2__(a,b)
404
408#if CMUTIL_CALL_SINGLE_EVAL
409# if defined(__GNUC__)
410 /* statement expression: GCC and Clang, C and C++ alike */
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__)
416# else
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__)
421# endif
422# else
423 /* immediately invoked lambda: any C++ compiler, MSVC included */
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__)
429# else
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__)
434# endif
435# endif
436#else
437 /* the receiver is named twice */
438# if CMUTIL_CALL_NESTED
439# define CMUTIL_CALL__(a,b,...) (a)->b((a) __VA_OPT__(,) __VA_ARGS__)
440# else
441# define CMUTIL_CALL__(a,b,...) (a)->b((a), ## __VA_ARGS__)
442# endif
443#endif
444
475#define CMCall CMUTIL_CALL__
476// for backward compatibility
477#define CMUTIL_CALL CMUTIL_CALL__
478
487CMUTIL_API const char *CMUTIL_GetLibVersion(void);
488
492typedef int (*CMCompareCB)(const void*, const void*);
493
497typedef void (*CMFreeCB)(void*);
498
502typedef void (*CMProcCB)(void*);
503
538
563CMUTIL_API void CMUTIL_Init(CMMemOper memoper);
564
575CMUTIL_API CMBool CMUTIL_Clear(void);
576
580typedef struct CMUTIL_Mem {
595 void *(*Alloc)(
596 size_t size);
597
608 void *(*Calloc)(
609 size_t nmem,
610 size_t size);
611
622 void *(*Realloc)(
623 void *ptr,
624 size_t size);
625
635 char *(*Strdup)(
636 const char *str);
637
643 void (*Free)(
644 void *ptr);
645} CMUTIL_Mem;
646
655CMUTIL_API CMUTIL_Mem *CMUTIL_GetMem(void);
656
661#define CMAlloc CMUTIL_GetMem()->Alloc
662
667#define CMCalloc CMUTIL_GetMem()->Calloc
668
672#define CMRealloc CMUTIL_GetMem()->Realloc
673
677#define CMStrdup CMUTIL_GetMem()->Strdup
678
683#define CMFree CMUTIL_GetMem()->Free
684
700typedef struct CMUTIL_Cond CMUTIL_Cond;
702
709 void (*Wait)(
710 CMUTIL_Cond *cond);
711
727 CMUTIL_Cond *cond,
728 long millisec);
729
748 void (*Set)(
749 CMUTIL_Cond *cond);
750
766 void (*Reset)(
767 CMUTIL_Cond *cond);
768
773 void (*Destroy)(
774 CMUTIL_Cond *cond);
775};
776
791CMUTIL_API CMUTIL_Cond *CMUTIL_CondCreate(CMBool manual_reset);
792
796typedef struct CMUTIL_Mutex CMUTIL_Mutex;
798
816 void (*Lock)(CMUTIL_Mutex *mutex);
817
824 void (*Unlock)(CMUTIL_Mutex *mutex);
825
834
839 void (*Destroy)(CMUTIL_Mutex *mutex);
840};
841
852
866#define CMSync(a, ...) do { \
867 CMCall((a), Lock); \
868 __VA_ARGS__ \
869 CMCall((a), Unlock); \
870} while(0)
871
875typedef struct CMUTIL_Thread CMUTIL_Thread;
877
887
898 void *(*Join)(CMUTIL_Thread *thread);
899
907 CMBool (*IsRunning)(const CMUTIL_Thread *thread);
908
915 uint32_t (*GetId)(const CMUTIL_Thread *thread);
916
922 const char *(*GetName)(const CMUTIL_Thread *thread);
923};
924
940 void*(*proc)(void*), void *udata, const char *name);
941
947CMUTIL_API uint32_t CMUTIL_ThreadSelfId(void);
948
954
959CMUTIL_API uint64_t CMUTIL_ThreadSystemSelfId(void);
960
966
978 void (*Execute)(CMUTIL_ThreadPool *tp, CMProcCB runnable, void *udata);
979
986
992};
993
1008 int pool_size, const char *name);
1009
1013typedef struct CMUTIL_Semaphore CMUTIL_Semaphore;
1015
1029 CMUTIL_Semaphore *semaphore, long millisec);
1030
1039 void (*Release)(
1040 CMUTIL_Semaphore *semaphore);
1041
1046 void (*Destroy)(CMUTIL_Semaphore *semaphore);
1047};
1048
1057
1058
1062typedef struct CMUTIL_RWLock CMUTIL_RWLock;
1064
1073 void (*ReadLock)(
1074 CMUTIL_RWLock *rwlock);
1075
1082 void (*ReadUnlock)(
1083 CMUTIL_RWLock *rwlock);
1084
1097 void (*WriteLock)(
1098 CMUTIL_RWLock *rwlock);
1099
1107 CMUTIL_RWLock *rwlock);
1108
1113 void (*Destroy)(CMUTIL_RWLock *rwlock);
1114};
1115
1122
1135typedef struct CMUTIL_Iterator CMUTIL_Iterator;
1137
1145 const CMUTIL_Iterator *iter);
1146
1152 void *(*Next)(
1153 CMUTIL_Iterator *iter);
1154
1161 void (*Destroy)(
1162 CMUTIL_Iterator *iter);
1163};
1164
1165
1169typedef struct CMUTIL_Array CMUTIL_Array;
1171
1189 CMBool (*Add)(CMUTIL_Array *array, void *item, void **ret);
1190
1208 void *(*Remove)(CMUTIL_Array *array, const void *compval);
1209
1225 void *(*InsertAt)(CMUTIL_Array *array, void *item, uint32_t index);
1226
1237 void *(*RemoveAt)(CMUTIL_Array *array, uint32_t index);
1238
1255 void *(*SetAt)(CMUTIL_Array *array, void *item, uint32_t index);
1256
1269 void *(*GetAt)(const CMUTIL_Array *array, uint32_t index);
1270
1286 void *(*Find)(const CMUTIL_Array *array, const void *compval, uint32_t *index);
1287
1294 size_t (*GetSize)(const CMUTIL_Array *array);
1295
1310 CMBool (*Push)(CMUTIL_Array *array, void *item);
1311
1322 void *(*Pop)(CMUTIL_Array *array);
1323
1334 void *(*Top)(const CMUTIL_Array *array);
1335
1346 void *(*Bottom)(const CMUTIL_Array *array);
1347
1356 CMUTIL_Iterator *(*Iterator)(const CMUTIL_Array *array);
1357
1367 void (*Clear)(CMUTIL_Array *array);
1368
1378 void (*Destroy)(CMUTIL_Array *array);
1379};
1380
1384#define CMUTIL_ARRAY_DEFAULT 10
1385
1391#define CMUTIL_ArrayCreate() \
1392 CMUTIL_ArrayCreateEx(CMUTIL_ARRAY_DEFAULT, NULL, NULL)
1393
1406 size_t initcapacity,
1407 CMCompareCB comparator,
1408 CMFreeCB freecb);
1409
1422typedef struct CMUTIL_String CMUTIL_String;
1437 ssize_t (*AddString)(
1438 CMUTIL_String *string, const char *tobeadded);
1439
1455 ssize_t (*AddNString)(
1456 CMUTIL_String *string, const char *tobeadded, size_t size);
1457
1467 ssize_t (*AddChar)(
1468 CMUTIL_String *string, char tobeadded);
1469
1480 ssize_t (*AddPrint)(
1481 CMUTIL_String *string, const char *fmt, ...);
1482
1493 ssize_t (*AddVPrint)(
1494 CMUTIL_String *string, const char *fmt, va_list args);
1495
1510 ssize_t (*AddAnother)(
1511 CMUTIL_String *string, const CMUTIL_String *tobeadded);
1512
1529 ssize_t (*InsertString)(
1530 CMUTIL_String *string, const char *tobeadded, uint32_t at);
1531
1551 ssize_t (*InsertNString)(
1552 CMUTIL_String *string,
1553 const char *tobeadded, uint32_t at, size_t size);
1554
1566 ssize_t (*InsertPrint)(
1567 CMUTIL_String *string, uint32_t idx, const char *fmt, ...);
1568
1580 ssize_t (*InsertVPrint)(
1581 CMUTIL_String *string, uint32_t idx,
1582 const char *fmt, va_list args);
1583
1600 ssize_t (*InsertAnother)(
1601 CMUTIL_String *string, uint32_t idx, CMUTIL_String *tobeadded);
1602
1613 void (*CutTailOff)(
1614 CMUTIL_String *string, size_t length);
1615
1625 CMUTIL_String *(*Substring)(
1626 const CMUTIL_String *string, uint32_t offset, size_t length);
1627
1635 CMUTIL_String *(*ToLower)(
1636 const CMUTIL_String *string);
1637
1644 CMUTIL_String *string);
1645
1653 CMUTIL_String *(*ToUpper)(
1654 const CMUTIL_String *string);
1655
1662 CMUTIL_String *string);
1663
1675 CMUTIL_String *(*Replace)(
1676 const CMUTIL_String *string,
1677 const char *needle, const char *alter);
1678
1685 size_t (*GetSize)(
1686 const CMUTIL_String *string);
1687
1694 const char *(*GetCString)(
1695 const CMUTIL_String *string);
1696
1708 int (*GetChar)(
1709 const CMUTIL_String *string, uint32_t idx);
1710
1716 void (*Clear)(
1717 CMUTIL_String *string);
1718
1726 CMUTIL_String *(*Clone)(
1727 const CMUTIL_String *string);
1728
1734 void (*Destroy)(
1735 CMUTIL_String *string);
1736
1742 void (*SelfTrim)(CMUTIL_String *string);
1743};
1744
1745#define CMUTIL_STRING_DEFAULT 32
1746
1752#define CMUTIL_StringCreate() \
1753 CMUTIL_StringCreateEx(CMUTIL_STRING_DEFAULT, NULL)
1754
1763 size_t initcapacity,
1764 const char *initcontent);
1765
1766
1783 void (*Add)(
1784 CMUTIL_StringArray *array, CMUTIL_String *string);
1785
1795 void (*AddCString)(
1796 CMUTIL_StringArray *array, const char *string);
1797
1813 CMUTIL_StringArray *array, CMUTIL_String *string, uint32_t index);
1814
1828 CMUTIL_StringArray *array, const char *string, uint32_t index);
1829
1843 CMUTIL_String *(*RemoveAt)(
1844 CMUTIL_StringArray *array, uint32_t index);
1845
1865 CMUTIL_String *(*SetAt)(
1866 CMUTIL_StringArray *array, CMUTIL_String *string, uint32_t index);
1867
1882 CMUTIL_String *(*SetAtCString)(
1883 CMUTIL_StringArray *array, const char *string, uint32_t index);
1884
1896 const CMUTIL_String *(*GetAt)(
1897 const CMUTIL_StringArray *array, uint32_t index);
1898
1906 const char *(*GetCString)(
1907 const CMUTIL_StringArray *array, uint32_t index);
1908
1915 size_t (*GetSize)(
1916 const CMUTIL_StringArray *array);
1917
1924 CMUTIL_Iterator *(*Iterator)(
1925 const CMUTIL_StringArray *array);
1926
1932 void (*Destroy)(
1933 CMUTIL_StringArray *array);
1934
1944 void (*PrintTo)(
1945 const CMUTIL_StringArray *array,
1946 CMUTIL_String *out);
1947};
1948
1952#define CMUTIL_STRINGARRAY_DEFAULT 32
1953
1958#define CMUTIL_StringArrayCreate() \
1959 CMUTIL_StringArrayCreateEx(CMUTIL_STRINGARRAY_DEFAULT)
1960
1968 size_t initcapacity);
1969
1970
1981#define CMUTIL_StringArrayCreateWith(s, ...) \
1982 CMUTIL_StringArrayCreateWithEx(s, __VA_ARGS__, NULL)
1983
1992 const char *str, ...);
1993
2006CMUTIL_API char *CMUTIL_StrRTrim(char *inp);
2007
2020CMUTIL_API char *CMUTIL_StrLTrim(char *inp);
2021
2034CMUTIL_API char *CMUTIL_StrTrim(char *inp);
2035
2048CMUTIL_API const char *CMUTIL_StrNextToken(
2049 char *dest, size_t buflen, const char *src, const char *delims);
2050
2061CMUTIL_API const char *CMUTIL_StrSkipSpaces(
2062 const char *src, const char *spaces);
2063
2075 const char *haystack, const char *needle);
2076
2087CMUTIL_API int CMUTIL_StringHexToBytes(uint8_t *dest, const char *src, int len);
2088
2089
2095
2104 CMUTIL_ByteBuffer *buffer,
2105 uint8_t b);
2106
2120 CMUTIL_ByteBuffer *(*AddBytes)(
2121 CMUTIL_ByteBuffer *buffer,
2122 const uint8_t *bytes,
2123 uint32_t length);
2124
2141 CMUTIL_ByteBuffer *(*AddBytesPart)(
2142 CMUTIL_ByteBuffer *buffer,
2143 const uint8_t *bytes,
2144 uint32_t offset,
2145 uint32_t length);
2146
2161 CMUTIL_ByteBuffer *(*InsertByteAt)(
2162 CMUTIL_ByteBuffer *buffer,
2163 uint32_t index,
2164 uint8_t b);
2165
2181 CMUTIL_ByteBuffer *(*InsertBytesAt)(
2182 CMUTIL_ByteBuffer *buffer,
2183 uint32_t index,
2184 const uint8_t *bytes,
2185 uint32_t length);
2186
2199 int (*GetAt)(
2200 const CMUTIL_ByteBuffer *buffer,
2201 uint32_t index);
2202
2213 size_t (*GetSize)(
2214 const CMUTIL_ByteBuffer *buffer);
2215
2227 uint8_t *(*GetBytes)(
2228 CMUTIL_ByteBuffer *buffer);
2229
2241 CMUTIL_ByteBuffer *buffer,
2242 size_t size);
2243
2253 size_t (*GetCapacity)(
2254 const CMUTIL_ByteBuffer *buffer);
2255
2264 void (*Destroy)(
2265 CMUTIL_ByteBuffer *buffer);
2266
2275 void (*Clear)(
2276 CMUTIL_ByteBuffer *buffer);
2277};
2278
2282#define CMUTIL_BYTEBUFFER_DEFAULT 32
2283
2287#define CMUTIL_ByteBufferCreate() \
2288 CMUTIL_ByteBufferCreateEx(CMUTIL_BYTEBUFFER_DEFAULT)
2289
2297 size_t initcapacity);
2298
2312typedef struct CMUTIL_MapPair CMUTIL_MapPair;
2326 const char *(*GetKey)(const CMUTIL_MapPair *pair);
2327
2340 void *(*GetValue)(const CMUTIL_MapPair *pair);
2341};
2342
2343
2347typedef struct CMUTIL_Map CMUTIL_Map;
2372 CMUTIL_Map *map, const char* key, void* value, void** prev);
2373
2386 void (*PutAll)(
2387 CMUTIL_Map *map, const CMUTIL_Map *src);
2388
2401 void *(*Get)(
2402 const CMUTIL_Map *map, const char* key);
2403
2416 void *(*Remove)(
2417 CMUTIL_Map *map, const char* key);
2418
2432 const CMUTIL_Map *map);
2433
2446 const CMUTIL_Array *(*GetPairs)(
2447 const CMUTIL_Map *map);
2448
2458 size_t (*GetSize)(
2459 const CMUTIL_Map *map);
2460
2471 CMUTIL_Iterator *(*Iterator)(
2472 const CMUTIL_Map *map);
2473
2485 void (*Clear)(
2486 CMUTIL_Map *map);
2487
2499 void (*ClearLink)(
2500 CMUTIL_Map *map);
2501
2511 void (*Destroy)(
2512 CMUTIL_Map *map);
2513
2526 void (*PrintTo)(
2527 const CMUTIL_Map *map, CMUTIL_String *out, const char*(*to_strcb)(void*));
2528
2540 void *(*GetAt)(
2541 const CMUTIL_Map *map, uint32_t index);
2542
2554 void *(*RemoveAt)(
2555 CMUTIL_Map *map, uint32_t index);
2556};
2557
2561#define CMUTIL_MAP_DEFAULT 256
2562
2566#define CMUTIL_MapCreate() CMUTIL_MapCreateEx(\
2567 CMUTIL_MAP_DEFAULT, CMFalse, NULL, 0.75f)
2568
2579 uint32_t bucketsize, CMBool isucase, CMFreeCB freecb,
2580 float load_factor);
2581
2582
2586typedef struct CMUTIL_List CMUTIL_List;
2588
2598 void (*AddFront)(CMUTIL_List *list, void *data);
2599
2609 void (*AddTail)(CMUTIL_List *list, void *data);
2610
2620 void *(*GetFront)(const CMUTIL_List *list);
2621
2631 void *(*GetTail)(const CMUTIL_List *list);
2632
2642 void *(*RemoveFront)(CMUTIL_List *list);
2643
2653 void *(*RemoveTail)(CMUTIL_List *list);
2654
2665 void *(*Remove)(CMUTIL_List *list, void *data);
2666
2675 size_t (*GetSize)(const CMUTIL_List *list);
2676
2686 CMUTIL_Iterator *(*Iterator)(const CMUTIL_List *list);
2687
2697 void (*Destroy)(CMUTIL_List *list);
2698
2708 void (*MoveAll)(CMUTIL_List *dst, CMUTIL_List *src);
2709};
2710
2718#define CMUTIL_ListCreate() CMUTIL_ListCreateEx(NULL)
2719
2731
2755
2756
2760typedef struct CMUTIL_XmlNode CMUTIL_XmlNode;
2770 CMUTIL_StringArray *(*GetAttributeNames)(const CMUTIL_XmlNode *node);
2771
2781 CMUTIL_String *(*GetAttribute)(
2782 const CMUTIL_XmlNode *node, const char *key);
2783
2792 CMUTIL_XmlNode *node, const char *key, const char *value);
2793
2800 size_t (*ChildCount)(const CMUTIL_XmlNode *node);
2801
2811
2823 CMUTIL_XmlNode *(*ChildAt)(const CMUTIL_XmlNode *node, uint32_t index);
2824
2834 CMUTIL_XmlNode *(*GetParent)(const CMUTIL_XmlNode *node);
2835
2845 const char *(*GetName)(const CMUTIL_XmlNode *node);
2846
2853 void (*SetName)(CMUTIL_XmlNode *node, const char *name);
2854
2864
2874 CMUTIL_String *(*ToDocument)(
2875 const CMUTIL_XmlNode *node, CMBool beutify);
2876
2888 CMUTIL_XmlNode *node, void *udata, void(*freef)(void*));
2889
2896 void *(*GetUserData)(const CMUTIL_XmlNode *node);
2897
2903 void (*Destroy)(CMUTIL_XmlNode *node);
2904};
2905
2916
2928 const char *xmlstr, size_t len);
2929
2939CMUTIL_API CMUTIL_XmlNode *CMUTIL_XmlParseFile(const char *fpath);
2940
2952 CMXmlNodeKind type, const char *tagname);
2953
2966 CMXmlNodeKind type, const char *tagname, size_t len);
2967
2982typedef struct CMUTIL_CSConv CMUTIL_CSConv;
2996 CMUTIL_String *(*Forward)(
2997 const CMUTIL_CSConv *conv, CMUTIL_String *instr);
2998
3011 CMUTIL_String *(*Backward)(
3012 const CMUTIL_CSConv *conv, CMUTIL_String *instr);
3013
3019 void (*Destroy)(CMUTIL_CSConv *conv);
3020};
3021
3031 const char *fromcs, const char *tocs);
3032
3046typedef struct CMUTIL_TimerTask CMUTIL_TimerTask;
3060 void (*Cancel)(CMUTIL_TimerTask *task);
3061};
3062
3066typedef struct CMUTIL_Timer CMUTIL_Timer;
3077 CMUTIL_TimerTask *(*ScheduleAtTime)(
3078 CMUTIL_Timer *timer, struct timeval *attime,
3079 CMProcCB proc, void *param);
3080
3090 CMUTIL_TimerTask *(*ScheduleDelay)(
3091 CMUTIL_Timer *timer, long delay,
3092 CMProcCB proc, void *param);
3093
3106 CMUTIL_TimerTask *(*ScheduleAtRepeat)(
3107 CMUTIL_Timer *timer, struct timeval *first, long period,
3108 CMBool elapse_skip, CMProcCB proc, void *param);
3109
3122 CMUTIL_TimerTask *(*ScheduleDelayRepeat)(
3123 CMUTIL_Timer *timer, long delay, long period,
3124 CMBool elapse_skip, CMProcCB proc, void *param);
3125
3134 void (*Purge)(CMUTIL_Timer *timer);
3135
3145 void (*Destroy)(CMUTIL_Timer *timer);
3146};
3147
3151#define CMUTIL_TIMER_PRECISION 1
3152
3156#define CMUTIL_TIMER_THREAD 2
3157
3167#define CMUTIL_TimerCreate() \
3168 CMUTIL_TimerCreateEx(CMUTIL_TIMER_PRECISION, CMUTIL_TIMER_THREAD)
3169
3178CMUTIL_API CMUTIL_Timer *CMUTIL_TimerCreateEx(long precision, int threads);
3179
3193typedef struct CMUTIL_Pool CMUTIL_Pool;
3209 void *(*CheckOut)(CMUTIL_Pool *pool, long millisec);
3210
3220 void (*Release)(CMUTIL_Pool *pool, void *resource);
3221
3231 void (*AddResource)(CMUTIL_Pool *pool, void *resource);
3232
3242 void (*Destroy)(CMUTIL_Pool *pool);
3243};
3244
3248typedef void* (*CMPoolItemCreateCB)(void *udata);
3249
3253typedef void (*CMPoolItemFreeCB)(void *resource, void *udata);
3254
3258typedef CMBool (*CMPoolItemTestCB)(void *resource, void *udata);
3259
3284 int initcnt,
3285 int maxcnt,
3286 CMPoolItemCreateCB createproc,
3287 CMPoolItemFreeCB destroyproc,
3288 CMPoolItemTestCB testproc,
3289 long pinginterval,
3290 CMBool testonborrow,
3291 void *udata,
3292 CMUTIL_Timer *timer);
3293
3308typedef struct CMUTIL_Library CMUTIL_Library;
3310
3323 void *(*GetProcedure)(
3324 const CMUTIL_Library *lib,
3325 const char *proc_name);
3326
3337 void (*Destroy)(
3338 CMUTIL_Library *lib);
3339};
3340
3353CMUTIL_API CMUTIL_Library *CMUTIL_LibraryCreate(const char *path);
3354
3368typedef struct CMUTIL_FileList CMUTIL_FileList;
3369
3373typedef struct CMUTIL_File CMUTIL_File;
3381 size_t (*Count)(
3382 const CMUTIL_FileList *flist);
3383
3392 CMUTIL_File *(*GetAt)(
3393 const CMUTIL_FileList *flist,
3394 uint32_t index);
3395
3401 void (*Destroy)(
3402 CMUTIL_FileList *flist);
3403};
3404
3416
3433 ssize_t (*Read)(
3434 const CMUTIL_FileStream *fs,
3435 CMUTIL_String *buffer,
3436 size_t size);
3437
3450 ssize_t (*Write)(
3451 const CMUTIL_FileStream *fs,
3452 const CMUTIL_String *buffer,
3453 size_t offset,
3454 size_t size);
3455
3461 void (*Close)(
3462 CMUTIL_FileStream *fs);
3463};
3464
3473 CMUTIL_String *(*GetContents)(
3474 const CMUTIL_File *file);
3475
3483 const CMUTIL_File *file);
3484
3492 const CMUTIL_File *file);
3493
3501 const CMUTIL_File *file);
3502
3510 const CMUTIL_File *file);
3511
3518 long (*Length)(
3519 const CMUTIL_File *file);
3520
3528 const char *(*GetName)(
3529 const CMUTIL_File *file);
3530
3538 const char *(*GetFullPath)(
3539 const CMUTIL_File *file);
3540
3547 time_t (*ModifiedTime)(
3548 const CMUTIL_File *file);
3549
3558 CMUTIL_FileList *(*Children)(
3559 const CMUTIL_File *file);
3560
3678 const CMUTIL_File *file,
3679 const char *pattern, CMBool recursive);
3680
3689 CMUTIL_FileStream *(*CreateStream)(
3690 const CMUTIL_File *file,
3691 CMFileOpenMode mode);
3692
3698 void (*Destroy)(
3699 CMUTIL_File *file);
3700};
3701
3709CMUTIL_API CMUTIL_File *CMUTIL_FileCreate(const char *path);
3710
3721CMUTIL_API CMBool CMUTIL_PathCreate(const char *path, uint32_t mode);
3722
3735typedef struct CMUTIL_Config CMUTIL_Config;
3743 void (*Save)(const CMUTIL_Config *conf, const char *path);
3744
3753 const char *(*Get)(const CMUTIL_Config *conf, const char *key);
3754
3762 void (*Set)(CMUTIL_Config *conf, const char *key, const char *value);
3763
3771 long (*GetLong)(const CMUTIL_Config *conf, const char *key);
3772
3780 void (*SetLong)(CMUTIL_Config *conf, const char *key, long value);
3781
3789 double (*GetDouble)(const CMUTIL_Config *conf, const char *key);
3790
3798 void (*SetDouble)(CMUTIL_Config *conf, const char *key, double value);
3799
3807 CMBool (*GetBoolean)(const CMUTIL_Config *conf, const char *key);
3808
3816 void (*SetBoolean)(CMUTIL_Config *conf, const char *key, CMBool value);
3817
3823 void(*Destroy)(CMUTIL_Config *conf);
3824};
3825
3833
3841CMUTIL_API CMUTIL_Config *CMUTIL_ConfigLoad(const char *fconf);
3842
3851#define CMUTIL_LOG_CONFIG_DEFAULT "cmutil_log.jsonc"
3852
3875
3891
3896
3902
3914 const CMUTIL_ConfLogger *logger,
3915 CMUTIL_LogAppender *appender,
3916 CMLogLevel level);
3917};
3918
3922typedef struct CMUTIL_Logger CMUTIL_Logger;
3939 void(*LogEx)(
3940 CMUTIL_Logger *logger,
3941 CMLogLevel level,
3942 const char *file,
3943 int line,
3944 CMBool printStack,
3945 const char *fmt,
3946 ...);
3947
3960 CMUTIL_Logger *logger,
3961 CMLogLevel level);
3962};
3963
3973 const char *(*GetName)(
3974 const CMUTIL_LogAppender *appender);
3975
3985 void(*SetAsync)(
3986 CMUTIL_LogAppender *appender, size_t buffersz);
3987
4003 void(*Append)(
4004 CMUTIL_LogAppender *appender,
4005 CMUTIL_Logger *logger,
4006 CMLogLevel level,
4007 CMUTIL_StringArray *stack,
4008 const char *file,
4009 int line,
4010 CMUTIL_String *logmsg);
4011
4020 void(*Flush)(CMUTIL_LogAppender *appender);
4021
4030 void(*Destroy)(CMUTIL_LogAppender *appender);
4031};
4032
4043 const char *name,
4044 const char *pattern,
4045 CMBool use_stderr);
4046
4057 const char *name,
4058 const char *fpath,
4059 const char *pattern);
4060
4073 const char *name,
4074 const char *fpath,
4075 CMLogTerm logterm,
4076 const char *rollpath,
4077 const char *pattern);
4078
4090 const char *name,
4091 const char *accept_host,
4092 int listen_port,
4093 const char *pattern);
4094
4104CMUTIL_API void CMUTIL_LogFallback(CMLogLevel level,
4105 const char *file, int line, const char *fmt, ...);
4106
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; \
4125 } \
4126 return l___logger; \
4127 }
4128
4141 CMUTIL_Logger *logger, CMLogLevel level);
4142
4153#define CMLogIsEnabled(level) CMUTIL_LogIsEnabled(g__CMUTIL_GetLogger(),level)
4154
4166#define CMUTIL_Log__(level,stack,f,...) do { \
4167 CMUTIL_Logger *g__logger = g__CMUTIL_GetLogger(); \
4168 if (g__logger) \
4169 g__logger->LogEx(g__logger, CMLogLevel_##level,__FILE__,__LINE__, \
4170 CM##stack,f,##__VA_ARGS__); \
4171 else \
4172 CMUTIL_LogFallback(CMLogLevel_##level, __FILE__, __LINE__, \
4173 f, ##__VA_ARGS__); \
4174 } while(0)
4175
4187#define CMUTIL_Log2__(level,stack,f,...) do { \
4188 CMUTIL_Logger *g__logger = g__CMUTIL_GetLogger(); \
4189 if (g__logger) \
4190 g__logger->LogEx(g__logger, level,__FILE__,__LINE__, \
4191 CM##stack,f,##__VA_ARGS__); \
4192 else \
4193 CMUTIL_LogFallback(level, __FILE__, __LINE__, \
4194 f, ##__VA_ARGS__); \
4195 } while(0)
4196
4206#define CMLogTrace(f,...) CMUTIL_Log__(Trace,False,f,##__VA_ARGS__)
4207
4217#define CMLogTraceS(f,...) CMUTIL_Log__(Trace,True ,f,##__VA_ARGS__)
4218
4228#define CMLogDebug(f,...) CMUTIL_Log__(Debug,False,f,##__VA_ARGS__)
4229
4239#define CMLogDebugS(f,...) CMUTIL_Log__(Debug,True ,f,##__VA_ARGS__)
4240
4250#define CMLogInfo(f,...) CMUTIL_Log__(Info ,False,f,##__VA_ARGS__)
4251
4261#define CMLogInfoS(f,...) CMUTIL_Log__(Info ,True ,f,##__VA_ARGS__)
4262
4272#define CMLogWarn(f,...) CMUTIL_Log__(Warn ,False,f,##__VA_ARGS__)
4273
4283#define CMLogWarnS(f,...) CMUTIL_Log__(Warn ,True ,f,##__VA_ARGS__)
4284
4294#define CMLogError(f,...) CMUTIL_Log__(Error,False,f,##__VA_ARGS__)
4295
4305#define CMLogErrorS(f,...) CMUTIL_Log__(Error,True ,f,##__VA_ARGS__)
4306
4316#define CMLogFatal(f,...) CMUTIL_Log__(Fatal,False,f,##__VA_ARGS__)
4317
4327#define CMLogFatalS(f,...) CMUTIL_Log__(Fatal,True ,f,##__VA_ARGS__)
4328
4339#define CMLog(l,f,...) CMUTIL_Log2__(l,False,f,##__VA_ARGS__)
4340
4351#define CMLogS(l,f,...) CMUTIL_Log2__(l,True ,f,##__VA_ARGS__)
4352
4356typedef struct CMUTIL_LogSystem CMUTIL_LogSystem;
4358
4368 const CMUTIL_LogSystem *logsys, CMUTIL_LogAppender *appender);
4383 CMUTIL_ConfLogger *(*CreateLogger)(
4384 const CMUTIL_LogSystem *logsys,
4385 const char *name,
4386 CMLogLevel level,
4387 CMBool additivity);
4388
4398 CMUTIL_Logger *(*GetLogger)(
4399 const CMUTIL_LogSystem *logsys, const char *name);
4400
4409 void(*Destroy)(CMUTIL_LogSystem *logsys);
4410
4424};
4425
4433
4450 const char *jsonfile);
4451
4459
4472
4487
4499 const CMUTIL_StackWalker *walker, int skipdepth);
4500
4512 const CMUTIL_StackWalker *walker,
4513 CMUTIL_String *outbuf, int skipdepth);
4514
4524};
4525
4533
4569
4573typedef struct sockaddr_storage CMUTIL_SocketAddr;
4574
4587 const CMUTIL_SocketAddr *saddr, char *hostbuf, int *port);
4588
4598 CMUTIL_SocketAddr *saddr, const char *host, int port);
4599
4603typedef struct CMUTIL_Socket CMUTIL_Socket;
4605
4619 const CMUTIL_Socket *socket,
4620 CMUTIL_ByteBuffer *buffer,
4621 uint32_t size, long timeout);
4622
4636 const CMUTIL_Socket *socket,
4637 const void *data,
4638 uint32_t size, long timeout);
4639
4655 const CMUTIL_Socket *socket, const void *data,
4656 uint32_t offset, uint32_t length, long timeout);
4657
4669 const CMUTIL_Socket *socket, long timeout);
4670
4682 const CMUTIL_Socket *socket, long timeout);
4683
4695 CMUTIL_Socket *(*ReadSocket)(
4696 const CMUTIL_Socket *socket,
4697 long timeout, CMSocketResult *rval);
4698
4712 const CMUTIL_Socket *socket,
4713 CMUTIL_Socket *tobesent, pid_t pid, long timeout);
4714
4726 const CMUTIL_Socket *socket, CMUTIL_SocketAddr *addr);
4727
4735 void (*Close)(
4736 CMUTIL_Socket *socket);
4737
4747 SOCKET (*GetRawSocket)(
4748 const CMUTIL_Socket *socket);
4749
4759 int (*ReadByte)(
4760 const CMUTIL_Socket *socket, long timeout);
4761
4773 const CMUTIL_Socket *socket, uint8_t c, long timeout);
4774
4785 void (*SetSilent)(
4786 CMUTIL_Socket *socket, CMBool silent);
4787};
4788
4799 const char *host, int port, long timeout);
4800
4810 const CMUTIL_SocketAddr *saddr, long timeout);
4811
4824 const char *ipc_path, long timeout);
4825
4840 const char *cert, const char *key, const char *ca,
4841 const char *servername,
4842 const char *host, int port, long timeout);
4843
4857 const char *cert, const char *key, const char *ca,
4858 const char *servername,
4859 const CMUTIL_SocketAddr *saddr, long timeout);
4860
4866
4879 const CMUTIL_ServerSocket *server,
4880 CMUTIL_Socket **res,
4881 long timeout);
4882
4890 void (*Close)(CMUTIL_ServerSocket *server);
4891
4901 void (*SetSilent)(
4902 CMUTIL_ServerSocket *socket, CMBool silent);
4903
4904};
4905
4918 const char *host, int port, int qcnt, CMBool silent);
4919
4934 const char *ipc_path, int qcnt, CMBool silent);
4935
4949 const char *cert, const char *key, const char *ca,
4950 const char *host, int port, int qcnt);
4951
4960 CMUTIL_Socket **s1, CMUTIL_Socket **s2);
4961
4975 CMUTIL_DGramSocket *dsock,
4976 const CMUTIL_SocketAddr *saddr);
4977
4986 CMUTIL_DGramSocket *dsock,
4987 const CMUTIL_SocketAddr *saddr);
4988
4996 CMUTIL_DGramSocket *dsock);
4997
5003 void (*Disconnect)(
5004 CMUTIL_DGramSocket *dsock);
5005
5014 CMUTIL_DGramSocket *dsock,
5015 CMUTIL_SocketAddr *saddr);
5016
5025 CMUTIL_DGramSocket *dsock,
5026 CMUTIL_SocketAddr *saddr);
5027
5039 CMUTIL_DGramSocket *dsock,
5040 CMUTIL_ByteBuffer *buf,
5041 long timeout);
5042
5054 CMUTIL_DGramSocket *dsock,
5055 CMUTIL_ByteBuffer *buf,
5056 long timeout);
5057
5068 CMUTIL_DGramSocket *dsock,
5069 CMUTIL_ByteBuffer *buf,
5070 CMUTIL_SocketAddr *saddr,
5071 long timeout);
5072
5083 CMUTIL_DGramSocket *dsock,
5084 CMUTIL_ByteBuffer *buf,
5085 CMUTIL_SocketAddr *saddr,
5086 long timeout);
5087
5095 void (*Close)(
5096 CMUTIL_DGramSocket *dsock);
5097};
5098
5105
5113 CMUTIL_SocketAddr *addr);
5114
5115
5130
5147 CMUTIL_HttpClient *client,
5148 CMBool verify_host,
5149 CMBool verify_peer);
5150
5166 CMUTIL_HttpClient *client,
5167 const char *certfile,
5168 const char *keyfile,
5169 const char *cafile );
5170
5181 CMUTIL_HttpClient *client,
5182 CMBool keepalive);
5183
5209 CMUTIL_HttpClient *client,
5210 const char *method,
5211 CMUTIL_Map *headers,
5212 const char *uri,
5213 CMUTIL_ByteBuffer *body,
5214 int *status,
5215 long timeout);
5216
5228 CMUTIL_HttpClient *client,
5229 CMUTIL_Map *headers,
5230 const char *uri,
5231 int *status,
5232 long timeout);
5233
5246 CMUTIL_HttpClient *client,
5247 CMUTIL_Map *headers,
5248 const char *uri,
5249 CMUTIL_ByteBuffer *body,
5250 int *status,
5251 long timeout);
5252
5261 void (*Destroy)(
5262 CMUTIL_HttpClient *client);
5263};
5264
5274CMUTIL_API CMUTIL_HttpClient *CMUTIL_HttpClientCreate(const char *urlprefix);
5275
5296
5300typedef struct CMUTIL_Json CMUTIL_Json;
5313 void (*ToString)(
5314 const CMUTIL_Json *json, CMUTIL_String *buf, CMBool pretty);
5315
5326 const CMUTIL_Json *json);
5327
5336 CMUTIL_Json *(*Clone)(
5337 const CMUTIL_Json *json);
5338
5347 void (*Destroy)(CMUTIL_Json *json);
5348};
5349
5358#define CMUTIL_JsonDestroy(a) CMCall((CMUTIL_Json*)(a), Destroy)
5359
5375
5381typedef struct CMUTIL_JsonValue CMUTIL_JsonValue;
5385
5397 const CMUTIL_JsonValue *jval);
5398
5407 int64_t (*GetLong)(
5408 const CMUTIL_JsonValue *jval);
5409
5418 double (*GetDouble)(
5419 const CMUTIL_JsonValue *jval);
5420
5429 const CMUTIL_String *(*GetString)(
5430 const CMUTIL_JsonValue *jval);
5431
5440 const char *(*GetCString)(
5441 const CMUTIL_JsonValue *jval);
5442
5452 const CMUTIL_JsonValue *jval);
5453
5462 void (*SetLong)(
5463 CMUTIL_JsonValue *jval, int64_t inval);
5464
5473 void (*SetDouble)(
5474 CMUTIL_JsonValue *jval, double inval);
5475
5484 void (*SetString)(
5485 CMUTIL_JsonValue *jval, const char *inval);
5486
5495 void (*SetBoolean)(
5496 CMUTIL_JsonValue *jval, CMBool inval);
5497
5505 void (*SetNull)(
5506 CMUTIL_JsonValue *jval);
5507};
5508
5515
5525
5536 const CMUTIL_JsonObject *jobj);
5537
5549 const CMUTIL_JsonObject *jobj, const char *key);
5550
5561 int64_t (*GetLong)(
5562 const CMUTIL_JsonObject *jobj, const char *key);
5563
5574 double (*GetDouble)(
5575 const CMUTIL_JsonObject *jobj, const char *key);
5576
5587 const CMUTIL_String *(*GetString)(
5588 const CMUTIL_JsonObject *jobj, const char *key);
5589
5600 const char *(*GetCString)(
5601 const CMUTIL_JsonObject *jobj, const char *key);
5602
5614 const CMUTIL_JsonObject *jobj, const char *key);
5615
5626 void (*Put)(
5627 CMUTIL_JsonObject *jobj, const char *key, CMUTIL_Json *json);
5628
5639 void (*PutLong)(
5640 CMUTIL_JsonObject *jobj, const char *key, int64_t value);
5641
5652 void (*PutDouble)(
5653 CMUTIL_JsonObject *jobj, const char *key, double value);
5654
5665 void (*PutString)(
5666 CMUTIL_JsonObject *jobj, const char *key, const char *value);
5667
5678 void (*PutBoolean)(
5679 CMUTIL_JsonObject *jobj, const char *key, CMBool value);
5680
5690 void (*PutNull)(
5691 CMUTIL_JsonObject *jobj, const char *key);
5692
5704 CMUTIL_Json *(*Remove)(
5705 CMUTIL_JsonObject *jobj, const char *key);
5706
5716 void (*Delete)(
5717 CMUTIL_JsonObject *jobj, const char *key);
5718};
5719
5728
5734typedef struct CMUTIL_JsonArray CMUTIL_JsonArray;
5738
5747 size_t (*GetSize)(
5748 const CMUTIL_JsonArray *jarr);
5749
5761 const CMUTIL_JsonArray *jarr, uint32_t index);
5762
5773 int64_t (*GetLong)(
5774 const CMUTIL_JsonArray *jarr, uint32_t index);
5775
5786 double (*GetDouble)(
5787 const CMUTIL_JsonArray *jarr, uint32_t index);
5788
5800 const CMUTIL_String *(*GetString)(
5801 const CMUTIL_JsonArray *jarr, uint32_t index);
5802
5814 const char *(*GetCString)(
5815 const CMUTIL_JsonArray *jarr, uint32_t index);
5816
5828 const CMUTIL_JsonArray *jarr, uint32_t index);
5829
5839 void (*Add)(
5840 CMUTIL_JsonArray *jarr, CMUTIL_Json *json);
5841
5850 void (*AddLong)(
5851 CMUTIL_JsonArray *jarr, int64_t value);
5852
5861 void (*AddDouble)(
5862 CMUTIL_JsonArray *jarr, double value);
5863
5873 void (*AddString)(
5874 CMUTIL_JsonArray *jarr, const char *value);
5875
5884 void (*AddBoolean)(
5885 CMUTIL_JsonArray *jarr, CMBool value);
5886
5894 void (*AddNull)(
5895 CMUTIL_JsonArray *jarr);
5896
5907 CMUTIL_Json *(*Remove)(
5908 CMUTIL_JsonArray *jarr, uint32_t index);
5909
5919 void (*Delete)(
5920 CMUTIL_JsonArray *jarr, uint32_t index);
5921};
5922
5929
5937
5945
5989
6002 CMUTIL_RestClient *client,
6003 CMUTIL_Map *headers,
6004 const char *uri);
6005
6016 CMUTIL_Json *(*Post)(
6017 CMUTIL_RestClient *client,
6018 CMUTIL_Map *headers,
6019 const char *uri,
6020 CMUTIL_Json *data);
6021
6032 CMUTIL_RestClient *client,
6033 CMUTIL_Map *headers,
6034 const char *uri,
6035 CMUTIL_Json *data);
6036
6044 void (*Delete)(
6045 CMUTIL_RestClient *client,
6046 CMUTIL_Map *headers,
6047 const char *uri);
6048
6058 void (*SetTimeout)(
6059 CMUTIL_RestClient *client,
6060 long timeout);
6061
6069 const CMUTIL_RestClient *client);
6070};
6071
6075#define CMUTIL_REST_DEFAULT_TIMEOUT 30000L
6076
6085CMUTIL_API CMUTIL_RestClient *CMUTIL_RestClientCreate(const char *urlprefix);
6086
6131
6135typedef struct CMUTIL_Process CMUTIL_Process;
6147
6159 pid_t (*GetPid)(CMUTIL_Process *proc);
6160
6172 const char *(*GetCommand)(CMUTIL_Process *proc);
6173
6186 const char *(*GetWorkDir)(CMUTIL_Process *proc);
6187
6199 const CMUTIL_StringArray *(*GetArgs)(CMUTIL_Process *proc);
6200
6211 const CMUTIL_Map *(*GetEnv)(CMUTIL_Process *proc);
6212
6222 void (*Suspend)(CMUTIL_Process *proc);
6223
6233 void (*Resume)(CMUTIL_Process *proc);
6234
6252
6265 ssize_t (*Write)(CMUTIL_Process *proc, const void *buf, size_t count);
6266
6279 ssize_t (*Read)(CMUTIL_Process *proc, CMUTIL_ByteBuffer *buf, size_t count);
6280
6292 int (*Wait)(CMUTIL_Process *proc, long millis);
6293
6302 void (*Kill)(CMUTIL_Process *proc);
6303
6313 void (*Destroy)(CMUTIL_Process *proc);
6314
6327 ssize_t (*ReadErr)(CMUTIL_Process *proc, CMUTIL_ByteBuffer *buf, size_t count);
6328};
6329
6345 const char *cwd,
6346 CMUTIL_Map *env,
6347 const char *command,
6348 ...);
6349
6367#define CMUTIL_ProcessCreate(cwd, env, command, ...) \
6368 CMUTIL_ProcessCreateEx(cwd, env, command, ##__VA_ARGS__, NULL)
6369
6370
6390 CMUTIL_String *(*Encrypt)(
6391 CMUTIL_BlockCrypto *crypto,
6392 CMUTIL_String *plain,
6393 const uint8_t *key, const uint8_t *iv);
6403 CMUTIL_String *(*Decrypt)(
6404 CMUTIL_BlockCrypto *crypto,
6405 CMUTIL_String *encrypted,
6406 const uint8_t *key, const uint8_t *iv);
6411 void (*Destroy)(
6412 CMUTIL_BlockCrypto *crypto);
6413};
6414
6424 const char *algo, const char *mode, const char *padding,
6425 int key_bits);
6426
6427
6431typedef struct CMUTIL_RSAKey CMUTIL_RSAKey;
6432
6440
6455 CMUTIL_String *(*GetEncoded)(CMUTIL_RSAKey *key);
6460 void (*Destroy)(CMUTIL_RSAKey *key);
6461};
6462
6470 const char *pem, const uint8_t *passphrase);
6471
6478 const char *pem);
6479
6487 const char *file_path, const uint8_t *passphrase);
6488
6495 const char *file_path);
6496
6500typedef struct CMUTIL_RSACrypto CMUTIL_RSACrypto;
6509 CMUTIL_String *(*EncryptWithPublicKey)(
6510 CMUTIL_RSACrypto *crypto,
6511 CMUTIL_String *plain,
6512 CMUTIL_PublicKey *pubKey);
6520 CMUTIL_String *(*EncryptWithPrivateKey)(
6521 CMUTIL_RSACrypto *crypto,
6522 CMUTIL_String *plain,
6523 CMUTIL_PrivateKey *privKey);
6531 CMUTIL_String *(*DecryptWithPublicKey)(
6532 CMUTIL_RSACrypto *crypto,
6533 CMUTIL_String *encrypted,
6534 CMUTIL_PublicKey *pubKey);
6542 CMUTIL_String *(*DecryptWithPrivateKey)(
6543 CMUTIL_RSACrypto *crypto,
6544 CMUTIL_String *encrypted,
6545 CMUTIL_PrivateKey *privKey);
6554 CMUTIL_RSACrypto *crypto,
6555 CMUTIL_String *plain,
6556 CMUTIL_PrivateKey *privKey);
6566 CMUTIL_RSACrypto *crypto,
6567 CMUTIL_String *plain,
6568 CMUTIL_String *signature,
6569 CMUTIL_PublicKey *pubKey);
6574 void (*Destroy)(
6575 CMUTIL_RSACrypto *crypto);
6576};
6577
6583
6589CMUTIL_API void CMUTIL_CryptoRandom(uint8_t *buf, size_t len);
6590
6601CMUTIL_API CMUTIL_String *CMUTIL_CryptoToBase64(const uint8_t *data, size_t len);
6602
6608CMUTIL_API CMUTIL_String *CMUTIL_CryptoFromBase64(const char *base64);
6609
6610#ifdef __cplusplus
6611}
6612#endif
6613
6614#endif // LIBCMUTILS_H__
6615
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