From 71c950bb749c3581ab389edfff9771cb06242e29 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 11 Jul 2021 20:47:51 -0400 Subject: Add SerdWorld for shared library state --- src/serd_internal.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/serd_internal.h') diff --git a/src/serd_internal.h b/src/serd_internal.h index e16a2c12..1bb2a3bc 100644 --- a/src/serd_internal.h +++ b/src/serd_internal.h @@ -17,6 +17,8 @@ #ifndef SERD_INTERNAL_H #define SERD_INTERNAL_H +#include "world.h" + #include "serd/serd.h" #include @@ -33,12 +35,16 @@ /* Error reporting */ static inline void -serd_error(SerdErrorFunc error_func, void* handle, const SerdError* e) +serd_error(const SerdWorld* world, const SerdError* e) { - if (error_func) { - error_func(handle, e); + if (world->error_func) { + world->error_func(world->error_handle, e); } else { - fprintf(stderr, "error: %s:%u:%u: ", e->filename, e->line, e->col); + if (e->filename) { + fprintf(stderr, "error: %s:%u:%u: ", e->filename, e->line, e->col); + } else { + fprintf(stderr, "error: "); + } vfprintf(stderr, e->fmt, *e->args); } } -- cgit v1.2.1