summaryrefslogtreecommitdiff
path: root/testing/hstox/util.h
diff options
context:
space:
mode:
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);