aboutsummaryrefslogtreecommitdiffstats
path: root/src/serdi.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-07-05 17:35:14 +0000
committerDavid Robillard <d@drobilla.net>2012-07-05 17:35:14 +0000
commit02a41f39b216ca43056fc2e8183351c077b5dd9c (patch)
tree1224e6ba637bc4879213786228a1b4d1e7516ea2 /src/serdi.c
parent1c7fb2461a581a501f62a7c72a444147da39787e (diff)
downloadserd-02a41f39b216ca43056fc2e8183351c077b5dd9c.tar.gz
serd-02a41f39b216ca43056fc2e8183351c077b5dd9c.tar.bz2
serd-02a41f39b216ca43056fc2e8183351c077b5dd9c.zip
Add error callback to reader and writer for custom error reporting.
Add -q option to serdi to suppress all non-data output, e.g. errors. Resolves #815. git-svn-id: http://svn.drobilla.net/serd/trunk@354 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'src/serdi.c')
-rw-r--r--src/serdi.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/serdi.c b/src/serdi.c
index 4c482884..b90c00e5 100644
--- a/src/serdi.c
+++ b/src/serdi.c
@@ -52,6 +52,7 @@ print_usage(const char* name, bool error)
fprintf(os, " -i SYNTAX Input syntax (`turtle' or `ntriples').\n");
fprintf(os, " -o SYNTAX Output syntax (`turtle' or `ntriples').\n");
fprintf(os, " -p PREFIX Add PREFIX to blank node IDs.\n");
+ fprintf(os, " -q Suppress all output except data.\n");
fprintf(os, " -r ROOT_URI Keep relative URIs within ROOT_URI.\n");
fprintf(os, " -s INPUT Parse INPUT as string (terminates options).\n");
fprintf(os, " -v Display version information and exit.\n");
@@ -79,6 +80,12 @@ bad_arg(const char* name, char opt)
return 1;
}
+static SerdStatus
+quiet_error_sink(void* handle, const SerdError* e)
+{
+ return SERD_SUCCESS;
+}
+
int
main(int argc, char** argv)
{
@@ -93,6 +100,7 @@ main(int argc, char** argv)
bool bulk_read = true;
bool bulk_write = false;
bool full_uris = false;
+ bool quiet = false;
const uint8_t* in_name = NULL;
const uint8_t* add_prefix = NULL;
const uint8_t* chop_prefix = NULL;
@@ -111,6 +119,8 @@ main(int argc, char** argv)
full_uris = true;
} else if (argv[a][1] == 'h') {
return print_usage(argv[0], false);
+ } else if (argv[a][1] == 'q') {
+ quiet = true;
} else if (argv[a][1] == 'v') {
return print_version();
} else if (argv[a][1] == 's') {
@@ -205,6 +215,11 @@ main(int argc, char** argv)
(SerdStatementSink)serd_writer_write_statement,
(SerdEndSink)serd_writer_end_anon);
+ if (quiet) {
+ serd_reader_set_error_sink(reader, quiet_error_sink, NULL);
+ serd_writer_set_error_sink(writer, quiet_error_sink, NULL);
+ }
+
SerdNode root = serd_node_from_string(SERD_URI, root_uri);
serd_writer_set_root_uri(writer, &root);
serd_writer_chop_blank_prefix(writer, chop_prefix);