|
| #define | INT64_MAX i64(0x7FFFFFFFFFFFFFFF) |
| |
| #define | CMUTIL_APPEND(a, b) a ## b |
| |
| #define | CMUTIL_UNUSED(a, ...) CMUTIL_UnusedP((void*)(int64_t)(a), ## __VA_ARGS__) |
| |
| #define | CMUTIL_CALL_NESTED 0 |
| | Whether CMCall may be nested inside another CMCall's arguments.
|
| |
| #define | CMUTIL_CALL_SINGLE_EVAL 0 |
| | Whether CMCall evaluates its receiver once instead of twice.
|
| |
| #define | CMUTIL_CAT2__(a, b) a ## b |
| |
| #define | CMUTIL_CALL__(a, b, ...) (a)->b((a), ## __VA_ARGS__) |
| |
| #define | CMCall CMUTIL_CALL__ |
| | Method caller for this library.
|
| |
|
#define | CMAlloc CMUTIL_GetMem()->Alloc |
| | Allocate new memory. Use this macro instead of malloc for debugging memory operations.
|
| |
|
#define | CMCalloc CMUTIL_GetMem()->Calloc |
| | Allocate new memory with zero filled. Use this macro instead of calloc.
|
| |
|
#define | CMRealloc CMUTIL_GetMem()->Realloc |
| | Reallocate memory with the given size preserving previous data.
|
| |
|
#define | CMStrdup CMUTIL_GetMem()->Strdup |
| | String duplication.
|
| |
|
#define | CMFree CMUTIL_GetMem()->Free |
| | Deallocate memory which allocated with CMAlloc, CMCalloc, CMRealloc and CMStrdup.
|
| |
| #define | CMSync(a, ...) |
| | Synchronized block macro.
|
| |
| #define | CMUTIL_ARRAY_DEFAULT 10 |
| |
| #define | CMUTIL_ArrayCreate() CMUTIL_ArrayCreateEx(CMUTIL_ARRAY_DEFAULT, NULL, NULL) |
| | Creates an unsorted dynamic array.
|
| |
| #define | CMUTIL_StringCreate() CMUTIL_StringCreateEx(CMUTIL_STRING_DEFAULT, NULL) |
| | Creates a string object.
|
| |
| #define | CMUTIL_STRINGARRAY_DEFAULT 32 |
| |
| #define | CMUTIL_StringArrayCreate() CMUTIL_StringArrayCreateEx(CMUTIL_STRINGARRAY_DEFAULT) |
| |
| #define | CMUTIL_StringArrayCreateWith(s, ...) CMUTIL_StringArrayCreateWithEx(s, __VA_ARGS__, NULL) |
| | Create a new CMUTIL_StringArray object with initial elements.
|
| |
| #define | CMUTIL_BYTEBUFFER_DEFAULT 32 |
| |
| #define | CMUTIL_ByteBufferCreate() CMUTIL_ByteBufferCreateEx(CMUTIL_BYTEBUFFER_DEFAULT) |
| |
| #define | CMUTIL_MAP_DEFAULT 256 |
| |
| #define | CMUTIL_MapCreate() |
| |
| #define | CMUTIL_ListCreate() CMUTIL_ListCreateEx(NULL) |
| | Create a new list with default settings.
|
| |
| #define | CMUTIL_TIMER_PRECISION 1 |
| |
| #define | CMUTIL_TIMER_THREAD 2 |
| |
| #define | CMUTIL_TimerCreate() CMUTIL_TimerCreateEx(CMUTIL_TIMER_PRECISION, CMUTIL_TIMER_THREAD) |
| | Create a timer object with default settings.
|
| |
| #define | CMUTIL_LOG_CONFIG_DEFAULT "cmutil_log.jsonc" |
| |
| #define | CMUTIL_LogDefine(name) |
| | Define a logger for the current source file.
|
| |
| #define | CMLogIsEnabled(level) CMUTIL_LogIsEnabled(g__CMUTIL_GetLogger(),level) |
| | Macro to check if logging is enabled for the specified log level.
|
| |
| #define | CMUTIL_Log__(level, stack, f, ...) |
| | Log a message with the specified log level and stack trace option.
|
| |
| #define | CMUTIL_Log2__(level, stack, f, ...) |
| | Log a message with the specified log level and stack trace option.
|
| |
| #define | CMLogTrace(f, ...) CMUTIL_Log__(Trace,False,f,##__VA_ARGS__) |
| | Log a message at the Trace level.
|
| |
| #define | CMLogTraceS(f, ...) CMUTIL_Log__(Trace,True ,f,##__VA_ARGS__) |
| | Log a message at the Trace level with stack trace.
|
| |
| #define | CMLogDebug(f, ...) CMUTIL_Log__(Debug,False,f,##__VA_ARGS__) |
| | Log a message at the Debug level.
|
| |
| #define | CMLogDebugS(f, ...) CMUTIL_Log__(Debug,True ,f,##__VA_ARGS__) |
| | Log a message at the Debug level with stack trace.
|
| |
| #define | CMLogInfo(f, ...) CMUTIL_Log__(Info ,False,f,##__VA_ARGS__) |
| | Log a message at the Info level.
|
| |
| #define | CMLogInfoS(f, ...) CMUTIL_Log__(Info ,True ,f,##__VA_ARGS__) |
| | Log a message at the Info level with stack trace.
|
| |
| #define | CMLogWarn(f, ...) CMUTIL_Log__(Warn ,False,f,##__VA_ARGS__) |
| | Log a message at the Warn level.
|
| |
| #define | CMLogWarnS(f, ...) CMUTIL_Log__(Warn ,True ,f,##__VA_ARGS__) |
| | Log a message at the Warn level with stack trace.
|
| |
| #define | CMLogError(f, ...) CMUTIL_Log__(Error,False,f,##__VA_ARGS__) |
| | Log a message at the Error level.
|
| |
| #define | CMLogErrorS(f, ...) CMUTIL_Log__(Error,True ,f,##__VA_ARGS__) |
| | Log a message at the Error level with stack trace.
|
| |
| #define | CMLogFatal(f, ...) CMUTIL_Log__(Fatal,False,f,##__VA_ARGS__) |
| | Log a message at the Fatal level.
|
| |
| #define | CMLogFatalS(f, ...) CMUTIL_Log__(Fatal,True ,f,##__VA_ARGS__) |
| | Log a message at the Fatal level with stack trace.
|
| |
| #define | CMLog(l, f, ...) CMUTIL_Log2__(l,False,f,##__VA_ARGS__) |
| | Log a message with the specified log level.
|
| |
| #define | CMLogS(l, f, ...) CMUTIL_Log2__(l,True ,f,##__VA_ARGS__) |
| | Log a message with the specified log level and stack trace.
|
| |
| #define | CMUTIL_JsonDestroy(a) CMCall((CMUTIL_Json*)(a), Destroy) |
| | Destroy the JSON object.
|
| |
| #define | CMUTIL_REST_DEFAULT_TIMEOUT 30000L |
| |
| #define | CMUTIL_ProcessCreate(cwd, env, command, ...) CMUTIL_ProcessCreateEx(cwd, env, command, ##__VA_ARGS__, NULL) |
| | Creates a new process with the specified command and arguments.
|
| |
|
| void | CMUTIL_UnusedP (void *a,...) |
| | Consumes its arguments so the compiler stops calling them unused.
|
| |
| const char * | CMUTIL_GetLibVersion (void) |
| | Get a version string of this library.
|
| |
| void | CMUTIL_Init (CMMemOper memoper) |
| | Initialize this library. This function must be called before calling any function in this library.
|
| |
| CMBool | CMUTIL_Clear (void) |
| | Clear allocated resource for this library.
|
| |
| CMUTIL_Mem * | CMUTIL_GetMem (void) |
| | Global memory operator structure. This object will be initialized with appropriate memory operators in CMUTIL_Init.
|
| |
| CMUTIL_Cond * | CMUTIL_CondCreate (CMBool manual_reset) |
| | Creates a condition object.
|
| |
| CMUTIL_Mutex * | CMUTIL_MutexCreate (void) |
| | Creates a mutex 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_Thread * | CMUTIL_ThreadSelf (void) |
| | Get the current thread context.
|
| |
| uint64_t | CMUTIL_ThreadSystemSelfId (void) |
| | Get system dependent thread id.
|
| |
| CMUTIL_ThreadPool * | CMUTIL_ThreadPoolCreate (int pool_size, const char *name) |
| | Creates a new threadpool object.
|
| |
| CMUTIL_Semaphore * | CMUTIL_SemaphoreCreate (int initcnt) |
| | Creates a semaphore object.
|
| |
| CMUTIL_RWLock * | CMUTIL_RWLockCreate (void) |
| | Create a read-write lock object.
|
| |
| CMUTIL_Array * | CMUTIL_ArrayCreateEx (size_t initcapacity, CMCompareCB comparator, CMFreeCB freecb) |
| | Creates a dynamic array with capacity and optional comparator and free callback.
|
| |
| 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_StringArrayCreateWithEx (const char *str,...) |
| | Create a new CMUTIL_StringArray object with initial elements.
|
| |
| char * | CMUTIL_StrRTrim (char *inp) |
| | Trim the right side of a c-style string.
|
| |
| char * | CMUTIL_StrLTrim (char *inp) |
| | Trim the left side of a c-style string.
|
| |
| char * | CMUTIL_StrTrim (char *inp) |
| | Trim the both side of a c-style string.
|
| |
| const char * | CMUTIL_StrNextToken (char *dest, size_t buflen, const char *src, const char *delims) |
| | Get the next token from src.
|
| |
| const char * | CMUTIL_StrSkipSpaces (const char *src, const char *spaces) |
| | Skip leading spaces.
|
| |
| CMUTIL_StringArray * | CMUTIL_StringSplit (const char *haystack, const char *needle) |
| | Split the haystack string using the needle.
|
| |
| int | CMUTIL_StringHexToBytes (uint8_t *dest, const char *src, int len) |
| | Convert hex encoded string to bytes.
|
| |
| CMUTIL_ByteBuffer * | CMUTIL_ByteBufferCreateEx (size_t initcapacity) |
| | Creates CMUTIL_ByteBuffer object with initial capacity.
|
| |
| CMUTIL_Map * | CMUTIL_MapCreateEx (uint32_t bucketsize, CMBool isucase, CMFreeCB freecb, float load_factor) |
| | Create a new map with custom settings.
|
| |
| CMUTIL_List * | CMUTIL_ListCreateEx (CMFreeCB freecb) |
| | Create a new list with a custom free callback.
|
| |
| CMUTIL_XmlNode * | CMUTIL_XmlParse (CMUTIL_String *str) |
| | Parse an XML string into an XML node tree.
|
| |
| 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_XmlNodeCreate (CMXmlNodeKind type, const char *tagname) |
| | Create a new XML node with the specified type and tag name.
|
| |
| 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_CSConv * | CMUTIL_CSConvCreate (const char *fromcs, const char *tocs) |
| | Create a character set conversion object.
|
| |
| CMUTIL_Timer * | CMUTIL_TimerCreateEx (long precision, int threads) |
| | Create a timer object with custom settings.
|
| |
| 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.
|
| |
| CMUTIL_Library * | CMUTIL_LibraryCreate (const char *path) |
| | Create a dynamic library loader for the specified library path.
|
| |
| CMUTIL_File * | CMUTIL_FileCreate (const char *path) |
| | Create a file or directory object for the specified path.
|
| |
| CMBool | CMUTIL_PathCreate (const char *path, uint32_t mode) |
| | Create directories recursively for the specified path.
|
| |
| CMUTIL_Config * | CMUTIL_ConfigCreate (void) |
| | Create a new empty configuration object.
|
| |
| CMUTIL_Config * | CMUTIL_ConfigLoad (const char *fconf) |
| | Load a configuration from a file.
|
| |
| CMUTIL_LogAppender * | CMUTIL_LogConsoleAppenderCreate (const char *name, const char *pattern, CMBool use_stderr) |
| | Create a console log appender.
|
| |
| CMUTIL_LogAppender * | CMUTIL_LogFileAppenderCreate (const char *name, const char *fpath, const char *pattern) |
| | Create a file log appender.
|
| |
| CMUTIL_LogAppender * | CMUTIL_LogRollingFileAppenderCreate (const char *name, const char *fpath, CMLogTerm logterm, const char *rollpath, const char *pattern) |
| | Create a rolling file log appender.
|
| |
| CMUTIL_LogAppender * | CMUTIL_LogSocketAppenderCreate (const char *name, const char *accept_host, int listen_port, const char *pattern) |
| | Create a socket log appender.
|
| |
| void | CMUTIL_LogFallback (CMLogLevel level, const char *file, int line, const char *fmt,...) |
| | Fallback logging function when no logger is available.
|
| |
| CMBool | CMUTIL_LogIsEnabled (CMUTIL_Logger *logger, CMLogLevel level) |
| | Check if logging is enabled for the specified log level.
|
| |
| CMUTIL_LogSystem * | CMUTIL_LogSystemCreate (void) |
| | Create a new log system object.
|
| |
| CMUTIL_LogSystem * | CMUTIL_LogSystemConfigureFomJson (const char *jsonfile) |
| | Configure the log system from a JSON configuration file.
|
| |
| CMUTIL_LogSystem * | CMUTIL_LogSystemGet (void) |
| | Get the current global log system.
|
| |
| void | CMUTIL_LogSystemSet (CMUTIL_LogSystem *lsys) |
| | Set the global log system.
|
| |
| CMUTIL_StackWalker * | CMUTIL_StackWalkerCreate (void) |
| | Create a new stack walker object.
|
| |
| CMSocketResult | CMUTIL_SocketAddrGet (const CMUTIL_SocketAddr *saddr, char *hostbuf, int *port) |
| | Get the host and port from a socket address.
|
| |
| CMSocketResult | CMUTIL_SocketAddrSet (CMUTIL_SocketAddr *saddr, const char *host, int port) |
| | Set the host and port in 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_SocketConnectWithAddr (const CMUTIL_SocketAddr *saddr, long timeout) |
| | Create a new 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_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.
|
| |
| 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_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.
|
| |
| 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.
|
| |
| CMBool | CMUTIL_SocketPair (CMUTIL_Socket **s1, CMUTIL_Socket **s2) |
| | Create a pair of connected sockets.
|
| |
| CMUTIL_DGramSocket * | CMUTIL_DGramSocketCreate (void) |
| | Create a new datagram socket.
|
| |
| CMUTIL_DGramSocket * | CMUTIL_DGramSocketCreateBind (CMUTIL_SocketAddr *addr) |
| | Create a new datagram socket and bind it to the given address.
|
| |
| CMUTIL_HttpClient * | CMUTIL_HttpClientCreate (const char *urlprefix) |
| | Create an HTTP client for the given URL prefix.
|
| |
| CMUTIL_JsonValue * | CMUTIL_JsonValueCreate (void) |
| | Create a new JSON value object.
|
| |
| CMUTIL_JsonObject * | CMUTIL_JsonObjectCreate (void) |
| | Create a new JSON object.
|
| |
| CMUTIL_JsonArray * | CMUTIL_JsonArrayCreate (void) |
| | Create a new JSON array.
|
| |
| CMUTIL_Json * | CMUTIL_JsonParse (CMUTIL_String *jsonstr) |
| | Parse a JSON string into a JSON object.
|
| |
| CMUTIL_Json * | CMUTIL_XmlToJson (CMUTIL_XmlNode *node) |
| | Convert an XML node to a JSON object.
|
| |
| CMUTIL_RestClient * | CMUTIL_RestClientCreate (const char *urlprefix) |
| | Create a REST client for the given URL prefix.
|
| |
| CMUTIL_Process * | CMUTIL_ProcessCreateEx (const char *cwd, CMUTIL_Map *env, const char *command,...) |
| | Creates a new process with the specified command and arguments.
|
| |
| CMUTIL_BlockCrypto * | CMUTIL_BlockCryptoCreate (const char *algo, const char *mode, const char *padding, int key_bits) |
| | Creates a new block crypto object.
|
| |
| CMUTIL_PrivateKey * | CMUTIL_PrivateKeyCreateFromPEM (const char *pem, const uint8_t *passphrase) |
| | Creates a private key object from a PEM-formatted string.
|
| |
| CMUTIL_PublicKey * | CMUTIL_PublicKeyCreateFromPEM (const char *pem) |
| | Creates a public 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_PublicKey * | CMUTIL_PublicKeyCreateFromFile (const char *file_path) |
| | Creates a public key object from a PEM-formatted file.
|
| |
| CMUTIL_RSACrypto * | CMUTIL_RSACryptoCreate (void) |
| | Creates a new RSA crypto object.
|
| |
| void | CMUTIL_CryptoRandom (uint8_t *buf, size_t len) |
| | Generates cryptographically strong random bytes.
|
| |
| CMUTIL_String * | CMUTIL_CryptoToBase64 (const uint8_t *data, size_t len) |
| | Encodes data to Base64 string.
|
| |
| CMUTIL_String * | CMUTIL_CryptoFromBase64 (const char *base64) |
| | Decodes Base64-encoded data.
|
| |
The entire public API of libcmutils.
This is the only header to include. Everything the library offers - collections, strings, concurrency, files, sockets, JSON, XML, logging, crypto and child processes - is declared here and grouped by subject in the module list.
- Author
- libcmutils: Dennis Soungjin Park xcoma.nosp@m.rt@g.nosp@m.mail..nosp@m.com
-
fpattern: David R. Tribble david.nosp@m..tri.nosp@m.bble@.nosp@m.beas.nosp@m.ys.co.nosp@m.m