General purpose utility functions


Utility functions

void xfree (void *)
char * xstrdup (const char *)

Functions

void * xmalloc (size_t size)
void * xrealloc (void *p, size_t size)
char * mm_unquote (const char *string)
char * mm_uncomment (const char *string)
char * xstrsep (char **stringp, const char *delim)
char * mm_stripchars (char *input, char *strip)
char * mm_addchars (char *input, char *add, u_int16_t linelength)

Function Documentation

char* mm_addchars ( char *  input,
char *  add,
u_int16_t  linelength 
)

Adds characters to a string at given positions

Parameters:
input The string to which to add characters
add The character string to add
linelength The position where to add the character
Returns:
A copy of the string with characters added
This function adds the characters add at each linelength positions and returns this new string.

char* mm_stripchars ( char *  input,
char *  strip 
)

Strips a given character set from a string

Parameters:
input The string which to strip
strip The character set to strip off
Returns:
A copy of the original string with all chars stripped

char* mm_uncomment ( const char *  string  ) 

Removes MIME comments from a string

Parameters:
string The string to uncomment
Returns:
A pointer to the uncommented string or NULL on error. Sets mm_errno.
This function removes MIME comments from a string (included in parantheses). It returns a pointer to a newly allocated memory region in which the uncommented string is stored. The returned string needs to be freed when it's not used anymore.

char* mm_unquote ( const char *  string  ) 

Unquotes a string

Parameters:
string The quoted string to unquote
Returns:
A pointer to the unquoted string
This function unquotes a string. That is, it returns a pointer to a newly allocated memory region in which the unquoted string is stored. Only leading and trailing double-qoutes are removed. The string needs to be freed when it is not needed anymore.

void* xmalloc ( size_t  size  ) 

Allocates a block of memory

Parameters:
size The size of the memory region to allocate
Returns:
A pointer to the allocated memory region
xmalloc() calls abort() if either the size argument is negative or the requested memory amount could not be allocated via an assert() call.

void* xrealloc ( void *  p,
size_t  size 
)

realloc() wrapper

Parameters:
p Pointer to a memory region which should be reallocated
size The new size of the memory region
Returns:
A pointer to the reallocated memory region
xrealloc() is a wrapper around realloc() which calls abort() if either the size argument is negative or the requested memory amount could not be allocated.

char* xstrsep ( char **  stringp,
const char *  delim 
)

separate strings

Parameters:
stringp A pointer to the string being splitted
delim The delimeter string
This function works similar to strsep(), with the difference that delim is treated as a whole.


Generated on Thu Mar 29 17:59:09 2007 for MiniMIME by  doxygen 1.5.1