/*
- * Copyright (C) 2015, 2016, 2017 "IoT.bzh"
+ * Copyright (C) 2015-2018 "IoT.bzh"
* Author José Bollo <jose.bollo@iot.bzh>
*
* Licensed under the Apache License, Version 2.0 (the "License");
#error "you should define AFB_VERSION"
#endif
+/* set the HAS_ options */
+#if defined(WITH_MONITORING_OPTION)
+# define HAS_MONITORING 1
+#else
+# define HAS_MONITORING 0
+#endif
+#if defined(WITH_DBUS_TRANSPARENCY)
+# define HAS_DBUS 1
+#else
+# define HAS_DBUS 0
+#endif
+
// default
#define DEFLT_CNTX_TIMEOUT 32000000 // default Client Connection
// Timeout: few more than one year
#define SET_MODE 18
-#define DBUS_CLIENT 20
-#define DBUS_SERVICE 21
+#if HAS_DBUS
+# define DBUS_CLIENT 20
+# define DBUS_SERVICE 21
+#endif
+
#define SO_BINDING 22
#define SET_SESSIONMAX 23
#define SET_TRACEEVT 'E'
#define SET_EXEC 'e'
#define DISPLAY_HELP 'h'
-#if defined(WITH_MONITORING_OPTION)
-#define SET_MONITORING 'M'
+#if HAS_MONITORING
+# define SET_MONITORING 'M'
#endif
#define SET_NAME 'n'
#define SET_TCP_PORT 'p'
#define SET_QUIET 'q'
#define SET_RNDTOKEN 'r'
#define SET_TRACESVC 'S'
+#define SET_TRACESES 's'
#define SET_TRACEREQ 'T'
#define SET_AUTH_TOKEN 't'
#define SET_UPLOAD_DIR 'u'
#define SET_WORK_DIR 'w'
const char shortopts[] =
- "c:D:E:ehn:p:qrT:t:u:Vvw:"
-#if defined(WITH_MONITORING_OPTION)
+ "c:D:E:ehn:p:qrS:s:T:t:u:Vvw:"
+#if HAS_MONITORING
"M"
#endif
;
{SET_MODE, 1, "mode", "Set the mode: either local, remote or global"},
+#if HAS_DBUS
{DBUS_CLIENT, 1, "dbus-client", "Bind to an afb service through dbus"},
{DBUS_SERVICE, 1, "dbus-server", "Provides an afb service through dbus"},
+#endif
{WS_CLIENT, 1, "ws-client", "Bind to an afb service through websocket"},
{WS_SERVICE, 1, "ws-server", "Provides an afb service through websockets"},
{SET_TRACEDITF, 1, "traceditf", "Log the requests: no, common, extra, all"},
{SET_TRACESVC, 1, "tracesvc", "Log the requests: no, all"},
{SET_TRACEEVT, 1, "traceevt", "Log the requests: no, common, extra, all"},
+ {SET_TRACESES, 1, "traceses", "Log the sessions: no, all"},
{ADD_CALL, 1, "call", "call at start format of val: API/VERB:json-args"},
{SET_NO_HTTPD, 0, "no-httpd", "Forbids HTTP service"},
{SET_EXEC, 0, "exec", "Execute the remaining arguments"},
-#if defined(WITH_MONITORING_OPTION)
+#if HAS_MONITORING
{SET_MONITORING, 0, "monitoring", "enable HTTP monitoring at <ROOT>/monitoring/"},
#endif
{0, 0, NULL, NULL}
{ NULL, 0 }
};
+static struct enumdesc traceses_desc[] = {
+ { "no", 0 },
+ { "common", afb_hook_flags_session_common },
+ { "all", afb_hook_flags_session_all },
+ { NULL, 0 }
+};
+
static struct enumdesc mode_desc[] = {
{ "local", AFB_MODE_LOCAL },
{ "remote", AFB_MODE_REMOTE },
+--------------------------------------------------------- */
static void printVersion(FILE * file)
{
- static const char version[] =
- "\n"
- " AFB [Application Framework Binder] version="AFB_VERSION"\n"
+ static char pm[2] = { '-', '+' };
+ fprintf(file,
"\n"
- " Copyright (C) 2015, 2016, 2017 \"IoT.bzh\"\n"
+ " AGL Framework Binder [AFB %s] %cDBUS %cMONITOR\n"
+ "\n",
+ AFB_VERSION,
+ pm[HAS_DBUS],
+ pm[HAS_MONITORING]
+ );
+ fprintf(file,
+ " Copyright (C) 2015-2018 \"IoT.bzh\"\n"
" AFB comes with ABSOLUTELY NO WARRANTY.\n"
" Licence Apache 2\n"
- "\n";
-
- fprintf(file, "%s", version);
+ "\n");
}
/*----------------------------------------------------------
config->mode = argvalenum(optc, mode_desc);
break;
+#if HAS_DBUS
case DBUS_CLIENT:
list_add(&config->dbus_clients, argvalstr(optc));
break;
case DBUS_SERVICE:
list_add(&config->dbus_servers, argvalstr(optc));
break;
+#endif
case WS_CLIENT:
list_add(&config->ws_clients, argvalstr(optc));
config->traceevt = argvalenum(optc, traceevt_desc);
break;
+ case SET_TRACESES:
+ config->traceses = argvalenum(optc, traceses_desc);
+ break;
+
case SET_NO_HTTPD:
noarg(optc);
config->noHttpd = 1;
config->random_token = 1;
break;
-#if defined(WITH_MONITORING_OPTION)
+#if HAS_MONITORING
case SET_MONITORING:
config->monitoring = 1;
break;
if (config->ldpaths == NULL && config->weak_ldpaths == NULL && !config->no_ldpaths)
list_add(&config->ldpaths, BINDING_INSTALL_DIR);
-#if defined(WITH_MONITORING_OPTION)
+#if HAS_MONITORING
if (config->monitoring)
list_add(&config->aliases, strdup("/monitoring:"BINDING_INSTALL_DIR"/monitoring"));
#endif
S(name)
L(aliases)
+#if HAS_DBUS
L(dbus_clients)
L(dbus_servers)
+#endif
L(ws_clients)
L(ws_servers)
L(so_bindings)
E(traceditf,traceditf_desc)
E(tracesvc,tracesvc_desc)
E(traceevt,traceevt_desc)
+ E(traceses,traceses_desc)
B(no_ldpaths)
B(noHttpd)
B(background)
+#if HAS_MONITORING
B(monitoring)
+#endif
B(random_token)
P("---END-OF-CONFIG---\n");
on_environment_enum(&config->traceditf, "AFB_TRACEDITF", traceditf_desc);
on_environment_enum(&config->tracesvc, "AFB_TRACESVC", tracesvc_desc);
on_environment_enum(&config->traceevt, "AFB_TRACEEVT", traceevt_desc);
+ on_environment_enum(&config->traceses, "AFB_TRACESES", traceses_desc);
on_environment_list(&config->ldpaths, "AFB_LDPATHS");
}
S(name)
L(aliases)
+#if HAS_DBUS
L(dbus_clients)
L(dbus_servers)
+#endif
L(ws_clients)
L(ws_servers)
L(so_bindings)
E(traceditf,traceditf_desc)
E(tracesvc,tracesvc_desc)
E(traceevt,traceevt_desc)
+ E(traceses,traceses_desc)
B(no_ldpaths)
B(noHttpd)
B(background)
+#if HAS_MONITORING
B(monitoring)
+#endif
B(random_token)
#undef E