summaryrefslogtreecommitdiff
path: root/test/parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/parse.c')
-rw-r--r--test/parse.c25
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;
+}