Add zlib error code to string conversion
This commit is contained in:
parent
6e71e8674d
commit
db2fa04765
25
zlib.cpp
25
zlib.cpp
@ -8,6 +8,31 @@ util::zlib::version (void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char*
|
||||||
|
util::zlib::code_to_string (int code) {
|
||||||
|
static const int MIN_CODE = -6;
|
||||||
|
static const int MAX_CODE = 2;
|
||||||
|
|
||||||
|
if (code > MAX_CODE || code < MIN_CODE) {
|
||||||
|
unreachable ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char* CODES[] = {
|
||||||
|
"OK",
|
||||||
|
"STREAM_END",
|
||||||
|
"NEED_DICT",
|
||||||
|
"ERRNO",
|
||||||
|
"STREAM_ERROR",
|
||||||
|
"DATA_ERROR",
|
||||||
|
"MEM_ERROR",
|
||||||
|
"BUF_ERROR",
|
||||||
|
"VERSION_ERROR",
|
||||||
|
};
|
||||||
|
|
||||||
|
return CODES[code + MIN_CODE];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
util::zlib::uncompress (uint8_t *dst, size_t dst_len,
|
util::zlib::uncompress (uint8_t *dst, size_t dst_len,
|
||||||
const uint8_t *src, size_t src_len) {
|
const uint8_t *src, size_t src_len) {
|
||||||
|
1
zlib.hpp
1
zlib.hpp
@ -29,6 +29,7 @@
|
|||||||
namespace util {
|
namespace util {
|
||||||
namespace zlib {
|
namespace zlib {
|
||||||
extern const char* version (void);
|
extern const char* version (void);
|
||||||
|
extern const char* code_to_string (int);
|
||||||
|
|
||||||
extern void compress (uint8_t *dst, size_t dst_len,
|
extern void compress (uint8_t *dst, size_t dst_len,
|
||||||
const uint8_t *src, size_t src_len,
|
const uint8_t *src, size_t src_len,
|
||||||
|
Loading…
Reference in New Issue
Block a user