The Multithreaded Portable Runtime (MPR) is a portable runtime library for embedded applications.
The MPR provides management for logging, error handling, events, files, http, memory, ssl, sockets, strings, xml parsing, and date/time functions. It also provides a foundation of safe routines for secure programming, that help to prevent buffer overflows and other security threats. The MPR is a library and a C API that can be used in both C and C++ programs.
The MPR uses a set extended typedefs for common types. These include: bool, cchar, cvoid, uchar, short, ushort, int, uint, long, ulong, int32, uint32, int64, uint64, float, and double. The cchar type is a const char, cvoid is const void. Several types have "u" prefixes to denote unsigned qualifiers.
The MPR includes a memory allocator and generational garbage collector. The allocator is a fast, immediate coalescing allocator that will return memory back to the O/S if not required. It is optimized for frequent allocations of small blocks (< 4K) and uses a scheme of free queues for fast allocation.
Not all of these APIs are thread-safe.
Mpr | Primary MPR application control structure. |
MprBuf | Dynamic Buffer Module. |
MprCache | In-memory caching. |
MprCmd | Command execution Service. |
MprDispatcher | Event Dispatcher. |
MprEvent | Event object. |
MprFile | File I/O Module. |
MprFileSystem | File system service. |
MprFloat | Floating Point Services. |
MprHash | Hash table entry structure. |
MprJson | JSON parser. |
MprList | List data structure. |
MprLog | Logging Services. |
MprMem | Memory Allocation Service. |
MprMime | Mime Type hash table entry (the URL extension is the key). |
MprModule | Loadable Module Service. |
MprModuleSerivce | Loadable module service. |
MprPath | Path (filename) Information. |
MprSignal | Signal control structure. |
MprSocket | Socket Service. |
MprSsl | SSL control structure. |
MprString | Safe String Module. |
MprSynch | Multithreaded Synchronization Services. |
MprTestService | Test service facility. |
MprThread | Thread Service. |
MprTime | Date and Time Service. |
MprWaitHandler | Wait Handler Service. |
MprWorker | Worker thread structure. |
MprXml | Per XML session structure. |
void | assert(bool cond) |
Assert that a condition is true. | |
bool | assertTrue(MprTestGroup *gp, cchar *loc, bool success, cchar *msg) |
Test assert. | |
char* | fmt(char *buf, ssize maxSize, cchar *fmt, ...) |
Format a string into a static buffer. | |
char* | fmtv(char *buf, ssize maxSize, cchar *fmt, va_list args) |
Format a string into a statically allocated buffer. | |
char* | itos(int64 value) |
Convert an integer to a string. | |
char* | itosbuf(char *buf, ssize size, int64 value, int radix) |
Convert an integer to a string buffer. | |
char* | itosradix(int64 value, int radix) |
Convert an integer to a string. | |
MprSocket* | mprAcceptSocket(MprSocket *listen) |
Accept an incoming connection. | |
MprKey* | mprAddDuplicateKey(MprHash *table, cvoid *key, cvoid *ptr) |
Add a duplicate symbol value into the hash table. | |
void | mprAddFileSystem(MprFileSystem *fs) |
Create and initialize the disk FileSystem. | |
int | mprAddItem(MprList *list, cvoid *item) |
Add an item to a list. | |
MprKey* | mprAddKey(MprHash *table, cvoid *key, cvoid *ptr) |
Add a symbol value into the hash table. | |
MprKey* | mprAddKeyFmt(MprHash *table, cvoid *key, cchar *fmt, ...) |
Add a key with a formatting value into the hash table. | |
MprMime* | mprAddMime(MprHash *table, cchar *ext, cchar *mimeType) |
Add a mime type to the mime type table. | |
int | mprAddNullItem(MprList *list) |
Add a null item to the list. | |
void | mprAddNullToBuf(MprBuf *buf) |
Add a null character to the buffer contents. | |
void | mprAddRoot(void *ptr) |
Add a memory block as a root for garbage collection. | |
MprSignal* | mprAddSignalHandler(int signo, void *handler, void *arg, MprDispatcher *dispatcher, int flags) |
Add a signal handler. | |
MprWaitHandler* | mprAddSocketHandler(MprSocket *sp, int mask, MprDispatcher *dispatcher, void *proc, void *data, int flags) |
Add a wait handler to a socket. | |
void | mprAddSocketProvider(cchar *name, MprSocketProvider *provider) |
Add a secure socket provider for SSL communications. | |
void | mprAddSslCiphers(struct MprSsl *ssl, cchar *ciphers) |
Add the ciphers to use for SSL. | |
void | mprAddStandardSignals() |
Add standard trapping of system signals. | |
void | mprAddTerminator(MprTerminator terminator) |
Add a terminator callback. | |
MprTestGroup* | mprAddTestGroup(MprTestService *ts, MprTestDef *def) |
Add a test group to the test service. | |
void | mprAdjustBufEnd(MprBuf *buf, ssize count) |
Adjust the buffer end position. | |
void | mprAdjustBufStart(MprBuf *buf, ssize count) |
Adjust the buffer start position. | |
void* | mprAlloc(ssize size) |
Allocate a block of memory. | |
void* | mprAllocMem(ssize size, int flags) |
Allocate a block of memory. | |
void* | mprAllocObj(Type type, MprManager manager) |
Allocate an object of a given type. | |
void* | mprAllocZeroed(ssize size) |
Allocate a zeroed block of memory. | |
MprList* | mprAppendList(MprList *list, MprList *add) |
Append a list. | |
bool | mprAreCmdEventsEnabled(MprCmd *cmd, int channel) |
Return true if command events are enabled. | |
void | mprAssert(cchar *loc, cchar *msg) |
Output an assure assertion failed message. | |
void | mprAtomicAdd(volatile int *target, int value) |
Atomic Add. | |
void | mprAtomicAdd64(volatile int64 *target, int value) |
Atomic 64 bit Add. | |
void | mprAtomicBarrier() |
Apply a full (read+write) memory barrier. | |
int | mprAtomicCas(void *volatile *target, void *expected, cvoid *value) |
Atomic Compare and Swap. | |
void* | mprAtomicExchange(void *volatile *target, cvoid *value) |
Exchange the target and a value. | |
void | mprAtomicListInsert(void *volatile *head, volatile void **link, void *item) |
Atomic list insertion. | |
MprFile* | mprAttachFileFd(int fd, cchar *name, int omode) |
Attach to an existing file descriptor. | |
int | mprAvailableWorkers() |
Get the count of available worker threads Return the count of free threads in the worker thread pool. | |
int | mprBackupLog(cchar *path, int count) |
Backup a log. | |
MprHash* | mprBlendHash(MprHash *target, MprHash *other) |
Blend two hash tables. | |
void | mprBreakpoint() |
Trigger a breakpoint. | |
char* | mprBufToString(MprBuf *buf) |
Convert the buffer contents to a string. | |
void | mprClearList(MprList *list) |
Clears the list of all items. | |
MprBuf* | mprCloneBuf(MprBuf *orig) |
Clone a buffer. | |
MprHash* | mprCloneHash(MprHash *table) |
Copy a hash table. | |
MprList* | mprCloneList(MprList *src) |
Clone a list and all elements. | |
struct MprSsl* | mprCloneSsl(MprSsl *src) |
Create the a new SSL control structure based on an existing structure. | |
void | mprCloseCmdFd(MprCmd *cmd, int channel) |
Close the command channel. | |
int | mprCloseFile(MprFile *file) |
Close a file. | |
void | mprCloseSocket(MprSocket *sp, bool graceful) |
Close a socket. | |
void | mprCompactBuf(MprBuf *buf) |
Compact the buffer contents. | |
int | mprCompareTime(MprTime t1, MprTime t2) |
Compare two times. | |
int | mprConnectSocket(MprSocket *sp, cchar *ip, int port, int flags) |
Connect a client socket. | |
int | mprCopyListContents(MprList *dest, MprList *src) |
Copy list contents. | |
int | mprCopyPath(cchar *from, cchar *to, int omode) |
Copy a file. | |
Mpr* | mprCreate(int argc, char **argv, int flags) |
Create an instance of the MPR. | |
MprBuf* | mprCreateBuf(ssize initialSize, ssize maxSize) |
Create a new buffer. | |
MprCache* | mprCreateCache(int options) |
Create a new cache object. | |
MprCmd* | mprCreateCmd(MprDispatcher *dispatcher) |
Create a new Command object. | |
MprCond* | mprCreateCond() |
Create a condition lock variable. | |
MprDispatcher* | mprCreateDispatcher(cchar *name, int flags) |
Create a new event dispatcher. | |
MprEvent* | mprCreateEvent(MprDispatcher *dispatcher, cchar *name, MprTicks period, void *proc, void *data, int flags) |
Create a new event. | |
int | mprCreateEventOutside(MprDispatcher *dispatcher, void *proc, void *data) |
Create an event outside the MPR. | |
MprFileSystem* | mprCreateFileSystem(cchar *path) |
Create and initialize the FileSystem subsystem. | |
MprHash* | mprCreateHash(int hashSize, int flags) |
Create a hash table. | |
MprHash* | mprCreateHashFromWords(cchar *str) |
Create a hash of words. | |
MprKeyValue* | mprCreateKeyPair(cchar *key, cchar *value) |
Create a key / value pair. | |
MprList* | mprCreateList(int size, int flags) |
Create a list. | |
MprMutex* | mprCreateLock() |
Create a Mutex lock object. | |
void | mprCreateLogService() |
Initialize the log service. | |
struct Mpr* | mprCreateMemService(MprManager manager, int flags) |
Create and initialize the Memory service. | |
MprHash* | mprCreateMimeTypes(cchar *path) |
Create the mime types. | |
MprModule* | mprCreateModule(cchar *name, cchar *path, cchar *entry, void *data) |
Create a module. | |
MprModuleService* | mprCreateModuleService() |
Create and initialize the module service. | |
int | mprCreateNotifierService(MprWaitService *ws) |
Internal. | |
int | mprCreateOsService() |
Create and initialze the O/S dependent subsystem. | |
MprRomFileSystem* | mprCreateRomFileSystem(cchar *path) |
Create and initialize the ROM FileSystem. | |
MprSocket* | mprCreateSocket() |
Create a socket. | |
MprSpin* | mprCreateSpinLock() |
Create a spin lock lock object. | |
struct MprSsl* | mprCreateSsl(int server) |
Create the SSL control structure. | |
MprTestService* | mprCreateTestService() |
Create the test service. | |
MprThread* | mprCreateThread(cchar *name, void *proc, void *data, ssize stackSize) |
Create a new thread. | |
int | mprCreateTimeService() |
Mpr time structure. | |
MprEvent* | mprCreateTimerEvent(MprDispatcher *dispatcher, cchar *name, MprTicks period, void *proc, void *data, int flags) |
Create a timer event. | |
MprWaitHandler* | mprCreateWaitHandler(int fd, int mask, MprDispatcher *dispatcher, void *proc, void *data, int flags) |
Create a wait handler. | |
char* | mprDecode64(cchar *str) |
Decode a null terminated string using base-46 encoding. | |
char* | mprDecode64Block(cchar *buf, ssize *len, int flags) |
Decode a null terminated string using base-46 encoding. | |
void | mprDecodeLocalTime(struct tm *timep, MprTime time) |
Decode a time value into a tokenized local time value. | |
void | mprDecodeUniversalTime(struct tm *timep, MprTime time) |
Decode a time value into a tokenized UTC time structure. | |
void | mprDedicateWorker(MprWorker *worker) |
Dedicate a worker thread to a current real thread. | |
int | mprDeletePath(cchar *path) |
Delete a file. | |
MprObj* | mprDeserialize(cchar *str) |
Deserialize a JSON string into an object tree. | |
MprObj* | mprDeserializeCustom(cchar *str, MprJsonCallback callback, void *data) |
Custom deserialization from a JSON string into an object tree. | |
void | mprDestroy(int how) |
Destroy the MPR. | |
void* | mprDestroyCache(MprCache *cache) |
Destroy a new cache object. | |
void | mprDestroyCmd(MprCmd *cmd) |
Destroy the command. | |
void | mprDestroyMemService() |
Destroy the memory service. | |
void | mprDisableCmdEvents(MprCmd *cmd, int channel) |
Disable command I/O events. | |
void | mprDisableDispatcher(MprDispatcher *dispatcher) |
Disable a dispatcher from service events. | |
void | mprDisableFileBuffering(MprFile *file) |
Disable file buffering. | |
void | mprDisconnectCmd(MprCmd *cmd) |
Disconnect a command its underlying I/O channels. | |
void | mprDisconnectSocket(MprSocket *sp) |
Disconnect a socket by closing its underlying file descriptor. | |
char* | mprEmptyString() |
Reference to a permanent preallocated empty string. | |
void | mprEnableCmdEvents(MprCmd *cmd, int channel) |
Enable command I/O events. | |
void | mprEnableCmdOutputEvents(MprCmd *cmd, bool on) |
Enable command I/O events for the command's STDOUT and STDERR channels. | |
void | mprEnableContinuousEvent(MprEvent *event, int enable) |
Enable or disable an event being continous. | |
void | mprEnableDispatcher(MprDispatcher *dispatcher) |
Enable a dispatcher to service events. | |
int | mprEnableFileBuffering(MprFile *file, ssize size, ssize maxSize) |
Enable file buffering. | |
bool | mprEnableGC(bool on) |
Enable or disable the garbage collector. | |
void | mprEnableSocketEvents(MprSocket *sp, int mask) |
Enable socket events for a socket callback. | |
char* | mprEncode64(cchar *str) |
Encode a string using base-46 encoding. | |
char* | mprEncode64Block(cchar *buf, ssize len) |
Encode buffer using base-46 encoding. | |
ssize | mprEprintf(cchar *fmt, ...) |
Print a formatted message to the standard error channel. | |
void | mprError(cchar *fmt, ...) |
Log an error message. | |
char* | mprEscapeCmd(cchar *cmd, int escChar) |
Encode a string escaping typical command (shell) characters. | |
char* | mprEscapeHtml(cchar *html) |
Encode a string by escaping typical HTML characters. | |
int | mprExpireCache(MprCache *cache, cchar *key, MprTicks expires) |
Set the expiry date for a cache item. | |
void | mprFinalizeCmd(MprCmd *cmd) |
Finalize the writing of data to the command process. | |
void | mprFlushBuf(MprBuf *buf) |
Flush the buffer contents. | |
int | mprFlushFile(MprFile *file) |
Flush any buffered write data. | |
ssize | mprFlushSocket(MprSocket *sp) |
Flush a socket. | |
char* | mprFormatLocalTime(cchar *fmt, MprTime time) |
Convert a time value to local time and format as a string. | |
char* | mprFormatTm(cchar *fmt, struct tm *timep) |
Format a time value as a local time. | |
char* | mprFormatUniversalTime(cchar *fmt, MprTime time) |
Convert a time value to universal time and format as a string. | |
ssize | mprFprintf(struct MprFile *file, cchar *fmt, ...) |
Print a formatted message to a file descriptor. | |
char* | mprGetAbsPath(cchar *path) |
Convert a path to an absolute path. | |
char* | mprGetAppDir() |
Get the application directory. | |
cchar* | mprGetAppName() |
Get the application name defined via mprSetAppName. | |
char* | mprGetAppPath() |
Get the application executable path. | |
cchar* | mprGetAppTitle() |
Get the application title string. | |
cchar* | mprGetAppVersion() |
Get the application version string. | |
ssize | mprGetBlockFromBuf(MprBuf *buf, char *blk, ssize count) |
Get a block of data from the buffer. | |
ssize | mprGetBlockSize(cvoid *ptr) |
Get the allocated size of a memory block. | |
char* | mprGetBuf(MprBuf *buf) |
Get the origin of the buffer content storage. | |
char* | mprGetBufEnd(MprBuf *buf) |
Get a reference to the end of the buffer contents. | |
ssize | mprGetBufLength(MprBuf *buf) |
Get the buffer content length. | |
MprBufProc | mprGetBufRefillProc(MprBuf *buf) |
Get the buffer refill procedure. | |
ssize | mprGetBufSize(MprBuf *buf) |
Get the current size of the buffer content storage. | |
ssize | mprGetBufSpace(MprBuf *buf) |
Get the space available to store content. | |
char* | mprGetBufStart(MprBuf *buf) |
Get the start of the buffer contents. | |
int | mprGetCharFromBuf(MprBuf *buf) |
Get a character from the buffer. | |
MprBuf* | mprGetCmdBuf(MprCmd *cmd, int channel) |
Get the underlying buffer for a channel. | |
int | mprGetCmdExitStatus(MprCmd *cmd) |
Get the command exit status. | |
int | mprGetCmdFd(MprCmd *cmd, int channel) |
Get the underlying file descriptor for an I/O channel. | |
bool | mprGetCmdlineLogging() |
Get if command line logging is being used. | |
MprOsThread | mprGetCurrentOsThread() |
Get the O/S thread. | |
char* | mprGetCurrentPath() |
Return the current working directory. | |
MprThread* | mprGetCurrentThread() |
Get the currently executing thread. | |
cchar* | mprGetCurrentThreadName() |
Return the name of the current thread. | |
char* | mprGetDate(char *fmt) |
Get a string representation of the current date/time. | |
bool | mprGetDebugMode() |
Get the debug mode. | |
MprDispatcher* | mprGetDispatcher() |
Get the MPR primary dispatcher. | |
cchar* | mprGetDomainName() |
Get the application domain name string. | |
MprTicks | mprGetElapsedTicks(MprTicks mark) |
Get the elapsed time since a ticks mark. | |
MprTime | mprGetElapsedTime(MprTime mark) |
Get the elapsed time since a starting time mark. | |
int | mprGetEndian() |
Return the endian byte ordering for the application. | |
int | mprGetError() |
Return the error code for the most recent system or library operation. | |
int | mprGetExitStatus() |
Get the exit status. | |
int | mprGetFileChar(MprFile *file) |
Read a character from the file. | |
int | mprGetFileFd(MprFile *file) |
Get the file descriptor for a file. | |
MprOff | mprGetFilePosition(MprFile *file) |
Return the current file position. | |
MprOff | mprGetFileSize(MprFile *file) |
Get the size of the file. | |
void* | mprGetFirstItem(MprList *list) |
Get the first item in the list. | |
MprKey* | mprGetFirstKey(MprHash *table) |
Return the first symbol in a symbol entry. | |
cchar* | mprGetFirstPathSeparator(cchar *path) |
Get the first path separator in a path. | |
int | mprGetHashLength(MprHash *table) |
Return the count of symbols in a symbol entry. | |
uint64 | mprGetHiResTicks() |
Get the CPU tick count. | |
cchar* | mprGetHostName() |
Get the application host name string. | |
cchar* | mprGetIpAddr() |
Get the application IP address string. | |
void* | mprGetItem(MprList *list, int index) |
Get an list item. | |
void* | mprGetLastItem(MprList *list) |
Get the last item in the list. | |
int | mprGetListCapacity(MprList *list) |
Get the current capacity of the list. | |
int | mprGetListLength(MprList *list) |
Get the number of items in the list. | |
struct MprFile* | mprGetLogFile() |
Get the log file object. | |
MprLogHandler | mprGetLogHandler() |
Get the current MPR debug log handler. | |
int | mprGetLogLevel() |
Get the current logging level. | |
char* | mprGetMD5(cchar *str) |
Get an MD5 checksum. | |
char* | mprGetMD5WithPrefix(cchar *buf, ssize len, cchar *prefix) |
Get an MD5 checksum with optional prefix string and buffer length. | |
int | mprGetMaxWorkers() |
Get the maximum count of worker pool threads Get the maximum limit of worker pool threads. | |
ssize | mprGetMem() |
Return the amount of memory currently used by the application. | |
MprMemStats* | mprGetMemStats() |
Return the current allocation memory statistics block. | |
cchar* | mprGetMimeProgram(MprHash *table, cchar *mimeType) |
Get the mime type program for a given mimeType. | |
cchar* | mprGetModuleSearchPath() |
Get the module search path. | |
Mpr* | mprGetMpr() |
Return the MPR control instance. | |
char* | mprGetNativePath(cchar *path) |
Get a path formatted according to the native O/S conventions. | |
void* | mprGetNextItem(MprList *list, int *lastIndex) |
Get the next item in the list. | |
MprKey* | mprGetNextKey(MprHash *table, MprKey *last) |
Return the next symbol in a symbol entry. | |
void* | mprGetNextStableItem(MprList *list, int *lastIndex) |
Get the next item in a stable list. | |
int | mprGetOsError() |
Return the O/S error code. | |
int | mprGetPageSize() |
Get the current O/S virtual page size. | |
char* | mprGetPathBase(cchar *path) |
Get the base portion of a path. | |
cchar* | mprGetPathBaseRef(cchar *path) |
Get a reference to the base portion of a path. | |
char* | mprGetPathDir(cchar *path) |
Get the directory portion of a path. | |
char* | mprGetPathExt(cchar *path) |
Get the file extension portion of a path. | |
MprList* | mprGetPathFiles(cchar *dir, int flags) |
Create a list of files in a directory or subdirectories. | |
char* | mprGetPathFirstDir(cchar *path) |
Get the first directory portion of a path. | |
int | mprGetPathInfo(cchar *path, MprPath *info) |
Return information about a file represented by a path. | |
char* | mprGetPathLink(cchar *path) |
Get the target of a symbolic link. | |
cchar* | mprGetPathNewline(cchar *path) |
Get the file newline character string for a given path. | |
char* | mprGetPathParent(cchar *path) |
Get the parent directory of a path. | |
cchar* | mprGetPathSeparators(cchar *path) |
Get the path directory separator. | |
char* | mprGetPortablePath(cchar *path) |
Get a portable path. | |
void* | mprGetPrevItem(MprList *list, int *lastIndex) |
Get the previous item in the list. | |
int | mprGetRandomBytes(char *buf, ssize size, bool block) |
Get some random data. | |
char* | mprGetRelPath(cchar *dest, cchar *origin) |
Get a relative path. | |
MprTicks | mprGetRemainingTicks(MprTicks mark, MprTicks timeout) |
Return the time remaining until a timeout has elapsed. | |
char* | mprGetSHA(cchar *str) |
Get an SHA1 checksum. | |
char* | mprGetSHABase64(cchar *str) |
Get an SHA1 checksum of a null terminated string. | |
char* | mprGetSHAWithPrefix(cchar *buf, ssize len, cchar *prefix) |
Get an SHA1 checksum with optional prefix string and buffer length. | |
cchar* | mprGetServerName() |
Get the application server name string. | |
bool | mprGetSocketBlockingMode(MprSocket *sp) |
Get the socket blocking mode. | |
int | mprGetSocketError(MprSocket *sp) |
Get a socket error code. | |
Socket | mprGetSocketFd(MprSocket *sp) |
Get the socket file descriptor. | |
int | mprGetSocketInfo(cchar *ip, int port, int *family, int *protocol, struct sockaddr **addr, Socklen *addrlen) |
Get the socket for an IP:Port address. | |
int | mprGetSocketPort(MprSocket *sp) |
Get the port used by a socket. | |
char* | mprGetSocketState(MprSocket *sp) |
Get the socket state. | |
int | mprGetSslCipherCode(cchar *cipher) |
Lookup an SSL cipher by its IANA name and return the cipher IANA code. | |
cchar* | mprGetSslCipherName(int cipher) |
Lookup an SSL cipher by its IANA code and return the string name. | |
MprFile* | mprGetStderr() |
Return a file object for the Stderr I/O channel. | |
MprFile* | mprGetStdin() |
Return a file object for the Stdin I/O channel. | |
MprFile* | mprGetStdout() |
Return a file object for the Stdout I/O channel. | |
char* | mprGetTempPath(cchar *tmpDir) |
Make a temporary file. | |
cchar* | mprGetThreadName(MprThread *thread) |
Get the thread name. | |
int | mprGetThreadPriority(MprThread *thread) |
Get the thread priroity. | |
MprTicks | mprGetTicks() |
Get the system time. | |
MprTime | mprGetTime() |
Get the time. | |
int | mprGetTimeZoneOffset(MprTime when) |
Get the current timezone offset for a given time. | |
char* | mprGetWinPath(cchar *path) |
Convert a path to an absolute windows path. | |
void | mprGetWorkerStats(MprWorkerStats *stats) |
Get the Worker service statistics. | |
void | mprGlobalLock() |
Globally lock the application. | |
void | mprGlobalUnlock() |
Unlock the global mutex. | |
int | mprGrowBuf(MprBuf *buf, ssize count) |
Grow the buffer. | |
bool | mprHasDualNetworkStack() |
has the system got a dual IPv4 + IPv6 network stack. | |
bool | mprHasIPv6() |
Determine if the system support IPv6. | |
bool | mprHasMemError() |
Determine if the MPR has encountered memory allocation errors. | |
bool | mprHasSecureSockets() |
Determine if SSL is available. | |
void | mprHiddenSocketData(MprSocket *sp, ssize len, int dir) |
Indicate that the application layer has buffered data for the socket. | |
void | mprHold(void *ptr) |
Hold a memory block. | |
int64 | mprIncCache(MprCache *cache, cchar *key, int64 amount) |
Increment a numeric cache item. | |
void | mprInfo(cchar *fmt, ...) |
Log an informational message. | |
void | mprInitList(MprList *list, int flags) |
Initialize a list structure. | |
MprMutex* | mprInitLock(MprMutex *mutex) |
Initialize a statically allocated Mutex lock object. | |
MprSpin* | mprInitSpinLock(MprSpin *lock) |
Initialize a statically allocated spinlock object. | |
int | mprInsertCharToBuf(MprBuf *buf, int c) |
Insert a character into the buffer. | |
int | mprInsertItemAtPos(MprList *list, int index, cvoid *item) |
Insert an item into a list at a specific position. | |
int | mprIsCmdComplete(MprCmd *cmd) |
Test if a command is complete. | |
bool | mprIsCmdRunning(MprCmd *cmd) |
Test if the command is still running. | |
bool | mprIsExiting() |
Determine if the MPR is exiting. | |
bool | mprIsFinished() |
Determine if the MPR has finished. | |
bool | mprIsIPv6(cchar *ip) |
Determine if the IP address is an IPv6 address. | |
bool | mprIsIdle() |
Determine if the App is idle. | |
int | mprIsInfinite(double value) |
Test if a double value is infinte. | |
int | mprIsNan(double value) |
Test if a double value is not-a-number. | |
bool | mprIsPathAbs(cchar *path) |
Determine if a path is absolute. | |
bool | mprIsPathDir(cchar *path) |
Determine if a path is a directory. | |
bool | mprIsPathRel(cchar *path) |
Determine if a path is relative. | |
bool | mprIsPathSeparator(cchar *path, cchar c) |
Test if a character is a path separarator. | |
bool | mprIsSocketEof(MprSocket *sp) |
Test if the other end of the socket has been closed. | |
bool | mprIsSocketSecure(MprSocket *sp) |
Determine if the socket is secure. | |
bool | mprIsSocketV6(MprSocket *sp) |
Determine if the socket is using IPv6 Currently only works for server side addresses. | |
bool | mprIsStopping() |
Test if the application is stopping. | |
bool | mprIsStoppingCore() |
Test if the application is stopping and core services are being terminated. | |
int | mprIsValid(cvoid *ptr) |
Test is a pointer is a valid memory context. | |
int | mprIsZero(double value) |
Test if a double value is zero. | |
char* | mprJoinPath(cchar *base, cchar *path) |
Join paths. | |
char* | mprJoinPathExt(cchar *path, cchar *ext) |
Join an extension to a path. | |
void | mprJsonParseError(MprJson *jp, cchar *fmt, ...) |
Signal a parse error in the JSON input stream. | |
Socket | mprListenOnSocket(MprSocket *sp, cchar *ip, int port, int flags) |
Listen on a server socket for incoming connections. | |
int | mprLoadModule(MprModule *mp) |
Load a module. | |
int | mprLoadNativeModule(MprModule *mp) |
Load a native module. | |
int | mprLoadSsl() |
Load the SSL module. | |
void | mprLock(MprMutex *lock) |
Lock access. | |
void | mprLog(int level, cchar *fmt, ...) |
Write a message to the log file. | |
void | mprLogHeader() |
Emit a descriptive log header. | |
int | mprLookAtLastCharInBuf(MprBuf *buf) |
Peek at the last character in the buffer. | |
int | mprLookAtNextCharInBuf(MprBuf *buf) |
Peek at the next character in the buffer. | |
MprFileSystem* | mprLookupFileSystem(cchar *path) |
Lookup a file system. | |
int | mprLookupItem(MprList *list, cvoid *item) |
Find an item and return its index. | |
void* | mprLookupKey(MprHash *table, cvoid *key) |
Lookup a symbol in the hash table. | |
MprKey* | mprLookupKeyEntry(MprHash *table, cvoid *key) |
Lookup a symbol in the hash table and return the hash entry. | |
cchar* | mprLookupMime(MprHash *table, cchar *ext) |
Get the mime type for an extension. | |
MprModule* | mprLookupModule(cchar *name) |
Lookup a module. | |
void* | mprLookupModuleData(cchar *name) |
Lookup a module and return the module data. | |
int | mprLookupStringItem(MprList *list, cchar *str) |
Find a string item and return its index. | |
int | mprMakeArgv(cchar *command, cchar ***argv, int flags) |
Make a argv style array of command arguments. | |
int | mprMakeDir(cchar *path, int perms, int owner, int group, bool makeMissing) |
Make a directory. | |
int | mprMakeLink(cchar *path, cchar *target, bool hard) |
Make a link. | |
void | mprMapSeparators(char *path, int separator) |
Map the separators in a path. | |
void | mprMark(void *ptr) |
Mark a memory block as in-use. | |
void | mprMarkBlock(cvoid *ptr) |
Mark a block as "in-use" for the Garbage Collector. | |
int | mprMemcmp(cvoid *b1, ssize b1Len, cvoid *b2, ssize b2Len) |
Compare two byte strings. | |
ssize | mprMemcpy(void *dest, ssize destMax, cvoid *src, ssize nbytes) |
Safe copy for a block of data. | |
void* | mprMemdup(cvoid *ptr, ssize size) |
Duplicate a block of memory. | |
void | mprNap(MprTicks msec) |
Nap for a while. | |
char* | mprNormalizePath(cchar *path) |
Normalize a path. | |
int | mprNotifyOn(MprWaitService *ws, MprWaitHandler *wp, int mask) |
Begin I/O notification services on a wait handler. | |
MprFile* | mprOpenFile(cchar *filename, int omode, int perms) |
Open a file. | |
int | mprParseArgs(char *command, char **argv, int maxArgs) |
Make a argv style array of command arguments. | |
int | mprParseSocketAddress(cchar *address, char **ip, int *port, int *secure, int defaultPort) |
Parse an socket address IP address. | |
int | mprParseTestArgs(MprTestService *ts, int argc, char **argv, MprTestParser extraParser) |
Parse test command arguments. | |
bool | mprPathExists(cchar *path, int omode) |
Determine if a file exists for a path name and can be accessed. | |
int | mprPeekFileChar(MprFile *file) |
Non-destructively read a character from the file. | |
void | mprPollWinCmd(MprCmd *cmd, MprTicks timeout) |
Poll for I/O on the command pipes. | |
void* | mprPopItem(MprList *list) |
Pop an item. | |
void | mprPrintMem(cchar *msg, int detail) |
Print a memory usage report to stdout. | |
ssize | mprPrintf(cchar *fmt, ...) |
Formatted print. | |
char* | mprPrintfCore(char *buf, ssize maxsize, cchar *fmt, va_list args) |
Format a string into a buffer. | |
void | mprPruneCache(MprCache *cache) |
Prune the cache. | |
int | mprPushItem(MprList *list, cvoid *item) |
Push an item onto the list. | |
ssize | mprPutBlockToBuf(MprBuf *buf, cchar *ptr, ssize size) |
Put a block to the buffer. | |
int | mprPutCharToBuf(MprBuf *buf, int c) |
Put a character to the buffer. | |
ssize | mprPutFileChar(MprFile *file, int c) |
Write a character to the file. | |
ssize | mprPutFileString(MprFile *file, cchar *str) |
Write a string to the file. | |
ssize | mprPutIntToBuf(MprBuf *buf, int64 i) |
Put an integer to the buffer. | |
ssize | mprPutPadToBuf(MprBuf *buf, int c, ssize count) |
Put padding characters to the buffer. | |
ssize | mprPutStringToBuf(MprBuf *buf, cchar *str) |
Put a string to the buffer. | |
ssize | mprPutSubStringToBuf(MprBuf *buf, cchar *str, ssize count) |
Put a substring to the buffer. | |
ssize | mprPutToBuf(MprBuf *buf, cchar *fmt, ...) |
Put a formatted string to the buffer. | |
void | mprQueueIOEvent(MprWaitHandler *wp) |
Queue an IO event for dispatch on the wait handler dispatcher. | |
int | mprRandom() |
Return a random number. | |
void | mprRawLog(int level, cchar *fmt, ...) |
Write a raw log message to the diagnostic log file. | |
char* | mprReadCache(MprCache *cache, cchar *key, MprTime *modified, int64 *version) |
Read an item from the cache. | |
ssize | mprReadCmd(MprCmd *cmd, int channel, char *buf, ssize bufsize) |
Make the I/O channels to send and receive data to and from the command. | |
ssize | mprReadFile(MprFile *file, void *buf, ssize size) |
Read data from a file. | |
char* | mprReadLine(MprFile *file, ssize size, ssize *len) |
Read a line from the file. | |
ssize | mprReadSocket(MprSocket *sp, void *buf, ssize size) |
Read from a socket. | |
void* | mprRealloc(void *ptr, ssize size) |
Reallocate a block. | |
int | mprReapCmd(MprCmd *cmd, MprTicks timeout) |
Reap the command. | |
void | mprRecallWaitHandler(MprWaitHandler *wp) |
Recall a wait handler. | |
void | mprRecallWaitHandlerByFd(int fd) |
Recall a wait handler by fd. | |
int | mprRefillBuf(MprBuf *buf) |
Refill the buffer with data. | |
void | mprRelayEvent(MprDispatcher *dispatcher, void *proc, void *data, MprEvent *event) |
Relay an event to a dispatcher. | |
void | mprRelease(void *ptr) |
Release a memory block. | |
void | mprReleaseWorker(MprWorker *worker) |
Release a worker thread. | |
bool | mprRemoveCache(MprCache *cache, cchar *key) |
Remove items from the cache. | |
void | mprRemoveEvent(MprEvent *event) |
Remove an event. | |
int | mprRemoveItem(MprList *list, cvoid *item) |
Remove an item from the list. | |
int | mprRemoveItemAtPos(MprList *list, int index) |
Remove an item from the list. | |
int | mprRemoveKey(MprHash *table, cvoid *key) |
Remove a symbol entry from the hash table. | |
int | mprRemoveLastItem(MprList *list) |
Remove the last item from the list. | |
int | mprRemoveRangeOfItems(MprList *list, int start, int end) |
Remove a range of items from the list. | |
void | mprRemoveRoot(void *ptr) |
remove a memory block as a root for garbage collection. | |
void | mprRemoveSocketHandler(MprSocket *sp) |
Remove a socket wait handler. | |
int | mprRemoveStringItem(MprList *list, cchar *str) |
Remove a string item from the list. | |
void | mprRemoveWaitHandler(MprWaitHandler *wp) |
Disconnect a wait handler from its underlying file descriptor. | |
char* | mprReplacePathExt(cchar *dir, cchar *ext) |
Replace an extension to a path. | |
void | mprReportTestResults(MprTestService *ts) |
Report the test results. | |
void | mprRequestGC(int flags) |
Collect garbage. | |
void | mprRescheduleEvent(MprEvent *event, MprTicks period) |
Reschedule an event. | |
void | mprResetBufIfEmpty(MprBuf *buf) |
Reset the buffer. | |
void | mprResetCond(MprCond *cond) |
Reset a condition variable. | |
void | mprResetMemError() |
Reset the memory allocation error flag. | |
void | mprResetTestGroup(MprTestGroup *gp) |
Reset a test group. | |
void | mprResetYield() |
Reset a sticky yield. | |
char* | mprResolvePath(cchar *base, cchar *path) |
Resolve paths. | |
void | mprRestart() |
Restart the application. | |
void | mprRestartContinuousEvent(MprEvent *event) |
Restart an event. | |
int | mprRunCmd(MprCmd *cmd, cchar *command, cchar **envp, char **out, char **err, MprTicks timeout, int flags) |
Run a command using a string command line. | |
int | mprRunCmdV(MprCmd *cmd, int argc, cchar **argv, cchar **envp, char **out, char **err, MprTicks timeout, int flags) |
Run a command using an argv[] array of arguments. | |
int | mprRunTests(MprTestService *ts) |
Run the define unit tests. | |
int | mprSamePath(cchar *path1, cchar *path2) |
Compare two paths if they are the same. | |
int | mprSamePathCount(cchar *path1, cchar *path2, ssize len) |
Compare two paths if they are the same for a given length. | |
char* | mprSearchForModule(cchar *module) |
Search for a module on the current module path. | |
char* | mprSearchPath(cchar *path, int flags, cchar *search, ...) |
Search for a path. | |
MprOff | mprSeekFile(MprFile *file, int seekType, MprOff distance) |
Seek the I/O pointer to a new location in the file. | |
cchar* | mprSerialize(MprObj *obj, int flags) |
Serialize a JSON object tree into a string. | |
int | mprServiceEvents(MprTicks delay, int flags) |
Service events. | |
bool | mprServicesAreIdle() |
Determine if the MPR services. | |
int | mprSetAppName(cchar *name, cchar *title, cchar *version) |
Set the application name, title and version. | |
void | mprSetAppPath(cchar *path) |
Set the application executable path. | |
void | mprSetBufMax(MprBuf *buf, ssize maxSize) |
Set the maximum buffer size. | |
void | mprSetBufRefillProc(MprBuf *buf, MprBufProc fn, void *arg) |
Set the buffer refill procedure. | |
int | mprSetBufSize(MprBuf *buf, ssize size, ssize maxSize) |
Set the buffer size. | |
void | mprSetCacheLimits(MprCache *cache, int64 keys, MprTicks lifespan, int64 memory, int resolution) |
Set the cache resource limits. | |
void | mprSetCmdCallback(MprCmd *cmd, MprCmdProc callback, void *data) |
Define a callback to be invoked to receive response data from the command. | |
void | mprSetCmdDefaultEnv(MprCmd *cmd, cchar **env) |
Set the default environment to use for commands. | |
void | mprSetCmdDir(MprCmd *cmd, cchar *dir) |
Set the home directory for the command. | |
void | mprSetCmdEnv(MprCmd *cmd, cchar **env) |
Set the command environment. | |
void | mprSetCmdSearchPath(MprCmd *cmd, cchar *search) |
Set the default command search path. | |
bool | mprSetCmdlineLogging(bool on) |
Set if command line logging was requested. | |
void | mprSetCurrentThreadPriority(int priority) |
Set the thread priroity for the current thread. | |
void | mprSetDebugMode(bool on) |
Turn on debug mode. | |
void | mprSetDomainName(cchar *s) |
Set the application domain name string. | |
void | mprSetEnv(cchar *key, cchar *value) |
Set an environment variable value. | |
void | mprSetExitStrategy(int strategy) |
Set the exit strategy for when the application terminates. | |
void | mprSetExitTimeout(MprTicks timeout) |
Set the exit timeout for a graceful shutdown or restart. | |
void | mprSetFilesLimit(int limit) |
Set the maximum number of open file/socket descriptors. | |
void | mprSetHostName(cchar *s) |
Set the application host name string. | |
MprIdleCallback | mprSetIdleCallback(MprIdleCallback idleCallback) |
Define a new idle callback to be invoked by mprIsIdle() | |
void | mprSetIpAddr(cchar *ip) |
Sete the application IP address string. | |
void* | mprSetItem(MprList *list, int index, cvoid *item) |
Set a list item. | |
int | mprSetListLimits(MprList *list, int initialSize, int maxSize) |
Define the list size limits. | |
void | mprSetLogBackup(ssize logSize, int backupCount, int flags) |
Set the log rotation parameters. | |
void | mprSetLogFile(struct MprFile *file) |
Set a file to be used for logging. | |
void | mprSetLogHandler(MprLogHandler handler) |
Set an MPR debug log handler. | |
void | mprSetLogLevel(int level) |
Set the current logging level. | |
void* | mprSetManager(void *ptr, MprManager manager) |
Update the manager for a block of memory. | |
int | mprSetMaxSocketAccept(int max) |
Set the maximum number of accepted client connections that are permissable. | |
void | mprSetMaxWorkers(int count) |
Set the maximum count of worker threads Set the maximum number of worker pool threads for the MPR. | |
void | mprSetMemError() |
Set an memory allocation error condition on a memory context. | |
void | mprSetMemLimits(ssize redline, ssize maxMemory) |
Configure the application memory limits. | |
void | mprSetMemNotifier(MprMemNotifier cback) |
Define a memory notifier. | |
void | mprSetMemPolicy(int policy) |
Set the memory allocation policy for when allocations fail. | |
int | mprSetMimeProgram(MprHash *table, cchar *mimeType, cchar *program) |
Set the mime type program. | |
void | mprSetMinWorkers(int count) |
Set the minimum count of worker threads Set the count of threads the worker pool will have. | |
void | mprSetModuleFinalizer(MprModule *module, MprModuleProc stop) |
Define a module finalizer that will be called before a module is stopped. | |
void | mprSetModuleSearchPath(char *searchPath) |
Set the module search path. | |
void | mprSetModuleTimeout(MprModule *module, MprTicks timeout) |
Set a module timeout. | |
void | mprSetOsError(int error) |
Set the O/S error code. | |
void | mprSetPathNewline(cchar *path, cchar *newline) |
Set the file system new line character string. | |
void | mprSetPathSeparators(cchar *path, cchar *separators) |
Set the file system path separators. | |
int | mprSetRomFileSystem(MprRomInode *inodeList) |
Set the ROM file system data. | |
void | mprSetServerName(cchar *s) |
Set the application server name string. | |
int | mprSetSocketBlockingMode(MprSocket *sp, bool on) |
Set the socket blocking mode. | |
void | mprSetSocketEof(MprSocket *sp, bool eof) |
Set an EOF condition on the socket. | |
int | mprSetSocketNoDelay(MprSocket *sp, bool on) |
Set the socket delay mode. | |
void | mprSetSslCaFile(struct MprSsl *ssl, cchar *caFile) |
Set the client certificate file to use for SSL. | |
void | mprSetSslCaPath(struct MprSsl *ssl, cchar *caPath) |
Set the path for the client certificate directory. | |
void | mprSetSslCertFile(struct MprSsl *ssl, cchar *certFile) |
Set certificate to use for SSL. | |
void | mprSetSslCiphers(MprSsl *ssl, cchar *ciphers) |
Set the ciphers to use. | |
void | mprSetSslKeyFile(struct MprSsl *ssl, cchar *keyFile) |
Set the key file to use for SSL. | |
void | mprSetSslProtocols(struct MprSsl *ssl, int protocols) |
Set the SSL protocol to use. | |
void | mprSetSslProvider(MprSsl *ssl, cchar *provider) |
Set the SSL provider to use. | |
void | mprSetThreadPriority(MprThread *thread, int priority) |
Set the thread priroity. | |
void | mprSetWorkerStackSize(int size) |
Set the default worker stack size. | |
bool | mprShouldAbortRequests() |
Test if requests should be aborted. | |
bool | mprShouldDenyNewRequests() |
Test if new requests should be denied. | |
void | mprSignalCond(MprCond *cond) |
Signal a condition lock variable. | |
void | mprSignalDispatcher(MprDispatcher *dispatcher) |
Signal the dispatcher to wakeup and re-examine its queues. | |
void | mprSignalMultiCond(MprCond *cond) |
Signal a condition lock variable for use with multiple waiters. | |
void | mprSignalTest2Complete(MprTestGroup *gp) |
Signal a test is complete. | |
void | mprSignalTestComplete(MprTestGroup *gp) |
Signal a test is complete. | |
void | mprSleep(MprTicks msec) |
Sleep for a while. | |
bool | mprSocketHandshaking(MprSocket *sp) |
Test if the socket is doing an SSL handshake. | |
bool | mprSocketHasBufferedRead(MprSocket *sp) |
Test if the socket has buffered read data. | |
bool | mprSocketHasBufferedWrite(MprSocket *sp) |
Test if the socket has buffered write data. | |
void | mprSort(void *base, ssize num, ssize width, MprSortProc compare, void *ctx) |
Quicksort. | |
MprList* | mprSortList(MprList *list, MprSortProc compare, void *ctx) |
Sort a list. | |
void | mprSpinLock(MprSpin *lock) |
Lock a spinlock. | |
void | mprSpinUnlock(MprSpin *lock) |
Unlock a spinlock. | |
int | mprStart() |
Start the Mpr services. | |
int | mprStartCmd(MprCmd *cmd, int argc, cchar **argv, cchar **envp, int flags) |
Start the command. | |
int | mprStartEventsThread() |
Start an thread dedicated to servicing events. | |
int | mprStartLogging(cchar *logSpec, int showConfig) |
Start logging. | |
int | mprStartModule(MprModule *mp) |
Start a module. | |
int | mprStartModuleService() |
Start the module service. | |
int | mprStartOsService() |
Start the O/S dependent subsystem. | |
int | mprStartThread(MprThread *thread) |
Start a thread. | |
int | mprStartWorker(MprWorkerProc proc, void *data) |
Start a worker thread. | |
int | mprStopCmd(MprCmd *cmd, int signal) |
Stop the command. | |
void | mprStopContinuousEvent(MprEvent *event) |
Stop an event. | |
int | mprStopModule(MprModule *mp) |
Stop a module. | |
void | mprStopModuleService() |
Stop the module service. | |
void | mprStopOsService() |
Stop the O/S dependent subsystem. | |
void | mprTerminate(int flags, int status) |
Terminate the application. | |
void | mprTrace(int level, cchar *fmt, ...) |
Write a trace message to the diagnostic log file. | |
char* | mprTransformPath(cchar *path, int flags) |
Transform a path. | |
char* | mprTrimPathDrive(cchar *path) |
Trim the drive from a path. | |
char* | mprTrimPathExt(cchar *path) |
Trim an extension from a path. | |
int | mprTruncateFile(cchar *path, MprOff size) |
Truncate a file. | |
bool | mprTryLock(MprMutex *lock) |
Attempt to lock access. | |
bool | mprTrySpinLock(MprSpin *lock) |
Attempt to lock access on a spin lock. | |
int | mprUnloadModule(MprModule *mp) |
Unload a module. | |
int | mprUnloadNativeModule(MprModule *mp) |
Unload a native module. | |
void | mprUnlock(MprMutex *lock) |
Unlock a mutex. | |
int | mprUpgradeSocket(MprSocket *sp, struct MprSsl *ssl, cchar *peerName) |
Upgrade a socket to use SSL/TLS. | |
char* | mprUriDecode(cchar *uri) |
Decode a URI string by de-scaping URI characters. | |
char* | mprUriDecodeInSitu(char *uri) |
Decode a URI string by de-scaping URI characters. | |
char* | mprUriEncode(cchar *uri, int map) |
Encode a string by escaping URI characters. | |
int | mprUsingDefaultLogHandler() |
Determine if the app is using the default MPR log handler. | |
void | mprValidateBlock(void *ptr) |
Validate a memory block and issue asserts if the memory block is not valid. | |
void | mprVerifyMem() |
Verify all memory. | |
void | mprVerifySslDepth(struct MprSsl *ssl, int depth) |
Control the depth of SSL SSL certificate verification. | |
void | mprVerifySslIssuer(struct MprSsl *ssl, bool on) |
Control the verification of SSL certificate issuers. | |
void | mprVerifySslPeer(struct MprSsl *ssl, bool on) |
Require verification of peer certificates. | |
void* | mprVirtAlloc(ssize size, int mode) |
Memory virtual memory into the applications address space. | |
void | mprVirtFree(void *ptr, ssize size) |
Free (unpin) a mapped section of virtual memory. | |
int | mprWaitForCmd(MprCmd *cmd, MprTicks timeout) |
Wait for the command to complete. | |
int | mprWaitForCond(MprCond *cond, MprTicks timeout) |
Wait for a condition lock variable. | |
int | mprWaitForEvent(MprDispatcher *dispatcher, MprTicks timeout) |
Wait for an event to occur on the given dispatcher. | |
void | mprWaitForIO(MprWaitService *ws, MprTicks timeout) |
Wait for I/O. | |
int | mprWaitForMultiCond(MprCond *cond, MprTicks timeout) |
Wait for a condition lock variable for use with multiple waiters. | |
int | mprWaitForSingleIO(int fd, int mask, MprTicks timeout) |
Wait for I/O on a file descriptor. | |
bool | mprWaitForTest2ToComplete(MprTestGroup *gp, MprTicks timeout) |
Wait for a test to complete. | |
bool | mprWaitForTestToComplete(MprTestGroup *gp, MprTicks timeout) |
Wait for a test to complete. | |
void | mprWaitOn(MprWaitHandler *wp, int desiredMask) |
Subscribe for desired wait events. | |
int | mprWaitTillIdle(MprTicks timeout) |
Wait until the application is idle. | |
void | mprWarn(cchar *fmt, ...) |
Log a warning message. | |
ssize | mprWriteCache(MprCache *cache, cchar *key, cchar *value, MprTime modified, MprTicks lifespan, int64 version, int options) |
Write a cache item. | |
ssize | mprWriteCmd(MprCmd *cmd, int channel, char *buf, ssize bufsize) |
Write data to an I/O channel. | |
ssize | mprWriteCmdBlock(MprCmd *cmd, int channel, char *buf, ssize bufsize) |
Write data to an I/O channel. | |
ssize | mprWriteFile(MprFile *file, cvoid *buf, ssize count) |
Write data to a file. | |
ssize | mprWriteFileFmt(MprFile *file, cchar *fmt, ...) |
Write formatted data to a file. | |
ssize | mprWriteFileString(MprFile *file, cchar *str) |
Write a string to a file. | |
ssize | mprWritePathContents(cchar *path, cchar *buf, ssize len, int mode) |
Create a file and write contents. | |
ssize | mprWriteSocket(MprSocket *sp, cvoid *buf, ssize len) |
Write to a socket. | |
ssize | mprWriteSocketString(MprSocket *sp, cchar *str) |
Write to a string to a socket. | |
ssize | mprWriteSocketVector(MprSocket *sp, MprIOVec *iovec, int count) |
Write a vector to a socket. | |
cchar* | mprXmlGetErrorMsg(MprXml *xp) |
Get the XML error message if mprXmlParse fails. | |
int | mprXmlGetLineNumber(MprXml *xp) |
Get the source XML line number. | |
void* | mprXmlGetParseArg(MprXml *xp) |
Get the XML callback argument. | |
MprXml* | mprXmlOpen(ssize initialSize, ssize maxSize) |
Open an XML parser instance. | |
int | mprXmlParse(MprXml *xp) |
Run the XML parser. | |
void | mprXmlSetInputStream(MprXml *xp, MprXmlInputStream fn, void *arg) |
Define the XML parser input stream. | |
void | mprXmlSetParseArg(MprXml *xp, void *parseArg) |
Set the XML callback argument. | |
void | mprXmlSetParserHandler(MprXml *xp, MprXmlHandler h) |
Set the XML parser data handle. | |
void | mprYield(int flags) |
Yield a thread to allow garbage collection. | |
void* | palloc(ssize size) |
Allocate a "permanent" block of memory that is not subject GC. | |
void | pfree(void *ptr) |
Free a "permanent" block of memory allocated via "palloc". | |
void* | prealloc(void *ptr, ssize size) |
Reallocate a "permanent" block of memory allocated via "palloc". | |
char* | scamel(cchar *str) |
Create a camel case version of the string. | |
int | scaselesscmp(cchar *s1, cchar *s2) |
Compare strings ignoring case. | |
bool | scaselessmatch(cchar *s1, cchar *s2) |
Compare strings ignoring case. | |
char* | schr(cchar *str, int c) |
Find a character in a string. | |
char* | sclone(cchar *str) |
Clone a string. | |
int | scmp(cchar *s1, cchar *s2) |
Compare strings. | |
char* | scontains(cchar *str, cchar *pattern) |
Find a pattern in a string. | |
ssize | scopy(char *dest, ssize destMax, cchar *src) |
Copy a string. | |
bool | sends(cchar *str, cchar *suffix) |
Test if the string ends with a given pattern. | |
char* | sfmt(cchar *fmt, ...) |
Format a string. | |
char* | sfmtv(cchar *fmt, va_list args) |
Format a string. | |
uint | shash(cchar *str, ssize len) |
Compute a hash code for a string. | |
uint | shashlower(cchar *str, ssize len) |
Compute a caseless hash code for a string. | |
char* | sjoin(cchar *str, ...) |
Catenate strings. | |
char* | sjoinv(cchar *str, va_list args) |
Catenate strings. | |
ssize | slen(cchar *str) |
Return the length of a string. | |
char* | slower(cchar *str) |
Convert a string to lower case. | |
bool | smatch(cchar *s1, cchar *s2) |
Compare strings. | |
int | sncaselesscmp(cchar *s1, cchar *s2, ssize len) |
Compare strings ignoring case. | |
char* | snclone(cchar *str, ssize len) |
Clone a substring. | |
int | sncmp(cchar *s1, cchar *s2, ssize len) |
Compare strings. | |
char* | sncontains(cchar *str, cchar *pattern, ssize limit) |
Find a pattern in a string with a limit. | |
ssize | sncopy(char *dest, ssize destMax, cchar *src, ssize len) |
Copy characters from a string. | |
char* | spascal(cchar *str) |
Create a Pascal case version of the string. | |
char* | spbrk(cchar *str, cchar *set) |
Locate the a character in a string. | |
char* | srchr(cchar *str, int c) |
Find a character in a string by searching backwards. | |
char* | srejoin(char *buf, ...) |
Append strings to an existing string and reallocate as required. | |
char* | srejoinv(char *buf, va_list args) |
Append strings to an existing string and reallocate as required. | |
ssize | sspn(cchar *str, cchar *set) |
Find the end of a spanning prefix. | |
bool | sstarts(cchar *str, cchar *prefix) |
Test if the string starts with a given pattern. | |
char* | ssub(cchar *str, ssize offset, ssize length) |
Create a substring. | |
char* | stemplate(cchar *str, struct MprHash *tokens) |
Replace template tokens in a string with values from a lookup table. | |
int64 | stoi(cchar *str) |
Convert a string to an integer. | |
int64 | stoiradix(cchar *str, int radix, int *err) |
Convert a string to an integer. | |
char* | stok(char *str, cchar *delim, char **last) |
Tokenize a string. | |
char* | strim(cchar *str, cchar *set, int where) |
Trim a string. | |
char* | supper(cchar *str) |
Convert a string to upper case. |
MprBufProc | Buffer refill callback function. |
MprCmdChild | Child status structure. |
MprCmdService | Command execution service. |
MprCond | Condition variable for single and multi-thread synchronization. |
MprDirEntry | Directory entry description. |
MprEventProc | Event callback function. |
MprForkCallback | Callback function before doing a fork(). |
MprFreeMem | Block structure when on a free list. |
MprHash | Hash table control structure. |
MprHashProc | Hashing function to use for the table. |
MprHeap | Memory allocator heap. |
MprIOVec | Vectored write array. |
MprJsonCallback | JSON callbacks. |
MprKeyValue | Key value pairs for use with MprList or MprKey. |
MprListCompareProc | List comparison procedure for sorting. |
MprLogHandler | Log handler callback type. |
MprManager | Mpr memory block manager prototype. |
MprMemNotifier | Memory allocation error callback. |
MprMemStats | Memory allocator statistics. |
MprModuleEntry | Loadable module entry point signature. |
MprModuleProc | Module start/stop point function signature. |
MprMutex | Multithreading lock control structure. |
MprObj | Object container for JSON parse trees. |
MprOff | Signed file offset data type. |
MprRegion | Memmory regions allocated from the O/S. |
MprRomInode | A RomInode is created for each file in the Rom file system. |
MprSignalInfo | Per signal structure. |
MprSignalProc | Signal callback procedure. |
MprSignalService | Signal service control. |
MprSocketPrebind | Callback before binding a socket. |
MprSocketProc | Socket I/O callback procedure. |
MprSocketProvider | Socket service provider interface. |
MprSocketService | Mpr socket service class. |
MprSortProc | Quicksort callback function. |
MprSpin | Multithreading spin lock control structure. |
MprTestCase | Test case structure. |
MprTestDef | Test case definition. |
MprTestFailure | Test failure record. |
MprTestGroup | A test group is a group of tests to cover a unit of functionality. |
MprTestParser | Callback parser for non-standard command line arguments. |
MprTestProc | Unit test callback procedure. |
MprThreadLocal | Thread local data storage. |
MprThreadProc | Thread main procedure. |
MprThreadService | Thread service. |
MprTicks | Elapsed time data type. |
MprWaitService | Wait Service. |
MprWorkerProc | Worker thread callback signature. |
MprWorkerService | Worker Thread Service. |
MprWorkerStats | Statistics for Workers. |
MprXmlHandler | XML callback handler. |
MprXmlInputStream | XML input stream function. |
#define | BIT_MPR_LOGGING 1 |
Default for logging is "on". | |
#define | MPR_ALLOC_MANAGER 0x1 |
Reserve room for a manager. | |
#define | MPR_ALLOC_PAD_MASK 0x1 |
Flags that impact padding. | |
#define | MPR_ALLOC_POLICY_EXIT 3 |
Exit the app if max exceeded with a MPR_EXIT_NORMAL exit. | |
#define | MPR_ALLOC_POLICY_NOTHING 0 |
Do nothing. | |
#define | MPR_ALLOC_POLICY_PRUNE 1 |
Prune all non-essential memory and continue. | |
#define | MPR_ALLOC_POLICY_RESTART 2 |
Gracefully restart the app if redline is exceeded. | |
#define | MPR_ALLOC_ZERO 0x2 |
Zero memory. | |
#define | MPR_ARGV_ARGS_ONLY 0x1 |
Command is missing program name. | |
#define | MPR_ASSERT_MSG 0x10 |
Originated from assert. | |
#define | MPR_BACKGROUND_PRIORITY 15 |
May only get CPU if idle. | |
#define | MPR_CACHE_ADD 0x2 |
Add key if not already existing. | |
#define | MPR_CACHE_APPEND 0x8 |
Set and append if already existing. | |
#define | MPR_CACHE_PREPEND 0x10 |
Set and prepend if already existing. | |
#define | MPR_CACHE_SET 0x4 |
Update key value, create if required. | |
#define | MPR_CACHE_SHARED 0x1 |
Use shared cache. | |
#define | MPR_CMD_DETACH 0x4 |
mprRunCmd flag to detach the child process and don't wait. | |
#define | MPR_CMD_ERR 0x4000 |
mprRunCmd flag to capture stdout. | |
#define | MPR_CMD_EXACT_ENV 0x8 |
mprRunCmd flag to use the exact environment (no inherit from parent). | |
#define | MPR_CMD_IN 0x1000 |
mprRunCmd flag to connect to stdin. | |
#define | MPR_CMD_NEW_SESSION 0x1 |
mprRunCmd flag to create a new session on unix. | |
#define | MPR_CMD_OUT 0x2000 |
mprRunCmd flag to capture stdout. | |
#define | MPR_CMD_SHOW 0x2 |
mprRunCmd flag to show the window of the created process on windows. | |
#define | MPR_CMD_STDERR 2 |
Stderr for the client side. | |
#define | MPR_CMD_STDIN 0 |
Stdout for the client side. | |
#define | MPR_CMD_STDOUT 1 |
Stdin for the client side. | |
#define | MPR_CMD_VXWORKS_EOF "_ _EOF_ _" |
Special string for VxWorks CGI to emit to signal EOF. | |
#define | MPR_CMD_VXWORKS_EOF_LEN 9 |
Length of MPR_CMD_VXWORKS_EOF. | |
#define | MPR_CONFIG 2 |
Configuration settings trace level. | |
#define | MPR_CRITICAL_PRIORITY 99 |
May not yield. | |
#define | MPR_DECODE_TOKEQ 1 |
Decode base 64 blocks up to a NULL or equals. | |
#define | MPR_DEFAULT_DATE "%a %b %d %T %Y %Z" |
Default date format used in mprFormatLocalTime/mprFormatUniversalTime when no format supplied. | |
#define | MPR_DEFAULT_MAX_THREADS 20 |
Default max threads. | |
#define | MPR_DEFAULT_MIN_THREADS 0 |
Default min threads. | |
#define | MPR_DISABLE_GC 0x1 |
Disable GC. | |
#define | MPR_DISPATCHER_AUTO_CREATE 0x8 |
Dispatcher is auto-created for incoming events. | |
#define | MPR_DISPATCHER_DESTROYED 0x4 |
Dispatcher is destroyed. | |
#define | MPR_DISPATCHER_ENABLED 0x1 |
Dispacher is enabled. | |
#define | MPR_DISPATCHER_WAITING 0x2 |
Dispatcher waiting for an event. | |
#define | MPR_ERR -1 |
Default error code. | |
#define | MPR_ERR_ABORTED -2 |
Action aborted. | |
#define | MPR_ERR_ALREADY_EXISTS -3 |
Item already exists. | |
#define | MPR_ERR_BAD_ARGS -4 |
Bad arguments or paramaeters. | |
#define | MPR_ERR_BAD_FORMAT -5 |
Bad input format. | |
#define | MPR_ERR_BAD_HANDLE -6 |
Bad file handle. | |
#define | MPR_ERR_BAD_STATE -7 |
Module is in a bad state. | |
#define | MPR_ERR_BAD_SYNTAX -8 |
Input has bad syntax. | |
#define | MPR_ERR_BAD_TYPE -9 |
Bad object type. | |
#define | MPR_ERR_BAD_VALUE -10 |
Bad or unexpected value. | |
#define | MPR_ERR_BASE -1 |
Base error code. | |
#define | MPR_ERR_BUSY -11 |
Resource is busy. | |
#define | MPR_ERR_CANT_ACCESS -12 |
Cannot access the file or resource. | |
#define | MPR_ERR_CANT_ALLOCATE -13 |
Cannot allocate resource. | |
#define | MPR_ERR_CANT_COMPLETE -14 |
Operation can't complete. | |
#define | MPR_ERR_CANT_CONNECT -15 |
Cannot connect to network or resource. | |
#define | MPR_ERR_CANT_CREATE -16 |
Cannot create the file or resource. | |
#define | MPR_ERR_CANT_DELETE -17 |
Cannot delete the resource. | |
#define | MPR_ERR_CANT_FIND -18 |
Cannot find resource. | |
#define | MPR_ERR_CANT_INITIALIZE -19 |
Cannot initialize resource. | |
#define | MPR_ERR_CANT_LOAD -20 |
Cannot load the resource. | |
#define | MPR_ERR_CANT_OPEN -21 |
Cannot open the file or resource. | |
#define | MPR_ERR_CANT_READ -22 |
Cannot read from the file or resource. | |
#define | MPR_ERR_CANT_WRITE -23 |
Cannot write to the file or resource. | |
#define | MPR_ERR_DELETED -24 |
Resource has been deleted. | |
#define | MPR_ERR_MEMORY -25 |
Memory allocation error. | |
#define | MPR_ERR_NETWORK -26 |
Underlying network error. | |
#define | MPR_ERR_NOT_INITIALIZED -27 |
Module or resource is not initialized. | |
#define | MPR_ERR_NOT_READY -28 |
Resource is not ready. | |
#define | MPR_ERR_OK 0 |
Success. | |
#define | MPR_ERR_READ_ONLY -29 |
The operation timed out. | |
#define | MPR_ERR_TIMEOUT -30 |
Operation exceeded specified time allowed. | |
#define | MPR_ERR_TOO_MANY -31 |
Too many requests or resources. | |
#define | MPR_ERR_WONT_FIT -32 |
Requested operation won't fit in available space. | |
#define | MPR_ERR_WOULD_BLOCK -33 |
Blocking operation would block. | |
#define | MPR_ERROR 1 |
Standard logging trace levels are 0 to 9 with 0 being the most verbose. | |
#define | MPR_ERROR_MSG 0x20 |
Originated from mprError. | |
#define | MPR_EVENT_CONTINUOUS 0x1 |
Timer event runs is automatically rescheduled. | |
#define | MPR_EVENT_DONT_QUEUE 0x4 |
Don't queue the event. | |
#define | MPR_EVENT_PRIORITY 50 |
Normal priority. | |
#define | MPR_EVENT_QUICK 0x2 |
Execute inline without executing via a thread. | |
#define | MPR_EVENT_RUNNING 0x10 |
Event currently executing. | |
#define | MPR_EVENT_STATIC_DATA 0x8 |
Event data is permanent and should not be marked by GC. | |
#define | MPR_EXIT_DEFAULT 0x1 |
Exit as per MPR->defaultStrategy. | |
#define | MPR_EXIT_GRACEFUL 0x8 |
Graceful shutdown waiting for requests to complete. | |
#define | MPR_EXIT_IMMEDIATE 0x2 |
Immediate exit. | |
#define | MPR_EXIT_NORMAL 0x4 |
Normal shutdown without waiting for requests to complete. | |
#define | MPR_EXIT_RESTART 0x10 |
Restart after exiting. | |
#define | MPR_FATAL_MSG 0x800 |
Fatal error, log and exit. | |
#define | MPR_FINISHED 0x8 |
Mpr object destroyed. | |
#define | MPR_GC_COMPLETE 0x2 |
mprRequestGC flags to do a complete collection (3 sweeps). | |
#define | MPR_GC_FORCE 0x1 |
mprRequestGC flags to force a GC whether it is required or not. | |
#define | MPR_GC_NO_BLOCK 0x4 |
mprRequestGC flags to not wait for the GC. | |
#define | MPR_GC_NO_YIELD 0x8 |
mprRequestGC flag to trigger GC but not yield. | |
#define | MPR_GEN_ETERNAL 3 |
Objects immune from collection. | |
#define | MPR_HASH_CASELESS 0x10 |
Key comparisons ignore case. | |
#define | MPR_HASH_LIST 0x100 |
Hash keys are numeric indicies. | |
#define | MPR_HASH_OWN 0x400 |
For own use. | |
#define | MPR_HASH_STATIC_KEYS 0x40 |
Keys are permanent - don't dup or mark. | |
#define | MPR_HASH_STATIC_VALUES 0x80 |
Values are permanent - don't mark. | |
#define | MPR_HASH_UNICODE 0x20 |
Hash keys are unicode strings. | |
#define | MPR_HASH_UNIQUE 0x200 |
Add to existing will fail. | |
#define | MPR_HTTP_DATE "%a, %d %b %Y %T GMT" |
Date format for use in HTTP (headers). | |
#define | MPR_INFO_MSG 0x40 |
Originated from mprInfo. | |
#define | MPR_JSON_ARRAY 3 |
The property is an array (MprHash with numeric keys). | |
#define | MPR_JSON_OBJ 2 |
The property is an object (MprHash). | |
#define | MPR_JSON_PRETTY 0x1 |
Serialize output in a more human readable, multiline "pretty" format. | |
#define | MPR_JSON_STRING 1 |
The property is a string (char*). | |
#define | MPR_JSON_UNKNOWN 0 |
The type of a property is unknown. | |
#define | MPR_LEVEL_MASK 0xf |
Level mask. | |
#define | MPR_LIST_STABLE 0x40 |
For own use. | |
#define | MPR_LIST_STATIC_VALUES 0x20 |
Flag for mprCreateList when values are permanent. | |
#define | MPR_LOCAL_TIMEZONE MAXINT |
Constants for mprParseTime. | |
#define | MPR_LOG_ANEW 0x20 |
Start anew on boot (rotate). | |
#define | MPR_LOG_APPEND 0x10 |
Append to existing log files. | |
#define | MPR_LOG_MSG 0x80 |
Originated from mprLog. | |
#define | MPR_MANAGE_FREE 0x1 |
Block being freed. | |
#define | MPR_MANAGE_MARK 0x2 |
Block being marked by GC. | |
#define | MPR_MARK_THREAD 0x4 |
Start a dedicated marker thread for garbage collection. | |
#define | MPR_MAX_GEN 3 |
Number of generations for object allocation. | |
#define | MPR_MEM_FAIL 0x4 |
Memory allocation failed - immediate exit. | |
#define | MPR_MEM_LIMIT 0x2 |
Memory use exceeds memory limit - invoking policy. | |
#define | MPR_MEM_REDLINE 0x1 |
Memory use exceeds redline limit. | |
#define | MPR_MEM_TOO_BIG 0x4 |
Memory allocation request is too big - immediate exit. | |
#define | MPR_MIN_TIME_FOR_GC 2 |
Wait till 2 milliseconds of idle time possible. | |
#define | MPR_MODULE_STARTED 0x1 |
Module stared. | |
#define | MPR_MODULE_STOPPED 0x2 |
Module stopped. | |
#define | MPR_NO_WINDOW 0x20 |
Don't create a windows Window. | |
#define | MPR_NORMAL_PRIORITY 50 |
Normal (default) priority. | |
#define | MPR_OBJ_HASH 0x1 |
Object is a hash. | |
#define | MPR_OBJ_LIST 0x1 |
Object is a hash. | |
#define | MPR_PATH_DEPTH_FIRST 0x2 |
Flag for mprGetPathFiles to do a depth-first traversal. | |
#define | MPR_PATH_DESCEND 0x1 |
Flag for mprGetPathFiles to traverse subdirectories. | |
#define | MPR_PATH_INC_HIDDEN 0x4 |
Flag for mprGetPathFiles to include hidden files. | |
#define | MPR_PATH_NODIRS 0x8 |
Flag for mprGetPathFiles to exclude subdirectories. | |
#define | MPR_PATH_RELATIVE 0x10 |
Flag for mprGetPathFiles to return paths relative to the directory. | |
#define | MPR_PROTO_ALL 0x1F |
All SSL protocols. | |
#define | MPR_PROTO_SSLV2 0x1 |
SSL V2 protocol. | |
#define | MPR_PROTO_SSLV3 0x2 |
SSL V3 protocol. | |
#define | MPR_PROTO_TLSV1 0x4 |
TLS V1 protocol. | |
#define | MPR_PROTO_TLSV11 0x8 |
TLS V1.1 protocol. | |
#define | MPR_PROTO_TLSV12 0x10 |
TLS V1.2 protocol. | |
#define | MPR_RAW_MSG 0x100 |
Raw message output. | |
#define | MPR_READABLE 0x2 |
Read event mask. | |
#define | MPR_REQUEST_PRIORITY 50 |
Normal priority. | |
#define | MPR_RFC_DATE "%a, %d %b %Y %T %Z" |
Format a date according to RFC822: (Fri, 07 Jan 2003 12:12:21 PDT). | |
#define | MPR_SERVICE_NO_GC 0x8 |
Don't run GC. | |
#define | MPR_SERVICE_ONE_THING 0x4 |
Wait for one event or one I/O. | |
#define | MPR_SIGNAL_AFTER 0x2 |
Flag to mprAddSignalHandler to run handler after existing handlers. | |
#define | MPR_SIGNAL_BEFORE 0x1 |
Flag to mprAddSignalHandler to run handler before existing handlers. | |
#define | MPR_SOCKET_BLOCK 0x1 |
Use blocking I/O. | |
#define | MPR_SOCKET_BROADCAST 0x2 |
Broadcast mode. | |
#define | MPR_SOCKET_BUFFERED_READ 0x800 |
Socket has buffered read data (in SSL stack). | |
#define | MPR_SOCKET_BUFFERED_WRITE 0x1000 |
Socket has buffered write data (in SSL stack). | |
#define | MPR_SOCKET_CHECKED 0x2000 |
Peer certificate has been checked. | |
#define | MPR_SOCKET_CLOSED 0x4 |
MprSocket has been closed. | |
#define | MPR_SOCKET_CONNECTING 0x8 |
MprSocket is connecting. | |
#define | MPR_SOCKET_DATAGRAM 0x10 |
Use datagrams. | |
#define | MPR_SOCKET_DISCONNECTED 0x4000 |
The mprDisconnectSocket has been called. | |
#define | MPR_SOCKET_EOF 0x20 |
Seen end of file. | |
#define | MPR_SOCKET_GRACEFUL 1 |
Do a graceful shutdown. | |
#define | MPR_SOCKET_HANDSHAKING 0x8000 |
Doing an SSL handshake. | |
#define | MPR_SOCKET_LISTENER 0x40 |
MprSocket is server listener. | |
#define | MPR_SOCKET_NODELAY 0x100 |
Disable Nagle algorithm. | |
#define | MPR_SOCKET_NOREUSE 0x80 |
Don't set SO_REUSEADDR option. | |
#define | MPR_SOCKET_SERVER 0x400 |
Socket is on the server-side. | |
#define | MPR_SOCKET_THREAD 0x200 |
Process callbacks on a worker thread. | |
#define | MPR_STARTED 0x1 |
Mpr services started. | |
#define | MPR_STOPPING 0x2 |
App is stopping. | |
#define | MPR_STOPPING_CORE 0x4 |
Stopping core services: GC and event dispatch. | |
#define | MPR_SWEEP_THREAD 0x8 |
Start a dedicated sweeper thread for garbage collection (unsupported). | |
#define | MPR_TICKS_PER_SEC 1000 |
Time ticks per second. | |
#define | MPR_TIMEOUT_GC_SYNC 100 |
Short wait period for threads to synchronize. | |
#define | MPR_TIMEOUT_LINGER 2000 |
Close socket linger timeout. | |
#define | MPR_TIMEOUT_NAP 20 |
Short pause. | |
#define | MPR_TIMEOUT_NO_BUSY 1000 |
Wait period to minimize CPU drain. | |
#define | MPR_TIMEOUT_PRUNER 120000 |
Time between worker thread pruner runs (2 min). | |
#define | MPR_TIMEOUT_START_TASK 10000 |
Time to start tasks running. | |
#define | MPR_TIMEOUT_STOP 30000 |
Default wait when stopping resources (30 sec). | |
#define | MPR_TIMEOUT_STOP_TASK 10000 |
Time to stop or reap tasks (vxworks). | |
#define | MPR_TIMEOUT_WORKER 60000 |
Prune worker that has been idle for 1 min. | |
#define | MPR_TRACE_MSG 0x200 |
Originated from mprTrace. | |
#define | MPR_TRIM_BOTH 0x3 |
Flag for strim to trim from both the start and the end of the string. | |
#define | MPR_TRIM_END 0x2 |
Flag for strim to trim from the end of the string. | |
#define | MPR_TRIM_START 0x1 |
Flag for strim to trim from the start of the string. | |
#define | MPR_USER_EVENTS_THREAD 0x10 |
User will explicitly manage own mprServiceEvents calls. | |
#define | MPR_UTC_TIMEZONE 0 |
Use UTC timezone. | |
#define | MPR_VERBOSE 9 |
Highest level of trace. | |
#define | MPR_WAIT_NEW_DISPATCHER 0x2 |
Wait handler flag to create a new dispatcher for each I/O event. | |
#define | MPR_WAIT_RECALL_HANDLER 0x1 |
Wait handler flag to recall the handler asap. | |
#define | MPR_WARN 2 |
Soft warning trace level. | |
#define | MPR_WARN_MSG 0x400 |
Originated from mprWarn. | |
#define | MPR_WORKER_BUSY 0x1 |
Worker currently running to a callback. | |
#define | MPR_WORKER_IDLE 0x4 |
Worker is sleeping (idle) on idleCond. | |
#define | MPR_WORKER_PRIORITY 50 |
Normal priority. | |
#define | MPR_WORKER_PRUNED 0x2 |
Worker has been pruned and will be terminated. | |
#define | MPR_WRITABLE 0x4 |
Write event mask. | |
#define | MPR_XML_AFTER_LS 2 |
Seen "<". | |
#define | MPR_XML_ATT_EQ 6 |
Seen "<tag att" =. | |
#define | MPR_XML_ATT_NAME 5 |
Seen "<tag att". | |
#define | MPR_XML_BEGIN 1 |
Before next tag. | |
#define | MPR_XML_CDATA 13 |
Seen "<![CDATA[" U. | |
#define | MPR_XML_COMMENT 3 |
Seen "<!–" (usr) U. | |
#define | MPR_XML_ELT_DATA 10 |
Seen "<tag>....<" U. | |
#define | MPR_XML_ELT_DEFINED 9 |
Seen "<tag...>" U. | |
#define | MPR_XML_END_ELT 11 |
Seen "<tag>....</tag>" U. | |
#define | MPR_XML_EOF -2 |
End of input. | |
#define | MPR_XML_ERR -1 |
Error. | |
#define | MPR_XML_NEW_ATT 7 |
Seen "<tag att = "val" U. | |
#define | MPR_XML_NEW_ELT 4 |
Seen "<tag" (usr) U. | |
#define | MPR_XML_PI 12 |
Seen "<?processingInst" U. | |
#define | MPR_XML_SOLO_ELT_DEFINED 8 |
Seen "<tag../>" U. | |
#define | MPR_YIELD_BLOCK 0x2 |
mprYield flag to yield and wait until GC the next GC occurs. | |
#define | MPR_YIELD_NO_BLOCK 0x1 |
mprYield flag to yield but do not wait. | |
#define | MPR_YIELD_STICKY 0x4 |
mprYield flag to yield and remain yielded until reset. | |
#define | tassert |
Assert macro for use by unit tests. | |
#define | tassert |
Assert macro for use by unit tests. |
Primary MPR application control structure.
char * | appDir | Path of directory containing app executable. | |
char * | appPath | Path name of application executable. | |
void * | appwebService | Appweb service object. | |
char ** | argBuf | Space for allocated argv. | |
int | argc | Count of command line args. | |
cchar ** | argv | Application command line args (not alloced). | |
bool | cmdlineLogging |
App has specified |
|
struct MprCmdService * | cmdService | Command service object. | |
MprCond * | cond | Sync after starting events thread. | |
bool | debugMode | Run in debug mode (no timers). | |
struct MprDispatcher * | dispatcher | Primary dispatcher. | |
char * | domainName | Domain portion. | |
void * | ediService | EDI object. | |
void * | ejsService | Ejscript service. | |
char * | emptyString | Empty string. | |
void * | espService | ESP service object. | |
int | eventing | Servicing events thread is active. | |
struct MprEventService * | eventService | Event service object. | |
int | exitStatus | Proposed program exit status. | |
int | exitStrategy | How to exit the app (normal, immediate, graceful). | |
MprTicks | exitTimeout | Request timeout when exiting. | |
struct MprFileSystem * | fileSystem | File system service object. | |
int | flags | Misc flags. | |
int | hasError | Mpr has an initialization error. | |
MprHeap * | heap | Memory heap control. | |
char * | hostName | Host name (fully qualified name). | |
void * | httpService | Http service object. | |
MprIdleCallback | idleCallback | Invoked to determine if the process is idle. | |
char * | ip | Public IP Address. | |
int | logBackup | Number of log files preserved when backing up. | |
MprFile * | logFile | Log file. | |
MprLogHandler | logHandler | Current log handler callback. | |
int | logLevel | Log trace level. | |
cchar * | logPath | Log path name. | |
ssize | logSize | Maximum log size. | |
MprOsThread | mainOsThread | Main OS thread ID. | |
MprHash * | mimeTypes | Table of mime types. | |
struct MprModuleService * | moduleService | Module service object. | |
MprMutex * | mutex | Thread synchronization. | |
char * | name | Product name. | |
struct MprDispatcher * | nonBlock | Nonblocking dispatcher. | |
struct MprOsService * | osService | O/S service object. | |
char * | pathEnv | Cached PATH env var. Used by MprCmd. | |
char * | serverName | Server name portion (no domain). | |
struct MprSignalService * | signalService | Signal service object. | |
struct MprSocketService * | socketService | Socket service object. | |
MprSpin * | spin | Quick thread synchronization. | |
MprTime | start | When the MPR started. | |
int | state | Processing state. | |
MprFile * | stdError | Standard error file. | |
MprFile * | stdInput | Standard input file. | |
MprFile * | stdOutput | Standard output file. | |
MprList * | terminators | Termination callbacks. | |
void * | testService | Test service object. | |
struct MprThreadService * | threadService | Thread service object. | |
MprHash * | timeTokens | Date/Time parsing tokens. | |
char * | title | Product title. | |
int | verifySsl | Default verification of SSL certificates. | |
char * | version | Product version. | |
struct MprWaitService * | waitService | IO Waiting service object. | |
struct MprWorkerService * | workerService | Worker service object. |
Assert that a condition is true.
cond | Boolean result of a conditional test. |
Add a terminator callback.
terminator | MprTerminator callback function. |
Trigger a breakpoint.
Create an instance of the MPR.
argc | Count of command line args. |
argv | Command line arguments for the application. Arguments may be passed into the Mpr for retrieval by the unit test framework. |
flags |
Create and initialze the O/S dependent subsystem.
Decode a null terminated string using base-46 encoding.
Decoding will terminate at the first null or '='str | String to decode. |
Decode a null terminated string using base-46 encoding.
buf | String to decode. |
len | Return parameter with the Length of the decoded data. |
flags | Set to MPR_DECODE_TOKEQ to stop at the first '='. |
Reference to a permanent preallocated empty string.
Encode a string using base-46 encoding.
str | String to encode. |
Encode buffer using base-46 encoding.
buf | Buffer to encode. |
len | Length of the buffer to encode. |
Encode a string escaping typical command (shell) characters.
cmd | Command string to encode. |
escChar | Escape character to use when encoding the command. |
Encode a string by escaping typical HTML characters.
html | HTML content to encode. |
Get the application directory.
Get the application name defined via mprSetAppName.
Get the application executable path.
Get the application title string.
Get the application version string.
Get if command line logging is being used.
Get the debug mode.
Get the application domain name string.
Return the endian byte ordering for the application.
Return the error code for the most recent system or library operation.
Get the exit status.
Get the application host name string.
Get the application IP address string.
Get the current logging level.
Get an MD5 checksum.
str | String to examine. |
Get an MD5 checksum with optional prefix string and buffer length.
buf | Buffer to checksum. |
len | Size of the buffer. |
prefix | String prefix to insert at the start of the result. |
Return the MPR control instance.
Return the O/S error code.
Get some random data.
buf | Reference to a buffer to hold the random data. |
size | Size of the buffer. |
block | Set to true if it is acceptable to block while accumulating entropy sufficient to provide good random data. Setting to false will cause this API to not block and may return random data of a lower quality. |
Get the application server name string.
Get an SHA1 checksum.
str | String to examine. |
Get an SHA1 checksum of a null terminated string.
str | String to checksum. |
Get an SHA1 checksum with optional prefix string and buffer length.
buf | Buffer to checksum. |
len | Size of the buffer. |
prefix | String prefix to insert at the start of the result. |
Determine if the MPR is exiting.
Determine if the MPR has finished.
Determine if the App is idle.
Test if the application is stopping.
Test if the application is stopping and core services are being terminated.
Make a argv style array of command arguments.
command | Command string to parse. |
argv | Output parameter containing the parsed arguments. |
flags | Set to MPR_ARGV_ARGS_ONLY if the command string does not contain a program name. In this case, argv[0] will be set to "". |
Nap for a while.
msec | Number of milliseconds to sleep. |
Make a argv style array of command arguments.
command | Command string to parse. |
argv | Array for the arguments. |
maxArgs | Size of the argv array. |
Return a random number.
Restart the application.
Determine if the MPR services.
Set the application name, title and version.
name | One word, lower case name for the app. |
title | Pascal case multi-word descriptive name. |
version | Version of the app. Major-Minor-Patch. E.g. 1.2.3. |
Set the application executable path.
path | A string containing the application executable path. |
Set if command line logging was requested.
on | Set to true to indicate command line logging is being used. |
Turn on debug mode.
on | Set to true to enable debugging mode. |
Set the application domain name string.
s | New value to use for the application domain name. |
Set an environment variable value.
key | Variable name. |
value | Variable value. |
Set the exit strategy for when the application terminates.
strategy | Set strategy to MPR_EXIT_IMMEDIATE for the application to exit immediately when terminated. Set to MPR_EXIT_GRACEFUL for the application to exit gracefully after allowing all current requests to complete before terminating. |
Set the exit timeout for a graceful shutdown or restart.
A graceful shutdown waits for existing requests to complete before exitingtimeout | Time in milliseconds to wait when terminating the MPR. |
Set the maximum number of open file/socket descriptors.
limit | Limit to enforce. |
Set the application host name string.
This is internal to the application and does not affect the O/S host names | New host name to use within the application. |
Define a new idle callback to be invoked by mprIsIdle()
idleCallback | Callback function to invoke to test if the application is idle. |
Sete the application IP address string.
ip | IP address string to store for the application. |
Set the O/S error code.
Set the application server name string.
s | New application server name to use within the application. |
Test if requests should be aborted.
Test if new requests should be denied.
This is useful in denying new requests when doing a graceful shutdown while continuing to service existing requestsSleep for a while.
msec | Number of milliseconds to sleep. |
Start the Mpr services.
Start an thread dedicated to servicing events.
This will create a new thread and invoke mprServiceEventsStart the O/S dependent subsystem.
Stop the O/S dependent subsystem.
Terminate the application.
flags | Termination control flags. Use MPR_EXIT_IMMEDIATE for an immediate abortive shutdown. Finalizers will not be run. Use MPR_EXIT_NORMAL to allow garbage collection and finalizers to run. Use MPR_EXIT_GRACEFUL to allow all current requests and commands to complete before exiting. |
status | Proposed program exit status. |
Decode a URI string by de-scaping URI characters.
uri | URI to decode. |
Decode a URI string by de-scaping URI characters.
uri | URI to decode. |
Encode a string by escaping URI characters.
uri | URI to encode. |
map | Map to encode characters. Select from MPR_ENCODE_URI or MPR_ENCODE_URI_COMPONENT. |
Wait until the application is idle.
timeout | Time in milliseconds to wait for the application to be idle. |
Dynamic Buffer Module.
ssize | buflen | Current size of buffer. | |
char * | data | Actual buffer for data. | |
char * | end | Pointer one past the last data chr. | |
char * | endbuf | Pointer one past the end of buffer. | |
ssize | growBy | Next growth increment to use. | |
ssize | maxsize | Max size the buffer can ever grow. | |
void * | refillArg | Refill arg - must be alloced memory. | |
MprBufProc | refillProc | Auto-refill procedure. | |
char * | start | Pointer to next data char. |
Add a null character to the buffer contents.
buf | Buffer created via mprCreateBuf. |
Adjust the buffer end position.
buf | Buffer created via mprCreateBuf. |
count | Positive or negative count of bytes to adjust the end position. |
Adjust the buffer start position.
buf | Buffer created via mprCreateBuf. |
count | Positive or negative count of bytes to adjust the start position. |
Convert the buffer contents to a string.
buf | Buffer created via mprCreateBuf. |
Compact the buffer contents.
buf | Buffer created via mprCreateBuf. |
Create a new buffer.
initialSize | Initial size of the buffer. |
maxSize | Maximum size the buffer can grow to. |
Flush the buffer contents.
buf | Buffer created via mprCreateBuf. |
Get a block of data from the buffer.
buf | Buffer created via mprCreateBuf. |
blk | Destination block for the read data. |
count | Count of bytes to read from the buffer. |
Get the origin of the buffer content storage.
buf | Buffer created via mprCreateBuf. |
Get a reference to the end of the buffer contents.
buf | Buffer created via mprCreateBuf. |
Get the buffer content length.
buf | Buffer created via mprCreateBuf. |
Get the buffer refill procedure.
buf | Buffer created via mprCreateBuf. |
Get the current size of the buffer content storage.
buf | Buffer created via mprCreateBuf. |
Get the space available to store content.
buf | Buffer created via mprCreateBuf. |
Get the start of the buffer contents.
buf | Buffer created via mprCreateBuf. |
Get a character from the buffer.
buf | Buffer created via mprCreateBuf. |
Grow the buffer.
buf | Buffer created via mprCreateBuf. |
count | Count of bytes by which to grow the buffer content size. |
Insert a character into the buffer.
buf | Buffer created via mprCreateBuf. |
c | Character to append. |
Peek at the last character in the buffer.
buf | Buffer created via mprCreateBuf. |
Peek at the next character in the buffer.
buf | Buffer created via mprCreateBuf. |
Put a block to the buffer.
buf | Buffer created via mprCreateBuf. |
ptr | Block to append. |
size | Size of block to append. |
Put a character to the buffer.
buf | Buffer created via mprCreateBuf. |
c | Character to append. |
Put an integer to the buffer.
buf | Buffer created via mprCreateBuf. |
i | Integer to append to the buffer. |
Put padding characters to the buffer.
buf | Buffer created via mprCreateBuf. |
c | Character to append. |
count | Count of pad characters to put. |
Put a string to the buffer.
buf | Buffer created via mprCreateBuf. |
str | String to append. |
Put a substring to the buffer.
buf | Buffer created via mprCreateBuf. |
str | String to append. |
count | Put at most count characters to the buffer. |
Put a formatted string to the buffer.
buf | Buffer created via mprCreateBuf. |
fmt | Printf style format string. |
... | Variable arguments for the format string. |
Refill the buffer with data.
buf | Buffer created via mprCreateBuf. |
Reset the buffer.
buf | Buffer created via mprCreateBuf. |
Set the maximum buffer size.
buf | Buffer created via mprCreateBuf. |
maxSize | New maximum size the buffer can grow to. |
Set the buffer refill procedure.
buf | Buffer created via mprCreateBuf. |
fn | Callback function to store. |
arg | Callback data argument. |
Set the buffer size.
buf | Buffer created via mprCreateBuf. |
size | Size to immediately make the buffer. If size is less than the current buffer size, it will be ignored. Set to -1 to ignore this parameter. |
maxSize | Maximum size the buffer contents can grow to. |
In-memory caching.
MprTicks | lifespan | Default lifespan (msec). | |
ssize | maxKeys | Max number of keys. | |
ssize | maxMem | Max memory for session data. | |
MprMutex * | mutex | Cache lock. | |
int | resolution | Frequence for pruner. | |
struct MprCache * | shared | Shared common cache. | |
MprHash * | store | Key/value store. | |
MprEvent * | timer | Pruning timer. | |
ssize | usedMem | Memory in use for keys and data. |
Create a new cache object.
options | Set of option flags. Select from MPR_CACHE_SHARED, MPR_CACHE_ADD, MPR_CACHE_ADD, MPR_CACHE_SET, MPR_CACHE_APPEND, MPR_CACHE_PREPEND |
Destroy a new cache object.
cache | The cache instance object returned from mprCreateCache |
Set the expiry date for a cache item.
cache | The cache instance object returned from mprCreateCache |
key | Cache item key. |
expires | Time when the cache item will expire. If expires is zero, the item is immediately removed from the cache. |
Increment a numeric cache item.
cache | The cache instance object returned from mprCreateCache |
key | Cache item key. |
amount | Numeric amount to increment the cache item. This may be a negative number to decrement the item. |
Prune the cache.
cache | The cache instance object returned from mprCreateCache |
Read an item from the cache.
cache | The cache instance object returned from mprCreateCache |
key | Cache item key. |
modified | Optional MprTime value reference to receive the last modified time of the cache item. Set to null if not required. |
version | Optional int64 value reference to receive the version number of the cache item. Set to null if not required. Cache items have a version number that is incremented every time the item is updated. |
Remove items from the cache.
cache | The cache instance object returned from mprCreateCache |
key | Cache item key. If set to null, then remove all keys from the cache. |
Set the cache resource limits.
cache | The cache instance object returned from mprCreateCache |
keys | Set the maximum number of keys the cache can store. |
lifespan | Set the default lifespan for cache items in milliseconds. |
memory | Memory limit in bytes for all cache keys and items. |
resolution | Set the cache item pruner resolution. This defines how frequently the cache manager will check items for expiration. |
Write a cache item.
cache | The cache instance object returned from mprCreateCache |
key | Cache item key to write. |
value | Value to set for the cache item. |
modified | Value to set for the cache last modified time. If set to zero, the current time is obtained via mprGetTime |
lifespan | Lifespan of the item in milliseconds. The item will be removed from the cache by the Cache manager when the lifetime expires unless it is rewritten to extend the lifespan. |
version | Expected version number of the item. This is used to do transactional writes to the cache item. First the version number is retrieved via mprReadCache and that version number is supplied to mprWriteCache when the item is updated. If another caller updates the item in between the read/write, the version number will not match when the item is subsequently written and this call will fail with the MPR_ERR_BAD_STATE return code. Set to zero if version checking is not required. |
options | Options to control how the item value is updated. Use MPR_CACHE_SET to update the cache item and create if it does not exist. Use MPR_CACHE_ADD to add the item only if it does not already exits. Use MPR_CACHE_APPEND to append the parameter value to any existing cache item value. Use MPR_CACHE_PREPEND to prepend the value. |
Command execution Service.
int | argc | Count of args in argv. | |
cchar ** | argv | List of args. Null terminated. | |
MprCmdProc | callback | Handler for client output and completion. | |
int | complete | All channels EOF and status gathered. | |
cchar ** | defaultEnv | Environment to use if no env passed to mprStartCmd. | |
char * | dir | Current working dir for the process. | |
MprDispatcher * | dispatcher | Dispatcher to use for wait events. | |
MprList * | env | List of environment variables. Null terminated. | |
int | eofCount | Count of end-of-files. | |
MprCmdFile | files[MPR_CMD_MAX_PIPE] | Stdin, stdout for the command. | |
int | flags | Control flags (userFlags not here). | |
MprForkCallback | forkCallback | Forked client callback. | |
cchar ** | makeArgv | Allocated argv. | |
MprMutex * | mutex | Multithread sync. | |
int | pid | Process ID of the created process. | |
int | pid2 | Persistent copy of the pid. | |
cchar * | program | Program path name. | |
int | requiredEof | Number of EOFs required for an exit. | |
char * | searchPath | Search path to use to locate the command. | |
MprSignal * | signal | Signal handler for SIGCHLD. | |
int | status | Command exit status. | |
MprBuf * | stderrBuf | Standard error output from the client. | |
MprBuf * | stdoutBuf | Standard output from the client. | |
int | stopped | Command stopped. | |
int | timedout | Request has timedout. | |
void * | userData | User data storage. | |
int | userFlags | User flags storage. |
Return true if command events are enabled.
cmd | MprCmd object created via mprCreateCmd. |
channel | Channel number to close. Should be either MPR_CMD_STDIN, MPR_CMD_STDOUT or MPR_CMD_STDERR. |
Close the command channel.
cmd | MprCmd object created via mprCreateCmd. |
channel | Channel number to close. Should be either MPR_CMD_STDIN, MPR_CMD_STDOUT or MPR_CMD_STDERR. |
Create a new Command object.
Destroy the command.
cmd | MprCmd object created via mprCreateCmd. |
Disable command I/O events.
This disables events on a given channelcmd | MprCmd object created via mprCreateCmd. |
channel | Channel number to close. Should be either MPR_CMD_STDIN, MPR_CMD_STDOUT or MPR_CMD_STDERR. |
Disconnect a command its underlying I/O channels.
This is used to prevent further I/O wait events while still preserving the MprCmd objectcmd | MprCmd object created via mprCreateCmd. |
Enable command I/O events.
This enables events on a given channelcmd | MprCmd object created via mprCreateCmd. |
channel | Channel number to close. Should be either MPR_CMD_STDIN, MPR_CMD_STDOUT or MPR_CMD_STDERR. |
Enable command I/O events for the command's STDOUT and STDERR channels.
cmd | MprCmd object created via mprCreateCmd. |
on | Set to true to enable events. Set to false to disable. |
Finalize the writing of data to the command process.
cmd | MprCmd object created via mprCreateCmd. |
Get the underlying buffer for a channel.
cmd | MprCmd object created via mprCreateCmd. |
channel | Channel number to close. Should be either MPR_CMD_STDIN, MPR_CMD_STDOUT or MPR_CMD_STDERR. |
Get the command exit status.
cmd | MprCmd object created via mprCreateCmd. |
Get the underlying file descriptor for an I/O channel.
cmd | MprCmd object created via mprCreateCmd. |
channel | Channel number to close. Should be either MPR_CMD_STDIN, MPR_CMD_STDOUT or MPR_CMD_STDERR. |
Test if the command is still running.
cmd | MprCmd object created via mprCreateCmd. |
Poll for I/O on the command pipes.
This is only used on windows which can't adequately detect EOF on a named pipecmd | MprCmd object created via mprCreateCmd. |
timeout | Time in milliseconds to wait for the command to complete and exit. |
Make the I/O channels to send and receive data to and from the command.
cmd | MprCmd object created via mprCreateCmd. |
channel | Channel number to read from. Should be either MPR_CMD_STDIN, MPR_CMD_STDOUT or MPR_CMD_STDERR. |
buf | Buffer to read into. |
bufsize | Size of buffer. |
Reap the command.
This waits for and collect the command exit statuscmd | MprCmd object created via mprCreateCmd. |
timeout | Time in milliseconds to wait for the command to complete and exit. |
Run a command using a string command line.
This starts the command via mprStartCmd() and waits for its completioncmd | MprCmd object created via mprCreateCmd. |
command | Command line to run. |
envp | Array of environment strings. Each environment string should be of the form: "KEY=VALUE". The array must be null terminated. |
out | Reference to a string to receive the stdout from the command. |
err | Reference to a string to receive the stderr from the command. |
timeout | Time in milliseconds to wait for the command to complete and exit. |
flags | Flags to modify execution. Valid flags are: MPR_CMD_NEW_SESSION Create a new session on Unix MPR_CMD_SHOW Show the commands window on Windows MPR_CMD_IN Connect to stdin MPR_CMD_EXACT_ENV Use the exact environment supplied. Don't inherit and blend with existing environment. |
Run a command using an argv[] array of arguments.
This invokes mprStartCmd() and waits for its completioncmd | MprCmd object created via mprCreateCmd. |
argc | Count of arguments in argv. |
argv | Command arguments array. |
envp | Array of environment strings. Each environment string should be of the form: "KEY=VALUE". The array must be null terminated. |
out | Reference to a string to receive the stdout from the command. |
err | Reference to a string to receive the stderr from the command. |
timeout | Time in milliseconds to wait for the command to complete and exit. |
flags | Flags to modify execution. Valid flags are: MPR_CMD_NEW_SESSION Create a new session on Unix MPR_CMD_SHOW Show the commands window on Windows MPR_CMD_IN Connect to stdin. |
Define a callback to be invoked to receive response data from the command.
cmd | MprCmd object created via mprCreateCmd. |
callback | Function of the signature MprCmdProc which will be invoked for receive notification for data from the commands stdout and stderr channels. MprCmdProc has the signature: int callback(MprCmd *cmd, int channel, void *data) {}. |
data | User defined data to be passed to the callback. |
Set the default environment to use for commands.
cmd | MprCmd object created via mprCreateCmd. |
env | Array of environment "KEY=VALUE" strings. Null terminated. |
Set the home directory for the command.
cmd | MprCmd object created via mprCreateCmd. |
dir | String directory path name. |
Set the command environment.
cmd | MprCmd object created via mprCreateCmd. |
env | Array of environment strings. Each environment string should be of the form: "KEY=VALUE". The array must be null terminated. |
Set the default command search path.
cmd | MprCmd object created via mprCreateCmd. |
search | Search string. This is in a format similar to the PATH environment variable. |
Start the command.
This starts the command but does not wait for its completion. Once started, mprWriteCmd can be used to write to the command and response data can be received via mprReadCmdcmd | MprCmd object created via mprCreateCmd. |
argc | Count of arguments in argv. |
argv | Command arguments array. |
envp | Array of environment strings. Each environment string should be of the form: "KEY=VALUE". The array must be null terminated. |
flags | Flags to modify execution. Valid flags are: MPR_CMD_NEW_SESSION Create a new session on Unix MPR_CMD_SHOW Show the commands window on Windows MPR_CMD_IN Connect to stdin. |
Stop the command.
The command is immediately killedcmd | MprCmd object created via mprCreateCmd. |
signal | Signal to send to the command to kill if required. |
Wait for the command to complete.
cmd | MprCmd object created via mprCreateCmd. |
timeout | Time in milliseconds to wait for the command to complete and exit. |
Write data to an I/O channel.
cmd | MprCmd object created via mprCreateCmd. |
channel | Channel number to read from. Should be either MPR_CMD_STDIN, MPR_CMD_STDOUT or MPR_CMD_STDERR. |
buf | Buffer to read into. |
bufsize | Size of buffer. |
Write data to an I/O channel.
cmd | MprCmd object created via mprCreateCmd. |
channel | Channel number to read from. Should be either MPR_CMD_STDIN, MPR_CMD_STDOUT or MPR_CMD_STDERR. |
buf | Buffer to read into. |
bufsize | Size of buffer. |
Event Dispatcher.
MprCond * | cond | Multi-thread sync. | |
MprEvent * | currentQ | Currently executing events. | |
MprEvent * | eventQ | Event queue. | |
int | flags | Dispatcher control flags. | |
cchar * | name | Dispatcher name / purpose. | |
struct MprDispatcher * | next | Next dispatcher linkage. | |
MprOsThread | owner | Owning thread of the dispatcher. | |
struct MprDispatcher * | parent | Queue pointer. | |
struct MprDispatcher * | prev | Previous dispatcher linkage. | |
struct MprWorker * | requiredWorker | Worker affinity. | |
struct MprEventService * | service | Event service reference. |
Create a new event dispatcher.
name | Useful name for debugging. |
flags | Initial dispatcher flags. Set MPR_DISPATCHER_ENABLED to enable. |
Disable a dispatcher from service events.
This removes the dispatcher from any dispatcher queues and allows it to be garbage collecteddispatcher | Dispatcher to disable. |
Enable a dispatcher to service events.
The mprCreateDispatcher routiner may create a dispatchers in the disabled state. Use mprEnableDispatcher to enable them to begin servicing eventsdispatcher | Dispatcher to enable. |
Get the MPR primary dispatcher.
Service events.
This can be called by any thread. Typically an app will dedicate one thread to be an event service thread. This call will service events until the timeout expires or if MPR_SERVICE_ONE_THING is specified in flags, after one event. This will service all enabled dispatcher queues and pending I/O eventsdelay | Time in milliseconds to wait. Set to zero for no wait. Set to -1 to wait forever. |
flags | If set to MPR_SERVICE_ONE_THING, this call will service at most one event. Otherwise set to zero. |
Signal the dispatcher to wakeup and re-examine its queues.
dispatcher | Event dispatcher to monitor. |
Wait for an event to occur on the given dispatcher.
dispatcher | Event dispatcher to monitor. |
timeout | for waiting in milliseconds. |
Event object.
void * | data | Event private data. | |
struct MprDispatcher * | dispatcher | Event dispatcher service. | |
MprTicks | due | When is the event due. | |
int | flags | Event flags. | |
struct MprWaitHandler * | handler | Optional wait handler. | |
int | mask | I/O mask of events. | |
cchar * | name | Static debug name of the event. | |
struct MprEvent * | next | Next event linkage. | |
MprTicks | period | Reschedule period. | |
struct MprEvent * | prev | Previous event linkage. | |
MprEventProc | proc | Callback procedure. | |
MprTicks | timestamp | When was the event created. |
Create a new event.
dispatcher | Dispatcher object created via mprCreateDispatcher. |
name | Debug name of the event. |
period | Time in milliseconds used by continuous events between firing of the event. |
proc | Function to invoke when the event is run. |
data | Data to associate with the event and stored in event->data. The data must be either an allocated memory object or MPR_EVENT_STATIC_DATA must be specified in flags. |
flags | Flags to modify the behavior of the event. Valid values are: MPR_EVENT_CONTINUOUS to create an event which will be automatically rescheduled accoring to the specified period. Use MPR_EVENT_STATIC_DATA if the data argument does not point to an allocated memory object. |
Create an event outside the MPR.
dispatcher | Dispatcher object created via mprCreateDispatcher. |
proc | Function to invoke when the event is run. |
data | Data to associate with the event and stored in event->data. The data must be non-MPR memory. |
Create a timer event.
dispatcher | Dispatcher object created via mprCreateDispatcher |
name | Debug name of the event. |
proc | Function to invoke when the event is run. |
period | Time in milliseconds used by continuous events between firing of the event. |
data | Data to associate with the event and stored in event->data. |
flags | Not used. |
Enable or disable an event being continous.
event | Event object returned from mprCreateEvent |
enable | Set to 1 to enable continous scheduling of the event. |
Remove an event.
event | Event object returned from mprCreateEvent |
Reschedule an event.
event | Event object returned from mprCreateEvent |
period | Time in milliseconds used by continuous events between firing of the event. |
Restart an event.
event | Event object returned from mprCreateEvent |
Stop an event.
event | Event object returned from mprCreateEvent |
File I/O Module.
int | attached | Attached to existing descriptor. | |
MprBuf * | buf | Buffer for I/O if buffered. | |
int | fd | File handle. | |
MprFileSystem * | fileSystem | File system owning this file. | |
MprRomInode * | inode | Reference to ROM file. | |
MprOff | iopos | Raw I/O position. | |
int | mode | File open mode. | |
char * | path | Filename. | |
int | perms | File permissions. | |
MprOff | pos | Current read position. | |
MprOff | size | Current file size. |
Attach to an existing file descriptor.
fd | File descriptor to attach to. |
name | Descriptive name for the file. |
omode | Posix style file open mode mask. The open mode may contain the following mask values ored together:
|
Close a file.
file | File instance returned from mprOpenFile |
Disable file buffering.
file | File instance returned from mprOpenFile |
Enable file buffering.
file | File instance returned from mprOpenFile |
size | Size to allocate for the buffer. |
maxSize | Maximum size the data buffer can grow to. |
Flush any buffered write data.
file | Pointer to an MprFile object returned via MprOpen. |
Read a character from the file.
file | Pointer to an MprFile object returned via MprOpen. |
Get the file descriptor for a file.
file | File object returned via mprOpenFile |
Return the current file position.
file | A file object returned from mprOpenFile |
Get the size of the file.
file | A file object returned from mprOpenFile |
Return a file object for the Stderr I/O channel.
Return a file object for the Stdin I/O channel.
Return a file object for the Stdout I/O channel.
Open a file.
filename | String containing the filename to open or create. |
omode | Posix style file open mode mask. The open mode may contain the following mask values ored together:
|
perms | Posix style file permissions mask. |
Non-destructively read a character from the file.
file | Pointer to an MprFile object returned via MprOpen. |
Write a character to the file.
file | Pointer to an MprFile object returned via MprOpen. |
c | Character to write. |
Write a string to the file.
file | Pointer to an MprFile object returned via MprOpen. |
str | String to write. |
Read data from a file.
file | Pointer to an MprFile object returned via MprOpen. |
buf | Buffer to contain the read data. |
size | Size of buf in characters. |
Read a line from the file.
file | Pointer to an MprFile object returned via MprOpen. |
size | Maximum number of characters in a line. |
len | Pointer to an integer to hold the length of the returned string. |
Seek the I/O pointer to a new location in the file.
file | Pointer to an MprFile object returned via MprOpen. |
seekType | Seek type may be one of the following three values:
|
distance | A positive or negative byte offset. |
Truncate a file.
path | File to truncate. |
size | New maximum size for the file. |
Write data to a file.
file | Pointer to an MprFile object returned via MprOpen. |
buf | Buffer containing the data to write. |
count | Cound of characters in buf to write. |
Write formatted data to a file.
file | Pointer to an MprFile object returned via MprOpen. |
fmt | Format string. |
Write a string to a file.
file | Pointer to an MprFile object returned via MprOpen. |
str | String to write. |
File system service.
MprAccessFileProc | accessPath | Virtual access file routine. | |
bool | caseSensitive | Path comparisons are case sensitive. | |
MprCloseFileProc | closeFile | Virtual close file routine. | |
MprDeleteFileProc | deletePath | Virtual delete file routine. | |
MprGetPathInfoProc | getPathInfo | Virtual get file information routine. | |
MprGetPathLinkProc | getPathLink | Virtual get the symbolic link target. | |
bool | hasDriveSpecs | Paths can have drive specifications. | |
MprMakeDirProc | makeDir | Virtual make directory routine. | |
MprMakeLinkProc | makeLink | Virtual make link routine. | |
char * | newline | Newline for text files. | |
MprOpenFileProc | openFile | Virtual open file routine. | |
MprReadFileProc | readFile | Virtual read file routine. | |
cchar * | root | Root file path. | |
MprSeekFileProc | seekFile | Virtual seek file routine. | |
char * | separators | Filename path separators. First separator is the preferred separator. | |
MprSetBufferedProc | setBuffered | Virtual set buffered I/O routine. | |
MprTruncateFileProc | truncateFile | Virtual truncate file routine. | |
MprWriteFileProc | writeFile | Virtual write file routine. |
Create and initialize the disk FileSystem.
fs | File system object. |
Create and initialize the FileSystem subsystem.
path | Path name to the root of the file system. |
Create and initialize the ROM FileSystem.
path | Path name to the root of the file system. |
Lookup a file system.
path | Path representing a file in the file system. |
Set the file system new line character string.
path | Path representing a file in the file system. |
newline | String containing the newline character(s). "\\n". Windows uses "\\r\\n". |
Set the file system path separators.
path | Path representing a file in the file system. |
separators | String containing the directory path separators. Defaults to "/". Windows uses "/\/". |
Set the ROM file system data.
inodeList | Reference to the ROM file system list of files (inodes). This is generated by the makerom tool. |
Floating Point Services.
Test if a double value is not-a-number.
value | Value to test. |
Test if a double value is zero.
value | Value to test. |
Hash table entry structure.
MprKey ** | buckets | Hash collision bucket table. | |
int | flags | Hash control flags. | |
MprHashProc | fn | Hash function. | |
int | length | Number of symbols in the table. | |
MprMutex * | mutex | GC marker sync. | |
int | size | Size of the buckets array. |
Add a duplicate symbol value into the hash table.
table | Symbol table returned via mprCreateSymbolTable. |
key | String key of the symbole entry to delete. |
ptr | Arbitrary pointer to associate with the key in the table. |
Add a symbol value into the hash table.
table | Symbol table returned via mprCreateSymbolTable. |
key | String key of the symbole entry to delete. |
ptr | Arbitrary pointer to associate with the key in the table. |
Add a key with a formatting value into the hash table.
table | Symbol table returned via mprCreateSymbolTable. |
key | String key of the symbole entry to delete. |
fmt | Format string. See mprPrintf |
Blend two hash tables.
target | Target hash to receive the properties from the other hash. |
other | Hash to provide properties to blend. |
Copy a hash table.
table | Symbol table returned via mprCreateSymbolTable. |
Create a hash table.
hashSize | Size of the hash table for the symbol table. Should be a prime number. Set to 0 or -1 to get a default (small) hash table. |
flags | Table control flags. Use MPR_HASH_CASELESS for case insensitive comparisions, MPR_HASH_UNICODE if the hash keys are unicode strings, MPR_HASH_STATIC_KEYS if the keys are permanent and should not be managed for Garbage collection, and MPR_HASH_STATIC_VALUES if the values are permanent. MPR_HASH_OWN to create an optimized list for private use that is not thread-safe. |
Create a hash of words.
str | String containing white space or comma separated words. |
Return the first symbol in a symbol entry.
table | Symbol table returned via mprCreateSymbolTable. |
Return the count of symbols in a symbol entry.
table | Symbol table returned via mprCreateSymbolTable. |
Return the next symbol in a symbol entry.
table | Symbol table returned via mprCreateSymbolTable. |
last | Symbol table entry returned via mprGetFirstSymbol or mprGetNextSymbol. |
Lookup a symbol in the hash table.
table | Symbol table returned via mprCreateSymbolTable. |
key | String key of the symbole entry to delete. |
Lookup a symbol in the hash table and return the hash entry.
table | Symbol table returned via mprCreateSymbolTable. |
key | String key of the symbole entry to delete. |
Remove a symbol entry from the hash table.
table | Symbol table returned via mprCreateSymbolTable. |
key | String key of the symbole entry to delete. |
JSON parser.
Deserialize a JSON string into an object tree.
str | JSON string to deserialize. |
Custom deserialization from a JSON string into an object tree.
str | JSON string to deserialize. |
callback | Callback functions. This is an instance of the MprJsonCallback structure. |
data | Opaque object to pass to the given callbacks. |
Signal a parse error in the JSON input stream.
jp | JSON control structure. |
fmt | Printf style format string. |
Serialize a JSON object tree into a string.
obj | Object returned via mprDeserialize |
flags | Serialization flags. Supported flags include MPR_JSON_PRETTY. |
List data structure.
int | flags | Control flags. | |
void ** | items | List item data. | |
int | length | Current length of the list contents. | |
int | maxSize | Maximum capacity. | |
MprMutex * | mutex | Multithread lock. | |
int | size | Current list capacity. |
Add an item to a list.
list | List pointer returned from mprCreateList |
item | Pointer to item to store. |
Add a null item to the list.
Append a list.
list | List pointer returned from mprCreateList |
add | List whose contents are added. |
Clears the list of all items.
list | List pointer returned from mprCreateList. |
Clone a list and all elements.
src | Source list to copy. |
Copy list contents.
dest | Destination list for the copy. |
src | Source list. |
Create a key / value pair.
key | Key string. |
value | Key value string. |
Create a list.
size | Initial capacity of the list. Set to < 0 to get a growable list with a default initial size. Set to 0 to to create the list but without any initial list storage. Then call mprSetListLimits to define the initial and maximum list size. |
flags | Control flags. Possible values are: MPR_LIST_STATIC_VALUES to indicate list items are static and should not be marked for GC. MPR_LIST_STABLE to create an optimized list for private use that is not thread-safe. |
Get the first item in the list.
list | List pointer returned from mprCreateList. |
Get an list item.
list | List pointer returned from mprCreateList. |
index | Item index into the list. Indexes have a range from zero to the lenghth of the list - 1. |
Get the last item in the list.
list | List pointer returned from mprCreateList. |
Get the current capacity of the list.
list | List pointer returned from mprCreateList. |
Get the number of items in the list.
list | List pointer returned from mprCreateList. |
Get the next item in the list.
list | List pointer returned from mprCreateList. |
lastIndex | Pointer to an integer that will hold the last index retrieved. |
Get the next item in a stable list.
list | List pointer returned from mprCreateList. |
lastIndex | Pointer to an integer that will hold the last index retrieved. |
Get the previous item in the list.
list | List pointer returned from mprCreateList. |
lastIndex | Pointer to an integer that will hold the last index retrieved. |
Initialize a list structure.
list | Reference to the MprList struct. |
flags | Control flags. Possible values are: MPR_LIST_STATIC_VALUES to indicate list items are static and should not be marked for GC. MPR_LIST_STABLE to create an optimized list for private use that is not thread-safe. |
Insert an item into a list at a specific position.
list | List pointer returned from mprCreateList |
index | Location at which to store the item. The previous item at this index is moved up to make room. |
item | Pointer to item to store. |
Find an item and return its index.
list | List pointer returned from mprCreateList. |
item | Pointer to value stored in the list. |
Find a string item and return its index.
list | List pointer returned from mprCreateList. |
str | Pointer to string to look for. |
Pop an item.
list | List pointer returned from mprCreateList. |
Push an item onto the list.
list | List pointer returned from mprCreateList. |
item | Item to push onto the list. |
Remove an item from the list.
list | List pointer returned from mprCreateList. |
item | Item pointer to remove. |
Remove an item from the list.
Remove the last item from the list.
list | List pointer returned from mprCreateList. |
Remove a range of items from the list.
list | List pointer returned from mprCreateList. |
start | Starting item index to remove (inclusive). |
end | Ending item index to remove (inclusive). |
Remove a string item from the list.
list | List pointer returned from mprCreateList. |
str | String value to remove. |
Set a list item.
list | List pointer returned from mprCreateList. |
index | Location to update. |
item | Pointer to item to store. |
Define the list size limits.
list | List pointer returned from mprCreateList. |
initialSize | Initial size for the list. This call will allocate space for at least this number of items. |
maxSize | Set the maximum limit the list can grow to become. |
Quicksort.
base | Base of array to sort. |
num | Number of array elements. |
width | Width of array elements. |
compare | Comparison function. |
ctx | Context argument to provide to comparison function. |
Sort a list.
list | List pointer returned from mprCreateList. |
compare | Comparison function. If null, then a default string comparison is used. |
ctx | Context to provide to comparison function. |
Logging Services.
Output an assure assertion failed message.
loc | Source code location string. Use MPR_LOC to define a file name and line number string suitable for this parameter. |
msg | Simple string message to output. |
Backup a log.
path | Base log filename. |
count | Count of archived logs to keep. |
Initialize the log service.
Log an error message.
fmt | Printf style format string. Variable number of arguments to. |
... | Variable number of arguments for printf data. |
Get the log file object.
Get the current MPR debug log handler.
Log an informational message.
fmt | Printf style format string. Variable number of arguments to. |
... | Variable number of arguments for printf data. |
Write a message to the log file.
level | Logging level for this message. The level is 0-9 with zero being the most verbose. |
fmt | Printf style format string. Variable number of arguments to. |
... | Variable number of arguments for printf data. |
Emit a descriptive log header.
Write a raw log message to the diagnostic log file.
level | Logging level for this message. The level is 0-9 with zero being the most verbose. |
fmt | Printf style format string. Variable number of arguments to. |
... | Variable number of arguments for printf data. |
Set the log rotation parameters.
logSize | If the size is zero, then the log file will be rotated on each application boot. Otherwise, the log file will be rotated if on application boot, the log file is larger than this size. |
backupCount | Count of the number of log files to keep. |
flags | Set to MPR_LOG_APPEND to append to existing log files. Set to MPR_LOG_TRUNCATE to truncate log files on application restart. |
Set the current logging level.
level | New logging level. Must be 0-9 inclusive. |
Start logging.
logSpec | Set the log file name and level. The format is "pathName[:level]". The following levels are generally observed:
|
showConfig | Set to true to log an initial system configuration. |
Write a trace message to the diagnostic log file.
level | Logging level for this message. The level is 0-9 with zero being the most verbose. |
fmt | Printf style format string. Variable number of arguments to. |
... | Variable number of arguments for printf data. |
Determine if the app is using the default MPR log handler.
Log a warning message.
fmt | Printf style format string. Variable number of arguments to. |
... | Variable number of arguments for printf data. |
Memory Allocation Service.
size_t | field1 | Pointer to adjacent, prior block in memory with last, manager fields. | |
size_t | field2 | Internal block length including header with gen and mark fields. |
Add a memory block as a root for garbage collection.
ptr | Any memory pointer. |
Allocate a block of memory.
size | Size of the memory block to allocate. |
Allocate a block of memory.
size | Size of the memory block to allocate. |
flags | Allocation flags. Supported flags include: MPR_ALLOC_MANAGER to reserve room for a manager callback and MPR_ALLOC_ZERO to zero allocated memory. |
Allocate an object of a given type.
type | Type of the object to allocate. |
manager | Manager function to invoke when the allocation is managed. |
Allocate a zeroed block of memory.
size | Size of the memory block to allocate. |
Create and initialize the Memory service.
manager | Memory manager to manage the Mpr object. |
flags | Memory initialization control flags. |
Destroy the memory service.
Called as the last thing before exitingEnable or disable the garbage collector.
on | Set to one to enable and zero to disable. |
Get the allocated size of a memory block.
ptr | Any memory allocated by mprAlloc. |
Return the amount of memory currently used by the application.
On Unix, this returns the total application memory size including code, stack, data and heap. On Windows, VxWorks and other operatings systems, it returns the amount of allocated heap memoryReturn the current allocation memory statistics block.
Get the current O/S virtual page size.
Determine if the MPR has encountered memory allocation errors.
Hold a memory block.
ptr | Any memory block. |
Test is a pointer is a valid memory context.
This is used to test if a block has been dynamically allocatedptr | Any memory context allocated by mprAlloc or mprCreate. |
Mark a block as "in-use" for the Garbage Collector.
The MPR memory garbage collector requires that all allocated memory be marked as in-use during a garbage collection sweep. When a memory block is allocated, it may provide a "manage" callback function that will be invoked during garbage collection so the block can be marked as "in-use"ptr | Reference to the block to mark as currently being used. |
Compare two byte strings.
b1 | Pointer to the first byte string. |
b1Len | Length of the first byte string. |
b2 | Pointer to the second byte string. |
b2Len | Length of the second byte string. |
Safe copy for a block of data.
dest | Pointer to the destination block. |
destMax | Maximum size of the destination block. |
src | Block to copy. |
nbytes | Size of the source block. |
Duplicate a block of memory.
ptr | Pointer to the block to duplicate. |
size | Size of the block to copy. |
Print a memory usage report to stdout.
msg | Prefix message to the report. |
detail | If true, print free queue detail report. |
Reallocate a block.
ptr | Memory to reallocate. If NULL, call malloc. |
size | New size of the required memory block. |
Release a memory block.
ptr | Any memory block. |
remove a memory block as a root for garbage collection.
ptr | Any memory pointer. |
Collect garbage.
flags | Flags to control the collection. Set flags to MPR_GC_FORCE to force one sweep. Set to zero to perform a conditional sweep where the sweep is only performed if there is sufficient garbage to warrant a collection. |
Reset the memory allocation error flag.
Update the manager for a block of memory.
ptr | Memory to free. If NULL, take no action. |
manager | Manager function to invoke when the memory is released. |
Set an memory allocation error condition on a memory context.
This will set an allocation error condition on the given context and all its parents. This way, you can test the ultimate parent and detect if any memory allocation errors have occurredConfigure the application memory limits.
redline | Soft memory limit. If exceeded, the request will be granted, but the memory handler will be invoked. |
maxMemory | Hard memory limit. If exceeded, the request will not be granted, and the memory handler will be invoked. |
Define a memory notifier.
cback | Notifier callback function. |
Set the memory allocation policy for when allocations fail.
policy | Set to MPR_ALLOC_POLICY_EXIT for the application to immediately exit on memory allocation errors. Set to MPR_ALLOC_POLICY_RESTART to restart the appplication on memory allocation errors. |
Validate a memory block and issue asserts if the memory block is not valid.
ptr | Pointer to allocated memory. |
Verify all memory.
This checks the integrity of all memory blocks by verifying the block headers and contents of all free memory blocks. Will only do anything meaningful when the product is compiled in debug modeMemory virtual memory into the applications address space.
size | of virtual memory to map. This size will be rounded up to the nearest page boundary. |
mode | Mask set to MPR_MAP_READ | MPR_MAP_WRITE. |
Free (unpin) a mapped section of virtual memory.
ptr | Virtual address to free. Should be page aligned. |
size | Size of memory to free in bytes. |
Allocate a "permanent" block of memory that is not subject GC.
size | Size of the memory block to allocate. |
Free a "permanent" block of memory allocated via "palloc".
ptr | Pointer to the block. |
Reallocate a "permanent" block of memory allocated via "palloc".
ptr | Pointer to the block. |
size | New block size. |
Mime Type hash table entry (the URL extension is the key).
char * | program | Mime type string. | |
char * | type | Mime type string. |
Add a mime type to the mime type table.
table | type hash table returned by mprCreateMimeTypes |
ext | Filename extension to use as a key for the given mime type. |
mimeType | Mime type string to associate with the ext key. |
Create the mime types.
path | Filename of a mime types definition file. |
Get the mime type program for a given mimeType.
table | type hash table returned by mprCreateMimeTypes |
mimeType | Mime type to update. |
Get the mime type for an extension.
This call will return the mime type from a limited internal set of mime types for the given path or extensiontable | Hash table of mime types to examine. |
ext | Path or extension to examine. |
Set the mime type program.
table | type hash table returned by mprCreateMimeTypes |
mimeType | Mime type to update. |
program | Program name to associate with this mime type. |
Loadable Module Service.
char * | entry | Module library init entry point. | |
int | flags | Module control flags. | |
void * | handle | O/S shared library load handle. | |
MprTicks | lastActivity | When the module was last used. | |
MprTime | modified | When the module file was last modified. | |
void * | moduleData | Module specific data - must be alloced data. | |
char * | name | Unique module name. | |
char * | path | Module library filename. | |
MprModuleProc | start | Start the module. | |
MprModuleProc | stop | Stop the module. Should be unloadable after stopping. | |
MprTicks | timeout | Inactivity unload timeout. |
Create a module.
name | Name of the module. |
path | Optional filename of a module library to load. When loading, the filename will be searched using the defined module search path (see mprSetModuleSearchPath). The filename may or may not include a platform specific shared library extension such as .dll, .so or .dylib. By omitting the library extension, code can portably load shared libraries. |
entry | Name of function to invoke after loading the module. |
data | Arbitrary data pointer. This will be defined in MprModule.data and passed into the module initialization entry point. |
Get the module search path.
Load a module.
mp | Module object created via mprCreateModule |
Load a native module.
mp | Module object created via mprCreateModule |
Lookup a module.
name | Name of the module specified to mprCreateModule |
Lookup a module and return the module data.
name | Name of the module specified to mprCreateModule |
Search for a module on the current module path.
module | Name of the module to locate. |
Define a module finalizer that will be called before a module is stopped.
module | Module object to modify. |
stop | Callback function to invoke before stopping the module. |
Set the module search path.
searchPath | Colon separated set of directories. |
Set a module timeout.
module | Module object to modify. |
timeout | Inactivity timeout in milliseconds before unloading the module. |
Start a module.
mp | Module object returned via mprLookupModule |
Stop a module.
mp | Module object returned via mprLookupModule |
Unload a module.
mp | Module object returned via mprLookupModule |
Unload a native module.
mp | Module object created via mprCreateModule |
Loadable module service.
Path (filename) Information.
MprTime | atime | Access time. | |
bool | caseMatters | Case comparisons matter. | |
int | checked | Path has been checked. | |
MprTime | ctime | Create time. | |
int | group | Group ID. | |
int64 | inode | Inode number. | |
bool | isDir | Set if directory. | |
bool | isLink | Set if a symbolic link. | |
bool | isReg | Set if a regular file. | |
MprTime | mtime | Modified time. | |
int | owner | Owner ID. | |
int | perms | Permission mask. | |
MprOff | size | File length. | |
int | valid | Valid data bit. |
Copy a file.
from | Path of the existing file to copy. |
to | Name of the new file copy. |
omode | Posix style file open mode mask. See mprOpenFile for the various modes. |
Delete a file.
path | String containing the path to delete. |
Convert a path to an absolute path.
path | Path to examine. |
Return the current working directory.
Get the first path separator in a path.
path | Path to examine. |
Get a path formatted according to the native O/S conventions.
path | Path name to examine. |
Get the base portion of a path.
path | Path name to examine. |
Get a reference to the base portion of a path.
path | Path name to examine. |
Get the directory portion of a path.
path | Path name to examine. |
Get the file extension portion of a path.
path | Path name to examine. |
Create a list of files in a directory or subdirectories.
This call returns a list of MprDirEntry objectsdir | Directory to list. |
flags | The flags may be set to MPR_PATH_DESCEND to traverse subdirectories. Set MPR_PATH_NODIRS to exclude directories from the results. Set to MPR_PATH_HIDDEN to include hidden files that start with ".". Set to MPR_PATH_DEPTH_FIRST to do a depth-first traversal, i.e. traverse subdirectories before considering adding the directory to the list. |
Get the first directory portion of a path.
path | Path name to examine. |
Return information about a file represented by a path.
path | String containing the path to query. |
info | Pointer to a pre-allocated MprPath structure. |
Get the target of a symbolic link.
path | Path name to examine. |
Get the file newline character string for a given path.
Return the character string used to delimit new lines in text filespath | Use this path to specify either the root of the file system or a file on the file system. |
Get the parent directory of a path.
path | Path name to examine. |
Get the path directory separator.
Return the directory separator characters used to separate directories on a given file system. Typically "/" or "\" The first entry is the default separatorpath | Use this path to specify either the root of the file system or a file on the file system. |
Get a portable path.
path | Path name to examine. |
Get a relative path.
dest | Destination file. |
origin | Starting location from which to compute a relative path to the destination If the origin is null, use the application's current working directory as the origin. |
Make a temporary file.
tmpDir | Base directory in which the temp file will be allocated. |
Convert a path to an absolute windows path.
path | Path to examine. |
Determine if a path is absolute.
path | Path name to examine. |
Determine if a path is a directory.
path | Path name to examine. |
Determine if a path is relative.
path | Path name to examine. |
Test if a character is a path separarator.
path | Path name to identify the file system. |
c | Character to test. |
Join paths.
base | Directory path name to use as the base. |
path | Other path name to join to the base path. |
Join an extension to a path.
path | Path name to use as a base. Path is not modified. |
ext | Extension to add. Must should not have a period prefix. |
Make a directory.
path | String containing the directory pathname to create. |
makeMissing | If true make all required intervening directory segments. |
perms | Posix style file permissions mask. |
owner | User to own the directory. Set to -1 not change the owner. |
group | Group to own the directory. Set to -1 not change the group. |
Make a link.
path | String containing the path to link to. |
target | String containing the new link path to be created. |
hard | If true, make a hard link, otherwise make a soft link. |
Map the separators in a path.
path | Path name to examine. |
separator | Separator character to use. |
Normalize a path.
path | First path to compare. |
Determine if a file exists for a path name and can be accessed.
path | Path name to test. |
omode | Posix style file open mode mask. See mprOpenFile for the various modes. |
Replace an extension to a path.
dir | Directory path name to test use as the base/dir. |
ext | Extension to add. The extension should not have a period prefix. |
Resolve paths.
base | Base path to use as the base. |
path | Path name to resolve against base. |
Compare two paths if they are the same.
path1 | First path to compare. |
path2 | Second path to compare. |
Compare two paths if they are the same for a given length.
path1 | First path to compare. |
path2 | Second path to compare. |
len | How many characters to compare. |
Search for a path.
path | Path name to locate. Must be an existing file or directory. |
flags | Flags. |
search | Variable number of directories to search. |
Transform a path.
path | First path to compare. |
flags | Flags to modify the path representation. |
Trim the drive from a path.
path | Path to examine. |
Trim an extension from a path.
path | Path to examine. |
Create a file and write contents.
path | Filename to create. |
buf | Buffer of data to write to the file. |
len | Size of the buf parameter in bytes. |
mode | File permissions with which to create the file. E.g. 0644. |
Signal control structure.
void * | data | Handler data. | |
MprDispatcher * | dispatcher | Dispatcher to service handler. | |
int | flags | Control flags. | |
MprSignalProc | handler | Signal handler (non-native). | |
struct MprSignal * | next | Chain of handlers on the same signo. | |
void(* | sigaction)() | Prior sigaction handler. | |
int | signo | Signal number. |
Add a signal handler.
The signal handling mechanism will trap the specified signal if issued and create an event on the given dispatcher. This will cause the handler function to be safely run by the dispatcher. Normally, signal handlers are difficult to write as the code must be Async-safe. This API permits the use of common, single-threaded code to be used for signal handlers without worrying about pre-emption by other signals or threadssigno | Signal number to handle. |
handler | Call back procedure to invoke. This has the signature MprSignalProc |
arg | Argument to provide to the handler. |
dispatcher | Event dispatcher on which to queue an event to run the handler. |
flags | Set to either MPR_SIGNAL_BEFORE or MPR_SIGNAL_AFTER to run the handler before/after existing handlers. |
Add standard trapping of system signals.
The trapped signals are SIGINT, SIGQUIT, SIGTERM, SIGPIPE and SIGXFSZ. SIGPIPE and SIGXFSZ are ignored. A graceful shutdown is initiated for SIGTERM whereas SIGINT and SIGQUIT will do an immediate exitSocket Service.
char * | acceptIp | Server addresss that accepted a new connection (actual interface). | |
int | acceptPort | Server port doing the listening. | |
char * | errorMsg | Connection related error messages. | |
Socket | fd | Actual socket file handle. | |
int | flags | Current state flags. | |
MprWaitHandler * | handler | Wait handler. | |
char * | ip | Server listen address or remote client address. | |
struct MprSocket * | listenSock | Listening socket. | |
MprMutex * | mutex | Multi-thread sync. | |
int | port | Port to listen or connect on. | |
MprSocketProvider * | provider | Socket implementation provider. | |
MprSocketService * | service | Socket service. | |
struct MprSsl * | ssl | SSL configuration. | |
void * | sslSocket | Extended SSL socket state. |
Accept an incoming connection.
listen | Listening server socket. |
Add a wait handler to a socket.
sp | Socket object created via mprCreateSocket. |
mask | Mask of events of interest. This is made by oring MPR_READABLE and MPR_WRITABLE. |
dispatcher | Dispatcher object to use for scheduling the I/O event. |
proc | Callback function to invoke when an I/O event of interest has occurred. |
data | Data item to pass to the callback. |
flags | Socket handler flags. |
Add a secure socket provider for SSL communications.
name | Name of the secure socket provider. |
provider | Socket provider object. |
Close a socket.
sp | Socket object returned from mprCreateSocket |
graceful | Set to true to do a graceful close. Otherwise, an abortive close will be performed. |
Connect a client socket.
sp | Socket object returned via mprCreateSocket |
ip | Host or IP address to connect to. |
port | TCP/IP port number to connect to. |
flags | Socket flags may use the following flags ored together:
|
Create a socket.
Disconnect a socket by closing its underlying file descriptor.
This is used to prevent further I/O wait events while still preserving the socket objectsp | Socket object. |
Enable socket events for a socket callback.
sp | Socket object returned from mprCreateSocket |
mask | Mask of events to enable. |
Flush a socket.
sp | Socket object returned from mprCreateSocket |
Get the socket blocking mode.
sp | Socket object returned from mprCreateSocket |
Get a socket error code.
sp | Socket object returned from mprCreateSocket |
Get the socket file descriptor.
sp | Socket object returned from mprCreateSocket |
Get the socket for an IP:Port address.
ip | IP address or hostname. |
port | Port number. |
family | Output parameter to contain the Internet protocol family. |
protocol | Output parameter to contain the Internet TCP/IP protocol. |
addr | Output parameter to contain the sockaddr description of the socket address. |
addrlen | Output parameter to hold the length of the sockaddr object. |
Get the port used by a socket.
sp | Socket object returned from mprCreateSocket |
Get the socket state.
sp | Socket object returned from mprCreateSocket |
has the system got a dual IPv4 + IPv6 network stack.
Determine if the system support IPv6.
Determine if SSL is available.
Determine if the IP address is an IPv6 address.
ip | IP address. |
Test if the other end of the socket has been closed.
sp | Socket object returned from mprCreateSocket |
Determine if the socket is secure.
sp | Socket object returned from mprCreateSocket |
Listen on a server socket for incoming connections.
sp | Socket object returned via mprCreateSocket |
ip | IP address to bind to. Set to 0.0.0.0 to bind to all possible addresses on a given port. |
port | TCP/IP port number to connect to. |
flags | Socket flags may use the following flags ored together:
|
Parse an socket address IP address.
address | An IP:PORT specification. The :PORT is optional. When an IP address contains an ipv6 port it should be written as aaaa:bbbb:cccc:dddd:eeee:ffff:gggg:hhhh:iiii or. |
ip | Pointer to receive a dynamically allocated IP string. |
port | Pointer to an integer to receive the port value. |
secure | Pointer to an integer to receive true if the address requires SSL. |
defaultPort | The default port number to use if the address does not contain a port. |
Read from a socket.
sp | Socket object returned from mprCreateSocket |
buf | Pointer to a buffer to hold the read data. |
size | Size of the buffer. |
Remove a socket wait handler.
sp | Socket object created via mprCreateSocket. |
Set the maximum number of accepted client connections that are permissable.
max | New maximum number of accepted client connections. |
Set the socket blocking mode.
sp | Socket object returned from mprCreateSocket |
on | Set to zero to put the socket into non-blocking mode. Set to non-zero to enable blocking mode. |
Set an EOF condition on the socket.
sp | Socket object returned from mprCreateSocket |
eof | Set to true to set an EOF condition. Set to false to clear it. |
Set the socket delay mode.
sp | Socket object returned from mprCreateSocket |
on | Set to non-zero to put the socket into no delay mode. Set to zero to enable the nagle algorithm. |
Test if the socket is doing an SSL handshake.
sp | Socket object returned from mprCreateSocket |
Test if the socket has buffered read data.
sp | Socket object returned from mprCreateSocket |
Test if the socket has buffered write data.
sp | Socket object returned from mprCreateSocket |
Upgrade a socket to use SSL/TLS.
sp | Socket to upgrade. |
ssl | SSL configuration to use. Set to NULL to use the default. |
peerName | Required peer name in handshake with peer. Used by clients to verify the server hostname. |
Write to a socket.
sp | Socket object returned from mprCreateSocket |
buf | Reference to a block to write to the socket. |
len | Length of data to write. This may be less than the requested write length if the socket is in non-blocking mode. Will return a negative MPR error code on errors. |
Write to a string to a socket.
sp | Socket object returned from mprCreateSocket |
str | Null terminated string to write. |
Write a vector to a socket.
sp | Socket object returned from mprCreateSocket |
iovec | Vector of data to write before the file contents. |
count | Count of entries in beforeVect. |
SSL control structure.
char * | caFile | Certificate verification cert file or bundle. | |
char * | caPath | Certificate verification cert directory (OpenSSL only). | |
char * | certFile | Alternatively, locate the cert in a file. | |
int | changed | Set if there is a change in the SSL config. Reset by providers. | |
char * | ciphers | Candidate ciphers to use. | |
void * | config | Extended provider SSL configuration. | |
int | configured | Set if this SSL configuration has been processed. | |
char * | key | Key string. | |
char * | keyFile | Alternatively, locate the key in a file. | |
MprMutex * | mutex | Multithread sync. | |
int | protocols | SSL protocols. | |
struct MprSocketProvider * | provider | Cached SSL provider to use. | |
char * | providerName | SSL provider to use - null if default. | |
int | verifyDepth | Set if the cert chain depth should be verified. | |
int | verifyIssuer | Set if the certificate issuer should be also verified. | |
int | verifyPeer | Verify the peer verificate. |
Add the ciphers to use for SSL.
ssl | SSL instance returned from mprCreateSsl |
ciphers | Cipher string to add to any existing ciphers. |
Create the a new SSL control structure based on an existing structure.
src | Structure to clone. |
Create the SSL control structure.
server | True if the SSL configuration will be used on the server side. |
Lookup an SSL cipher by its IANA name and return the cipher IANA code.
cipher | Cipher IANA name. |
Lookup an SSL cipher by its IANA code and return the string name.
cipher | Cipher IANA code. |
Load the SSL module.
Set the client certificate file to use for SSL.
ssl | SSL instance returned from mprCreateSsl |
caFile | Path to the SSL client certificate file. |
Set the path for the client certificate directory.
ssl | SSL instance returned from mprCreateSsl |
caPath | Path to the SSL client certificate directory. |
Set certificate to use for SSL.
ssl | SSL instance returned from mprCreateSsl |
certFile | Path to the SSL certificate file. |
Set the ciphers to use.
ssl | SSL instance returned from mprCreateSsl |
ciphers | String of suitable ciphers. |
Set the key file to use for SSL.
ssl | SSL instance returned from mprCreateSsl |
keyFile | Path to the SSL key file. |
Set the SSL protocol to use.
ssl | SSL instance returned from mprCreateSsl |
protocols | SSL protocols mask. |
Set the SSL provider to use.
ssl | SSL instance returned from mprCreateSsl |
provider | SSL provider name (openssl | matrixssl | est | nanossl). |
Control the depth of SSL SSL certificate verification.
ssl | SSL instance returned from mprCreateSsl |
depth | Set to the number of intermediate certificates to verify. Defaults to 1. |
Control the verification of SSL certificate issuers.
ssl | SSL instance returned from mprCreateSsl |
on | Set to true to enable SSL certificate issuer verification. |
Require verification of peer certificates.
ssl | SSL instance returned from mprCreateSsl |
on | Set to true to enable peer SSL certificate verification. |
Safe String Module.
Format a string into a static buffer.
buf | Pointer to the buffer. |
maxSize | Size of the buffer. |
fmt | Printf style format string. |
... | Variable arguments to format. |
Format a string into a statically allocated buffer.
buf | Pointer to the buffer. |
maxSize | Size of the buffer. |
fmt | Printf style format string. |
args | Varargs argument obtained from va_start. |
Convert an integer to a string.
value | Integer value to convert. |
Convert an integer to a string buffer.
buf | Pointer to the buffer that will hold the string. |
size | Size of the buffer. |
value | Integer value to convert. |
radix | The base radix to use when encoding the number. |
Convert an integer to a string.
value | Integer value to convert. |
radix | The base radix to use when encoding the number. |
Print a formatted message to the standard error channel.
fmt | Printf style format string. |
... | Variable arguments to format. |
Print a formatted message to a file descriptor.
file | MprFile object returned via mprOpenFile |
fmt | Printf style format string. |
... | Variable arguments to format. |
Formatted print.
This is a secure verion of printf that can handle null argsfmt | Printf style format string. |
... | Variable arguments to format. |
Format a string into a buffer.
buf | Optional buffer to contain the formatted result. |
maxsize | Maximum size of the result. |
fmt | Printf style format string. |
args | Variable arguments to format. |
Create a camel case version of the string.
str | Pointer to the block to duplicate. |
Compare strings ignoring case.
This is a safe replacement for strcasecmp. It can handle NULL argss1 | First string to compare. |
s2 | Second string to compare. |
Compare strings ignoring case.
This is similar to scaselesscmp but it returns a booleans1 | First string to compare. |
s2 | Second string to compare. |
Find a character in a string.
str | String to examine. |
c | Character to search for. |
Clone a string.
str | Pointer to the block to duplicate. |
Compare strings.
s1 | First string to compare. |
s2 | Second string to compare. |
Find a pattern in a string.
str | Pointer to the string to search. |
pattern | String pattern to search for. |
Copy a string.
dest | Pointer to a pointer that will hold the address of the allocated block. |
destMax | Maximum size of the target string in characters. |
src | String to copy. |
Test if the string ends with a given pattern.
str | String to examine. |
suffix | Pattern to search for. |
Format a string.
This is a secure verion of printf that can handle null argsfmt | Printf style format string. |
... | Variable arguments for the format string. |
Format a string.
This is a secure verion of printf that can handle null argsfmt | Printf style format string. |
args | Varargs argument obtained from va_start. |
Compute a hash code for a string.
str | String to examine. |
len | Length in characters of the string to include in the hash code. |
Compute a caseless hash code for a string.
str | String to examine. |
len | Length in characters of the string to include in the hash code. |
Catenate strings.
str | First string to catentate. |
... | Variable number of string arguments to append. Terminate list with NULL. |
Catenate strings.
str | First string to catentate. |
args | Varargs argument obtained from va_start. |
Return the length of a string.
str | String to measure. |
Convert a string to lower case.
str | String to convert. |
Compare strings.
s1 | First string to compare. |
s2 | Second string to compare. |
Compare strings ignoring case.
s1 | First string to compare. |
s2 | Second string to compare. |
len | Length of characters to compare. |
Clone a substring.
str | Pointer to the block to duplicate. |
len | Number of bytes to copy. The actual length copied is the minimum of the given length and the length of the supplied string. The result is null terminated. |
Compare strings.
s1 | First string to compare. |
s2 | Second string to compare. |
len | Length of characters to compare. |
Find a pattern in a string with a limit.
str | Pointer to the string to search. |
pattern | String pattern to search for. |
limit | Count of characters in the string to search. |
Copy characters from a string.
dest | Pointer to a pointer that will hold the address of the allocated block. |
destMax | Maximum size of the target string in characters. |
src | String to copy. |
len | Maximum count of characters to copy. |
Create a Pascal case version of the string.
str | Pointer to the block to duplicate. |
Locate the a character in a string.
str | String to examine. |
set | Set of characters to scan for. |
Find a character in a string by searching backwards.
str | String to examine. |
c | Character to scan for. |
Append strings to an existing string and reallocate as required.
buf | Existing (allocated) string to reallocate. May be null. May not be a string literal. |
... | Variable number of string arguments to append. Terminate list with NULL. |
Append strings to an existing string and reallocate as required.
buf | Existing (allocated) string to reallocate. May be null. May not be a string literal. |
args | Varargs argument obtained from va_start. |
Find the end of a spanning prefix.
str | String to examine. |
set | Set of characters to span. |
Test if the string starts with a given pattern.
str | String to examine. |
prefix | Pattern to search for. |
Create a substring.
str | String to examine. |
offset | Starting offset within str for the beginning of the substring. |
length | Length of the substring in characters. |
Replace template tokens in a string with values from a lookup table.
Tokens are ${variable} referencesstr | String to expand. |
tokens | Hash table of token values to use. |
Convert a string to an integer.
str | Pointer to the string to parse. |
Convert a string to an integer.
str | Pointer to the string to parse. |
radix | Base to use when parsing the string. |
err | Return error code. Set to 0 if successful. |
Tokenize a string.
str | String to tokenize. |
delim | Set of characters that are used as token separators. |
last | Last token pointer. |
Trim a string.
str | String to trim. |
set | String of characters to remove. |
where | Flags to indicate trim from the start, end or both. Use MPR_TRIM_START, MPR_TRIM_END, MPR_TRIM_BOTH. |
Convert a string to upper case.
str | String to convert. |
Multithreaded Synchronization Services.
Atomic Add.
This is a lock free functiontarget | Address of the target word to add to. |
value | Value to add to the target. |
Atomic 64 bit Add.
This is a lock free functiontarget | Address of the target word to add to. |
value | Value to add to the target. |
Apply a full (read+write) memory barrier.
Atomic Compare and Swap.
This is a lock free functiontarget | Address of the target word to swap. |
expected | Expected value of the target. |
value | New value to store at the target. |
Exchange the target and a value.
target | Address of the target word to exchange. |
value | Value to store to the target. |
Atomic list insertion.
Inserts "item" at the "head" of the list. The "link" field is the next field in item. This is a lock-free functionhead | list head. |
link | Reference to the list head link field. |
item | Item to insert. |
Create a condition lock variable.
Create a Mutex lock object.
Create a spin lock lock object.
Globally lock the application.
Unlock the global mutex.
Initialize a statically allocated Mutex lock object.
mutex | Reference to an MprMutex structure to initialize. |
Initialize a statically allocated spinlock object.
lock | Reference to a static MprSpin object. |
Lock access.
Reset a condition variable.
This sets the condition variable to the unsignalled conditioncond | Condition variable object created via mprCreateCond |
Signal a condition lock variable.
cond | Condition variable object created via mprCreateCond |
Signal a condition lock variable for use with multiple waiters.
cond | Condition variable object created via mprCreateCond |
Lock a spinlock.
Unlock a spinlock.
Attempt to lock access.
Attempt to lock access on a spin lock.
Unlock a mutex.
Wait for a condition lock variable.
cond | Condition variable object created via mprCreateCond |
timeout | Time in milliseconds to wait for the condition variable to be signaled. |
Wait for a condition lock variable for use with multiple waiters.
cond | Condition variable object created via mprCreateCond |
timeout | Time in milliseconds to wait for the condition variable to be signaled. |
Test service facility.
int | activeThreadCount | Currently active test threads. | |
int | argc | Count of arguments. | |
char ** | argv | Arguments for test (not alloced). | |
bool | continueOnFailures | Keep testing on failures. | |
bool | debugOnFailures | Break to the debugger. | |
int | echoCmdLine | Echo the command line. | |
int | firstArg | Count of arguments. | |
MprList * | groups | Master list of test groups. | |
int | iterations | Times to run the test. | |
MprMutex * | mutex | Multi-thread sync. | |
cchar * | name | Name for entire test. | |
int | numThreads | Number of test threads. | |
bool | singleStep | Pause between tests. | |
MprTime | start | When testing began. | |
int | testDepth | Depth of entire test. | |
MprList * | testFilter | Test groups to run. | |
MprList * | threadData | Per thread objects. | |
int | totalFailedCount | Total count of failing tests. | |
int | totalTestCount | Total count of all tests. | |
int | verbose | Output activity trace. | |
int | workers | Count of worker threads. |
Test assert.
gp | Test group reference. |
loc | Program location string including filename and line number. |
success | Boolean indicating whether the test passed or failed. |
msg | Message to display if the test failed. |
Add a test group to the test service.
ts | Test service object returned from mprCreateTestService |
def | Test group definition to add. |
Create the test service.
Parse test command arguments.
ts | Test service object returned from mprCreateTestService |
argc | Count of arguments in argv. |
argv | Argument array. |
extraParser | Callback function to invoke to parse non-standard arguments. |
Report the test results.
ts | Test service object returned from mprCreateTestService |
Reset a test group.
gp | Test group reference. |
Run the define unit tests.
ts | Test service object returned from mprCreateTestService |
Signal a test is complete.
gp | Test group reference. |
Signal a test is complete.
gp | Test group reference. |
Wait for a test to complete.
gp | Test group reference. |
timeout | Timeout in milliseconds to block waiting for the test to complete. |
Wait for a test to complete.
gp | Test group reference. |
timeout | Timeout in milliseconds to block waiting for the test to complete. |
Thread Service.
MprCond * | cond | Multi-thread synchronization. | |
void * | data | Data argument. | |
MprThreadProc | entry | Users thread entry point. | |
int | isMain | Is the main thread. | |
MprMutex * | mutex | Multi-thread locking. | |
char * | name | Name of thead for trace. | |
MprOsThread | osThread | O/S thread id. | |
ulong | pid | Owning process id. | |
int | priority | Current priority. | |
ssize | stackSize | Only VxWorks implements. | |
int | stickyYield | Yielded does not auto-clear after GC. | |
int | yielded | Thread has yielded to GC. |
Create a new thread.
name | Unique name to give the thread. |
proc | Entry point function for the thread. mprStartThread will invoke this function to start the thread. |
data | Thread private data stored in MprThread.data. |
stackSize | Stack size to use for the thread. On VM based systems, increasing this value, does not necessarily incurr a real memory (working-set) increase. Set to zero for a default stack size. |
Get the O/S thread.
Get the currently executing thread.
Get the thread name.
thread | Thread object returned from mprCreateThread |
Get the thread priroity.
thread | Thread object returned by mprCreateThread |
Set the thread priroity for the current thread.
priority | Priority to associate with the thread. Mpr thread priorities are are integer values between 0 and 100 inclusive with 50 being a normal priority. The MPR maps these priorities in a linear fashion onto native O/S priorites. Useful constants are:
|
Set the thread priroity.
thread | Thread object returned by mprCreateThread |
priority | Priority to associate with the thread. Mpr thread priorities are are integer values between 0 and 100 inclusive with 50 being a normal priority. The MPR maps these priorities in a linear fashion onto native O/S priorites. Useful constants are:
|
Start a thread.
thread | Thread object returned from mprCreateThread |
Date and Time Service.
Compare two times.
t1 | First time. |
t2 | Second time. |
Mpr time structure.
Decode a time value into a tokenized local time value.
timep | Pointer to a tm structure to hold the result. |
time | Time to format. |
Decode a time value into a tokenized UTC time structure.
timep | Pointer to a tm structure to hold the result. |
time | The time to format. |
Convert a time value to local time and format as a string.
fmt | Time format string. |
time | Time to format. Use mprGetTime to retrieve the current time. |
Format a time value as a local time.
fmt | The time format to use. |
timep | The time value to format. |
Convert a time value to universal time and format as a string.
fmt | Time format string. |
time | Time to format. Use mprGetTime to retrieve the current time. |
Get a string representation of the current date/time.
fmt | Date formatting string. See strftime for acceptable date format specifiers. If null, then this routine uses the MPR_DEFAULT_DATE format. |
Get the elapsed time since a ticks mark.
Create the ticks mark with mprGetTicks()mark | Starting time stamp. |
Get the elapsed time since a starting time mark.
mark | Starting time created via mprGetTime() |
Return the time remaining until a timeout has elapsed.
mark | Starting time stamp. |
timeout | Time in milliseconds. |
Get the system time.
Get the time.
Get the current timezone offset for a given time.
when | Time to examine to extract the timezone. |
Wait Handler Service.
MprCond * | callbackComplete | Signalled when a callback is complete. | |
int | desiredMask | Mask of desired events. | |
MprDispatcher * | dispatcher | Event dispatcher to use for I/O events. | |
MprEvent * | event | Event object to process I/O events. | |
int | fd | O/S File descriptor (sp->sock). | |
int | flags | Control flags. | |
void * | handlerData | Argument to pass to proc. | |
struct MprWaitHandler * | next | List linkage. | |
int | notifierIndex | Index for notifier. | |
int | presentMask | Mask of current events. | |
MprEventProc | proc | Callback event procedure. | |
struct MprWorker * | requiredWorker | Designate the required worker thread to run the callback. | |
MprWaitService * | service | Wait service pointer. | |
struct MprThread * | thread | Thread executing the callback, set even if worker is null. |
Internal.
Create a wait handler.
fd | File descriptor. |
mask | Mask of events of interest. This is made by oring MPR_READABLE and MPR_WRITABLE. |
dispatcher | Dispatcher object to use for scheduling the I/O event. |
proc | Callback function to invoke when an I/O event of interest has occurred. |
data | Data item to pass to the callback. |
flags | Wait handler flags. Use MPR_WAIT_NEW_DISPATCHER to auto-create a new dispatcher for each I/O event. |
Recall a wait handler.
wp | Wait handler to recall. |
Recall a wait handler by fd.
fd | File descriptor that matches that of a wait handler to recall. |
Disconnect a wait handler from its underlying file descriptor.
This is used to prevent further I/O wait events while still preserving the wait handlerwp | Wait handler object. |
Wait for I/O.
This call waits for any I/O events on wait handlers until the given timeout expiresws | Wait service object. |
timeout | Timeout in milliseconds to wait for an event. |
Wait for I/O on a file descriptor.
No processing of the I/O event is donefd | File descriptor to examine. |
mask | Mask of events of interest (MPR_READABLE | MPR_WRITABLE). |
timeout | Timeout in milliseconds to wait for an event. |
Subscribe for desired wait events.
wp | Wait handler created via mprCreateWaitHandler |
desiredMask | Mask of desired events (MPR_READABLE | MPR_WRITABLE). |
Worker thread structure.
MprWorkerProc | cleanup | Procedure to cleanup after run before sleeping. | |
void * | data | User per-worker data. | |
MprCond * | idleCond | Used to wait for work. | |
MprTicks | lastActivity | When the worker was last used. | |
MprWorkerProc | proc | Procedure to run. | |
int | running | Worker running a job. | |
int | state | Worker state. | |
MprThread * | thread | Thread associated with this worker. | |
MprWorkerService * | workerService | Worker service. |
Get the count of available worker threads Return the count of free threads in the worker thread pool.
Dedicate a worker thread to a current real thread.
This implements thread affinity and is required on some platforms where some APIs (waitpid on uClibc) cannot be called on a different threadworker | Worker object. |
worker | Worker thread reference. |
Get the maximum count of worker pool threads Get the maximum limit of worker pool threads.
Get the Worker service statistics.
stats | Reference to stats object to receive the stats. |
Set the maximum count of worker threads Set the maximum number of worker pool threads for the MPR.
If this number if less than the current number of threads, excess threads will be gracefully pruned as they exitcount | Maximum limit of threads to define. |
Set the minimum count of worker threads Set the count of threads the worker pool will have.
This will cause the worker pool to pre-create at least this many threadscount | Minimum count of threads to use. |
Set the default worker stack size.
size | Stack size in bytes. |
Per XML session structure.
char * | errMsg | Error message text. | |
MprXmlHandler | handler | Callback function. | |
MprBuf * | inBuf | Input data queue. | |
void * | inputArg | Arg for mprXmlSetInputStream() | |
int | lineNumber | Current line no for debug. | |
void * | parseArg | Arg passed to mprXmlParse() | |
int | quoteChar | XdbAtt quote char. | |
MprXmlInputStream | readFn | Read data function. | |
MprBuf * | tokBuf | Parsed token buffer. |
Get the XML error message if mprXmlParse fails.
xp | XML parser instance returned from mprXmlOpen. |
Get the source XML line number.
xp | XML parser instance returned from mprXmlOpen. |
Get the XML callback argument.
xp | XML parser instance returned from mprXmlOpen. |
Open an XML parser instance.
initialSize | Initialize size of XML in-memory token buffer. |
maxSize | Maximum size of XML in-memory token buffer. Set to -1 unlimited. |
Run the XML parser.
xp | XML parser instance returned from mprXmlOpen. |
Define the XML parser input stream.
Thisxp | XML parser instance returned from mprXmlOpen. |
fn | Callback function to provide data to the XML parser. The callback is invoked with the signature: ssize callbac(MprXml *xp, void *arg, char *buf, ssize size);. |
arg | Callback argument to pass to the. |
Set the XML callback argument.
xp | XML parser instance returned from mprXmlOpen. |
parseArg | Argument to use for the callback. |
Set the XML parser data handle.
xp | XML parser instance returned from mprXmlOpen. |
h | Arbitrary data to associate with the parser. |
Clone a buffer.
orig | Original buffer to copy. |
Create and initialize the module service.
Destroy the MPR.
how | Exit strategy to use when exiting. Set to MPR_EXIT_DEFAULT to use the existing exit strategy. Set to MPR_EXIT_IMMEDIATE for an immediate abortive shutdown. Finalizers will not be run. Use MPR_EXIT_NORMAL to allow garbage collection and finalizers to run. Use MPR_EXIT_GRACEFUL to allow all current requests and commands to complete before exiting. |
Return the name of the current thread.
Get the CPU tick count.
Indicate that the application layer has buffered data for the socket.
sp | Socket object returned from mprCreateSocket |
len | Length of buffered data in bytes. |
dir | Buffer direction. Set to MPR_READABLE for buffered read data and MPR_WRITABLE for buffered write data. |
Test if a command is complete.
A command is complete when the child has exited and all command output and error output has been receivedcmd | MprCmd object created via mprCreateCmd. |
Determine if the socket is using IPv6 Currently only works for server side addresses.
sp | Socket object returned from mprCreateSocket |
Mark a memory block as in-use.
ptr | Reference to managed memory block. This must be managed memory allocated by the MPR. Do not call mprMark on memory allocated via malloc(), strdup() or other non-MPR allocation routines. It is safe pass a NULL pointer to mprMark and this will have no effect. This is a convenient pattern where manager functions can call mprMark() without testing if the element reference is null or not. |
Begin I/O notification services on a wait handler.
ws | Wait Service object. |
wp | Wait handler associated with the file descriptor. |
mask | Mask of events of interest. This is made by oring MPR_READABLE and MPR_WRITABLE. |
Queue an IO event for dispatch on the wait handler dispatcher.
wp | Wait handler created via mprCreateWaitHandler |
Relay an event to a dispatcher.
This invokes the callback proc as though it was invoked from the given dispatcherdispatcher | Dispatcher object created via mprCreateDispatcher |
proc | Procedure to invoke. |
data | Argument to proc. |
event | Event object. |
Release a worker thread.
This releases a worker thread to be assignable to any real threadworker | Worker object. |
worker | Worker thread reference. |
Reset a sticky yield.
Set a file to be used for logging.
file | MprFile object instance. |
Set an MPR debug log handler.
handler | Callback handler. |
Start the module service.
Start a worker thread.
proc | Worker procedure callback. |
data | Data parameter to the callback. |
Stop the module service.
Yield a thread to allow garbage collection.
flags | Set to MPR_YIELD_BLOCK to wait until the garbage collection is complete. This is not normally required. Set to MPR_YIELD_STICKY to remain in the yielded state. This is useful when sleeping or blocking waiting for I/O. mprResetYield must be called after setting a sticky yield. |
Hashing function to use for the table.
name | Name to hash. |
len | Length of the name to hash. |
Object container for JSON parse trees.
Signed file offset data type.
Supports large files greater than 4GB in size on all systemsElapsed time data type.
Stores time in milliseconds from some arbitrary start epochXML input stream function.
xp | XML instance reference. |
arg | to input stream. |
buf | Buffer into which to read data. |
size | Size of buf. |
Buffer refill callback function.
buf | Instance of an MprBuf. |
arg | Data argument supplied to mprSetBufRefillProc |
Callback function before doing a fork().
Event callback function.
List comparison procedure for sorting.
arg1 | First list item to compare. |
arg2 | Second list item to compare. |
Quicksort callback function.
p1 | Pointer to first element. |
p2 | Pointer to second element. |
ctx | Context argument to provide to comparison function. |
Log handler callback type.
file | Source filename. Derived by using FILE |
line | Source line number. Derived by using LINE |
flags | Error flags. |
level | Message logging level. Levels are 0-9 with zero being the most verbose. |
msg | Message being logged. |
Mpr memory block manager prototype.
ptr | Any memory context allocated by the MPR. |
Memory allocation error callback.
Notifiers are called if a low memory condition existspolicy | Memory depletion policy. Set to one of MPR_ALLOC_POLICY_NOTHING, MPR_ALLOC_POLICY_PRUNE, MPR_ALLOC_POLICY_RESTART or MPR_ALLOC_POLICY_EXIT. |
cause | Cause of the memory allocation condition. If flags is set to MPR_MEM_LOW, the memory pool is low, but the allocation succeeded. If flags contain MPR_MEM_DEPLETED, the allocation failed. |
size | Size of the allocation that triggered the low memory condition. |
total | Total memory currently in use. |
Loadable module entry point signature.
data | Data passed to mprCreateModule. |
mp | Module object reference returned from mprCreateModule |
Module start/stop point function signature.
mp | Module object reference returned from mprCreateModule |
Signal callback procedure.
Callback before binding a socket.
Socket I/O callback procedure.
Proc returns non-zero if the socket has been deletedCallback parser for non-standard command line arguments.
Unit test callback procedure.
Thread main procedure.
arg | Argument to the thread main. |
tp | Thread instance reference. |
Worker thread callback signature.
data | worker callback data. Set via mprStartWorker or mprActivateWorker. |
worker | Reference to the worker thread object. |
XML callback handler.
xp | XML instance reference. |
state | XML state. |
tagName | Current XML tag. |
attName | Current XML attribute. |
value | Current XML element value. |
Child status structure.
Command execution service.
Condition variable for single and multi-thread synchronization.
pthread_cond_t | cv | Unix pthreads condition variable. | |
struct MprMutex * | mutex | Thread synchronization mutex. | |
int | triggered | Value of the condition. |
Directory entry description.
bool | isDir | True if the file is a directory. | |
bool | isLink | True if the file is a symbolic link. | |
MprTime | lastModified | Time the file was last modified. | |
char * | name | Name of the file. | |
MprOff | size | Size of the file. |
Block structure when on a free list.
uint | count | Number of blocks on the queue. | |
int | minSize | Min size of block in queue. | |
struct MprFreeMem * | next | Next free block. | |
struct MprFreeMem * | prev | Previous free block. |
Hash table control structure.
MprKey ** | buckets | Hash collision bucket table. | |
int | flags | Hash control flags. | |
MprHashProc | fn | Hash function. | |
int | length | Number of symbols in the table. | |
MprMutex * | mutex | GC marker sync. | |
int | size | Size of the buckets array. |
Memory allocator heap.
int | active | Active generation for new and active blocks. | |
int | allocPolicy | Memory allocation depletion policy. | |
int | chunkSize | O/S memory allocation chunk size. | |
int | collecting | Manual GC is running. | |
int | dead | Dead generation (blocks about to be freed). | |
int | destroying | Destroying the heap. | |
int | earlyYieldQuota | Quota of new allocations before yielding threads early to cleanup. | |
int | enabled | GC is enabled. | |
int | eternal | Eternal generation (permanent and dead blocks). | |
int | flags | GC operational control flags. | |
int | from | Eligible mprCollectGarbage flags. | |
int | gcRequested | GC has been requested. | |
int | hasError | Memory allocation error. | |
int | hasSweeper | Has dedicated sweeper thread. | |
MprSpin | heapLock | Heap allocation lock. | |
int | iteration | GC iteration counter (debug only). | |
struct MprThread * | marker | Marker thread. | |
MprCond * | markerCond | Marker sleep cond var. | |
int | marking | Actually marking objects now. | |
int | mustYield | Threads must yield for GC which is due. | |
MprMutex * | mutex | Locking for state changes. | |
int | newCount | Count of new gen allocations. | |
int | newQuota | Quota of new allocations before idle GC worthwhile. | |
int | nextSeqno | Next sequence number. | |
MprMemNotifier | notifier | Memory allocation failure callback. | |
int | pageSize | System page size. | |
int | pauseGC | Pause GC (short). | |
ssize | priorFree | Last sweep free memory. | |
int | priorNewCount | Last sweep new count. | |
MprRegion * | regions | List of memory regions. | |
int | rootIndex | Marker root scan index. | |
MprSpin | rootLock | Root locking. | |
struct MprList * | roots | List of GC root objects. | |
int | scribble | Scribble over freed memory (slow). | |
int | stale | Stale generation for blocks that may have no references. | |
struct MprThread * | sweeper | Optional sweeper thread. | |
int | sweeping | Actually sweeping objects now. | |
int | track | Track memory allocations. | |
int | verify | Verify memory contents (very slow). |
Vectored write array.
ssize | len | Length of block to write. | |
char * | start | Start of block to write. |
JSON callbacks.
int(* | checkState)(struct MprJson *jp, cchar *name) | Check state callback for JSON deserialization. This function is called at the conclusion of object levels when a "}" or "]" is encountered in the input stream. It is also invoked after each "name:" is parsed. | |
MprObj *(* | makeObj)(struct MprJson *jp, bool list) | MakeObject callback for JSON deserialization. This function is called to construct an object for each level in the object tree. Objects will be either arrays or objects. | |
void(* | parseError)(struct MprJson *jp, cchar *msg) | Handle a parse error. This function is called from mprJsonParseError to handle error reporting. | |
int(* | setValue)(struct MprJson *jp, MprObj *obj, int index, cchar *name, cchar *value, int valueType) | SetValue callback for JSON deserialization. This function is called to a property value in an object. |
Key value pairs for use with MprList or MprKey.
void * | key | Key string. | |
void * | value | Associated value for the key. |
Memory allocator statistics.
ssize | bytesAllocated | Bytes currently allocated. | |
ssize | bytesFree | Bytes currently free. | |
uint | errors | Allocation errors. | |
ssize | freed | Bytes freed in last sweep. | |
int | inMemException | Recursive protect. | |
ssize | maxMemory | Max memory that can be allocated. | |
uint | numCpu | Number of CPUs. | |
uint | pageSize | System page size. | |
uint64 | ram | System RAM size in bytes. | |
ssize | redLine | Warn if allocation exceeds this level. | |
int | regions | Number of allocated regions. | |
ssize | rss | OS calculated resident stack size in bytes. | |
uint64 | user | System user RAM size in bytes (excludes kernel). |
Multithreading lock control structure.
A RomInode is created for each file in the Rom file system.
uchar * | data | Pointer to file data. | |
int | num | Inode number. | |
char * | path | File path. | |
int | size | Size of file. |
Per signal structure.
int | triggered | Set to true when triggered. |
Signal service control.
int | hasSignals | Signal sent to process. | |
MprSignalInfo | info[MPR_MAX_SIGNALS] | Actual signal info and arg. | |
MprMutex * | mutex | Multithread sync. | |
struct sigaction | prior[MPR_MAX_SIGNALS] | Prior sigaction handler before hooking. | |
MprSignal ** | signals | Signal handlers. | |
MprList * | standard | Standard signal handlers. |
Socket service provider interface.
Mpr socket service class.
char * | defaultProvider | Default secure provider for SSL connections. | |
int | hasIPv6 | System has supoprt for IPv6. | |
int | maxAccept | Maximum number of accepted client socket connections. | |
MprMutex * | mutex | Multithread locking. | |
int | numAccept | Count of client socket connections. | |
MprSocketPrebind | prebind | Prebind callback. | |
MprHash * | providers | Secure socket providers. | |
MprList * | secureSockets | List of secured (matrixssl) sockets. | |
MprSocketProvider * | standardProvider | Socket provider for non-SSL connections. |
Multithreading spin lock control structure.
Test case structure.
Test case definition.
Test failure record.
char * | loc | Program location of the failure. | |
char * | message | Failure message typically the assertion program text. |
A test group is a group of tests to cover a unit of functionality.
MprList * | cases | List of tests in this group. | |
struct HttpConn * | conn | Http connection for this group. | |
char * | content | Cached response content. | |
void * | data | Test specific data. | |
MprTestDef * | def | Test definition ref. | |
MprDispatcher * | dispatcher | Per group thread dispatcher. | |
int | failedCount | Total failures of this test. | |
MprList * | failures | List of all failures. | |
char * | fullName | Fully qualified name of test. | |
MprList * | groups | List of groups. | |
int | hasInternet | Convenience flag for internet available for use. | |
int | hasIPv6 | Convenience flag for IPv6 service. | |
struct Http * | http | Http service. | |
MprMutex * | mutex | Multi-thread sync. | |
char * | name | Name of test. | |
struct MprTestGroup * | parent | Parent test group. | |
struct MprTestGroup * | root | Top level test group parent. | |
MprTestService * | service | Reference to the service. | |
bool | skip | Skip this test. | |
bool | skipWarned | Warned that test will be skipped. | |
bool | success | Result of last run. | |
int | testComplete | Test complete signal. | |
int | testCount | Count of tests. | |
int | testDepth | Depth at which test should run. |
Thread local data storage.
pthread_key_t | key | Data key. |
Thread service.
MprCond * | cond | Multi-thread sync. | |
struct MprThread * | mainThread | Main application Mpr thread id. | |
ssize | stackSize | Default thread stack size. | |
MprList * | threads | List of all threads. |
Wait Service.
Worker Thread Service.
MprList * | busyThreads | List of threads to service tasks. | |
MprList * | idleThreads | List of threads to service tasks. | |
int | maxThreads | Max # threads in worker pool. | |
int | maxUsedThreads | Max threads ever used. | |
int | minThreads | Max # threads in worker pool. | |
MprMutex * | mutex | Per task synchronization. | |
int | nextThreadNum | Unique next thread number. | |
int | numThreads | Current number of threads in worker pool. | |
struct MprEvent * | pruneTimer | Timer for excess threads pruner. | |
ssize | stackSize | Stack size for worker threads. | |
MprWorkerProc | startWorker | Worker thread startup hook. |
Statistics for Workers.
int | busy | Number of busy workers. | |
int | idle | Number of idle workers. | |
int | max | Configured max number of workers. | |
int | maxUsed | Max number of workers ever used used. | |
int | min | Configured minimum number of workers. | |
int | yielded | Number of busy workers yielded for GC. |