mpr/embedded.cpp File Reference


Detailed Description

Miscellaneous routines safe for embedded programming.

Overview:
This module provides safe replacements for the standard library string and formatting routines. It also provides some thread-safe replacements for functions that are only safe when single-threaded.
Remarks:
Most routines in this file are not thread-safe. It is the callers responsibility to perform all thread synchronization.


Functions

int  mprAddToArray (MprArray *array, void *item)
MprArray mprCreateArray ()
void  mprDestroyArray (MprArray *array)
int  mprFprintf (int fd, char *fmt,...)
int  mprPrintf (char *fmt,...)
int  mprRemoveFromArray (MprArray *array, int index)
int  mprStaticPrintf (char *fmt,...)

Function Documentation

int mprAddToArray MprArray array,
void *  item
 

Synopsis:
Add an item to an array
Overview:
Add the specified item to the array. The array must have been previously created via mprCreateArray. The array will grow as required to store the item.
Parameters:
array  Array pointer returned from mprCreateArray.
item  Pointer to item to store.
Returns:
Returns a positive integer array index for the inserted item. If the item cannot be inserted due to a memory allocation failure, -1 is returned.
Stability classification:
Evolving.
Library:
libappWeb
See also:
mprCreateArray, mprDestroyArray, mprRemoveFromArray

MprArray * mprCreateArray  ) 
 

Synopsis:
Create an array
Overview:
Creates an empty array. MprArray's can store generic pointers and automatically grow as required when items are added to the array. Callers should invoke mprDestoryArray when finished with the array to release allocated storage.
Returns:
Returns a pointer to the array.
Stability classification:
Evolving.
Library:
libappWeb
See also:
mprAddToArray, mprDestroyArray, mprRemoveFromArray

void mprDestroyArray MprArray array  ) 
 

Synopsis:
Destroy an array
Overview:
Destroys an array previously created via mprCreateArray. The array does not have to be empty prior to invoking this function.
Returns:
Returns a pointer to the array.
Stability classification:
Evolving.
Library:
libappWeb
See also:
mprAddToArray, mprCreateArray, mprRemoveFromArray

int mprFprintf int  fd,
char *  fmt,
... 
 

Synopsis:
Print a formatted message to a file descriptor
Overview:
This is a replacement for fprintf as part of the safe string MPR library. It minimizes memory use and uses a file descriptor instead

int mprPrintf char *  fmt,
... 
 

Synopsis:
Compact printf. This will use less memory than the standard printf
Overview:
Linking without printf and all its derivatives will save memory for applications that demand minimal footprint. The MPR can be build without using any printf routines.
Parameters:
fmt  Printf style format string
Returns:
Returns the number of bytes written
Stability classification:
Evolving.
Library:
libappWeb
See also:
MprLogListener, mprLog

int mprRemoveFromArray MprArray array,
int  index
 

Synopsis:
Remove the nominated
Overview:
Removes the element specified by index, from the array. The array index is provided by mprAddToArray.
Returns:
Returns the number of remaining elements in the array. Returns zero when the array is empty.
Stability classification:
Evolving.
Library:
libappWeb
See also:
mprAddToArray, mprCreateArray, mprDestroyArray

int mprStaticPrintf char *  fmt,
... 
 

Synopsis:
Print a message to the applications standard output without allocating memory.
Overview:
Normal Printf routines may allocate dynamic memory when parsing the format string. mprStaticPrintf uses a static buffer and will never allocate dynamic memory. It is suitable for use by low-level handlers that must not error when doing output.
Parameters:
fmt  Printf style format string
Returns:
Returns the number of bytes written
Remarks:
The maximum output is MPR_MAX_STRING - 1.
Stability classification:
Evolving.
Library:
libappWeb
See also:
mprPrintf, mprLog

© Mbedthis Software LLC, 2003-2004. All rights reserved. Mbedthis is a trademark of Mbedthis Software LLC.