libcmutils 0.6.5
Multi-platform C99 utility library
Loading...
Searching...
No Matches
libcmutils.h File Reference

The entire public API of libcmutils. More...

#include <sys/time.h>
#include <unistd.h>
#include <netinet/in.h>
#include <stdarg.h>
#include <stdint.h>
#include <inttypes.h>
#include <sys/types.h>

Go to the source code of this file.

Data Structures

struct  CMUTIL_Mem
 
struct  CMUTIL_Cond
 Platform independent condition definition for concurrency control. More...
 
struct  CMUTIL_Mutex
 Platform independent mutex implementation. More...
 
struct  CMUTIL_Thread
 Platform independent thread object. More...
 
struct  CMUTIL_ThreadPool
 A threadpool object. More...
 
struct  CMUTIL_Semaphore
 Platform independent semaphore object. More...
 
struct  CMUTIL_RWLock
 Platform independent read/write lock object. More...
 
struct  CMUTIL_Iterator
 Iterator of collection members. More...
 
struct  CMUTIL_Array
 Dynamic array of any type element. More...
 
struct  CMUTIL_String
 Multifunctional string type. More...
 
struct  CMUTIL_StringArray
 Dynamic array of string objects. More...
 
struct  CMUTIL_ByteBuffer
 Manipulation of bytes. More...
 
struct  CMUTIL_MapPair
 Key-value pair for CMUTIL_Map. More...
 
struct  CMUTIL_Map
 Hashmap type with item order preserved. More...
 
struct  CMUTIL_List
 A doubly linked list type. More...
 
struct  CMUTIL_XmlNode
 XML node manipulation. More...
 
struct  CMUTIL_CSConv
 Character set conversion object. More...
 
struct  CMUTIL_TimerTask
 Timer task handle. More...
 
struct  CMUTIL_Timer
 Timer object for scheduling tasks. More...
 
struct  CMUTIL_Pool
 Resource pool object. More...
 
struct  CMUTIL_Library
 Dynamic library loader. More...
 
struct  CMUTIL_FileList
 A list of files in a directory. More...
 
struct  CMUTIL_FileStream
 File stream object for reading and writing files. More...
 
struct  CMUTIL_File
 A file or directory object. More...
 
struct  CMUTIL_Config
 Configuration management object. More...
 
struct  CMUTIL_ConfLogger
 Logger configuration object. More...
 
struct  CMUTIL_Logger
 Logger object. More...
 
struct  CMUTIL_LogAppender
 Log appender object. More...
 
struct  CMUTIL_LogSystem
 Log system object. More...
 
struct  CMUTIL_StackWalker
 Stack walker object. More...
 
struct  CMUTIL_Socket
 Socket object. More...
 
struct  CMUTIL_ServerSocket
 Server socket object. More...
 
struct  CMUTIL_DGramSocket
 Datagram socket object. More...
 
struct  CMUTIL_HttpClient
 An HTTP/HTTPS client built on the socket layer. More...
 
struct  CMUTIL_Json
 JSON base object. More...
 
struct  CMUTIL_JsonValue
 JSON value object. More...
 
struct  CMUTIL_JsonObject
 JSON object. More...
 
struct  CMUTIL_JsonArray
 JSON array type. More...
 
struct  CMUTIL_RestClient
 A JSON layer over CMUTIL_HttpClient. More...
 
struct  CMUTIL_Process
 structure for managing external processes. More...
 
struct  CMUTIL_BlockCrypto
 Block cipher encryption/decryption object. More...
 
struct  CMUTIL_RSAKey
 RSA key object (can be either a private or public key). More...
 
struct  CMUTIL_RSACrypto
 RSA encryption/decryption and signature object. More...
 

Macros

#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.
 

Typedefs

typedef int(* CMCompareCB) (const void *, const void *)
 Object comparison callback type.
 
typedef void(* CMFreeCB) (void *)
 Callback type for memory deallocation.
 
typedef void(* CMProcCB) (void *)
 Callback type for execution of some procedure.
 
typedef void *(* CMPoolItemCreateCB) (void *udata)
 Callback type for creating a pool item.
 
typedef void(* CMPoolItemFreeCB) (void *resource, void *udata)
 Callback type for freeing a pool item.
 
typedef CMBool(* CMPoolItemTestCB) (void *resource, void *udata)
 Callback type for testing a pool item.
 
