aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-05-12 17:56:27 +0200
committerDavid Robillard <d@drobilla.net>2018-05-27 18:23:15 +0200
commitcc1378913b22737fc1abb81de15313099d005eae (patch)
treeabbba65b63b991eae9add189ac990f331c25afaf /src
parent9143f8ece49e902dda34a5c99ae721543bfa0d33 (diff)
downloadserd-cc1378913b22737fc1abb81de15313099d005eae.tar.gz
serd-cc1378913b22737fc1abb81de15313099d005eae.tar.bz2
serd-cc1378913b22737fc1abb81de15313099d005eae.zip
Add serd_world_get_blank()
Diffstat (limited to 'src')
-rw-r--r--src/world.c19
-rw-r--r--src/world.h2
2 files changed, 20 insertions, 1 deletions
diff --git a/src/world.c b/src/world.c
index 0457e34f..9d364e04 100644
--- a/src/world.c
+++ b/src/world.c
@@ -18,6 +18,7 @@
#include "world.h"
+#include "node.h"
#include "serd_config.h"
#include <errno.h>
@@ -29,6 +30,8 @@
# include <fcntl.h>
#endif
+#define BLANK_CHARS 11
+
FILE*
serd_world_fopen(SerdWorld* world, const char* path, const char* mode)
{
@@ -71,7 +74,11 @@ serd_world_errorf(SerdWorld* world, SerdStatus st, const char* fmt, ...)
SerdWorld*
serd_world_new(void)
{
- return (SerdWorld*)calloc(1, sizeof(SerdWorld));
+ SerdWorld* world = (SerdWorld*)calloc(1, sizeof(SerdWorld));
+
+ world->blank_node = serd_node_new_blank("b0000000000");
+
+ return world;
}
void
@@ -80,6 +87,16 @@ serd_world_free(SerdWorld* world)
free(world);
}
+const SerdNode*
+serd_world_get_blank(SerdWorld* world)
+{
+ char* buf = serd_node_buffer(world->blank_node);
+ memset(buf, 0, BLANK_CHARS + 1);
+ world->blank_node->n_bytes = snprintf(
+ buf, BLANK_CHARS, "b%u", ++world->next_blank_id);
+ return world->blank_node;
+}
+
void
serd_world_set_error_sink(SerdWorld* world,
SerdErrorSink error_sink,
diff --git a/src/world.h b/src/world.h
index f35eb96c..e3bd3784 100644
--- a/src/world.h
+++ b/src/world.h
@@ -24,6 +24,8 @@
struct SerdWorldImpl {
SerdErrorSink error_sink;
void* error_handle;
+ uint32_t next_blank_id;
+ SerdNode* blank_node;
};
FILE* serd_world_fopen(SerdWorld* world, const char* path, const char* mode);