#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. |
M_EXTERN char* bin2hex | ( | const unsigned char * | binstr, | |
const int | len | |||
) |
Convert a byte array into a colon-separated hexadecimal sequence.
binstr | ByteArray to be parsed | |
len | Number of bytes to be converted |
M_EXTERN char* clone_str | ( | const char * | str | ) |
Duplicate a string.
str | String to be cloned |
M_EXTERN unsigned char* hex2bin | ( | const char * | hexstr | ) |
Convert a colon-separated hexadecimal data into a byte array.
hexstr | String to be parsed |
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.
hexstr | String to be parsed | |
res | Pointer to pre-allocated user space | |
size | Pointer to store lenght of data parsed |
M_EXTERN int is_empty_str | ( | const char * | str | ) |
Check for a null or spaced string.
str | Tested string |
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.
To free() memory used by this call, call free(res[0]); free(res);
str | String to be parsed | |
sep | Character to be used as separator | |
nelems | Number of elements of resulting array |
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.
To free() memory used by this call, just call free result pointer
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 |
M_EXTERN char* tolower_str | ( | const char * | str | ) |
Duplicate a string converting all chars to lower-case.
str | String to be cloned & lowercased |
M_EXTERN char* toupper_str | ( | const char * | str | ) |
Duplicate a string converting all chars to upper-case.
str | String to be cloned & uppercassed |
M_EXTERN char* trim | ( | const char * | str | ) |
Remove all extra spaces from a string.
a char is considered space if trues isspace()
str | String to be trimmed |