summaryrefslogtreecommitdiff
path: root/testing/hstox/util.h
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2016-10-01 00:26:52 +0100
committeriphydf <iphydf@users.noreply.github.com>2016-10-01 02:13:34 +0100
commitc037100747a1a224160cb12defb600ddfe1ba927 (patch)
tree8332a7d288116b802866e1ed98d1b950425206f7 /testing/hstox/util.h
parent1977d56caaff40ea9bbf6754b69bec9539a5a969 (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.h27
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
20char const *type_name(msgpack_object_type type);
21
22// Statically allocated "asprintf".
23char const *ssprintf(char const *fmt, ...);
24
25int msgpack_pack_string(msgpack_packer *pk, char const *str);
26int msgpack_pack_stringf(msgpack_packer *pk, char const *fmt, ...);
27int msgpack_pack_vstringf(msgpack_packer *pk, char const *fmt, va_list ap);