More string.h docs, and fix style
This commit is contained in:
+44
-29
@@ -8,27 +8,46 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/** Encode to ascii-hex, upper case letters.
|
||||||
|
*
|
||||||
|
* Subtract the return value from the passed in @out to find
|
||||||
|
* the length of the converted data
|
||||||
|
*
|
||||||
|
* @param in data to encode
|
||||||
|
* @param len length of data
|
||||||
|
* @param out where to store result. Must hold at least len * 2 + 1
|
||||||
|
* @return returns one past the end of the converted data
|
||||||
|
*/
|
||||||
|
char* uc_hex_encode(const uint8_t *in, size_t len, char *out);
|
||||||
|
|
||||||
|
/** Decode hex. Will stop at the first non-hex digit
|
||||||
char*
|
* (anything not 0-9,a-f or A-F)
|
||||||
uc_hex_encode(const uint8_t *in, size_t len, char *out);
|
* Subtract the return value from the passed in @out to find
|
||||||
uint8_t*
|
* the length of the converted data
|
||||||
uc_hex_decode(const char *in, size_t maxlen,uint8_t *out);
|
*
|
||||||
char*
|
* @param in data to encode
|
||||||
uc_hex_encode_delim(const uint8_t *in, size_t inlen, char *out, int outlen, char *delim);
|
* @param maxlen max length of @in to convert,
|
||||||
|
* conversion stops when either maxlen is reached,
|
||||||
|
* nul terminator of in is found or a non hex digit is found.
|
||||||
|
* @param out where to store result. Must hold at least maxlen/2
|
||||||
|
* @return returns one past the end of the converted data
|
||||||
|
*/
|
||||||
|
uint8_t* uc_hex_decode(const char *in, size_t maxlen,uint8_t *out);
|
||||||
|
/** As uc_hex_encode , but inserts the @delim string between each converted
|
||||||
|
* byte (each 2 hex chars)
|
||||||
|
*/
|
||||||
|
char* uc_hex_encode_delim(const uint8_t *in, size_t inlen, char *out, int outlen, char *delim);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert the string to lowercase, calls tolower() on each char.
|
* Convert the string to lowercase, calls tolower() on each char.
|
||||||
* @param s string to lowercase
|
* @param s string to lowercase
|
||||||
*/
|
*/
|
||||||
void
|
void uc_str_tolower(char *s);
|
||||||
uc_str_tolower(char *s);
|
|
||||||
/**
|
/**
|
||||||
* Convert the string to uppercase, calls toupper() on each char.
|
* Convert the string to uppercase, calls toupper() on each char.
|
||||||
* @param s string to uppercase
|
* @param s string to uppercase
|
||||||
*/
|
*/
|
||||||
void
|
void uc_str_toupper(char *s);
|
||||||
uc_str_toupper(char *s);
|
|
||||||
|
|
||||||
/** Macro to calculate the number of bytes required to BCD encode
|
/** Macro to calculate the number of bytes required to BCD encode
|
||||||
* the number of ascii digits
|
* the number of ascii digits
|
||||||
@@ -48,8 +67,7 @@ uc_str_toupper(char *s);
|
|||||||
* if the number of ASCII digits is odd. This would usually be 0x0 or 0xf.
|
* if the number of ASCII digits is odd. This would usually be 0x0 or 0xf.
|
||||||
* @return the number of bytes written to bcdout
|
* @return the number of bytes written to bcdout
|
||||||
*/
|
*/
|
||||||
size_t
|
size_t uc_ascii2bcd(const char *ascii, unsigned char *bcdout, unsigned char filler);
|
||||||
uc_ascii2bcd(const char *ascii, unsigned char *bcdout, unsigned char filler);
|
|
||||||
|
|
||||||
/** Convert the BCD digits to ascii.
|
/** Convert the BCD digits to ascii.
|
||||||
* The resulting ascii string is 0 terminated.
|
* The resulting ascii string is 0 terminated.
|
||||||
@@ -59,33 +77,30 @@ uc_ascii2bcd(const char *ascii, unsigned char *bcdout, unsigned char filler);
|
|||||||
* @param asciiout buffer to place ASCII in, must be UC_ASCII_LEN(bcdlen)+1 big
|
* @param asciiout buffer to place ASCII in, must be UC_ASCII_LEN(bcdlen)+1 big
|
||||||
* @return the number of characters written to bcdout (this will always be UC_ASCII_LEN(bcdlen)
|
* @return the number of characters written to bcdout (this will always be UC_ASCII_LEN(bcdlen)
|
||||||
*/
|
*/
|
||||||
size_t
|
size_t uc_bcd2ascii(const unsigned char *bcd, size_t bcdlen, char *asciiout);
|
||||||
uc_bcd2ascii(const unsigned char *bcd, size_t bcdlen, char *asciiout);
|
|
||||||
|
|
||||||
char*
|
/** uc_sprintb for converting the values into ascii bit representation
|
||||||
uc_sprintb(char *result, unsigned int value);
|
* e.g. 0x3 -> "00000011". The result must be able to hold the max number
|
||||||
char*
|
* of bits of the type + 1. Returns 'result'
|
||||||
uc_sprintbc(char *result, unsigned char value);
|
*/
|
||||||
char*
|
char* uc_sprintb(char *result, unsigned int value);
|
||||||
uc_sprintbll(char *result, unsigned long long value);
|
char* uc_sprintbc(char *result, unsigned char value);
|
||||||
char*
|
char* uc_sprintbll(char *result, unsigned long long value);
|
||||||
uc_sprintbs(char *result, unsigned short value);
|
char* uc_sprintbs(char *result, unsigned short value);
|
||||||
|
|
||||||
/** Like http://swtch.com/plan9port/man/man3/getfields.html
|
/** Like http://swtch.com/plan9port/man/man3/getfields.html
|
||||||
*/
|
*/
|
||||||
int
|
int getfields(char *str, char **args, int max, int mflag, const char *set);
|
||||||
getfields(char *str, char **args, int max, int mflag, const char *set);
|
|
||||||
|
|
||||||
//Converts bytes to a human representable test, (i.e. 12kB, 160 MB 1.78 GB etc.)
|
//Converts bytes to a human representable test, (i.e. 12kB, 160 MB 1.78 GB etc.)
|
||||||
///result should be at least of size 12,
|
///result should be at least of size 12,
|
||||||
///returns the result argument
|
///returns the result argument
|
||||||
char *
|
char * uc_human_bytesz_dec(uint64_t bytes, char *result, size_t result_len);
|
||||||
uc_human_bytesz_dec(uint64_t bytes, char *result, size_t result_len);
|
|
||||||
|
|
||||||
//same as uc_human_bytesz_bin, but Conversion is done in binary
|
//same as uc_human_bytesz_bin, but Conversion is done in binary
|
||||||
//(base 2 ,1 KiB == 1024 bytes)
|
//(base 2 ,1 KiB == 1024 bytes)
|
||||||
char *
|
char * uc_human_bytesz_bin(uint64_t bytes, char *result, size_t result_len);
|
||||||
uc_human_bytesz_bin(uint64_t bytes, char *result, size_t result_len);
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user