diff options
-rw-r--r-- | journal-notify.c | 19 | ||||
-rw-r--r-- | journal-notify.h | 5 |
2 files changed, 20 insertions, 4 deletions
diff --git a/journal-notify.c b/journal-notify.c index 9819f07..ea73666 100644 --- a/journal-notify.c +++ b/journal-notify.c @@ -9,6 +9,21 @@ const char * program = NULL; +const static char optstring[] = "aehi:m:nor:v"; +const static struct option options_long[] = { + /* name has_arg flag val */ + { "and", no_argument, NULL, 'a' }, + { "extended-regex", no_argument, NULL, 'e' }, + { "help", no_argument, NULL, 'h' }, + { "icon", required_argument, NULL, 'i' }, + { "match", required_argument, NULL, 'm' }, + { "no-case", no_argument, NULL, 'n' }, + { "or", no_argument, NULL, 'o' }, + { "regex", required_argument, NULL, 'r' }, + { "verbose", no_argument, NULL, 'v' }, + { 0, 0, 0, 0 } +}; + /*** notify ***/ int notify(const char * summary, const char * body, const char * icon) { NotifyNotification * notification; @@ -55,7 +70,7 @@ int main(int argc, char **argv) { /* get command line options - part I * just get -h (help), -e and -n (regex options) here */ - while ((i = getopt(argc, argv, OPTSTRING)) != -1) { + while ((i = getopt_long(argc, argv, optstring, options_long, NULL)) != -1) { switch (i) { case 'e': regex_flags |= REG_EXTENDED; @@ -86,7 +101,7 @@ int main(int argc, char **argv) { } /* get command line options - part II*/ - while ((i = getopt(argc, argv, OPTSTRING)) != -1) { + while ((i = getopt_long(argc, argv, optstring, options_long, NULL)) != -1) { switch (i) { case 'a': if (verbose > 1) diff --git a/journal-notify.h b/journal-notify.h index c16942d..858b9c8 100644 --- a/journal-notify.h +++ b/journal-notify.h @@ -8,10 +8,12 @@ #ifndef _JOURNAL_NOTIFY_H #define _JOURNAL_NOTIFY_H +#include <getopt.h> +#include <regex.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <regex.h> +#include <unistd.h> #include <systemd/sd-journal.h> @@ -19,7 +21,6 @@ #include "version.h" -#define OPTSTRING "aehi:m:nor:v" #define DEFAULTICON "dialog-information" /*** notify ***/ |