Add hooking for events
[src/app-framework-binder.git] / src / afb-config.c
index 1b4a369..98dd4e5 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #define _GNU_SOURCE
-#define NO_BINDING_VERBOSE_MACRO
+#define AFB_BINDING_PRAGMA_NO_VERBOSE_MACRO
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -31,7 +31,7 @@
 #include "afb-config.h"
 #include "afb-hook.h"
 
-#include <afb/afb-binding.h>
+#include <afb/afb-binding-v1.h>
 
 #if !defined(BINDING_INSTALL_DIR)
 #error "you should define BINDING_INSTALL_DIR"
 
 #define SET_NO_HTTPD       28
 
+#define ADD_CALL           'c'
 #define SET_TRACEDITF      'D'
+#define SET_TRACEEVT       'E'
 #define SET_EXEC           'e'
 #define DISPLAY_HELP       'h'
 #define SET_QUIET          'q'
 #define SET_RNDTOKEN       'r'
+#define SET_TRACESVC       'S'
 #define SET_TRACEREQ       'T'
 #define SET_AUTH_TOKEN     't'
 #define SET_UPLOAD_DIR     'u'
 #define SET_VERBOSE        'v'
 #define SET_WORK_DIR       'w'
 
-#define SHORTOPTS      "D:ehqrT:t:u:Vvw:"
+#define SHORTOPTS      "c:D:E:ehqrT:t:u:Vvw:"
 
 // Command line structure hold cli --command + help text
 typedef struct {
@@ -151,6 +154,10 @@ static AFB_options cliOptions[] = {
 
        {SET_TRACEREQ,      1, "tracereq",    "Log the requests: no, common, extra, all"},
        {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"},
+
+       {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"},
@@ -182,6 +189,20 @@ static struct enumdesc traceditf_desc[] = {
        { NULL, 0 }
 };
 
+static struct enumdesc tracesvc_desc[] = {
+       { "no",     0 },
+       { "all",    afb_hook_flags_svc_all },
+       { NULL, 0 }
+};
+
+static struct enumdesc traceevt_desc[] = {
+       { "no",     0 },
+       { "common", afb_hook_flags_evt_common },
+       { "extra",  afb_hook_flags_evt_extra },
+       { "all",    afb_hook_flags_evt_all },
+       { NULL, 0 }
+};
+
 static struct enumdesc mode_desc[] = {
        { "local",  AFB_MODE_LOCAL },
        { "remote", AFB_MODE_REMOTE },
@@ -437,6 +458,10 @@ static void parse_arguments(int argc, char **argv, struct afb_config *config)
                        list_add(&config->ldpaths, argvalstr(optc));
                        break;
 
+               case ADD_CALL:
+                       list_add(&config->calls, argvalstr(optc));
+                       break;
+
                case SET_SESSION_DIR:
                        /* config->sessiondir = argvalstr(optc); */
                        WARNING("Obsolete otpion %s ignored", optname(optc));
@@ -500,6 +525,14 @@ static void parse_arguments(int argc, char **argv, struct afb_config *config)
                        config->traceditf = argvalenum(optc, traceditf_desc);
                        break;
 
+               case SET_TRACESVC:
+                       config->tracesvc = argvalenum(optc, tracesvc_desc);
+                       break;
+
+               case SET_TRACEEVT:
+                       config->traceevt = argvalenum(optc, traceevt_desc);
+                       break;
+
                case SET_NO_HTTPD:
                        noarg(optc);
                        config->noHttpd = 1;
@@ -620,6 +653,7 @@ void afb_config_dump(struct afb_config *config)
        L(ws_servers)
        L(so_bindings)
        L(ldpaths)
+       L(calls)
 
        V(exec)