diff options
author | David Robillard <d@drobilla.net> | 2020-08-14 17:32:01 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-03-08 23:23:05 -0500 |
commit | 0daee5d67f5924f260651556a46f0af354fca341 (patch) | |
tree | 2e000a4090e7d9ee2d57b1757e831942a70bc2c2 /src/serdi.c | |
parent | 2ab2b5f2c7bd4d26aa99eee959f0e5192b3813dc (diff) | |
download | serd-0daee5d67f5924f260651556a46f0af354fca341.tar.gz serd-0daee5d67f5924f260651556a46f0af354fca341.tar.bz2 serd-0daee5d67f5924f260651556a46f0af354fca341.zip |
Add empty syntax type for suppressing output
Diffstat (limited to 'src/serdi.c')
-rw-r--r-- | src/serdi.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/serdi.c b/src/serdi.c index 72b7afe1..e546f463 100644 --- a/src/serdi.c +++ b/src/serdi.c @@ -31,6 +31,7 @@ #include <stdbool.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #define SERDI_ERROR(msg) fprintf(stderr, "serdi: " msg) #define SERDI_ERRORF(fmt, ...) fprintf(stderr, "serdi: " fmt, __VA_ARGS__) @@ -95,14 +96,15 @@ main(int argc, char** argv) return print_usage(argv[0], true); } - SerdSyntax input_syntax = (SerdSyntax)0; - SerdSyntax output_syntax = (SerdSyntax)0; + SerdSyntax input_syntax = SERD_SYNTAX_EMPTY; + SerdSyntax output_syntax = SERD_SYNTAX_EMPTY; SerdReaderFlags reader_flags = 0; SerdWriterFlags writer_flags = 0; bool from_string = false; bool from_stdin = false; bool bulk_read = true; bool bulk_write = false; + bool osyntax_set = false; bool quiet = false; size_t stack_size = 4194304; const char* add_prefix = NULL; @@ -158,11 +160,14 @@ main(int argc, char** argv) } stack_size = (size_t)size; } else if (argv[a][1] == 'o') { + osyntax_set = true; if (++a == argc) { return missing_arg(argv[0], 'o'); } - if (!(output_syntax = serd_syntax_by_name(argv[a]))) { + if (!strcmp(argv[a], "empty")) { + output_syntax = SERD_SYNTAX_EMPTY; + } else if (!(output_syntax = serd_syntax_by_name(argv[a]))) { return print_usage(argv[0], true); } } else if (argv[a][1] == 'p') { @@ -206,7 +211,7 @@ main(int argc, char** argv) } const bool input_has_graphs = serd_syntax_has_graphs(input_syntax); - if (!output_syntax) { + if (!output_syntax && !osyntax_set) { output_syntax = input_has_graphs ? SERD_NQUADS : SERD_NTRIPLES; } |