aboutsummaryrefslogtreecommitdiffstats
path: root/journal-notify.c
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2014-07-21 12:45:55 +0200
committerGravatar Christian Hesse <mail@eworm.de>2014-07-21 12:45:55 +0200
commitd5f62e3a36ac094f4063da42a653c51d7003ac47 (patch)
tree9eb4f1aa67f164cfb291308dfa2019564dc2e233 /journal-notify.c
parenta27eba09c69b48f3f3c6a6ce08fa0ef5c1a37472 (diff)
downloadjournal-notify-d5f62e3a36ac094f4063da42a653c51d7003ac47.tar.gz
journal-notify-d5f62e3a36ac094f4063da42a653c51d7003ac47.tar.zst
allow to add logical AND and OR to matches
Diffstat (limited to 'journal-notify.c')
-rw-r--r--journal-notify.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/journal-notify.c b/journal-notify.c
index 0f54090..bc7740c 100644
--- a/journal-notify.c
+++ b/journal-notify.c
@@ -18,7 +18,7 @@
const char * program = NULL;
-#define OPTSTRING "ehi:m:nr:v"
+#define OPTSTRING "aehi:m:nor:v"
#define DEFAULTICON "dialog-information"
int notify(const char * summary, const char * body, const char * icon) {
@@ -71,7 +71,7 @@ int main(int argc, char **argv) {
regex_flags |= REG_EXTENDED;
break;
case 'h':
- fprintf(stderr, "usage: %s [-e] [-h] [-i ICON] [-m MATCH] [-n] [-r REGEX] [-vv]\n", program);
+ fprintf(stderr, "usage: %s [-e] [-h] [-i ICON] [-m MATCH] [-o -m MATCH] [-a -m MATCH] [-n] [-r REGEX] [-vv]\n", program);
return EXIT_SUCCESS;
case 'n':
regex_flags |= REG_ICASE;
@@ -98,6 +98,16 @@ int main(int argc, char **argv) {
/* get command line options - part II*/
while ((i = getopt(argc, argv, OPTSTRING)) != -1) {
switch (i) {
+ case 'a':
+ if (verbose > 1)
+ printf("Adding logical AND to match...\n");
+
+ if ((rc = sd_journal_add_conjunction(journal)) < 0) {
+ fprintf(stderr, "Failed to add logical AND to match.\n");
+ goto out20;
+ }
+
+ break;
case 'i':
icon = optarg;
break;
@@ -111,6 +121,16 @@ int main(int argc, char **argv) {
}
break;
+ case 'o':
+ if (verbose > 1)
+ printf("Adding logical OR to match...\n");
+
+ if ((rc = sd_journal_add_disjunction(journal)) < 0) {
+ fprintf(stderr, "Failed to add logical OR to match.\n");
+ goto out20;
+ }
+
+ break;
case 'r':
if (verbose > 1)
printf("Adding regular expression '%s'...\n", optarg);