#include <stdlib.h>
#include <string.h>
Go to the source code of this file.
|  | 
| M_EXTERN int | is_empty_str (const char *str) | 
|  | Check for a null or spaced string.  More... 
 | 
|  | 
| M_EXTERN char * | clone_str (const char *str) | 
|  | Duplicate a string.  More... 
 | 
|  | 
| M_EXTERN char * | toupper_str (const char *str) | 
|  | Duplicate a string converting all chars to upper-case.  More... 
 | 
|  | 
| M_EXTERN char * | tolower_str (const char *str) | 
|  | Duplicate a string converting all chars to lower-case.  More... 
 | 
|  | 
| M_EXTERN char * | bin2hex (const unsigned char *binstr, const int len) | 
|  | Convert a byte array into a colon-separated hexadecimal sequence.  More... 
 | 
|  | 
| M_EXTERN unsigned char * | hex2bin (const char *hexstr) | 
|  | Convert a colon-separated hexadecimal data into a byte array.  More... 
 | 
|  | 
| 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.  More... 
 | 
|  | 
| 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.  More... 
 | 
|  | 
| 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.  More... 
 | 
|  | 
| M_EXTERN char * | trim (const char *str) | 
|  | Remove all extra spaces from a string.  More... 
 | 
|  | 
◆ M_EXTERN
String management library. 
Definition at line 37 of file strings.h.
 
 
◆ bin2hex()
      
        
          | M_EXTERN char* bin2hex | ( | const unsigned char * | binstr, | 
        
          |  |  | const int | len | 
        
          |  | ) |  |  | 
      
 
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 
 
 
◆ clone_str()
      
        
          | M_EXTERN char* clone_str | ( | const char * | str | ) |  | 
      
 
Duplicate a string. 
- Parameters
- 
  
  
- Returns
- Pointer to cloned string or null if error in allocating memory 
 
 
◆ hex2bin()
      
        
          | M_EXTERN unsigned char* hex2bin | ( | const char * | hexstr | ) |  | 
      
 
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 
 
 
◆ hex2bin_static()
      
        
          | 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. 
- 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 
 
 
◆ is_empty_str()
      
        
          | M_EXTERN int is_empty_str | ( | const char * | str | ) |  | 
      
 
Check for a null or spaced string. 
- Parameters
- 
  
  
- Returns
- nonzero on null, empty or spaced string, else zero 
 
 
◆ split()
      
        
          | 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); 
- 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 
 
 
◆ split_static()
      
        
          | 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 
- 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 
 
 
◆ tolower_str()
      
        
          | M_EXTERN char* tolower_str | ( | const char * | str | ) |  | 
      
 
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 
 
 
◆ toupper_str()
      
        
          | M_EXTERN char* toupper_str | ( | const char * | str | ) |  | 
      
 
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 
 
 
◆ trim()
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