Main Page | Data Structures | File List | Data Fields | Globals

array.c File Reference

#include "array.h"

Functions

char ** array_string_explode (char *string, char sep, char pad)
char ** array_string_boundify (char *str, int colwid)
char * array_string_implode (char **array, char *sep, char pad, int defwid)
char ** array_string_append (char **array, char *text)
int array_string_search (char **array, char *search)
char ** array_string_remove (char **array, void *ptr)
char ** array_string_remove_bytext (char **array, char *matchtext, int allinst)
void array_string_print (char **array)
void array_string_free (char **array)

Detailed Description

String based array functions. Mainly intended for strings.

Function Documentation

char** array_string_append char **  array,
char *  text
 

Parameters:
array The array to append to.
text The text to append to the array.
Return values:
char ** Of the newly allocated array.
NULL On error.
Description:
Appends the string 'text' to the end of an array.
Note:
Always expect the array you passed to this function to be freed, unless NULL is returned.

char** array_string_boundify char *  str,
int  colwid
 

Parameters:
str The string to boundify.
colwid The width of the columns.
Return values:
char ** Of the newly allocated array of strings.
NULL On error.
Description:
Breaks apart a string at white space as close as it can to the default width.

char** array_string_explode char *  string,
char  sep,
char  pad
 

Parameters:
string The string to be exploded.
sep The separating character.
pad A padding character to ignore.
Return values:
char ** Of the newly allocated array of strings.
NULL On error.
Description:
Explodes a delimited string into an array. Escaped literals are supported. Quotes are ignored so you should encode the delimiter even if its wrapped in quotes.

void array_string_free char **  array  ) 
 

Parameters:
array The array to be freed.
Description:
Frees an array of strings. Can be used for other data types that do not contain sub-pointers like structs. Last element in the array MUST be NULL.

char* array_string_implode char **  array,
char *  sep,
char  pad,
int  defwid
 

Parameters:
array The array to implode.
sep The string separating the elements in the array.
pad The padding charter used to pad to the column width.
defwid The default width of a column.
Return values:
char * Of the newly allocated string.
NULL on error.
Description:
Implodes an array into columns, delimited by 'sep', and columns are padded to the width of 'defwid' with the char 'pad'. Make sure none of your strings in the array contain the delimiter 'sep'.
Note:
If the default width is exceeded then only the separator is placed between elements from the array.

void array_string_print char **  array  ) 
 

Parameters:
array The array to print from.
Description:
Prints an array of strings.

char** array_string_remove char **  array,
void *  ptr
 

Parameters:
array The array to remove the element from.
ptr The element pointer to search for.
Return values:
char ** Of the newly allocated array.
NULL On error.
Description:
Removes the pointer 'ptr' from the supplied array.
Note:
Always expect the array you passed to this function to be freed, unless NULL is returned. BUG NOTICE: If the pointer was not found in the array the newly allocated array does not have space for the NULL terminating element. Be careful to make sure the pointer does exist in the array before using this function to remove it. This behaver is likely to change.

char** array_string_remove_bytext char **  array,
char *  matchtext,
int  allinst
 

Parameters:
array The array to remove the element(s) from.
matchtext The text to search for.
allinst If all instance of the 'matchtext' are to be removed.
Return values:
char ** Of the newly allocated array.
NULL On error.
Description:
Removes an element from an array if the text matches 'matchtext'. If 'allinst' is TRUE and more than one match for 'matchtext' is found then all instances will be removed.
Note:
The search text must be exact. This function is case and length sensitive.

Always expect the array you passed to this function to be freed, unless NULL is returned.

int array_string_search char **  array,
char *  search
 

Parameters:
array The array to be searched.
search The string to search for in the array.
Return values:
TRUE If the search string is in the array.
FALSE If the search string is not found or on error.
Description:
Searches for a string in an array of strings.
Note:
The search text must be exact. This function is case and length sensitive.


Generated on Fri Jun 4 18:35:18 2004 for cuf by doxygen 1.3.6