summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/afb-api-so-v2.c3
-rw-r--r--src/afb-api-so-v2.h4
-rw-r--r--src/afb-api-so.c11
-rw-r--r--src/afb-api-v3.c9
-rw-r--r--src/afb-api-v3.h14
-rw-r--r--src/afb-args.c9
-rw-r--r--src/afb-evt.c2
-rw-r--r--src/afb-evt.h3
-rw-r--r--src/afb-export.c158
-rw-r--r--src/afb-export.h39
-rw-r--r--src/afb-xreq.c6
-rw-r--r--src/afb-xreq.h6
13 files changed, 185 insertions, 81 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 58870aa4..b1475e31 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -35,6 +35,7 @@ option(WITH_AFB_TRACE "include monitoring trace" ON)
option(WITH_SUPERVISOR "Activates installation of supervisor" OFF)
option(WITH_DBUS_TRANSPARENCY "Allows API transparency over DBUS" OFF)
option(WITH_LEGACY_BINDING_V1 "Includes the legacy Binding API version 1" OFF)
+option(WITH_LEGACY_BINDING_V2 "Includes the legacy Binding API version 2" ON)
option(WITH_LEGACY_BINDING_VDYN "Includes the legacy Binding API version dynamic" OFF)
if(INCLUDE_SUPERVISOR)
@@ -58,6 +59,7 @@ add_definitions(
-DWITH_AFB_HOOK=$<BOOL:${WITH_AFB_HOOK}>
-DWITH_AFB_TRACE=$<BOOL:${WITH_AFB_TRACE}>
-DWITH_LEGACY_BINDING_V1=$<BOOL:${INCLUDE_LEGACY_BINDING_V1}>
+ -DWITH_LEGACY_BINDING_V2=$<BOOL:${WITH_LEGACY_BINDING_V2}>
-DWITH_LEGACY_BINDING_VDYN=$<BOOL:${INCLUDE_LEGACY_BINDING_VDYN}>
-DWITH_DBUS_TRANSPARENCY=$<BOOL:${INCLUDE_DBUS_TRANSPARENCY}>
-DWITH_SUPERVISION=$<BOOL:${INCLUDE_SUPERVISOR}>
diff --git a/src/afb-api-so-v2.c b/src/afb-api-so-v2.c
index 71d51c04..a0399da1 100644
--- a/src/afb-api-so-v2.c
+++ b/src/afb-api-so-v2.c
@@ -15,6 +15,8 @@
* limitations under the License.
*/
+#if WITH_LEGACY_BINDING_V2
+
#define _GNU_SOURCE
#include <stdlib.h>
@@ -221,3 +223,4 @@ int afb_api_so_v2_add(const char *path, void *handle, struct afb_apiset *declare
return -1;
}
+#endif
diff --git a/src/afb-api-so-v2.h b/src/afb-api-so-v2.h
index 998fab58..9b4cb091 100644
--- a/src/afb-api-so-v2.h
+++ b/src/afb-api-so-v2.h
@@ -18,6 +18,8 @@
#pragma once
+#if WITH_LEGACY_BINDING_V2
+
struct afb_apiset;
struct afb_binding_v2;
struct afb_binding_data_v2;
@@ -29,3 +31,5 @@ extern int afb_api_so_v2_add_binding(const struct afb_binding_v2 *binding, void
extern void afb_api_so_v2_process_call(const struct afb_binding_v2 *binding, struct afb_xreq *xreq);
extern struct json_object *afb_api_so_v2_make_description_openAPIv3(const struct afb_binding_v2 *binding, const char *apiname);
+
+#endif
diff --git a/src/afb-api-so.c b/src/afb-api-so.c
index 11088b1c..3838380e 100644
--- a/src/afb-api-so.c
+++ b/src/afb-api-so.c
@@ -25,7 +25,6 @@
#include <sys/stat.h>
#include "afb-api-so.h"
-#include "afb-api-so-v2.h"
#include "afb-api-so-v3.h"
#include "verbose.h"
#include "sig-monitor.h"
@@ -36,6 +35,9 @@
#if WITH_LEGACY_BINDING_VDYN
# include "afb-api-so-vdyn.h"
#endif
+#if WITH_LEGACY_BINDING_V2
+# include "afb-api-so-v2.h"
+#endif
struct safe_dlopen
{
@@ -91,6 +93,7 @@ static int load_binding(const char *path, int force, struct afb_apiset *declare_
if (rc)
return 0; /* yes version 3 */
+#if WITH_LEGACY_BINDING_V2
/* try the version 2 */
rc = afb_api_so_v2_add(path, handle, declare_set, call_set);
if (rc < 0) {
@@ -99,6 +102,12 @@ static int load_binding(const char *path, int force, struct afb_apiset *declare_
}
if (rc)
return 0; /* yes version 2 */
+#else
+ if (dlsym(handle, "afbBindingV2")) {
+ WARNING("binding [%s]: version 2 not supported", path);
+ obsolete = 1;
+ }
+#endif
#if WITH_LEGACY_BINDING_VDYN
/* try the version dyn */
diff --git a/src/afb-api-v3.c b/src/afb-api-v3.c
index 95727065..7b889ee8 100644
--- a/src/afb-api-v3.c
+++ b/src/afb-api-v3.c
@@ -44,7 +44,9 @@ struct afb_api_v3 {
int refcount;
int count;
struct afb_verb_v3 **verbs;
+#if WITH_LEGACY_BINDING_V2
const struct afb_verb_v2 *verbsv2;
+#endif
const struct afb_verb_v3 *verbsv3;
struct afb_export *export;
const char *info;
@@ -77,7 +79,9 @@ static struct afb_verb_v3 *search_dynamic_verb(struct afb_api_v3 *api, const cha
void afb_api_v3_process_call(struct afb_api_v3 *api, struct afb_xreq *xreq)
{
const struct afb_verb_v3 *verbsv3;
+#if WITH_LEGACY_BINDING_V2
const struct afb_verb_v2 *verbsv2;
+#endif
const char *name;
name = xreq->request.called_verb;
@@ -104,6 +108,7 @@ void afb_api_v3_process_call(struct afb_api_v3 *api, struct afb_xreq *xreq)
return;
}
+#if WITH_LEGACY_BINDING_V2
/* look in legacy set */
verbsv2 = api->verbsv2;
if (verbsv2) {
@@ -116,7 +121,7 @@ void afb_api_v3_process_call(struct afb_api_v3 *api, struct afb_xreq *xreq)
}
}
}
-
+#endif
afb_xreq_reply_unknown_verb(xreq);
}
@@ -252,12 +257,14 @@ struct afb_export *afb_api_v3_export(struct afb_api_v3 *api)
return api->export;
}
+#if WITH_LEGACY_BINDING_V2
void afb_api_v3_set_verbs_v2(
struct afb_api_v3 *api,
const struct afb_verb_v2 *verbs)
{
api->verbsv2 = verbs;
}
+#endif
void afb_api_v3_set_verbs_v3(
struct afb_api_v3 *api,
diff --git a/src/afb-api-v3.h b/src/afb-api-v3.h
index e666e783..73d6fba3 100644
--- a/src/afb-api-v3.h
+++ b/src/afb-api-v3.h
@@ -23,7 +23,6 @@ struct afb_api_v3;
struct afb_api_x3;
struct afb_auth;
struct afb_req_x2;
-struct afb_verb_v2;
struct afb_verb_v3;
struct afb_binding_v3;
struct afb_xreq;
@@ -57,10 +56,6 @@ extern void afb_api_v3_unref(struct afb_api_v3 *api);
extern struct afb_export *afb_api_v3_export(struct afb_api_v3 *api);
-extern void afb_api_v3_set_verbs_v2(
- struct afb_api_v3 *api,
- const struct afb_verb_v2 *verbs);
-
extern void afb_api_v3_set_verbs_v3(
struct afb_api_v3 *api,
const struct afb_verb_v3 *verbs);
@@ -83,3 +78,12 @@ extern int afb_api_v3_del_verb(
extern void afb_api_v3_process_call(struct afb_api_v3 *api, struct afb_xreq *xreq);
extern struct json_object *afb_api_v3_make_description_openAPIv3(struct afb_api_v3 *api, const char *apiname);
+#if WITH_LEGACY_BINDING_V2
+
+struct afb_verb_v2;
+
+extern void afb_api_v3_set_verbs_v2(
+ struct afb_api_v3 *api,
+ const struct afb_verb_v2 *verbs);
+
+#endif \ No newline at end of file
diff --git a/src/afb-args.c b/src/afb-args.c
index 2af77f37..1dc2e6ca 100644
--- a/src/afb-args.c
+++ b/src/afb-args.c
@@ -381,7 +381,13 @@ static void printVersion(FILE * file)
#else
"-"
#endif
- "VDYN +V2 +V3]\n"
+ "VDYN "
+#if WITH_LEGACY_BINDING_V2
+ "+"
+#else
+ "-"
+#endif
+ "V2 +V3]\n"
"\n",
AFB_VERSION
);
@@ -545,6 +551,7 @@ static int config_has_bool(struct json_object *config, int optid)
&& json_object_get_boolean(x);
}
+__attribute__((unused))
static int config_has_str(struct json_object *config, int optid, const char *val)
{
int i, n;
diff --git a/src/afb-evt.c b/src/afb-evt.c
index 05d90961..0467bef1 100644
--- a/src/afb-evt.c
+++ b/src/afb-evt.c
@@ -698,6 +698,7 @@ int afb_evt_event_x2_unhooked_push(struct afb_event_x2 *eventid, struct json_obj
return 0;
}
+#if WITH_LEGACY_BINDING_V1 || WITH_LEGACY_BINDING_V2
struct afb_event_x1 afb_evt_event_from_evtid(struct afb_evtid *evtid)
{
return evtid
@@ -708,6 +709,7 @@ struct afb_event_x1 afb_evt_event_from_evtid(struct afb_evtid *evtid)
#endif
: (struct afb_event_x1){ .itf = NULL, .closure = NULL };
}
+#endif
void afb_evt_event_x2_unref(struct afb_event_x2 *eventid)
{
diff --git a/src/afb-evt.h b/src/afb-evt.h
index 5ba6ce9b..4ccd8f48 100644
--- a/src/afb-evt.h
+++ b/src/afb-evt.h
@@ -75,7 +75,10 @@ extern int afb_evt_event_x2_remove_watch(struct afb_evt_listener *listener, stru
extern struct afb_evtid *afb_evt_event_x2_to_evtid(struct afb_event_x2 *eventid);
extern struct afb_event_x2 *afb_evt_event_x2_from_evtid(struct afb_evtid *evtid);
+
+#if WITH_LEGACY_BINDING_V1 || WITH_LEGACY_BINDING_V2
extern struct afb_event_x1 afb_evt_event_from_evtid(struct afb_evtid *evtid);
+#endif
#if WITH_AFB_HOOK
extern struct afb_evtid *afb_evt_evtid_hooked_addref(struct afb_evtid *evtid);
diff --git a/src/afb-export.c b/src/afb-export.c
index d0cabf6e..8ebe8e06 100644
--- a/src/afb-export.c
+++ b/src/afb-export.c
@@ -36,7 +36,9 @@
#if WITH_LEGACY_BINDING_V1
#include "afb-api-so-v1.h"
#endif
+#if WITH_LEGACY_BINDING_V2
#include "afb-api-so-v2.h"
+#endif
#include "afb-api-v3.h"
#include "afb-common.h"
#include "afb-cred.h"
@@ -68,7 +70,9 @@ enum afb_api_version
#if WITH_LEGACY_BINDING_V1
Api_Version_1 = 1,
#endif
+#if WITH_LEGACY_BINDING_V2
Api_Version_2 = 2,
+#endif
Api_Version_3 = 3
};
@@ -265,11 +269,6 @@ static void vverbose_cb(struct afb_api_x3 *closure, int level, const char *file,
}
}
-static void legacy_vverbose_v1_cb(struct afb_api_x3 *closure, int level, const char *file, int line, const char *fmt, va_list args)
-{
- vverbose_cb(closure, level, file, line, NULL, fmt, args);
-}
-
static struct afb_event_x2 *event_x2_make_cb(struct afb_api_x3 *closure, const char *name)
{
struct afb_export *export = from_api_x3(closure);
@@ -285,12 +284,6 @@ static struct afb_event_x2 *event_x2_make_cb(struct afb_api_x3 *closure, const c
return afb_evt_event_x2_create2(export->api.apiname, name);
}
-static struct afb_event_x1 legacy_event_x1_make_cb(struct afb_api_x3 *closure, const char *name)
-{
- struct afb_event_x2 *event = event_x2_make_cb(closure, name);
- return afb_evt_event_from_evtid(afb_evt_event_x2_to_evtid(event));
-}
-
static int event_broadcast_cb(struct afb_api_x3 *closure, const char *name, struct json_object *object)
{
size_t plen, nlen;
@@ -345,11 +338,6 @@ static int queue_job_cb(struct afb_api_x3 *closure, void (*callback)(int signum,
return jobs_queue(group, timeout, callback, argument);
}
-static struct afb_req_x1 legacy_unstore_req_cb(struct afb_api_x3 *closure, struct afb_stored_req *sreq)
-{
- return afb_xreq_unstore(sreq);
-}
-
static int require_api_cb(struct afb_api_x3 *closure, const char *name, int initialized)
{
struct afb_export *export = from_api_x3(closure);
@@ -421,6 +409,24 @@ static struct afb_api_x3 *api_new_api_cb(
return apiv3 ? to_api_x3(afb_api_v3_export(apiv3)) : NULL;
}
+#if WITH_LEGACY_BINDING_V1 || WITH_LEGACY_BINDING_V2
+
+static void legacy_vverbose_v1_cb(struct afb_api_x3 *closure, int level, const char *file, int line, const char *fmt, va_list args)
+{
+ vverbose_cb(closure, level, file, line, NULL, fmt, args);
+}
+
+static struct afb_event_x1 legacy_event_x1_make_cb(struct afb_api_x3 *closure, const char *name)
+{
+ struct afb_event_x2 *event = event_x2_make_cb(closure, name);
+ return afb_evt_event_from_evtid(afb_evt_event_x2_to_evtid(event));
+}
+
+static struct afb_req_x1 legacy_unstore_req_cb(struct afb_api_x3 *closure, struct afb_stored_req *sreq)
+{
+ return afb_xreq_unstore(sreq);
+}
+
static const struct afb_daemon_itf_x1 daemon_itf = {
.vverbose_v1 = legacy_vverbose_v1_cb,
.vverbose_v2 = vverbose_cb,
@@ -437,6 +443,7 @@ static const struct afb_daemon_itf_x1 daemon_itf = {
.add_alias = add_alias_cb,
.new_api = api_new_api_cb,
};
+#endif
#if WITH_AFB_HOOK
static void hooked_vverbose_cb(struct afb_api_x3 *closure, int level, const char *file, int line, const char *function, const char *fmt, va_list args)
@@ -449,11 +456,6 @@ static void hooked_vverbose_cb(struct afb_api_x3 *closure, int level, const char
va_end(ap);
}
-static void legacy_hooked_vverbose_v1_cb(struct afb_api_x3 *closure, int level, const char *file, int line, const char *fmt, va_list args)
-{
- hooked_vverbose_cb(closure, level, file, line, NULL, fmt, args);
-}
-
static struct afb_event_x2 *hooked_event_x2_make_cb(struct afb_api_x3 *closure, const char *name)
{
struct afb_export *export = from_api_x3(closure);
@@ -462,15 +464,6 @@ static struct afb_event_x2 *hooked_event_x2_make_cb(struct afb_api_x3 *closure,
return r;
}
-static struct afb_event_x1 legacy_hooked_event_x1_make_cb(struct afb_api_x3 *closure, const char *name)
-{
- struct afb_event_x2 *event = hooked_event_x2_make_cb(closure, name);
- struct afb_event_x1 e;
- e.closure = event;
- e.itf = event ? event->itf : NULL;
- return e;
-}
-
static int hooked_event_broadcast_cb(struct afb_api_x3 *closure, const char *name, struct json_object *object)
{
int r;
@@ -534,13 +527,6 @@ static int hooked_queue_job_cb(struct afb_api_x3 *closure, void (*callback)(int
return afb_hook_api_queue_job(export, callback, argument, group, timeout, r);
}
-static struct afb_req_x1 legacy_hooked_unstore_req_cb(struct afb_api_x3 *closure, struct afb_stored_req *sreq)
-{
- struct afb_export *export = from_api_x3(closure);
- afb_hook_api_legacy_unstore_req(export, sreq);
- return legacy_unstore_req_cb(closure, sreq);
-}
-
static int hooked_require_api_cb(struct afb_api_x3 *closure, const char *name, int initialized)
{
int result;
@@ -573,6 +559,29 @@ static struct afb_api_x3 *hooked_api_new_api_cb(
return result;
}
+#if WITH_LEGACY_BINDING_V1 || WITH_LEGACY_BINDING_V2
+
+static void legacy_hooked_vverbose_v1_cb(struct afb_api_x3 *closure, int level, const char *file, int line, const char *fmt, va_list args)
+{
+ hooked_vverbose_cb(closure, level, file, line, NULL, fmt, args);
+}
+
+static struct afb_event_x1 legacy_hooked_event_x1_make_cb(struct afb_api_x3 *closure, const char *name)
+{
+ struct afb_event_x2 *event = hooked_event_x2_make_cb(closure, name);
+ struct afb_event_x1 e;
+ e.closure = event;
+ e.itf = event ? event->itf : NULL;
+ return e;
+}
+
+static struct afb_req_x1 legacy_hooked_unstore_req_cb(struct afb_api_x3 *closure, struct afb_stored_req *sreq)
+{
+ struct afb_export *export = from_api_x3(closure);
+ afb_hook_api_legacy_unstore_req(export, sreq);
+ return legacy_unstore_req_cb(closure, sreq);
+}
+
static const struct afb_daemon_itf_x1 hooked_daemon_itf = {
.vverbose_v1 = legacy_hooked_vverbose_v1_cb,
.vverbose_v2 = hooked_vverbose_cb,
@@ -591,6 +600,8 @@ static const struct afb_daemon_itf_x1 hooked_daemon_itf = {
};
#endif
+#endif
+
/******************************************************************************
******************************************************************************
******************************************************************************
@@ -639,39 +650,41 @@ static int call_sync_x3(
return afb_calls_call_sync(export, api, verb, args, object, error, info);
}
-static void legacy_call_v12(
+static void legacy_call_x3(
struct afb_api_x3 *apix3,
const char *api,
const char *verb,
struct json_object *args,
- void (*callback)(void*, int, struct json_object*),
+ void (*callback)(void*, int, struct json_object*, struct afb_api_x3*),
void *closure)
{
struct afb_export *export = from_api_x3(apix3);
- afb_calls_legacy_call_v12(export, api, verb, args, callback, closure);
+ afb_calls_legacy_call_v3(export, api, verb, args, callback, closure);
}
-static void legacy_call_x3(
+static int legacy_call_sync(
struct afb_api_x3 *apix3,
const char *api,
const char *verb,
struct json_object *args,
- void (*callback)(void*, int, struct json_object*, struct afb_api_x3*),
- void *closure)
+ struct json_object **result)
{
struct afb_export *export = from_api_x3(apix3);
- afb_calls_legacy_call_v3(export, api, verb, args, callback, closure);
+ return afb_calls_legacy_call_sync(export, api, verb, args, result);
}
-static int legacy_call_sync(
+#if WITH_LEGACY_BINDING_V1 || WITH_LEGACY_BINDING_V2
+
+static void legacy_call_v12(
struct afb_api_x3 *apix3,
const char *api,
const char *verb,
struct json_object *args,
- struct json_object **result)
+ void (*callback)(void*, int, struct json_object*),
+ void *closure)
{
struct afb_export *export = from_api_x3(apix3);
- return afb_calls_legacy_call_sync(export, api, verb, args, result);
+ afb_calls_legacy_call_v12(export, api, verb, args, callback, closure);
}
/* the interface for services */
@@ -679,6 +692,7 @@ static const struct afb_service_itf_x1 service_itf = {
.call = legacy_call_v12,
.call_sync = legacy_call_sync
};
+#endif
#if WITH_AFB_HOOK
static void hooked_call_x3(
@@ -706,39 +720,41 @@ static int hooked_call_sync_x3(
return afb_calls_hooked_call_sync(export, api, verb, args, object, error, info);
}
-static void legacy_hooked_call_v12(
+static void legacy_hooked_call_x3(
struct afb_api_x3 *apix3,
const char *api,
const char *verb,
struct json_object *args,
- void (*callback)(void*, int, struct json_object*),
+ void (*callback)(void*, int, struct json_object*, struct afb_api_x3*),
void *closure)
{
struct afb_export *export = from_api_x3(apix3);
- afb_calls_legacy_hooked_call_v12(export, api, verb, args, callback, closure);
+ afb_calls_legacy_hooked_call_v3(export, api, verb, args, callback, closure);
}
-static void legacy_hooked_call_x3(
+static int legacy_hooked_call_sync(
struct afb_api_x3 *apix3,
const char *api,
const char *verb,
struct json_object *args,
- void (*callback)(void*, int, struct json_object*, struct afb_api_x3*),
- void *closure)
+ struct json_object **result)
{
struct afb_export *export = from_api_x3(apix3);
- afb_calls_legacy_hooked_call_v3(export, api, verb, args, callback, closure);
+ return afb_calls_legacy_hooked_call_sync(export, api, verb, args, result);
}
-static int legacy_hooked_call_sync(
+#if WITH_LEGACY_BINDING_V1 || WITH_LEGACY_BINDING_V2
+
+static void legacy_hooked_call_v12(
struct afb_api_x3 *apix3,
const char *api,
const char *verb,
struct json_object *args,
- struct json_object **result)
+ void (*callback)(void*, int, struct json_object*),
+ void *closure)
{
struct afb_export *export = from_api_x3(apix3);
- return afb_calls_legacy_hooked_call_sync(export, api, verb, args, result);
+ afb_calls_legacy_hooked_call_v12(export, api, verb, args, callback, closure);
}
/* the interface for services */
@@ -748,6 +764,8 @@ static const struct afb_service_itf_x1 hooked_service_itf = {
};
#endif
+#endif
+
/******************************************************************************
******************************************************************************
******************************************************************************
@@ -762,6 +780,7 @@ static int api_set_verbs_v2_cb(
struct afb_api_x3 *api,
const struct afb_verb_v2 *verbs)
{
+#if WITH_LEGACY_BINDING_V2
struct afb_export *export = from_api_x3(api);
if (export->unsealed) {
@@ -770,6 +789,9 @@ static int api_set_verbs_v2_cb(
}
errno = EPERM;
+#else
+ errno = ECANCELED;
+#endif
return -1;
}
@@ -1305,10 +1327,12 @@ static void set_interfaces(struct afb_export *export)
export->export.v1.daemon.itf = export->hookditf ? &hooked_daemon_itf : &daemon_itf;
break;
#endif
+#if WITH_LEGACY_BINDING_V2
case Api_Version_2:
export->export.v2->daemon.itf = export->hookditf ? &hooked_daemon_itf : &daemon_itf;
export->export.v2->service.itf = export->hooksvc ? &hooked_service_itf : &service_itf;
break;
+#endif
}
#else
@@ -1320,10 +1344,12 @@ static void set_interfaces(struct afb_export *export)
export->export.v1.daemon.itf = &daemon_itf;
break;
#endif
+#if WITH_LEGACY_BINDING_V2
case Api_Version_2:
export->export.v2->daemon.itf = &daemon_itf;
export->export.v2->service.itf = &service_itf;
break;
+#endif
}
#endif
@@ -1437,6 +1463,7 @@ struct afb_export *afb_export_create_v1(struct afb_apiset *declare_set,
}
#endif
+#if WITH_LEGACY_BINDING_V2
struct afb_export *afb_export_create_v2(struct afb_apiset *declare_set,
struct afb_apiset *call_set,
const char *apiname,
@@ -1459,6 +1486,7 @@ struct afb_export *afb_export_create_v2(struct afb_apiset *declare_set,
}
return export;
}
+#endif
struct afb_export *afb_export_create_v3(struct afb_apiset *declare_set,
struct afb_apiset *call_set,
@@ -1526,6 +1554,7 @@ int afb_export_unshare_session(struct afb_export *export)
return 0;
}
+#if WITH_LEGACY_BINDING_V1 || WITH_LEGACY_BINDING_V2
int afb_export_handle_events_v12(struct afb_export *export, void (*on_event)(const char *event, struct json_object *object))
{
/* check version */
@@ -1533,8 +1562,10 @@ int afb_export_handle_events_v12(struct afb_export *export, void (*on_event)(con
#if WITH_LEGACY_BINDING_V1
case Api_Version_1:
#endif
+#if WITH_LEGACY_BINDING_V2
case Api_Version_2:
break;
+#endif
default:
ERROR("invalid version 12 for API %s", export->api.apiname);
errno = EINVAL;
@@ -1544,6 +1575,7 @@ int afb_export_handle_events_v12(struct afb_export *export, void (*on_event)(con
export->on_any_event_v12 = on_event;
return ensure_listener(export);
}
+#endif
int afb_export_handle_events_v3(struct afb_export *export, void (*on_event)(struct afb_api_x3 *api, const char *event, struct json_object *object))
{
@@ -1602,7 +1634,9 @@ void afb_export_logmask_set(struct afb_export *export, int mask)
#if WITH_LEGACY_BINDING_V1
case Api_Version_1: export->export.v1.verbosity = verbosity_from_mask(mask); break;
#endif
+#if WITH_LEGACY_BINDING_V2
case Api_Version_2: export->export.v2->verbosity = verbosity_from_mask(mask); break;
+#endif
}
}
@@ -1655,9 +1689,11 @@ static void do_init(int sig, void *closure)
.closure = to_api_x3(export) }) : 0;
break;
#endif
+#if WITH_LEGACY_BINDING_V2
case Api_Version_2:
rc = export->init.v2 ? export->init.v2() : 0;
break;
+#endif
case Api_Version_3:
rc = export->init.v3 ? export->init.v3(to_api_x3(export)) : 0;
break;
@@ -1690,11 +1726,14 @@ int afb_export_start(struct afb_export *export)
}
/* set event handling */
+#if WITH_LEGACY_BINDING_V1 || WITH_LEGACY_BINDING_V2
switch (export->version) {
#if WITH_LEGACY_BINDING_V1
case Api_Version_1:
#endif
+#if WITH_LEGACY_BINDING_V2
case Api_Version_2:
+#endif
if (export->on_any_event_v12) {
rc = afb_export_handle_events_v12(export, export->on_any_event_v12);
break;
@@ -1708,6 +1747,7 @@ int afb_export_start(struct afb_export *export)
ERROR("Can't set event handler for %s", export->api.apiname);
return -1;
}
+#endif
#if WITH_AFB_HOOK
/* Starts the service */
@@ -1747,9 +1787,11 @@ static void api_call_cb(void *closure, struct afb_xreq *xreq)
afb_api_so_v1_process_call(export->desc.v1, xreq);
break;
#endif
+#if WITH_LEGACY_BINDING_V2
case Api_Version_2:
afb_api_so_v2_process_call(export->desc.v2, xreq);
break;
+#endif
case Api_Version_3:
afb_api_v3_process_call(export->desc.v3, xreq);
break;
@@ -1770,9 +1812,11 @@ static struct json_object *api_describe_cb(void *closure)
result = afb_api_so_v1_make_description_openAPIv3(export->desc.v1, export->api.apiname);
break;
#endif
+#if WITH_LEGACY_BINDING_V2
case Api_Version_2:
result = afb_api_so_v2_make_description_openAPIv3(export->desc.v2, export->api.apiname);
break;
+#endif
case Api_Version_3:
result = afb_api_v3_make_description_openAPIv3(export->desc.v3, export->api.apiname);
break;
diff --git a/src/afb-export.h b/src/afb-export.h
index cb65020a..c763c84c 100644
--- a/src/afb-export.h
+++ b/src/afb-export.h
@@ -24,8 +24,6 @@ struct afb_apiset;
struct afb_context;
struct afb_xreq;
-struct afb_binding_v2;
-struct afb_binding_data_v2;
struct afb_api_v3;
struct afb_api_x3;
struct afb_event_x2;
@@ -39,15 +37,6 @@ extern struct afb_export *afb_export_create_none_for_path(
int (*creator)(void*, struct afb_api_x3*),
void *closure);
-extern struct afb_export *afb_export_create_v2(struct afb_apiset *declare_set,
- struct afb_apiset *call_set,
- const char *apiname,
- const struct afb_binding_v2 *binding,
- struct afb_binding_data_v2 *data,
- int (*init)(),
- void (*onevent)(const char*, struct json_object*),
- const char* path);
-
extern struct afb_export *afb_export_create_v3(struct afb_apiset *declare_set,
struct afb_apiset *call_set,
const char *apiname,
@@ -74,11 +63,6 @@ extern int afb_export_preinit_x3(
int (*preinit)(void *,struct afb_api_x3*),
void *closure);
-extern int afb_export_handle_events_v12(
- struct afb_export *export,
- void (*on_event)(const char *event, struct json_object *object));
-
-
extern int afb_export_handle_events_v3(
struct afb_export *export,
void (*on_event)(struct afb_api_x3 *api, const char *event, struct json_object *object));
@@ -136,3 +120,26 @@ extern struct afb_binding_v1 *afb_export_register_v1(
#endif
+#if WITH_LEGACY_BINDING_V2
+
+struct afb_binding_v2;
+struct afb_binding_data_v2;
+
+extern struct afb_export *afb_export_create_v2(struct afb_apiset *declare_set,
+ struct afb_apiset *call_set,
+ const char *apiname,
+ const struct afb_binding_v2 *binding,
+ struct afb_binding_data_v2 *data,
+ int (*init)(),
+ void (*onevent)(const char*, struct json_object*),
+ const char* path);
+
+#endif
+
+#if WITH_LEGACY_BINDING_V1 || WITH_LEGACY_BINDING_V2
+extern int afb_export_handle_events_v12(
+ struct afb_export *export,
+ void (*on_event)(const char *event, struct json_object *object));
+#endif
+
+
diff --git a/src/afb-xreq.c b/src/afb-xreq.c
index f4756a9f..8cc22c3f 100644
--- a/src/afb-xreq.c
+++ b/src/afb-xreq.c
@@ -722,6 +722,7 @@ int afb_xreq_legacy_subcall_sync(struct afb_xreq *xreq, const char *api, const c
return afb_req_x2_subcall_sync_legacy(xreq_to_req_x2(xreq), api, verb, args, result);
}
+#if WITH_LEGACY_BINDING_V1
static int xreq_session_check_apply_v1(struct afb_xreq *xreq, int sessionflags)
{
int loa;
@@ -763,6 +764,7 @@ static int xreq_session_check_apply_v1(struct afb_xreq *xreq, int sessionflags)
return 0;
}
+#endif
static int xreq_session_check_apply_v2(struct afb_xreq *xreq, uint32_t sessionflags, const struct afb_auth *auth)
{
@@ -800,6 +802,7 @@ static int xreq_session_check_apply_v2(struct afb_xreq *xreq, uint32_t sessionfl
return 0;
}
+#if WITH_LEGACY_BINDING_V1
void afb_xreq_call_verb_v1(struct afb_xreq *xreq, const struct afb_verb_desc_v1 *verb)
{
if (!verb)
@@ -808,7 +811,9 @@ void afb_xreq_call_verb_v1(struct afb_xreq *xreq, const struct afb_verb_desc_v1
if (!xreq_session_check_apply_v1(xreq, verb->session))
verb->callback(xreq_to_req_x1(xreq));
}
+#endif
+#if WITH_LEGACY_BINDING_V2
void afb_xreq_call_verb_v2(struct afb_xreq *xreq, const struct afb_verb_v2 *verb)
{
if (!verb)
@@ -817,6 +822,7 @@ void afb_xreq_call_verb_v2(struct afb_xreq *xreq, const struct afb_verb_v2 *verb
if (!xreq_session_check_apply_v2(xreq, verb->session, verb->auth))
verb->callback(xreq_to_req_x1(xreq));
}
+#endif
void afb_xreq_call_verb_v3(struct afb_xreq *xreq, const struct afb_verb_v3 *verb)
{
diff --git a/src/afb-xreq.h b/src/afb-xreq.h
index da966a44..f1945a02 100644
--- a/src/afb-xreq.h
+++ b/src/afb-xreq.h
@@ -85,6 +85,7 @@ struct afb_xreq
/* req wrappers for xreq */
extern struct afb_req_x1 afb_xreq_unstore(struct afb_stored_req *sreq);
+
extern void afb_xreq_addref(struct afb_xreq *xreq);
extern void afb_xreq_unref(struct afb_xreq *xreq);
extern void afb_xreq_unhooked_addref(struct afb_xreq *xreq);
@@ -154,8 +155,13 @@ extern void afb_xreq_init(struct afb_xreq *xreq, const struct afb_xreq_query_itf
extern void afb_xreq_process(struct afb_xreq *xreq, struct afb_apiset *apiset);
+#if WITH_LEGACY_BINDING_V1
extern void afb_xreq_call_verb_v1(struct afb_xreq *xreq, const struct afb_verb_desc_v1 *verb);
+#endif
+#if WITH_LEGACY_BINDING_V2
extern void afb_xreq_call_verb_v2(struct afb_xreq *xreq, const struct afb_verb_v2 *verb);
+#endif
+
extern void afb_xreq_call_verb_v3(struct afb_xreq *xreq, const struct afb_verb_v3 *verb);
extern const char *xreq_on_behalf_cred_export(struct afb_xreq *xreq);