Files | |
| file | ub_strutils.h |
| Utility functions for strings. | |
Functions | |
| void | ub_hexdump (bool console, bool debug, unsigned char *buf, int size, int addr) |
| dump out data in hex format to the console More... | |
| void | ub_byte2hexstr (uint8_t a, char *astr) |
| convert a byte to 2-digit hex string More... | |
| int | ub_hexstr2barray (const char *bstr, uint8_t *bytes, const char delim, int len) |
| convert array of 2-digit hex string More... | |
| char * | ub_bmac2smac (ub_macaddr_t bmac, char *smac) |
| convert a binary type mac address to a string type mac address('XX:XX:XX:XX:XX:XX' format) More... | |
| uint8_t * | ub_smac2bmac (const char *smac, ub_macaddr_t bmac) |
| convert a string type mac address('XX:XX:XX:XX:XX:XX' format) to a binary type mac address. More... | |
| char * | ub_bsid2ssid (ub_streamid_t bsid, char *ssid) |
| convert a binary type stream id to a string type stream id ('XX:XX:XX:XX:XX:XX:XX:XX' format) More... | |
| uint8_t * | ub_ssid2bsid (const char *ssid, ub_streamid_t bsid) |
| convert a string type stream id('XX:XX:XX:XX:XX:XX:XX:XX' format) to a binary type stream id More... | |
| int | ub_str2bytearray (uint8_t *dest, const char *input, uint8_t base) |
| convert a string type byte array('01,00,1e,00,00,03,....02,00,01') to a byte array More... | |
| char * | ub_bytearray2str (char *dest, const unsigned char *bytes, int len) |
| convert a byte array to a string type byte array('01,00,1e,00,00,03,....02,00,01') More... | |
| int | ub_find_nospace (const char *astr, int maxn) |
| look for non space charcter and return the number of passed characters More... | |
| int | ub_find_space (const char *astr, int maxn) |
| look for space charcter and return the number of passed characters More... | |
| int | ub_command_line_parser (char *line, char *argv[], int maxargc) |
| parse a command line string and make argc,argv[] for main function, More... | |
| int | ub_strncpy (char *dest, const char *src, int maxlen) |
| copy a string More... | |
Typedefs | |
| typedef uint8_t | ub_bytearray8_t[8] |
| 8-byte binary array More... | |
| typedef ub_bytearray8_t | ub_streamid_t |
| 8-byte binary array is used for Stream ID More... | |
| typedef uint8_t | ub_bytearray6_t[6] |
| 6-byte binary array More... | |
| typedef ub_bytearray6_t | ub_macaddr_t |
| 6-byte binary array is used for MAC Address More... | |
| typedef uint8_t ub_bytearray8_t[8] |
8-byte binary array
| typedef ub_bytearray8_t ub_streamid_t |
8-byte binary array is used for Stream ID
| typedef uint8_t ub_bytearray6_t[6] |
6-byte binary array
| typedef ub_bytearray6_t ub_macaddr_t |
6-byte binary array is used for MAC Address
| void ub_hexdump | ( | bool | console, |
| bool | debug, | ||
| unsigned char * | buf, | ||
| int | size, | ||
| int | addr | ||
| ) |
dump out data in hex format to the console
| console | select output to consol |
| debug | select output to debug memory |
| buf | reference to the data buffer |
| size | size of the data to be dumped. |
| addr | offset address at the top of the data |
| void ub_byte2hexstr | ( | uint8_t | a, |
| char * | astr | ||
| ) |
convert a byte to 2-digit hex string
| a | a byte value |
| astr | 2-byte string pointer to return 2-digit hex string |
| int ub_hexstr2barray | ( | const char * | bstr, |
| uint8_t * | bytes, | ||
| const char | delim, | ||
| int | len | ||
| ) |
convert array of 2-digit hex string
| bstr | hex string array separated by delim |
| bytes | byte array to return the result |
| delim | a delimiter character |
| len | length of bytes |
| char* ub_bmac2smac | ( | ub_macaddr_t | bmac, |
| char * | smac | ||
| ) |
convert a binary type mac address to a string type mac address('XX:XX:XX:XX:XX:XX' format)
| bmac | mac address in binary format. |
| smac | the converted mac addrsss. |
| uint8_t* ub_smac2bmac | ( | const char * | smac, |
| ub_macaddr_t | bmac | ||
| ) |
convert a string type mac address('XX:XX:XX:XX:XX:XX' format) to a binary type mac address.
| smac | mac address in string format |
| bmac | the converted mac address in binary format |
| char* ub_bsid2ssid | ( | ub_streamid_t | bsid, |
| char * | ssid | ||
| ) |
convert a binary type stream id to a string type stream id ('XX:XX:XX:XX:XX:XX:XX:XX' format)
| bsid | stream id in binary format |
| ssid | the converted stream id in string format. |
| uint8_t* ub_ssid2bsid | ( | const char * | ssid, |
| ub_streamid_t | bsid | ||
| ) |
convert a string type stream id('XX:XX:XX:XX:XX:XX:XX:XX' format) to a binary type stream id
| ssid | stream id in string format; either lower case format or upper scale format |
| bsid | the converted stream id in binary format |
| int ub_str2bytearray | ( | uint8_t * | dest, |
| const char * | input, | ||
| uint8_t | base | ||
| ) |
convert a string type byte array('01,00,1e,00,00,03,....02,00,01') to a byte array
| input | byte array in string format; either lower or upper case hex |
| dest | the converted byte array. The caller is responsible to reserve enough size of memory with 'dest'. |
| base | used for strtoul conversion, must be '10','16' |
| char* ub_bytearray2str | ( | char * | dest, |
| const unsigned char * | bytes, | ||
| int | len | ||
| ) |
convert a byte array to a string type byte array('01,00,1e,00,00,03,....02,00,01')
| dest | the converted byte array in string format; lower case hex The caller is responsible to reserve enough size of memory with 'dest'. |
| bytes | byte array to be converted |
| len | number of bytes to be converted to string |
| int ub_find_nospace | ( | const char * | astr, |
| int | maxn | ||
| ) |
look for non space charcter and return the number of passed characters
| astr | string |
| maxn | max number of characters to be checked |
| int ub_find_space | ( | const char * | astr, |
| int | maxn | ||
| ) |
look for space charcter and return the number of passed characters
| astr | string |
| maxn | max number of characters to be checked |
| int ub_command_line_parser | ( | char * | line, |
| char * | argv[], | ||
| int | maxargc | ||
| ) |
parse a command line string and make argc,argv[] for main function,
| line | command line string |
| argv | the result of argment array |
| maxargc | maximum number of arguments |
| int ub_strncpy | ( | char * | dest, |
| const char * | src, | ||
| int | maxlen | ||
| ) |
copy a string
| dest | destination string space, must have maxlen size including null |
| src | source string |
| maxlen | max length |