diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-10-01 00:26:52 +0100 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-10-01 02:13:34 +0100 |
commit | c037100747a1a224160cb12defb600ddfe1ba927 (patch) | |
tree | 8332a7d288116b802866e1ed98d1b950425206f7 /testing/hstox/util.h | |
parent | 1977d56caaff40ea9bbf6754b69bec9539a5a969 (diff) |
Import the hstox SUT interface from hstox.
We'll maintain it in the c-toxcore repo, where it belongs.
Diffstat (limited to 'testing/hstox/util.h')
-rw-r--r-- | testing/hstox/util.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/testing/hstox/util.h b/testing/hstox/util.h new file mode 100644 index 00000000..c00578a2 --- /dev/null +++ b/testing/hstox/util.h | |||
@@ -0,0 +1,27 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #include <msgpack.h> | ||
4 | |||
5 | #define check_return(err, expr) \ | ||
6 | __extension__({ \ | ||
7 | __typeof__(expr) _r = (expr); \ | ||
8 | if (_r < 0) \ | ||
9 | return err | (__LINE__ << 16); \ | ||
10 | _r; \ | ||
11 | }) | ||
12 | |||
13 | #define propagate(expr) \ | ||
14 | do { \ | ||
15 | __typeof__(expr) _r = (expr); \ | ||
16 | if (_r != E_OK) \ | ||
17 | return _r; \ | ||
18 | } while (0) | ||
19 | |||
20 | char const *type_name(msgpack_object_type type); | ||
21 | |||
22 | // Statically allocated "asprintf". | ||
23 | char const *ssprintf(char const *fmt, ...); | ||
24 | |||
25 | int msgpack_pack_string(msgpack_packer *pk, char const *str); | ||
26 | int msgpack_pack_stringf(msgpack_packer *pk, char const *fmt, ...); | ||
27 | int msgpack_pack_vstringf(msgpack_packer *pk, char const *fmt, va_list ap); | ||