4 #include <idzebra/res.h>
5 #include <idzebra/api.h>
7 typedef short IDZEBRA_RES;
8 #define RES_LIST char** res_args
11 -------------------------------------------------------------------------------
13 -------------------------------------------------------------------------------
15 void idzebra_api_init(void);
17 char **api_errors(void);
19 int api_check_error(void);
21 void api_clear_error(void);
24 ZebraService idzebra_start (RES_LIST);
26 IDZEBRA_RES idzebra_stop(ZebraService zs);
29 ZebraHandle idzebra_open (ZebraService zs, RES_LIST);
31 IDZEBRA_RES idzebra_close(ZebraHandle zh);
33 IDZEBRA_RES idzebra_samplefunc(ZebraHandle zh, RES_LIST);
37 -------------------------------------------------------------------------------
38 Utility functions for argument handling
39 -------------------------------------------------------------------------------
42 #if __STDC_VERSION__ < 199901L
44 # define __func__ __FUNCTION__
46 # define __func__ "<unknown>"
50 #define API_SET_CONTEXT api_error_context = __func__
52 void args_parse_res (Res r,
53 const char **valid_args,
57 void args_use (ZebraHandle zh,
63 #define ARG_MODE_OPTIONAL 0
64 #define ARG_MODE_MANDATORY 1
65 #define ARG_MODE_FORCE 2
67 #define RES_OPEN(var,def,over) \
68 var = res_open(def, over); \
69 res_set(var,"__context__", __func__ ); \
76 #define ARGS_PARSE(...) \
78 const char *vargs[] = { __VA_ARGS__ , 0 }; \
79 RES_OPEN(func_res, 0, 0); \
80 RES_OPEN(local, 0, 0); \
81 args_parse_res(func_res, vargs, local, res_args); \
85 temp_res = res_add_over(zh->session_res, func_res); \
87 #define ARGS_PROCESS(mode, ...) \
89 const char *vargs[] = { __VA_ARGS__ , 0 }; \
90 args_use(zh, local, func_res, mode, vargs); \
96 res_remove_over(temp_res); \
97 used = res_get_array(local, "_used"); \
98 args_use(zh, zh->session_res, 0, ARG_MODE_FORCE, used); \
103 if (func_res) res_close(func_res); \
104 if (local) res_close(local); \
106 #endif /* API_SWIG_H */