-void afb_config_dump(struct afb_config *config)
-{
- struct afb_config_list *l;
- struct enumdesc *e;
- char **v;
-
-#define NN(x) (x)?:""
-#define P(...) fprintf(stderr, __VA_ARGS__)
-#define PF(x) P("-- %15s: ", #x)
-#define PE P("\n")
-#define S(x) PF(x);P("%s",NN(config->x));PE;
-#define D(x) PF(x);P("%d",config->x);PE;
-#define H(x) PF(x);P("%x",config->x);PE;
-#define B(x) PF(x);P("%s",config->x?"yes":"no");PE;
-#define L(x) PF(x);l=config->x;if(l){P("%s\n",NN(l->value));for(l=l->next;l;l=l->next)P("-- %15s %s\n","",NN(l->value));}else PE;
-#define E(x,d) for(e=d;e->name&&e->value!=config->x;e++);if(e->name){PF(x);P("%s",e->name);PE;}else{D(x);}
-#define V(x) P("-- %15s:", #x);for(v=config->x;v&&*v;v++)P(" %s",*v); PE;
-
- P("---BEGIN-OF-CONFIG---\n");
- S(console)
- S(rootdir)
- S(roothttp)
- S(rootbase)
- S(rootapi)
- S(workdir)
- S(uploaddir)
- S(token)
-
- L(aliases)
- L(dbus_clients)
- L(dbus_servers)
- L(ws_clients)
- L(ws_servers)
- L(so_bindings)
- L(ldpaths)
- L(calls)
-
- V(exec)
-
- D(httpdPort)
- B(background)
- D(cacheTimeout)
- D(apiTimeout)
- D(cntxTimeout)
- D(nbSessionMax)
- E(mode,mode_desc)
- E(tracereq,tracereq_desc)
- E(traceditf,traceditf_desc)
- B(noHttpd)
- P("---END-OF-CONFIG---\n");
-
-#undef V
-#undef E
-#undef L
-#undef B
-#undef H
-#undef D
-#undef S
-#undef PE
-#undef PF
-#undef P
-#undef NN
-}
-
-struct afb_config *afb_config_parse_arguments(int argc, char **argv)
-{
- struct afb_config *result;
-
- result = calloc(1, sizeof *result);
+static void on_environment_bool(struct json_object *config, int optid, const char *name)
+{
+ char *value = getenv(name);
+ int asbool;
+
+ if (value) {
+ asbool = string_to_bool(value);
+ if (asbool < 0)
+ WARNING("Unknown value %s for environment variable %s, ignored", value, name);
+ else
+ config_set_bool(config, optid, asbool);
+ }
+}
+
+static void parse_environment(struct json_object *config)
+{
+ on_environment_enum(config, SET_TRACEREQ, "AFB_TRACEREQ", afb_hook_flags_xreq_from_text);
+ on_environment_enum(config, SET_TRACEEVT, "AFB_TRACEEVT", afb_hook_flags_evt_from_text);
+ on_environment_enum(config, SET_TRACESES, "AFB_TRACESES", afb_hook_flags_session_from_text);
+ on_environment_enum(config, SET_TRACEAPI, "AFB_TRACEAPI", afb_hook_flags_api_from_text);
+ on_environment_enum(config, SET_TRACEGLOB, "AFB_TRACEGLOB", afb_hook_flags_global_from_text);
+ on_environment(config, ADD_LDPATH, "AFB_LDPATHS", config_add_str);
+ on_environment(config, ADD_SET, "AFB_SET", config_mix2_str);
+#if !defined(REMOVE_LEGACY_TRACE)
+ on_environment_enum(config, SET_TRACEDITF, "AFB_TRACEDITF", afb_hook_flags_legacy_ditf_from_text);
+ on_environment_enum(config, SET_TRACESVC, "AFB_TRACESVC", afb_hook_flags_legacy_svc_from_text);
+#endif
+ on_environment_bool(config, SET_TRAP_FAULTS, "AFB_TRAP_FAULTS");
+}