4 #include <yaz/xmalloc.h>
5 #include <idzebra/res.h>
6 #include <idzebra/api.h>
8 typedef short IDZEBRA_RES;
9 #define RES_LIST char** res_args
11 typedef struct idzebra_swig_service *IDZebraService;
13 typedef struct idzebra_swig_session *IDZebraSession;
16 -------------------------------------------------------------------------------
18 -------------------------------------------------------------------------------
20 void idzebra_api_init(void);
22 char **api_errors(void);
24 int api_check_error(void);
26 void api_clear_error(void);
29 IDZebraService idzebra_start (RES_LIST);
31 IDZEBRA_RES idzebra_stop(IDZebraService srv);
34 IDZebraSession idzebra_open (IDZebraService srv, RES_LIST);
36 IDZEBRA_RES idzebra_close(IDZebraSession sess);
38 IDZEBRA_RES idzebra_samplefunc(IDZebraSession sess, RES_LIST);
42 -------------------------------------------------------------------------------
43 Utility functions for argument handling
44 -------------------------------------------------------------------------------
47 #if __STDC_VERSION__ < 199901L
49 # define __func__ __FUNCTION__
51 # define __func__ "<unknown>"
55 #define API_SET_CONTEXT api_error_context = __func__
57 void args_parse_res (Res r,
58 const char **valid_args,
62 void args_use (IDZebraSession sess,
68 #define ARG_MODE_OPTIONAL 0
69 #define ARG_MODE_MANDATORY 1
70 #define ARG_MODE_FORCE 2
72 #define RES_OPEN(var,def,over) \
73 var = res_open(def, over); \
74 res_set(var,"__context__", __func__ ); \
81 #define ARGS_PARSE(...) \
83 const char *vargs[] = { __VA_ARGS__ , 0 }; \
84 RES_OPEN(func_res, 0, 0); \
85 RES_OPEN(local, 0, 0); \
86 args_parse_res(func_res, vargs, local, res_args); \
90 temp_res = res_add_over(sess->res, func_res); \
92 #define ARGS_PROCESS(mode, ...) \
94 const char *vargs[] = { __VA_ARGS__ , 0 }; \
95 args_use(sess, local, func_res, mode, vargs); \
101 res_remove_over(temp_res); \
102 used = res_get_array(local, "_used"); \
103 args_use(sess, sess->res, 0, ARG_MODE_FORCE, used); \
108 if (func_res) res_close(func_res); \
109 if (temp_res) res_close_over(temp_res); \
110 if (local) res_close(local); \
112 #endif /* API_SWIG_H */
116 * indent-tabs-mode: nil
118 * vim: shiftwidth=4 tabstop=8 expandtab