aboutsummaryrefslogtreecommitdiffstats
path: root/src/env.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-02-20 19:18:28 -0500
committerDavid Robillard <d@drobilla.net>2023-12-02 18:49:07 -0500
commitd62c7dc45af3256c6cd70d12a11e91b5b872c7db (patch)
tree63f9f1cc8f8900ad59b5bd8f07b70e6008522d21 /src/env.c
parentab1aa43256fac3e017212abe6f9d845bf74c024c (diff)
downloadserd-d62c7dc45af3256c6cd70d12a11e91b5b872c7db.tar.gz
serd-d62c7dc45af3256c6cd70d12a11e91b5b872c7db.tar.bz2
serd-d62c7dc45af3256c6cd70d12a11e91b5b872c7db.zip
Replace multiple stream callbacks with SerdEvent
This makes plumbing easier since everything goes through the same "stream" and only one callback is required to handling everything. It's also more easily extensible in case more event types need to be added in the future.
Diffstat (limited to 'src/env.c')
-rw-r--r--src/env.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/env.c b/src/env.c
index 8b3970b3..4ce0add4 100644
--- a/src/env.c
+++ b/src/env.c
@@ -238,12 +238,16 @@ serd_env_expand_node(const SerdEnv* const env, const SerdNode* const node)
return NULL;
}
-void
-serd_env_foreach(const SerdEnv* const env,
- const SerdPrefixFunc func,
- void* const handle)
+SerdStatus
+serd_env_write_prefixes(const SerdEnv* const env, const SerdSink* const sink)
{
- for (size_t i = 0; i < env->n_prefixes; ++i) {
- func(handle, env->prefixes[i].name, env->prefixes[i].uri);
+ SerdStatus st = SERD_SUCCESS;
+
+ for (size_t i = 0; !st && i < env->n_prefixes; ++i) {
+ const SerdPrefix* const prefix = &env->prefixes[i];
+
+ st = serd_sink_write_prefix(sink, prefix->name, prefix->uri);
}
+
+ return st;
}