MLIB
|
Utility functions for strings of hex characters. More...
#include <mlib/mlib.h>
Functions | |
void | mlib::binhex (char *dst, const unsigned char *src, size_t sz) |
convert binary data to a string of hex digits | |
void | mlib::bytehex (char *dst, unsigned char bin) |
convert one byte to two hex digits | |
void | mlib::shorthex (char *dst, unsigned short bin) |
convert a short integer to 4 hex digits | |
void | mlib::longhex (char *dst, unsigned long bin) |
convert a long integer to 8 hex digits | |
bool | mlib::hexbyte (unsigned char &dst, const char *src) |
convert two ASCII hex digits to binary | |
bool | mlib::hexshort (unsigned short &dst, const char *src) |
convert four ASCII hex digits to binary | |
bool | mlib::hexlong (unsigned long &dst, const char *src) |
convert eight ASCII hex digits to binary | |
size_t | mlib::hexbin (unsigned char *dst, const char *src, size_t sz) |
convert a string of hex digits to binary | |
Utility functions for strings of hex characters.
void mlib::binhex | ( | char * | str, |
const unsigned char * | bin, | ||
size_t | sz ) |
convert binary data to a string of hex digits
str | output string |
bin | input binary data |
sz | size of binary data |
The output string is null-terminated. It must be at least 2*sz
+1 bytes.
void mlib::bytehex | ( | char * | str, |
unsigned char | bin ) |
convert one byte to two hex digits
str | output string. Must be at least 3 bytes long |
bin | input binary value |
The output string is null-terminated.
size_t mlib::hexbin | ( | unsigned char * | bin, |
const char * | str, | ||
size_t | sz ) |
convert a string of hex digits to binary
bin | resulting binary data |
str | input hex string |
sz | maximum size of binary data |
bool mlib::hexbyte | ( | unsigned char & | bin, |
const char * | str ) |
convert two ASCII hex digits to binary
bin | resulting byte value |
str | input string of hex digits |
true
if conversion was successful, false
otherwise bool mlib::hexlong | ( | unsigned long & | bin, |
const char * | str ) |
convert eight ASCII hex digits to binary
bin | resulting long integer value |
str | input string of hex digits |
true
if conversion was successful, false
otherwise bool mlib::hexshort | ( | unsigned short & | bin, |
const char * | str ) |
convert four ASCII hex digits to binary
bin | resulting short integer value |
str | input string of hex digits |
true
if conversion was successful, false
otherwise void mlib::longhex | ( | char * | str, |
unsigned long | bin ) |
convert a long integer to 8 hex digits
str | output string. Must be at least 9 bytes long |
bin | input binary value |
The output string is null-terminated.
void mlib::shorthex | ( | char * | str, |
unsigned short | bin ) |
convert a short integer to 4 hex digits
str | output string. Must be at least 5 bytes long |
bin | input binary value |
The output string is null-terminated.