.set_verbosity = set_verbosity_cb
};
-int afb_api_so_v2_add(const char *path, void *handle, struct afb_apiset *apiset)
+int afb_api_so_v2_add_binding(struct afb_binding_v2 *binding, void *handle, struct afb_apiset *apiset)
{
int rc;
struct api_so_v2 *desc;
- struct afb_binding_v2 *binding;
struct afb_api afb_api;
- /* retrieves the register function */
- binding = dlsym(handle, afb_api_so_v2_descriptor);
- if (!binding)
- return 0;
-
- INFO("binding [%s] looks like an AFB binding V2", path);
-
/* basic checks */
- if (binding->api == NULL || *binding->api == 0) {
- ERROR("binding [%s] bad api name...", path);
- goto error;
- }
- if (!afb_api_is_valid_name(binding->api)) {
- ERROR("binding [%s] invalid api name...", path);
- goto error;
- }
- if (binding->specification == NULL || *binding->specification == 0) {
- ERROR("binding [%s] bad specification...", path);
- goto error;
- }
- if (binding->verbs == NULL) {
- ERROR("binding [%s] no verbs...", path);
- goto error;
- }
+ assert(binding->api);
+ assert(binding->specification);
+ assert(binding->verbs);
/* allocates the description */
desc = calloc(1, sizeof *desc);
/* init the interface */
afb_ditf_init(&desc->ditf, binding->api);
- /* for log purpose, a fake binding is needed here */
-
/* init the binding */
if (binding->init) {
- NOTICE("binding %s [%s] calling init function", binding->api, path);
+ INFO("binding %s calling init function", binding->api);
rc = binding->init(&desc->ditf.interface);
if (rc < 0) {
- ERROR("binding %s [%s] initialisation function failed...", binding->api, path);
+ ERROR("binding %s initialisation function failed...", binding->api);
goto error2;
}
}
afb_api.closure = desc;
afb_api.itf = &so_v2_api_itf;
if (afb_apiset_add(apiset, binding->api, afb_api) < 0) {
- ERROR("binding [%s] can't be registered...", path);
+ ERROR("binding %s can't be registered to set %s...", binding->api, afb_apiset_name(apiset));
goto error2;
}
- NOTICE("binding %s loaded with API prefix %s", path, binding->api);
+ NOTICE("binding %s added to set %s", binding->api, afb_apiset_name(apiset));
return 1;
error2:
return -1;
}
+int afb_api_so_v2_add(const char *path, void *handle, struct afb_apiset *apiset)
+{
+ struct afb_binding_v2 *binding;
+
+ /* retrieves the register function */
+ binding = dlsym(handle, afb_api_so_v2_descriptor);
+ if (!binding)
+ return 0;
+
+ INFO("binding [%s] looks like an AFB binding V2", path);
+
+ /* basic checks */
+ if (binding->api == NULL || *binding->api == 0) {
+ ERROR("binding [%s] bad api name...", path);
+ goto error;
+ }
+ if (!afb_api_is_valid_name(binding->api)) {
+ ERROR("binding [%s] invalid api name...", path);
+ goto error;
+ }
+ if (binding->specification == NULL || *binding->specification == 0) {
+ ERROR("binding [%s] bad specification...", path);
+ goto error;
+ }
+ if (binding->verbs == NULL) {
+ ERROR("binding [%s] no verbs...", path);
+ goto error;
+ }
+
+ return afb_api_so_v2_add_binding(binding, handle, apiset);
+
+ error:
+ return -1;
+}
+