typedef struct sockaddr_storage CMUTIL_SocketAddr
 Socket address object.
 
typedef CMUTIL_RSAKey CMUTIL_PrivateKey
 An RSA key that can decrypt and sign.
 
typedef CMUTIL_RSAKey CMUTIL_PublicKey
 An RSA key that can encrypt and verify.
 

Enumerations

enum  CMBool { CMTrue = 1 , CMFalse = 0 }
 Boolean definition for this library. More...
 
enum  CMMemOper { CMMemSystem = 0 , CMMemRecycle , CMMemDebug }
 Memory operation types. Refer CMUTIL_Init function for details. More...
 
enum  CMXmlNodeKind { CMXmlNodeUnknown = 0 , CMXmlNodeText , CMXmlNodeTag }
 The kind of XML node. More...
 
enum  CMFileOpenMode { CMFileOpenRead = 0 , CMFileOpenWrite , CMFileOpenAppend }
 File open mode enumeration. More...
 
enum  CMLogLevel {
  CMLogLevel_Trace = 0 , CMLogLevel_Debug , CMLogLevel_Info , CMLogLevel_Warn ,
  CMLogLevel_Error , CMLogLevel_Fatal
}
 Log severity levels. More...
 
enum  CMLogTerm {
  CMLogTerm_Year = 0 , CMLogTerm_Month , CMLogTerm_Date , CMLogTerm_Hour ,
  CMLogTerm_Minute
}
 Log rolling terms. More...
 
enum  CMSocketResult {
  CMSocketOk = 0 , CMSocketTimeout , CMSocketPollFailed , CMSocketReceiveFailed ,
  CMSocketSendFailed , CMSocketUnsupported , CMSocketNotConnected , CMSocketConnectFailed ,
  CMSocketBindFailed , CMSocketUnknownError = 0x7FFFFFFF
}
 Socket operation result codes. More...
 
enum  CMJsonType { CMJsonTypeValue = 0 , CMJsonTypeObject , CMJsonTypeArray }
 JSON value types. More...
 
enum  CMJsonValueType {
  CMJsonValueLong = 0 , CMJsonValueDouble , CMJsonValueString , CMJsonValueBoolean ,
  CMJsonValueNull
}
 JSON value types. More...
 
enum  CMProcStreamType {
  CMProcStreamNone = 0 , CMProcStreamRead = 1 , CMProcStreamWrite = 2 , CMProcStreamReadWrite = 3 ,
  CMProcStreamReadErr = 4
}
 of process stream types. More...
 

Functions

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_MemCMUTIL_GetMem (void)
 Global memory operator structure. This object will be initialized with appropriate memory operators in CMUTIL_Init.
 
CMUTIL_CondCMUTIL_CondCreate (CMBool manual_reset)
 Creates a condition object.
 
CMUTIL_MutexCMUTIL_MutexCreate (void)
 Creates a mutex object.
 
CMUTIL_ThreadCMUTIL_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_ThreadCMUTIL_ThreadSelf (void)
 Get the current thread context.
 
uint64_t CMUTIL_ThreadSystemSelfId (void)
 Get system dependent thread id.
 
CMUTIL_ThreadPoolCMUTIL_ThreadPoolCreate (int pool_size, const char *name)
 Creates a new threadpool object.
 
CMUTIL_SemaphoreCMUTIL_SemaphoreCreate (int initcnt)
 Creates a semaphore object.
 
CMUTIL_RWLockCMUTIL_RWLockCreate (void)
 Create a read-write lock object.
 
CMUTIL_ArrayCMUTIL_ArrayCreateEx (size_t initcapacity, CMCompareCB comparator, CMFreeCB freecb)
 Creates a dynamic array with capacity and optional comparator and free callback.
 
CMUTIL_StringCMUTIL_StringCreateEx (size_t initcapacity, const char *initcontent)
 Creates a string object with initial capacity and content.
 
CMUTIL_StringArrayCMUTIL_StringArrayCreateEx (size_t initcapacity)
 
CMUTIL_StringArrayCMUTIL_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_StringArrayCMUTIL_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_ByteBufferCMUTIL_ByteBufferCreateEx (size_t initcapacity)
 Creates CMUTIL_ByteBuffer object with initial capacity.
 
CMUTIL_MapCMUTIL_MapCreateEx (uint32_t bucketsize, CMBool isucase, CMFreeCB freecb, float load_factor)
 Create a new map with custom settings.
 
