diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/reader.c | 6 | ||||
-rw-r--r-- | src/reader.h | 2 | ||||
-rw-r--r-- | src/serdi.c | 6 | ||||
-rw-r--r-- | src/world.c | 32 | ||||
-rw-r--r-- | src/world.h | 6 | ||||
-rw-r--r-- | src/writer.c | 38 |
6 files changed, 46 insertions, 44 deletions
diff --git a/src/reader.c b/src/reader.c index dfa80f06..bc8edd52 100644 --- a/src/reader.c +++ b/src/reader.c @@ -40,8 +40,10 @@ r_err(SerdReader* reader, SerdStatus st, const char* fmt, ...) { va_list args; va_start(args, fmt); - const SerdError e = { st, &reader->source.cur, fmt, &args }; - serd_world_error(reader->world, &e); + const SerdMessage msg = { + st, SERD_LOG_LEVEL_ERROR, &reader->source.cur, fmt, &args + }; + serd_world_log(reader->world, &msg); va_end(args); return st; } diff --git a/src/reader.h b/src/reader.h index 506aaff2..7794526b 100644 --- a/src/reader.h +++ b/src/reader.h @@ -46,7 +46,7 @@ typedef struct { struct SerdReaderImpl { SerdWorld* world; const SerdSink* sink; - SerdErrorSink error_sink; + SerdMessageSink msg_sink; void* error_handle; SerdNode* rdf_first; SerdNode* rdf_rest; diff --git a/src/serdi.c b/src/serdi.c index 22727c46..379ab1b9 100644 --- a/src/serdi.c +++ b/src/serdi.c @@ -76,10 +76,10 @@ missing_arg(const char* name, char opt) } static SerdStatus -quiet_error_sink(void* handle, const SerdError* e) +quiet_error_sink(void* handle, const SerdMessage* msg) { (void)handle; - (void)e; + (void)msg; return SERD_SUCCESS; } @@ -219,7 +219,7 @@ main(int argc, char** argv) serd_reader_set_strict(reader, !lax); if (quiet) { - serd_world_set_error_sink(world, quiet_error_sink, NULL); + serd_world_set_message_sink(world, quiet_error_sink, NULL); } SerdNode* root = serd_new_uri(root_uri); diff --git a/src/world.c b/src/world.c index 21bce2f3..0bc4f4bc 100644 --- a/src/world.c +++ b/src/world.c @@ -51,22 +51,22 @@ serd_world_fopen(SerdWorld* world, const char* path, const char* mode) } SerdStatus -serd_world_error(const SerdWorld* world, const SerdError* e) +serd_world_log(const SerdWorld* world, const SerdMessage* msg) { - if (world->error_sink) { - world->error_sink(world->error_handle, e); + if (world->msg_sink) { + world->msg_sink(world->msg_handle, msg); } else { fprintf(stderr, "error: "); - if (e->cursor) { + if (msg->cursor) { fprintf(stderr, "%s:%u:%u: ", - serd_node_get_string(e->cursor->file), - e->cursor->line, - e->cursor->col); + serd_node_get_string(msg->cursor->file), + msg->cursor->line, + msg->cursor->col); } - vfprintf(stderr, e->fmt, *e->args); + vfprintf(stderr, msg->fmt, *msg->args); } - return e->status; + return msg->status; } SerdStatus @@ -74,8 +74,8 @@ serd_world_errorf(const SerdWorld* world, SerdStatus st, const char* fmt, ...) { va_list args; va_start(args, fmt); - const SerdError e = { st, NULL, fmt, &args }; - serd_world_error(world, &e); + const SerdMessage msg = { st, SERD_LOG_LEVEL_ERROR, NULL, fmt, &args }; + serd_world_log(world, &msg); va_end(args); return st; } @@ -119,10 +119,10 @@ serd_world_get_blank(SerdWorld* world) } void -serd_world_set_error_sink(SerdWorld* world, - SerdErrorSink error_sink, - void* handle) +serd_world_set_message_sink(SerdWorld* world, + SerdMessageSink msg_sink, + void* handle) { - world->error_sink = error_sink; - world->error_handle = handle; + world->msg_sink = msg_sink; + world->msg_handle = handle; } diff --git a/src/world.h b/src/world.h index 9ac13a95..f4e7ee3e 100644 --- a/src/world.h +++ b/src/world.h @@ -24,8 +24,8 @@ struct SerdWorldImpl { SerdNodes* nodes; - SerdErrorSink error_sink; - void* error_handle; + SerdMessageSink msg_sink; + void* msg_handle; uint32_t next_blank_id; SerdNode* blank_node; const SerdNode* rdf_first; @@ -39,7 +39,7 @@ struct SerdWorldImpl { FILE* serd_world_fopen(SerdWorld* world, const char* path, const char* mode); -SerdStatus serd_world_error(const SerdWorld* world, const SerdError* e); +SerdStatus serd_world_log(const SerdWorld* world, const SerdMessage* msg); SerdStatus serd_world_errorf(const SerdWorld* world, SerdStatus st, const char* fmt, ...); diff --git a/src/writer.c b/src/writer.c index fd1dc043..09bffeef 100644 --- a/src/writer.c +++ b/src/writer.c @@ -101,24 +101,24 @@ static const SepRule rules[] = { }; struct SerdWriterImpl { - SerdWorld* world; - SerdSink iface; - SerdSyntax syntax; - SerdStyleFlags style; - SerdEnv* env; - SerdNode* root_node; - SerdURI root_uri; - SerdStack anon_stack; - SerdWriteFunc write_func; - void* stream; - SerdErrorSink error_sink; - void* error_handle; - WriteContext context; - unsigned indent; - char* bprefix; - size_t bprefix_len; - Sep last_sep; - bool empty; + SerdWorld* world; + SerdSink iface; + SerdSyntax syntax; + SerdStyleFlags style; + SerdEnv* env; + SerdNode* root_node; + SerdURI root_uri; + SerdStack anon_stack; + SerdWriteFunc write_func; + void* stream; + SerdMessageSink msg_sink; + void* msg_handle; + WriteContext context; + unsigned indent; + char* bprefix; + size_t bprefix_len; + Sep last_sep; + bool empty; }; typedef enum { @@ -186,7 +186,7 @@ write_character(SerdWriter* writer, const uint8_t* utf8, size_t* size) switch (*size) { case 0: serd_world_errorf( - writer->world, SERD_ERR_BAD_ARG, "invalid UTF-8: %X\n", utf8[0]); + writer->world, SERD_ERR_BAD_ARG, "invalid UTF-8: %X\n", utf8[0]); return sink(replacement_char, sizeof(replacement_char), writer); case 1: snprintf(escape, sizeof(escape), "\\u%04X", utf8[0]); |