Add option --weak-ldpaths (for weak loading path)
authorJosé Bollo <jose.bollo@iot.bzh>
Fri, 25 Aug 2017 11:09:13 +0000 (13:09 +0200)
committerJosé Bollo <jose.bollo@iot.bzh>
Fri, 25 Aug 2017 11:09:13 +0000 (13:09 +0200)
This option allows to specify a loading path where
binding that fails on load are ignored.

Change-Id: Ie0646f88ba9207dd117737a8b251a7a42f424f02
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
src/afb-config.c
src/afb-config.h
src/main.c

index 98dd4e5..18f7fa7 100644 (file)
@@ -68,7 +68,7 @@
 #define SET_LDPATH         13
 #define SET_APITIMEOUT     14
 #define SET_CNTXTIMEOUT    15
-
+#define SET_WEAK_LDPATH    16
 
 #define SET_MODE           18
 
@@ -136,6 +136,7 @@ static AFB_options cliOptions[] = {
 
        {SET_LDPATH,        1, "ldpaths",     "Load bindings from dir1:dir2:... [default = " BINDING_INSTALL_DIR "]"},
        {SO_BINDING,        1, "binding",     "Load the binding of path"},
+       {SET_WEAK_LDPATH,   1, "weak-ldpaths","Same as --ldpaths but ignore erros"},
 
        {SET_AUTH_TOKEN,    1, "token",       "Initial Secret [default=no-session, --token= for session without authentication]"},
        {SET_RNDTOKEN,      0, "random-token","Creates a random token"},
@@ -458,6 +459,10 @@ static void parse_arguments(int argc, char **argv, struct afb_config *config)
                        list_add(&config->ldpaths, argvalstr(optc));
                        break;
 
+               case SET_WEAK_LDPATH:
+                       list_add(&config->weak_ldpaths, argvalstr(optc));
+                       break;
+
                case ADD_CALL:
                        list_add(&config->calls, argvalstr(optc));
                        break;
@@ -607,7 +612,7 @@ static void config_set_default(struct afb_config *config)
        if (config->rootapi == NULL)
                config->rootapi = "/api";
 
-       if (config->ldpaths == NULL)
+       if (config->ldpaths == NULL && config->weak_ldpaths == NULL)
                list_add(&config->ldpaths, BINDING_INSTALL_DIR);
 
        // if no config dir create a default path from uploaddir
index 4ff5d14..a81d296 100644 (file)
@@ -43,6 +43,7 @@ struct afb_config {
        struct afb_config_list *ws_servers;
        struct afb_config_list *so_bindings;
        struct afb_config_list *ldpaths;
+       struct afb_config_list *weak_ldpaths;
        struct afb_config_list *calls;
 
        char **exec;
index 84bdc61..3999b77 100644 (file)
@@ -593,6 +593,7 @@ static void start(int signum)
        apiset_start_list(config->dbus_clients, afb_api_dbus_add_client, "the afb-dbus client");
        apiset_start_list(config->ws_clients, afb_api_ws_add_client, "the afb-websocket client");
        apiset_start_list(config->ldpaths, afb_api_so_add_pathset_fails, "the binding path set");
+       apiset_start_list(config->weak_ldpaths, afb_api_so_add_pathset_nofails, "the weak binding path set");
        apiset_start_list(config->so_bindings, afb_api_so_add_binding, "the binding");
 
        apiset_start_list(config->dbus_servers, afb_api_dbus_add_server, "the afb-dbus service");