CMUTIL_ListCMUTIL_ListCreateEx (CMFreeCB freecb)
 Create a new list with a custom free callback.
 
CMUTIL_XmlNodeCMUTIL_XmlParse (CMUTIL_String *str)
 Parse an XML string into an XML node tree.
 
CMUTIL_XmlNodeCMUTIL_XmlParseString (const char *xmlstr, size_t len)
 Parse an XML string into an XML node tree.
 
CMUTIL_XmlNodeCMUTIL_XmlParseFile (const char *fpath)
 Parse an XML file into an XML node tree.
 
CMUTIL_XmlNodeCMUTIL_XmlNodeCreate (CMXmlNodeKind type, const char *tagname)
 Create a new XML node with the specified type and tag name.
 
CMUTIL_XmlNodeCMUTIL_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_CSConvCMUTIL_CSConvCreate (const char *fromcs, const char *tocs)
 Create a character set conversion object.
 
CMUTIL_TimerCMUTIL_TimerCreateEx (long precision, int threads)
 Create a timer object with custom settings.
 
CMUTIL_PoolCMUTIL_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_LibraryCMUTIL_LibraryCreate (const char *path)
 Create a dynamic library loader for the specified library path.
 
CMUTIL_FileCMUTIL_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_ConfigCMUTIL_ConfigCreate (void)
 Create a new empty configuration object.
 
CMUTIL_ConfigCMUTIL_ConfigLoad (const char *fconf)
 Load a configuration from a file.
 
CMUTIL_LogAppenderCMUTIL_LogConsoleAppenderCreate (const char *name, const char *pattern, CMBool use_stderr)
 Create a console log appender.
 
CMUTIL_LogAppenderCMUTIL_LogFileAppenderCreate (const char *name, const char *fpath, const char *pattern)
 Create a file log appender.
 
CMUTIL_LogAppenderCMUTIL_LogRollingFileAppenderCreate (const char *name, const char *fpath, CMLogTerm logterm, const char *rollpath, const char *pattern)
 Create a rolling file log appender.
 
CMUTIL_LogAppenderCMUTIL_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_LogSystemCMUTIL_LogSystemCreate (void)
 Create a new log system object.
 
CMUTIL_LogSystemCMUTIL_LogSystemConfigureFomJson (const char *jsonfile)
 Configure the log system from a JSON configuration file.
 
CMUTIL_LogSystemCMUTIL_LogSystemGet (void)
 Get the current global log system.
 
void CMUTIL_LogSystemSet (CMUTIL_LogSystem *lsys)
 Set the global log system.
 
CMUTIL_StackWalkerCMUTIL_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_SocketCMUTIL_SocketConnect (const char *host, int port, long timeout)
 Create a new socket which connected to the given endpoint.
 
CMUTIL_SocketCMUTIL_SocketConnectWithAddr (const CMUTIL_SocketAddr *saddr, long timeout)
 Create a new socket which connected to the given socket address.
 
CMUTIL_SocketCMUTIL_SocketConnectIPC (const char *ipc_path, long timeout)
 Create a new socket which connected to the given ipc path.
 
CMUTIL_SocketCMUTIL_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_SocketCMUTIL_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_ServerSocketCMUTIL_ServerSocketCreate (const char *host, int port, int qcnt, CMBool silent)
 Create a new server socket which listens on the given host and port.
 
CMUTIL_ServerSocketCMUTIL_ServerSocketCreateIPC (const char *ipc_path, int qcnt, CMBool silent)
 Create a new server socket which listens on the given ipc path.
 
CMUTIL_ServerSocketCMUTIL_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_DGramSocketCMUTIL_DGramSocketCreate (void)
 Create a new datagram socket.
 
CMUTIL_DGramSocketCMUTIL_DGramSocketCreateBind (CMUTIL_SocketAddr *addr)
 Create a new datagram socket and bind it to the given address.
 
CMUTIL_HttpClientCMUTIL_HttpClientCreate (const char *urlprefix)
 Create an HTTP client for the given URL prefix.
 
CMUTIL_JsonValueCMUTIL_JsonValueCreate (void)
 Create a new JSON value object.
 
CMUTIL_JsonObjectCMUTIL_JsonObjectCreate (void)
 Create a new JSON object.
 
