URI: 
       tAdd -l flag to list numeric values of events - wendy - watch files/directories and run commands on any event
  HTML git clone git://z3bra.org/wendy
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit cff44da04995e9f4eda7483b47047295d345f1e6
   DIR parent 0176b6dc43a8dfb6682c3a76634e7b78e8354ed6
  HTML Author: Willy Goiffon <dev@z3bra.org>
       Date:   Fri, 13 Mar 2020 11:04:36 +0100
       
       Add -l flag to list numeric values of events
       
       Diffstat:
         M wendy.1                             |       4 +++-
         M wendy.c                             |      22 ++++++++++++++++++++--
       
       2 files changed, 23 insertions(+), 3 deletions(-)
       ---
   DIR diff --git a/wendy.1 b/wendy.1
       t@@ -6,7 +6,7 @@
        .Nd inotify based event watcher
        .Sh SYNOPSIS
        .Nm wendy
       -.Op Fl adrv
       +.Op Fl adlrv
        .Op Fl m Ar mask
        .Op Fl w Ar inode
        .Op command Op Ar args...
       t@@ -24,6 +24,8 @@ Directory mode. Only directories will be watched, while regular
        files will be skipped (even if explicitely set with -w). See IN_ONLYDIR
        from
        .Xr inotify 7 .
       +.It Fl l
       +List events along with their numeric values.
        .It Fl r
        Recursive mode. Everytime an IN_CREATE event is triggered,
        a watch is added on the target file/directory.
   DIR diff --git a/wendy.c b/wendy.c
       t@@ -22,7 +22,7 @@ struct watcher {
        
        SLIST_HEAD(watchers, watcher) head;
        
       -char *evname[] = {
       +char *evname[IN_ALL_EVENTS] = {
                [IN_ACCESS] =        "ACCESS",
                [IN_MODIFY] =        "MODIFY",
                [IN_ATTRIB] =        "ATTRIB",
       t@@ -38,7 +38,7 @@ char *evname[] = {
        };
        
        int verbose = 0;
       -int aflag = 0, dflag = 0, rflag = 0;
       +int aflag = 0, dflag = 0, lflag = 0, rflag = 0;
        
        void
        usage(char *name)
       t@@ -54,6 +54,16 @@ basename(char *p)
                return *b ? b + 1 : p;
        }
        
       +int
       +listevents(char **ev)
       +{
       +        int i;
       +        for (i=0; i<IN_ALL_EVENTS; i++)
       +                if (ev[i])
       +                        printf("%s\t%d\n", ev[i], i);
       +        return 0;
       +}
       +
        struct watcher *
        getwatcher(struct watchers *h, int wd)
        {
       t@@ -147,6 +157,9 @@ main (int argc, char **argv)
                case 'd':
                        dflag = 1;
                        break;
       +        case 'l':
       +                lflag = 1;
       +                break;
                case 'r':
                        rflag = 1;
                        break;
       t@@ -163,6 +176,11 @@ main (int argc, char **argv)
                        usage(argv0);
                } ARGEND;
        
       +        if (lflag) {
       +                listevents(evname);
       +                return 0;
       +        }
       +
                /* remaining arguments is the command to run on event */
                cmd = (argc > 0) ? argv : NULL;