/*
- * Copyright (C) 2015-2018 "IoT.bzh"
+ * Copyright (C) 2015-2019 "IoT.bzh"
* Author José Bollo <jose.bollo@iot.bzh>
*
* Licensed under the Apache License, Version 2.0 (the "License");
#define SET_TRACEDITF 25
#define SET_TRACESVC 26
#endif
-
-#define SET_TRAP_FAULTS 27
-
+#define SET_TRAP_FAULTS 27
+#define ADD_CALL 28
#if defined(WITH_DBUS_TRANSPARENCY)
# define ADD_DBUS_CLIENT 30
# define ADD_DBUS_SERVICE 31
#define ADD_AUTO_API 'A'
#define ADD_BINDING 'b'
#define SET_CONFIG 'C'
-#define ADD_CALL 'c'
+#define SET_COLOR 'c'
#define SET_DAEMON 'D'
#define SET_EXEC 'e'
#define GET_HELP 'h'
static struct option_desc optdefs[] = {
/* *INDENT-OFF* */
{SET_VERBOSE, 0, "verbose", "Verbose Mode, repeat to increase verbosity"},
+ {SET_COLOR, 0, "color", "Colorize the ouput"},
{SET_QUIET, 0, "quiet", "Quiet Mode, repeat to decrease verbosity"},
{SET_LOG, 1, "log", "Tune log level"},
{SET_SESSIONMAX, 1, "session-max", "Max count of session simultaneously [default " d2s(DEFAULT_MAX_SESSION_COUNT) "]"},
+#if WITH_AFB_HOOK
{SET_TRACEREQ, 1, "tracereq", "Log the requests: none, common, extra, all"},
{SET_TRACEEVT, 1, "traceevt", "Log the events: none, common, extra, all"},
{SET_TRACESES, 1, "traceses", "Log the sessions: none, all"},
#if !defined(REMOVE_LEGACY_TRACE)
{SET_TRACEDITF, 1, "traceditf", "Log the daemons: no, common, all"},
{SET_TRACESVC, 1, "tracesvc", "Log the services: no, all"},
+#endif
#endif
{ADD_CALL, 1, "call", "Call at start, format of val: API/VERB:json-args"},
fprintf(file,
"\n"
" AGL Framework Binder [AFB %s] "
+
#if defined(WITH_DBUS_TRANSPARENCY)
"+"
#else
"-"
#endif
"DBUS "
+
#if defined(WITH_MONITORING_OPTION)
"+"
#else
#else
"-"
#endif
- "SUPERVISION [BINDINGS "
+ "SUPERVISION "
+
+#if WITH_AFB_HOOK
+ "+"
+#else
+ "-"
+#endif
+ "HOOK "
+
+#if WITH_TRACE
+ "+"
+#else
+ "-"
+#endif
+ "TRACE "
+
+ "[BINDINGS "
#if defined(WITH_LEGACY_BINDING_V1)
"+"
#else
AFB_VERSION
);
fprintf(file,
- " Copyright (C) 2015-2018 \"IoT.bzh\"\n"
+ " Copyright (C) 2015-2019 \"IoT.bzh\"\n"
" AFB comes with ABSOLUTELY NO WARRANTY.\n"
" Licence Apache 2\n"
"\n");
return config_set_optint_base(config, optid, mini, maxi, 10);
}
+__attribute__((unused))
static void config_set_optenum(struct json_object *config, int optid, int (*func)(const char*))
{
const char *name = get_arg(optid);
verbose_inc();
break;
+ case SET_COLOR:
+ verbose_colorize();
+ break;
+
case SET_QUIET:
verbose_dec();
break;
break;
+#if WITH_AFB_HOOK
case SET_TRACEREQ:
config_set_optenum(config, optid, afb_hook_flags_xreq_from_text);
break;
case SET_TRACESVC:
config_set_optenum(config, optid, afb_hook_flags_legacy_svc_from_text);
break;
+#endif
#endif
case SET_EXEC:
static void on_environment(struct json_object *config, int optid, const char *name, void (*func)(struct json_object*, int, const char*))
{
- char *value = getenv(name);
+ char *value = secure_getenv(name);
if (value && *value)
func(config, optid, value);
}
+__attribute__((unused))
static void on_environment_enum(struct json_object *config, int optid, const char *name, int (*func)(const char*))
{
- char *value = getenv(name);
+ char *value = secure_getenv(name);
if (value) {
if (func(value) == -1)
static void on_environment_bool(struct json_object *config, int optid, const char *name)
{
- char *value = getenv(name);
+ char *value = secure_getenv(name);
int asbool;
if (value) {
static void parse_environment(struct json_object *config)
{
+#if WITH_AFB_HOOK
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
+#endif
+ on_environment(config, ADD_LDPATH, "AFB_LDPATHS", config_add_str);
+ on_environment(config, ADD_SET, "AFB_SET", config_mix2_str);
on_environment_bool(config, SET_TRAP_FAULTS, "AFB_TRAP_FAULTS");
}