diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2017-06-11 13:33:18 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2017-06-11 13:33:18 +0100 |
commit | 768988d88470ffc1c64c35d6f9d3c37a9a6f75da (patch) | |
tree | e1af2f6bf6b69583bdf25e3cbb83e2c842d925d8 /test/parse.c | |
parent | 602a6b133f83e2349a4b233536fdca90446638cd (diff) | |
download | libnslog-768988d88470ffc1c64c35d6f9d3c37a9a6f75da.tar.gz libnslog-768988d88470ffc1c64c35d6f9d3c37a9a6f75da.tar.bz2 |
Simple parser for filter syntax
Diffstat (limited to 'test/parse.c')
-rw-r--r-- | test/parse.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/parse.c b/test/parse.c new file mode 100644 index 0000000..9fca97b --- /dev/null +++ b/test/parse.c @@ -0,0 +1,25 @@ +#include "nslog/nslog.h" + +#include <stdio.h> +#include <stdlib.h> + +int main(int argc, char **argv) +{ + if (argc != 2) { + fprintf(stderr, "usage: parse 'filtertext'\n"); + return 1; + } + nslog_filter_t *filt; + nslog_error err; + + err = nslog_filter_from_text(argv[1], &filt); + if (err != NSLOG_NO_ERROR) { + fprintf(stderr, "Unable to parse.\n"); + return 2; + } + char *ct = nslog_filter_sprintf(filt); + filt = nslog_filter_unref(filt); + printf("%s\n", ct); + free(ct); + return 0; +} |