String Utils


Functions

int qsort_numeric_strcmp (const void *str1, const void *str2)
 Qsort numeric string compare function.
int qsort_strcmp (const void *str1, const void *str2)
 Qsort string compare function.
char * string_copy (const char *string)
 Copy a string.
char * string_create (const char *format,...)
 Create a new string.
char * string_create_va_list (const char *format, va_list args)
 Create a new string.
char * trim_trailing_spaces (char *string)
 Trim all space characters from the end of a string.


Function Documentation

int qsort_numeric_strcmp ( const void *  str1,
const void *  str2 
)

Qsort numeric string compare function.

This function can be used by qsort to sort an array of string pointers by using the numeric values found within the strings. The first numbers found in the strings will be compared, if those are equal the next numbers found will be used, and so on and so fourth, until no more numbers are found in the strings. If all numeric values are equal, the strcmp result will be returned.

Parameters:
str1 - pointer to pointer to string 1
str2 - pointer to pointer to string 2

Definition at line 55 of file string_utils.c.

int qsort_strcmp ( const void *  str1,
const void *  str2 
)

Qsort string compare function.

This function can be used by qsort to sort an array of string pointers.

Parameters:
str1 - pointer to pointer to string 1
str2 - pointer to pointer to string 2

Definition at line 90 of file string_utils.c.

char* string_copy ( const char *  string  ) 

Copy a string.

The returned string is dynamically allocated and must be freed by the calling process.

Parameters:
string - the string to copy
Returns:
  • pointer to the copy of the string
  • NULL if:
    • the input string is NULL
    • a memory allocation error occurred

Definition at line 109 of file string_utils.c.

char* string_create ( const char *  format,
  ... 
)

Create a new string.

This functions creates a new string under the control of the format argument. The returned string is dynamically allocated and must be freed by the calling process.

Parameters:
format - format string (see printf)
... - arguments for the format string
Returns:
  • pointer to the new string
  • NULL if:
    • the format string is NULL
    • a memory allocation error occurred

Definition at line 143 of file string_utils.c.

Here is the call graph for this function:

char* string_create_va_list ( const char *  format,
va_list  args 
)

Create a new string.

This functions creates a new string under the control of the format argument. The returned string is dynamically allocated and must be freed by the calling process.

Parameters:
format - format string (see printf)
args - arguments for the format string
Returns:
  • pointer to the new string
  • NULL if:
    • the format string is NULL
    • a memory allocation error occurred

Definition at line 177 of file string_utils.c.

char* trim_trailing_spaces ( char *  string  ) 

Trim all space characters from the end of a string.

This function replaces all isspace() characters at the end of a string with the terminating null character.

Parameters:
string - the string to trim
Returns:
pointer to the modified input string

Definition at line 226 of file string_utils.c.


Generated on Wed May 18 20:17:35 2011 for libdsutil by  doxygen 1.5.6