CMUTIL_JsonArrayCMUTIL_JsonArrayCreate (void)
 Create a new JSON array.
 
CMUTIL_JsonCMUTIL_JsonParse (CMUTIL_String *jsonstr)
 Parse a JSON string into a JSON object.
 
CMUTIL_JsonCMUTIL_XmlToJson (CMUTIL_XmlNode *node)
 Convert an XML node to a JSON object.
 
CMUTIL_RestClientCMUTIL_RestClientCreate (const char *urlprefix)
 Create a REST client for the given URL prefix.
 
CMUTIL_ProcessCMUTIL_ProcessCreateEx (const char *cwd, CMUTIL_Map *env, const char *command,...)
 Creates a new process with the specified command and arguments.
 
CMUTIL_BlockCryptoCMUTIL_BlockCryptoCreate (const char *algo, const char *mode, const char *padding, int key_bits)
 Creates a new block crypto object.
 
CMUTIL_PrivateKeyCMUTIL_PrivateKeyCreateFromPEM (const char *pem, const uint8_t *passphrase)
 Creates a private key object from a PEM-formatted string.
 
CMUTIL_PublicKeyCMUTIL_PublicKeyCreateFromPEM (const char *pem)
 Creates a public key object from a PEM-formatted string.
 
CMUTIL_PrivateKeyCMUTIL_PrivateKeyCreateFromFile (const char *file_path, const uint8_t *passphrase)
 Creates a private key object from a PEM-formatted file.
 
CMUTIL_PublicKeyCMUTIL_PublicKeyCreateFromFile (const char *file_path)
 Creates a public key object from a PEM-formatted file.
 
CMUTIL_RSACryptoCMUTIL_RSACryptoCreate (void)
 Creates a new RSA crypto object.
 
void CMUTIL_CryptoRandom (uint8_t *buf, size_t len)
 Generates cryptographically strong random bytes.
 
CMUTIL_StringCMUTIL_CryptoToBase64 (const uint8_t *data, size_t len)
 Encodes data to Base64 string.
 
CMUTIL_StringCMUTIL_CryptoFromBase64 (const char *base64)
 Decodes Base64-encoded data.
 

Detailed Description

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

Macro Definition Documentation

◆ CMUTIL_UNUSED

#define CMUTIL_UNUSED (   a,
  ... 
)    CMUTIL_UnusedP((void*)(int64_t)(a), ## __VA_ARGS__)

Unused variable wrapper for avoiding compile warning.

◆ CMUTIL_LOG_CONFIG_DEFAULT

#define CMUTIL_LOG_CONFIG_DEFAULT   "cmutil_log.jsonc"

Default log configuration file name.

◆ CMUTIL_ProcessCreate

#define CMUTIL_ProcessCreate (   cwd,
  env,
  command,
  ... 
)     CMUTIL_ProcessCreateEx(cwd, env, command, ##__VA_ARGS__, NULL)

Creates a new process with the specified command and arguments.

Sets working directory, environment variables, command, and arguments for the new process. This macro adds NULL as the last argument to CMUTIL_ProcessCreateEx.

Parameters
cwdThe working directory for the new process.
envThe environment variables for the new process.
commandThe command to execute in the new process.
...Additional arguments of the process.
Returns
A pointer to the newly created process, or NULL on failure.

Function Documentation

◆ CMUTIL_UnusedP()

void CMUTIL_UnusedP ( void *  a,
  ... 
)

Consumes its arguments so the compiler stops calling them unused.

Use the CMUTIL_UNUSED macro above rather than this function.

Parameters
aFirst value to consume.
...Any further values to consume.

◆ CMUTIL_GetLibVersion()

const char * CMUTIL_GetLibVersion ( void  )

Get a version string of this library.

Returns
Version string of this library.

◆ CMUTIL_CryptoToBase64()

CMUTIL_String * CMUTIL_CryptoToBase64 ( const uint8_t *  data,
size_t  len 
)

Encodes data to Base64 string.

Parameters
dataThe data to encode.
lenThe length of the data.
Returns
The Base64 encoded string, or NULL on failure.

◆ CMUTIL_CryptoFromBase64()

CMUTIL_String * CMUTIL_CryptoFromBase64 ( const char *  base64)

Decodes Base64-encoded data.

Parameters
base64The Base64-encoded data.
Returns
The decoded data as a CMUTIL_String object, or NULL on failure.