#include <stdlib.h>
#include <string.h>
Go to the source code of this file.
Defines |
#define | M_EXTERN extern |
| String management library.
|
Functions |
M_EXTERN int | is_empty_str (const char *str) |
| Check for a null or spaced string.
|
M_EXTERN char * | clone_str (const char *str) |
| Duplicate a string.
|
M_EXTERN char * | toupper_str (const char *str) |
| Duplicate a string converting all chars to upper-case.
|
M_EXTERN char * | tolower_str (const char *str) |
| Duplicate a string converting all chars to lower-case.
|
M_EXTERN char * | bin2hex (const unsigned char *binstr, const int len) |
| Convert a byte array into a colon-separated hexadecimal sequence.
|
M_EXTERN unsigned char * | hex2bin (const char *hexstr) |
| Convert a colon-separated hexadecimal data into a byte array.
|
M_EXTERN unsigned char * | hex2bin_static (const char *hexstr, unsigned char **res, int *size) |
| Convert a colon-separated hexadecimal data into a byte array, store result into a previously allocated space.
|
M_EXTERN char ** | split (const char *str, char sep, int nelems) |
| Splits a string to an array of nelems by using sep as character separator.
|
M_EXTERN char ** | split_static (const char *str, char sep, int nelems, char *dst) |
| Splits a string to an array of nelems by using sep as character separator, using dest as pre-allocated destination memory for the resulting array.
|
M_EXTERN char * | trim (const char *str) |
| Remove all extra spaces from a string.
|
Define Documentation
String management library.
Definition at line 37 of file strings.h.
Function Documentation
Convert a byte array into a colon-separated hexadecimal sequence.
- Parameters:
-
binstr | ByteArray to be parsed |
len | Number of bytes to be converted |
- Returns:
- Pointer to result string or null if error in allocating memory
Duplicate a string.
- Parameters:
-
- Returns:
- Pointer to cloned string or null if error in allocating memory
Convert a colon-separated hexadecimal data into a byte array.
- Parameters:
-
hexstr | String to be parsed |
- Returns:
- Pointer to resulting byte array, or null if no memory available
Convert a colon-separated hexadecimal data into a byte array, store result into a previously allocated space.
- Parameters:
-
hexstr | String to be parsed |
res | Pointer to pre-allocated user space |
size | Pointer to store lenght of data parsed |
- Returns:
- Pointer to resulting byte array, or null on parse error
Check for a null or spaced string.
- Parameters:
-
- Returns:
- nonzero on null, empty or spaced string, else zero
Splits a string to an array of nelems by using sep as character separator.
To free() memory used by this call, call free(res[0]); free(res);
- Parameters:
-
str | String to be parsed |
sep | Character to be used as separator |
nelems | Number of elements of resulting array |
- Returns:
- res: Pointer to resulting string array, or null if malloc() error
Splits a string to an array of nelems by using sep as character separator, using dest as pre-allocated destination memory for the resulting array.
To free() memory used by this call, just call free result pointer
- Parameters:
-
str | String to be parsed |
sep | Character to be used as separator |
nelems | Number of elements of resulting array |
dst | Char array to store temporary data |
- Returns:
- Pointer to resulting string array, or null if malloc() error
Duplicate a string converting all chars to lower-case.
- Parameters:
-
str | String to be cloned & lowercased |
- Returns:
- Pointer to result string or null if error in allocating memory
Duplicate a string converting all chars to upper-case.
- Parameters:
-
str | String to be cloned & uppercassed |
- Returns:
- Pointer to result string or null if error in allocating memory
Remove all extra spaces from a string.
a char is considered space if trues isspace()
- Parameters:
-
- Returns:
- Pointer to cloned string with all spaces trimmed or null if error in allocating memory