57 lines
1.2 KiB
C
57 lines
1.2 KiB
C
#ifndef UCORE_STRING_H_
|
|
#define UCORE_STRING_H_
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
|
|
|
|
char*
|
|
uc_hex_encode(const uint8_t *in, size_t len, char *out);
|
|
uint8_t*
|
|
uc_hex_decode(const char *in, size_t maxlen,uint8_t *out);
|
|
char*
|
|
uc_hex_encode_delim(const uint8_t *in, size_t inlen, char *out, int outlen, char *delim);
|
|
|
|
void
|
|
uc_str_tolower(char *s);
|
|
void
|
|
uc_str_toupper(char *s);
|
|
|
|
#define UC_BCD_LEN(ascii_len) ((ascii_len) / 2 + ((ascii_len) % 2))
|
|
#define UC_ASCII_LEN(bcd_len) ((bcd_len) * 2 + 1)
|
|
|
|
size_t
|
|
uc_ascii2bcd(const char *ascii, unsigned char *bcdout, unsigned char filler);
|
|
size_t
|
|
uc_bcd2ascii(const unsigned char *bcd, size_t bcdlen, char *asciiout);
|
|
|
|
char*
|
|
uc_sprintb(char *result, unsigned int value);
|
|
char*
|
|
uc_sprintbc(char *result, unsigned char value);
|
|
char*
|
|
uc_sprintbll(char *result, unsigned long long value);
|
|
char*
|
|
uc_sprintbs(char *result, unsigned short value);
|
|
|
|
int
|
|
getfields(char *str, char **args, int max, int mflag, const char *set);
|
|
|
|
//ocnvert bytes to a human representable test, (i.e. 12kB, 160 MB 1.78 GB etc.
|
|
///result should be at least of size 12,
|
|
///returns the result argument
|
|
char *
|
|
uc_human_bytesz(uint64_t bytes, char *result, size_t result_len);
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
|
|
#endif
|
|
|