This module contains functions related to string management.
char* sld_string_allocate |
( |
char * |
string | ) |
|
Allocates enough memory to store the specified string. You can then call strcpy() using the returned heap space as a destination.
- Parameters
-
- Returns
- A pointer to a block of uninitialized memory large enough to contain the passed string
- Warning
- This function makes use of the sld_memory_pool. Be sure to periodically check memory pool usage by calling sld_memory_pool_objects() and sld_memory_pool_size(). If necessary, call sld_memory_pool_free() or sld_memory_pool_nuke() to prevent memory leaks.
char* sld_string_capitalize |
( |
char * |
string | ) |
|
SLD_BOOL sld_string_casecmp |
( |
char * |
string1, |
|
|
char * |
string2 |
|
) |
| |
char* sld_string_chomp |
( |
char * |
string | ) |
|
char* sld_string_chop |
( |
char * |
string | ) |
|
Removes trailing "\r\n" characters on a passed string or the last character if "\r\n" does not exist.
- Parameters
-
string | a string potentially containing a trailing "\r\n" or containing a trailing character to be removed |
- Returns
- A new string free of trailing "\r\n" characters or the last character removed
- Warning
- This function makes use of the sld_memory_pool. Be sure to periodically check memory pool usage by calling sld_memory_pool_objects() and sld_memory_pool_size(). If necessary, call sld_memory_pool_free() or sld_memory_pool_nuke() to prevent memory leaks.
SLD_BOOL sld_string_contains_character |
( |
char * |
string, |
|
|
char |
character |
|
) |
| |
Checks whether or not a string contains a specified character.
- Parameters
-
string | a string potentially containing a specified character |
character | a character which possibly exists in the passed string |
- Returns
- True or false
char* sld_string_multiply |
( |
char * |
string, |
|
|
int |
factor, |
|
|
char |
separator |
|
) |
| |
Multiplies a passed string by the specified factor and separated by the specified character.
- Parameters
-
string | a string to repeat |
factor | an amount to repeat |
separator | character used to separate each string instance |
- Returns
- A new string containing the original string repeated by the passed factor and separated by separator
- Warning
- This function makes use of the sld_memory_pool. Be sure to periodically check memory pool usage by calling sld_memory_pool_objects() and sld_memory_pool_size(). If necessary, call sld_memory_pool_free() or sld_memory_pool_nuke() to prevent memory leaks.
- Examples:
- daemon.c.
char* sld_string_reverse |
( |
char * |
string | ) |
|
char* sld_string_trim |
( |
char * |
string | ) |
|
Removes leading and trailing whitespace from the passed string.
- Parameters
-
string | a string potentially containing leading and trailing whitespace |
- Returns
- A new string free of leading and trailing whitespace
- Warning
- This function makes use of the sld_memory_pool. Be sure to periodically check memory pool usage by calling sld_memory_pool_objects() and sld_memory_pool_size(). If necessary, call sld_memory_pool_free() or sld_memory_pool_nuke() to prevent memory leaks.
char* sld_string_trim_leading |
( |
char * |
string | ) |
|
char* sld_string_trim_trailing |
( |
char * |
string | ) |
|
char* sld_string_uncapitalize |
( |
char * |
string | ) |
|