+ if (config->uploaddir == NULL)
+ config->uploaddir = ".";
+
+ // if no Angular/HTML5 rootbase let's try '/' as default
+ if (config->rootbase == NULL)
+ config->rootbase = "/opa";
+
+ if (config->rootapi == NULL)
+ config->rootapi = "/api";
+
+ if (config->ldpaths == NULL)
+ list_add(&config->ldpaths, BINDING_INSTALL_DIR);
+
+ // if no config dir create a default path from uploaddir
+ if (config->console == NULL) {
+ config->console = malloc(512);
+ strncpy(config->console, config->uploaddir, 512);
+ strncat(config->console, "/AFB-console.out", 512);
+ }
+}
+
+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