Explorar o código

Rebrand to Volksdata.

scossu hai 1 mes
pai
achega
3a3070214d
Modificáronse 55 ficheiros con 2792 adicións e 2790 borrados
  1. 2 2
      Doxyfile
  2. 22 22
      Makefile
  3. 23 21
      README.md
  4. 0 0
      ext/sqlite/README_volksdata.md
  5. 0 10
      include/lsup/codec/codec_nt.h
  6. 0 12
      include/lsup/codec/codec_ttl.h
  7. 0 7
      include/lsup_rdf.h
  8. 7 0
      include/volksdata.h
  9. 69 69
      include/volksdata/buffer.h
  10. 25 25
      include/volksdata/codec.h
  11. 10 0
      include/volksdata/codec/codec_nt.h
  12. 12 0
      include/volksdata/codec/codec_ttl.h
  13. 9 9
      include/volksdata/codec/parser_nt.h
  14. 6 6
      include/volksdata/codec/parser_ttl.h
  15. 0 0
      include/volksdata/codec/tokens_nt.h
  16. 0 0
      include/volksdata/codec/tokens_ttl.h
  17. 87 87
      include/volksdata/core.h
  18. 4 4
      include/volksdata/data/bootstrap.h
  19. 18 18
      include/volksdata/environment.h
  20. 125 125
      include/volksdata/graph.h
  21. 26 26
      include/volksdata/namespace.h
  22. 108 108
      include/volksdata/store.h
  23. 6 6
      include/volksdata/store_htable.h
  24. 66 66
      include/volksdata/store_interface.h
  25. 7 7
      include/volksdata/store_mdb.h
  26. 158 158
      include/volksdata/term.h
  27. 29 29
      profile.c
  28. 36 36
      src/buffer.c
  29. 5 5
      src/codec.c
  30. 1 1
      src/codec/Makefile
  31. 41 41
      src/codec/codec_nt.c
  32. 69 69
      src/codec/codec_ttl.c
  33. 13 13
      src/codec/grammar_nt.y
  34. 66 66
      src/codec/grammar_ttl.y
  35. 31 31
      src/codec/lexer_nt.re
  36. 18 18
      src/codec/lexer_ttl.re
  37. 27 27
      src/core.c
  38. 37 37
      src/environment.c
  39. 299 299
      src/graph.c
  40. 35 35
      src/namespace.c
  41. 65 65
      src/store.c
  42. 86 86
      src/store_htable.c
  43. 181 181
      src/store_mdb.c
  44. 208 208
      src/term.c
  45. 5 5
      test.c
  46. 39 39
      test/assets/triples.h
  47. 10 10
      test/test.h
  48. 48 48
      test/test_codec_nt.c
  49. 15 15
      test/test_codec_ttl.c
  50. 304 304
      test/test_graph.c
  51. 25 25
      test/test_namespace.c
  52. 109 109
      test/test_store.c
  53. 17 17
      test/test_store_ht.c
  54. 24 24
      test/test_store_mdb.c
  55. 159 159
      test/test_term.c

+ 2 - 2
Doxyfile

@@ -42,13 +42,13 @@ DOXYFILE_ENCODING      = UTF-8
 # title of most generated pages and in a few other places.
 # The default value is: My Project.
 
-PROJECT_NAME           = LSUP_RDF
+PROJECT_NAME           = Volksdata
 
 # The PROJECT_NUMBER tag can be used to enter a project or revision number. This
 # could be handy for archiving the generated documentation or if some version
 # control system is used.
 
-PROJECT_NUMBER         = 1.0a2
+PROJECT_NUMBER         = 1.0b5
 
 # Using the PROJECT_BRIEF tag one can provide an optional one line description
 # for a project that appears at the top of each page and should give viewers a

+ 22 - 22
Makefile

@@ -31,9 +31,9 @@ INCLUDEDIR := $(PREFIX)/include
 BUILDDIR := ./build
 OUTDIR := ./bin
 TMPDIR ?= /tmp
-VALGRIND_DUMP := $(TMPDIR)/lsup_valgrind.log
-CALLGRIND_DUMP := $(TMPDIR)/lsup_callgrind.out
-MASSIF_DUMP := $(TMPDIR)/lsup_massif.out
+VALGRIND_DUMP := $(TMPDIR)/volksdata_valgrind.log
+CALLGRIND_DUMP := $(TMPDIR)/volksdata_callgrind.out
+MASSIF_DUMP := $(TMPDIR)/volksdata_massif.out
 
 INCLUDE_BASE := . -Iinclude -Iext/tpl/src -Iext/hashmap -Iext/log/src
 INCLUDE := -I$(INCLUDE_BASE)
@@ -62,8 +62,8 @@ EXT_H := $(wildcard ext/log/src/*.h) \
 	  	$(wildcard ext/tpl/src/*.h) \
 	  	$(wildcard ext/hashmap/*.h)
 
-LSUP_SRC = $(wildcard src/*.c)
-SRC = $(EXT_SRC) $(LSUP_SRC)
+VOLK_SRC = $(wildcard src/*.c)
+SRC = $(EXT_SRC) $(VOLK_SRC)
 TEST_SRC = $(wildcard test/*.c) test.c
 
 EXT_OBJ := $(EXT_SRC:%.c=$(BUILDDIR)/%.o)
@@ -81,11 +81,11 @@ CODEC_OBJ = $(patsubst $(CODEC_DIR)/%.c, $(BUILDDIR)/%.o, $(CODEC_SRC))
 endif
 
 ifneq ($(DEBUG), 0)
-STATIC_LIB = $(OUTDIR)/liblsuprdf_dbg.a
-LOCAL_OBJ = $(LSUP_SRC:src/%.c=$(BUILDDIR)/%_dbg.o)
+STATIC_LIB = $(OUTDIR)/libvolksdata_dbg.a
+LOCAL_OBJ = $(VOLK_SRC:src/%.c=$(BUILDDIR)/%_dbg.o)
 else
-STATIC_LIB = $(OUTDIR)/liblsuprdf.a
-LOCAL_OBJ = $(LSUP_SRC:src/%.c=$(BUILDDIR)/%.o)
+STATIC_LIB = $(OUTDIR)/libvolksdata.a
+LOCAL_OBJ = $(VOLK_SRC:src/%.c=$(BUILDDIR)/%.o)
 endif
 OBJ = $(EXT_OBJ) $(LOCAL_OBJ)
 DYN_LIB = $(STATIC_LIB:.a=.so)
@@ -123,7 +123,7 @@ export LD_LIBRARY_PATH = $(OUTDIR):$(libdir)
 help:
 	@echo "Command overview:"; echo; \
 		grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
-		| sed -n 's/^\(.*\): \(.*\)##\(.*\)/\1|\3/p' \
+		| SED -N 'S/^\(.*\): \(.*\)##\(.*\)/\1|\3/P' \
 		| column -t  -s '|'
 	
 
@@ -174,9 +174,9 @@ $(PARSER): $(LEMON_SRC)
 install: lib ## Install library and dependencies to $PREFIX. May require sudo.
 	@echo "Installing library files in $(PREFIX)."
 	mkdir -p $(libdir)
-	mkdir -p $(INCLUDEDIR)/lsup
+	mkdir -p $(INCLUDEDIR)/volksdata
 	cp $(LIBS) $(libdir) && \
-		cp -r include/lsup/* $(EXT_H) $(INCLUDEDIR)/lsup && \
+		cp -r include/volksdata/* $(EXT_H) $(INCLUDEDIR)/volksdata && \
 		cp include/*.h $(INCLUDEDIR)
 
 
@@ -191,15 +191,15 @@ clean: ## Clean up artifacts, including language parsers.
 
 .PHONY: uninstall ## Uninstall library (not the dependencies).
 uninstall:
-	rm -f $(libdir)/liblsuprdf*
-	rm -rf $(INCLUDEDIR)/lsup*
+	rm -f $(libdir)/libvolksdata*
+	rm -rf $(INCLUDEDIR)/volksdata*
 	rm -f bin/test*
 
 
 # For testing, use debug symbols.
-bin/test: DEBUG = 1
+bin/test: override DEBUG = 1
 bin/test: lib $(TEST_SRC)
-	$(CC) $(DBG_CFLAGS) $(LDFLAGS) -llsuprdf_dbg \
+	$(CC) $(CFLAGS) $(LDFLAGS) -lvolksdata_dbg \
 		test.c -o bin/test
 
 
@@ -239,14 +239,14 @@ memtest: bin/test memcheck ## Run a test suite using Valgrind. Output to separat
 # Profiling application.
 bin/profile: DEBUG = 1
 bin/profile: lib profile.c
-	$(CC) $(CFLAGS) -g -DTESTING $(LDFLAGS) -llsuprdf_dbg \
+	$(CC) $(CFLAGS) -g -DTESTING $(LDFLAGS) -lvolksdata_dbg \
 		profile.c -o bin/profile
 
 
 # Performance test application. Essentially the profiling code without debug.
 bin/perftest: DEBUG = 0
 bin/perftest: lib profile.c
-	$(CC) $(CFLAGS) -g $(LDFLAGS) -llsuprdf profile.c -o bin/perftest
+	$(CC) $(CFLAGS) -g $(LDFLAGS) -lvolksdata profile.c -o bin/perftest
 
 
 .PHONY: perftest
@@ -256,7 +256,7 @@ perftest: bin/perftest ## Run a performance test by creating, inserting and look
 
 .PHONY: profile
 profile: bin/profile ## Run a profiling session on a limited set of high-volume commands.
-	LSUP_MDB_MAPSIZE=800000 valgrind --tool=callgrind \
+	VOLK_MDB_MAPSIZE=800000 valgrind --tool=callgrind \
 		--callgrind-out-file="$(CALLGRIND_DUMP)" bin/profile 1000
 	@echo "Profile dump written at $(CALLGRIND_DUMP) . Open it with "\
 		"qcachegrind, kcachegrind, etc."
@@ -264,7 +264,7 @@ profile: bin/profile ## Run a profiling session on a limited set of high-volume
 
 .PHONY: test_profile
 test_profile: bin/test ## Run profiling on the standard test suite.
-	LSUP_MDB_MAPSIZE=800000 valgrind --tool=callgrind \
+	VOLK_MDB_MAPSIZE=800000 valgrind --tool=callgrind \
 		--callgrind-out-file="$(CALLGRIND_DUMP)" bin/test
 	@echo "Profile dump written at $(CALLGRIND_DUMP) . Open it with "\
 		"qcachegrind, kcachegrind, etc."
@@ -272,14 +272,14 @@ test_profile: bin/test ## Run profiling on the standard test suite.
 
 .PHONY: footprint
 footprint: bin/perftest ## Measure memory footprint by generating and storing 100K triples.
-	LSUP_MDB_MAPSIZE=80000000 valgrind --tool=massif \
+	VOLK_MDB_MAPSIZE=80000000 valgrind --tool=massif \
 		--massif-out-file=$(MASSIF_DUMP) bin/perftest 100000
 	@echo "Memory stats file written at $(MASSIF_DUMP). Open it with "\
 		"massif-visualizer or similar."
 
 
 # Requires cinclude2dot (https://www.flourish.org/cinclude2dot) and Graphviz.
-depgraph: $(LSUP_SRC) include/* include/lsup/* include/lsup/codec/* ## Build a visual dependency graph of the code.
+depgraph: $(VOLK_SRC) include/* include/volksdata/* include/volksdata/codec/* ## Build a visual dependency graph of the code.
 	cinclude2dot --merge=module --include=$(DEPS) \
 		--exclude='test|ext' >| $(DOCS)/dev/deps.dot
 	dot $(DOCS)/dev/deps.dot -Tpdf >| $(DOCS)/dev/deps.pdf

+ 23 - 21
README.md

@@ -1,15 +1,15 @@
-# `lsup_rdf`
+# Volksdata
 
-Embedded RDF (and maybe later, generic graph) store and manipulation library.
+Linked Data for the People.
 
 ## Purpose
 
-The goal of this library is to provide efficient and compact handling of RDF
-data. At least a complete C API and Lua bindings (in a separate project) are
-being built.
+Volksdata (full name: Volksdata Linkswagen) is an efficient and compact library
+for handling, storing, and querying RDF, i.e. [Linked
+Data](https://www.w3.org/TR/rdf-primer/).
 
 This library can be embedded directly in a program and store persistent data
-without the need of running a server. In addition, `lsup_rdf` can perform
+without the need of running a server. In addition, Volksdata can perform
 in-memory graph operations such as validation, de/serialization, boolean
 operations, lookup, etc.
 
@@ -47,8 +47,8 @@ unpaid fun project, so don't be surprised if you find some gross stuff.
 
 ### In Scope – Short Term
 
-The short-term goal is to support usage in Lakesuperior and a workable set
-of features as a standalone library:
+The short-term goal is to support usage in some personal projects and a
+workable set of features as a standalone library:
 
 - ✓ Handling of graphs, triples, terms
 - ✓ Memory- and disk-backed (persistent) graph storage
@@ -63,13 +63,13 @@ of features as a standalone library:
 - ✓ Serialization and de-serialization to/from Turtle and TriG
 - ✓ Compile-time configuration of max graph size (efficiency vs. capacity)
 - ✓ Lua bindings (on a [separate project](
-        https://git.knowledgetx.com/scossu/lsup_lua))
+        https://git.knowledgetx.com/scossu/volksdata_lua))
 - ⚒ Basic command line utilities
 - ✓ Store interface for custom back end implementations
-- ⚒ POSIX conformance
 
 ### Possibly In scope – Long Term
 
+- POSIX conformance
 - Binary serialization and hashing of graphs
 - Binary protocol for synchronizing remote replicas
 - True plug-in architecture for 3rd-party store implementations
@@ -88,7 +88,7 @@ of features as a standalone library:
 
 ### Requirements
 
-- It is recommended to build and run `lsup_rdf` on a Linux system. No other
+- It is recommended to build and run Volksdata on a Linux system. No other
   OS has been tested so far.
 - A C compiler. This has been only tested with `gcc` so far.
 - [LMDB](https://symas.com/lmdb/) libraries and headers.
@@ -121,13 +121,15 @@ make install DEBUG=1 LOCAL=1
 
 Installs the library with debug symbols in `~/.local`.
 
+**FIXME:** At the moment, `make test` needs `DEBUG=1 to run.
+
 
 ### Compile-Time defines (`-D[...]`)
 
 `DEBUG`: Set debug mode: memory map is at reduced size, logging is forced to
 TRACE level, etc.
 
-`LSUP_RDF_STREAM_CHUNK_SIZE`: Size of RDF decoding buffer, i.e., maximum size
+`VOLK_RDF_STREAM_CHUNK_SIZE`: Size of RDF decoding buffer, i.e., maximum size
 of a chunk of RDF data fed to the parser when decoding a RDF file into a graph.
 This should be larger than the maximum expected size of a single term in your
 RDF source. The default value is 8192, which is mildly conservative. If you
@@ -136,10 +138,10 @@ very long string literal, try recompiling the library with a larger value.
 
 ## Embedding & linking
 
-The generated `liblsuprdf.so` and `liblsuprdf.a` libraries can be linked
-dynamically or statically to your code. Only the `lsup_rdf.h` header, which
-recursively includes other headers in the `include` directory, needs to be
-`#include`d in the embedding code.
+The generated `libvolksdata.so` and `libvolksdata.a` libraries can be linked
+dynamically or statically to your code. Only the `volksdata.h` header, which
+recursively includes other headers in the `include/volksdata` directory, needs
+to be `#include`d in the embedding code.
 
 Environment variables and/or compiler options might have to be set in order to
 find the dynamic libraries and headers in their install locations.
@@ -150,16 +152,16 @@ and other targets in the current Makefile.
 
 ### Environment Variables
 
-`LSUP_DEFAULT_CTX`: string to derive the default context URI for context-aware
+`VOLK_DEFAULT_CTX`: string to derive the default context URI for context-aware
 stores when the environment is initialized. This must be a fully qualified URI.
-If unspecified, the value of `LSUP_DEFAULT_CTX_LABEL` is used.
+If unspecified, the value of `VOLK_DEFAULT_CTX_LABEL` is used.
 
-`LSUP_MDB_STORE_PATH`: The file path for the persistent store back end. For
+`VOLK_MDB_STORE_PATH`: The file path for the persistent store back end. For
 production use it is strongly recommended to set this to a permanent location
 on the fastest storage volume available. If unset, the current directory will
 be used. The directory must exist.
 
-`LSUP_LOGLEVEL`: A number between 0 and 5, corresponding to:
+`VOLK_LOGLEVEL`: A number between 0 and 5, corresponding to:
 
 - 0: `TRACE`
 - 1: `DEBUG`
@@ -170,7 +172,7 @@ be used. The directory must exist.
 
 If unspecified, it is set to 3.
 
-`LSUP_MDB_MAPSIZE`: Virtual memory map size. It is recommended to leave this
+`VOLK_MDB_MAPSIZE`: Virtual memory map size. It is recommended to leave this
 alone, except when running Valgrind or other tools that limit memory usage.
 The map size by itself does not preallocate any resources and is safe to
 increase beyond the physical capacity of the host system. By default, it is set

+ 0 - 0
ext/sqlite/README_lsup.md → ext/sqlite/README_volksdata.md


+ 0 - 10
include/lsup/codec/codec_nt.h

@@ -1,10 +0,0 @@
-#ifndef _LSUP_CODEC_NT_H
-#define _LSUP_CODEC_NT_H
-
-#include "lsup/codec/parser_nt.h"
-
-/** @brief N-Triples codec.
- */
-extern const LSUP_Codec nt_codec;
-
-#endif

+ 0 - 12
include/lsup/codec/codec_ttl.h

@@ -1,12 +0,0 @@
-#ifndef _LSUP_CODEC_TTL_H
-#define _LSUP_CODEC_TTL_H
-
-#include "lsup/codec/parser_ttl.h"
-
-/** @brief Turtle codec.
- *
- * @sa #codec_t
- */
-extern const LSUP_Codec ttl_codec;
-
-#endif

+ 0 - 7
include/lsup_rdf.h

@@ -1,7 +0,0 @@
-#ifndef _LSUP_RDF_H
-#define _LSUP_RDF_H
-
-#include "lsup/codec/codec_nt.h"
-#include "lsup/codec/codec_ttl.h"
-
-#endif  // _LSUP_RDF_H

+ 7 - 0
include/volksdata.h

@@ -0,0 +1,7 @@
+#ifndef _VOLK_RDF_H
+#define _VOLK_RDF_H
+
+#include "volksdata/codec/codec_nt.h"
+#include "volksdata/codec/codec_ttl.h"
+
+#endif  // _VOLK_RDF_H

+ 69 - 69
include/lsup/buffer.h → include/volksdata/buffer.h

@@ -1,7 +1,7 @@
-#ifndef _LSUP_BUFFER_H
-#define _LSUP_BUFFER_H
+#ifndef _VOLK_BUFFER_H
+#define _VOLK_BUFFER_H
 
-#include "lsup/core.h"
+#include "volksdata/core.h"
 
 /** @defgroup buffer Buffer module
  * @ingroup public
@@ -20,19 +20,19 @@ typedef enum {
     TRP_POS_S = 0,
     TRP_POS_P = 1,
     TRP_POS_O = 2,
-} LSUP_TriplePos;
+} VOLK_TriplePos;
 
 
 /// Buffer flags, stored in buffer structure.
 typedef enum {
-    LSUP_BUF_BORROWED = 1<<0,       /**< Borrowed buffer. This indicates that
+    VOLK_BUF_BORROWED = 1<<0,       /**< Borrowed buffer. This indicates that
                                       *  the memory block pointed to by the
                                       *  buffer is owned by another function,
-                                      *  and instructs #LSUP_buffer_free() to
+                                      *  and instructs #VOLK_buffer_free() to
                                       *  only free the buffer handle, but not
                                       *  the underlying data.
                                       */
-} LSUP_BufferFlag;
+} VOLK_BufferFlag;
 
 
 /** @brief General-purpose data buffer.
@@ -42,13 +42,13 @@ typedef enum {
  * performed by simply using the addr and size attributes.
  *
  * A buffer can be initialized once and reused multiple times, e.g. in a loop,
- * without being freed between iterations, by using #LSUP_buffer_init.
+ * without being freed between iterations, by using #VOLK_buffer_init.
  */
-typedef struct LSUP_Buffer {
+typedef struct VOLK_Buffer {
     /*@null@*/ unsigned char *addr;
     size_t size;
-    LSUP_BufferFlag flags;
-} LSUP_Buffer;
+    VOLK_BufferFlag flags;
+} VOLK_Buffer;
 
 
 /** @brief Triple of byte buffers.
@@ -58,10 +58,10 @@ typedef struct LSUP_Buffer {
  * and triples is done in the term and triple modules.
  */
 typedef struct buffer_triple_t {
-    LSUP_Buffer *s;
-    LSUP_Buffer *p;
-    LSUP_Buffer *o;
-} LSUP_BufferTriple;
+    VOLK_Buffer *s;
+    VOLK_Buffer *p;
+    VOLK_Buffer *o;
+} VOLK_BufferTriple;
 
 
 /*
@@ -70,12 +70,12 @@ typedef struct buffer_triple_t {
 
 /** @brief Initialize or reuse a buffer handle.
  *
- * The handle must have been created with #LSUP_buffer_new*().
+ * The handle must have been created with #VOLK_buffer_new*().
  *
  * The data block is resized without being freed first. The handle must be
- * eventually freed with #LSUP_buffer_done() after use.
+ * eventually freed with #VOLK_buffer_done() after use.
  *
- * @param[in] buf A buffer handle obtained with #LSUP_buffer_new or by manual
+ * @param[in] buf A buffer handle obtained with #VOLK_buffer_new or by manual
  *  allocation.
  *
  * @param[in] size New size.
@@ -84,32 +84,32 @@ typedef struct buffer_triple_t {
  *  of the data to be copied is determined by the size parameter. If NULL, the
  *  existing data are preserved as with a normal realloc().
  */
-LSUP_rc
-LSUP_buffer_init (
-        LSUP_Buffer *buf, const size_t size, const unsigned char *data);
+VOLK_rc
+VOLK_buffer_init (
+        VOLK_Buffer *buf, const size_t size, const unsigned char *data);
 
 
 /** @brief Create a new buffer and optionally populate it with data.
  *
- * To change the buffer size and/or data later call #LSUP_buffer_init.
+ * To change the buffer size and/or data later call #VOLK_buffer_init.
  *
- * To copy a buffer just do buf2 = LSUP_buffer_new (buf1->addr, buf1->size);
+ * To copy a buffer just do buf2 = VOLK_buffer_new (buf1->addr, buf1->size);
  *
  * @param[in] size Length of the data.
  *
  * @param[in] data Optional data to initially populate the object with. If
  *  NULL, the buffer data are garbage.
  *
- * @return LSUP_Buffer handle. It must be freed with #LSUP_buffer_free. NULL
+ * @return VOLK_Buffer handle. It must be freed with #VOLK_buffer_free. NULL
  *  on error.
  */
-inline LSUP_Buffer *
-LSUP_buffer_new (const unsigned char *data, const size_t size)
+inline VOLK_Buffer *
+VOLK_buffer_new (const unsigned char *data, const size_t size)
 {
-    LSUP_Buffer *buf;
+    VOLK_Buffer *buf;
     CALLOC_GUARD (buf, NULL);
 
-    if (LSUP_buffer_init (buf, size, data) != LSUP_OK) {
+    if (VOLK_buffer_init (buf, size, data) != VOLK_OK) {
         free (buf->addr);
         free (buf);
         return NULL;
@@ -122,56 +122,56 @@ LSUP_buffer_new (const unsigned char *data, const size_t size)
 /** @brief Create a borrowed buffer (memory view).
  *
  * A borrowed buffer does not own the memory block pointed to and should not
- * be freed. It can be identified by the LSUP_BUF_BORROWED flag.
+ * be freed. It can be identified by the VOLK_BUF_BORROWED flag.
  *
  * @param[in] data Address of data handled by the buffer.
  *
  * @param[in] size Length of the data.
  *
- * @return LSUP_Buffer handle. It must be freed with #LSUP_buffer_free, which
+ * @return VOLK_Buffer handle. It must be freed with #VOLK_buffer_free, which
  * will correctly leave the underlying data alone. NULL on error.
  */
-inline LSUP_Buffer *
-LSUP_buffer_new_borrowed (unsigned char *data, const size_t size)
+inline VOLK_Buffer *
+VOLK_buffer_new_borrowed (unsigned char *data, const size_t size)
 {
-    LSUP_Buffer *buf;
+    VOLK_Buffer *buf;
     MALLOC_GUARD (buf, NULL);
 
     buf->addr = data;
     buf->size = size;
-    buf->flags = LSUP_BUF_BORROWED;
+    buf->flags = VOLK_BUF_BORROWED;
 
     return buf;
 }
 
 
-/** @brief Dummy buffer to be used with #LSUP_buffer_init.
+/** @brief Dummy buffer to be used with #VOLK_buffer_init.
  */
-#define BUF_DUMMY LSUP_buffer_new (NULL, 0)
+#define BUF_DUMMY VOLK_buffer_new (NULL, 0)
 
 
 /** @brief Free the content of a buffer.
  *
  * @note This function is safe to use on borrowed buffers.
  */
-void LSUP_buffer_done (LSUP_Buffer *buf);
+void VOLK_buffer_done (VOLK_Buffer *buf);
 
 
 /** @brief Free a buffer.
  *
  * @note This function is safe to use on borrowed buffers. In such case, only
- *  the `LSUP_Buffer` structure is freed, but not the underlying data.
+ *  the `VOLK_Buffer` structure is freed, but not the underlying data.
  */
-void LSUP_buffer_free (LSUP_Buffer *buf);
+void VOLK_buffer_free (VOLK_Buffer *buf);
 
 
 /** @brief Hash a buffer.
  */
-inline LSUP_Key
-LSUP_buffer_hash (const LSUP_Buffer *buf)
+inline VOLK_Key
+VOLK_buffer_hash (const VOLK_Buffer *buf)
 {
     return (buf == NULL) ? NULL_KEY :
-        LSUP_HASH (buf->addr, buf->size, LSUP_HASH_SEED);
+        VOLK_HASH (buf->addr, buf->size, VOLK_HASH_SEED);
 }
 
 
@@ -180,7 +180,7 @@ LSUP_buffer_hash (const LSUP_Buffer *buf)
  * The string is printed in Python style: printable characters are output
  * literally, and non-printable ones as hex sequences.
  */
-void LSUP_buffer_print (const LSUP_Buffer *buf);
+void VOLK_buffer_print (const VOLK_Buffer *buf);
 
 
 /** @brief Format a buffer into anb ASCII string.
@@ -192,14 +192,14 @@ void LSUP_buffer_print (const LSUP_Buffer *buf);
  * @return Formatted string. It must be freed with free().
  */
 char *
-LSUP_buffer_as_str (const LSUP_Buffer *buf);
+VOLK_buffer_as_str (const VOLK_Buffer *buf);
 
 
 /** @brief Compare two buffers.
  *
  * The return value is the same as memcmp.
  */
-inline int LSUP_buffer_cmp (const LSUP_Buffer *buf1, const LSUP_Buffer *buf2)
+inline int VOLK_buffer_cmp (const VOLK_Buffer *buf1, const VOLK_Buffer *buf2)
 {
     return memcmp (
             buf1->addr, buf2->addr,
@@ -209,14 +209,14 @@ inline int LSUP_buffer_cmp (const LSUP_Buffer *buf1, const LSUP_Buffer *buf2)
 
 /** @brief Return whether two buffers are equal.
  *
- * This may be faster than #LSUP_buffer_cmp() because it does a size comparison
+ * This may be faster than #VOLK_buffer_cmp() because it does a size comparison
  * first.
  */
-inline bool LSUP_buffer_eq (const LSUP_Buffer *buf1, const LSUP_Buffer *buf2)
+inline bool VOLK_buffer_eq (const VOLK_Buffer *buf1, const VOLK_Buffer *buf2)
 {
     if (buf1->size != buf2->size) return false;
 
-    return (LSUP_buffer_cmp (buf1, buf2) == 0) ? true : false;
+    return (VOLK_buffer_cmp (buf1, buf2) == 0) ? true : false;
 }
 
 
@@ -226,7 +226,7 @@ inline bool LSUP_buffer_eq (const LSUP_Buffer *buf1, const LSUP_Buffer *buf2)
 
 /** @brief Create a new buffer triple.
  *
- * @important The triple must be freed with #LSUP_btriple_free().
+ * @important The triple must be freed with #VOLK_btriple_free().
  *
  * @param[in] s Subject as a serialized buffer.
  *
@@ -236,13 +236,13 @@ inline bool LSUP_buffer_eq (const LSUP_Buffer *buf1, const LSUP_Buffer *buf2)
  *
  * @return New triple.
  */
-LSUP_BufferTriple *
-LSUP_btriple_new(LSUP_Buffer *s, LSUP_Buffer *p, LSUP_Buffer *o);
+VOLK_BufferTriple *
+VOLK_btriple_new(VOLK_Buffer *s, VOLK_Buffer *p, VOLK_Buffer *o);
 
 
 /** @brief Initialize internal term pointers in a heap-allocated buffer triple.
  *
- * @important The triple must be freed with #LSUP_btriple_free().
+ * @important The triple must be freed with #VOLK_btriple_free().
  *
  * @param[in] sspo Serialized triple pointer to initialize.
  *
@@ -252,12 +252,12 @@ LSUP_btriple_new(LSUP_Buffer *s, LSUP_Buffer *p, LSUP_Buffer *o);
  *
  * @param[in] o Object as a serialized buffer.
  *
- * @return LSUP_OK on success.
+ * @return VOLK_OK on success.
  */
-LSUP_rc
-LSUP_btriple_init (
-        LSUP_BufferTriple *sspo,
-        LSUP_Buffer *s, LSUP_Buffer *p, LSUP_Buffer *o);
+VOLK_rc
+VOLK_btriple_init (
+        VOLK_BufferTriple *sspo,
+        VOLK_Buffer *s, VOLK_Buffer *p, VOLK_Buffer *o);
 
 
 /** @brief Free the internal pointers of a buffer triple.
@@ -265,7 +265,7 @@ LSUP_btriple_init (
  * @param[in] sspo Buffer triple to be freed.
  */
 void
-LSUP_btriple_done (LSUP_BufferTriple *sspo);
+VOLK_btriple_done (VOLK_BufferTriple *sspo);
 
 
 /** @brief Free a buffer triple and all its internal pointers.
@@ -276,7 +276,7 @@ LSUP_btriple_done (LSUP_BufferTriple *sspo);
  * @param[in] sspo Buffer triple to be freed.
  */
 void
-LSUP_btriple_free (LSUP_BufferTriple *sspo);
+VOLK_btriple_free (VOLK_BufferTriple *sspo);
 
 
 /** @brief Get serialized triple by term position.
@@ -289,8 +289,8 @@ LSUP_btriple_free (LSUP_BufferTriple *sspo);
  *
  * @return Corresponding serialized term or NULL if n is out of range.
  */
-inline LSUP_Buffer *
-LSUP_btriple_pos (const LSUP_BufferTriple *btrp, LSUP_TriplePos n)
+inline VOLK_Buffer *
+VOLK_btriple_pos (const VOLK_BufferTriple *btrp, VOLK_TriplePos n)
 {
     if (n == TRP_POS_S) return btrp->s;
     if (n == TRP_POS_P) return btrp->p;
@@ -309,14 +309,14 @@ LSUP_btriple_pos (const LSUP_BufferTriple *btrp, LSUP_TriplePos n)
  *
  * @return Hash value.
  */
-inline LSUP_Key
-LSUP_btriple_hash (const LSUP_BufferTriple *strp)
+inline VOLK_Key
+VOLK_btriple_hash (const VOLK_BufferTriple *strp)
 {
-    return LSUP_HASH (
+    return VOLK_HASH (
         strp->s->addr, strp->s->size,
-        LSUP_HASH (
+        VOLK_HASH (
             strp->p->addr, strp->p->size,
-            LSUP_HASH (strp->o->addr, strp->o->size, LSUP_HASH_SEED)
+            VOLK_HASH (strp->o->addr, strp->o->size, VOLK_HASH_SEED)
         )
     );
 }
@@ -324,12 +324,12 @@ LSUP_btriple_hash (const LSUP_BufferTriple *strp)
 
 /** @brief Dummy buffer triple.
  *
- * Triple of dummy buffer, with #LSUP_Buffer size space allocated, but no
+ * Triple of dummy buffer, with #VOLK_Buffer size space allocated, but no
  * contents.
  *
- * Free with #LSUP_btriple_free().
+ * Free with #VOLK_btriple_free().
  */
-#define BTRP_DUMMY LSUP_btriple_new (BUF_DUMMY, BUF_DUMMY, BUF_DUMMY)
+#define BTRP_DUMMY VOLK_btriple_new (BUF_DUMMY, BUF_DUMMY, BUF_DUMMY)
 
 /// @} END defgroup buffer
 #endif

+ 25 - 25
include/lsup/codec.h → include/volksdata/codec.h

@@ -1,7 +1,7 @@
-#ifndef _LSUP_CODEC_BASE_H
-#define _LSUP_CODEC_BASE_H
+#ifndef _VOLK_CODEC_BASE_H
+#define _VOLK_CODEC_BASE_H
 
-#include "lsup/graph.h"
+#include "volksdata/graph.h"
 
 /** @defgroup codec RDF codec module
  * @ingroup private
@@ -10,24 +10,24 @@
 /**
  * Max data size passed to the scanner and parser at each iteration.
  */
-#ifdef LSUP_RDF_STREAM_CHUNK_SIZE
-#define CHUNK_SIZE LSUP_RDF_STREAM_CHUNK_SIZE
+#ifdef VOLK_RDF_STREAM_CHUNK_SIZE
+#define CHUNK_SIZE VOLK_RDF_STREAM_CHUNK_SIZE
 #else
 #define CHUNK_SIZE 8192
 #endif
 
 
-typedef struct codec_t LSUP_Codec;
+typedef struct codec_t VOLK_Codec;
 
 
 /// Parser state.
 typedef struct ttl_parser_state {
-    LSUP_GraphIterator *    it;     ///< Iterator used to build the graph.
-    LSUP_Term *             base;   ///< Base IRI used in the document.
-    LSUP_Term *             lms;    ///< Link map subject.
+    VOLK_GraphIterator *    it;     ///< Iterator used to build the graph.
+    VOLK_Term *             base;   ///< Base IRI used in the document.
+    VOLK_Term *             lms;    ///< Link map subject.
     size_t                  ct;     ///< Statements parsed.
-    LSUP_rc                 rc;     ///< Internal return code.
-} LSUP_TTLParserState;
+    VOLK_rc                 rc;     ///< Internal return code.
+} VOLK_TTLParserState;
 
 /** @brief Parse error information.
  *
@@ -37,7 +37,7 @@ typedef struct parse_error_t {
     unsigned int        line;       // Line number where the error occurred.
     unsigned int        linec;      // Position in line of the offending token.
     char *              token;      // String representation of the token.
-} LSUP_ParseError;
+} VOLK_ParseError;
 */
 
 
@@ -54,9 +54,9 @@ typedef struct parse_error_t {
  *  it only needs to be freed after the last call. It should be initialized to
  *  NULL at the beginning.
  *
- * @return LSUP_OK on successful encoding; <0 for other errors.
+ * @return VOLK_OK on successful encoding; <0 for other errors.
  */
-typedef LSUP_rc (*term_enc_fn_t)(const LSUP_Term *term, char **rep);
+typedef VOLK_rc (*term_enc_fn_t)(const VOLK_Term *term, char **rep);
 
 
 /** @brief Initialize a graph encoding loop.
@@ -75,7 +75,7 @@ typedef LSUP_rc (*term_enc_fn_t)(const LSUP_Term *term, char **rep);
  * function and, eventually, to a #gr_encode_done_fn_t function. This
  * structure is opaque and defined by each codec according to its own needs.
  */
-typedef void * (*gr_encode_init_fn_t)(const LSUP_Graph *gr);
+typedef void * (*gr_encode_init_fn_t)(const VOLK_Graph *gr);
 
 
 /** @brief Perform one encoding iteration.
@@ -93,10 +93,10 @@ typedef void * (*gr_encode_init_fn_t)(const LSUP_Graph *gr);
  *  loop. It is reallocated at each iteration, so memory from a previous
  *  iteration may be overwritten with new data.
  *
- * @return LSUP_OK if a new token was processed; LSUP_END if the end of the
+ * @return VOLK_OK if a new token was processed; VOLK_END if the end of the
  *  loop was reached.
  */
-typedef LSUP_rc (*gr_encode_iter_fn_t)(void *it, char **res);
+typedef VOLK_rc (*gr_encode_iter_fn_t)(void *it, char **res);
 
 
 /** @brief Finalize an encoding operation.
@@ -110,7 +110,7 @@ typedef LSUP_rc (*gr_encode_iter_fn_t)(void *it, char **res);
 typedef void (*gr_encode_done_fn_t)(void *it);
 
 
-/** @brief Prototype for decoding a string into a LSUP_Term.
+/** @brief Prototype for decoding a string into a VOLK_Term.
  *
  * Implementations MAY ignore any other tokens after finding the first one.
  *
@@ -121,10 +121,10 @@ typedef void (*gr_encode_done_fn_t)(void *it);
  * @param[out] term Pointer to the term handle to be created. Implementaions
  *  SHOULD return NULL on a parse error.
  *
- * @return Implementations MUST return LSUP_OK on success and a negative value
+ * @return Implementations MUST return VOLK_OK on success and a negative value
  *  on parsing error.
  */
-typedef LSUP_rc (*term_decode_fn_t)(const char *rep, LSUP_Term **term);
+typedef VOLK_rc (*term_decode_fn_t)(const char *rep, VOLK_Term **term);
 
 
 /** @brief Prototype for decoding a complete RDF document file into a graph.
@@ -146,11 +146,11 @@ typedef LSUP_rc (*term_decode_fn_t)(const char *rep, LSUP_Term **term);
  * @param[out] err Pointer to error info string. If no error occurs, it yields
  *  NULL.
  *
- * @return Implementations MUST return LSUP_OK on success and a negative value
+ * @return Implementations MUST return VOLK_OK on success and a negative value
  *  on parsing error.
  */
-typedef LSUP_rc (*gr_decode_fn_t)(
-        FILE *rep, LSUP_Graph **gr, size_t *ct, char **err);
+typedef VOLK_rc (*gr_decode_fn_t)(
+        FILE *rep, VOLK_Graph **gr, size_t *ct, char **err);
 
 
 /** @brief Codec structure.
@@ -223,9 +223,9 @@ inline uint8_t
  *
  * @param[out] out Output string.
  *
- * @return LSUP_OK on success; LSUP_MEM_ERR on memory error.
+ * @return VOLK_OK on success; VOLK_MEM_ERR on memory error.
  */
-LSUP_rc
+VOLK_rc
 escape_lit (const char *in, char **out);
 
 

+ 10 - 0
include/volksdata/codec/codec_nt.h

@@ -0,0 +1,10 @@
+#ifndef _VOLK_CODEC_NT_H
+#define _VOLK_CODEC_NT_H
+
+#include "volksdata/codec/parser_nt.h"
+
+/** @brief N-Triples codec.
+ */
+extern const VOLK_Codec nt_codec;
+
+#endif

+ 12 - 0
include/volksdata/codec/codec_ttl.h

@@ -0,0 +1,12 @@
+#ifndef _VOLK_CODEC_TTL_H
+#define _VOLK_CODEC_TTL_H
+
+#include "volksdata/codec/parser_ttl.h"
+
+/** @brief Turtle codec.
+ *
+ * @sa #codec_t
+ */
+extern const VOLK_Codec ttl_codec;
+
+#endif

+ 9 - 9
include/lsup/codec/parser_nt.h → include/volksdata/codec/parser_nt.h

@@ -1,7 +1,7 @@
-#ifndef _LSUP_NT_PARSER_H
-#define _LSUP_NT_PARSER_H
+#ifndef _VOLK_NT_PARSER_H
+#define _VOLK_NT_PARSER_H
 
-#include "lsup/codec.h"
+#include "volksdata/codec.h"
 
 
 /** @brief Parse a single term.
@@ -13,11 +13,11 @@
  *
  * @param[out] term Term to be created from the string.
  *
- * @return LSUP_OK on success, LSUP_VALUE_ERR if the string is not valid
+ * @return VOLK_OK on success, VOLK_VALUE_ERR if the string is not valid
  *  N-Triples syntax for a IRI ref, Literal or BNode.
  */
-LSUP_rc
-LSUP_nt_parse_term (const char *rep, LSUP_Term **term);
+VOLK_rc
+VOLK_nt_parse_term (const char *rep, VOLK_Term **term);
 
 
 /** @brief Parse a N-Triples document from a file handle.
@@ -32,10 +32,10 @@ LSUP_nt_parse_term (const char *rep, LSUP_Term **term);
  *
  * @param[out] err String handle to be populated with an error message.
  *
- * @return LSUP_OK on success, LSUP_VALUE_ERR if a parsing error was
+ * @return VOLK_OK on success, VOLK_VALUE_ERR if a parsing error was
  *  encountered. On error, `err` will contain the error message.
  */
-LSUP_rc
-LSUP_nt_parse_doc (FILE *stream, LSUP_Graph **gr, size_t *ct, char **err);
+VOLK_rc
+VOLK_nt_parse_doc (FILE *stream, VOLK_Graph **gr, size_t *ct, char **err);
 
 #endif

+ 6 - 6
include/lsup/codec/parser_ttl.h → include/volksdata/codec/parser_ttl.h

@@ -1,7 +1,7 @@
-#ifndef _LSUP_TTL_PARSER_H
-#define _LSUP_TTL_PARSER_H
+#ifndef _VOLK_TTL_PARSER_H
+#define _VOLK_TTL_PARSER_H
 
-#include "lsup/codec.h"
+#include "volksdata/codec.h"
 
 
 /** @brief Parse a N-Triples document from a file handle.
@@ -16,10 +16,10 @@
  *
  * @param[out] err String handle to be populated with an error message.
  *
- * @return LSUP_OK on success, LSUP_VALUE_ERR if a parsing error was
+ * @return VOLK_OK on success, VOLK_VALUE_ERR if a parsing error was
  *  encountered. On error, `err` will contain the error message.
  */
-LSUP_rc
-LSUP_ttl_parse_doc (FILE *stream, LSUP_Graph **gr, size_t *ct, char **err);
+VOLK_rc
+VOLK_ttl_parse_doc (FILE *stream, VOLK_Graph **gr, size_t *ct, char **err);
 
 #endif

+ 0 - 0
include/lsup/codec/tokens_nt.h → include/volksdata/codec/tokens_nt.h


+ 0 - 0
include/lsup/codec/tokens_ttl.h → include/volksdata/codec/tokens_ttl.h


+ 87 - 87
include/lsup/core.h → include/volksdata/core.h

@@ -1,5 +1,5 @@
-#ifndef _LSUP_CORE_H
-#define _LSUP_CORE_H
+#ifndef _VOLK_CORE_H
+#define _VOLK_CORE_H
 
 #ifndef NOCOLOR
 #define LOG_USE_COLOR
@@ -22,7 +22,7 @@
 #include "xxhash.h"
 
 
-#define LSUP_VERSION "1.0b2"
+#define VOLK_VERSION "1.0b2"
 
 
 // Logging and debugging.
@@ -47,12 +47,12 @@
 /** @defgroup public LSUP Public API
  * @{
  */
-#define LSUP_NS "urn:lsup:"             /// Default LS namespace.
+#define VOLK_NS "urn:lsup:"             /// Default LS namespace.
 
-#define KLEN sizeof(LSUP_Key)           /// Key length.
-#define DBL_KLEN sizeof(LSUP_DoubleKey) /// Double key length.
-#define TRP_KLEN sizeof(LSUP_TripleKey) /// Triple key length.
-#define QUAD_KLEN sizeof(LSUP_QuadKey)  /// Quad key length.
+#define KLEN sizeof(VOLK_Key)           /// Key length.
+#define DBL_KLEN sizeof(VOLK_DoubleKey) /// Double key length.
+#define TRP_KLEN sizeof(VOLK_TripleKey) /// Triple key length.
+#define QUAD_KLEN sizeof(VOLK_QuadKey)  /// Quad key length.
 
 # define UUIDSTR_SIZE 37
 
@@ -70,11 +70,11 @@
  * @ingroup public
  * @{
  */
-typedef int LSUP_rc;
+typedef int VOLK_rc;
 
 /** @brief Generic success return code.
  */
-#define LSUP_OK             0
+#define VOLK_OK             0
 
 /** @brief No action taken.
  *
@@ -84,21 +84,21 @@ typedef int LSUP_rc;
  * If this is returned from the iteration of multiple updates, it means that
  * none of the iterations produced a change in state.
  */
-#define LSUP_NOACTION       88801
+#define VOLK_NOACTION       88801
 
 /** @brief No result yielded.
  *
  * A read operation returned no results. If an iterator is expected to be
  * created, it may be created empty.
  */
-#define LSUP_NORESULT       88802
+#define VOLK_NORESULT       88802
 
 /** @brief Loop end.
  *
  * End of a loop was reached. This can be used in a while() or for()
  * loop as a terminating condition.
  */
-#define LSUP_END            88803
+#define VOLK_END            88803
 
 /** @brief Conflict warning.
  *
@@ -109,41 +109,41 @@ typedef int LSUP_rc;
  * some resources in the loop may have changed state and the operation as a
  * whole completed successfully.
  *
- * The error-level counterpart to this is #LSUP_CONFLICT_ERR.
+ * The error-level counterpart to this is #VOLK_CONFLICT_ERR.
  */
-#define LSUP_CONFLICT       88804
+#define VOLK_CONFLICT       88804
 
-#define LSUP_MIN_WARNING    LSUP_NOACTION
+#define VOLK_MIN_WARNING    VOLK_NOACTION
 /**brief Last warning value. Used internally.
  *
  * @note When adding new warning codes, use a value larger than the last one
- * in the list. Also change LSUP_MAX_WARNING.
+ * in the list. Also change VOLK_MAX_WARNING.
  */
-#define LSUP_MAX_WARNING    LSUP_CONFLICT
+#define VOLK_MAX_WARNING    VOLK_CONFLICT
 
 /// Generic error return code.
-#define LSUP_ERROR          -88899
+#define VOLK_ERROR          -88899
 
 /// Codec parser error.
-#define LSUP_PARSE_ERR      -88898
+#define VOLK_PARSE_ERR      -88898
 
 /// An invalid input value was provided.
-#define LSUP_VALUE_ERR      -88897
+#define VOLK_VALUE_ERR      -88897
 
 /// Error handling a store transaction.
-#define LSUP_TXN_ERR        -88896
+#define VOLK_TXN_ERR        -88896
 
 /// Low-level database error.
-#define LSUP_DB_ERR         -88895
+#define VOLK_DB_ERR         -88895
 
 /// Functionality is not implemented.
-#define LSUP_NOT_IMPL_ERR   -88894
+#define VOLK_NOT_IMPL_ERR   -88894
 
 /// I/O error.
-#define LSUP_IO_ERR         -88893
+#define VOLK_IO_ERR         -88893
 
 /// Memory allocation error.
-#define LSUP_MEM_ERR        -88892
+#define VOLK_MEM_ERR        -88892
 
 /** @brief Conflict error.
  *
@@ -152,12 +152,12 @@ typedef int LSUP_rc;
  * operation has been interrupted and any state change within the loop prior to
  * the error has been rolled back.
  *
- * The warning-level counterpart to this is #LSUP_CONFLICT.
+ * The warning-level counterpart to this is #VOLK_CONFLICT.
  */
-#define LSUP_CONFLICT_ERR   -88891
+#define VOLK_CONFLICT_ERR   -88891
 
 /// Error while handling environment setup; or environment not initialized.
-#define LSUP_ENV_ERR        -88890
+#define VOLK_ENV_ERR        -88890
 ///@}  END defgroup return
 
 /** @defgroup hashing Hashing stuff
@@ -165,64 +165,64 @@ typedef int LSUP_rc;
  * @{
  */
 
-#ifndef LSUP_HASH_SEED
+#ifndef VOLK_HASH_SEED
 /// Seed used for all hashing. Compile-time configurable.
-#define LSUP_HASH_SEED 0
+#define VOLK_HASH_SEED 0
 #endif
 
 /// Default 32-bit hashing function.
-#define LSUP_HASH32(buf, size, seed) XXH32 (buf, size, seed)
+#define VOLK_HASH32(buf, size, seed) XXH32 (buf, size, seed)
 /// Default 64-bit hashing function.
-#define LSUP_HASH64(buf, size, seed) XXH3_64bits_withSeed (buf, size, seed)
+#define VOLK_HASH64(buf, size, seed) XXH3_64bits_withSeed (buf, size, seed)
 /// Default 128-bit hashing function.
-#define LSUP_HASH128(buf, size, seed) XXH3_128bits_withSeed (buf, size, seed)
+#define VOLK_HASH128(buf, size, seed) XXH3_128bits_withSeed (buf, size, seed)
 /// Default hashing function. Depends on architecture.
 #if INTPTR_MAX == INT64_MAX
-#define LSUP_HASH(...) LSUP_HASH64 (__VA_ARGS__)
+#define VOLK_HASH(...) VOLK_HASH64 (__VA_ARGS__)
 #else
-#define LSUP_HASH(...) LSUP_HASH32 (__VA_ARGS__)
+#define VOLK_HASH(...) VOLK_HASH32 (__VA_ARGS__)
 #endif
 
 
 extern char *warning_msg[], *error_msg[];
 
-extern char *LSUP_root_path;
+extern char *VOLK_root_path;
 
 
 /// 32-bit hash data type.
-typedef XXH32_hash_t LSUP_Hash32;
+typedef XXH32_hash_t VOLK_Hash32;
 /// 64-bit hash data type.
-typedef XXH64_hash_t LSUP_Hash64;
+typedef XXH64_hash_t VOLK_Hash64;
 /// 128-bit hash data type.
-typedef XXH128_hash_t LSUP_Hash128;
+typedef XXH128_hash_t VOLK_Hash128;
 /** @brief Default hash data type.
  *
  * This is 64 bit long for 64-bit systems.
  */
 #if INTPTR_MAX == INT64_MAX
-typedef LSUP_Hash64 LSUP_Hash;
+typedef VOLK_Hash64 VOLK_Hash;
 #else
-typedef LSUP_Hash32 LSUP_Hash;
+typedef VOLK_Hash32 VOLK_Hash;
 #endif
 ///@}  END defgroup hashing
 
 /// Boolean operations that can be performed on a graph.
 typedef enum {
-    LSUP_BOOL_UNION,                ///< Boolean union.
-    LSUP_BOOL_SUBTRACTION,          ///< Boolean subtraction.
-    LSUP_BOOL_INTERSECTION,         ///< Boolean intersection.
-    LSUP_BOOL_XOR,                  ///< Boolean XOR.
-} LSUP_bool_op;
+    VOLK_BOOL_UNION,                ///< Boolean union.
+    VOLK_BOOL_SUBTRACTION,          ///< Boolean subtraction.
+    VOLK_BOOL_INTERSECTION,         ///< Boolean intersection.
+    VOLK_BOOL_XOR,                  ///< Boolean XOR.
+} VOLK_bool_op;
 
 
 /// Term key, i.e., hash of a serialized term.
-typedef size_t LSUP_Key;
-/// Array of two #LSUP_Key values.
-typedef LSUP_Key LSUP_DoubleKey[2];
-/// Array of three #LSUP_Key values, representing a triple.
-typedef LSUP_Key LSUP_TripleKey[3];
-/// Array of three #LSUP_Key values, representing a triple with context.
-typedef LSUP_Key LSUP_QuadKey[4];
+typedef size_t VOLK_Key;
+/// Array of two #VOLK_Key values.
+typedef VOLK_Key VOLK_DoubleKey[2];
+/// Array of three #VOLK_Key values, representing a triple.
+typedef VOLK_Key VOLK_TripleKey[3];
+/// Array of three #VOLK_Key values, representing a triple with context.
+typedef VOLK_Key VOLK_QuadKey[4];
 
 /// UUID string tpe.
 typedef char uuid_str_t[UUIDSTR_SIZE];
@@ -231,7 +231,7 @@ typedef char uuid_str_t[UUIDSTR_SIZE];
 /** @brief Return an error message for a return code.
  */
 const char *
-LSUP_strerror (LSUP_rc rc);
+VOLK_strerror (VOLK_rc rc);
 /// @} END defgroup public
 
 
@@ -239,12 +239,12 @@ LSUP_strerror (LSUP_rc rc);
  * @{
  */
 /// minimum error value.
-#define LSUP_MIN_ERROR      LSUP_ERROR
+#define VOLK_MIN_ERROR      VOLK_ERROR
 /**brief minimum error value.
  * @note When adding new error codes, use a value larger than the last one
- * in the list. Also change LSUP_MAX_ERROR.
+ * in the list. Also change VOLK_MAX_ERROR.
  */
-#define LSUP_MAX_ERROR      LSUP_ENV_ERR
+#define VOLK_MAX_ERROR      VOLK_ENV_ERR
 
 
 /*
@@ -260,36 +260,36 @@ LSUP_strerror (LSUP_rc rc);
 #define LOG_TRACE(...)
 #endif
 
-/** @brief Log an error or warning for return codes that are not LSUP_OK.
+/** @brief Log an error or warning for return codes that are not VOLK_OK.
  *
  * Note that, if used outside of the other macros below, care must be taken
  * to pass it an actual return code rather than an expression, otherwise the
  * expression will be evaluated multiple times.
  */
 #define LOG_RC(rc) do {                                             \
-    if ((rc) < 0) log_error (LSUP_strerror (rc));                   \
-    else if ((rc) > 0) log_warn (LSUP_strerror (rc));              \
+    if ((rc) < 0) log_error (VOLK_strerror (rc));                   \
+    else if ((rc) > 0) log_warn (VOLK_strerror (rc));              \
 } while (0);
 
-/// Jump to `marker` if `exp` does not return `LSUP_OK`.
+/// Jump to `marker` if `exp` does not return `VOLK_OK`.
 #define CHECK(exp, marker) do {                                     \
-    LSUP_rc _rc = (exp);                                            \
+    VOLK_rc _rc = (exp);                                            \
     LOG_RC(_rc);                                                    \
-    if (UNLIKELY (_rc != LSUP_OK)) {                                \
+    if (UNLIKELY (_rc != VOLK_OK)) {                                \
         log_error (                                                 \
                 "*** PREMATURE EXIT due to error: %s",              \
-                LSUP_strerror (_rc));                               \
+                VOLK_strerror (_rc));                               \
         goto marker;                                                \
     }                                                               \
 } while (0);
 
 /// Jump to `marker` if `exp` returns a negative value (skip warnings).
 #define PCHECK(exp, marker) do {                                    \
-    LSUP_rc _rc = (exp);                                            \
-    if (UNLIKELY (_rc < LSUP_OK)) {                                 \
+    VOLK_rc _rc = (exp);                                            \
+    if (UNLIKELY (_rc < VOLK_OK)) {                                 \
         log_error (                                                 \
                 "*** PREMATURE EXIT due to error: %s",              \
-                LSUP_strerror (_rc));                               \
+                VOLK_strerror (_rc));                               \
         LOG_RC(_rc);                                                \
         goto marker;                                                \
     }                                                               \
@@ -303,46 +303,46 @@ LSUP_strerror (LSUP_rc rc);
     }                                                               \
 } while (0);
 
-/// Return `exp` return value if it is of `LSUP_rc` type and nonzero.
+/// Return `exp` return value if it is of `VOLK_rc` type and nonzero.
 #define RCCK(exp) do {                                              \
-    LSUP_rc _rc = (exp);                                            \
-    if (UNLIKELY (_rc != LSUP_OK)) {                                \
+    VOLK_rc _rc = (exp);                                            \
+    if (UNLIKELY (_rc != VOLK_OK)) {                                \
         log_error (                                                 \
                 "*** PREMATURE EXIT due to error: %s",              \
-                LSUP_strerror (_rc));                               \
+                VOLK_strerror (_rc));                               \
         return _rc;                                                 \
     }                                                               \
 } while (0);
 
-/// Return `exp` return value if it is of `LSUP_rc` type and negative (=error)
+/// Return `exp` return value if it is of `VOLK_rc` type and negative (=error)
 #define PRCCK(exp) do {                                             \
-    LSUP_rc _rc = (exp);                                            \
-    if (UNLIKELY (_rc < LSUP_OK)) {                                 \
+    VOLK_rc _rc = (exp);                                            \
+    if (UNLIKELY (_rc < VOLK_OK)) {                                 \
         log_error (                                                 \
                 "*** PREMATURE EXIT due to error: %s",              \
-                LSUP_strerror (_rc));                               \
+                VOLK_strerror (_rc));                               \
         return _rc;                                                 \
     }                                                               \
 } while (0);
 
 /// Return `NULL` if `exp` returns a nonzero value.
 #define RCNL(exp) do {                                              \
-    LSUP_rc _rc = (exp);                                            \
-    if (UNLIKELY (_rc != LSUP_OK)) {                                \
+    VOLK_rc _rc = (exp);                                            \
+    if (UNLIKELY (_rc != VOLK_OK)) {                                \
         log_error (                                                 \
                 "*** PREMATURE EXIT due to error: %s",              \
-                LSUP_strerror (_rc));                               \
+                VOLK_strerror (_rc));                               \
         return NULL;                                                \
     }                                                               \
 } while (0);
 
 /// Return NULL if `exp` returns a negative value (=error)
 #define PRCNL(exp) do {                                             \
-    LSUP_rc _rc = (exp);                                            \
-    if (UNLIKELY (_rc < LSUP_OK)) {                                 \
+    VOLK_rc _rc = (exp);                                            \
+    if (UNLIKELY (_rc < VOLK_OK)) {                                 \
         log_error (                                                 \
                 "*** PREMATURE EXIT due to error: %s",              \
-                LSUP_strerror (_rc));                               \
+                VOLK_strerror (_rc));                               \
         return NULL;                                                \
     }                                                               \
 } while (0);
@@ -360,8 +360,8 @@ LSUP_strerror (LSUP_rc rc);
 } while (0);
 
 /*
-#define MALLOC_GUARD_ME(var) MALLOC_GUARD((var), LSUP_MEM_ERR)      \
-#define CALLOC_GUARD_ME(var) CALLOC_GUARD((var), LSUP_MEM_ERR)      \
+#define MALLOC_GUARD_ME(var) MALLOC_GUARD((var), VOLK_MEM_ERR)      \
+#define CALLOC_GUARD_ME(var) CALLOC_GUARD((var), VOLK_MEM_ERR)      \
 #define MALLOC_GUARD_NL(var) MALLOC_GUARD((var), NULL)              \
 #define CALLOC_GUARD_NL(var) CALLOC_GUARD((var), NULL)              \
 */
@@ -372,7 +372,7 @@ LSUP_strerror (LSUP_rc rc);
  * Modified from
  * https://gist.github.com/JonathonReinhart/8c0d90191c38af2dcadb102c4e202950
  */
-LSUP_rc
+VOLK_rc
 mkdir_p (const char *path, mode_t mode);
 
 
@@ -380,7 +380,7 @@ mkdir_p (const char *path, mode_t mode);
  *
  * @param[in] path Path of directory to remove.
  */
-LSUP_rc
+VOLK_rc
 rm_r (const char *path);
 
 
@@ -442,4 +442,4 @@ inline int utf8_encode (const uint32_t utf, unsigned char *out)
 
 /// @} END defgroup private
 
-#endif  /* _LSUP_CORE_H */
+#endif  /* _VOLK_CORE_H */

+ 4 - 4
include/lsup/data/bootstrap.h → include/volksdata/data/bootstrap.h

@@ -1,5 +1,5 @@
-#ifndef LSUP_INIT_DATA_H
-#define LSUP_INIT_DATA_H
+#ifndef VOLK_INIT_DATA_H
+#define VOLK_INIT_DATA_H
 
 /** @brief Initial namespace map.
  */
@@ -7,11 +7,11 @@ const char *init_nsmap[][2] = {
     {"dc",       "http://purl.org/dc/elements/1.1/"},
     {"dcterms",  "http://purl.org/dc/terms/"},
     {"foaf",     "http://xmlns.com/foaf/0.1/"},
-    {"lsup",     LSUP_NS},
+    {"lsup",     VOLK_NS},
     {"rdf",      "http://www.w3.org/1999/02/22-rdf-syntax-ns#"},
     {"rdfs",     "http://www.w3.org/2000/01/rdf-schema#"},
     {"xsd",      "http://www.w3.org/2001/XMLSchema#"},
     {NULL}
 };
 
-#endif /* LSUP_INIT_DATA_H */
+#endif /* VOLK_INIT_DATA_H */

+ 18 - 18
include/lsup/environment.h → include/volksdata/environment.h

@@ -2,17 +2,17 @@
  *
  * @brief Handle LSUP environment initialization and teardown.
  *
- * #LSUP_init() should be called before performing any other interaction with
+ * #VOLK_init() should be called before performing any other interaction with
  * this library.
  *
- * #LSUP_done() is called automatically on program exit (`atexit`).
+ * #VOLK_done() is called automatically on program exit (`atexit`).
  */
 
-#ifndef _LSUP_ENVIRONMENT_H
-#define _LSUP_ENVIRONMENT_H
+#ifndef _VOLK_ENVIRONMENT_H
+#define _VOLK_ENVIRONMENT_H
 
 
-#include "lsup/term.h"
+#include "volksdata/term.h"
 
 
 /**@defgroup environment Environment module
@@ -27,14 +27,14 @@
 /** @brief Default context.
  *
  * The actual default context IRI used throughout the application may use a
- * value from the `LSUP_DEFAULT_CTX_URI` environment variable.
+ * value from the `VOLK_DEFAULT_CTX_URI` environment variable.
  */
-#define DEFAULT_CTX_LABEL LSUP_NS "default"
+#define DEFAULT_CTX_LABEL VOLK_NS "default"
 
 /// Default context.
-extern LSUP_Term *LSUP_default_ctx;
+extern VOLK_Term *VOLK_default_ctx;
 /// Serialized default context.
-extern LSUP_Buffer *LSUP_default_ctx_buf;
+extern VOLK_Buffer *VOLK_default_ctx_buf;
 
 
 /** @brief Initialize the default environment.
@@ -44,11 +44,11 @@ extern LSUP_Buffer *LSUP_default_ctx_buf;
  * The default environment is cleaned up automatically on exit.
  *
  * This environment should suit most cases, unless an application needs to use
- * multiple environments and call #LSUP_init with specific handles. Such
- * other environment(s) must be freed up manually with #LSUP_done().
+ * multiple environments and call #VOLK_init with specific handles. Such
+ * other environment(s) must be freed up manually with #VOLK_done().
  */
-LSUP_rc
-LSUP_init (void);
+VOLK_rc
+VOLK_init (void);
 
 /** @brief Close the default environment.
  *
@@ -56,20 +56,20 @@ LSUP_init (void);
  * no effect.
  */
 void
-LSUP_done (void);
+VOLK_done (void);
 
 
 /** TODO
  */
-LSUP_rc
-LSUP_env_put_id (const uint32_t key, const char *data);
+VOLK_rc
+VOLK_env_put_id (const uint32_t key, const char *data);
 
 
 /** TODO
  */
 const char *
-LSUP_env_get_id (const uint32_t key);
+VOLK_env_get_id (const uint32_t key);
 
 /// @} END defgroup environment
 
-#endif /* _LSUP_ENVIRONMENT_H */
+#endif /* _VOLK_ENVIRONMENT_H */

+ 125 - 125
include/lsup/graph.h → include/volksdata/graph.h

@@ -1,9 +1,9 @@
-#ifndef _LSUP_GRAPH_H
-#define _LSUP_GRAPH_H
+#ifndef _VOLK_GRAPH_H
+#define _VOLK_GRAPH_H
 
-#include "lsup/store.h"
-#include "lsup/environment.h"
-#include "lsup/term.h"
+#include "volksdata/store.h"
+#include "volksdata/environment.h"
+#include "volksdata/term.h"
 
 
 /** @defgroup graph RDF graph module
@@ -13,50 +13,50 @@
 
 /** @brief Graph object.
  */
-typedef struct graph_t LSUP_Graph;
+typedef struct graph_t VOLK_Graph;
 
 /** @brief Graph iterator.
  *
- * This opaque handle is generated by #LSUP_graph_lookup_txn and is used to
- * iterate over lookup results with #LSUP_graph_iter_next. It must be freed
- * with #LSUP_graph_iter_free when done.
+ * This opaque handle is generated by #VOLK_graph_lookup_txn and is used to
+ * iterate over lookup results with #VOLK_graph_iter_next. It must be freed
+ * with #VOLK_graph_iter_free when done.
  */
-typedef struct graph_iter_t LSUP_GraphIterator;
+typedef struct graph_iter_t VOLK_GraphIterator;
 
 
 /** @brief Create new graph.
  *
  * @param[in] store Back end store handle. It may be the result of
- * #LSUP_store_new(), or NULL; in the latter case, it defaults to a temporary
+ * #VOLK_store_new(), or NULL; in the latter case, it defaults to a temporary
  * HTable store that is freed together with the graph.
  *
  * @param[in] uri_str URI string of the new graph. It MUST be a non-prefixed
- *  URI. For a namespace-prefixed URI, use #LSUP_graph_new_ns(). If NULL, a
+ *  URI. For a namespace-prefixed URI, use #VOLK_graph_new_ns(). If NULL, a
  *  UUID4 URN is generated.
  *
- * @return New graph, or NULL on error. Must be freed with #LSUP_graph_free().
+ * @return New graph, or NULL on error. Must be freed with #VOLK_graph_free().
  */
-LSUP_Graph *
-LSUP_graph_new (LSUP_Store *store, const char *uri_str);
+VOLK_Graph *
+VOLK_graph_new (VOLK_Store *store, const char *uri_str);
 
 
 /** @brief Create an empty graph using a namespace-prefixed string for its URI.
  *
  * @param[in] store Back end store handle. It may be the result of
- * #LSUP_store_new(), or NULL; in the latter case, it defaults to a temporary
+ * #VOLK_store_new(), or NULL; in the latter case, it defaults to a temporary
  * HTable store that is freed together with the graph.
  *
  * @param[in] uri_str URI string of the new graph. It MUST be a namespace-
  *  prefixed URI registered in the global namespace map. It cannot be NULL.
  *
- * @return New graph, or NULL on error. Must be freed with #LSUP_graph_free().
+ * @return New graph, or NULL on error. Must be freed with #VOLK_graph_free().
  */
-inline LSUP_Graph *
-LSUP_graph_new_ns (LSUP_Store *store, const char *ns_str) {
+inline VOLK_Graph *
+VOLK_graph_new_ns (VOLK_Store *store, const char *ns_str) {
     char *uri_str;
-    RCNL (LSUP_nsmap_normalize_uri (ns_str, &uri_str));
+    RCNL (VOLK_nsmap_normalize_uri (ns_str, &uri_str));
 
-    LSUP_Graph *gr = LSUP_graph_new (store, uri_str);
+    VOLK_Graph *gr = VOLK_graph_new (store, uri_str);
     free (uri_str);
 
     return gr;
@@ -82,13 +82,13 @@ LSUP_graph_new_ns (LSUP_Store *store, const char *ns_str) {
  * @return New graph handle. It must be freed by the caller. If no matching
  * context URI was found, NULL is returned.
  */
-LSUP_Graph *
-LSUP_graph_get_txn (
-        void *txn, LSUP_Store *store, const LSUP_Term *uri, size_t *ct);
+VOLK_Graph *
+VOLK_graph_get_txn (
+        void *txn, VOLK_Store *store, const VOLK_Term *uri, size_t *ct);
 
 
-/// Non-transactional version of #LSUP_graph_get_txn().
-#define LSUP_graph_get(...) LSUP_graph_get_txn (NULL, __VA_ARGS__)
+/// Non-transactional version of #VOLK_graph_get_txn().
+#define VOLK_graph_get(...) VOLK_graph_get_txn (NULL, __VA_ARGS__)
 
 
 /** @brief Copy triples from a source graph into a destination one.
@@ -108,18 +108,18 @@ LSUP_graph_get_txn (
  * @param[in] s, p, o Terms to look up for filtering. Any and all terms can be
  * NULL, which indicate unbound terms.
  *
- * @return LSUP_OK on success; LSUP_NOACTION if no triples were copied; <0
+ * @return VOLK_OK on success; VOLK_NOACTION if no triples were copied; <0
  *  if an error occurred.
  */
-LSUP_rc
-LSUP_graph_copy_contents_txn (
-        void *txn, const LSUP_Graph *src, LSUP_Graph *dest,
-        const LSUP_Term *s, const LSUP_Term *p, const LSUP_Term *o);
+VOLK_rc
+VOLK_graph_copy_contents_txn (
+        void *txn, const VOLK_Graph *src, VOLK_Graph *dest,
+        const VOLK_Term *s, const VOLK_Term *p, const VOLK_Term *o);
 
 
 /* @brief Copy all triples from a graph (non-transactional).
  *
- * This is a shortcut for #LSUP_graph_copy_contents_txn(). If you need to
+ * This is a shortcut for #VOLK_graph_copy_contents_txn(). If you need to
  * specify a transaction handle for the copy, use that.
  *
  * @param[in] src Source graph.
@@ -129,27 +129,27 @@ LSUP_graph_copy_contents_txn (
  * @param[in] s, p, o Terms to look up for filtering. Any and all terms can be
  * NULL, which indicate unbound terms.
  *
- * @return LSUP_OK on success; LSUP_NOACTION if no triples were copied; <0
+ * @return VOLK_OK on success; VOLK_NOACTION if no triples were copied; <0
  *  if an error occurred.
  */
-#define LSUP_graph_copy_contents(...) \
-    LSUP_graph_copy_contents_txn (NULL, __VA_ARGS__)
+#define VOLK_graph_copy_contents(...) \
+    VOLK_graph_copy_contents_txn (NULL, __VA_ARGS__)
 
 
 /* @brief Copy all triples from a graph.
  *
- * This is a shortcut for #LSUP_graph_copy_contents_txn(). If you need to
+ * This is a shortcut for #VOLK_graph_copy_contents_txn(). If you need to
  * specify a transaction handle and/or a filter for the copy, use that.
  *
  * @param[in] src Source graph.
  *
  * @param[in] dest Destination graph.
  *
- * @return LSUP_OK on success; LSUP_NOACTION if no triples were copied; <0
+ * @return VOLK_OK on success; VOLK_NOACTION if no triples were copied; <0
  *  if an error occurred.
  */
-#define LSUP_graph_copy(src, dest) \
-    LSUP_graph_copy_contents_txn (NULL, src, dest, NULL, NULL, NULL)
+#define VOLK_graph_copy(src, dest) \
+    VOLK_graph_copy_contents_txn (NULL, src, dest, NULL, NULL, NULL)
 
 
 /** Perform a boolean operation between two graphs.
@@ -161,34 +161,34 @@ LSUP_graph_copy_contents_txn (
  * @param[in] txn R/W transaction handle for the destination store.  It may be
  * NULL, or an open transaction within which the operation is performed.
  *
- * @param[in] op Operation to perform. One of #LSUP_bool_op.
+ * @param[in] op Operation to perform. One of #VOLK_bool_op.
  *
  * @param[in] gr1 First operand.
  *
  * @param[in] gr2 Second operand.
  *
  * @param[out] res Result graph. The handle should be initialized via
- *  #LSUP_graph_new() or equivalent. Any preexisting contents are not removed.
+ *  #VOLK_graph_new() or equivalent. Any preexisting contents are not removed.
  *  If an unrecoverable error occurs, this graph is freed, and any preexisting
  *  triples are lost. Therefore, reusing a result graph handle should only be
  *  done in tightly controlled loops or sequences.
  *
- * @return LSUP_OK on success; <0 on error.
+ * @return VOLK_OK on success; <0 on error.
  */
-LSUP_rc
-LSUP_graph_bool_op_txn (
-        void *txn, const LSUP_bool_op op,
-        const LSUP_Graph *gr1, const LSUP_Graph *gr2, LSUP_Graph *res);
+VOLK_rc
+VOLK_graph_bool_op_txn (
+        void *txn, const VOLK_bool_op op,
+        const VOLK_Graph *gr1, const VOLK_Graph *gr2, VOLK_Graph *res);
 
 
-/// Non-transactional version of #LSUP_graph_bool_op_txn.
-#define LSUP_graph_bool_op(...) LSUP_graph_bool_op_txn (NULL, __VA_ARGS__)
+/// Non-transactional version of #VOLK_graph_bool_op_txn.
+#define VOLK_graph_bool_op(...) VOLK_graph_bool_op_txn (NULL, __VA_ARGS__)
 
 
 /** @brief Free a graph.
  */
 void
-LSUP_graph_free (LSUP_Graph *gr);
+VOLK_graph_free (VOLK_Graph *gr);
 
 
 /** @brief Compare two graphs.
@@ -203,30 +203,30 @@ LSUP_graph_free (LSUP_Graph *gr);
  * @return True if the graphs are topologically equal, false otherwise.
  */
 bool
-LSUP_graph_equals (const LSUP_Graph *gr1, const LSUP_Graph *gr2);
+VOLK_graph_equals (const VOLK_Graph *gr1, const VOLK_Graph *gr2);
 
 
 /** @brief Read-only graph URI.
  *
- * Note that, while #LSUP_graph_new() and #LSUP_graph_set_uri() expect a
- *  string, this function returns the complete #LSUP_Term structure.
+ * Note that, while #VOLK_graph_new() and #VOLK_graph_set_uri() expect a
+ *  string, this function returns the complete #VOLK_Term structure.
  *
- * To change the graph URI, use #LSUP_graph_set_uri.
+ * To change the graph URI, use #VOLK_graph_set_uri.
  */
-const LSUP_Term *
-LSUP_graph_uri (const LSUP_Graph *gr);
+const VOLK_Term *
+VOLK_graph_uri (const VOLK_Graph *gr);
 
 
 /** @brief Underlying graph store handle.
  */
-LSUP_Store *
-LSUP_graph_store (const LSUP_Graph *gr);
+VOLK_Store *
+VOLK_graph_store (const VOLK_Graph *gr);
 
 
 /** Set the URI of a graph.
  *
  * Note that by changing the URI of a graph backed by a context-sensitive store
- * (i.e. LSUP_STORE_MDB*) effectively changes the underlying context that the
+ * (i.e. VOLK_STORE_MDB*) effectively changes the underlying context that the
  * triples are bound to. Triples are looked up in, and added to, the context
  * that the graph URI represents. A non-context graph retains the same triple
  * set when a graph URI changes, and relative URI lookups are resolved in
@@ -237,10 +237,10 @@ LSUP_graph_store (const LSUP_Graph *gr);
  * @param[in] uri_str New URI string. If namespace-prefixed, it will be
  *  resolved according to the graph's namespace map.
  *
- * @return LSUP_OK on success; <0 on error.
+ * @return VOLK_OK on success; <0 on error.
  */
-LSUP_rc
-LSUP_graph_set_uri (LSUP_Graph *gr, const char *uri_str);
+VOLK_rc
+VOLK_graph_set_uri (VOLK_Graph *gr, const char *uri_str);
 
 
 /** @brief Number of triples in a graph.
@@ -250,7 +250,7 @@ LSUP_graph_set_uri (LSUP_Graph *gr, const char *uri_str);
  * @return Number of triples, or a negative value on error.
  */
 size_t
-LSUP_graph_size (const LSUP_Graph *gr);
+VOLK_graph_size (const VOLK_Graph *gr);
 
 
 /** @brief Whether a graph contains a triple.
@@ -262,7 +262,7 @@ LSUP_graph_size (const LSUP_Graph *gr);
  * @return 1 if the triple is found, 0 if not found.
  */
 bool
-LSUP_graph_contains (const LSUP_Graph *gr, const LSUP_Triple *spo);
+VOLK_graph_contains (const VOLK_Graph *gr, const VOLK_Triple *spo);
 
 
 /** @brief Initialize an iterator to add triples.
@@ -272,37 +272,37 @@ LSUP_graph_contains (const LSUP_Graph *gr, const LSUP_Triple *spo);
  *
  * @param[in] gr Graph to add to. It is added to the iterator state.
  *
- * @return Iterator handle. This should be passed to #LSUP_graph_add_iter() and
- * must be freed with #LSUP_graph_add_done().
+ * @return Iterator handle. This should be passed to #VOLK_graph_add_iter() and
+ * must be freed with #VOLK_graph_add_done().
  */
-LSUP_GraphIterator *
-LSUP_graph_add_init_txn (void *txn, LSUP_Graph *gr);
+VOLK_GraphIterator *
+VOLK_graph_add_init_txn (void *txn, VOLK_Graph *gr);
 
 
-/// Non-transactional version of #LSUP_graph_add_init_txn().
-#define LSUP_graph_add_init(...) LSUP_graph_add_init_txn (NULL, __VA_ARGS__)
+/// Non-transactional version of #VOLK_graph_add_init_txn().
+#define VOLK_graph_add_init(...) VOLK_graph_add_init_txn (NULL, __VA_ARGS__)
 
 
 /** @brief Add a single triple to the store.
  *
- * @param[in] it Iterator obtained with #LSUP_graph_add_init_txn().
+ * @param[in] it Iterator obtained with #VOLK_graph_add_init_txn().
  *
  * @param[in] spo Triple to add. Caller retains ownership. NOTE: the triple
  *  subject and object, if IRIRefs, are stored as relative to the graph URI.
  */
-LSUP_rc
-LSUP_graph_add_iter (LSUP_GraphIterator *it, const LSUP_Triple *spo);
+VOLK_rc
+VOLK_graph_add_iter (VOLK_GraphIterator *it, const VOLK_Triple *spo);
 
 
 /** @brief Finalize an add iteration loop and free the iterator.
  *
  * DO NOT USE with iterators obtained with other than
- * #LSUP_graph_add_init_txn().
+ * #VOLK_graph_add_init_txn().
  *
  * @param[in] it Iterator to finalize.
  */
 void
-LSUP_graph_add_done (LSUP_GraphIterator *it);
+VOLK_graph_add_done (VOLK_GraphIterator *it);
 
 
 /** @brief Add triples to a graph.
@@ -316,13 +316,13 @@ LSUP_graph_add_done (LSUP_GraphIterator *it);
  * @param[out] ct This will be filled with the total number of triples
  *  inserted.
  */
-LSUP_rc
-LSUP_graph_add_txn (
-        void *txn, LSUP_Graph *gr, LSUP_Triple *const *trp, size_t *ct);
+VOLK_rc
+VOLK_graph_add_txn (
+        void *txn, VOLK_Graph *gr, VOLK_Triple *const *trp, size_t *ct);
 
 
-/// Non-transactional version of #LSUP_graph_add_txn.
-#define LSUP_graph_add(...) LSUP_graph_add_txn (NULL, __VA_ARGS__)
+/// Non-transactional version of #VOLK_graph_add_txn.
+#define VOLK_graph_add(...) VOLK_graph_add_txn (NULL, __VA_ARGS__)
 
 
 /** @brief Delete triples by a matching pattern.
@@ -336,14 +336,14 @@ LSUP_graph_add_txn (
  * @param[out] ct If not NULL it is populated with the number of triples
  *  deleted.
  */
-LSUP_rc
-LSUP_graph_remove_txn (
-        void *txn, LSUP_Graph *gr, const LSUP_Term *s, const LSUP_Term *p,
-        const LSUP_Term *o, size_t *ct);
+VOLK_rc
+VOLK_graph_remove_txn (
+        void *txn, VOLK_Graph *gr, const VOLK_Term *s, const VOLK_Term *p,
+        const VOLK_Term *o, size_t *ct);
 
 
-/// Non-transactional version of #LSUP_graph_remove_txn.
-#define LSUP_graph_remove(...) LSUP_graph_remove_txn (NULL, __VA_ARGS__)
+/// Non-transactional version of #VOLK_graph_remove_txn.
+#define VOLK_graph_remove(...) VOLK_graph_remove_txn (NULL, __VA_ARGS__)
 
 
 /** @brief Look up triples by a matching pattern and yield an iterator.
@@ -364,48 +364,48 @@ LSUP_graph_remove_txn (
  * @param[out] ct If not NULL, this handle is populated with the number of
  *  entries found.
  *
- * @return Pointer to a LSUP_GraphIterator to be generated. It must be
- *  freed with #LSUP_graph_iter_free() after use.
+ * @return Pointer to a VOLK_GraphIterator to be generated. It must be
+ *  freed with #VOLK_graph_iter_free() after use.
  */
-LSUP_GraphIterator *
-LSUP_graph_lookup_txn (void *txn, const LSUP_Graph *gr, const LSUP_Term *s,
-        const LSUP_Term *p, const LSUP_Term *o, size_t *ct);
+VOLK_GraphIterator *
+VOLK_graph_lookup_txn (void *txn, const VOLK_Graph *gr, const VOLK_Term *s,
+        const VOLK_Term *p, const VOLK_Term *o, size_t *ct);
 
 
-/// Non-transactional version of #LSUP_graph_lookup_txn.
-#define LSUP_graph_lookup(...) LSUP_graph_lookup_txn (NULL, __VA_ARGS__)
+/// Non-transactional version of #VOLK_graph_lookup_txn.
+#define VOLK_graph_lookup(...) VOLK_graph_lookup_txn (NULL, __VA_ARGS__)
 
 
 /** @brief Advance a cursor obtained by a lookup and return a matching triple.
  *
- * @param[in] it Iterator handle obtained through #LSUP_graph_lookup_txn.
+ * @param[in] it Iterator handle obtained through #VOLK_graph_lookup_txn.
  *
  * @param[out] spo Triple handle pointer to be populated with the next result.
  * If not NULL, it will allocate a new triple and new terms, and should be
- * freed with LSUP_triple_free().
+ * freed with VOLK_triple_free().
  *
- * @return LSUP_OK if a result was found; LSUP_END if the end of the match list
+ * @return VOLK_OK if a result was found; VOLK_END if the end of the match list
  *  was reached.
  */
-LSUP_rc
-LSUP_graph_iter_next (LSUP_GraphIterator *it, LSUP_Triple **spo);
+VOLK_rc
+VOLK_graph_iter_next (VOLK_GraphIterator *it, VOLK_Triple **spo);
 
 
 /** @brief Return the graph related to an iterator.
  */
-const LSUP_Graph *
-LSUP_graph_iter_graph (LSUP_GraphIterator *it);
+const VOLK_Graph *
+VOLK_graph_iter_graph (VOLK_GraphIterator *it);
 
 
 /** @brief Free a graph iterator.
  *
- * DO NOT USE with iterators obtained with #LSUP_graph_add_init_txn(). Use
- * #LSUP_graph_add_done() with those.
+ * DO NOT USE with iterators obtained with #VOLK_graph_add_init_txn(). Use
+ * #VOLK_graph_add_done() with those.
  *
  * @param[in] it Iterator to finalize.
  */
 void
-LSUP_graph_iter_free (LSUP_GraphIterator *it);
+VOLK_graph_iter_free (VOLK_GraphIterator *it);
 
 
 /** @brief Print graph information and triples to stdout.
@@ -413,15 +413,15 @@ LSUP_graph_iter_free (LSUP_GraphIterator *it);
  * @param[in] gr Graph handle to display.
  */
 void
-LSUP_graph_print (const LSUP_Graph *gr);
+VOLK_graph_print (const VOLK_Graph *gr);
 
 
 /** @brief Get term pairs connected to a term in a graph.
  *
- * This returns a #LSUP_LinkMap extracted from a graph for a given term. The
- * map can generate triples using #LSUP_link_map_triples().
+ * This returns a #VOLK_LinkMap extracted from a graph for a given term. The
+ * map can generate triples using #VOLK_link_map_triples().
  *
- * Depending on the type requested (`LSUP_CONN_*), the term can be leveraged
+ * Depending on the type requested (`VOLK_CONN_*), the term can be leveraged
  * as a subject, predicate, or object.
  *
  * @param[in] gr Graph to extract the connection list from.
@@ -431,11 +431,11 @@ LSUP_graph_print (const LSUP_Graph *gr);
  * @param[in] type Type of connections to look up.
  *
  * @return Link map for the requested term. It should be freed with
- *  #LSUP_link_map_free().
+ *  #VOLK_link_map_free().
  */
-LSUP_LinkMap *
-LSUP_graph_connections (
-        const LSUP_Graph *gr, const LSUP_Term *t, const LSUP_LinkType type);
+VOLK_LinkMap *
+VOLK_graph_connections (
+        const VOLK_Graph *gr, const VOLK_Term *t, const VOLK_LinkType type);
 
 
 /** @brief Get a list of terms related to a term pair in a graph.
@@ -452,10 +452,10 @@ LSUP_graph_connections (
  *
  * @return Term set of results.
  */
-LSUP_TermSet *
-LSUP_graph_term_set (
-        const LSUP_Graph *gr, const LSUP_Term *t1, const LSUP_TriplePos t1_pos,
-        const LSUP_Term *t2, const LSUP_TriplePos t2_pos);
+VOLK_TermSet *
+VOLK_graph_term_set (
+        const VOLK_Graph *gr, const VOLK_Term *t1, const VOLK_TriplePos t1_pos,
+        const VOLK_Term *t2, const VOLK_TriplePos t2_pos);
 
 
 /** @brief Get all unique subjcts, predicates, or objects in a graph.
@@ -464,8 +464,8 @@ LSUP_graph_term_set (
  *
  * @param[in] pos Position in the triples of the terms to look for.
  */
-LSUP_TermSet *
-LSUP_graph_unique_terms (const LSUP_Graph *gr, LSUP_TriplePos pos);
+VOLK_TermSet *
+VOLK_graph_unique_terms (const VOLK_Graph *gr, VOLK_TriplePos pos);
 
 
 /** @brief List all graph URIs in a store.
@@ -476,12 +476,12 @@ LSUP_graph_unique_terms (const LSUP_Graph *gr, LSUP_TriplePos pos);
  *
  * @return Term set of graph URIs, or NULL on error.
  */
-LSUP_TermSet *
-LSUP_graph_list_txn (void *txn, const LSUP_Store *store);
+VOLK_TermSet *
+VOLK_graph_list_txn (void *txn, const VOLK_Store *store);
 
 
-/// Non-transactional version of #LSUP_graph_list_txn.
-#define LSUP_graph_list(...) LSUP_graph_list_txn (NULL, __VA_ARGS__)
+/// Non-transactional version of #VOLK_graph_list_txn.
+#define VOLK_graph_list(...) VOLK_graph_list_txn (NULL, __VA_ARGS__)
 
 
 /** @brief Add triples for a term and related link map to a graph.
@@ -490,14 +490,14 @@ LSUP_graph_list_txn (void *txn, const LSUP_Store *store);
  * that, triples are added with the given term as the subject, the predicate,
  * or the object.
  *
- * @param[in] it Graph iterator obtained with #LSUP_graph_add_init_txn().
+ * @param[in] it Graph iterator obtained with #VOLK_graph_add_init_txn().
  *
  * @param[in] lm Link map.
  *
- * @return Number of triples parsed on success, or <0 (LSUP_*_ERR) on error.
+ * @return Number of triples parsed on success, or <0 (VOLK_*_ERR) on error.
  */
 size_t
-LSUP_graph_add_link_map ( LSUP_GraphIterator *it, LSUP_LinkMap *lm);
+VOLK_graph_add_link_map ( VOLK_GraphIterator *it, VOLK_LinkMap *lm);
 
 
 /** @brief Add triples for an anonymous collection to a graph.
@@ -511,8 +511,8 @@ LSUP_graph_add_link_map ( LSUP_GraphIterator *it, LSUP_LinkMap *lm);
  *
  * @return Blank node representing the first list item.
  */
-LSUP_Term *
-LSUP_bnode_add_collection (LSUP_GraphIterator *it, LSUP_TermSet *ts);
+VOLK_Term *
+VOLK_bnode_add_collection (VOLK_GraphIterator *it, VOLK_TermSet *ts);
 
 /// @}  END defgroup graph
 #endif

+ 26 - 26
include/lsup/namespace.h → include/volksdata/namespace.h

@@ -1,9 +1,9 @@
-#ifndef _LSUP_NAMESPACE_H
-#define _LSUP_NAMESPACE_H
+#ifndef _VOLK_NAMESPACE_H
+#define _VOLK_NAMESPACE_H
 
 #include "hashmap.h"
 
-#include "lsup/core.h"
+#include "volksdata/core.h"
 
 
 /** @defgroup namespace Namespace module
@@ -18,23 +18,23 @@
 
 /** @brief Namespace prefix type.
  */
-typedef char LSUP_ns_pfx[PFX_LEN];
+typedef char VOLK_ns_pfx[PFX_LEN];
 
 
 /** @brief Prefix / Namespace pair.
  */
 typedef struct ns_entry_t {
-    LSUP_ns_pfx         pfx;        // Namespace prefix.
+    VOLK_ns_pfx         pfx;        // Namespace prefix.
     char *              ns;         // Fully qualified NS.
 } NSEntry;
 
 
 /** @brief Default namespace prefix map.
  *
- * This is a singleton. It gets created with #LSUP_init() and freed with
- * #LSUP_done().
+ * This is a singleton. It gets created with #VOLK_init() and freed with
+ * #VOLK_done().
  */
-extern struct hashmap *LSUP_default_nsm;
+extern struct hashmap *VOLK_default_nsm;
 
 
 /** @brief Add a prefix -> namespace pair to the map or update it.
@@ -47,11 +47,11 @@ extern struct hashmap *LSUP_default_nsm;
  *
  * @param[in] nsstr Fully qualified namespace.
  *
- * @return LSUP_OK if the record was added or replaced; LSUP_MEM_ERR if an
+ * @return VOLK_OK if the record was added or replaced; VOLK_MEM_ERR if an
  * allocation error occurred.
  */
-LSUP_rc
-LSUP_nsmap_add (const char *pfx, const char *nsstr);
+VOLK_rc
+VOLK_nsmap_add (const char *pfx, const char *nsstr);
 
 
 /** @brief Remove a prefix -> namespace pair from a map.
@@ -60,10 +60,10 @@ LSUP_nsmap_add (const char *pfx, const char *nsstr);
  *
  * @param[in] pfx The namespace prefix to remove.
  *
- * @return LSUP_OK on successful delete; LSUP_NOACTION if no record was found.
+ * @return VOLK_OK on successful delete; VOLK_NOACTION if no record was found.
  */
-LSUP_rc
-LSUP_nsmap_remove (const char *pfx);
+VOLK_rc
+VOLK_nsmap_remove (const char *pfx);
 
 
 /** @brief Get the namespace for a prefix.
@@ -76,7 +76,7 @@ LSUP_nsmap_remove (const char *pfx);
  *  should not be modified directly.
  */
 const char *
-LSUP_nsmap_get_ns (const char *pfx);
+VOLK_nsmap_get_ns (const char *pfx);
 
 
 /** @brief Get the prefix for a namespace.
@@ -88,7 +88,7 @@ LSUP_nsmap_get_ns (const char *pfx);
  * @return Found prefix, or NULL if the namespace is not mapped.
  */
 const char *
-LSUP_nsmap_get_pfx (const char *ns);
+VOLK_nsmap_get_pfx (const char *ns);
 
 
 /** @brief Convert a namespace-prefixed string to a FQ URI sring if mapped.
@@ -101,11 +101,11 @@ LSUP_nsmap_get_pfx (const char *ns);
  *  result is not normalized and a TERM_NS_IRIREF should not be construed with
  *  it.
  *
- * @return LSUP_OK on success, LSUP_NORESULT if no entry was found in the map,
- *  LSUP_MEM_ERR if a memory allocation error ocurred.
+ * @return VOLK_OK on success, VOLK_NORESULT if no entry was found in the map,
+ *  VOLK_MEM_ERR if a memory allocation error ocurred.
  */
-LSUP_rc
-LSUP_nsmap_normalize_uri (const char *pfx_uri, char **fq_uri);
+VOLK_rc
+VOLK_nsmap_normalize_uri (const char *pfx_uri, char **fq_uri);
 
 
 /** @brief Convert a FQ URI string to a prefixed string if the prefix is found.
@@ -124,11 +124,11 @@ LSUP_nsmap_normalize_uri (const char *pfx_uri, char **fq_uri);
  *  that the result is not denormalized and a TERM_IRIREF should not be
  *  construed with it.
  *
- * @return LSUP_OK on success, LSUP_NORESULT if no entry was found in the map,
- *  LSUP_MEM_ERR if a memory allocation error ocurred.
+ * @return VOLK_OK on success, VOLK_NORESULT if no entry was found in the map,
+ *  VOLK_MEM_ERR if a memory allocation error ocurred.
  */
-LSUP_rc
-LSUP_nsmap_denormalize_uri (const char *fq_uri, char **pfx_uri);
+VOLK_rc
+VOLK_nsmap_denormalize_uri (const char *fq_uri, char **pfx_uri);
 
 
 /** @brief Dump all entries of the namespace map.
@@ -141,14 +141,14 @@ LSUP_nsmap_denormalize_uri (const char *fq_uri, char **pfx_uri);
  *  pointed to by the array are owned by the namespace map, but the individual
  *  pointers must be freed along with the parent array. E.g.:
  *
- *      const char ***nsm_data = LSUP_nsmap_dump (nsm);
+ *      const char ***nsm_data = VOLK_nsmap_dump (nsm);
  *      // [...]
  *      for (size_t i = 0; nsm_data[i] != NULL; i++)
  *          free (nsm_data[i]);
  *      free (nsm_data);
  */
 const char ***
-LSUP_nsmap_dump (void);
+VOLK_nsmap_dump (void);
 
 /// @}  END defgroup namespace
 #endif

+ 108 - 108
include/lsup/store.h → include/volksdata/store.h

@@ -10,14 +10,14 @@
  * well as entries in the `BACKEND_TBL` macro.
  */
 
-#ifndef _LSUP_STORE_H
-#define _LSUP_STORE_H
+#ifndef _VOLK_STORE_H
+#define _VOLK_STORE_H
 
 /*
  * Add new back end headers here.
  */
-#include "lsup/store_htable.h"
-#include "lsup/store_mdb.h"
+#include "volksdata/store_htable.h"
+#include "volksdata/store_mdb.h"
 
 /** @defgroup store Backend store module
  * @ingroup public
@@ -35,13 +35,13 @@
     ENTRY(  MDB,        mdbstore_int ) \
 
 
-/// Store types. All prefixed with `LSUP_STORE_`.
+/// Store types. All prefixed with `VOLK_STORE_`.
 typedef enum {
 #define ENTRY(a, b) \
-    LSUP_STORE_##a,
+    VOLK_STORE_##a,
 BACKEND_TBL
 #undef ENTRY
-} LSUP_StoreType;
+} VOLK_StoreType;
 
 
 /** @brief Store structure.
@@ -54,24 +54,24 @@ BACKEND_TBL
  * outside of this structure, but manipulated by the interface specified in
  * here.
  *
- * @sa #LSUP_graph_new()
+ * @sa #VOLK_graph_new()
  */
 typedef struct store_t {
-    LSUP_StoreType                  type;   ///< Store type.
+    VOLK_StoreType                  type;   ///< Store type.
     char *                          id;     /**< Store ID.
                                              *
                                              *   NOTE: This is
                                              *   NULL for volatile stores.
                                              */
-    const LSUP_StoreInt *           sif;    ///< Store interface.
+    const VOLK_StoreInt *           sif;    ///< Store interface.
     void *                          data;   ///< Store back end data.
-} LSUP_Store;
+} VOLK_Store;
 
 
 /** @brief Return store interface for a specific type.
  */
-const LSUP_StoreInt *
-LSUP_store_int (LSUP_StoreType type);
+const VOLK_StoreInt *
+VOLK_store_int (VOLK_StoreType type);
 
 
 /** @brief Return the store type label.
@@ -81,7 +81,7 @@ LSUP_store_int (LSUP_StoreType type);
  * @return Store type label as `STORE_<type>`.
  */
 const char *
-LSUP_store_type_label (LSUP_StoreType type);
+VOLK_store_type_label (VOLK_StoreType type);
 
 
 /** @brief Create a new store.
@@ -90,12 +90,12 @@ LSUP_store_type_label (LSUP_StoreType type);
  * graphs with the same back end, hence it is managed independently.
  *
  * @param[in] store_type Type of store backing the graph. One of the values of
- *  #LSUP_StoreType.
+ *  #VOLK_StoreType.
  *
  * @param[in] store_id Identifier for the store. This may be
  *  interpreted differently by each store implementation. For the MDB store,
  *  this is the file path where the store is located. It is ignored by volatile
- *  stores (with LSUP_STORE_PERM feature flag set to false). If a store
+ *  stores (with VOLK_STORE_PERM feature flag set to false). If a store
  *  does not exist for the given identifier, a new one is initialized. If this
  *  parameter is NULL, the default store for the selected type is used.
  *
@@ -106,34 +106,34 @@ LSUP_store_type_label (LSUP_StoreType type);
  *  @param clear Flag that is passed to the `init_fn` function of the store
  *   interface, if present, to clear an existing store with the same ID.
  *
- *  @return Store handle. It must be freed with #LSUP_store_free().
+ *  @return Store handle. It must be freed with #VOLK_store_free().
  */
-LSUP_Store *
-LSUP_store_new (
-        const LSUP_StoreType store_type, const char *store_id, size_t size,
+VOLK_Store *
+VOLK_store_new (
+        const VOLK_StoreType store_type, const char *store_id, size_t size,
         bool clear);
 
 
-/** @brief Free a store created with #LSUP_store_new().
+/** @brief Free a store created with #VOLK_store_new().
  *
  * @param[in] store Store handle.
  */
 void
-LSUP_store_free (LSUP_Store *store);
+VOLK_store_free (VOLK_Store *store);
 
 
 size_t
-LSUP_store_size (const LSUP_Store *store);
+VOLK_store_size (const VOLK_Store *store);
 
 
 /// Feature flags belonging to the store interface.
-const LSUP_StoreFeature
-LSUP_store_features (const LSUP_Store *store);
+const VOLK_StoreFeature
+VOLK_store_features (const VOLK_Store *store);
 
 
 /// Store identifier.
 char *
-LSUP_store_id (const LSUP_Store *store);
+VOLK_store_id (const VOLK_Store *store);
 
 
 /** @brief Begin a transaction.
@@ -141,8 +141,8 @@ LSUP_store_id (const LSUP_Store *store);
  * If the store supports it, begin a transaction. Only one transaction may be
  * opened at a time.
  *
- * The transaction must be either committed with #LSUP_store_commit() or
- * rolled back with #LSUP_store_abort().
+ * The transaction must be either committed with #VOLK_store_commit() or
+ * rolled back with #VOLK_store_abort().
  *
  * @param[in] store Store handle.
  *
@@ -150,29 +150,29 @@ LSUP_store_id (const LSUP_Store *store);
  *
  * @param[out] txn Address to be populated with the new transaction handle.
  *
- * @return LSUP_OK on success; LSUP_VALUE_ERR if the store does not
- *  support transactions; LSUP_TXN_ERR if the store has already an uncommitted
+ * @return VOLK_OK on success; VOLK_VALUE_ERR if the store does not
+ *  support transactions; VOLK_TXN_ERR if the store has already an uncommitted
  *  transaction; <0 on other errors.
  */
-LSUP_rc
-LSUP_store_begin (LSUP_Store *store, int flags, void **txn);
+VOLK_rc
+VOLK_store_begin (VOLK_Store *store, int flags, void **txn);
 
 
 /** @brief Commit a transaction.
  *
  * If the store supports it, commit an open transaction. In case of
  * error, the transaction is left open and it is advisable to roll it back with
- * #LSUP_store_abort().
+ * #VOLK_store_abort().
  *
  * @param[in] store Store handle.
  *
  * @param[in] txn transaction handle to commit.
  *
- * @return LSUP_OK if the transaction was committed successfully; LSUP_NOACTION
- *  if NULL was passed; LSUP_TXN_ERR on error.
+ * @return VOLK_OK if the transaction was committed successfully; VOLK_NOACTION
+ *  if NULL was passed; VOLK_TXN_ERR on error.
  */
-LSUP_rc
-LSUP_store_commit (LSUP_Store *store, void *txn);
+VOLK_rc
+VOLK_store_commit (VOLK_Store *store, void *txn);
 
 
 /** @brief Abort (roll back) a transaction.
@@ -184,7 +184,7 @@ LSUP_store_commit (LSUP_Store *store, void *txn);
  * @param[in] txn transaction handle to abort.
  */
 void
-LSUP_store_abort (LSUP_Store *store, void *txn);
+VOLK_store_abort (VOLK_Store *store, void *txn);
 
 
 /** @brief Update the context of triples in a context-aware store.
@@ -201,16 +201,16 @@ LSUP_store_abort (LSUP_Store *store, void *txn);
  *
  * @param[in] new_c New context handle.
  *
- * @return LSUP_OK on success; LSUP_NOACTION if no triples were found under the
+ * @return VOLK_OK on success; VOLK_NOACTION if no triples were found under the
  *  given context; <0 on error.
  */
-LSUP_rc
-LSUP_store_update_ctx_txn (
-        LSUP_Store *store, void *txn, const LSUP_Buffer *old_c,
-        const LSUP_Buffer *new_c);
+VOLK_rc
+VOLK_store_update_ctx_txn (
+        VOLK_Store *store, void *txn, const VOLK_Buffer *old_c,
+        const VOLK_Buffer *new_c);
 
-#define LSUP_store_update_ctx(store, ...) \
-    LSUP_store_update_txn (store, NULL, __VA_ARGS__)
+#define VOLK_store_update_ctx(store, ...) \
+    VOLK_store_update_txn (store, NULL, __VA_ARGS__)
 
 
 /** @brief Initialize bulk triple load.
@@ -228,17 +228,17 @@ LSUP_store_update_ctx_txn (
  *  default context is not NULL, triples will be added to the default context
  *  for the store, If the default context for the store is NULL, regardless of
  *  the value of sc, triples will be added with no context. Only meaningful
- *  for stores with the LSUP_STORE_CTX feature.
+ *  for stores with the VOLK_STORE_CTX feature.
  *
  * @return Iterator handle to be passed to the following load steps.
  */
 void *
-LSUP_store_add_init_txn (
-        LSUP_Store *store, void *txn, const LSUP_Buffer *sc);
+VOLK_store_add_init_txn (
+        VOLK_Store *store, void *txn, const VOLK_Buffer *sc);
 
-/// Non-transactional version of #LSUP_store_add_init_txn().
-#define LSUP_store_add_init(store, ...) \
-    LSUP_store_add_init_txn (store, NULL, __VA_ARGS__)
+/// Non-transactional version of #VOLK_store_add_init_txn().
+#define VOLK_store_add_init(store, ...) \
+    VOLK_store_add_init_txn (store, NULL, __VA_ARGS__)
 
 
 /** @brief Add one triple into the store.
@@ -249,16 +249,16 @@ LSUP_store_add_init_txn (
  *
  * @param[in] store Store handle.
  *
- * @param[in] it Iterator obtained by #LSUP_store_add_init().
+ * @param[in] it Iterator obtained by #VOLK_store_add_init().
  *
  * @param[in] sspo Serialized triple to be added.
  *
- * @return LSUP_OK if the triple was inserted; LSUP_NOACTION if the triple
- *  already existed; LSUP_DB_ERR if an MDB error occurred.
+ * @return VOLK_OK if the triple was inserted; VOLK_NOACTION if the triple
+ *  already existed; VOLK_DB_ERR if an MDB error occurred.
  */
-LSUP_rc
-LSUP_store_add_iter (
-        LSUP_Store *store, void *it, const LSUP_BufferTriple *sspo);
+VOLK_rc
+VOLK_store_add_iter (
+        VOLK_Store *store, void *it, const VOLK_BufferTriple *sspo);
 
 
 /** @brief Abort an add loop and free iterator.
@@ -271,7 +271,7 @@ LSUP_store_add_iter (
  * @param[in] it Iterator obtained by #store_add_init_fn_t.
  */
 void
-LSUP_store_add_abort (LSUP_Store *store, void *it);
+VOLK_store_add_abort (VOLK_Store *store, void *it);
 
 
 /** @brief Finalize an add loop and free iterator.
@@ -280,13 +280,13 @@ LSUP_store_add_abort (LSUP_Store *store, void *it);
  *
  * @param[in] store Store handle.
  *
- * @param[in] it Iterator obtained by #LSUP_store_add_init().
+ * @param[in] it Iterator obtained by #VOLK_store_add_init().
  *
- * @return LSUP_OK on success, <0 on failure. In the latter case, a transaction
+ * @return VOLK_OK on success, <0 on failure. In the latter case, a transaction
  *  may be aborted in a transactional back end.
  */
-LSUP_rc
-LSUP_store_add_done (LSUP_Store *store, void *it);
+VOLK_rc
+VOLK_store_add_done (VOLK_Store *store, void *it);
 
 
 /** @brief Add a single term to the store.
@@ -298,12 +298,12 @@ LSUP_store_add_done (LSUP_Store *store, void *it);
  *
  * @param[in] sterm Serialized term to store.
  */
-LSUP_rc
-LSUP_store_add_term_txn (LSUP_Store *store, void *txn, LSUP_Buffer *sterm);
+VOLK_rc
+VOLK_store_add_term_txn (VOLK_Store *store, void *txn, VOLK_Buffer *sterm);
 
-/// Non-transactional version of #LSUP_store_add_term_txn().
-#define LSUP_store_add_term(store, ...) \
-    LSUP_store_add_term_txn (store, NULL, __VA_ARGS__)
+/// Non-transactional version of #VOLK_store_add_term_txn().
+#define VOLK_store_add_term(store, ...) \
+    VOLK_store_add_term_txn (store, NULL, __VA_ARGS__)
 
 
 /** @brief Look up triples by pattern matching.
@@ -311,7 +311,7 @@ LSUP_store_add_term_txn (LSUP_Store *store, void *txn, LSUP_Buffer *sterm);
  * This function may return a count of matches and/or an iterator of results as
  * serialized triples.
  *
- * For stores with #LSUP_STORE_TXN, this opens a read-only transaction. The
+ * For stores with #VOLK_STORE_TXN, this opens a read-only transaction. The
  * transaction handle is held in the iterator structure and is closed when the
  * iterator is freed with #iter_free_fn_t().
  *
@@ -344,14 +344,14 @@ LSUP_store_add_term_txn (LSUP_Store *store, void *txn, LSUP_Buffer *sterm);
  * the first result which can be retrieved with #iter_next_fn_t.
  */
 void *
-LSUP_store_lookup_txn (
-        const LSUP_Store *store, void *txn,
-        const LSUP_Buffer *ss, const LSUP_Buffer *sp, const LSUP_Buffer *so,
-        const LSUP_Buffer *sc, size_t *ct);
+VOLK_store_lookup_txn (
+        const VOLK_Store *store, void *txn,
+        const VOLK_Buffer *ss, const VOLK_Buffer *sp, const VOLK_Buffer *so,
+        const VOLK_Buffer *sc, size_t *ct);
 
-/// Non-transactional version of #LSUP_store_lookup_txn().
-#define LSUP_store_lookup(store, ...) \
-    LSUP_store_lookup_txn (store, NULL, __VA_ARGS__)
+/// Non-transactional version of #VOLK_store_lookup_txn().
+#define VOLK_store_lookup(store, ...) \
+    VOLK_store_lookup_txn (store, NULL, __VA_ARGS__)
 
 
 /** @brief Yield the matching triples and advance the iterator.
@@ -359,28 +359,28 @@ LSUP_store_lookup_txn (
  * @note Iterators keep transactions open. Don't hold on to them longer than
  * necessary.
  *
- * @note If the store interface has the LSUP_STORE_COW feature, the memory
- * buffer referenced by the #LSUP_Buffer handle is owned by the database. It
+ * @note If the store interface has the VOLK_STORE_COW feature, the memory
+ * buffer referenced by the #VOLK_Buffer handle is owned by the database. It
  * must not be written to or freed. To modify the data or use them beyond the
- * caller's scope, this memory must be copied. Note that the #LSUP_Buffer
+ * caller's scope, this memory must be copied. Note that the #VOLK_Buffer
  * handle must still be freed (with a plain `free()`), but not the underlying
  * data buffer, since only the latter is owned by the back end. Implementations
- * with the `LSUP_STORE_COW` feature SHOULD create buffers with the
- * `LSUP_BUF_BORROWED` flag, so that they can be safely freed with
- * #LSUP_buffer_free() and #LSUP_btriple_free().
+ * with the `VOLK_STORE_COW` feature SHOULD create buffers with the
+ * `VOLK_BUF_BORROWED` flag, so that they can be safely freed with
+ * #VOLK_buffer_free() and #VOLK_btriple_free().
  *
  * @param[in] store Store handle.
  *
  * @param[in] it Opaque iterator handle obtained with #store_lookup_fn_t.
  *
- * @param[out] sspo #LSUP_BufferTriple to be populated with three serialized
+ * @param[out] sspo #VOLK_BufferTriple to be populated with three serialized
  * terms if found. It may be NULL, in which case it is not populated.
  *
  * @param[out] ctx If not NULL, it is populated with a NULL-terminated array of
- *  LSUP_Buffer structs, one for each context associated with the matching
+ *  VOLK_Buffer structs, one for each context associated with the matching
  *  triple. These contexts are the same regardless of the context filter used
  *  in the lookup. The array is freed with a simple `free()`. This parameter
- *  is ignored by implementations without the LSUP_STORE_CTX feature.
+ *  is ignored by implementations without the VOLK_STORE_CTX feature.
  *
  *  To iterate over the context array, use this loop:
  *
@@ -388,13 +388,13 @@ LSUP_store_lookup_txn (
  *      while (ctx[i].addr)
  *          do_something(ctx + (i++));
  *
- * @return LSUP_OK if results were found; LSUP_END if no (more) results were
- * found; LSUP_DB_ERR if a backend error occurred.
+ * @return VOLK_OK if results were found; VOLK_END if no (more) results were
+ * found; VOLK_DB_ERR if a backend error occurred.
  */
-LSUP_rc
-LSUP_store_iter_next (
-        LSUP_Store *store, void *it, LSUP_BufferTriple *sspo,
-        LSUP_Buffer **ctx);
+VOLK_rc
+VOLK_store_iter_next (
+        VOLK_Store *store, void *it, VOLK_BufferTriple *sspo,
+        VOLK_Buffer **ctx);
 
 
 /** @brief Free an iterator allocated by a lookup.
@@ -404,7 +404,7 @@ LSUP_store_iter_next (
  * @param[in] it Iterator pointer. It will be set to NULL after freeing.
  */
 void
-LSUP_store_iter_free (LSUP_Store *store, void *it);
+VOLK_store_iter_free (VOLK_Store *store, void *it);
 
 
 /** @brief Get iterator active transaction handle.
@@ -422,7 +422,7 @@ LSUP_store_iter_free (LSUP_Store *store, void *it);
  * @return Transaction handle. DO NOT close this transaction directly.
  */
 void *
-LSUP_store_iter_txn (const LSUP_Store *store, void *it);
+VOLK_store_iter_txn (const VOLK_Store *store, void *it);
 
 
 /** @brief Delete triples by pattern matching.
@@ -445,24 +445,24 @@ LSUP_store_iter_txn (const LSUP_Store *store, void *it);
  * @param[out] ct If not NULL, this will be populated with the number of
  *  triples actually deleted.
  *
- * @return LSUP_OK on success; LSUP_NOACTION if no triples were deleted;
+ * @return VOLK_OK on success; VOLK_NOACTION if no triples were deleted;
  *  <0 on error.
  *
  */
-LSUP_rc
-LSUP_store_remove_txn (
-        LSUP_Store *store, void *txn,
-        const LSUP_Buffer *ss, const LSUP_Buffer *sp, const LSUP_Buffer *so,
-        const LSUP_Buffer *sc, size_t *ct);
+VOLK_rc
+VOLK_store_remove_txn (
+        VOLK_Store *store, void *txn,
+        const VOLK_Buffer *ss, const VOLK_Buffer *sp, const VOLK_Buffer *so,
+        const VOLK_Buffer *sc, size_t *ct);
 
-/// Non-transactional version of #LSUP_store_remove_txn().
-#define LSUP_store_remove(store, ...) \
-    LSUP_store_remove_txn (store, NULL, __VA_ARGS__)
+/// Non-transactional version of #VOLK_store_remove_txn().
+#define VOLK_store_remove(store, ...) \
+    VOLK_store_remove_txn (store, NULL, __VA_ARGS__)
 
 
 /** @brief get index of all graph (context) URIs in a store.
  *
- * Only applicable to stores with the LSUP_STORE_CTX feature flag.
+ * Only applicable to stores with the VOLK_STORE_CTX feature flag.
  *
  * @param[in] store Store handle.
  *
@@ -471,13 +471,13 @@ LSUP_store_remove_txn (
  *
  * @return Set of all context URIs.
  */
-LSUP_Buffer **
-LSUP_store_ctx_list_txn (LSUP_Store *store, void *txn);
+VOLK_Buffer **
+VOLK_store_ctx_list_txn (VOLK_Store *store, void *txn);
 
-/// Non-transactional version of #LSUP_store_ctx_list_txn().
-#define LSUP_store_ctx_list(store) \
-    LSUP_store_ctx_list_txn (store, NULL)
+/// Non-transactional version of #VOLK_store_ctx_list_txn().
+#define VOLK_store_ctx_list(store) \
+    VOLK_store_ctx_list_txn (store, NULL)
 
 
 /// @}  END store
-#endif  /* LSUP_STORE_H */
+#endif  /* VOLK_STORE_H */

+ 6 - 6
include/lsup/store_htable.h → include/volksdata/store_htable.h

@@ -17,13 +17,13 @@
  * graph and outputting some results on a file) an ad-hoc MDB store located in
  * RAM disk can be used, which is much faster.
  */
-#ifndef _LSUP_STORE_HTABLE_H
-#define _LSUP_STORE_HTABLE_H
+#ifndef _VOLK_STORE_HTABLE_H
+#define _VOLK_STORE_HTABLE_H
 
-#include "lsup/buffer.h"
-#include "lsup/store_interface.h"
+#include "volksdata/buffer.h"
+#include "volksdata/store_interface.h"
 
 
-extern const LSUP_StoreInt htstore_int;
+extern const VOLK_StoreInt htstore_int;
 
-#endif  // _LSUP_STORE_HTABLE_H
+#endif  // _VOLK_STORE_HTABLE_H

+ 66 - 66
include/lsup/store_interface.h → include/volksdata/store_interface.h

@@ -18,24 +18,24 @@
  *
  * - A structure representing a store iterator state, also opaque.
  *
- * - The LSUP_StoreInt interface with all the functions defined in the
+ * - The VOLK_StoreInt interface with all the functions defined in the
  *   interface necessary to interact with the store.
  *
  * See the `store_htable.{c,h}` and `store_mdb.{c,h}` files for examples of
  * fully functioning implementations.
  *
- * The #LSUP_StoreInt structure defines a store interface for raw buffer
+ * The #VOLK_StoreInt structure defines a store interface for raw buffer
  * triples. Nothing in the store functions' signatures should hint at RDF
  * triples—they should accept and produce exclusively raw byte buffers
- * (#LSUP_Buffer). A store interface may have any of the `LSUP_STORE_*` faeture
+ * (#VOLK_Buffer). A store interface may have any of the `VOLK_STORE_*` faeture
  * flags which should be reflected in the way its members are implemented.
  */
 
 
-#ifndef _LSUP_STORE_INTERFACE_H
-#define _LSUP_STORE_INTERFACE_H
+#ifndef _VOLK_STORE_INTERFACE_H
+#define _VOLK_STORE_INTERFACE_H
 
-#include "lsup/environment.h"
+#include "volksdata/environment.h"
 
 
 /** @defgroup store_interface Store interface module
@@ -46,19 +46,19 @@
 /*
  * Store feature flags.
  *
- * NOTE: LSUP_STORE_PERM need only be set by an implementation based on whether
+ * NOTE: VOLK_STORE_PERM need only be set by an implementation based on whether
  * the data may be cleared before the perogram ends.  It is the client's
  * responsibility to guarantee permanence beyond the lifespan of the program. A
- * store featuring LSUP_STORE_PERM MUST guarantee that the data remain
+ * store featuring VOLK_STORE_PERM MUST guarantee that the data remain
  * available on storage for the user to further handle them.
  */
 typedef enum {
-    LSUP_STORE_PERM     = 1<<0,   ///< Store is on a permanent support.
-    LSUP_STORE_CTX      = 1<<1,   ///< Store supports contexts (quads).
-    LSUP_STORE_IDX      = 1<<2,   ///< Store is fully SPO(C)-indexed.
-    LSUP_STORE_TXN      = 1<<3,   ///< Supports transaction handling.
-    LSUP_STORE_COW      = 1<<4,   ///< Copy on write. @sa #iter_next_fn_t()
-} LSUP_StoreFeature;
+    VOLK_STORE_PERM     = 1<<0,   ///< Store is on a permanent support.
+    VOLK_STORE_CTX      = 1<<1,   ///< Store supports contexts (quads).
+    VOLK_STORE_IDX      = 1<<2,   ///< Store is fully SPO(C)-indexed.
+    VOLK_STORE_TXN      = 1<<3,   ///< Supports transaction handling.
+    VOLK_STORE_COW      = 1<<4,   ///< Copy on write. @sa #iter_next_fn_t()
+} VOLK_StoreFeature;
 
 
 /*
@@ -67,7 +67,7 @@ typedef enum {
 
 /** @brief Prototype: create any environment necessary for the store to work.
  *
- * #LSUP_store_new() calls this function before creating the store handle.
+ * #VOLK_store_new() calls this function before creating the store handle.
  *
  * This function should be idempotent on separate calls to the same `id`,
  * unless the `clear` option is set to `true`.
@@ -81,7 +81,7 @@ typedef enum {
  *
  * @param[in] clear Whether to remove an existing environment with the same ID.
  */
-typedef LSUP_rc (*store_setup_fn_t)(const char *id, bool clear);
+typedef VOLK_rc (*store_setup_fn_t)(const char *id, bool clear);
 
 
 /** @brief Prototype: create a new store.
@@ -131,13 +131,13 @@ typedef char * (*store_id_fn_t)(const void *store);
  *
  * @param[in] store The store to get stats for.
  */
-typedef LSUP_rc (*store_stat_fn_t)(void *store, void *stat);
+typedef VOLK_rc (*store_stat_fn_t)(void *store, void *stat);
 #endif
 
 
 /** @brief Begin a transaction.
  *
- * Only for LSUP_STORE_TXN stores.
+ * Only for VOLK_STORE_TXN stores.
  *
  * The transaction handle is managed by the store implementation and can be any
  * data type.
@@ -149,25 +149,25 @@ typedef LSUP_rc (*store_stat_fn_t)(void *store, void *stat);
  * @param[out] txn Will point to the new open transaction on success, or to
  * undefined content on failure.
  *
- * @return LSUP_OK if the transaction started successfully, <0 on error.
+ * @return VOLK_OK if the transaction started successfully, <0 on error.
  */
-typedef LSUP_rc (*store_txn_begin_fn_t)(void *store, int flags, void **txn);
+typedef VOLK_rc (*store_txn_begin_fn_t)(void *store, int flags, void **txn);
 
 
 /** @brief Commit a transaction.
  *
- * Only for LSUP_STORE_TXN stores.
+ * Only for VOLK_STORE_TXN stores.
  *
  * @param[in] txn Transaction handle initialized by #store_txn_begin_fn_t().
  *
- * @return LSUP_OK if the transaction was committed successfully, <0 on error.
+ * @return VOLK_OK if the transaction was committed successfully, <0 on error.
  */
-typedef LSUP_rc (*store_txn_commit_fn_t)(void *txn);
+typedef VOLK_rc (*store_txn_commit_fn_t)(void *txn);
 
 
 /** @brief Abort a transaction.
  *
- * Only for LSUP_STORE_TXN stores.
+ * Only for VOLK_STORE_TXN stores.
  *
  * @param[in] txn Transaction handle initialized by #store_txn_begin_fn_t().
  */
@@ -176,53 +176,53 @@ typedef void (*store_txn_abort_fn_t)(void *txn);
 
 /** @brief Update the context of triples in a context-aware store.
  *
- * Only defined in stores with the LSUP_STORE_CTX feature.
+ * Only defined in stores with the VOLK_STORE_CTX feature.
  *
- * @sa #LSUP_store_update_ctx_txn()
+ * @sa #VOLK_store_update_ctx_txn()
  */
-typedef LSUP_rc (*store_update_ctx_fn_t)(
-        void *store, const LSUP_Buffer *old_c, const LSUP_Buffer *new_c,
+typedef VOLK_rc (*store_update_ctx_fn_t)(
+        void *store, const VOLK_Buffer *old_c, const VOLK_Buffer *new_c,
         void *udata);
 
 
 /** @brief Initialize bulk triple load.
  *
- * @sa #LSUP_store_add_init_txn()
+ * @sa #VOLK_store_add_init_txn()
  */
 typedef void * (*store_add_init_fn_t)(
-        void *store, const LSUP_Buffer *sc, void *udata);
+        void *store, const VOLK_Buffer *sc, void *udata);
 
 
 /** @brief Add one triple into the store.
  *
- * @sa LSUP_store_add_iter().
+ * @sa VOLK_store_add_iter().
  */
-typedef LSUP_rc (*store_add_iter_fn_t)(
-        void *it, const LSUP_BufferTriple * sspo);
+typedef VOLK_rc (*store_add_iter_fn_t)(
+        void *it, const VOLK_BufferTriple * sspo);
 
 
 /** @brief Abort an add loop and free iterator.
  *
- * Only available for stores with the LSUP_STORE_CTX feature.
+ * Only available for stores with the VOLK_STORE_CTX feature.
  *
- * @sa LSUP_store_add_abort().
+ * @sa VOLK_store_add_abort().
  */
 typedef void (*store_add_abort_fn_t)(void *it);
 
 
 /** @brief Finalize an add loop and free iterator.
  *
- * @sa #LSUP_store_add_done().
+ * @sa #VOLK_store_add_done().
  */
-typedef LSUP_rc (*store_add_done_fn_t)(void *it);
+typedef VOLK_rc (*store_add_done_fn_t)(void *it);
 
 
 /** @brief Add a single term to the store.
  *
- * @sa #LSUP_store_add_term_txn().
+ * @sa #VOLK_store_add_term_txn().
  */
-typedef LSUP_rc (*store_add_term_fn_t)(
-        void *store, const LSUP_Buffer *sterm, void *udata);
+typedef VOLK_rc (*store_add_term_fn_t)(
+        void *store, const VOLK_Buffer *sterm, void *udata);
 
 
 /*
@@ -231,12 +231,12 @@ typedef LSUP_rc (*store_add_term_fn_t)(
 
 /** @brief Prototype: look up triples by pattern matching.
  *
- * @sa #LSUP_store_lookup_txn().
+ * @sa #VOLK_store_lookup_txn().
  */
 typedef void * (*store_lookup_fn_t)(
         void *store,
-        const LSUP_Buffer *ss, const LSUP_Buffer *sp, const LSUP_Buffer *so,
-        const LSUP_Buffer *sc, void *udata, size_t *ct);
+        const VOLK_Buffer *ss, const VOLK_Buffer *sp, const VOLK_Buffer *so,
+        const VOLK_Buffer *sc, void *udata, size_t *ct);
 
 
 /** @brief Prototype: check for existence of a triple (T/F).
@@ -248,51 +248,51 @@ typedef void * (*store_lookup_fn_t)(
  * @param[in] sspo Triple to look up. All members must not be NULL.
  *
  * @param[in] sc Optional context to look into. It may be NULL. It is
- *  disregarded by stores without the LSUP_STORE_CTX feature.
+ *  disregarded by stores without the VOLK_STORE_CTX feature.
  *
  * @return Whether the triple exist in the store (/context).
  */
 typedef bool (*store_trp_exist_fn_t)(
-        void *store, const LSUP_BufferTriple *sspo, const LSUP_Buffer *sc);
+        void *store, const VOLK_BufferTriple *sspo, const VOLK_Buffer *sc);
 
 
 /** @brief Prototype: yield the matching triples and advance the iterator.
  *
- * @sa LSUP_store_iter_next().
+ * @sa VOLK_store_iter_next().
  */
-typedef LSUP_rc (*iter_next_fn_t)(
-        void *it, LSUP_BufferTriple *sspo, LSUP_Buffer **ctx);
+typedef VOLK_rc (*iter_next_fn_t)(
+        void *it, VOLK_BufferTriple *sspo, VOLK_Buffer **ctx);
 
 
 /** @brief Prototype: free an iterator allocated by a lookup.
  *
- * @sa #LSUP_store_iter_free().
+ * @sa #VOLK_store_iter_free().
  */
 typedef void (*iter_free_fn_t)(void * it);
 
 
 /** @brief Prototype: get iterator active transaction handle.
  *
- * @sa #LSUP_store_iter_txn().
+ * @sa #VOLK_store_iter_txn().
  */
 typedef void * (*iter_txn_fn_t)(void *it);
 
 
 /** @brief Prototype: delete triples by pattern matching.
  *
- * @sa #LSUP_store_remove_txn().
+ * @sa #VOLK_store_remove_txn().
  */
-typedef LSUP_rc (*store_remove_fn_t)(
+typedef VOLK_rc (*store_remove_fn_t)(
         void *store,
-        const LSUP_Buffer *ss, const LSUP_Buffer *sp, const LSUP_Buffer *so,
-        const LSUP_Buffer *sc, void *udata, size_t *ct);
+        const VOLK_Buffer *ss, const VOLK_Buffer *sp, const VOLK_Buffer *so,
+        const VOLK_Buffer *sc, void *udata, size_t *ct);
 
 
 /** @brief Prototype: Get index of all graph (context) URIs in a store.
  *
- * @sa #LSUP_store_ctx_list_txn()
+ * @sa #VOLK_store_ctx_list_txn()
  */
-typedef LSUP_Buffer ** (*store_ctx_list_fn_t)(void *store, void *txn);
+typedef VOLK_Buffer ** (*store_ctx_list_fn_t)(void *store, void *txn);
 
 
 
@@ -312,12 +312,12 @@ typedef LSUP_Buffer ** (*store_ctx_list_fn_t)(void *store, void *txn);
  * interaction with the store.
  *
  * Transaction control members are only applicable to stores with the
- * #LSUP_STORE_TXN feature.
+ * #VOLK_STORE_TXN feature.
  */
 typedef struct store_if_t {
     // Basic properties.
     char                name[16];       ///< Store type name.
-    LSUP_StoreFeature   features;       ///< Feature flags.
+    VOLK_StoreFeature   features;       ///< Feature flags.
 
     // Allocation, setup and deallocation.
     store_setup_fn_t    setup_fn;       ///< Called before #store_new_fn_t.
@@ -337,7 +337,7 @@ typedef struct store_if_t {
     store_update_ctx_fn_t update_ctx_fn; ///< Update context URI.
                                          ///<
                                          ///< Only available in stores with
-                                         ///< #LSUP_STORE_CTX feature. Optional.
+                                         ///< #VOLK_STORE_CTX feature. Optional.
 
     // Addition.
     store_add_init_fn_t add_init_fn;    ///< Initialize add iteration.
@@ -345,13 +345,13 @@ typedef struct store_if_t {
     store_add_abort_fn_t add_abort_fn;  ///< Abort (roll back) the add process.
                                         ///<
                                         ///< Only available in
-                                        ///< stores with #LSUP_STORE_TXN
+                                        ///< stores with #VOLK_STORE_TXN
                                         ///< feature. Optional.
     store_add_done_fn_t add_done_fn;    ///< Complete the add process.
     store_add_term_fn_t add_term_fn;    ///< Add (index) a term to the store.
                                         ///<
                                         ///< Only available in stores with
-                                        ///< #LSUP_STORE_IDX feature. Optional.
+                                        ///< #VOLK_STORE_IDX feature. Optional.
 
     // Look up.
     store_lookup_fn_t   lookup_fn;      ///< Look up triples by pattern. 
@@ -367,8 +367,8 @@ typedef struct store_if_t {
     store_ctx_list_fn_t ctx_list_fn;    ///< Get all context URIs in a store.
                                         ///<
                                         ///< Only applicable to stores with
-                                        ///< LSUP_STORE_CTX feature.
-} LSUP_StoreInt;
+                                        ///< VOLK_STORE_CTX feature.
+} VOLK_StoreInt;
 
 
 /*
@@ -376,9 +376,9 @@ typedef struct store_if_t {
  * These should be placed in the .c file where the interface functions are
  * defined, and declared as `extern` in the related .h file.
 
-const LSUP_StoreInt my_store_int = {
+const VOLK_StoreInt my_store_int = {
     .name           = "My Store", // Truncated to 15 chars.
-    .features       = LSUP_STORE_PERM | LSUP_STORE_IDX,
+    .features       = VOLK_STORE_PERM | VOLK_STORE_IDX,
 
     .setup_fn       = my_setup_fn,
     .new_fn         = my_new_fn,
@@ -411,4 +411,4 @@ const LSUP_StoreInt my_store_int = {
 */
 
 /// @}  END defgroup store_interface
-#endif  /* _LSUP_STORE_INTERFACE_H */
+#endif  /* _VOLK_STORE_INTERFACE_H */

+ 7 - 7
include/lsup/store_mdb.h → include/volksdata/store_mdb.h

@@ -27,20 +27,20 @@
  */
 
 
-#ifndef _LSUP_STORE_MDB_H
-#define _LSUP_STORE_MDB_H
+#ifndef _VOLK_STORE_MDB_H
+#define _VOLK_STORE_MDB_H
 
 #include "lmdb.h"
 
-#include "lsup/buffer.h"
-#include "lsup/store_interface.h"
+#include "volksdata/buffer.h"
+#include "volksdata/store_interface.h"
 
 
 // FIXME find a better cross-platform path.
 /// Default MDB store identifier and location.
-#define LSUP_MDB_STORE_URN "file://" TMPDIR "/mdb_store"
+#define VOLK_MDB_STORE_URN "file://" TMPDIR "/mdb_store"
 
 /// MDB store interface.
-extern const LSUP_StoreInt mdbstore_int;
+extern const VOLK_StoreInt mdbstore_int;
 
-#endif  /* _LSUP_STORE_MDB_H */
+#endif  /* _VOLK_STORE_MDB_H */

+ 158 - 158
include/lsup/term.h → include/volksdata/term.h

@@ -1,10 +1,10 @@
-#ifndef _LSUP_TERM_H
-#define _LSUP_TERM_H
+#ifndef _VOLK_TERM_H
+#define _VOLK_TERM_H
 
 //#include <assert.h>
 
-#include "lsup/buffer.h"
-#include "lsup/namespace.h"
+#include "volksdata/buffer.h"
+#include "volksdata/namespace.h"
 
 /** @defgroup term RDF term and triple module
  * @ingroup public
@@ -14,8 +14,8 @@
 #define UUID4_URN_SIZE UUIDSTR_SIZE + 10
 
 // Some common RDF term values.
-#define LSUP_RDF_TYPE       "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
-#define LSUP_RDF_TYPE_NS    "rdf:type"
+#define VOLK_RDF_TYPE       "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
+#define VOLK_RDF_TYPE_NS    "rdf:type"
 /// Default data type for untyped literals (prefixed IRI).
 #define DEFAULT_DTYPE       "http://www.w3.org/2001/XMLSchema#string"
 #define DEFAULT_DTYPE_NS    "xsd:string"
@@ -26,94 +26,94 @@
  */
 
 /// Language tag, currently restricted to 7 characters.
-typedef char LSUP_LangTag[8];
+typedef char VOLK_LangTag[8];
 
 /// Term type.
 typedef enum {
-    LSUP_TERM_UNDEFINED = 0,///< Undefined placeholder or result of an error.
+    VOLK_TERM_UNDEFINED = 0,///< Undefined placeholder or result of an error.
                             ///<
                             ///< Invalid for most operations.
-    LSUP_TERM_IRIREF,       ///< IRI reference.
-    LSUP_TERM_LITERAL,      ///< Literal without language tag.
-    LSUP_TERM_LT_LITERAL,   ///< Language-tagged string literal.
-    LSUP_TERM_BNODE,        ///< Blank node.
-} LSUP_TermType;
+    VOLK_TERM_IRIREF,       ///< IRI reference.
+    VOLK_TERM_LITERAL,      ///< Literal without language tag.
+    VOLK_TERM_LT_LITERAL,   ///< Language-tagged string literal.
+    VOLK_TERM_BNODE,        ///< Blank node.
+} VOLK_TermType;
 
 /// Opaque IRI information.
-typedef struct iri_info_t LSUP_IRIInfo;
+typedef struct iri_info_t VOLK_IRIInfo;
 
 /// Opaque iterator for link maps.
-typedef struct link_map_iter LSUP_LinkMapIterator;
+typedef struct link_map_iter VOLK_LinkMapIterator;
 
 /// RDF term.
 typedef struct term_t {
     char *              data;       ///< URI, literal value, or BNode label.
     union {
-        struct term_t * datatype;   ///< Data type IRI for LSUP_TERM_LITERAL.
-        LSUP_LangTag    lang;       ///< Lang tag for LSUP_TERM_LT_LITERAL.
-        LSUP_Key        bnode_id;   ///< BNode ID for comparison & skolemization.
-        LSUP_IRIInfo *  iri_info;   ///< IRI information structure.
+        struct term_t * datatype;   ///< Data type IRI for VOLK_TERM_LITERAL.
+        VOLK_LangTag    lang;       ///< Lang tag for VOLK_TERM_LT_LITERAL.
+        VOLK_Key        bnode_id;   ///< BNode ID for comparison & skolemization.
+        VOLK_IRIInfo *  iri_info;   ///< IRI information structure.
     };
-    LSUP_TermType       type;       ///< Term type.
-} LSUP_Term;
+    VOLK_TermType       type;       ///< Term type.
+} VOLK_Term;
 
 
 /** @brief Shorthand to test if a term is a literal of any kind.
  */
-#define LSUP_IS_LITERAL(term) \
-    ((term)->type == LSUP_TERM_LITERAL || (term)->type == LSUP_TERM_LT_LITERAL)
+#define VOLK_IS_LITERAL(term) \
+    ((term)->type == VOLK_TERM_LITERAL || (term)->type == VOLK_TERM_LT_LITERAL)
 
 
 /** @brief Whether the environment is already initialized.
  */
-#define LSUP_IS_INIT (LSUP_default_datatype != NULL)
+#define VOLK_IS_INIT (VOLK_default_datatype != NULL)
 
 
 /** @brief RDF triple.
  *
  * This represents a complete RDF statement. Triple terms can be accessed
  * directly via the `s`, `p`, `o` members or sequentially via
- * #LSUP_triple_pos().
+ * #VOLK_triple_pos().
  */
 typedef struct triple_t {
-    LSUP_Term *s;                   ///< Subject.
-    LSUP_Term *p;                   ///< Predicate.
-    LSUP_Term *o;                   ///< Object.
-} LSUP_Triple;
+    VOLK_Term *s;                   ///< Subject.
+    VOLK_Term *p;                   ///< Predicate.
+    VOLK_Term *o;                   ///< Object.
+} VOLK_Triple;
 
 
 /// Link type.
 typedef enum {
-    LSUP_LINK_INBOUND,              ///< Inbound link (sp).
-    LSUP_LINK_OUTBOUND,             ///< Outbound link (po).
-    LSUP_LINK_EDGE,                 ///< Edge link (so).
-} LSUP_LinkType;
+    VOLK_LINK_INBOUND,              ///< Inbound link (sp).
+    VOLK_LINK_OUTBOUND,             ///< Outbound link (po).
+    VOLK_LINK_EDGE,                 ///< Edge link (so).
+} VOLK_LinkType;
 
 
 /** @brief The immediate neighborhood of terms connected to a term.
  *
  * This is a hash map whose each term is related to a set of one or more other
  * terms. The hash map is inside an opaque handle and is manipulated via the
- * `LSUP_link_map_*` functions.
+ * `VOLK_link_map_*` functions.
  *
- * If the type of the link map is `LSUP_LINK_INBOUND`, the map keys
+ * If the type of the link map is `VOLK_LINK_INBOUND`, the map keys
  * represent predicates and the sets related to them are the objects, and the
  * term associated to the link map is the object.
  *
- * If the type is `LSUP_LINK_OUTBOUND`, the keys represent predicates, the
+ * If the type is `VOLK_LINK_OUTBOUND`, the keys represent predicates, the
  * related sets objects, and the associated term is the subject.
  *
- * If the type is `LSUP_LINK_EDGE`, the keys represent subjects and the related
+ * If the type is `VOLK_LINK_EDGE`, the keys represent subjects and the related
  * sets objects, and the associated term is the predicate.
  */
-typedef struct link_map LSUP_LinkMap;
+typedef struct link_map VOLK_LinkMap;
 
 
 /** @brief a set of unique terms.
  *
  * This is used to bulk-add terms to a link map.
  */
-typedef struct hashmap LSUP_TermSet;
+typedef struct hashmap VOLK_TermSet;
 
 
 /*
@@ -122,20 +122,20 @@ typedef struct hashmap LSUP_TermSet;
 
 /** @brief Compiled hash of default literal data type.
  */
-extern uint32_t LSUP_default_dtype_key;
+extern uint32_t VOLK_default_dtype_key;
 
 /** @brief Default literal data type URI.
  *
  * Literal terms created with undefined data type will have it set to this
  * URI implicitly.
  */
-extern LSUP_Term *LSUP_default_datatype;
+extern VOLK_Term *VOLK_default_datatype;
 
 /** @brief Global term cache.
  *
  * Stores frequently used terms, e.g. data type URIs.
  */
-extern LSUP_TermSet *LSUP_term_cache;
+extern VOLK_TermSet *VOLK_term_cache;
 
 
 /*
@@ -145,58 +145,58 @@ extern LSUP_TermSet *LSUP_term_cache;
 /** @brief Create a new term.
  *
  * This is a generic function; it is recommended to use specialized functions
- * such as #LSUP_iriref_new(), #LSUP_literal_new(), etc. as they have strict
+ * such as #VOLK_iriref_new(), #VOLK_literal_new(), etc. as they have strict
  * type checks for the metadata parameter.
  *
- * @param[in] type Term type. One of #LSUP_TermType.
+ * @param[in] type Term type. One of #VOLK_TermType.
  *
  * @param[in] data Term data: textual URI, literal value without data type
  *  or langtag, etc. It may be NULL for IRI refs and BNodes, in which case a
  *  random identifier is generated.
  *
- * @param[in] metadata language tag (LSUP_LangTag *) for language-tagged
- * literals; or data type (LSUP_Term *) for other literals. It may be NULL.
+ * @param[in] metadata language tag (VOLK_LangTag *) for language-tagged
+ * literals; or data type (VOLK_Term *) for other literals. It may be NULL.
  *
- * @return New term, which must be freed with #LSUP_term_free after use; or
+ * @return New term, which must be freed with #VOLK_term_free after use; or
  *  NULL on error.
  */
-LSUP_Term *
-LSUP_term_new (LSUP_TermType type, const char *data, void *metadata);
+VOLK_Term *
+VOLK_term_new (VOLK_TermType type, const char *data, void *metadata);
 
 
-/** @brief Placeholder term to use with LSUP_term_reset.
+/** @brief Placeholder term to use with VOLK_term_reset.
  */
-#define TERM_DUMMY LSUP_term_new (LSUP_TERM_UNDEFINED, NULL, NULL)
+#define TERM_DUMMY VOLK_term_new (VOLK_TERM_UNDEFINED, NULL, NULL)
 
 
 /** @brief Create an IRI reference.
  *
- * Must be freed with #LSUP_term_free.
+ * Must be freed with #VOLK_term_free.
  *
  * @param[in] data The fully qualified URI. If NULL, a UUID4 URN is generated.
  *
- * @return same as #LSUP_term_new().
+ * @return same as #VOLK_term_new().
  */
-inline LSUP_Term *
-LSUP_iriref_new (const char *data)
-{ return LSUP_term_new (LSUP_TERM_IRIREF, data, NULL); }
+inline VOLK_Term *
+VOLK_iriref_new (const char *data)
+{ return VOLK_term_new (VOLK_TERM_IRIREF, data, NULL); }
 
 
 /** @brief Create an IRI reference from a namespace-prefixed string.
  *
- * Must be freed with #LSUP_term_free.
+ * Must be freed with #VOLK_term_free.
  *
  * @param[in] data Namespace-prefixed URI. It MUST NOT be NULL,
  *
- * @return same as #LSUP_term_new().
+ * @return same as #VOLK_term_new().
  */
-inline LSUP_Term *
-LSUP_iriref_new_ns (const char *data)
+inline VOLK_Term *
+VOLK_iriref_new_ns (const char *data)
 {
     char *fquri;
-    RCNL (LSUP_nsmap_normalize_uri (data, &fquri));
+    RCNL (VOLK_nsmap_normalize_uri (data, &fquri));
 
-    LSUP_Term *t = LSUP_term_new (LSUP_TERM_IRIREF, fquri, NULL);
+    VOLK_Term *t = VOLK_term_new (VOLK_TERM_IRIREF, fquri, NULL);
     free (fquri);
 
     return t;
@@ -220,8 +220,8 @@ LSUP_iriref_new_ns (const char *data)
  *
  * @return New absolute IRI, or NULL if either term is not an IRI.
  */
-LSUP_Term *
-LSUP_iriref_new_abs (const LSUP_Term *root, const LSUP_Term *iri);
+VOLK_Term *
+VOLK_iriref_new_abs (const VOLK_Term *root, const VOLK_Term *iri);
 
 
 /** @brief Create a new relative IRI from an absolute IRI and a web root IRI.
@@ -236,53 +236,53 @@ LSUP_iriref_new_abs (const LSUP_Term *root, const LSUP_Term *iri);
  * @return New IRI, or NULL if either term is not an IRI. If the input IRI is
  * not a path under the root IRI, the result will be identical to the input.
  */
-LSUP_Term *
-LSUP_iriref_new_rel (const LSUP_Term *root, const LSUP_Term *iri);
+VOLK_Term *
+VOLK_iriref_new_rel (const VOLK_Term *root, const VOLK_Term *iri);
 
 
 /** @brief Shortcut to create a literal term.
  *
- * Must be freed with #LSUP_term_free.
+ * Must be freed with #VOLK_term_free.
  *
  * @param[in] data The literal string.
  *
  * @param[in] datatype Data type URI string. If NULL, the default data type
  * (xsd:string) is used. The new term takes ownership of the pointer.
  *
- * @return same as #LSUP_term_new().
+ * @return same as #VOLK_term_new().
  */
-inline LSUP_Term *
-LSUP_literal_new (const char *data, LSUP_Term *datatype)
-{ return LSUP_term_new (LSUP_TERM_LITERAL, data, datatype); }
+inline VOLK_Term *
+VOLK_literal_new (const char *data, VOLK_Term *datatype)
+{ return VOLK_term_new (VOLK_TERM_LITERAL, data, datatype); }
 
 
 /** @brief Shortcut to create a language-tagged literal term.
  *
- * Must be freed with #LSUP_term_free.
+ * Must be freed with #VOLK_term_free.
  *
  * @param[in] data The literal string.
  *
  * @param[in] lang Language tag string.
  *
- * @return same as #LSUP_term_new().
+ * @return same as #VOLK_term_new().
  */
-inline LSUP_Term *
-LSUP_lt_literal_new (const char *data, char *lang)
-{ return LSUP_term_new (LSUP_TERM_LT_LITERAL, data, lang); }
+inline VOLK_Term *
+VOLK_lt_literal_new (const char *data, char *lang)
+{ return VOLK_term_new (VOLK_TERM_LT_LITERAL, data, lang); }
 
 
 /** @brief Shortcut to create a blank node.
  *
- * Must be freed with #LSUP_term_free.
+ * Must be freed with #VOLK_term_free.
  *
  * @param[in] data The BNode identifier. It can be NULL, in which case, a
  *  random identifier is minted.
  *
- * @return same as #LSUP_term_new().
+ * @return same as #VOLK_term_new().
  */
-inline LSUP_Term *
-LSUP_bnode_new (const char *data)
-{ return LSUP_term_new (LSUP_TERM_BNODE, data, NULL); }
+inline VOLK_Term *
+VOLK_bnode_new (const char *data)
+{ return VOLK_term_new (VOLK_TERM_BNODE, data, NULL); }
 
 
 /** @brief Copy a term.
@@ -291,35 +291,35 @@ LSUP_bnode_new (const char *data)
  *
  * @return A new duplicate term handle.
  */
-LSUP_Term *
-LSUP_term_copy (const LSUP_Term *src);
+VOLK_Term *
+VOLK_term_copy (const VOLK_Term *src);
 
 
 /** @brief Deserialize a buffer into a term.
  *
  * @param[in] sterm Buffer to convert into a term. It must be a valid
- *  serialized term from store or obtained with #LSUP_term_serialize().
+ *  serialized term from store or obtained with #VOLK_term_serialize().
  *
- * @return New term handle. It must be freed with #LSUP_term_free().
+ * @return New term handle. It must be freed with #VOLK_term_free().
  */
-LSUP_Term *
-LSUP_term_new_from_buffer (const LSUP_Buffer *sterm);
+VOLK_Term *
+VOLK_term_new_from_buffer (const VOLK_Buffer *sterm);
 
 
 /** @brief Serialize a term into a buffer.
  *
  * @param[in] term Term to convert into a buffer.
  *
- * @return New buffer handle. It must be freed with #LSUP_buffer_free().
+ * @return New buffer handle. It must be freed with #VOLK_buffer_free().
  */
-LSUP_Buffer *
-LSUP_term_serialize (const LSUP_Term *term);
+VOLK_Buffer *
+VOLK_term_serialize (const VOLK_Term *term);
 
 
 /** @brief Hash a buffer.
  */
-LSUP_Key
-LSUP_term_hash (const LSUP_Term *term);
+VOLK_Key
+VOLK_term_hash (const VOLK_Term *term);
 
 
 /** @brief Compare two terms.
@@ -327,12 +327,12 @@ LSUP_term_hash (const LSUP_Term *term);
  * The terms evaluate as equal if their hashes are equal—i.e. if they are
  * semantically equivalent.
  */
-inline bool LSUP_term_equals (const LSUP_Term *term1, const LSUP_Term *term2)
-{ return term1 == term2 || LSUP_term_hash (term1) == LSUP_term_hash (term2); }
+inline bool VOLK_term_equals (const VOLK_Term *term1, const VOLK_Term *term2)
+{ return term1 == term2 || VOLK_term_hash (term1) == VOLK_term_hash (term2); }
 
 
 void
-LSUP_term_free (LSUP_Term *term);
+VOLK_term_free (VOLK_Term *term);
 
 
 /** @brief Get the prefix portion of a IRI ref.
@@ -343,7 +343,7 @@ LSUP_term_free (LSUP_Term *term);
  *  should be freed after use.
  */
 char *
-LSUP_iriref_prefix (const LSUP_Term *iri);
+VOLK_iriref_prefix (const VOLK_Term *iri);
 
 
 /** @brief Get the path portion of a IRI ref.
@@ -355,7 +355,7 @@ LSUP_iriref_prefix (const LSUP_Term *iri);
  * be freed after use.
  */
 char *
-LSUP_iriref_path (const LSUP_Term *iri);
+VOLK_iriref_path (const VOLK_Term *iri);
 
 
 /** @brief Get the fragment portion of a IRI ref.
@@ -366,7 +366,7 @@ LSUP_iriref_path (const LSUP_Term *iri);
  * contains no fragment. It should be freed after use.
  */
 char *
-LSUP_iriref_frag (const LSUP_Term *iri);
+VOLK_iriref_frag (const VOLK_Term *iri);
 
 /*
  * TRIPLES
@@ -374,7 +374,7 @@ LSUP_iriref_frag (const LSUP_Term *iri);
 
 /** @brief Create a new triple from three terms.
  *
- * Terms are NOT copied. To free them with the triple, use #LSUP_triple_free().
+ * Terms are NOT copied. To free them with the triple, use #VOLK_triple_free().
  * To only free the triple, use free().
  *
  * TODO Term types are not validated at the moment.
@@ -386,26 +386,26 @@ LSUP_iriref_frag (const LSUP_Term *iri);
  * @param[in] o Triple object.
  *
  */
-LSUP_Triple *
-LSUP_triple_new(LSUP_Term *s, LSUP_Term *p, LSUP_Term *o);
+VOLK_Triple *
+VOLK_triple_new(VOLK_Term *s, VOLK_Term *p, VOLK_Term *o);
 
 
 /** @brief Dummy triple with NULL slots. It is not a valid triple.
  */
-#define TRP_DUMMY LSUP_triple_new (NULL, NULL, NULL)
+#define TRP_DUMMY VOLK_triple_new (NULL, NULL, NULL)
 
 
-LSUP_Triple *
-LSUP_triple_new_from_btriple (const LSUP_BufferTriple *sspo);
+VOLK_Triple *
+VOLK_triple_new_from_btriple (const VOLK_BufferTriple *sspo);
 
 
-LSUP_BufferTriple *
-LSUP_triple_serialize (const LSUP_Triple *spo);
+VOLK_BufferTriple *
+VOLK_triple_serialize (const VOLK_Triple *spo);
 
 
 /** @brief Initialize internal term pointers in a heap-allocated triple.
  *
- * @sa #LSUP_triple_new()
+ * @sa #VOLK_triple_new()
  *
  * @param[in] spo Triple pointer to initialize.
  *
@@ -415,8 +415,8 @@ LSUP_triple_serialize (const LSUP_Triple *spo);
  *
  * @param[in] o Triple object.
  */
-LSUP_rc
-LSUP_triple_init (LSUP_Triple *spo, LSUP_Term *s, LSUP_Term *p, LSUP_Term *o);
+VOLK_rc
+VOLK_triple_init (VOLK_Triple *spo, VOLK_Term *s, VOLK_Term *p, VOLK_Term *o);
 
 
 /** @brief Free the internal pointers of a triple.
@@ -424,7 +424,7 @@ LSUP_triple_init (LSUP_Triple *spo, LSUP_Term *s, LSUP_Term *p, LSUP_Term *o);
  * @param[in] spo Triple to be freed.
  */
 void
-LSUP_triple_done (LSUP_Triple *spo);
+VOLK_triple_done (VOLK_Triple *spo);
 
 
 /** @brief Free a triple and all its internal pointers.
@@ -435,7 +435,7 @@ LSUP_triple_done (LSUP_Triple *spo);
  * @param[in] spo Triple to be freed.
  */
 void
-LSUP_triple_free (LSUP_Triple *spo);
+VOLK_triple_free (VOLK_Triple *spo);
 
 
 /** @brief Get triple by term position.
@@ -448,8 +448,8 @@ LSUP_triple_free (LSUP_Triple *spo);
  *
  * @return Corresponding triple term or NULL if n is out of range.
  */
-inline LSUP_Term *
-LSUP_triple_pos (const LSUP_Triple *trp, const LSUP_TriplePos n)
+inline VOLK_Term *
+VOLK_triple_pos (const VOLK_Triple *trp, const VOLK_TriplePos n)
 {
     if (n == TRP_POS_S) return trp->s;
     if (n == TRP_POS_P) return trp->p;
@@ -462,12 +462,12 @@ LSUP_triple_pos (const LSUP_Triple *trp, const LSUP_TriplePos n)
  *
  * TODO This doesn't handle blank nodes correctly.
  */
-inline LSUP_Key
-LSUP_triple_hash (const LSUP_Triple *trp)
+inline VOLK_Key
+VOLK_triple_hash (const VOLK_Triple *trp)
 {
-    LSUP_BufferTriple *strp = LSUP_triple_serialize (trp);
-    LSUP_Key hash = LSUP_btriple_hash (strp);
-    LSUP_btriple_free (strp);
+    VOLK_BufferTriple *strp = VOLK_triple_serialize (trp);
+    VOLK_Key hash = VOLK_btriple_hash (strp);
+    VOLK_btriple_free (strp);
 
     return hash;
 }
@@ -477,8 +477,8 @@ LSUP_triple_hash (const LSUP_Triple *trp)
  *
  * @return New empty term set.
  */
-LSUP_TermSet *
-LSUP_term_set_new (void);
+VOLK_TermSet *
+VOLK_term_set_new (void);
 
 
 /** @brief Free a term set.
@@ -486,7 +486,7 @@ LSUP_term_set_new (void);
  * @param[in] ts Term set handle.
  */
 void
-LSUP_term_set_free (LSUP_TermSet *ts);
+VOLK_term_set_free (VOLK_TermSet *ts);
 
 
 /** @brief Add term to a term set.
@@ -499,17 +499,17 @@ LSUP_term_set_free (LSUP_TermSet *ts);
  *
  * @param[in] term Term to be added to the list. The term set will take
  * ownership of the term and free it when it's freed with
- * #LSUP_term_set_free()—only if the return code is LSUP_OK.
+ * #VOLK_term_set_free()—only if the return code is VOLK_OK.
  *
  * @param[out] existing If not NULL, and if the term being added is a
  * duplicate, this variable will be populated with the existing term handle.
  *
- * @return LSUP_OK on success; LSUP_NOACTION if the term is duplicate;
- *  LSUP_MEM_ERR on memory error. Note: if not LSUP_OK, the caller is in charge
+ * @return VOLK_OK on success; VOLK_NOACTION if the term is duplicate;
+ *  VOLK_MEM_ERR on memory error. Note: if not VOLK_OK, the caller is in charge
  *  of freeing the `term` handle.
  */
-LSUP_rc
-LSUP_term_set_add (LSUP_TermSet *ts, LSUP_Term *term, LSUP_Term **existing);
+VOLK_rc
+VOLK_term_set_add (VOLK_TermSet *ts, VOLK_Term *term, VOLK_Term **existing);
 
 
 /** @brief Get a term from a term set.
@@ -521,8 +521,8 @@ LSUP_term_set_add (LSUP_TermSet *ts, LSUP_Term *term, LSUP_Term **existing);
  * @return The retrieved term if found, or NULL. The term must not be
  *  modified or freed.
  */
-const LSUP_Term *
-LSUP_term_set_get (LSUP_TermSet *ts, LSUP_Key key);
+const VOLK_Term *
+VOLK_term_set_get (VOLK_TermSet *ts, VOLK_Key key);
 
 
 /** @brief Iterate trough a term set.
@@ -534,11 +534,11 @@ LSUP_term_set_get (LSUP_TermSet *ts, LSUP_Key key);
  * @param[out] term Pointer to be populated with the next term on success. It
  *  may be NULL.
  *
- * @return LSUP_OK if the next term was retrieved; LSUP_END if the end of the
+ * @return VOLK_OK if the next term was retrieved; VOLK_END if the end of the
  *  set has been reached.
  */
-LSUP_rc
-LSUP_term_set_next (LSUP_TermSet *ts, size_t *i, LSUP_Term **term);
+VOLK_rc
+VOLK_term_set_next (VOLK_TermSet *ts, size_t *i, VOLK_Term **term);
 
 
 /** @brief Size of a term set.
@@ -548,7 +548,7 @@ LSUP_term_set_next (LSUP_TermSet *ts, size_t *i, LSUP_Term **term);
  * @return Number of unique terms in the term set.
  */
 size_t
-LSUP_term_set_size (LSUP_TermSet *ts);
+VOLK_term_set_size (VOLK_TermSet *ts);
 
 
 /** @brief New link map.
@@ -557,30 +557,30 @@ LSUP_term_set_size (LSUP_TermSet *ts);
  *  be freed after this function call.
  *
  * @param[in] type Type of links that the link map shall contain.
- * @sa #LSUP_LinkType
+ * @sa #VOLK_LinkType
  *
  * @return a new empty link map.
  */
-LSUP_LinkMap *
-LSUP_link_map_new (const LSUP_Term *linked_term, LSUP_LinkType type);
+VOLK_LinkMap *
+VOLK_link_map_new (const VOLK_Term *linked_term, VOLK_LinkType type);
 
 
 /** @brief Free a link map.
  *
  * All arrays and term handles are recursively freed.
  *
- * @param[in] lm link map handle obtained with #LSUP_link_map_new().
+ * @param[in] lm link map handle obtained with #VOLK_link_map_new().
  */
 void
-LSUP_link_map_free (LSUP_LinkMap *lm);
+VOLK_link_map_free (VOLK_LinkMap *lm);
 
 
 /** @brief Return the link map type.
  *
- * @return Link type. @sa #LSUP_LinkType
+ * @return Link type. @sa #VOLK_LinkType
  */
-LSUP_LinkType
-LSUP_link_map_type (const LSUP_LinkMap *map);
+VOLK_LinkType
+VOLK_link_map_type (const VOLK_LinkMap *map);
 
 
 /** @brief Add a term - term set pair to a link map.
@@ -592,7 +592,7 @@ LSUP_link_map_type (const LSUP_LinkMap *map);
  * In any case, the caller should not directly use the term and term set after
  * passing them to this function.
  *
- * @param[in] lmap Link map handle obtained with #LSUP_link_map_new().
+ * @param[in] lmap Link map handle obtained with #VOLK_link_map_new().
  *
  * @param[in] term Term to be associated with the given object list. The
  *  link map takes ownership of the term.
@@ -600,42 +600,42 @@ LSUP_link_map_type (const LSUP_LinkMap *map);
  * @param[in] tset term set to be associated with the given term. The link
  *  map takes ownership of the term set and the terms in it.
  *
- * @return LSUP_OK on success; LSUP_MEM_ERR on allocation error.
+ * @return VOLK_OK on success; VOLK_MEM_ERR on allocation error.
  */
-LSUP_rc
-LSUP_link_map_add (
-        LSUP_LinkMap *lmap, LSUP_Term *term, LSUP_TermSet *tset);
+VOLK_rc
+VOLK_link_map_add (
+        VOLK_LinkMap *lmap, VOLK_Term *term, VOLK_TermSet *tset);
 
 
 /** @brief Create a new iterator to loop through a link map.
  *
  * @param[in] lmap Map handle to iterate.
  */
-LSUP_LinkMapIterator *
-LSUP_link_map_iter_new (const LSUP_LinkMap *lmap);
+VOLK_LinkMapIterator *
+VOLK_link_map_iter_new (const VOLK_LinkMap *lmap);
 
 
 /** @brief Iterate through a link map.
  *
  * Each call to this function yields a linked term and the related term set.
  *
- * @param[in] it Link map iterator obtained with #LSUP_link_map_iter_new().
+ * @param[in] it Link map iterator obtained with #VOLK_link_map_iter_new().
  *
  * @param[out] lt Linked term returned.
  *
  * @param[out] ts Term set returned.
  *
- * @return LSUP_OK if a result was yielded; LSUP_END if the end of the link map
+ * @return VOLK_OK if a result was yielded; VOLK_END if the end of the link map
  *  has been reached.
  */
-LSUP_rc
-LSUP_link_map_next (
-        LSUP_LinkMapIterator *it, LSUP_Term **lt, LSUP_TermSet **ts);
+VOLK_rc
+VOLK_link_map_next (
+        VOLK_LinkMapIterator *it, VOLK_Term **lt, VOLK_TermSet **ts);
 
 
 /// Free a link map iterator.
 void
-LSUP_link_map_iter_free (LSUP_LinkMapIterator *it);
+VOLK_link_map_iter_free (VOLK_LinkMapIterator *it);
 
 
 /**@brief Iterate over a link map and generate triples.
@@ -644,18 +644,18 @@ LSUP_link_map_iter_free (LSUP_LinkMapIterator *it);
  * term sets in the map, based on a given related term.
  *
  * @param[in] it Link map iterator handle, obtained with
- *  #LSUP_link_map_iter_new().
+ *  #VOLK_link_map_iter_new().
  *
  * @param[in,out] spo Result triple. The triple handle must be pre-allocated
  *  (it may be TRP_DUMMY) and calls to this function will be set its memebers
- *  to term handles owned by the link map. If rc != LSUP_OK, the contents are
+ *  to term handles owned by the link map. If rc != VOLK_OK, the contents are
  *  undefined.
  *
- * @return LSUP_OK if a new triple was yielded; LSUP_END if the end of the loop
+ * @return VOLK_OK if a new triple was yielded; VOLK_END if the end of the loop
  *  has been reached; <0 on error.
  */
-LSUP_rc
-LSUP_link_map_triples (LSUP_LinkMapIterator *it, LSUP_Triple *spo);
+VOLK_rc
+VOLK_link_map_triples (VOLK_LinkMapIterator *it, VOLK_Triple *spo);
 
 ///@} END defgroup term
 #endif

+ 29 - 29
profile.c

@@ -1,12 +1,12 @@
 #include <time.h>
-#include "lsup_rdf.h"
+#include "volksdata.h"
 
 #define NT 100000
 
-static LSUP_Triple **
+static VOLK_Triple **
 generate_triples (size_t nt)
 {
-    LSUP_Triple **trp;
+    VOLK_Triple **trp;
     trp = malloc((nt  + 1) * sizeof(*trp));
     if (!trp) exit (-1);
 
@@ -16,10 +16,10 @@ generate_triples (size_t nt)
         sprintf(sstr, "urn:s:%lu", i % (nt / 100));
         sprintf(pstr, "urn:p:%lu", i % (nt / 1000));
         sprintf(ostr, "urn:o:%lu", i);
-        trp[i] = LSUP_triple_new(
-                LSUP_iriref_new (sstr, NULL),
-                LSUP_iriref_new (pstr, NULL),
-                LSUP_iriref_new (ostr, NULL));
+        trp[i] = VOLK_triple_new(
+                VOLK_iriref_new (sstr, NULL),
+                VOLK_iriref_new (pstr, NULL),
+                VOLK_iriref_new (ostr, NULL));
     }
     log_info ("Triples generated.");
 
@@ -31,13 +31,13 @@ int main(int argc, char *argv[])
 {
     size_t nt = (argc > 1) ? atoi (argv[1]) : NT;
     // Set env variable to test path.
-    putenv ("LSUP_MDB_STORE_URN=file://" TMPDIR "/lsup_profile_mdb");
+    putenv ("VOLK_MDB_STORE_URN=file://" TMPDIR "/volksdata_profile_mdb");
 
-    if (LSUP_init() != LSUP_OK) {
-        log_fatal ("Failed to initialize LSUP environment.");
+    if (VOLK_init() != VOLK_OK) {
+        log_fatal ("Failed to initialize Volksdata environment.");
         exit (-1);
     }
-    LSUP_store_int (LSUP_STORE_MDB)->setup_fn (NULL, true);
+    VOLK_store_int (VOLK_STORE_MDB)->setup_fn (NULL, true);
 
     int rc;
     clock_t start, tc1, tc2, end;
@@ -46,48 +46,48 @@ int main(int argc, char *argv[])
     log_info ("Generating %lu triples.", nt);
     start = clock();
 
-    LSUP_Triple **trp = generate_triples(nt);
+    VOLK_Triple **trp = generate_triples(nt);
     tc1 = clock();
     wallclock = (double) (tc1 - start) / CLOCKS_PER_SEC;
     log_info ("Time elapsed: %lf s", wallclock);
 
     log_info ("Inserting triples.");
-    LSUP_Graph *gr = LSUP_graph_new (NULL, NULL, NULL);
+    VOLK_Graph *gr = VOLK_graph_new (NULL, NULL, NULL);
     if (!gr) {
         log_error ("Error creating graph!");
         return -1;
     }
 
     size_t ct;
-    rc = LSUP_graph_add(gr, trp, &ct);
-    if (rc != LSUP_OK) log_warn ("Graph loading interrupted: %d.", rc);
+    rc = VOLK_graph_add(gr, trp, &ct);
+    if (rc != VOLK_OK) log_warn ("Graph loading interrupted: %d.", rc);
     else log_info ("Graph populated with %lu triples.", ct);
 
     for (size_t i = 0; i < nt; i++)
-        LSUP_triple_free (trp[i]);
+        VOLK_triple_free (trp[i]);
     free (trp);
 
     tc2 = clock();
     wallclock = (double) (tc2 - tc1) / CLOCKS_PER_SEC;
     log_info ("Time elapsed: %lf s", wallclock);
-    log_info ("Graph size: %lu", LSUP_graph_size (gr));
+    log_info ("Graph size: %lu", VOLK_graph_size (gr));
 
     log_info ("Lookup...");
     ct = 0;
-    LSUP_Term *s = LSUP_iriref_new ("urn:s:8", NULL);
-    LSUP_Term *p = LSUP_iriref_new ("urn:p:0", NULL);
-    LSUP_Term *o = LSUP_iriref_new ("urn:o:300", NULL);
-    LSUP_GraphIterator *it = LSUP_graph_lookup(gr, s, NULL, NULL, &ct);
+    VOLK_Term *s = VOLK_iriref_new ("urn:s:8", NULL);
+    VOLK_Term *p = VOLK_iriref_new ("urn:p:0", NULL);
+    VOLK_Term *o = VOLK_iriref_new ("urn:o:300", NULL);
+    VOLK_GraphIterator *it = VOLK_graph_lookup(gr, s, NULL, NULL, &ct);
     log_info ("Found triples by count: %lu", ct);
-    LSUP_Triple *spo = NULL;
+    VOLK_Triple *spo = NULL;
     ct = 0;
-    while (LSUP_graph_iter_next (it, &spo) != LSUP_END) {
+    while (VOLK_graph_iter_next (it, &spo) != VOLK_END) {
         ct ++;
-        LSUP_triple_free (spo);
+        VOLK_triple_free (spo);
         spo = NULL;
     }
     log_info ("Found triples by iteration: %lu", ct);
-    LSUP_graph_iter_free (it);
+    VOLK_graph_iter_free (it);
     end = clock();
     wallclock = (double) (end - tc2) / CLOCKS_PER_SEC;
     log_info ("Time elapsed: %lf s", wallclock);
@@ -98,10 +98,10 @@ int main(int argc, char *argv[])
             "%d triples created and inserted in %lf s (%lf triples/s)",
             nt, wallclock, rate);
 
-    LSUP_term_free (s);
-    LSUP_term_free (p);
-    LSUP_term_free (o);
-    LSUP_graph_free(gr);
+    VOLK_term_free (s);
+    VOLK_term_free (p);
+    VOLK_term_free (o);
+    VOLK_graph_free(gr);
 
     return rc;
 }

+ 36 - 36
src/buffer.c

@@ -1,20 +1,20 @@
-#include "lsup/buffer.h"
+#include "volksdata/buffer.h"
 
 /* * * Inline extern prototypes * * */
 
-LSUP_Buffer *LSUP_buffer_new (const unsigned char *data, const size_t size);
-LSUP_rc LSUP_buffer_init (
-        LSUP_Buffer *buf, const size_t size, const unsigned char *data);
-bool LSUP_buffer_eq (const LSUP_Buffer *buf1, const LSUP_Buffer *buf2);
-int LSUP_buffer_cmp (const LSUP_Buffer *buf1, const LSUP_Buffer *buf2);
+VOLK_Buffer *VOLK_buffer_new (const unsigned char *data, const size_t size);
+VOLK_rc VOLK_buffer_init (
+        VOLK_Buffer *buf, const size_t size, const unsigned char *data);
+bool VOLK_buffer_eq (const VOLK_Buffer *buf1, const VOLK_Buffer *buf2);
+int VOLK_buffer_cmp (const VOLK_Buffer *buf1, const VOLK_Buffer *buf2);
 static inline char unescape_char (const char c);
 
 
 /* * * API * * */
 
-LSUP_rc
-LSUP_buffer_init (
-        LSUP_Buffer *buf, const size_t size, const unsigned char *data)
+VOLK_rc
+VOLK_buffer_init (
+        VOLK_Buffer *buf, const size_t size, const unsigned char *data)
 {
     // Do not rely on glibc realloc to handle zero size. See man 3 realloc -
     // Nonportable behavior.
@@ -26,7 +26,7 @@ LSUP_buffer_init (
     } else {
         // If buf->addr is NULL, realloc == malloc. This is portable.
         unsigned char *tmp = realloc (buf->addr, size);
-        if (UNLIKELY (size > 0 && tmp == NULL)) return LSUP_MEM_ERR;
+        if (UNLIKELY (size > 0 && tmp == NULL)) return VOLK_MEM_ERR;
 
         buf->addr = tmp;
     }
@@ -34,11 +34,11 @@ LSUP_buffer_init (
 
     if (data && buf->addr) memcpy (buf->addr, data, buf->size);
 
-    return LSUP_OK;
+    return VOLK_OK;
 }
 
 
-void LSUP_buffer_print (const LSUP_Buffer *buf)
+void VOLK_buffer_print (const VOLK_Buffer *buf)
 {
     for (size_t i = 0; i < buf->size; i++) {
         char chr = ((char*)buf->addr)[i];
@@ -53,7 +53,7 @@ void LSUP_buffer_print (const LSUP_Buffer *buf)
 
 
 char *
-LSUP_buffer_as_str (const LSUP_Buffer *buf)
+VOLK_buffer_as_str (const VOLK_Buffer *buf)
 {
     size_t i, str_size = 1; // terminating NUL
 
@@ -87,14 +87,14 @@ LSUP_buffer_as_str (const LSUP_Buffer *buf)
 }
 
 
-void LSUP_buffer_done (LSUP_Buffer *buf)
+void VOLK_buffer_done (VOLK_Buffer *buf)
 {
-    if (LIKELY (buf) && !(buf->flags & LSUP_BUF_BORROWED)) free (buf->addr);
+    if (LIKELY (buf) && !(buf->flags & VOLK_BUF_BORROWED)) free (buf->addr);
 }
 
-void LSUP_buffer_free (LSUP_Buffer *buf)
+void VOLK_buffer_free (VOLK_Buffer *buf)
 {
-    LSUP_buffer_done (buf);
+    VOLK_buffer_done (buf);
     free (buf);
 }
 
@@ -103,13 +103,13 @@ void LSUP_buffer_free (LSUP_Buffer *buf)
  * Buffer triples.
  */
 
-LSUP_BufferTriple *
-LSUP_btriple_new(LSUP_Buffer *s, LSUP_Buffer *p, LSUP_Buffer *o)
+VOLK_BufferTriple *
+VOLK_btriple_new(VOLK_Buffer *s, VOLK_Buffer *p, VOLK_Buffer *o)
 {
-    LSUP_BufferTriple *sspo = malloc (sizeof (*sspo));
+    VOLK_BufferTriple *sspo = malloc (sizeof (*sspo));
     if (!sspo) return NULL;
 
-    if (UNLIKELY (LSUP_btriple_init (sspo, s, p, o))) {
+    if (UNLIKELY (VOLK_btriple_init (sspo, s, p, o))) {
         free (sspo);
         return NULL;
     }
@@ -118,37 +118,37 @@ LSUP_btriple_new(LSUP_Buffer *s, LSUP_Buffer *p, LSUP_Buffer *o)
 }
 
 
-LSUP_rc
-LSUP_btriple_init (
-        LSUP_BufferTriple *sspo, LSUP_Buffer *s, LSUP_Buffer *p, LSUP_Buffer *o)
+VOLK_rc
+VOLK_btriple_init (
+        VOLK_BufferTriple *sspo, VOLK_Buffer *s, VOLK_Buffer *p, VOLK_Buffer *o)
 {
     sspo->s = s;
     sspo->p = p;
     sspo->o = o;
 
-    return LSUP_OK;
+    return VOLK_OK;
 }
 
 
 void
-LSUP_btriple_done (LSUP_BufferTriple *sspo)
+VOLK_btriple_done (VOLK_BufferTriple *sspo)
 {
     if (UNLIKELY (!sspo)) return;
 
-    LSUP_buffer_done (sspo->s);
-    LSUP_buffer_done (sspo->p);
-    LSUP_buffer_done (sspo->o);
+    VOLK_buffer_done (sspo->s);
+    VOLK_buffer_done (sspo->p);
+    VOLK_buffer_done (sspo->o);
 }
 
 
 void
-LSUP_btriple_free (LSUP_BufferTriple *sspo)
+VOLK_btriple_free (VOLK_BufferTriple *sspo)
 {
     if (UNLIKELY (!sspo)) return;
 
-    LSUP_buffer_free (sspo->s);
-    LSUP_buffer_free (sspo->p);
-    LSUP_buffer_free (sspo->o);
+    VOLK_buffer_free (sspo->s);
+    VOLK_buffer_free (sspo->p);
+    VOLK_buffer_free (sspo->o);
 
     free (sspo);
 }
@@ -172,6 +172,6 @@ static inline char unescape_char (const char c) {
 
 /* Extern inline prototypes. */
 
-LSUP_Key LSUP_buffer_hash (const LSUP_Buffer *buf);
-LSUP_Key LSUP_btriple_hash (const LSUP_BufferTriple *strp);
-LSUP_Buffer *LSUP_btriple_pos (const LSUP_BufferTriple *trp, LSUP_TriplePos n);
+VOLK_Key VOLK_buffer_hash (const VOLK_Buffer *buf);
+VOLK_Key VOLK_btriple_hash (const VOLK_BufferTriple *strp);
+VOLK_Buffer *VOLK_btriple_pos (const VOLK_BufferTriple *trp, VOLK_TriplePos n);

+ 5 - 5
src/codec.c

@@ -1,4 +1,4 @@
-#include "lsup/codec.h"
+#include "volksdata/codec.h"
 
 
 /** @brief List of characters to be escaped in serialized literals.
@@ -77,7 +77,7 @@ uint8_t *unescape_unicode (const uint8_t *esc_str, size_t size)
 }
 
 
-LSUP_rc
+VOLK_rc
 escape_lit (const char *in, char **out_p)
 {
     size_t out_size = strlen (in) + 1;
@@ -91,7 +91,7 @@ escape_lit (const char *in, char **out_p)
     }
 
     char *out = calloc (1, out_size);
-    if (UNLIKELY (!out)) return LSUP_MEM_ERR;
+    if (UNLIKELY (!out)) return VOLK_MEM_ERR;
 
     size_t boundary;
     boundary = strcspn (in, LIT_ECHAR);
@@ -108,14 +108,14 @@ escape_lit (const char *in, char **out_p)
     }
 
     *out_p = out;
-    return LSUP_OK;
+    return VOLK_OK;
 }
 
 
 char *
 fmt_header (char *pfx)
 {
-    char *body = "Generated by lsup_rdf v" LSUP_VERSION " on ";
+    char *body = "Generated by lsup_rdf v" VOLK_VERSION " on ";
     time_t now = time (NULL);
     char date[16];
     strftime (date, sizeof (date), "%m/%d/%Y", gmtime (&now));

+ 1 - 1
src/codec/Makefile

@@ -5,7 +5,7 @@ PARSER = $(BASEDIR)/bin/lemon
 LEMON_SRC_DIR = $(BASEDIR)/ext/sqlite/tool
 
 INCLUDE_DIR = $(BASEDIR)/include
-CODEC_INCLUDE_DIR = $(INCLUDE_DIR)/lsup/codec
+CODEC_INCLUDE_DIR = $(INCLUDE_DIR)/volksdata/codec
 BUILDDIR = ../../build
 
 CODEC_SRC = $(wildcard codec_*.c)

+ 41 - 41
src/codec/codec_nt.c

@@ -1,57 +1,57 @@
-#include "lsup/codec/codec_nt.h"
+#include "volksdata/codec/codec_nt.h"
 
 
 /// NT codec iterator type.
 typedef struct {
-    const LSUP_Codec *  codec;      // Codec that generated this iterator.
-    LSUP_GraphIterator *gr_it;      // Graph iterator.
+    const VOLK_Codec *  codec;      // Codec that generated this iterator.
+    VOLK_GraphIterator *gr_it;      // Graph iterator.
     size_t              cur;        // Internal cursor.
-    LSUP_rc             rc;         // Internal return code.
+    VOLK_rc             rc;         // Internal return code.
     char *              str_s,      // Temporary string.
          *              str_p,      // Temporary string.
          *              str_o;      // Temporary string.
-} LSUP_NTCodecIterator;
+} VOLK_NTCodecIterator;
 
 
 
 /* * * Codec functions. * * */
 
-static LSUP_rc
-term_to_nt (const LSUP_Term *term, char **out_p)
+static VOLK_rc
+term_to_nt (const VOLK_Term *term, char **out_p)
 {
-    LSUP_rc rc;
+    VOLK_rc rc;
     char *out = NULL, *escaped;
     const char *metadata = NULL;
     size_t buf_len;
 
     char *data = term->data;
     switch (term->type) {
-        case LSUP_TERM_IRIREF:
+        case VOLK_TERM_IRIREF:
             out = realloc (*out_p, strlen (data) + 3);
-            if (UNLIKELY (!out)) return LSUP_MEM_ERR;
+            if (UNLIKELY (!out)) return VOLK_MEM_ERR;
 
             sprintf (out, "<%s>", data);
 
             if (data != term->data) free (data);
-            rc = LSUP_OK;
+            rc = VOLK_OK;
             break;
 
-        case LSUP_TERM_LITERAL:
+        case VOLK_TERM_LITERAL:
             // Calculate string length.
-            if (escape_lit (term->data, &escaped) != LSUP_OK)
-                return LSUP_ERROR;
+            if (escape_lit (term->data, &escaped) != VOLK_OK)
+                return VOLK_ERROR;
             buf_len = strlen (escaped) + 3; // Room for "" and terminator
 
             if (
                 term->datatype != 0
-                && term->datatype != LSUP_default_datatype
+                && term->datatype != VOLK_default_datatype
             ) {
                 metadata = term->datatype->data;
                 buf_len += strlen (metadata) + 4; // Room for ^^<>
             }
 
             out = realloc (*out_p, buf_len);
-            if (UNLIKELY (!out)) return LSUP_MEM_ERR;
+            if (UNLIKELY (!out)) return VOLK_MEM_ERR;
 
             sprintf (out, "\"%s\"", escaped);
             free (escaped);
@@ -60,14 +60,14 @@ term_to_nt (const LSUP_Term *term, char **out_p)
             if (metadata)
                 out = strcat (strcat (strcat (out, "^^<"), metadata), ">");
 
-            rc = LSUP_OK;
+            rc = VOLK_OK;
 
             break;
 
-        case LSUP_TERM_LT_LITERAL:
+        case VOLK_TERM_LT_LITERAL:
             // Calculate string length.
-            if (escape_lit (term->data, &escaped) != LSUP_OK)
-                return LSUP_ERROR;
+            if (escape_lit (term->data, &escaped) != VOLK_OK)
+                return VOLK_ERROR;
             buf_len = strlen (escaped) + 3; // Room for "" and terminator
 
             if (term->lang[0] != '\0') {
@@ -76,7 +76,7 @@ term_to_nt (const LSUP_Term *term, char **out_p)
             }
 
             out = realloc (*out_p, buf_len);
-            if (UNLIKELY (!out)) return LSUP_MEM_ERR;
+            if (UNLIKELY (!out)) return VOLK_MEM_ERR;
 
             sprintf (out, "\"%s\"", escaped);
             free (escaped);
@@ -84,22 +84,22 @@ term_to_nt (const LSUP_Term *term, char **out_p)
             // Add lang.
             if (metadata) out = strcat (strcat (out, "@"), metadata);
 
-            rc = LSUP_OK;
+            rc = VOLK_OK;
 
             break;
 
-        case LSUP_TERM_BNODE:
+        case VOLK_TERM_BNODE:
             out = realloc (*out_p, strlen (term->data) + 3);
-            if (UNLIKELY (!out)) return LSUP_MEM_ERR;
+            if (UNLIKELY (!out)) return VOLK_MEM_ERR;
 
             sprintf (out, "_:%s", term->data);
-            rc = LSUP_OK;
+            rc = VOLK_OK;
 
             break;
 
         default:
             out = *out_p;  // This is considered garbage.
-            rc = LSUP_PARSE_ERR;
+            rc = VOLK_PARSE_ERR;
     }
 
     *out_p = out;
@@ -108,29 +108,29 @@ term_to_nt (const LSUP_Term *term, char **out_p)
 
 
 static void *
-gr_to_nt_init (const LSUP_Graph *gr)
+gr_to_nt_init (const VOLK_Graph *gr)
 {
-    LSUP_NTCodecIterator *it;
+    VOLK_NTCodecIterator *it;
     CALLOC_GUARD (it, NULL);
 
     it->codec = &nt_codec;
-    it->gr_it = LSUP_graph_lookup(gr, NULL, NULL, NULL, &it->cur);
+    it->gr_it = VOLK_graph_lookup(gr, NULL, NULL, NULL, &it->cur);
 
     return it;
 }
 
 
-static LSUP_rc
+static VOLK_rc
 gr_to_nt_iter (void *h, char **res) {
-    LSUP_NTCodecIterator *it = h;
-    LSUP_Triple *spo = NULL;
-    LSUP_rc rc = LSUP_graph_iter_next (it->gr_it, &spo);
-    if (rc != LSUP_OK) goto finally;
+    VOLK_NTCodecIterator *it = h;
+    VOLK_Triple *spo = NULL;
+    VOLK_rc rc = VOLK_graph_iter_next (it->gr_it, &spo);
+    if (rc != VOLK_OK) goto finally;
 
     term_to_nt (spo->s, &it->str_s);
     term_to_nt (spo->p, &it->str_p);
     term_to_nt (spo->o, &it->str_o);
-    LSUP_triple_free (spo);
+    VOLK_triple_free (spo);
 
     // 3 term separators + dot + newline + terminal = 6
     char *tmp = realloc (
@@ -138,7 +138,7 @@ gr_to_nt_iter (void *h, char **res) {
             + strlen (it->str_o) + 6);
     if (UNLIKELY (!tmp)) {
         *res = NULL;
-        rc = LSUP_MEM_ERR;
+        rc = VOLK_MEM_ERR;
         goto finally;
     }
 
@@ -155,8 +155,8 @@ finally:
 static void
 gr_to_nt_done (void *h)
 {
-    LSUP_NTCodecIterator *it = h;
-    LSUP_graph_iter_free (it->gr_it);
+    VOLK_NTCodecIterator *it = h;
+    VOLK_graph_iter_free (it->gr_it);
     free (it->str_s);
     free (it->str_p);
     free (it->str_o);
@@ -164,7 +164,7 @@ gr_to_nt_done (void *h)
 }
 
 
-const LSUP_Codec nt_codec = {
+const VOLK_Codec nt_codec = {
     .name               = "N-Triples",
     .mimetype           = "application/n-triples",
     .extension          = "nt",
@@ -175,6 +175,6 @@ const LSUP_Codec nt_codec = {
     .encode_graph_iter  = gr_to_nt_iter,
     .encode_graph_done  = gr_to_nt_done,
 
-    .decode_term        = LSUP_nt_parse_term,
-    .decode_graph       = LSUP_nt_parse_doc,
+    .decode_term        = VOLK_nt_parse_term,
+    .decode_graph       = VOLK_nt_parse_doc,
 };

+ 69 - 69
src/codec/codec_ttl.c

@@ -1,4 +1,4 @@
-#include "lsup/codec/codec_ttl.h"
+#include "volksdata/codec/codec_ttl.h"
 
 
 /** @brief NT codec iterator.
@@ -9,41 +9,41 @@
  * :s :p1 :o1, :o2, o3; p2 o4, o5, <http://example.com/ext1> .
  */
 typedef struct {
-    const LSUP_Codec *  codec;      ///< Codec that generated this iterator.
-    const LSUP_Graph *  gr;        ///< Graph being encoded.
-    LSUP_TermSet *      subjects;   ///< All subjects in the graph.
+    const VOLK_Codec *  codec;      ///< Codec that generated this iterator.
+    const VOLK_Graph *  gr;        ///< Graph being encoded.
+    VOLK_TermSet *      subjects;   ///< All subjects in the graph.
     size_t              s_cur;      ///< Term set cursor.
-    LSUP_rc             rc;         ///< Internal return code.
+    VOLK_rc             rc;         ///< Internal return code.
     char *              s_str;      ///< Serialized subject block (output).
     char *              p_str;      ///< Serialized predicate block.
     char *              o_str;      ///< Serialized object block.
-} LSUP_TTLCodecIterator;
+} VOLK_TTLCodecIterator;
 
 
 /* * * Codec functions. * * */
 
-static LSUP_rc
-term_to_ttl (const LSUP_Term *term, char **out_p)
+static VOLK_rc
+term_to_ttl (const VOLK_Term *term, char **out_p)
 {
-    LSUP_rc rc;
+    VOLK_rc rc;
     char *tmp = NULL, *out = NULL;
     char *metadata = NULL;
     size_t buf_len;
 
-    LSUP_rc md_rc = LSUP_NORESULT;
+    VOLK_rc md_rc = VOLK_NORESULT;
     switch (term->type) {
-        case LSUP_TERM_IRIREF:
-            if (strcmp (term->data, LSUP_RDF_TYPE) == 0) {
+        case VOLK_TERM_IRIREF:
+            if (strcmp (term->data, VOLK_RDF_TYPE) == 0) {
                 // Shorten RDF type
                 buf_len = 2;
                 tmp = "a";
             } else {
-                md_rc = LSUP_nsmap_denormalize_uri (term->data, &tmp);
+                md_rc = VOLK_nsmap_denormalize_uri (term->data, &tmp);
                 PRCCK (md_rc);
-                if (md_rc == LSUP_NORESULT) {
+                if (md_rc == VOLK_NORESULT) {
                     // If URI counld not be shortened, add `<>`
                     out = realloc (*out_p, strlen (tmp) + 3);
-                    if (UNLIKELY (!out)) return LSUP_MEM_ERR;
+                    if (UNLIKELY (!out)) return VOLK_MEM_ERR;
                     sprintf (out, "<%s>", tmp);
                     free (tmp);
 
@@ -52,22 +52,22 @@ term_to_ttl (const LSUP_Term *term, char **out_p)
                     out = tmp;
                 }
             }
-            rc = LSUP_OK;
+            rc = VOLK_OK;
             break;
 
-        case LSUP_TERM_LITERAL:
+        case VOLK_TERM_LITERAL:
             // Calculate string length.
-            if (escape_lit (term->data, &tmp) != LSUP_OK)
-                return LSUP_ERROR;
+            if (escape_lit (term->data, &tmp) != VOLK_OK)
+                return VOLK_ERROR;
             buf_len = strlen (tmp) + 3; // Room for "" and terminator
 
             // Data type.
             bool shorten = false;
             if (
                 term->datatype != 0
-                && term->datatype != LSUP_default_datatype
+                && term->datatype != VOLK_default_datatype
             ) {
-                md_rc = LSUP_nsmap_denormalize_uri (
+                md_rc = VOLK_nsmap_denormalize_uri (
                         term->datatype->data, &metadata);
                 PRCCK (md_rc);
                 unsigned padding = 0;
@@ -87,19 +87,19 @@ term_to_ttl (const LSUP_Term *term, char **out_p)
                     shorten = true;
                 } else {
                     // Room for `^^<>` for FQURI, `^^` for NS URI
-                    padding = md_rc == LSUP_NORESULT ? 4 : 2;
+                    padding = md_rc == VOLK_NORESULT ? 4 : 2;
                 }
                 buf_len += strlen (metadata) + padding;
             }
 
             out = realloc (*out_p, buf_len);
-            if (UNLIKELY (!out)) return LSUP_MEM_ERR;
+            if (UNLIKELY (!out)) return VOLK_MEM_ERR;
 
             if (shorten) {
                 strcpy (out, tmp);
             } else if (metadata) {
                 char *fmt = (
-                        md_rc == LSUP_NORESULT ? "\"%s\"^^<%s>"
+                        md_rc == VOLK_NORESULT ? "\"%s\"^^<%s>"
                         : "\"%s\"^^%s");
                 sprintf (out, fmt, tmp, metadata);
             }
@@ -108,23 +108,23 @@ term_to_ttl (const LSUP_Term *term, char **out_p)
             }
             free (tmp);
 
-            rc = LSUP_OK;
+            rc = VOLK_OK;
 
             break;
 
-        case LSUP_TERM_LT_LITERAL:
+        case VOLK_TERM_LT_LITERAL:
             // Calculate string length.
-            if (escape_lit (term->data, &tmp) != LSUP_OK)
-                return LSUP_ERROR;
+            if (escape_lit (term->data, &tmp) != VOLK_OK)
+                return VOLK_ERROR;
             buf_len = strlen (tmp) + 3; // Room for "" and terminator
 
             if (term->lang[0] != '\0') {
-                metadata = strndup (term->lang, sizeof (LSUP_LangTag));
+                metadata = strndup (term->lang, sizeof (VOLK_LangTag));
                 buf_len += strlen (metadata) + 1; // Room for @
             }
 
             out = realloc (*out_p, buf_len);
-            if (UNLIKELY (!out)) return LSUP_MEM_ERR;
+            if (UNLIKELY (!out)) return VOLK_MEM_ERR;
 
             sprintf (out, "\"%s\"", tmp);
             free (tmp);
@@ -132,22 +132,22 @@ term_to_ttl (const LSUP_Term *term, char **out_p)
             // Add lang.
             if (metadata) out = strcat (strcat (out, "@"), metadata);
 
-            rc = LSUP_OK;
+            rc = VOLK_OK;
 
             break;
 
-        case LSUP_TERM_BNODE:
+        case VOLK_TERM_BNODE:
             out = realloc (*out_p, strlen (term->data) + 3);
-            if (UNLIKELY (!out)) return LSUP_MEM_ERR;
+            if (UNLIKELY (!out)) return VOLK_MEM_ERR;
 
             sprintf (out, "_:%s", term->data);
-            rc = LSUP_OK;
+            rc = VOLK_OK;
 
             break;
 
         default:
             out = *out_p;  // This is considered garbage.
-            rc = LSUP_PARSE_ERR;
+            rc = VOLK_PARSE_ERR;
     }
     free (metadata);
 
@@ -157,28 +157,28 @@ term_to_ttl (const LSUP_Term *term, char **out_p)
 
 
 static void *
-gr_to_ttl_init (const LSUP_Graph *gr)
+gr_to_ttl_init (const VOLK_Graph *gr)
 {
-    LSUP_TTLCodecIterator *it;
+    VOLK_TTLCodecIterator *it;
     CALLOC_GUARD (it, NULL);
 
     it->codec = &ttl_codec;
     it->gr = gr;
-    it->subjects = LSUP_graph_unique_terms (gr, TRP_POS_S);
+    it->subjects = VOLK_graph_unique_terms (gr, TRP_POS_S);
     // Sets the condition to build the prolog on 1st iteration.
-    it->rc = LSUP_NORESULT;
+    it->rc = VOLK_NORESULT;
 
     return it;
 }
 
 
 /// Build header and prolog.
-static LSUP_rc
-build_prolog (LSUP_TTLCodecIterator *it, char **res_p)
+static VOLK_rc
+build_prolog (VOLK_TTLCodecIterator *it, char **res_p)
 {
     char *res = fmt_header ("# ");
 
-    const char ***nsm = LSUP_nsmap_dump ();
+    const char ***nsm = VOLK_nsmap_dump ();
     char *ns_tpl = "@prefix %s: <%s> .\n";
 
     // Prefix map.
@@ -187,7 +187,7 @@ build_prolog (LSUP_TTLCodecIterator *it, char **res_p)
         size_t old_len = strlen (res);
         size_t ns_len = strlen (ns[0]) + strlen (ns[1]) + strlen (ns_tpl);
         char *tmp = realloc (res, old_len + ns_len + 1);
-        if (UNLIKELY (!tmp)) return LSUP_MEM_ERR;
+        if (UNLIKELY (!tmp)) return VOLK_MEM_ERR;
         res = tmp;
 
         sprintf (res + old_len, ns_tpl, ns[0], ns[1]);
@@ -196,46 +196,46 @@ build_prolog (LSUP_TTLCodecIterator *it, char **res_p)
     free (nsm);
 
     // Base.
-    char *base_uri_str = LSUP_graph_uri (it->gr)->data;
+    char *base_uri_str = VOLK_graph_uri (it->gr)->data;
     char *base_stmt_tpl = "\n@base <%s> .\n\n";
     char *base_stmt = malloc (
             strlen (base_stmt_tpl) + strlen (base_uri_str) + 1);
-    if (!UNLIKELY (base_stmt)) return LSUP_MEM_ERR;
+    if (!UNLIKELY (base_stmt)) return VOLK_MEM_ERR;
     sprintf (base_stmt, base_stmt_tpl, base_uri_str);
     res = realloc (res, strlen (res) + strlen (base_stmt) + 1);
-    if (!UNLIKELY (res)) return LSUP_MEM_ERR;
+    if (!UNLIKELY (res)) return VOLK_MEM_ERR;
     res = strcat (res, base_stmt);
     free (base_stmt);
 
     *res_p = res;
-    it->rc = LSUP_OK;
+    it->rc = VOLK_OK;
 
-    return LSUP_OK;
+    return VOLK_OK;
 }
 
 
 /// Encode all the triples for a single subject.
-static LSUP_rc
+static VOLK_rc
 gr_to_ttl_iter (void *h, char **res_p) {
-    LSUP_TTLCodecIterator *it = h;
+    VOLK_TTLCodecIterator *it = h;
 
-    if (it->rc == LSUP_NORESULT) return build_prolog (it, res_p);
+    if (it->rc == VOLK_NORESULT) return build_prolog (it, res_p);
 
-    LSUP_Term *s = NULL;
+    VOLK_Term *s = NULL;
     char *res = *res_p;  // Result string will be reallocated.
-    RCCK (LSUP_term_set_next (it->subjects, &it->s_cur, &s));
+    RCCK (VOLK_term_set_next (it->subjects, &it->s_cur, &s));
 
     term_to_ttl (s, &res);
 
-    LSUP_LinkMap *lmap = LSUP_graph_connections (
-            it->gr, s, LSUP_LINK_OUTBOUND);
+    VOLK_LinkMap *lmap = VOLK_graph_connections (
+            it->gr, s, VOLK_LINK_OUTBOUND);
 
-    LSUP_LinkMapIterator *lmit = LSUP_link_map_iter_new (lmap);
-    LSUP_Term *p = NULL;
-    LSUP_TermSet *o_ts = NULL;
+    VOLK_LinkMapIterator *lmit = VOLK_link_map_iter_new (lmap);
+    VOLK_Term *p = NULL;
+    VOLK_TermSet *o_ts = NULL;
     char *p_join = " ";
     // Begin predicate loop.
-    while (LSUP_link_map_next (lmit, &p, &o_ts) != LSUP_END) {
+    while (VOLK_link_map_next (lmit, &p, &o_ts) != VOLK_END) {
         // Add predicate representation.
         RCCK (term_to_ttl (p, &it->p_str));
         char *tmp = realloc (
@@ -247,9 +247,9 @@ gr_to_ttl_iter (void *h, char **res_p) {
 
         // Add objects for predicate.
         size_t i = 0;
-        LSUP_Term *o = NULL;
+        VOLK_Term *o = NULL;
         char *o_join = " ";
-        while (LSUP_term_set_next (o_ts, &i, &o) != LSUP_END) {
+        while (VOLK_term_set_next (o_ts, &i, &o) != VOLK_END) {
             it->rc = term_to_ttl (o, &it->o_str);
             RCCK (it->rc);
             char *tmp = realloc (
@@ -266,23 +266,23 @@ gr_to_ttl_iter (void *h, char **res_p) {
 
     *res_p = strcat (tmp, s_sep);
 
-    LSUP_link_map_iter_free (lmit);
-    LSUP_link_map_free (lmap);
+    VOLK_link_map_iter_free (lmit);
+    VOLK_link_map_free (lmap);
 
     return it->rc;
 
 memfail:
     free (res);
     *res_p = NULL;
-    return LSUP_MEM_ERR;
+    return VOLK_MEM_ERR;
 }
 
 
 static void
 gr_to_ttl_done (void *h)
 {
-    LSUP_TTLCodecIterator *it = h;
-    LSUP_term_set_free (it->subjects);
+    VOLK_TTLCodecIterator *it = h;
+    VOLK_term_set_free (it->subjects);
     free (it->s_str);
     free (it->p_str);
     free (it->o_str);
@@ -290,7 +290,7 @@ gr_to_ttl_done (void *h)
 }
 
 
-const LSUP_Codec ttl_codec = {
+const VOLK_Codec ttl_codec = {
     .name               = "Turtle",
     .mimetype           = "text/turtle",
     .extension          = "ttl",
@@ -301,6 +301,6 @@ const LSUP_Codec ttl_codec = {
     .encode_graph_iter  = gr_to_ttl_iter,
     .encode_graph_done  = gr_to_ttl_done,
 
-    //.decode_term        = LSUP_ttl_parse_term,
-    .decode_graph       = LSUP_ttl_parse_doc,
+    //.decode_term        = VOLK_ttl_parse_term,
+    .decode_graph       = VOLK_ttl_parse_doc,
 };

+ 13 - 13
src/codec/grammar_nt.y

@@ -8,16 +8,16 @@
  * To generate the parser, run: `lemon ${FILE}'
  */
 
-#include "lsup/codec.h"
+#include "volksdata/codec.h"
 }
 
 %name NTParse
 
-%token_type { LSUP_Term * }
+%token_type { VOLK_Term * }
 %token_prefix "T_"
 
 %default_type           { void * }
-%extra_argument         { LSUP_GraphIterator *it }
+%extra_argument         { VOLK_GraphIterator *it }
 
 
 // Rules.
@@ -28,24 +28,24 @@ triples     ::= eol.
 triples     ::= triple eol.
 triples     ::= triples triple eol.
 
-%type triple            { LSUP_Triple * }
-%destructor triple      { LSUP_triple_free ($$); }
+%type triple            { VOLK_Triple * }
+%destructor triple      { VOLK_triple_free ($$); }
 triple(A)   ::= ws subject(S) ws predicate(P) ws object(O) ws DOT. {
-                A = LSUP_triple_new (S, P, O);
-                LSUP_graph_add_iter (it, A);
+                A = VOLK_triple_new (S, P, O);
+                VOLK_graph_add_iter (it, A);
             }
 
-%type subject           { LSUP_Term * }
-%destructor subject     { (void)(it); LSUP_term_free ($$); }
+%type subject           { VOLK_Term * }
+%destructor subject     { (void)(it); VOLK_term_free ($$); }
 subject     ::= IRIREF.
 subject     ::= BNODE.
 
-%type predicate         { LSUP_Term * }
-%destructor predicate   { LSUP_term_free ($$); }
+%type predicate         { VOLK_Term * }
+%destructor predicate   { VOLK_term_free ($$); }
 predicate   ::= IRIREF.
 
-%type object            { LSUP_Term * }
-%destructor object      { LSUP_term_free ($$); }
+%type object            { VOLK_Term * }
+%destructor object      { VOLK_term_free ($$); }
 object      ::= IRIREF.
 object      ::= BNODE.
 object      ::= LITERAL.

+ 66 - 66
src/codec/grammar_ttl.y

@@ -8,7 +8,7 @@
  * TTL EBNF: https://www.w3.org/TeamSubmission/turtle/#sec-grammar-grammar
  */
 
-#include "lsup/codec.h"
+#include "volksdata/codec.h"
 
 }
 
@@ -16,12 +16,12 @@
 
 %stack_overflow {
     log_error ("Stack oveflow in TTL parsing.");
-    state->rc = LSUP_MEM_ERR;
+    state->rc = VOLK_MEM_ERR;
 }
 
 %parse_failure {
     log_error ("TTL parse error. Cannot continue.");
-    state->rc = LSUP_PARSE_ERR;
+    state->rc = VOLK_PARSE_ERR;
 }
 
 %syntax_error {
@@ -37,7 +37,7 @@
 
 %default_type           { char * }
 
-%extra_argument         { LSUP_TTLParserState *state }
+%extra_argument         { VOLK_TTLParserState *state }
 
 // Low- to high-priority.
 %left PERIOD .
@@ -61,175 +61,175 @@ statement   ::= triples .
 statement   ::= WS .
 
 prefixID    ::= PREFIX(P) WS IRIREF(N) PERIOD . {
-                LSUP_nsmap_add (P, N);
+                VOLK_nsmap_add (P, N);
 
                 free (P);
                 free (N);
             }
 
 base        ::= BASE WS IRIREF(D) PERIOD . {
-                LSUP_term_free (state->base);
-                state->base = LSUP_iriref_new (D);
+                VOLK_term_free (state->base);
+                state->base = VOLK_iriref_new (D);
 
                 free (D);
             }
 
 triples 	::= subject(S) ows predObjList(L) PERIOD . {
-                size_t ct = LSUP_graph_add_link_map (state->it, L);
+                size_t ct = VOLK_graph_add_link_map (state->it, L);
                 state->ct += ct;
-                state->rc = LSUP_OK;
+                state->rc = VOLK_OK;
                 LOG_TRACE("Added %lu triples.", ct);
 
-                LSUP_term_free (S);
-                LSUP_link_map_free (L);
+                VOLK_term_free (S);
+                VOLK_link_map_free (L);
             }
 triples 	::= subject(S) ows predObjList(L) SEMICOLON PERIOD . [PERIOD] {
-                size_t ct = LSUP_graph_add_link_map (state->it, L);
+                size_t ct = VOLK_graph_add_link_map (state->it, L);
                 state->ct += ct;
-                state->rc = LSUP_OK;
+                state->rc = VOLK_OK;
                 LOG_TRACE("Added %lu triples.", ct);
 
-                LSUP_term_free (S);
-                LSUP_link_map_free (L);
+                VOLK_term_free (S);
+                VOLK_link_map_free (L);
             }
 
-%type predObjList       { LSUP_LinkMap * }
-%destructor predObjList { LSUP_link_map_free ($$); }
+%type predObjList       { VOLK_LinkMap * }
+%destructor predObjList { VOLK_link_map_free ($$); }
 predObjList(A) ::= predicate(P) ows objectList(O) . [SEMICOLON] {
-                A = LSUP_link_map_new (state->lms, LSUP_LINK_OUTBOUND);
-                LSUP_link_map_add (A, P, O);
+                A = VOLK_link_map_new (state->lms, VOLK_LINK_OUTBOUND);
+                VOLK_link_map_add (A, P, O);
             }
 predObjList(A) ::= predObjList(L) SEMICOLON predicate(P) ows objectList(O) . {
-                LSUP_link_map_add (L, P, O);
+                VOLK_link_map_add (L, P, O);
                 A = L;
             }
 
-%type objectList { LSUP_TermSet * }
-%destructor objectList { LSUP_term_set_free ($$); }
+%type objectList { VOLK_TermSet * }
+%destructor objectList { VOLK_term_set_free ($$); }
 objectList(A) ::= objectList(L) COMMA object(O) . {
-                if (LSUP_term_set_add (L, O, NULL) == LSUP_NOACTION)
-                    LSUP_term_free (O);
+                if (VOLK_term_set_add (L, O, NULL) == VOLK_NOACTION)
+                    VOLK_term_free (O);
                 A = L;
             }
 objectList(A) ::= object(O) . [IRIREF] {
-                A = LSUP_term_set_new();
-                LSUP_term_set_add (A, O, NULL);
+                A = VOLK_term_set_new();
+                VOLK_term_set_add (A, O, NULL);
             }
 
-%type subject { LSUP_Term * }
-%destructor subject { LSUP_term_free ($$); }
+%type subject { VOLK_Term * }
+%destructor subject { VOLK_term_free ($$); }
 subject 	::= resource(D) . { state->lms = D; }
 subject 	::= blank(D) . { state->lms = D; }
 
-%type predicate { LSUP_Term * }
-%destructor predicate { LSUP_term_free ($$); }
+%type predicate { VOLK_Term * }
+%destructor predicate { VOLK_term_free ($$); }
 predicate   ::= resource .
-predicate(A)::= RDF_TYPE . { A = LSUP_iriref_new_ns ("rdf:type"); }
+predicate(A)::= RDF_TYPE . { A = VOLK_iriref_new_ns ("rdf:type"); }
 
-%type object { LSUP_Term * }
-%destructor object { LSUP_term_free ($$); }
+%type object { VOLK_Term * }
+%destructor object { VOLK_term_free ($$); }
 object 	    ::= resource .
 object 	    ::= blank .
 object 	    ::= literal .
 
-%type literal { LSUP_Term * }
-%destructor literal { LSUP_term_free ($$); }
+%type literal { VOLK_Term * }
+%destructor literal { VOLK_term_free ($$); }
 literal(A)  ::= STRING(D) . {
-                A = LSUP_literal_new (D, NULL);
+                A = VOLK_literal_new (D, NULL);
                 LOG_TRACE("Created plain literal: \"%s\"", A->data);
                 free (D);
             }
 literal(A)  ::= STRING(D) LANGTAG(L) . {
-                A = LSUP_lt_literal_new (D, L);
+                A = VOLK_lt_literal_new (D, L);
                 LOG_TRACE("Created LT-literal: \"%s\"@%s", A->data, A->lang);
                 free (D);
                 free (L);
             }
 literal(A)  ::= STRING(D) DTYPE_MARKER resource(M) . {
-                A = LSUP_literal_new (D, M);
+                A = VOLK_literal_new (D, M);
                 LOG_TRACE(
                         "Created DT-literal: \"%s\"^^%s",
                         A->data, A->datatype);
                 free (D);
             }
 literal(A)  ::= INTEGER(D) . {
-                A = LSUP_literal_new (D, LSUP_iriref_new_ns ("xsd:integer"));
+                A = VOLK_literal_new (D, VOLK_iriref_new_ns ("xsd:integer"));
                 free (D);
             }
 literal(A)  ::= DOUBLE(D) . {
-                A = LSUP_literal_new (D, LSUP_iriref_new_ns ("xsd:double"));
+                A = VOLK_literal_new (D, VOLK_iriref_new_ns ("xsd:double"));
                 free (D);
             }
 literal(A)  ::= DECIMAL(D) . {
-                A = LSUP_literal_new (D, LSUP_iriref_new_ns ("xsd:decimal"));
+                A = VOLK_literal_new (D, VOLK_iriref_new_ns ("xsd:decimal"));
                 free (D);
             }
 literal(A)  ::= BOOLEAN(D) . {
-                A = LSUP_literal_new (D, LSUP_iriref_new_ns ("xsd:boolean"));
+                A = VOLK_literal_new (D, VOLK_iriref_new_ns ("xsd:boolean"));
                 free (D);
             }
 
-%type blank { LSUP_Term * }
-%destructor blank { LSUP_term_free ($$); }
+%type blank { VOLK_Term * }
+%destructor blank { VOLK_term_free ($$); }
 blank(A)    ::= BNODE_ID(D) . {
-                A = LSUP_bnode_new (D);
+                A = VOLK_bnode_new (D);
                 LOG_TRACE("Created blank node: _:%s", A->data);
                 free (D);
             }
 blank(A)    ::= LBRACKET RBRACKET . [BNODE_ID] {
-                A = LSUP_bnode_new (NULL);
+                A = VOLK_bnode_new (NULL);
                 LOG_TRACE("Created empty list BN: _:%s", A->data);
             }
 blank(A)    ::= LBRACKET predObjList(L) RBRACKET . [BNODE_ID] {
-                A = LSUP_bnode_new (NULL);
+                A = VOLK_bnode_new (NULL);
                 state->lms = A;
-                state->ct += LSUP_graph_add_link_map (state->it, L);
+                state->ct += VOLK_graph_add_link_map (state->it, L);
                 LOG_TRACE("Created list BN: _:%s", A->data);
 
-                LSUP_link_map_free (L);
+                VOLK_link_map_free (L);
             }
 blank       ::= collection . [BNODE_ID]
 blank(A)    ::= LPAREN RPAREN . [BNODE_ID] {
-                A = LSUP_iriref_new_ns ("rdf:nil");
+                A = VOLK_iriref_new_ns ("rdf:nil");
                 LOG_TRACE("Created list terminator: %s", A->data);
             }
 
 // "collection" is the subject of the first collection item.
-%type collection { LSUP_Term * }
-%destructor collection { LSUP_term_free ($$); }
+%type collection { VOLK_Term * }
+%destructor collection { VOLK_term_free ($$); }
 // Collection triples are added here to the graph.
 collection(A) ::= LPAREN itemList(L) RPAREN . {
-                A = LSUP_bnode_add_collection (state->it, L);
-                LSUP_term_set_free (L);
+                A = VOLK_bnode_add_collection (state->it, L);
+                VOLK_term_set_free (L);
             }
 
-%type itemList { LSUP_TermSet * }
-%destructor itemList { LSUP_term_set_free ($$); }
+%type itemList { VOLK_TermSet * }
+%destructor itemList { VOLK_term_set_free ($$); }
 itemList(A) ::= itemList(L) ows object(O) . {
-                if (LSUP_term_set_add (L, O, NULL) == LSUP_NOACTION)
-                    LSUP_term_free (O);
+                if (VOLK_term_set_add (L, O, NULL) == VOLK_NOACTION)
+                    VOLK_term_free (O);
                 A = L;
             }
 itemList(A) ::= object(O) . {
-                A = LSUP_term_set_new ();
-                LSUP_term_set_add (A, O, NULL);
+                A = VOLK_term_set_new ();
+                VOLK_term_set_add (A, O, NULL);
             }
 
-%type resource { LSUP_Term * }
-%destructor resource { LSUP_term_free ($$); }
+%type resource { VOLK_Term * }
+%destructor resource { VOLK_term_free ($$); }
 resource(A) ::= IRIREF(D) . {
-                LSUP_Term *rel_iri = LSUP_iriref_new (D);
+                VOLK_Term *rel_iri = VOLK_iriref_new (D);
                 free (D);
                 if (state->base) {
-                    A = LSUP_iriref_new_abs (rel_iri, state->base);
-                    LSUP_term_free (rel_iri);
+                    A = VOLK_iriref_new_abs (rel_iri, state->base);
+                    VOLK_term_free (rel_iri);
                 } else {
                     A = rel_iri;
                 }
                 LOG_TRACE("Created IRI: <%s>", A->data);
             }
 resource(A) ::= QNAME(D) . {
-                A = LSUP_iriref_new_ns (D);
+                A = VOLK_iriref_new_ns (D);
                 LOG_TRACE("Created IRI: %s", A->data);
                 free (D);
             }

+ 31 - 31
src/codec/lexer_nt.re

@@ -1,5 +1,5 @@
-#include "lsup/codec/parser_nt.h"
-#include "lsup/codec/tokens_nt.h"
+#include "volksdata/codec/parser_nt.h"
+#include "volksdata/codec/tokens_nt.h"
 
 
 #define YYCTYPE     uint8_t
@@ -73,7 +73,7 @@ void NTParseTrace();
 
 // Lexer.
 
-static int lex (ParseIterator *it, LSUP_Term **term)
+static int lex (ParseIterator *it, VOLK_Term **term)
 {
     const YYCTYPE *lit_data_e, *dtype_s, *lang_s;
 
@@ -131,7 +131,7 @@ loop:
 
         LOG_DEBUG("URI data: %s", data);
 
-        *term = LSUP_iriref_new ((char*)data);
+        *term = VOLK_iriref_new ((char*)data);
         free (data);
 
         if (!UNLIKELY (term)) return -1;
@@ -146,13 +146,13 @@ loop:
 
         char *metadata = NULL;
         const YYCTYPE *md_marker;
-        LSUP_TermType type = LSUP_TERM_LITERAL;
+        VOLK_TermType type = VOLK_TERM_LITERAL;
 
         if (dtype_s) {
             md_marker = dtype_s;
             size = YYCURSOR - md_marker - 1;
         } else if (lang_s) {
-            type = LSUP_TERM_LT_LITERAL;
+            type = VOLK_TERM_LT_LITERAL;
             md_marker = lang_s;
             size = YYCURSOR - md_marker;
         } else md_marker = NULL;
@@ -164,13 +164,13 @@ loop:
             LOG_TRACE("metadata: %s", metadata);
         }
 
-        if (type == LSUP_TERM_LITERAL) {
-            LSUP_Term *dtype;
-            dtype = (metadata ? LSUP_iriref_new ((char *) metadata) : NULL);
+        if (type == VOLK_TERM_LITERAL) {
+            VOLK_Term *dtype;
+            dtype = (metadata ? VOLK_iriref_new ((char *) metadata) : NULL);
 
-            *term = LSUP_literal_new ((char *) data, dtype);
+            *term = VOLK_literal_new ((char *) data, dtype);
 
-        } else *term = LSUP_lt_literal_new ((char *) data, (char *) metadata);
+        } else *term = VOLK_lt_literal_new ((char *) data, (char *) metadata);
 
         free (data);
         free (metadata);
@@ -184,7 +184,7 @@ loop:
 
         LOG_DEBUG("BNode data: %s", data);
 
-        *term = LSUP_term_new (LSUP_TERM_BNODE, (char*)data, NULL);
+        *term = VOLK_term_new (VOLK_TERM_BNODE, (char*)data, NULL);
         free (data);
 
         if (!UNLIKELY (term)) return -1;
@@ -227,8 +227,8 @@ loop:
 }
 
 
-LSUP_rc
-LSUP_nt_parse_term (const char *rep, LSUP_Term **term)
+VOLK_rc
+VOLK_nt_parse_term (const char *rep, VOLK_Term **term)
 {
     FILE *fh = fmemopen ((void *)rep, strlen (rep), "r");
 
@@ -243,14 +243,14 @@ LSUP_nt_parse_term (const char *rep, LSUP_Term **term)
         case T_IRIREF:
         case T_LITERAL:
         case T_BNODE:
-            return LSUP_OK;
+            return VOLK_OK;
         default:
-            return LSUP_PARSE_ERR;
+            return VOLK_PARSE_ERR;
     }
 }
 
-LSUP_rc
-LSUP_nt_parse_doc (FILE *fh, LSUP_Graph **gr_p, size_t *ct, char **err_p)
+VOLK_rc
+VOLK_nt_parse_doc (FILE *fh, VOLK_Graph **gr_p, size_t *ct, char **err_p)
 {
     *err_p = NULL;
     *gr_p = NULL;
@@ -264,18 +264,18 @@ LSUP_nt_parse_doc (FILE *fh, LSUP_Graph **gr_p, size_t *ct, char **err_p)
 
     void *parser = NTParseAlloc (malloc);
 
-    LSUP_rc rc;
+    VOLK_rc rc;
 
-    LSUP_Graph *gr = LSUP_graph_new (NULL, NULL);
-    if (UNLIKELY (!gr)) return LSUP_MEM_ERR;
+    VOLK_Graph *gr = VOLK_graph_new (NULL, NULL);
+    if (UNLIKELY (!gr)) return VOLK_MEM_ERR;
 
-    LSUP_GraphIterator *it = LSUP_graph_add_init (gr);
+    VOLK_GraphIterator *it = VOLK_graph_add_init (gr);
     if (UNLIKELY (!it)) {
-        LSUP_graph_free (gr);
-        return LSUP_MEM_ERR;
+        VOLK_graph_free (gr);
+        return VOLK_MEM_ERR;
     }
 
-    LSUP_Term *term = NULL;
+    VOLK_Term *term = NULL;
 
     for (;;) {
         int ttype = lex (&parse_it, &term);
@@ -295,7 +295,7 @@ LSUP_nt_parse_doc (FILE *fh, LSUP_Graph **gr_p, size_t *ct, char **err_p)
             char *err_str = malloc (err_size);
             sprintf (err_str, "%s%s%s", err_start, token, err_info);
 
-            rc = LSUP_PARSE_ERR;
+            rc = VOLK_PARSE_ERR;
             *err_p = err_str;
             log_error (err_str);
 
@@ -310,19 +310,19 @@ LSUP_nt_parse_doc (FILE *fh, LSUP_Graph **gr_p, size_t *ct, char **err_p)
     if (ct) *ct = parse_it.ct;
 
     log_info ("Parsed %u triples.", parse_it.ct);
-    LOG_DEBUG("Graph size: %lu", LSUP_graph_size (gr));
+    LOG_DEBUG("Graph size: %lu", VOLK_graph_size (gr));
 
-    rc = parse_it.ct > 0 ? LSUP_OK : LSUP_NORESULT;
+    rc = parse_it.ct > 0 ? VOLK_OK : VOLK_NORESULT;
     *gr_p = gr;
 
 finally: ;
     NTParse (parser, 0, NULL, it);
     NTParseFree (parser, free);
 
-    LSUP_graph_add_done (it);
-    LSUP_term_free (term);
+    VOLK_graph_add_done (it);
+    VOLK_term_free (term);
 
-    if (rc < 0) LSUP_graph_free (gr);
+    if (rc < 0) VOLK_graph_free (gr);
 
     return rc;
 }

+ 18 - 18
src/codec/lexer_ttl.re

@@ -1,5 +1,5 @@
-#include "lsup/codec/parser_ttl.h"
-#include "lsup/codec/tokens_ttl.h"
+#include "volksdata/codec/parser_ttl.h"
+#include "volksdata/codec/tokens_ttl.h"
 
 
 /** @brief TTL is UTF-8 encoded.
@@ -358,17 +358,17 @@ lchar:
 }
 
 
-LSUP_rc
-LSUP_ttl_parse_doc (FILE *fh, LSUP_Graph **gr_p, size_t *ct, char **err_p)
+VOLK_rc
+VOLK_ttl_parse_doc (FILE *fh, VOLK_Graph **gr_p, size_t *ct, char **err_p)
 {
     *err_p = NULL;
     *gr_p = NULL;
 
-    LSUP_TTLParserState *state = malloc (sizeof (*state));
-    if (UNLIKELY (!state)) return LSUP_MEM_ERR;
+    VOLK_TTLParserState *state = malloc (sizeof (*state));
+    if (UNLIKELY (!state)) return VOLK_MEM_ERR;
     state->base = NULL;
     state->ct = 0;
-    state->rc = LSUP_NORESULT;
+    state->rc = VOLK_NORESULT;
 
     ParseIterator parse_it;
     parse_init (&parse_it, fh);
@@ -376,13 +376,13 @@ LSUP_ttl_parse_doc (FILE *fh, LSUP_Graph **gr_p, size_t *ct, char **err_p)
     void *parser = TTLParseAlloc (malloc);
 
     // TODO add basic NS, critically xsd: and rdf:
-    LSUP_Graph *gr = LSUP_graph_new (NULL, NULL);
-    if (UNLIKELY (!gr)) return LSUP_MEM_ERR;
+    VOLK_Graph *gr = VOLK_graph_new (NULL, NULL);
+    if (UNLIKELY (!gr)) return VOLK_MEM_ERR;
 
-    state->it = LSUP_graph_add_init (gr);
+    state->it = VOLK_graph_add_init (gr);
     if (UNLIKELY (!state->it)) {
-        LSUP_graph_free (gr);
-        return LSUP_MEM_ERR;
+        VOLK_graph_free (gr);
+        return VOLK_MEM_ERR;
     }
 
     YYCTYPE *token;
@@ -410,7 +410,7 @@ LSUP_ttl_parse_doc (FILE *fh, LSUP_Graph **gr_p, size_t *ct, char **err_p)
             sprintf (err_str, "%s%s%s", err_start, err_token, err_info);
             log_error (err_str);
 
-            state->rc = LSUP_PARSE_ERR;
+            state->rc = VOLK_PARSE_ERR;
             *err_p = err_str;
 
             goto finally;
@@ -424,21 +424,21 @@ LSUP_ttl_parse_doc (FILE *fh, LSUP_Graph **gr_p, size_t *ct, char **err_p)
     if (ct) *ct = state->ct;
 
     log_info ("Parsed %u triples.", state->ct);
-    LOG_DEBUG("Graph size: %lu", LSUP_graph_size (gr));
+    LOG_DEBUG("Graph size: %lu", VOLK_graph_size (gr));
 
     *gr_p = gr;
 
 finally: ;
-    LSUP_rc rc = state->rc;
+    VOLK_rc rc = state->rc;
     LOG_TRACE("rc is %d", rc);
 
     TTLParseFree (parser, free);
 
-    LSUP_graph_add_done (state->it);
-    LSUP_term_free (state->base);
+    VOLK_graph_add_done (state->it);
+    VOLK_term_free (state->base);
     free (state);
 
-    if (rc < 0) LSUP_graph_free (gr);
+    if (rc < 0) VOLK_graph_free (gr);
 
     return rc;
 }

+ 27 - 27
src/core.c

@@ -4,21 +4,21 @@
 #include <string.h>
 
 #include "lmdb.h"
-#include "lsup/core.h"
+#include "volksdata/core.h"
 
 
-bool LSUP_env_is_init = false;
+bool VOLK_env_is_init = false;
 
 /** @brief Warning messages.
  *
  * The message corresponding to the rc is found by
- * warning_msg[rc - LSUP_MIN_WARNING]. #LSUP_strerror() facilitates this.
+ * warning_msg[rc - VOLK_MIN_WARNING]. #VOLK_strerror() facilitates this.
  */
 char *warning_msg[] = {
-    "LSUP_NOACTION: No action or change of state occurred.",
-    "LSUP_NORESULT: No result.",
-    "LSUP_END: End of the loop reached.",
-    "LSUP_CONFLICT: A conflict prevented a resource from being updated.",
+    "VOLK_NOACTION: No action or change of state occurred.",
+    "VOLK_NORESULT: No result.",
+    "VOLK_END: End of the loop reached.",
+    "VOLK_CONFLICT: A conflict prevented a resource from being updated.",
 };
 
 /** @brief error messages.
@@ -27,25 +27,25 @@ char *warning_msg[] = {
  * be triggered only by error return values.
  *
  * The message corresponding to the rc is found by
- * err_msg[rc - LSUP_MIN_ERROR]. #LSUP_strerror() facilitates this.
+ * err_msg[rc - VOLK_MIN_ERROR]. #VOLK_strerror() facilitates this.
  */
 char *err_msg[] = {
-    "LSUP_ERROR: Runtime error.",
-    "LSUP_PARSE_ERR: Error parsing input.",
-    "LSUP_VALUE_ERR: Invalid input.",
-    "LSUP_TXN_ERR: MDB transaction error.",
-    "LSUP_DB_ERR: Database error.",
-    "LSUP_NOT_IMPL_ERR: Feature is not implemented.",
-    "LSUP_IO_ERR: Input/Output error.",
-    "LSUP_MEM_ERR: Memory error.",
-    "LSUP_CONFLICT_ERR: A resource conflict interrupted the operation.",
-    "LSUP_ENV_ERR: Environment not initialized. Did you call LSUP_init()?",
+    "VOLK_ERROR: Runtime error.",
+    "VOLK_PARSE_ERR: Error parsing input.",
+    "VOLK_VALUE_ERR: Invalid input.",
+    "VOLK_TXN_ERR: MDB transaction error.",
+    "VOLK_DB_ERR: Database error.",
+    "VOLK_NOT_IMPL_ERR: Feature is not implemented.",
+    "VOLK_IO_ERR: Input/Output error.",
+    "VOLK_MEM_ERR: Memory error.",
+    "VOLK_CONFLICT_ERR: A resource conflict interrupted the operation.",
+    "VOLK_ENV_ERR: Environment not initialized. Did you call VOLK_init()?",
 };
 
-char *LSUP_root_path = __FILE__; // This is trimmed to root path on init.
+char *VOLK_root_path = __FILE__; // This is trimmed to root path on init.
 
 
-LSUP_rc
+VOLK_rc
 mkdir_p (const char *_path, mode_t mode)
 {
     char *path = strdup (_path);
@@ -57,7 +57,7 @@ mkdir_p (const char *_path, mode_t mode)
         else break;
 
     errno = 0;
-    LSUP_rc rc = LSUP_NOACTION;
+    VOLK_rc rc = VOLK_NOACTION;
 
     /* Iterate the string */
     for (p = path + 1; *p; p++) {
@@ -73,7 +73,7 @@ mkdir_p (const char *_path, mode_t mode)
     if (mkdir (path, mode) != 0) {
         if (errno != EEXIST) rc = errno;
     } else {
-        rc = LSUP_OK;
+        rc = VOLK_OK;
     }
 
 finally:
@@ -106,13 +106,13 @@ int rm_r(const char *path)
 
 
 const char *
-LSUP_strerror (LSUP_rc rc)
+VOLK_strerror (VOLK_rc rc)
 {
-    if (rc >= LSUP_MIN_ERROR && rc <= LSUP_MAX_ERROR)
-        return err_msg[rc - LSUP_MIN_ERROR];
+    if (rc >= VOLK_MIN_ERROR && rc <= VOLK_MAX_ERROR)
+        return err_msg[rc - VOLK_MIN_ERROR];
 
-    if (rc >= LSUP_MIN_WARNING && rc <= LSUP_MAX_WARNING)
-        return warning_msg[rc - LSUP_MIN_WARNING];
+    if (rc >= VOLK_MIN_WARNING && rc <= VOLK_MAX_WARNING)
+        return warning_msg[rc - VOLK_MIN_WARNING];
 
     return mdb_strerror (rc);
 }

+ 37 - 37
src/environment.c

@@ -1,12 +1,12 @@
-#include "lsup/environment.h"
-#include "lsup/data/bootstrap.h"
+#include "volksdata/environment.h"
+#include "volksdata/data/bootstrap.h"
 
 
 /*
  * External variables.
  */
-LSUP_Term *LSUP_default_ctx = NULL;
-LSUP_Buffer *LSUP_default_ctx_buf = NULL;
+VOLK_Term *VOLK_default_ctx = NULL;
+VOLK_Buffer *VOLK_default_ctx_buf = NULL;
 
 
 /**
@@ -24,7 +24,7 @@ static uint64_t nsmap_hash_fn (
         const void *item, uint64_t seed0, uint64_t seed1)
 {
     const NSEntry *nse = item;
-    return (uint64_t) LSUP_HASH64 (nse->pfx, strlen (nse->pfx), seed0);
+    return (uint64_t) VOLK_HASH64 (nse->pfx, strlen (nse->pfx), seed0);
 }
 
 static void nsmap_free_fn (void *item)
@@ -35,79 +35,79 @@ static void nsmap_free_fn (void *item)
  * API
  */
 
-LSUP_rc
-LSUP_init (void)
+VOLK_rc
+VOLK_init (void)
 {
-    if (LSUP_IS_INIT) {
-        LOG_RC (LSUP_NOACTION);
-        return LSUP_NOACTION;
+    if (VOLK_IS_INIT) {
+        LOG_RC (VOLK_NOACTION);
+        return VOLK_NOACTION;
     }
 
 #ifdef DEBUG
     // In debug mode, always use max logging.
     int loglevel = LOG_TRACE;
 #else
-    char *_loglevel = getenv ("LSUP_LOGLEVEL");
+    char *_loglevel = getenv ("VOLK_LOGLEVEL");
     int loglevel = (_loglevel == NULL) ? LOG_INFO : atoi (_loglevel);
 #endif
     log_set_level (loglevel);
 
     // Default namespace map.
-    LSUP_default_nsm = hashmap_new (
-            sizeof (NSEntry), 0, LSUP_HASH_SEED, 0,
+    VOLK_default_nsm = hashmap_new (
+            sizeof (NSEntry), 0, VOLK_HASH_SEED, 0,
             nsmap_hash_fn, nsmap_comp_fn, nsmap_free_fn, NULL);
 
-    if (hashmap_oom (LSUP_default_nsm)) return LSUP_MEM_ERR;
+    if (hashmap_oom (VOLK_default_nsm)) return VOLK_MEM_ERR;
 
 
-    if (UNLIKELY (!LSUP_default_nsm)) return LSUP_ERROR;
+    if (UNLIKELY (!VOLK_default_nsm)) return VOLK_ERROR;
     for (int i = 0; init_nsmap[i][0] != NULL; i++)
-        LSUP_nsmap_add (init_nsmap[i][0], init_nsmap[i][1]);
+        VOLK_nsmap_add (init_nsmap[i][0], init_nsmap[i][1]);
 
     // Default context URI.
-    const char *default_ctx_str = getenv ("LSUP_DEFAULT_CTX");
+    const char *default_ctx_str = getenv ("VOLK_DEFAULT_CTX");
     if (!default_ctx_str) default_ctx_str = DEFAULT_CTX_LABEL;
-    LSUP_default_ctx = LSUP_iriref_new (default_ctx_str);
-    if (UNLIKELY (!LSUP_default_ctx)) return LSUP_ERROR;
-    LSUP_default_ctx_buf = LSUP_term_serialize (LSUP_default_ctx);
-    if (UNLIKELY (!LSUP_default_ctx_buf)) return LSUP_ERROR;
+    VOLK_default_ctx = VOLK_iriref_new (default_ctx_str);
+    if (UNLIKELY (!VOLK_default_ctx)) return VOLK_ERROR;
+    VOLK_default_ctx_buf = VOLK_term_serialize (VOLK_default_ctx);
+    if (UNLIKELY (!VOLK_default_ctx_buf)) return VOLK_ERROR;
 
     // Initialize term cache.
-    LSUP_term_cache = LSUP_term_set_new();
-    if (UNLIKELY (!LSUP_term_cache)) return LSUP_MEM_ERR;
+    VOLK_term_cache = VOLK_term_set_new();
+    if (UNLIKELY (!VOLK_term_cache)) return VOLK_MEM_ERR;
 
     // Create and cache default literal datatype key.
     // This will be done only once in the program, so no need to check for
     // duplicates.
     // This is the last operation that can fail in this function, and it is
-    // the indicator for LSUP_IS_INIT.
-    LSUP_default_datatype = LSUP_iriref_new (DEFAULT_DTYPE);
-    LSUP_rc rc = LSUP_term_set_add (
-            LSUP_term_cache, LSUP_default_datatype, NULL);
+    // the indicator for VOLK_IS_INIT.
+    VOLK_default_datatype = VOLK_iriref_new (DEFAULT_DTYPE);
+    VOLK_rc rc = VOLK_term_set_add (
+            VOLK_term_cache, VOLK_default_datatype, NULL);
     PRCCK (rc);
 
     log_info ("LSUP environment initialized.");
 
     // Set automatic teardown TODO Is this a good idea?
-    atexit (LSUP_done);
+    atexit (VOLK_done);
 
-    return LSUP_OK;
+    return VOLK_OK;
 }
 
 
 void
-LSUP_done (void)
+VOLK_done (void)
 {
-    if (!LSUP_IS_INIT) return;
+    if (!VOLK_IS_INIT) return;
 
     // Free default NS map and context.
-    LSUP_buffer_free (LSUP_default_ctx_buf);
-    LSUP_term_free (LSUP_default_ctx);
-    hashmap_free (LSUP_default_nsm);
+    VOLK_buffer_free (VOLK_default_ctx_buf);
+    VOLK_term_free (VOLK_default_ctx);
+    hashmap_free (VOLK_default_nsm);
 
     // Free ID cache, including default literal datatype.
-    hashmap_free (LSUP_term_cache);
-    LSUP_default_datatype = NULL; // This causes LSUP_IS_INIT to return false.
+    hashmap_free (VOLK_term_cache);
+    VOLK_default_datatype = NULL; // This causes VOLK_IS_INIT to return false.
 
     log_info ("LSUP environment torn down.");
 }
@@ -117,4 +117,4 @@ LSUP_done (void)
  * Extern inline prototypes.
  */
 
-bool LSUP_is_init (void);
+bool VOLK_is_init (void);

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 299 - 299
src/graph.c


+ 35 - 35
src/namespace.c

@@ -1,4 +1,4 @@
-#include "lsup/namespace.h"
+#include "volksdata/namespace.h"
 
 
 /** @brief Iterator for dumping NS map.
@@ -35,11 +35,11 @@ static bool nsmap_dump_ns_iter_fn (const void *item, void *udata)
  * avoids circular dependencies; and anyways, nsm-related functions in the
  * environment module are not exposed.
  */
-struct hashmap *LSUP_default_nsm = NULL;
+struct hashmap *VOLK_default_nsm = NULL;
 
 
-LSUP_rc
-LSUP_nsmap_add (const char *pfx, const char *nsstr)
+VOLK_rc
+VOLK_nsmap_add (const char *pfx, const char *nsstr)
 {
     NSEntry entry_s = {};
 
@@ -50,7 +50,7 @@ LSUP_nsmap_add (const char *pfx, const char *nsstr)
     strncpy (entry_s.pfx, pfx, PFX_LEN -1);
     entry_s.ns = strdup (nsstr);
 
-    const NSEntry *ret = hashmap_delete (LSUP_default_nsm, &entry_s);
+    const NSEntry *ret = hashmap_delete (VOLK_default_nsm, &entry_s);
     if (!ret) LOG_DEBUG("Adding prefix '%s' to NS map.", entry_s.pfx);
     else {
         LOG_DEBUG(
@@ -59,45 +59,45 @@ LSUP_nsmap_add (const char *pfx, const char *nsstr)
         // Free replaced NS string.
         free (ret->ns);
     }
-    hashmap_set (LSUP_default_nsm, &entry_s);
-    if (hashmap_oom (LSUP_default_nsm)) return LSUP_MEM_ERR;
+    hashmap_set (VOLK_default_nsm, &entry_s);
+    if (hashmap_oom (VOLK_default_nsm)) return VOLK_MEM_ERR;
 
-    return LSUP_OK;
+    return VOLK_OK;
 }
 
 
-LSUP_rc
-LSUP_nsmap_remove (const char *pfx)
+VOLK_rc
+VOLK_nsmap_remove (const char *pfx)
 {
     NSEntry entry_s = {};
     strncpy (entry_s.pfx, pfx, PFX_LEN - 1);
-    const NSEntry *entry = hashmap_delete (LSUP_default_nsm, &entry_s);
+    const NSEntry *entry = hashmap_delete (VOLK_default_nsm, &entry_s);
 
-    if (!entry) return LSUP_NOACTION;
+    if (!entry) return VOLK_NOACTION;
 
     free (entry->ns);
 
-    return LSUP_OK;
+    return VOLK_OK;
 }
 
 
 const char *
-LSUP_nsmap_get_ns (const char *pfx)
+VOLK_nsmap_get_ns (const char *pfx)
 {
     NSEntry entry_s = {};
     strncpy (entry_s.pfx, pfx, PFX_LEN - 1);
-    const NSEntry *entry = hashmap_get (LSUP_default_nsm, &entry_s);
+    const NSEntry *entry = hashmap_get (VOLK_default_nsm, &entry_s);
 
     return (entry) ? entry->ns : NULL;
 }
 
 
 const char *
-LSUP_nsmap_get_pfx (const char *ns)
+VOLK_nsmap_get_pfx (const char *ns)
 {
     const NSEntry *entry;
     size_t i = 0;
-    while (hashmap_iter (LSUP_default_nsm, &i, (void **) &entry)) {
+    while (hashmap_iter (VOLK_default_nsm, &i, (void **) &entry)) {
         if (strncmp (entry->ns, ns, strlen (ns)) == 0)
             return entry->pfx;
     }
@@ -106,14 +106,14 @@ LSUP_nsmap_get_pfx (const char *ns)
 }
 
 
-LSUP_rc
-LSUP_nsmap_normalize_uri (const char *pfx_uri, char **fq_uri_p)
+VOLK_rc
+VOLK_nsmap_normalize_uri (const char *pfx_uri, char **fq_uri_p)
 {
     if (!pfx_uri) {
         log_error ("Prefixed URI cannot be NULL.");
-        return LSUP_VALUE_ERR;
+        return VOLK_VALUE_ERR;
     }
-    LSUP_rc rc = LSUP_NORESULT;
+    VOLK_rc rc = VOLK_NORESULT;
     char *fq_uri = NULL;
 
     size_t pfx_len = strcspn (pfx_uri, ":");
@@ -124,22 +124,22 @@ LSUP_nsmap_normalize_uri (const char *pfx_uri, char **fq_uri_p)
         goto finally;
     }
 
-    LSUP_ns_pfx pfx;
+    VOLK_ns_pfx pfx;
     strncpy (pfx, pfx_uri, pfx_len);
     pfx[pfx_len] = '\0';
 
-    const char *ns = LSUP_nsmap_get_ns (pfx);
+    const char *ns = VOLK_nsmap_get_ns (pfx);
 
     if (ns) {
         // -1 for :, +1 for terminator.
         size_t fq_size = strlen (ns) + strlen (pfx_uri) - pfx_len;
         fq_uri = malloc (fq_size);
-        if (UNLIKELY (! (fq_uri))) return LSUP_MEM_ERR;
+        if (UNLIKELY (! (fq_uri))) return VOLK_MEM_ERR;
 
         strcpy (fq_uri, ns);
         strcat (fq_uri, pfx_uri + pfx_len + 1);
 
-        rc = LSUP_OK;
+        rc = VOLK_OK;
     } else log_warn ("No NS prefix found in map to normalize %s", pfx_uri);
 
 finally:
@@ -149,22 +149,22 @@ finally:
 }
 
 
-LSUP_rc
-LSUP_nsmap_denormalize_uri (const char *fq_uri, char **pfx_uri_p)
+VOLK_rc
+VOLK_nsmap_denormalize_uri (const char *fq_uri, char **pfx_uri_p)
 {
     /*
-     * This is different from LSUP_nsmap_get_ns, in that the URI being looked
+     * This is different from VOLK_nsmap_get_ns, in that the URI being looked
      * at will unlikely match exactly the full namespace stored in the map.
      * This function has to count the characters left over from the match in
      * order to add the URI suffix.
      */
-    LSUP_rc rc = LSUP_NORESULT;
+    VOLK_rc rc = VOLK_NORESULT;
     const NSEntry *entry;
     const char *pfx = NULL;
     char *pfx_uri = NULL;
 
     size_t i = 0, offset;
-    while (hashmap_iter (LSUP_default_nsm, &i, (void **) &entry)) {
+    while (hashmap_iter (VOLK_default_nsm, &i, (void **) &entry)) {
         offset = strlen (entry->ns);
         if (strncmp (entry->ns, fq_uri, offset) == 0) {
             pfx = entry->pfx;
@@ -174,11 +174,11 @@ LSUP_nsmap_denormalize_uri (const char *fq_uri, char **pfx_uri_p)
     if (pfx) {
         // +2: one for terminating \x00, one for the colon.
         pfx_uri = malloc (strlen (pfx) + strlen (fq_uri) - offset + 2);
-        if (UNLIKELY (! (pfx_uri))) return LSUP_MEM_ERR;
+        if (UNLIKELY (! (pfx_uri))) return VOLK_MEM_ERR;
 
         sprintf (pfx_uri, "%s:%s", pfx, fq_uri + offset);
 
-        rc = LSUP_OK;
+        rc = VOLK_OK;
     } else log_warn ("No NS prefix found in map to denormalize %s", fq_uri);
 
     *pfx_uri_p = pfx_uri;
@@ -188,9 +188,9 @@ LSUP_nsmap_denormalize_uri (const char *fq_uri, char **pfx_uri_p)
 
 
 const char ***
-LSUP_nsmap_dump (void)
+VOLK_nsmap_dump (void)
 {
-    size_t i = hashmap_count (LSUP_default_nsm);
+    size_t i = hashmap_count (VOLK_default_nsm);
 
     const char ***data = malloc (2 * (i + 1) * sizeof (char *));
     if (UNLIKELY (!data)) return NULL;
@@ -201,7 +201,7 @@ LSUP_nsmap_dump (void)
     }
 
     struct dump_iter_t cur = {.i = 0, .data = data};
-    hashmap_scan (LSUP_default_nsm, nsmap_dump_ns_iter_fn, &cur);
+    hashmap_scan (VOLK_default_nsm, nsmap_dump_ns_iter_fn, &cur);
     data[i] = NULL; // Sentinel
 
     return data;

+ 65 - 65
src/store.c

@@ -1,9 +1,9 @@
-#include "lsup/store.h"
+#include "volksdata/store.h"
 
 
-#define ENTRY(a, b) case LSUP_STORE_##a: return &b;
-const LSUP_StoreInt *
-LSUP_store_int (LSUP_StoreType type) {
+#define ENTRY(a, b) case VOLK_STORE_##a: return &b;
+const VOLK_StoreInt *
+VOLK_store_int (VOLK_StoreType type) {
     switch (type) {
         BACKEND_TBL
         default: return NULL;
@@ -13,9 +13,9 @@ LSUP_store_int (LSUP_StoreType type) {
 
 
 const char *
-LSUP_store_type_label (LSUP_StoreType type)
+VOLK_store_type_label (VOLK_StoreType type)
 {
-#define ENTRY(a, b) case LSUP_STORE_##a: return "STORE_" #a;
+#define ENTRY(a, b) case VOLK_STORE_##a: return "STORE_" #a;
     switch (type) {
         BACKEND_TBL
         default: return "";
@@ -24,23 +24,23 @@ LSUP_store_type_label (LSUP_StoreType type)
 }
 
 
-LSUP_Store *
-LSUP_store_new (
-        const LSUP_StoreType store_type, const char *store_id, size_t size,
+VOLK_Store *
+VOLK_store_new (
+        const VOLK_StoreType store_type, const char *store_id, size_t size,
         bool clear)
 {
-    if (UNLIKELY (!LSUP_IS_INIT)) {
+    if (UNLIKELY (!VOLK_IS_INIT)) {
         log_error (
-                "Environment is not initialized. Did you call LSUP_init()?");
+                "Environment is not initialized. Did you call VOLK_init()?");
         return NULL;
     }
-    const LSUP_StoreInt *sif = LSUP_store_int (store_type);
+    const VOLK_StoreInt *sif = VOLK_store_int (store_type);
     if (UNLIKELY (!sif)) {
         log_error ("Not a valid store type: %d", store_type);
         return NULL;
     }
 
-    LSUP_Store *store;
+    VOLK_Store *store;
     MALLOC_GUARD (store, NULL);
 
     store->type = store_type;
@@ -64,7 +64,7 @@ fail:
 
 
 void
-LSUP_store_free (LSUP_Store *store)
+VOLK_store_free (VOLK_Store *store)
 {
     if (UNLIKELY (!store)) return;
 
@@ -75,79 +75,79 @@ LSUP_store_free (LSUP_Store *store)
 
 
 size_t
-LSUP_store_size (const LSUP_Store *store)
+VOLK_store_size (const VOLK_Store *store)
 { return store->sif->size_fn (store->data); }
 
 
-const LSUP_StoreFeature
-LSUP_store_features (const LSUP_Store *store)
+const VOLK_StoreFeature
+VOLK_store_features (const VOLK_Store *store)
 { return store->sif->features; }
 
 
 char *
-LSUP_store_id (const LSUP_Store *store)
+VOLK_store_id (const VOLK_Store *store)
 { return store->sif->id_fn (store->data); }
 
 
-LSUP_rc
-LSUP_store_begin (LSUP_Store *store, int flags, void **txn) {
-    if (UNLIKELY (!(store->sif->features & LSUP_STORE_TXN)))
-        return LSUP_NOT_IMPL_ERR;
+VOLK_rc
+VOLK_store_begin (VOLK_Store *store, int flags, void **txn) {
+    if (UNLIKELY (!(store->sif->features & VOLK_STORE_TXN)))
+        return VOLK_NOT_IMPL_ERR;
 
     return store->sif->txn_begin_fn (store->data, flags, txn);
 }
 
 
-LSUP_rc
-LSUP_store_commit (LSUP_Store *store, void *txn)
+VOLK_rc
+VOLK_store_commit (VOLK_Store *store, void *txn)
 {
-    if (UNLIKELY (!(store->sif->features & LSUP_STORE_TXN)))
-        return LSUP_NOT_IMPL_ERR;
+    if (UNLIKELY (!(store->sif->features & VOLK_STORE_TXN)))
+        return VOLK_NOT_IMPL_ERR;
 
     return store->sif->txn_commit_fn (txn);
 }
 
 
 void
-LSUP_store_abort (LSUP_Store *store, void *txn)
+VOLK_store_abort (VOLK_Store *store, void *txn)
 {
-    if (UNLIKELY (!(store->sif->features & LSUP_STORE_TXN))) return;
+    if (UNLIKELY (!(store->sif->features & VOLK_STORE_TXN))) return;
 
     store->sif->txn_abort_fn (txn);
 }
 
 
-LSUP_rc
-LSUP_store_update_ctx_txn (
-        LSUP_Store *store, void *txn, const LSUP_Buffer *old_c,
-        const LSUP_Buffer *new_c)
+VOLK_rc
+VOLK_store_update_ctx_txn (
+        VOLK_Store *store, void *txn, const VOLK_Buffer *old_c,
+        const VOLK_Buffer *new_c)
 {
     // TODO Handle txn better for non-txn stores.
-    if (UNLIKELY (!(store->sif->features & LSUP_STORE_CTX)))
-        return LSUP_NOT_IMPL_ERR;
+    if (UNLIKELY (!(store->sif->features & VOLK_STORE_CTX)))
+        return VOLK_NOT_IMPL_ERR;
 
     return store->sif->update_ctx_fn (store->data, old_c, new_c, txn);
 }
 
 
 void *
-LSUP_store_add_init_txn (
-        LSUP_Store *store, void *txn, const LSUP_Buffer *sc)
+VOLK_store_add_init_txn (
+        VOLK_Store *store, void *txn, const VOLK_Buffer *sc)
     // TODO Handle txn better for non-txn stores.
 { return store->sif->add_init_fn (store->data, sc, txn); }
 
 
-LSUP_rc
-LSUP_store_add_iter (
-        LSUP_Store *store, void *it, const LSUP_BufferTriple *sspo)
+VOLK_rc
+VOLK_store_add_iter (
+        VOLK_Store *store, void *it, const VOLK_BufferTriple *sspo)
 { return store->sif->add_iter_fn (it, sspo); }
 
 
 void
-LSUP_store_add_abort (LSUP_Store *store, void *it)
+VOLK_store_add_abort (VOLK_Store *store, void *it)
 {
     if (
-        UNLIKELY (!(store->sif->features & LSUP_STORE_TXN)) ||
+        UNLIKELY (!(store->sif->features & VOLK_STORE_TXN)) ||
         UNLIKELY (!store->sif->add_abort_fn)
     ) return;
 
@@ -155,23 +155,23 @@ LSUP_store_add_abort (LSUP_Store *store, void *it)
 }
 
 
-LSUP_rc
-LSUP_store_add_done (LSUP_Store *store, void *it)
+VOLK_rc
+VOLK_store_add_done (VOLK_Store *store, void *it)
 { return store->sif->add_done_fn (it); }
 
 
-LSUP_rc
-LSUP_store_add_term_txn (LSUP_Store *store, void *txn, LSUP_Buffer *sterm)
+VOLK_rc
+VOLK_store_add_term_txn (VOLK_Store *store, void *txn, VOLK_Buffer *sterm)
 { return store->sif->add_term_fn (store, sterm, txn); }
 
 
 void *
-LSUP_store_lookup_txn (
-        const LSUP_Store *store, void *txn,
-        const LSUP_Buffer *ss, const LSUP_Buffer *sp, const LSUP_Buffer *so,
-        const LSUP_Buffer *sc, size_t *ct)
+VOLK_store_lookup_txn (
+        const VOLK_Store *store, void *txn,
+        const VOLK_Buffer *ss, const VOLK_Buffer *sp, const VOLK_Buffer *so,
+        const VOLK_Buffer *sc, size_t *ct)
 {
-    if (UNLIKELY (!(store->sif->features & LSUP_STORE_CTX)) && sc) {
+    if (UNLIKELY (!(store->sif->features & VOLK_STORE_CTX)) && sc) {
         log_warn (
                 "Store does not support contexts. Ignoring passed context.");
         sc = NULL;
@@ -180,11 +180,11 @@ LSUP_store_lookup_txn (
     return store->sif->lookup_fn (store->data, ss, sp, so, sc, txn, ct); }
 
 
-LSUP_rc LSUP_store_iter_next (
-        LSUP_Store *store, void *it, LSUP_BufferTriple *sspo,
-        LSUP_Buffer **ctx)
+VOLK_rc VOLK_store_iter_next (
+        VOLK_Store *store, void *it, VOLK_BufferTriple *sspo,
+        VOLK_Buffer **ctx)
 {
-    if (UNLIKELY (!(store->sif->features & LSUP_STORE_CTX)) && ctx) {
+    if (UNLIKELY (!(store->sif->features & VOLK_STORE_CTX)) && ctx) {
         log_warn (
                 "Store does not support contexts. Ignoring passed context.");
         ctx = NULL;
@@ -195,14 +195,14 @@ LSUP_rc LSUP_store_iter_next (
 
 
 void
-LSUP_store_iter_free (LSUP_Store *store, void *it)
+VOLK_store_iter_free (VOLK_Store *store, void *it)
 { store->sif->lu_free_fn (it); }
 
 
 void *
-LSUP_store_iter_txn (const LSUP_Store *store, void *it)
+VOLK_store_iter_txn (const VOLK_Store *store, void *it)
 {
-    if (UNLIKELY (!(store->sif->features & LSUP_STORE_TXN))) {
+    if (UNLIKELY (!(store->sif->features & VOLK_STORE_TXN))) {
         log_warn ("Store does not support transactions.");
         return NULL;
     }
@@ -211,18 +211,18 @@ LSUP_store_iter_txn (const LSUP_Store *store, void *it)
 }
 
 
-LSUP_rc
-LSUP_store_remove_txn (
-        LSUP_Store *store, void *txn,
-        const LSUP_Buffer *ss, const LSUP_Buffer *sp, const LSUP_Buffer *so,
-        const LSUP_Buffer *sc, size_t *ct)
+VOLK_rc
+VOLK_store_remove_txn (
+        VOLK_Store *store, void *txn,
+        const VOLK_Buffer *ss, const VOLK_Buffer *sp, const VOLK_Buffer *so,
+        const VOLK_Buffer *sc, size_t *ct)
 { return store->sif->remove_fn (store->data, ss, sp, so, sc, txn, ct); }
 
 
-LSUP_Buffer **
-LSUP_store_ctx_list_txn (LSUP_Store *store, void *txn)
+VOLK_Buffer **
+VOLK_store_ctx_list_txn (VOLK_Store *store, void *txn)
 {
-    if (UNLIKELY (!(store->sif->features & LSUP_STORE_CTX))) {
+    if (UNLIKELY (!(store->sif->features & VOLK_STORE_CTX))) {
         log_error ("Store does not support contexts.");
         return NULL;
     }

+ 86 - 86
src/store_htable.c

@@ -1,17 +1,17 @@
 #include "hashmap.h"
 
-#include "lsup/store_htable.h"
+#include "volksdata/store_htable.h"
 
 
 /**
  * Callback type for key comparison.
  */
-typedef bool (*LSUP_key_eq_fn_t)(
-        const LSUP_Key spok[], const LSUP_Key luk[]);
+typedef bool (*VOLK_key_eq_fn_t)(
+        const VOLK_Key spok[], const VOLK_Key luk[]);
 
 
 typedef struct idx_entry_t {
-    LSUP_Key            key;        ///< Serialized term key.
+    VOLK_Key            key;        ///< Serialized term key.
     void *              data;       ///< Serialized term data.
     size_t              size;       ///< Serialized term size.
 } IndexEntry;
@@ -24,12 +24,12 @@ typedef struct ht_store_t {
 typedef struct ht_iterator_t {
     HTStore *           store;      ///< Store being iterated.
     size_t              cur;        ///< Internal hash table cursor.
-    LSUP_Key            luk[3];     ///< 0÷3 lookup keys.
-    LSUP_key_eq_fn_t    eq_fn;      ///< Equality function to test triples.
+    VOLK_Key            luk[3];     ///< 0÷3 lookup keys.
+    VOLK_key_eq_fn_t    eq_fn;      ///< Equality function to test triples.
     int                 rc;         ///< Return code for *next* result.
                                     ///< When the end of results is reached,
-                                    ///< this is set to LSUP_END.
-    LSUP_TripleKey *    entry;      ///< Retrieved SPO key.
+                                    ///< this is set to VOLK_END.
+    VOLK_TripleKey *    entry;      ///< Retrieved SPO key.
 } HTIterator;
 
 
@@ -37,56 +37,56 @@ typedef struct ht_iterator_t {
  * Dummy callback for queries with all parameters unbound. Returns true.
 */
 static bool lookup_none_eq_fn (
-        const LSUP_Key spok[], const LSUP_Key luk[])
+        const VOLK_Key spok[], const VOLK_Key luk[])
 { return true; }
 
 /**
  * Keyset lookup for S key.
  */
 static bool lookup_sk_eq_fn (
-        const LSUP_Key spok[], const LSUP_Key luk[])
+        const VOLK_Key spok[], const VOLK_Key luk[])
 { return spok[0] == luk[0]; }
 
 /**
  * Keyset lookup for P key.
  */
 static bool lookup_pk_eq_fn (
-        const LSUP_Key spok[], const LSUP_Key luk[])
+        const VOLK_Key spok[], const VOLK_Key luk[])
 { return spok[1] == luk[1]; }
 
 /**
  * Keyset lookup for O key.
  */
 static bool lookup_ok_eq_fn (
-        const LSUP_Key spok[], const LSUP_Key luk[])
+        const VOLK_Key spok[], const VOLK_Key luk[])
 { return spok[2] == luk[2]; }
 
 /**
  * Keyset lookup for S and P keys.
  */
 static bool lookup_spk_eq_fn (
-        const LSUP_Key spok[], const LSUP_Key luk[])
+        const VOLK_Key spok[], const VOLK_Key luk[])
 { return spok[0] == luk[0] && spok[1] == luk[1]; }
 
 /**
  * Keyset lookup for S and O keys.
  */
 static bool lookup_sok_eq_fn (
-        const LSUP_Key spok[], const LSUP_Key luk[])
+        const VOLK_Key spok[], const VOLK_Key luk[])
 { return spok[0] == luk[0] && spok[2] == luk[2]; }
 
 /**
  * Keyset lookup for P and O keys.
  */
 static bool lookup_pok_eq_fn (
-        const LSUP_Key spok[], const LSUP_Key luk[])
+        const VOLK_Key spok[], const VOLK_Key luk[])
 { return spok[1] == luk[1] && spok[2] == luk[2]; }
 
 /**
  * Keyset lookup for S, P and O keys.
  */
 static bool lookup_spok_eq_fn (
-        const LSUP_Key spok[], const LSUP_Key luk[])
+        const VOLK_Key spok[], const VOLK_Key luk[])
 { return spok[0] == luk[0] && spok[1] == luk[1] && spok[2] == luk[2]; }
 
 
@@ -94,7 +94,7 @@ static bool lookup_spok_eq_fn (
 
 uint64_t trp_key_hash_fn (
         const void *item, uint64_t seed0, uint64_t seed1)
-{ return (uint64_t) (LSUP_HASH (item, TRP_KLEN, seed0)); }
+{ return (uint64_t) (VOLK_HASH (item, TRP_KLEN, seed0)); }
 
 
 int trp_key_cmp_fn (const void *a, const void *b, void *udata)
@@ -125,20 +125,20 @@ static void htstore_idx_free_fn (void *item)
 
 /* * * Other prototypes. * * */
 
-inline static LSUP_rc
+inline static VOLK_rc
 tkey_to_strp (
-        const HTStore *store, const LSUP_Key *spok, LSUP_BufferTriple *sspo);
+        const HTStore *store, const VOLK_Key *spok, VOLK_BufferTriple *sspo);
 
 
-static LSUP_rc
-add_key_iter (HTIterator *it, const LSUP_Key *spok);
+static VOLK_rc
+add_key_iter (HTIterator *it, const VOLK_Key *spok);
 
 
 /** @brief Advance iterator by next key.
  *
  * Result is stored in it->entry.
  */
-static LSUP_rc
+static VOLK_rc
 htiter_next_key (HTIterator *it);
 
 
@@ -163,12 +163,12 @@ htstore_new (const char *id, size_t size)
     CALLOC_GUARD (ht, NULL);
 
     ht->idx = hashmap_new (
-            sizeof (IndexEntry), 0, LSUP_HASH_SEED, 0,
+            sizeof (IndexEntry), 0, VOLK_HASH_SEED, 0,
             htstore_idx_hash_fn, htstore_idx_cmp_fn, htstore_idx_free_fn,
             NULL);
 
     ht->keys = hashmap_new (
-            sizeof (LSUP_TripleKey), size, LSUP_HASH_SEED, 0,
+            sizeof (VOLK_TripleKey), size, VOLK_HASH_SEED, 0,
             trp_key_hash_fn, trp_key_cmp_fn, NULL,
             NULL);
 
@@ -177,23 +177,23 @@ htstore_new (const char *id, size_t size)
 
 
 #if 0
-static LSUP_rc
+static VOLK_rc
 htstore_copy_contents (HTStore *dest, const HTStore *src)
 {
     size_t i = 0;
-    LSUP_TripleKey *spok;
+    VOLK_TripleKey *spok;
     IndexEntry *entry;
     while (hashmap_iter (src->keys, &i, (void **) &spok)) {
         hashmap_set (dest->keys, spok);
-        if (UNLIKELY (hashmap_oom (dest->keys))) return LSUP_MEM_ERR;
+        if (UNLIKELY (hashmap_oom (dest->keys))) return VOLK_MEM_ERR;
     }
     i = 0;
     while (hashmap_iter (src->idx, &i, (void **) &entry)) {
         hashmap_set (dest->idx, entry);
-        if (UNLIKELY (hashmap_oom (dest->idx))) return LSUP_MEM_ERR;
+        if (UNLIKELY (hashmap_oom (dest->idx))) return VOLK_MEM_ERR;
     }
 
-    return LSUP_OK;
+    return VOLK_OK;
 }
 #endif
 
@@ -216,15 +216,15 @@ htstore_size (const void *h)
 }
 
 
-static LSUP_rc
-htstore_add_term (void *h, const LSUP_Buffer *sterm, void *_unused)
+static VOLK_rc
+htstore_add_term (void *h, const VOLK_Buffer *sterm, void *_unused)
 {
     (void) _unused;
     HTStore *store = h;
     IndexEntry entry_s = {
-        .key = LSUP_buffer_hash (sterm),
+        .key = VOLK_buffer_hash (sterm),
     };
-    if (hashmap_get (store->idx, &entry_s)) return LSUP_NOACTION;
+    if (hashmap_get (store->idx, &entry_s)) return VOLK_NOACTION;
 
     entry_s.data = malloc (sterm->size);
     memcpy (entry_s.data, sterm->addr, sterm->size);
@@ -234,12 +234,12 @@ htstore_add_term (void *h, const LSUP_Buffer *sterm, void *_unused)
     hashmap_set (store->idx, &entry_s);
     //LOG_TRACE("Term index size: %lu", hashmap_count (store->idx));
 
-    return LSUP_OK;
+    return VOLK_OK;
 }
 
 
 static void *
-htstore_add_init (void *h, const LSUP_Buffer *_unused, void *_unused2)
+htstore_add_init (void *h, const VOLK_Buffer *_unused, void *_unused2)
 {
     (void) _unused;
     (void) _unused2;
@@ -252,40 +252,40 @@ htstore_add_init (void *h, const LSUP_Buffer *_unused, void *_unused2)
 }
 
 
-static LSUP_rc
-htstore_add_iter (void *h, const LSUP_BufferTriple *sspo)
+static VOLK_rc
+htstore_add_iter (void *h, const VOLK_BufferTriple *sspo)
 {
     HTIterator *it = h;
-    LSUP_TripleKey spok = {
-        LSUP_buffer_hash (sspo->s),
-        LSUP_buffer_hash (sspo->p),
-        LSUP_buffer_hash (sspo->o),
+    VOLK_TripleKey spok = {
+        VOLK_buffer_hash (sspo->s),
+        VOLK_buffer_hash (sspo->p),
+        VOLK_buffer_hash (sspo->o),
     };
 
-    LSUP_rc rc = add_key_iter (it, spok);
+    VOLK_rc rc = add_key_iter (it, spok);
 
-    if (rc != LSUP_OK) return rc;
+    if (rc != VOLK_OK) return rc;
 
     for (int i = 0; i < 3; i++)
-        htstore_add_term (it->store, LSUP_btriple_pos (sspo, i), NULL);
+        htstore_add_term (it->store, VOLK_btriple_pos (sspo, i), NULL);
 
     return rc;
 }
 
 
-static LSUP_rc
+static VOLK_rc
 htstore_add_done (void *h)
 {
     free (h);
-    return LSUP_OK;
+    return VOLK_OK;
 }
 
 
 static void *
 htstore_lookup (
         void *h,
-        const LSUP_Buffer *ss, const LSUP_Buffer *sp, const LSUP_Buffer *so,
-        const LSUP_Buffer *sc, void *_unused, size_t *ct)
+        const VOLK_Buffer *ss, const VOLK_Buffer *sp, const VOLK_Buffer *so,
+        const VOLK_Buffer *sc, void *_unused, size_t *ct)
 {
     (void) _unused;
     HTStore *store = h;
@@ -293,14 +293,14 @@ htstore_lookup (
     CALLOC_GUARD (it, NULL);
 
     it->store = store;
-    it->rc = LSUP_END;
+    it->rc = VOLK_END;
 
     if (ct) *ct = 0;
     if (hashmap_count (store->keys) == 0) return it;
 
-    it->luk[0] = LSUP_buffer_hash (ss);
-    it->luk[1] = LSUP_buffer_hash (sp);
-    it->luk[2] = LSUP_buffer_hash (so);
+    it->luk[0] = VOLK_buffer_hash (ss);
+    it->luk[1] = VOLK_buffer_hash (sp);
+    it->luk[2] = VOLK_buffer_hash (so);
 
     // s p o
     if (ss && sp && so) {
@@ -339,21 +339,21 @@ htstore_lookup (
 
     if (ct) {
         // Loop over results to determine count.
-        while (htiter_next_key (it) == LSUP_OK) (*ct)++;
+        while (htiter_next_key (it) == VOLK_OK) (*ct)++;
 
         // Reposition cursor to the hashtable beginning.
         it->cur = 0;
-        it->rc = LSUP_OK;
+        it->rc = VOLK_OK;
     }
 
     return it;
 }
 
 
-static LSUP_rc
+static VOLK_rc
 htstore_remove(
-        void *h, const LSUP_Buffer *ss, const LSUP_Buffer *sp,
-        const LSUP_Buffer *so,  const LSUP_Buffer *_unused,
+        void *h, const VOLK_Buffer *ss, const VOLK_Buffer *sp,
+        const VOLK_Buffer *so,  const VOLK_Buffer *_unused,
         void *_unused2, size_t *ct_p)
 {
     (void) _unused;
@@ -362,20 +362,20 @@ htstore_remove(
     size_t ct;
 
     HTIterator *it = htstore_lookup (store, ss, sp, so, NULL, NULL, &ct);
-    if (UNLIKELY (!it)) return LSUP_DB_ERR;
+    if (UNLIKELY (!it)) return VOLK_DB_ERR;
 
-    LSUP_rc rc;
+    VOLK_rc rc;
     if (ct == 0) {
-        rc = LSUP_NOACTION;
+        rc = VOLK_NOACTION;
         goto finally;
     }
 
-    while (htiter_next_key (it) == LSUP_OK) {
+    while (htiter_next_key (it) == VOLK_OK) {
         LOG_TRACE(
                 "Deleting {%lx, %lx, %lx}.",
                 it->entry[0][0], it->entry[0][1], it->entry[0][2]);
         hashmap_delete (store->keys, it->entry);
-        rc = LSUP_OK;
+        rc = VOLK_OK;
         it->cur = 0; // Reset cursor, buckets are rearranged after deletion.
     }
 
@@ -387,13 +387,13 @@ finally:
 }
 
 
-static LSUP_rc
+static VOLK_rc
 htiter_next_key (HTIterator *it)
 {
-    if (UNLIKELY (!it)) return LSUP_VALUE_ERR;
+    if (UNLIKELY (!it)) return VOLK_VALUE_ERR;
 
     // This value is for internal looping only. It shall never be returned.
-    it->rc = LSUP_NORESULT;
+    it->rc = VOLK_NORESULT;
 
     do {
         // Loop through all triples until a match is found, or end is reached.
@@ -405,32 +405,32 @@ htiter_next_key (HTIterator *it)
                     it->entry[0][0], it->entry[0][1], it->entry[0][2]
                 );
 
-                it->rc = LSUP_OK;
+                it->rc = VOLK_OK;
             }
         }
-        else it->rc = LSUP_END;
+        else it->rc = VOLK_END;
 
-    } while (it->rc == LSUP_NORESULT);
+    } while (it->rc == VOLK_NORESULT);
 
     return it->rc;
 }
 
 
-static LSUP_rc
-htiter_next (void *h, LSUP_BufferTriple *sspo, LSUP_Buffer **_unused)
+static VOLK_rc
+htiter_next (void *h, VOLK_BufferTriple *sspo, VOLK_Buffer **_unused)
 {
     (void) _unused;
     HTIterator *it = h;
-    LSUP_rc rc = htiter_next_key (it);
-    if (rc != LSUP_OK) return rc;
+    VOLK_rc rc = htiter_next_key (it);
+    if (rc != VOLK_OK) return rc;
 
     return tkey_to_strp (it->store, *it->entry, sspo);
 }
 
 
-const LSUP_StoreInt htstore_int = {
+const VOLK_StoreInt htstore_int = {
     .name           = "Hash Table Store",
-    .features       = LSUP_STORE_COW,
+    .features       = VOLK_STORE_COW,
 
     .setup_fn       = NULL,
     .new_fn         = htstore_new,
@@ -455,40 +455,40 @@ const LSUP_StoreInt htstore_int = {
  * Other statics.
  */
 
-inline static LSUP_rc
+inline static VOLK_rc
 tkey_to_strp (
-        const HTStore *store, const LSUP_Key *spok, LSUP_BufferTriple *sspo)
+        const HTStore *store, const VOLK_Key *spok, VOLK_BufferTriple *sspo)
 {
     // Data owned by the store.
     const IndexEntry *tmp;
 
     for (int i = 0; i < 3; i++) {
         tmp = hashmap_get (store->idx, spok + i);
-        if (UNLIKELY (!tmp)) return LSUP_DB_ERR;
-        LSUP_btriple_pos(sspo, i)->addr = tmp->data;
-        LSUP_btriple_pos(sspo, i)->size = tmp->size;
-        LSUP_btriple_pos(sspo, i)->flags |= LSUP_BUF_BORROWED;
+        if (UNLIKELY (!tmp)) return VOLK_DB_ERR;
+        VOLK_btriple_pos(sspo, i)->addr = tmp->data;
+        VOLK_btriple_pos(sspo, i)->size = tmp->size;
+        VOLK_btriple_pos(sspo, i)->flags |= VOLK_BUF_BORROWED;
     }
 
-    return LSUP_OK;
+    return VOLK_OK;
 }
 
 
-static LSUP_rc
-add_key_iter (HTIterator *it, const LSUP_Key *spok)
+static VOLK_rc
+add_key_iter (HTIterator *it, const VOLK_Key *spok)
 {
     // Add triple.
     LOG_TRACE("Inserting spok: {%lx, %lx, %lx}", spok[0], spok[1], spok[2]);
 
     if (hashmap_get (it->store->keys, spok)) {
         LOG_TRACE("Triple found. Not adding.");
-        return LSUP_NOACTION;
+        return VOLK_NOACTION;
     }
 
     LOG_TRACE("Triple not found, inserting.");
 
     hashmap_set (it->store->keys, (void *)spok);
-    if (hashmap_oom(it->store->keys)) return LSUP_MEM_ERR;
+    if (hashmap_oom(it->store->keys)) return VOLK_MEM_ERR;
 
-    return LSUP_OK;
+    return VOLK_OK;
 }

+ 181 - 181
src/store_mdb.c

@@ -1,4 +1,4 @@
-#include "lsup/store_mdb.h"
+#include "volksdata/store_mdb.h"
 
 /**
  * Number of DBs defined. See MAIN_TABLE and LOOKUP_TABLE defines below.
@@ -80,15 +80,15 @@ typedef struct mdbstore_iter_t {
     MDB_cursor *        ctx_cur;    ///< MDB c:spo index cursor.
     MDB_val             key;        ///< Internal data handler.
     MDB_val             data;       ///< Internal data handler.
-    LSUP_TripleKey      spok;       ///< Triple to be populated with match.
-    LSUP_Key *          ck;         /**< Context array.
+    VOLK_TripleKey      spok;       ///< Triple to be populated with match.
+    VOLK_Key *          ck;         /**< Context array.
                                       *
                                       *  This shall be populated for each
                                       * matching triple if requested. */
     iter_op_fn_t        iter_op_fn; ///< Function used to look up next match.
     const uint8_t *     term_order; ///< Term order used in 1-2bound look-ups.
-    LSUP_Key            luk[3];     ///< 0÷3 lookup keys.
-    LSUP_Key            luc;        ///< Ctx key to filter by. May be NULL_KEY.
+    VOLK_Key            luk[3];     ///< 0÷3 lookup keys.
+    VOLK_Key            luc;        ///< Ctx key to filter by. May be NULL_KEY.
     size_t              i;          ///< Internal counter for paged lookups.
     size_t              ct;         ///< Current count of records inserted or
                                     ///< results found.
@@ -197,27 +197,27 @@ static const uint8_t lookup_ordering_2bound[3][3] = {
  * Static prototypes.
  */
 static int index_triple(
-        MDBStore *store, StoreOp op, LSUP_TripleKey spok, LSUP_Key ck,
+        MDBStore *store, StoreOp op, VOLK_TripleKey spok, VOLK_Key ck,
         MDB_txn *txn);
-static LSUP_rc mdbstore_add_term (void *h, const LSUP_Buffer *sterm, void *th);
+static VOLK_rc mdbstore_add_term (void *h, const VOLK_Buffer *sterm, void *th);
 
-inline static LSUP_rc lookup_0bound (MDBIterator *it, size_t *ct);
-inline static LSUP_rc lookup_1bound (
+inline static VOLK_rc lookup_0bound (MDBIterator *it, size_t *ct);
+inline static VOLK_rc lookup_1bound (
         uint8_t idx0, MDBIterator *it, size_t *ct);
-inline static LSUP_rc lookup_2bound (
+inline static VOLK_rc lookup_2bound (
         uint8_t idx0, uint8_t idx1, MDBIterator *it, size_t *ct);
-inline static LSUP_rc lookup_3bound(MDBIterator *it, size_t *ct);
+inline static VOLK_rc lookup_3bound(MDBIterator *it, size_t *ct);
 
 
 static const char *
 mdbstore_path_from_id (const char *id)
 {
     // Set environment path.
-    if (!id) id = getenv ("LSUP_MDB_STORE_URN");
+    if (!id) id = getenv ("VOLK_MDB_STORE_URN");
     if (!id) {
-        id = LSUP_MDB_STORE_URN;
+        id = VOLK_MDB_STORE_URN;
         log_info (
-            "`LSUP_MDB_STORE_URN' environment variable is not "
+            "`VOLK_MDB_STORE_URN' environment variable is not "
             "set. The default URN %s has been set as the store ID.", id
         );
     }
@@ -237,18 +237,18 @@ mdbstore_path_from_id (const char *id)
  *
  * This function takes care of creating the environment path if not existing,
  * and checking that it's a writable directory. If the path is not specified
- * in the LSUP_MDB_STORE_URN environment variable, a default directory is used.
+ * in the VOLK_MDB_STORE_URN environment variable, a default directory is used.
  */
-static LSUP_rc
+static VOLK_rc
 mdbstore_setup (const char *id, bool clear)
 {
     const char *path = mdbstore_path_from_id (id);
-    if (!path) return LSUP_VALUE_ERR;
+    if (!path) return VOLK_VALUE_ERR;
 
     // If the directory exists (unless clear == true), do nothing.
     if (clear) rm_r (path);
-    LSUP_rc rc = mkdir_p (path, ENV_DIR_MODE);
-    log_info ("Create dir rc: %s", LSUP_strerror (rc));
+    VOLK_rc rc = mkdir_p (path, ENV_DIR_MODE);
+    log_info ("Create dir rc: %s", VOLK_strerror (rc));
     PRCCK (rc);
 
     // Open a temporary environment and txn to create the DBs.
@@ -280,25 +280,25 @@ mdbstore_setup (const char *id, bool clear)
         // Index default context.
         MDB_cursor *cur;
         CHECK (mdb_cursor_open (txn, dbi, &cur), fail);
-        LSUP_Key k = LSUP_buffer_hash (LSUP_default_ctx_buf);
+        VOLK_Key k = VOLK_buffer_hash (VOLK_default_ctx_buf);
         MDB_val key, data;
         key.mv_data = &k;
         key.mv_size = sizeof (k);
 
-        data.mv_data = LSUP_default_ctx_buf->addr;
-        data.mv_size = LSUP_default_ctx_buf->size;
+        data.mv_data = VOLK_default_ctx_buf->addr;
+        data.mv_size = VOLK_default_ctx_buf->size;
 
-        LSUP_rc db_rc = mdb_cursor_put (cur, &key, &data, 0);
+        VOLK_rc db_rc = mdb_cursor_put (cur, &key, &data, 0);
         CHECK (db_rc, fail);
     }
 
     mdb_txn_commit (txn);
     mdb_env_close (env);
 
-    return clear ? LSUP_OK : rc;
+    return clear ? VOLK_OK : rc;
 
 fail:
-    if (rc >= 0) rc = LSUP_DB_ERR;
+    if (rc >= 0) rc = VOLK_DB_ERR;
     mdb_txn_abort (txn);
     return rc;
 }
@@ -310,7 +310,7 @@ fail:
  *
  * Some environment variables affect various store parameters:
  *
- * - LSUP_MDB_MAPSIZE Long int specifying the size of the memory map. Usually
+ * - VOLK_MDB_MAPSIZE Long int specifying the size of the memory map. Usually
  *   it is not necessary to modify this, unless one is operating under memory
  *   and disk constraints. The default map size is 1Tb.
  */
@@ -329,7 +329,7 @@ mdbstore_new (const char *id, size_t _unused)
 
     // Set map size.
     size_t mapsize;
-    char *env_mapsize = getenv ("LSUP_MDB_MAPSIZE");
+    char *env_mapsize = getenv ("VOLK_MDB_MAPSIZE");
     if (env_mapsize == NULL) mapsize = DEFAULT_MAPSIZE;
     else sscanf (env_mapsize, "%zu", &mapsize);
     log_info (
@@ -387,7 +387,7 @@ mdbstore_id (const void *h)
 #endif
 
 
-static LSUP_rc
+static VOLK_rc
 mdbstore_stat (const MDBStore *store, MDB_stat *stat)
 {
     if (!(store->flags & LSSTORE_OPEN)) return 0;
@@ -396,10 +396,10 @@ mdbstore_stat (const MDBStore *store, MDB_stat *stat)
     mdb_txn_begin (store->env, NULL, MDB_RDONLY, &txn);
 
     if (mdb_stat (txn, store->dbi[IDX_SPO_C], stat) != MDB_SUCCESS)
-        return LSUP_DB_ERR;
+        return VOLK_DB_ERR;
     mdb_txn_abort (txn);
 
-    return LSUP_OK;
+    return VOLK_OK;
 }
 
 
@@ -410,29 +410,29 @@ mdbstore_size (const void *h)
     // Size is calculated outside of any pending write txn.
 
     MDB_stat stat;
-    if (mdbstore_stat (store, &stat) != LSUP_OK) return 0;
+    if (mdbstore_stat (store, &stat) != VOLK_OK) return 0;
 
     return stat.ms_entries;
 }
 
 
-static LSUP_rc
+static VOLK_rc
 mdbstore_txn_begin (void *h, int flags, void **th)
 {
     MDBStore *store = h;
 
     RCCK (mdb_txn_begin (store->env, NULL, flags, (MDB_txn **) th));
 
-    return LSUP_OK;
+    return VOLK_OK;
 }
 
 
-static LSUP_rc
+static VOLK_rc
 mdbstore_txn_commit (void *th)
 {
     RCCK (mdb_txn_commit ((MDB_txn *) th));
 
-    return LSUP_OK;
+    return VOLK_OK;
 }
 
 
@@ -457,7 +457,7 @@ mdbiter_txn (void *h)
  *  NULL, the loop transaction will have the passed txn set as its parent.
  */
 static void *
-mdbstore_add_init (void *h, const LSUP_Buffer *sc, void *th)
+mdbstore_add_init (void *h, const VOLK_Buffer *sc, void *th)
 {
     MDBStore *store = h;
     /* An iterator is used here. Some members are a bit misused but it does
@@ -473,7 +473,7 @@ mdbstore_add_init (void *h, const LSUP_Buffer *sc, void *th)
 
     if (sc) {
         // Store context if it's not the default one.
-        it->luc = LSUP_buffer_hash (sc);
+        it->luc = VOLK_buffer_hash (sc);
 
         // Insert t:st for context.
         //LOG_DEBUG("Adding context: %s", sc);
@@ -486,13 +486,13 @@ mdbstore_add_init (void *h, const LSUP_Buffer *sc, void *th)
                 it->txn, it->store->dbi[IDX_T_ST],
                 &it->key, &it->data, MDB_NOOVERWRITE);
         if (db_rc != MDB_SUCCESS && db_rc != MDB_KEYEXIST) {
-            log_error (LSUP_strerror (db_rc));
+            log_error (VOLK_strerror (db_rc));
             mdb_txn_abort (it->txn);
             return NULL;
         }
     } else {
         LOG_DEBUG("No context passed to iterator, using default.");
-        it->luc = LSUP_buffer_hash (LSUP_default_ctx_buf);
+        it->luc = VOLK_buffer_hash (VOLK_default_ctx_buf);
     }
 
     return it;
@@ -510,20 +510,20 @@ fail:
  * #mdbstore_add_abort or #mdbstore_add_done. FIXME
  *
  */
-static LSUP_rc
-mdbstore_add_iter (void *h, const LSUP_BufferTriple *sspo)
+static VOLK_rc
+mdbstore_add_iter (void *h, const VOLK_BufferTriple *sspo)
 {
-    if (UNLIKELY (!h)) return LSUP_VALUE_ERR;
+    if (UNLIKELY (!h)) return VOLK_VALUE_ERR;
 
     MDBIterator *it = h;
-    int db_rc = LSUP_NOACTION;
-    LSUP_TripleKey spok = NULL_TRP;
+    int db_rc = VOLK_NOACTION;
+    VOLK_TripleKey spok = NULL_TRP;
 
     // Add triple terms.
     for (int i = 0; i < 3; i++) {
-        LSUP_Buffer *st = LSUP_btriple_pos (sspo, i);
+        VOLK_Buffer *st = VOLK_btriple_pos (sspo, i);
 
-        spok[i] = LSUP_buffer_hash (st);
+        spok[i] = VOLK_buffer_hash (st);
 
         it->key.mv_data = spok + i;
         it->key.mv_size = KLEN;
@@ -535,7 +535,7 @@ mdbstore_add_iter (void *h, const LSUP_BufferTriple *sspo)
                 &it->key, &it->data, MDB_NOOVERWRITE);
         if (db_rc != MDB_SUCCESS && db_rc != MDB_KEYEXIST) {
             LOG_RC (db_rc);
-            return LSUP_DB_ERR;
+            return VOLK_DB_ERR;
         }
     }
 
@@ -554,30 +554,30 @@ mdbstore_add_iter (void *h, const LSUP_BufferTriple *sspo)
             it->txn, it->store->dbi[IDX_SPO_C],
             &it->key, &it->data, MDB_NODUPDATA);
 
-    if (db_rc == MDB_KEYEXIST) return LSUP_NOACTION;
+    if (db_rc == MDB_KEYEXIST) return VOLK_NOACTION;
     if (db_rc != MDB_SUCCESS) {
         log_error (
-                "MDB error while inserting triple: %s", LSUP_strerror(db_rc));
-        return LSUP_DB_ERR;
+                "MDB error while inserting triple: %s", VOLK_strerror(db_rc));
+        return VOLK_DB_ERR;
     }
 
     // Index.
-    LSUP_rc rc = index_triple (it->store, OP_ADD, spok, it->luc, it->txn);
-    if (rc == LSUP_OK) it->i++;
+    VOLK_rc rc = index_triple (it->store, OP_ADD, spok, it->luc, it->txn);
+    if (rc == VOLK_OK) it->i++;
 
     return rc;
 }
 
 
-static LSUP_rc
+static VOLK_rc
 mdbstore_add_done (void *h)
 {
     MDBIterator *it = h;
-    LSUP_rc rc = LSUP_OK;
+    VOLK_rc rc = VOLK_OK;
 
     if (mdb_txn_commit (it->txn) != MDB_SUCCESS) {
         mdb_txn_abort (it->txn);
-        rc = LSUP_TXN_ERR;
+        rc = VOLK_TXN_ERR;
     }
 
     free (it);
@@ -596,11 +596,11 @@ mdbstore_add_abort (void *h)
 }
 
 
-static LSUP_rc
+static VOLK_rc
 key_to_sterm (
-        MDBStore *store, MDB_txn *txn, const LSUP_Key key, LSUP_Buffer *sterm)
+        MDBStore *store, MDB_txn *txn, const VOLK_Key key, VOLK_Buffer *sterm)
 {
-    LSUP_rc rc = LSUP_NORESULT;
+    VOLK_rc rc = VOLK_NORESULT;
     int db_rc;
 
     MDB_val key_v, data_v;
@@ -609,15 +609,15 @@ key_to_sterm (
 
     db_rc = mdb_get (txn, store->dbi[IDX_T_ST], &key_v, &data_v);
 
-    sterm->flags |= LSUP_BUF_BORROWED;
+    sterm->flags |= VOLK_BUF_BORROWED;
     if (db_rc == MDB_SUCCESS) {
         sterm->addr = data_v.mv_data;
         sterm->size = data_v.mv_size;
-        rc = LSUP_OK;
+        rc = VOLK_OK;
     } else if (db_rc == MDB_NOTFOUND) {
         sterm->addr = NULL;
         sterm->size = 0;
-    } else rc = LSUP_DB_ERR;
+    } else rc = VOLK_DB_ERR;
 
     return rc;
 }
@@ -625,20 +625,20 @@ key_to_sterm (
 
 static void *
 mdbstore_lookup (
-        void *h, const LSUP_Buffer *ss, const LSUP_Buffer *sp,
-        const LSUP_Buffer *so, const LSUP_Buffer *sc, void *th, size_t *ct)
+        void *h, const VOLK_Buffer *ss, const VOLK_Buffer *sp,
+        const VOLK_Buffer *so, const VOLK_Buffer *sc, void *th, size_t *ct)
 {
-    LSUP_TripleKey spok = {
-        LSUP_buffer_hash (ss),
-        LSUP_buffer_hash (sp),
-        LSUP_buffer_hash (so),
+    VOLK_TripleKey spok = {
+        VOLK_buffer_hash (ss),
+        VOLK_buffer_hash (sp),
+        VOLK_buffer_hash (so),
     };
 
     MDBIterator *it;
     CALLOC_GUARD (it, NULL);
 
     it->store = h;
-    it->luc = LSUP_buffer_hash (sc);
+    it->luc = VOLK_buffer_hash (sc);
     LOG_DEBUG("Lookup context: %lx", it->luc);
 
     if (ct) *ct = 0;
@@ -650,7 +650,7 @@ mdbstore_lookup (
         // Start RO transaction if not in a write txn already.
         it->rc = mdb_txn_begin (it->store->env, NULL, MDB_RDONLY, &it->txn);
         if (it->rc != MDB_SUCCESS) {
-            log_error ("Database error in lookup: %s", LSUP_strerror (it->rc));
+            log_error ("Database error in lookup: %s", VOLK_strerror (it->rc));
             return NULL;
         }
         LOG_TRACE ("Opening new MDB transaction @%p", it->txn);
@@ -722,20 +722,20 @@ mdbstore_lookup (
  * ckset is filled with an array of contexts that the triple appears
  * in, if not NULL.
  */
-static LSUP_rc
+static VOLK_rc
 mdbiter_next_key (MDBIterator *it)
 {
-    if (UNLIKELY (!it)) return LSUP_VALUE_ERR;
+    if (UNLIKELY (!it)) return VOLK_VALUE_ERR;
 
     // Only advance if the previous it->rc wasn't already at the end.
-    if (it->rc == MDB_NOTFOUND) return LSUP_END;
+    if (it->rc == MDB_NOTFOUND) return VOLK_END;
 
     if (UNLIKELY (it->rc != MDB_SUCCESS)) {
-        log_error ("Database error: %s", LSUP_strerror (it->rc));
-        return LSUP_DB_ERR;
+        log_error ("Database error: %s", VOLK_strerror (it->rc));
+        return VOLK_DB_ERR;
     }
 
-    LSUP_rc rc;
+    VOLK_rc rc;
 
     /* Retrieve current value and advance cursor to the next result.
      * it->rc is set to the result of the next iteration.
@@ -749,14 +749,14 @@ mdbiter_next_key (MDBIterator *it)
     data.mv_size = KLEN;
 
     if (it->luc) {
-        rc = LSUP_NORESULT;  // Flow control value, will never be returned.
+        rc = VOLK_NORESULT;  // Flow control value, will never be returned.
         do {
             //LOG_DEBUG("begin ctx loop.");
             /* If ctx is specified, look if the matching triple is associated
              * with it. If not, move on to the next triple.
              * The loop normally exits when a triple with matching ctx is found
-             * (LSUP_OK), if there are no more triples (LSUP_END), or if there
-             * is an error (LSUP_DB_ERR).
+             * (VOLK_OK), if there are no more triples (VOLK_END), or if there
+             * is an error (VOLK_DB_ERR).
              */
             LOG_TRACE (
                     "Found spok: {%lx, %lx, %lx}",
@@ -767,26 +767,26 @@ mdbiter_next_key (MDBIterator *it)
             db_rc = mdb_cursor_get (it->ctx_cur, &key, &data, MDB_GET_BOTH);
 
             if (db_rc == MDB_SUCCESS) {
-                rc = LSUP_OK;
+                rc = VOLK_OK;
                 LOG_TRACE("Triple found in context: %x", it->luc);
 
             } else if (db_rc == MDB_NOTFOUND) {
                 LOG_TRACE("Triple not found in context: %x", it->luc);
-                if (it->rc == MDB_NOTFOUND) rc = LSUP_END;
+                if (it->rc == MDB_NOTFOUND) rc = VOLK_END;
                 else it->iter_op_fn (it);
 
             } else {
-                log_error ("Database error: %s", LSUP_strerror (db_rc));
-                rc = LSUP_DB_ERR;
+                log_error ("Database error: %s", VOLK_strerror (db_rc));
+                rc = VOLK_DB_ERR;
             }
-        } while (rc == LSUP_NORESULT);
+        } while (rc == VOLK_NORESULT);
 
     } else {
         LOG_TRACE (
                 "Found spok in any context: {%lx, %lx, %lx}",
                 it->spok[0], it->spok[1], it->spok[2]);
 
-        rc = LSUP_OK;
+        rc = VOLK_OK;
     }
 
     // Get all contexts for a triple.
@@ -794,15 +794,15 @@ mdbiter_next_key (MDBIterator *it)
     db_rc = mdb_cursor_get (it->ctx_cur, &key, &data, MDB_SET_KEY);
     if (db_rc != MDB_SUCCESS) {
         log_error ("No context found for triple!");
-        return LSUP_DB_ERR;
+        return VOLK_DB_ERR;
     }
 
     size_t ct;
     db_rc = mdb_cursor_count (it->ctx_cur, &ct);
-    if (db_rc != MDB_SUCCESS) return LSUP_DB_ERR;
+    if (db_rc != MDB_SUCCESS) return VOLK_DB_ERR;
     // 1 spare for sentinel. Always allocated even on zero matches.
-    LSUP_Key *tmp_ck = realloc (it->ck, sizeof (*it->ck) * (ct + 1));
-    if (!tmp_ck) return LSUP_MEM_ERR;
+    VOLK_Key *tmp_ck = realloc (it->ck, sizeof (*it->ck) * (ct + 1));
+    if (!tmp_ck) return VOLK_MEM_ERR;
     it->ck = tmp_ck;
 
     size_t i = 0;
@@ -819,14 +819,14 @@ mdbiter_next_key (MDBIterator *it)
 }
 
 
-static LSUP_rc
+static VOLK_rc
 mdbiter_next (
-        void *h, LSUP_BufferTriple *sspo, LSUP_Buffer **ctx_p)
+        void *h, VOLK_BufferTriple *sspo, VOLK_Buffer **ctx_p)
 {
     MDBIterator *it = h;
-    LSUP_rc rc = mdbiter_next_key (it);
+    VOLK_rc rc = mdbiter_next_key (it);
 
-    if (rc == LSUP_OK) {
+    if (rc == VOLK_OK) {
         if (sspo) {
             key_to_sterm (it->store, it->txn, it->spok[0], sspo->s);
             key_to_sterm (it->store, it->txn, it->spok[1], sspo->p);
@@ -840,10 +840,10 @@ mdbiter_next (
             // Preallocate.
             size_t i = 0;
             while (it->ck[i++]); // Include sentinel in count.
-            LSUP_Buffer *ctx;
+            VOLK_Buffer *ctx;
             LOG_TRACE("Allocating %lu context buffers + sentinel.", i - 1);
             ctx = malloc(i * sizeof (*ctx));
-            if (!ctx) return LSUP_MEM_ERR;
+            if (!ctx) return VOLK_MEM_ERR;
 
             for (i = 0; it->ck[i]; i++)
                 key_to_sterm (it->store, it->txn, it->ck[i], ctx + i);
@@ -873,17 +873,17 @@ mdbiter_free (void *h)
 }
 
 
-static LSUP_rc
+static VOLK_rc
 mdbstore_update_ctx (
-        void *h, const LSUP_Buffer *old_c, const LSUP_Buffer *new_c, void *th)
+        void *h, const VOLK_Buffer *old_c, const VOLK_Buffer *new_c, void *th)
 {
-    LSUP_rc rc = LSUP_NOACTION;
+    VOLK_rc rc = VOLK_NOACTION;
     MDBStore *store = h;
     unsigned char *trp_data = NULL;
 
-    LSUP_Key
-        old_ck = LSUP_buffer_hash (old_c),
-        new_ck = LSUP_buffer_hash (new_c);
+    VOLK_Key
+        old_ck = VOLK_buffer_hash (old_c),
+        new_ck = VOLK_buffer_hash (new_c);
     // lu_key, lu_data look up all triples with old context in c:spo, and
     // replace old c with new c.
     MDB_txn
@@ -909,7 +909,7 @@ mdbstore_update_ctx (
         log_error (
                 "Context key %lu already exists. Not replacing old graph.",
                 new_ck);
-        rc = LSUP_CONFLICT;
+        rc = VOLK_CONFLICT;
         goto close_i;
     }
 
@@ -921,21 +921,21 @@ mdbstore_update_ctx (
     rc = mdb_cursor_get (i_cur, &key, &data, MDB_SET);
     if (rc == MDB_NOTFOUND) {
         log_info ("No triples found associated with old context.");
-        rc = LSUP_NOACTION;
+        rc = VOLK_NOACTION;
         goto close_i;
     }
     if (rc != MDB_SUCCESS) {
-        rc = LSUP_DB_ERR;
+        rc = VOLK_DB_ERR;
         goto close_i;
     }
 
-    // From here on, it can only be LSUP_OK or error.
-    rc = LSUP_OK;
+    // From here on, it can only be VOLK_OK or error.
+    rc = VOLK_OK;
     size_t trp_ct;
     CHECK (rc = mdb_cursor_count (i_cur, &trp_ct), close_i);
     trp_data = malloc (trp_ct * TRP_KLEN);
     if (UNLIKELY (!trp_data)) {
-        rc = LSUP_MEM_ERR;
+        rc = VOLK_MEM_ERR;
         goto close_i;
     }
 
@@ -943,7 +943,7 @@ mdbstore_update_ctx (
     // deleted while cursors are active.
     rc = mdb_cursor_get (i_cur, &key, &data, MDB_GET_MULTIPLE);
     if (rc != MDB_SUCCESS) {
-        rc = rc == MDB_NOTFOUND ? LSUP_NOACTION : LSUP_DB_ERR;
+        rc = rc == MDB_NOTFOUND ? VOLK_NOACTION : VOLK_DB_ERR;
         goto close_i;
     }
     size_t loc_cur = 0;
@@ -1001,7 +1001,7 @@ close_d:
 close_i:
     mdb_cursor_close (i_cur);
 close_txn:
-    if (rc == LSUP_OK) {
+    if (rc == VOLK_OK) {
         RCCK (mdb_txn_commit (txn));
     } else mdb_txn_abort (txn);
 
@@ -1012,20 +1012,20 @@ finally:
 }
 
 
-static LSUP_rc
+static VOLK_rc
 mdbstore_remove (
-        void *h, const LSUP_Buffer *ss, const LSUP_Buffer *sp,
-        const LSUP_Buffer *so, const LSUP_Buffer *sc, void *th, size_t *ct)
+        void *h, const VOLK_Buffer *ss, const VOLK_Buffer *sp,
+        const VOLK_Buffer *so, const VOLK_Buffer *sc, void *th, size_t *ct)
 {
     MDBStore *store = h;
-    LSUP_rc
-        rc = LSUP_NOACTION,
+    VOLK_rc
+        rc = VOLK_NOACTION,
         db_rc = 0;
 
-    LSUP_Key ck = NULL_KEY;
+    VOLK_Key ck = NULL_KEY;
 
-    if (sc == NULL) sc = LSUP_default_ctx_buf;
-    ck = LSUP_buffer_hash (sc);
+    if (sc == NULL) sc = VOLK_default_ctx_buf;
+    ck = VOLK_buffer_hash (sc);
 
     MDB_txn *txn;
     mdb_txn_begin (store->env, (MDB_txn *) th, 0, &txn);
@@ -1042,10 +1042,10 @@ mdbstore_remove (
 
     // The lookup operates within the current (bottom) write transaction.
     MDBIterator *it = mdbstore_lookup (store, ss, sp, so, sc, txn, ct);
-    if (UNLIKELY (!it)) return LSUP_DB_ERR;
+    if (UNLIKELY (!it)) return VOLK_DB_ERR;
     if (ct) LOG_DEBUG("Found %lu triples to remove.", *ct);
 
-    while (mdbiter_next_key (it) == LSUP_OK) {
+    while (mdbiter_next_key (it) == VOLK_OK) {
         spok_v.mv_data = it->spok;
 
         db_rc = mdb_cursor_get (dcur, &spok_v, &ck_v, MDB_GET_BOTH);
@@ -1087,7 +1087,7 @@ mdbstore_remove (
     mdbiter_free (it);
 
     if (UNLIKELY (mdb_txn_commit (txn) != MDB_SUCCESS)) {
-        rc = LSUP_TXN_ERR;
+        rc = VOLK_TXN_ERR;
         goto fail;
     }
 
@@ -1096,15 +1096,15 @@ mdbstore_remove (
 fail:
     mdb_txn_abort (txn);
 
-    log_error ("Database error: %s", LSUP_strerror (db_rc));
+    log_error ("Database error: %s", VOLK_strerror (db_rc));
 
-    return rc == LSUP_TXN_ERR ? rc : LSUP_DB_ERR;
+    return rc == VOLK_TXN_ERR ? rc : VOLK_DB_ERR;
 }
 
 
 #if 0
 static int
-mdbstore_tkey_exists (MDBStore *store, LSUP_Key tkey)
+mdbstore_tkey_exists (MDBStore *store, VOLK_Key tkey)
 {
     int db_rc, rc;
     MDB_val key, data;
@@ -1122,8 +1122,8 @@ mdbstore_tkey_exists (MDBStore *store, LSUP_Key tkey)
     if (db_rc == MDB_SUCCESS) rc = 1;
     else if (db_rc == MDB_NOTFOUND) rc = 0;
     else {
-        log_error ("DB error: %s", LSUP_strerror (db_rc));
-        rc = LSUP_DB_ERR;
+        log_error ("DB error: %s", VOLK_strerror (db_rc));
+        rc = VOLK_DB_ERR;
     }
 
     if (cur) mdb_cursor_close (cur);
@@ -1143,10 +1143,10 @@ mdbstore_tkey_exists (MDBStore *store, LSUP_Key tkey)
  * @param[in] th transaction handle. It may be NULL, in which case a new
  * transaction is opened and closed for the operation.
  *
- * @return LSUP_OK on success; <0 on error.
+ * @return VOLK_OK on success; <0 on error.
  */
-static LSUP_rc
-mdbstore_add_term (void *h, const LSUP_Buffer *sterm, void *th)
+static VOLK_rc
+mdbstore_add_term (void *h, const VOLK_Buffer *sterm, void *th)
 {
     //LOG_TRACE("Adding term to MDB store: %s", sterm->addr);
     MDBStore *store = h;
@@ -1163,7 +1163,7 @@ mdbstore_add_term (void *h, const LSUP_Buffer *sterm, void *th)
     MDB_cursor *cur;
     CHECK (mdb_cursor_open (txn, store->dbi[IDX_T_ST], &cur), fail);
 
-    LSUP_Key k = LSUP_buffer_hash (sterm);
+    VOLK_Key k = VOLK_buffer_hash (sterm);
     key.mv_data = &k;
     key.mv_size = sizeof (k);
 
@@ -1175,20 +1175,20 @@ mdbstore_add_term (void *h, const LSUP_Buffer *sterm, void *th)
 
     if (!borrowed_txn) CHECK (db_rc = mdb_txn_commit (txn), fail);
 
-    return LSUP_OK;
+    return VOLK_OK;
 
 fail:
     if (!borrowed_txn) mdb_txn_abort (txn);
     LOG_TRACE("Aborted txn for adding term.");
-    return LSUP_DB_ERR;
+    return VOLK_DB_ERR;
 }
 
 
-LSUP_Buffer **
+VOLK_Buffer **
 mdbstore_ctx_list (void *h, void *th)
 {
     MDBStore *store = h;
-    LSUP_rc db_rc;
+    VOLK_rc db_rc;
     MDB_txn *txn;
     if (th) txn = th;
     else CHECK (mdb_txn_begin (store->env, NULL, MDB_RDONLY, &txn), fail);
@@ -1199,13 +1199,13 @@ mdbstore_ctx_list (void *h, void *th)
     MDB_val key, data;
     db_rc = mdb_cursor_get (cur, &key, &data, MDB_FIRST);
 
-    LSUP_Buffer **tdata = NULL;
+    VOLK_Buffer **tdata = NULL;
     size_t i = 0;
     while (db_rc == MDB_SUCCESS) {
         tdata = realloc (tdata, (i + 1) * sizeof (*tdata));
         if (UNLIKELY (!tdata)) goto fail;
         tdata[i] = BUF_DUMMY;
-        LSUP_Key tkey = *(LSUP_Key*)key.mv_data;
+        VOLK_Key tkey = *(VOLK_Key*)key.mv_data;
         CHECK (key_to_sterm (store, txn, tkey, tdata[i]), fail);
         db_rc = mdb_cursor_get (cur, &key, &data, MDB_NEXT_NODUP);
         i++;
@@ -1225,10 +1225,10 @@ fail:
 }
 
 
-const LSUP_StoreInt mdbstore_int = {
+const VOLK_StoreInt mdbstore_int = {
     .name           = "MDB Store",
-    .features       = LSUP_STORE_PERM | LSUP_STORE_CTX | LSUP_STORE_IDX
-                      | LSUP_STORE_TXN | LSUP_STORE_COW,
+    .features       = VOLK_STORE_PERM | VOLK_STORE_CTX | VOLK_STORE_IDX
+                      | VOLK_STORE_TXN | VOLK_STORE_COW,
 
     .setup_fn       = mdbstore_setup,
     .new_fn         = mdbstore_new,
@@ -1270,13 +1270,13 @@ const LSUP_StoreInt mdbstore_int = {
  * @param[in] th Transaction handle. This MUST be a valid pointer to an open
  *  RW transaction.
  */
-static LSUP_rc
+static VOLK_rc
 index_triple(
-        MDBStore *store, StoreOp op, LSUP_TripleKey spok, LSUP_Key ck,
+        MDBStore *store, StoreOp op, VOLK_TripleKey spok, VOLK_Key ck,
         MDB_txn *txn)
 {
     int db_rc;
-    LSUP_rc rc = LSUP_NOACTION;
+    VOLK_rc rc = VOLK_NOACTION;
     MDB_val v1, v2;
 
     LOG_TRACE("Indexing triple: {%lx %lx %lx}", spok[0], spok[1], spok[2]);
@@ -1295,9 +1295,9 @@ index_triple(
             mdb_cursor_open (txn, store->dbi[IDX_C_SPO], &cur);
             if (mdb_cursor_get (cur, &v1, &v2, MDB_GET_BOTH) == MDB_SUCCESS) {
                 db_rc = mdb_cursor_del (cur, 0);
-                if (db_rc != MDB_SUCCESS) return LSUP_DB_ERR;
+                if (db_rc != MDB_SUCCESS) return VOLK_DB_ERR;
 
-                rc = LSUP_OK;
+                rc = VOLK_OK;
             }
 
             mdb_cursor_close (cur);
@@ -1314,13 +1314,13 @@ index_triple(
             db_rc = mdb_put(
                     txn, store->dbi[IDX_C_SPO],
                     &v1, &v2, MDB_NODUPDATA);
-            if (db_rc != MDB_SUCCESS) return LSUP_DB_ERR;
-            if (db_rc != MDB_KEYEXIST) rc = LSUP_OK;
+            if (db_rc != MDB_SUCCESS) return VOLK_DB_ERR;
+            if (db_rc != MDB_KEYEXIST) rc = VOLK_OK;
         }
 
-    } else return LSUP_VALUE_ERR;
+    } else return VOLK_VALUE_ERR;
 
-    LSUP_DoubleKey dbl_keys[3] = {
+    VOLK_DoubleKey dbl_keys[3] = {
         {spok[1], spok[2]},  // po
         {spok[0], spok[2]},  // so
         {spok[0], spok[1]},  // sp
@@ -1355,7 +1355,7 @@ index_triple(
             db_rc = mdb_cursor_get (cur2, &v2, &v1, MDB_GET_BOTH);
             if (db_rc == MDB_SUCCESS) mdb_cursor_del (cur2, 0);
             // TODO error handling.
-            rc = LSUP_OK;
+            rc = VOLK_OK;
 
             mdb_cursor_close (cur2);
 
@@ -1368,8 +1368,8 @@ index_triple(
 
             db_rc = mdb_put (txn, db1, &v1, &v2, MDB_NODUPDATA);
 
-            if (db_rc == MDB_SUCCESS) rc = LSUP_OK;
-            else if (db_rc != MDB_KEYEXIST) return LSUP_DB_ERR;
+            if (db_rc == MDB_SUCCESS) rc = VOLK_OK;
+            else if (db_rc != MDB_KEYEXIST) return VOLK_DB_ERR;
 
             // 2-bound index.
             LOG_TRACE("Indexing in %s: ", db_labels[lookup_indices[i + 3]]);
@@ -1379,8 +1379,8 @@ index_triple(
 
             db_rc = mdb_put (txn, db2, &v2, &v1, MDB_NODUPDATA);
 
-            if (db_rc == MDB_SUCCESS) rc = LSUP_OK;
-            else if (db_rc != MDB_KEYEXIST) return LSUP_DB_ERR;
+            if (db_rc == MDB_SUCCESS) rc = VOLK_OK;
+            else if (db_rc != MDB_KEYEXIST) return VOLK_DB_ERR;
         }
     }
 
@@ -1397,7 +1397,7 @@ index_triple(
 inline static void
 it_next_0bound (MDBIterator *it)
 {
-    memcpy (it->spok, it->key.mv_data, sizeof (LSUP_TripleKey));
+    memcpy (it->spok, it->key.mv_data, sizeof (VOLK_TripleKey));
 
     it->rc = mdb_cursor_get (it->cur, &it->key, &it->data, MDB_NEXT);
 }
@@ -1412,7 +1412,7 @@ it_next_0bound (MDBIterator *it)
 inline static void
 it_next_1bound (MDBIterator *it)
 {
-    LSUP_DoubleKey *lu_dset = it->data.mv_data;
+    VOLK_DoubleKey *lu_dset = it->data.mv_data;
 
     it->spok[it->term_order[0]] = it->luk[0];
     it->spok[it->term_order[1]] = lu_dset[it->i][0];
@@ -1448,7 +1448,7 @@ it_next_1bound (MDBIterator *it)
 inline static void
 it_next_2bound (MDBIterator *it)
 {
-    LSUP_Key *lu_dset = it->data.mv_data;
+    VOLK_Key *lu_dset = it->data.mv_data;
 
     it->spok[it->term_order[0]] = it->luk[0];
     it->spok[it->term_order[1]] = it->luk[1];
@@ -1479,7 +1479,7 @@ it_next_3bound (MDBIterator *it)
 
 /* * * Term-specific lookups. * * */
 
-inline static LSUP_rc
+inline static VOLK_rc
 lookup_0bound (MDBIterator *it, size_t *ct)
 {
     LOG_DEBUG("Looking up 0 bound terms.");
@@ -1511,8 +1511,8 @@ lookup_0bound (MDBIterator *it, size_t *ct)
 
     it->rc = mdb_cursor_open (it->txn, it->store->dbi[IDX_SPO_C], &it->cur);
     if (it->rc != MDB_SUCCESS) {
-        log_error ("Database error: %s", LSUP_strerror (it->rc));
-        return LSUP_DB_ERR;
+        log_error ("Database error: %s", VOLK_strerror (it->rc));
+        return VOLK_DB_ERR;
     }
 
     it->rc = mdb_cursor_get (it->cur, &it->key, &it->data, MDB_FIRST);
@@ -1524,15 +1524,15 @@ lookup_0bound (MDBIterator *it, size_t *ct)
     it->iter_op_fn = it_next_0bound;
 
     if (it->rc != MDB_SUCCESS && it->rc != MDB_NOTFOUND) {
-        log_error ("Database error: %s", LSUP_strerror (it->rc));
-        return LSUP_DB_ERR;
+        log_error ("Database error: %s", VOLK_strerror (it->rc));
+        return VOLK_DB_ERR;
     }
 
-    return LSUP_OK;
+    return VOLK_OK;
 }
 
 
-inline static LSUP_rc
+inline static VOLK_rc
 lookup_1bound (uint8_t idx0, MDBIterator *it, size_t *ct)
 {
     it->term_order = (const uint8_t*)lookup_ordering_1bound[idx0];
@@ -1550,7 +1550,7 @@ lookup_1bound (uint8_t idx0, MDBIterator *it, size_t *ct)
         if (it->luc != NULL_KEY) {
             LOG_DEBUG("Counting in context: %lx", it->luc);
             MDBIterator *ct_it;
-            MALLOC_GUARD (ct_it, LSUP_MEM_ERR);
+            MALLOC_GUARD (ct_it, VOLK_MEM_ERR);
             /*
             memcpy (ct_it, it, sizeof (*ct_it));
             */
@@ -1565,11 +1565,11 @@ lookup_1bound (uint8_t idx0, MDBIterator *it, size_t *ct)
             ct_it->luc = it->luc;
             ct_it->i = 0;
 
-            LSUP_rc rc = lookup_1bound (idx0, ct_it, NULL);
+            VOLK_rc rc = lookup_1bound (idx0, ct_it, NULL);
             if (rc < 0) return rc;
 
-            LSUP_rc db_rc;
-            while (LSUP_END != (db_rc = mdbiter_next_key (ct_it))) {
+            VOLK_rc db_rc;
+            while (VOLK_END != (db_rc = mdbiter_next_key (ct_it))) {
                 if (UNLIKELY (db_rc < 0)) return db_rc;
                 (*ct)++;
             }
@@ -1594,15 +1594,15 @@ lookup_1bound (uint8_t idx0, MDBIterator *it, size_t *ct)
         it->rc = mdb_cursor_get (it->cur, &it->key, &it->data, MDB_GET_MULTIPLE);
 
     if (it->rc != MDB_SUCCESS && it->rc != MDB_NOTFOUND) {
-        log_error ("Database error: %s", LSUP_strerror (it->rc));
-        return LSUP_DB_ERR;
+        log_error ("Database error: %s", VOLK_strerror (it->rc));
+        return VOLK_DB_ERR;
     }
 
-    return LSUP_OK;
+    return VOLK_OK;
 }
 
 
-inline static LSUP_rc
+inline static VOLK_rc
 lookup_2bound(uint8_t idx0, uint8_t idx1, MDBIterator *it, size_t *ct)
 {
     uint8_t luk1_offset, luk2_offset;
@@ -1640,11 +1640,11 @@ lookup_2bound(uint8_t idx0, uint8_t idx1, MDBIterator *it, size_t *ct)
         log_error (
                 "Values %d and %d not found in lookup keys.",
                 idx0, idx1);
-        return LSUP_VALUE_ERR;
+        return VOLK_VALUE_ERR;
     }
 
     // Compose term keys in lookup key.
-    LSUP_DoubleKey luk;
+    VOLK_DoubleKey luk;
     luk[luk1_offset] = it->luk[0];
     luk[luk2_offset] = it->luk[1];
 
@@ -1659,7 +1659,7 @@ lookup_2bound(uint8_t idx0, uint8_t idx1, MDBIterator *it, size_t *ct)
         // the context is to loop over them.
         if (it->luc != NULL_KEY) {
             MDBIterator *ct_it;
-            MALLOC_GUARD (ct_it, LSUP_MEM_ERR);
+            MALLOC_GUARD (ct_it, VOLK_MEM_ERR);
 
             ct_it->store = it->store;
             ct_it->txn = it->txn;
@@ -1672,7 +1672,7 @@ lookup_2bound(uint8_t idx0, uint8_t idx1, MDBIterator *it, size_t *ct)
 
             lookup_2bound (idx0, idx1, ct_it, NULL);
 
-            while (mdbiter_next_key (ct_it) != LSUP_END) (*ct) ++;
+            while (mdbiter_next_key (ct_it) != VOLK_END) (*ct) ++;
 
             // Free the counter iterator without freeing the shared txn.
             if (ct_it->cur) mdb_cursor_close (ct_it->cur);
@@ -1694,15 +1694,15 @@ lookup_2bound(uint8_t idx0, uint8_t idx1, MDBIterator *it, size_t *ct)
         it->rc = mdb_cursor_get (it->cur, &it->key, &it->data, MDB_GET_MULTIPLE);
 
     if (it->rc != MDB_SUCCESS && it->rc != MDB_NOTFOUND) {
-        log_error ("Database error: %s", LSUP_strerror (it->rc));
-        return LSUP_DB_ERR;
+        log_error ("Database error: %s", VOLK_strerror (it->rc));
+        return VOLK_DB_ERR;
     }
 
-    return LSUP_OK;
+    return VOLK_OK;
 }
 
 
-inline static LSUP_rc
+inline static VOLK_rc
 lookup_3bound (MDBIterator *it, size_t *ct)
 {
     LOG_DEBUG(
@@ -1730,8 +1730,8 @@ lookup_3bound (MDBIterator *it, size_t *ct)
     it->rc = mdb_cursor_get (it->cur, &it->key, &it->data, MDB_GET_BOTH);
 
     if (it->rc != MDB_SUCCESS && it->rc != MDB_NOTFOUND) {
-        log_error ("Database error: %s", LSUP_strerror (it->rc));
-        return LSUP_DB_ERR;
+        log_error ("Database error: %s", VOLK_strerror (it->rc));
+        return VOLK_DB_ERR;
     }
 
     mdb_cursor_close (it->cur);
@@ -1740,9 +1740,9 @@ lookup_3bound (MDBIterator *it, size_t *ct)
     if (ct && it->rc == MDB_SUCCESS) *ct = 1;
 
     it->iter_op_fn = it_next_3bound;
-    memcpy (it->spok, it->luk, sizeof (LSUP_TripleKey));
+    memcpy (it->spok, it->luk, sizeof (VOLK_TripleKey));
 
-    return LSUP_OK;
+    return VOLK_OK;
 }
 
 

+ 208 - 208
src/term.c

@@ -1,6 +1,6 @@
 #include "tpl.h"
 
-#include "lsup/term.h"
+#include "volksdata/term.h"
 
 /** @brief tpl packing format for a term.
  *
@@ -9,7 +9,7 @@
  */
 #define TERM_PACK_FMT "csU"
 
-#define MAX_VALID_TERM_TYPE     LSUP_TERM_BNODE /* For type validation. */
+#define MAX_VALID_TERM_TYPE     VOLK_TERM_BNODE /* For type validation. */
 
 
 /*
@@ -33,25 +33,25 @@ struct iri_info_t {
 
 /// Key-term pair in term set.
 typedef struct keyed_term {
-    LSUP_Key            key;        ///< Key (hash) of the term.
-    LSUP_Term *         term;       ///< Term handle.
+    VOLK_Key            key;        ///< Key (hash) of the term.
+    VOLK_Term *         term;       ///< Term handle.
 } KeyedTerm;
 
 
 /** @brief Single link between a term and a term set.
  *
  * This link is not qualified and must not be used by itself. It belongs
- * in a #LSUP_LinkMap which qualifies all links of the same type.
+ * in a #VOLK_LinkMap which qualifies all links of the same type.
  */
 typedef struct link {
     KeyedTerm *         term;       ///< Linked term.
-    LSUP_TermSet *      tset;       ///< Term set linked to the term.
+    VOLK_TermSet *      tset;       ///< Term set linked to the term.
 } Link;
 
 
 /// Opaque link map iterator.
 struct link_map_iter {
-    const LSUP_LinkMap *map;        ///< Link map to iterate.
+    const VOLK_LinkMap *map;        ///< Link map to iterate.
     size_t              i;          ///< Linking term loop cursor.
     size_t              j;          ///< Term set loop cursor.
     const Link *        link;       ///< Current link being retrieved.
@@ -69,19 +69,19 @@ struct link_map_iter {
  * - Each KeyedTerm contains a Term and its hash.
  */
 typedef struct link_map {
-    LSUP_LinkType       type;       ///< Link type.
-    LSUP_Term          *linked_t;   ///< Linked term.
+    VOLK_LinkType       type;       ///< Link type.
+    VOLK_Term          *linked_t;   ///< Linked term.
     struct hashmap     *links;      ///< Map of #Link instances.
-} LSUP_LinkMap;
+} VOLK_LinkMap;
 
 
 /*
  * External variables.
  */
 
-uint32_t LSUP_default_dtype_key = 0;
-LSUP_Term *LSUP_default_datatype = NULL;
-LSUP_TermSet *LSUP_term_cache = NULL;
+uint32_t VOLK_default_dtype_key = 0;
+VOLK_Term *VOLK_default_datatype = NULL;
+VOLK_TermSet *VOLK_term_cache = NULL;
 
 
 /*
@@ -92,17 +92,17 @@ LSUP_TermSet *LSUP_term_cache = NULL;
 static const char *invalid_uri_chars = "<>\" {}|\\^`";
 
 /// Minimum valid type code.
-static const LSUP_TermType MIN_VALID_TYPE = LSUP_TERM_IRIREF;
-/// Maximum valid type code. Change this if adding to enum LSUP_TermType.
-static const LSUP_TermType MAX_VALID_TYPE = LSUP_TERM_BNODE;
+static const VOLK_TermType MIN_VALID_TYPE = VOLK_TERM_IRIREF;
+/// Maximum valid type code. Change this if adding to enum VOLK_TermType.
+static const VOLK_TermType MAX_VALID_TYPE = VOLK_TERM_BNODE;
 
 /*
  * Static prototypes.
  */
 
-static LSUP_rc
+static VOLK_rc
 term_init (
-        LSUP_Term *term, LSUP_TermType type, const char *data, void *metadata);
+        VOLK_Term *term, VOLK_TermType type, const char *data, void *metadata);
 
 
 /*
@@ -126,7 +126,7 @@ tset_cmp_fn (const void *a, const void *b, void *udata)
 
 static void
 tset_free_fn (void *item)
-{ LSUP_term_free (((KeyedTerm *) item)->term); }
+{ VOLK_term_free (((KeyedTerm *) item)->term); }
 
 
 /*
@@ -152,28 +152,28 @@ static void
 link_map_free_fn (void *item)
 {
     Link *link = item;
-    LSUP_term_free (link->term->term);
+    VOLK_term_free (link->term->term);
     free (link->term);
-    LSUP_term_set_free (link->tset);
+    VOLK_term_set_free (link->tset);
 }
 
 
-static LSUP_rc parse_iri (char *iri, MatchCoord coords[]);
+static VOLK_rc parse_iri (char *iri, MatchCoord coords[]);
 
 
  /*
  * Term API.
  */
 
-LSUP_Term *
-LSUP_term_new (
-        LSUP_TermType type, const char *data, void *metadata)
+VOLK_Term *
+VOLK_term_new (
+        VOLK_TermType type, const char *data, void *metadata)
 {
-    LSUP_Term *term;
+    VOLK_Term *term;
     CALLOC_GUARD (term, NULL);
 
     if (UNLIKELY (term_init (
-                    term, type, data, metadata) != LSUP_OK)) {
+                    term, type, data, metadata) != VOLK_OK)) {
         free (term);
         return NULL;
     }
@@ -182,27 +182,27 @@ LSUP_term_new (
 }
 
 
-LSUP_Term *
-LSUP_term_copy (const LSUP_Term *src)
+VOLK_Term *
+VOLK_term_copy (const VOLK_Term *src)
 {
     void *metadata = NULL;
 
-    if (src->type == LSUP_TERM_LITERAL)
+    if (src->type == VOLK_TERM_LITERAL)
         metadata = (void *) src->datatype;
-    else if (src->type == LSUP_TERM_LT_LITERAL)
+    else if (src->type == VOLK_TERM_LT_LITERAL)
         metadata = (void *) src->lang;
 
-    return LSUP_term_new (src->type, src->data, metadata);
+    return VOLK_term_new (src->type, src->data, metadata);
 }
 
 
-LSUP_Term *
-LSUP_term_new_from_buffer (const LSUP_Buffer *sterm)
+VOLK_Term *
+VOLK_term_new_from_buffer (const VOLK_Buffer *sterm)
 {
     if (UNLIKELY (!sterm)) return NULL;
 
-    LSUP_Term *term = NULL;
-    LSUP_TermType type = LSUP_TERM_UNDEFINED;
+    VOLK_Term *term = NULL;
+    VOLK_TermType type = VOLK_TERM_UNDEFINED;
     char *data = NULL;
     void *metadata;
 
@@ -220,9 +220,9 @@ LSUP_term_new_from_buffer (const LSUP_Buffer *sterm)
         goto finally;
     }
 
-    if (type == LSUP_TERM_LT_LITERAL)
-        term = LSUP_lt_literal_new (data, (char *)&metadata);
-    else term = LSUP_term_new (type, data, metadata);
+    if (type == VOLK_TERM_LT_LITERAL)
+        term = VOLK_lt_literal_new (data, (char *)&metadata);
+    else term = VOLK_term_new (type, data, metadata);
 
 finally:
     tpl_free (tn);
@@ -232,28 +232,28 @@ finally:
 }
 
 
-LSUP_Term *
-LSUP_iriref_new_abs (const LSUP_Term *root, const LSUP_Term *iri)
+VOLK_Term *
+VOLK_iriref_new_abs (const VOLK_Term *root, const VOLK_Term *iri)
 {
-    if (iri->type != LSUP_TERM_IRIREF) {
+    if (iri->type != VOLK_TERM_IRIREF) {
         log_error ("Provided path is not an IRI.");
         return NULL;
     }
-    if (root->type != LSUP_TERM_IRIREF) {
+    if (root->type != VOLK_TERM_IRIREF) {
         log_error ("Provided root is not an IRI.");
         return NULL;
     }
 
     char
         *data,
-        *pfx = LSUP_iriref_prefix (iri);
+        *pfx = VOLK_iriref_prefix (iri);
 
     if (strlen (pfx) > 0) data = iri->data;
 
     else if (iri->data[0] == '/') {
         free (pfx);
 
-        pfx = LSUP_iriref_prefix (root);
+        pfx = VOLK_iriref_prefix (root);
         data = malloc (strlen (iri->data) + strlen (pfx) + 1);
         if (!data) return NULL;
 
@@ -267,21 +267,21 @@ LSUP_iriref_new_abs (const LSUP_Term *root, const LSUP_Term *iri)
     }
     free (pfx);
 
-    LSUP_Term *ret = LSUP_iriref_new (data);
+    VOLK_Term *ret = VOLK_iriref_new (data);
     if (data != iri->data) free (data);
 
     return ret;
 }
 
 
-LSUP_Term *
-LSUP_iriref_new_rel (const LSUP_Term *root, const LSUP_Term *iri)
+VOLK_Term *
+VOLK_iriref_new_rel (const VOLK_Term *root, const VOLK_Term *iri)
 {
-    if (iri->type != LSUP_TERM_IRIREF) {
+    if (iri->type != VOLK_TERM_IRIREF) {
         log_error ("Provided path is not an IRI.");
         return NULL;
     }
-    if (root->type != LSUP_TERM_IRIREF) {
+    if (root->type != VOLK_TERM_IRIREF) {
         log_error ("Provided root is not an IRI.");
         return NULL;
     }
@@ -290,51 +290,51 @@ LSUP_iriref_new_rel (const LSUP_Term *root, const LSUP_Term *iri)
             strstr (iri->data, root->data) == iri->data ?
             strlen (root->data) : 0);
 
-    return LSUP_iriref_new (iri->data + offset);
+    return VOLK_iriref_new (iri->data + offset);
 }
 
 
-LSUP_Buffer *
-LSUP_term_serialize (const LSUP_Term *term)
+VOLK_Buffer *
+VOLK_term_serialize (const VOLK_Term *term)
 {
     /*
      * In serializing a term, the fact that two terms of different types may
      * be semantically identical must be taken into account. Specifically, a
      * namespace-prefixed IRI ref is identical to its fully qualified version,
-     * and a LSUP_TERM_LT_LITERAL with no language tag is identical to a
-     * LSUP_TERM_LITERAL of xsd:string type, made up of the same string. Such
+     * and a VOLK_TERM_LT_LITERAL with no language tag is identical to a
+     * VOLK_TERM_LITERAL of xsd:string type, made up of the same string. Such
      * terms must have identical serializations.
      */
 
     if (UNLIKELY (!term)) return NULL;
 
-    LSUP_Term *tmp_term;
+    VOLK_Term *tmp_term;
     void *metadata = NULL;
 
-    if (term->type == LSUP_TERM_LT_LITERAL) {
+    if (term->type == VOLK_TERM_LT_LITERAL) {
         // For LT literals with empty lang tag, convert to a normal xsd:string.
         if (strlen (term->lang) == 0)
-            tmp_term = LSUP_literal_new (term->data, NULL);
+            tmp_term = VOLK_literal_new (term->data, NULL);
         else {
-            tmp_term = LSUP_lt_literal_new (term->data, (char *) term->lang);
+            tmp_term = VOLK_lt_literal_new (term->data, (char *) term->lang);
             memcpy (&metadata, tmp_term->lang, sizeof (metadata));
         }
-    } else if (term->type == LSUP_TERM_LITERAL) {
-        tmp_term = LSUP_term_new (term->type, term->data, term->datatype);
+    } else if (term->type == VOLK_TERM_LITERAL) {
+        tmp_term = VOLK_term_new (term->type, term->data, term->datatype);
         metadata = tmp_term->datatype;
-    } else tmp_term = LSUP_term_copy (term);
+    } else tmp_term = VOLK_term_copy (term);
 
-    LSUP_Buffer *sterm;
+    VOLK_Buffer *sterm;
     CALLOC_GUARD (sterm, NULL);
 
     //LOG_TRACE("Effective term being serialized: %s", tmp_term->data);
     int rc = tpl_jot (
             TPL_MEM, &sterm->addr, &sterm->size, TERM_PACK_FMT,
             &tmp_term->type, &tmp_term->data, &metadata);
-    LSUP_term_free (tmp_term);
+    VOLK_term_free (tmp_term);
 
     if (rc != 0) {
-        LSUP_buffer_free (sterm);
+        VOLK_buffer_free (sterm);
         return NULL;
     }
 
@@ -342,37 +342,37 @@ LSUP_term_serialize (const LSUP_Term *term)
 }
 
 
-LSUP_Key
-LSUP_term_hash (const LSUP_Term *term)
+VOLK_Key
+VOLK_term_hash (const VOLK_Term *term)
 {
-    LSUP_Buffer *buf;
+    VOLK_Buffer *buf;
 
     if (UNLIKELY (!term)) buf = BUF_DUMMY;
-    else buf = LSUP_term_serialize (term);
+    else buf = VOLK_term_serialize (term);
 
-    LSUP_Key key = LSUP_buffer_hash (buf);
+    VOLK_Key key = VOLK_buffer_hash (buf);
 
-    LSUP_buffer_free (buf);
+    VOLK_buffer_free (buf);
 
     return key;
 }
 
 
 void
-LSUP_term_free (LSUP_Term *term)
+VOLK_term_free (VOLK_Term *term)
 {
     if (UNLIKELY (!term)) return;
 
-    if (term->type == LSUP_TERM_IRIREF) free (term->iri_info);
+    if (term->type == VOLK_TERM_IRIREF) free (term->iri_info);
     free (term->data);
     free (term);
 }
 
 
 char *
-LSUP_iriref_prefix (const LSUP_Term *iri)
+VOLK_iriref_prefix (const VOLK_Term *iri)
 {
-    if (iri->type != LSUP_TERM_IRIREF) {
+    if (iri->type != VOLK_TERM_IRIREF) {
         log_error ("Term is not a IRI ref type.");
         return NULL;
     }
@@ -386,9 +386,9 @@ LSUP_iriref_prefix (const LSUP_Term *iri)
 
 
 char *
-LSUP_iriref_path (const LSUP_Term *iri)
+VOLK_iriref_path (const VOLK_Term *iri)
 {
-    if (iri->type != LSUP_TERM_IRIREF) {
+    if (iri->type != VOLK_TERM_IRIREF) {
         log_error ("Term is not a IRI ref type.");
         return NULL;
     }
@@ -402,9 +402,9 @@ LSUP_iriref_path (const LSUP_Term *iri)
 
 
 char *
-LSUP_iriref_frag (const LSUP_Term *iri)
+VOLK_iriref_frag (const VOLK_Term *iri)
 {
-    if (iri->type != LSUP_TERM_IRIREF) {
+    if (iri->type != VOLK_TERM_IRIREF) {
         log_error ("Term is not a IRI ref type.");
         return NULL;
     }
@@ -421,13 +421,13 @@ LSUP_iriref_frag (const LSUP_Term *iri)
  * Triple API.
  */
 
-LSUP_Triple *
-LSUP_triple_new(LSUP_Term *s, LSUP_Term *p, LSUP_Term *o)
+VOLK_Triple *
+VOLK_triple_new(VOLK_Term *s, VOLK_Term *p, VOLK_Term *o)
 {
-    LSUP_Triple *spo = malloc (sizeof (*spo));
+    VOLK_Triple *spo = malloc (sizeof (*spo));
     if (!spo) return NULL;
 
-    if (UNLIKELY (LSUP_triple_init (spo, s, p, o))) {
+    if (UNLIKELY (VOLK_triple_init (spo, s, p, o))) {
         free (spo);
         return NULL;
     }
@@ -436,45 +436,45 @@ LSUP_triple_new(LSUP_Term *s, LSUP_Term *p, LSUP_Term *o)
 }
 
 
-LSUP_Triple *
-LSUP_triple_new_from_btriple (const LSUP_BufferTriple *sspo)
+VOLK_Triple *
+VOLK_triple_new_from_btriple (const VOLK_BufferTriple *sspo)
 {
-    LSUP_Triple *spo = malloc (sizeof (*spo));
+    VOLK_Triple *spo = malloc (sizeof (*spo));
     if (!spo) return NULL;
 
-    spo->s = LSUP_term_new_from_buffer (sspo->s);
-    spo->p = LSUP_term_new_from_buffer (sspo->p);
-    spo->o = LSUP_term_new_from_buffer (sspo->o);
+    spo->s = VOLK_term_new_from_buffer (sspo->s);
+    spo->p = VOLK_term_new_from_buffer (sspo->p);
+    spo->o = VOLK_term_new_from_buffer (sspo->o);
 
     return spo;
 }
 
 
-LSUP_BufferTriple *
-LSUP_triple_serialize (const LSUP_Triple *spo)
+VOLK_BufferTriple *
+VOLK_triple_serialize (const VOLK_Triple *spo)
 {
-    LSUP_BufferTriple *sspo = malloc (sizeof (*sspo));
+    VOLK_BufferTriple *sspo = malloc (sizeof (*sspo));
     if (!sspo) return NULL;
 
-    sspo->s = LSUP_term_serialize (spo->s);
-    sspo->p = LSUP_term_serialize (spo->p);
-    sspo->o = LSUP_term_serialize (spo->o);
+    sspo->s = VOLK_term_serialize (spo->s);
+    sspo->p = VOLK_term_serialize (spo->p);
+    sspo->o = VOLK_term_serialize (spo->o);
 
     return sspo;
 }
 
 
-LSUP_rc
-LSUP_triple_init (LSUP_Triple *spo, LSUP_Term *s, LSUP_Term *p, LSUP_Term *o)
+VOLK_rc
+VOLK_triple_init (VOLK_Triple *spo, VOLK_Term *s, VOLK_Term *p, VOLK_Term *o)
 {
     /* FIXME TRP_DUMMY is a problem here.
-    if (! LSUP_IS_IRI (s) && s->type != LSUP_TERM_BNODE) {
+    if (! VOLK_IS_IRI (s) && s->type != VOLK_TERM_BNODE) {
         log_error ("Subject is not of a valid term type: %d", s->type);
-        return LSUP_VALUE_ERR;
+        return VOLK_VALUE_ERR;
     }
-    if (! LSUP_IS_IRI (p)) {
+    if (! VOLK_IS_IRI (p)) {
         log_error ("Predicate is not of a valid term type: %d", p->type);
-        return LSUP_VALUE_ERR;
+        return VOLK_VALUE_ERR;
     }
     */
 
@@ -482,29 +482,29 @@ LSUP_triple_init (LSUP_Triple *spo, LSUP_Term *s, LSUP_Term *p, LSUP_Term *o)
     spo->p = p;
     spo->o = o;
 
-    return LSUP_OK;
+    return VOLK_OK;
 }
 
 
 void
-LSUP_triple_done (LSUP_Triple *spo)
+VOLK_triple_done (VOLK_Triple *spo)
 {
     if (UNLIKELY (!spo)) return;
 
-    LSUP_term_free (spo->s);
-    LSUP_term_free (spo->p);
-    LSUP_term_free (spo->o);
+    VOLK_term_free (spo->s);
+    VOLK_term_free (spo->p);
+    VOLK_term_free (spo->o);
 }
 
 
 void
-LSUP_triple_free (LSUP_Triple *spo)
+VOLK_triple_free (VOLK_Triple *spo)
 {
     if (UNLIKELY (!spo)) return;
 
-    LSUP_term_free (spo->s);
-    LSUP_term_free (spo->p);
-    LSUP_term_free (spo->o);
+    VOLK_term_free (spo->s);
+    VOLK_term_free (spo->p);
+    VOLK_term_free (spo->o);
 
     free (spo);
 }
@@ -514,12 +514,12 @@ LSUP_triple_free (LSUP_Triple *spo)
  * Multi-add functions.
  */
 
-LSUP_TermSet *
-LSUP_term_set_new ()
+VOLK_TermSet *
+VOLK_term_set_new ()
 {
     // Capacity of 4 is an arbitrary guess.
-    LSUP_TermSet *ts = hashmap_new (
-            sizeof (KeyedTerm), 4, LSUP_HASH_SEED, 0,
+    VOLK_TermSet *ts = hashmap_new (
+            sizeof (KeyedTerm), 4, VOLK_HASH_SEED, 0,
             tset_hash_fn, tset_cmp_fn, tset_free_fn, NULL);
     if (UNLIKELY (hashmap_oom (ts))) return NULL;
 
@@ -527,27 +527,27 @@ LSUP_term_set_new ()
 }
 
 
-LSUP_rc
-LSUP_term_set_add (LSUP_TermSet *ts, LSUP_Term *term, LSUP_Term **existing)
+VOLK_rc
+VOLK_term_set_add (VOLK_TermSet *ts, VOLK_Term *term, VOLK_Term **existing)
 {
-    LSUP_Hash key = LSUP_term_hash (term);
+    VOLK_Hash key = VOLK_term_hash (term);
     KeyedTerm entry_s = {.key=key, .term=term};
 
     const KeyedTerm *ex = hashmap_get (ts, &entry_s);
     if (ex) {
         if (existing) *existing = ex->term;
-        return LSUP_NOACTION;
+        return VOLK_NOACTION;
     }
 
     hashmap_set (ts, &entry_s);
-    if (hashmap_oom (ts)) return LSUP_MEM_ERR;
+    if (hashmap_oom (ts)) return VOLK_MEM_ERR;
 
-    return LSUP_OK;
+    return VOLK_OK;
 }
 
 
-const LSUP_Term *
-LSUP_term_set_get (LSUP_TermSet *ts, LSUP_Key key)
+const VOLK_Term *
+VOLK_term_set_get (VOLK_TermSet *ts, VOLK_Key key)
 {
     const KeyedTerm *entry = hashmap_get (ts, &(KeyedTerm){.key=key});
     if (entry) LOG_TRACE("ID found for key %lx: %s", key, entry->term->data);
@@ -557,20 +557,20 @@ LSUP_term_set_get (LSUP_TermSet *ts, LSUP_Key key)
 }
 
 
-LSUP_rc
-LSUP_term_set_next (LSUP_TermSet *ts, size_t *i, LSUP_Term **term)
+VOLK_rc
+VOLK_term_set_next (VOLK_TermSet *ts, size_t *i, VOLK_Term **term)
 {
     KeyedTerm *kt = NULL;
-    if (!hashmap_iter (ts, i, (void **)&kt)) return LSUP_END;
+    if (!hashmap_iter (ts, i, (void **)&kt)) return VOLK_END;
 
     if (term) *term = kt->term;
 
-    return LSUP_OK;
+    return VOLK_OK;
 }
 
 
 void
-LSUP_term_set_free (LSUP_TermSet *ts)
+VOLK_term_set_free (VOLK_TermSet *ts)
 {
     if (UNLIKELY (!ts)) return;
     hashmap_free (ts);
@@ -578,51 +578,51 @@ LSUP_term_set_free (LSUP_TermSet *ts)
 
 
 size_t
-LSUP_term_set_size (LSUP_TermSet *ts)
+VOLK_term_set_size (VOLK_TermSet *ts)
 { return hashmap_count (ts); }
 
 
-LSUP_LinkMap *
-LSUP_link_map_new (const LSUP_Term *linked_term, LSUP_LinkType type)
+VOLK_LinkMap *
+VOLK_link_map_new (const VOLK_Term *linked_term, VOLK_LinkType type)
 {
-    LSUP_LinkMap *lm;
+    VOLK_LinkMap *lm;
     MALLOC_GUARD (lm, NULL);
     lm->type = type;
     lm->links = hashmap_new (
-            sizeof (Link), 0, LSUP_HASH_SEED, 0,
+            sizeof (Link), 0, VOLK_HASH_SEED, 0,
             link_map_hash_fn, link_map_cmp_fn, link_map_free_fn, NULL);
     if (!linked_term) {
         log_error ("term must not be NULL.");
         free (lm);
         return NULL;
     }
-    lm->linked_t = LSUP_term_copy (linked_term);
+    lm->linked_t = VOLK_term_copy (linked_term);
 
     return lm;
 }
 
 
 void
-LSUP_link_map_free (LSUP_LinkMap *lm)
+VOLK_link_map_free (VOLK_LinkMap *lm)
 {
     hashmap_free (lm->links);
-    LSUP_term_free (lm->linked_t);
+    VOLK_term_free (lm->linked_t);
     free (lm);
 }
 
 
-LSUP_LinkType
-LSUP_link_map_type (const LSUP_LinkMap *map)
+VOLK_LinkType
+VOLK_link_map_type (const VOLK_LinkMap *map)
 { return map->type; }
 
 
 // TODO Memory error handling.
-LSUP_rc
-LSUP_link_map_add (
-        LSUP_LinkMap *lmap, LSUP_Term *term, LSUP_TermSet *tset)
+VOLK_rc
+VOLK_link_map_add (
+        VOLK_LinkMap *lmap, VOLK_Term *term, VOLK_TermSet *tset)
 {
     // Keyed term to look up the link term and insert it, if necessary.
-    KeyedTerm entry_s = {.key=LSUP_term_hash (term), .term=term};
+    KeyedTerm entry_s = {.key=VOLK_term_hash (term), .term=term};
 
     const Link *ex = hashmap_get (lmap->links, &(Link){.term=&entry_s});
     if (ex) {
@@ -638,32 +638,32 @@ LSUP_link_map_add (
                     kt->term->data, ex->term->term->data);
             if (hashmap_get (ex->tset, kt))
                 // Term already exist, free the new one and move on.
-                LSUP_term_free (kt->term);
+                VOLK_term_free (kt->term);
             else
                 // Insert KeyedTerm, the term set now owns the underlying term.
                 hashmap_set (ex->tset, kt);
         }
         // Free link term that hasn't been used.
-        LSUP_term_free (term);
+        VOLK_term_free (term);
     } else {
         // Add the new term and the termset wholesale.
         LOG_TRACE("Adding new linking term %s.", term->data);
         // Allocate inserted member on heap, it will be owned by the map.
         KeyedTerm *ins;
-        MALLOC_GUARD (ins, LSUP_MEM_ERR);
+        MALLOC_GUARD (ins, VOLK_MEM_ERR);
         memcpy (ins, &entry_s, sizeof (entry_s));
         Link link = {.term=ins, .tset=tset};
         hashmap_set (lmap->links, &link);
     }
 
-    return LSUP_OK;
+    return VOLK_OK;
 }
 
 
-LSUP_LinkMapIterator *
-LSUP_link_map_iter_new (const LSUP_LinkMap *lmap)
+VOLK_LinkMapIterator *
+VOLK_link_map_iter_new (const VOLK_LinkMap *lmap)
 {
-    LSUP_LinkMapIterator *it;
+    VOLK_LinkMapIterator *it;
     CALLOC_GUARD (it, NULL);
     it->map = lmap;
 
@@ -673,32 +673,32 @@ LSUP_link_map_iter_new (const LSUP_LinkMap *lmap)
 
 // This leaves the link and link map references intact.
 void
-LSUP_link_map_iter_free (LSUP_LinkMapIterator *it) { free (it); }
+VOLK_link_map_iter_free (VOLK_LinkMapIterator *it) { free (it); }
 
 
-LSUP_rc
-LSUP_link_map_next (
-        LSUP_LinkMapIterator *it, LSUP_Term **lt, LSUP_TermSet **ts)
+VOLK_rc
+VOLK_link_map_next (
+        VOLK_LinkMapIterator *it, VOLK_Term **lt, VOLK_TermSet **ts)
 {
     if (!hashmap_iter (it->map->links, &it->i, (void **)&it->link))
-        return LSUP_END;
+        return VOLK_END;
 
     *lt = it->link->term->term;
     *ts = it->link->tset;
 
-    return LSUP_OK;
+    return VOLK_OK;
 }
 
 
 // TODO dismantle if the only triple generator is for the graph.
-LSUP_rc
-LSUP_link_map_triples (
-        LSUP_LinkMapIterator *it, LSUP_Triple *spo)
+VOLK_rc
+VOLK_link_map_triples (
+        VOLK_LinkMapIterator *it, VOLK_Triple *spo)
 {
     // Assign external (related) term.
-    if (it->map->type == LSUP_LINK_INBOUND)
+    if (it->map->type == VOLK_LINK_INBOUND)
         spo->o = it->map->linked_t;
-    else if (it->map->type == LSUP_LINK_OUTBOUND)
+    else if (it->map->type == VOLK_LINK_OUTBOUND)
         spo->s = it->map->linked_t;
     else spo->p = it->map->linked_t;
 
@@ -710,21 +710,21 @@ ext_loop:
     // Advance external counter and start new internal loop.
     it->j = 0;
     if (!hashmap_iter (it->map->links, &it->i, (void **)&it->link))
-        return LSUP_END;
+        return VOLK_END;
 int_loop:
     // If end of the term set is reached, start with a new linking term.
     if (!hashmap_iter (it->link->tset, &it->j, (void **)&kt)) goto ext_loop;
 
     // Continue pulling from term set.
     // Assign linking term.
-    if (it->map->type == LSUP_LINK_EDGE) spo->s = it->link->term->term;
+    if (it->map->type == VOLK_LINK_EDGE) spo->s = it->link->term->term;
     else spo->p = it->link->term->term;
 
     // Assign term in term set.
-    if (it->map->type == LSUP_LINK_INBOUND) spo->s = kt->term;
+    if (it->map->type == VOLK_LINK_INBOUND) spo->s = kt->term;
     else spo->o = kt->term;
 
-    return LSUP_OK;
+    return VOLK_OK;
 }
 
 
@@ -732,37 +732,37 @@ int_loop:
  * Static functions.
  */
 
-static LSUP_rc
+static VOLK_rc
 term_init (
-        LSUP_Term *term, LSUP_TermType type,
+        VOLK_Term *term, VOLK_TermType type,
         const char *data, void *metadata)
 {
     // Exit early if environment is not initialized.
-    // EXCEPT for IRIRef which is used inside of LSUP_init().
-    if (!LSUP_IS_INIT && type != LSUP_TERM_IRIREF)
-        return LSUP_ENV_ERR;
+    // EXCEPT for IRIRef which is used inside of VOLK_init().
+    if (!VOLK_IS_INIT && type != VOLK_TERM_IRIREF)
+        return VOLK_ENV_ERR;
 
     // Undefined type. Make quick work of it.
-    if (type == LSUP_TERM_UNDEFINED) {
+    if (type == VOLK_TERM_UNDEFINED) {
         term->type = type;
         if (data) {
             term->data = malloc (strlen (data) + 1);
-            if (UNLIKELY (!term->data)) return LSUP_MEM_ERR;
+            if (UNLIKELY (!term->data)) return VOLK_MEM_ERR;
             strcpy (term->data, data);
         }
-        return LSUP_OK;
+        return VOLK_OK;
     }
 
     if (type < MIN_VALID_TYPE || type > MAX_VALID_TYPE) {
         log_error ("%d is not a valid term type.", type);
-        return LSUP_VALUE_ERR;
+        return VOLK_VALUE_ERR;
     }
 
     term->type = type;
 
     if (data) {
         // Validate IRI.
-        if (term->type == LSUP_TERM_IRIREF) {
+        if (term->type == VOLK_TERM_IRIREF) {
             char *fquri = (char *) data;
 
             if (strpbrk (fquri, invalid_uri_chars) != NULL) {
@@ -771,18 +771,18 @@ term_init (
                         invalid_uri_chars, fquri);
 #if 0
                 // TODO This causes W3C TTL test #29 to fail. Remove?
-                return LSUP_VALUE_ERR;
+                return VOLK_VALUE_ERR;
 #endif
             }
 
             // Capture interesting IRI parts.
             MatchCoord matches[7] = {};  // Initialize all to 0.
-            if (UNLIKELY (parse_iri (fquri, matches) != LSUP_OK)) {
+            if (UNLIKELY (parse_iri (fquri, matches) != VOLK_OK)) {
                 log_error ("Error matching URI pattern.");
 
-                return LSUP_VALUE_ERR;
+                return VOLK_VALUE_ERR;
             }
-            MALLOC_GUARD (term->iri_info, LSUP_MEM_ERR);
+            MALLOC_GUARD (term->iri_info, VOLK_MEM_ERR);
 
             term->iri_info->prefix = matches[1];
             term->iri_info->path = matches[4];
@@ -793,19 +793,19 @@ term_init (
 
     } else {
         // No data. Make up a random UUID or URI if allowed.
-        if (type == LSUP_TERM_IRIREF || type == LSUP_TERM_BNODE) {
+        if (type == VOLK_TERM_IRIREF || type == VOLK_TERM_BNODE) {
             uuid_t uuid;
             uuid_generate_random (uuid);
 
             uuid_str_t uuid_str;
             uuid_unparse_lower (uuid, uuid_str);
 
-            if (type == LSUP_TERM_IRIREF) {
+            if (type == VOLK_TERM_IRIREF) {
                 term->data = malloc (UUID4_URN_SIZE);
                 snprintf (
                         term->data, UUID4_URN_SIZE, "urn:uuid4:%s", uuid_str);
 
-                MALLOC_GUARD (term->iri_info, LSUP_MEM_ERR);
+                MALLOC_GUARD (term->iri_info, VOLK_MEM_ERR);
 
                 // Allocate IRI match patterns manually.
                 term->iri_info->prefix.offset = 0;
@@ -818,14 +818,14 @@ term_init (
             } else term->data = strdup (uuid_str);
         } else {
             log_error ("No data provided for term.");
-            return LSUP_VALUE_ERR;
+            return VOLK_VALUE_ERR;
         }
     }
 
-    if (term->type == LSUP_TERM_LT_LITERAL) {
+    if (term->type == VOLK_TERM_LT_LITERAL) {
         if (!metadata) {
             log_warn ("Lang tag is NULL. Creating a non-tagged literal.");
-            term->type = LSUP_TERM_LITERAL;
+            term->type = VOLK_TERM_LITERAL;
         } else {
             // FIXME metadata should be const all across.
             char *lang_str = (char *) metadata;
@@ -834,45 +834,45 @@ term_init (
             strncpy(term->lang, lang_str, sizeof (term->lang) - 1);
             if (strlen (term->lang) < 1) {
                 log_error ("Lang tag cannot be an empty string.");
-                return LSUP_VALUE_ERR;
+                return VOLK_VALUE_ERR;
             }
             term->lang[7] = '\0';
         }
     }
 
-    if (term->type == LSUP_TERM_LITERAL) {
+    if (term->type == VOLK_TERM_LITERAL) {
         term->datatype = metadata;
-        if (! term->datatype) term->datatype = LSUP_default_datatype;
+        if (! term->datatype) term->datatype = VOLK_default_datatype;
         LOG_TRACE("Storing data type: %s", term->datatype->data);
 
-        if (term->datatype->type != LSUP_TERM_IRIREF) {
+        if (term->datatype->type != VOLK_TERM_IRIREF) {
             log_error (
                     "Literal data type is not an IRI: %s",
                     term->datatype->data);
 
-            return LSUP_VALUE_ERR;
+            return VOLK_VALUE_ERR;
         }
 
-        LSUP_Term *ex = NULL;
-        LSUP_term_set_add (LSUP_term_cache, term->datatype, &ex);
+        VOLK_Term *ex = NULL;
+        VOLK_term_set_add (VOLK_term_cache, term->datatype, &ex);
         if (ex && ex != term->datatype) {
             // Replace datatype handle with the one in term cache, and free
             // the new one.
-            if (term->datatype != LSUP_default_datatype)
-                LSUP_term_free (term->datatype);
+            if (term->datatype != VOLK_default_datatype)
+                VOLK_term_free (term->datatype);
             term->datatype = ex;
         }
 
         //LOG_TRACE("Datatype address: %p", term->datatype);
-        LOG_TRACE("Datatype hash: %lx", LSUP_term_hash (term->datatype));
+        LOG_TRACE("Datatype hash: %lx", VOLK_term_hash (term->datatype));
 
-    } else if (term->type == LSUP_TERM_BNODE) {
+    } else if (term->type == VOLK_TERM_BNODE) {
         // TODO This is not usable for global skolemization.
-        term->bnode_id = LSUP_HASH (
-                term->data, strlen (term->data) + 1, LSUP_HASH_SEED);
+        term->bnode_id = VOLK_HASH (
+                term->data, strlen (term->data) + 1, VOLK_HASH_SEED);
     }
 
-    return LSUP_OK;
+    return VOLK_OK;
 }
 
 
@@ -909,7 +909,7 @@ term_init (
  * and the second one stores the length of the match. A length of 0 indicates
  * no match.
  */
-static LSUP_rc
+static VOLK_rc
 parse_iri (char *iri_str, MatchCoord coord[]) {
     char *cur = iri_str;
     size_t iri_len = strlen (iri_str);
@@ -1000,7 +1000,7 @@ parse_iri (char *iri_str, MatchCoord coord[]) {
     coord[0].size = iri_len;
     //LOG_DEBUG("Full match: %lu, %lu", coord[0].offset, coord[0].size);
 
-    return LSUP_OK;
+    return VOLK_OK;
 }
 
 
@@ -1008,12 +1008,12 @@ parse_iri (char *iri_str, MatchCoord coord[]) {
  * Extern inline functions.
  */
 
-LSUP_Key LSUP_term_hash (const LSUP_Term *term);
-LSUP_Term *LSUP_iriref_new (const char *data);
-LSUP_Term *LSUP_iriref_new_ns (const char *data);
-LSUP_Term *LSUP_literal_new (const char *data, LSUP_Term *datatype);
-LSUP_Term *LSUP_lt_literal_new (const char *data, char *lang);
-LSUP_Term *LSUP_bnode_new (const char *data);
-bool LSUP_term_equals (const LSUP_Term *term1, const LSUP_Term *term2);
-LSUP_Term *LSUP_triple_pos (const LSUP_Triple *trp, LSUP_TriplePos n);
-LSUP_Key LSUP_triple_hash (const LSUP_Triple *trp);
+VOLK_Key VOLK_term_hash (const VOLK_Term *term);
+VOLK_Term *VOLK_iriref_new (const char *data);
+VOLK_Term *VOLK_iriref_new_ns (const char *data);
+VOLK_Term *VOLK_literal_new (const char *data, VOLK_Term *datatype);
+VOLK_Term *VOLK_lt_literal_new (const char *data, char *lang);
+VOLK_Term *VOLK_bnode_new (const char *data);
+bool VOLK_term_equals (const VOLK_Term *term1, const VOLK_Term *term2);
+VOLK_Term *VOLK_triple_pos (const VOLK_Triple *trp, VOLK_TriplePos n);
+VOLK_Key VOLK_triple_hash (const VOLK_Triple *trp);

+ 5 - 5
test.c

@@ -8,12 +8,12 @@
 #include "test_store_mdb.c"
 #include "test_graph.c"
 
-#define TEST_STORE_PATH TMPDIR "/lsup_test_mdb"
+#define TEST_STORE_PATH TMPDIR "/volksdata_test_mdb"
 
 int main(int argc, char **argv) {
 
     // Set env variable to test path.
-    putenv ("LSUP_MDB_STORE_PATH=" TEST_STORE_PATH);
+    putenv ("VOLK_MDB_STORE_PATH=" TEST_STORE_PATH);
     // Clear out database from previous test.
     rm_r (TEST_STORE_PATH);
 
@@ -22,7 +22,7 @@ int main(int argc, char **argv) {
 
     start = clock();
 
-    LSUP_rc rc = LSUP_init();
+    VOLK_rc rc = VOLK_init();
     RCCK (rc);
 
     if (
@@ -36,13 +36,13 @@ int main(int argc, char **argv) {
         0
     ) {
         log_error ("Test failed.");
-        rc = LSUP_ERROR;
+        rc = VOLK_ERROR;
     } else {
         log_info ("");
         log_info ("********************");
         log_info ("* ALL TESTS PASSED *");
         log_info ("********************");
-        rc = LSUP_OK;
+        rc = VOLK_OK;
     }
 
     end = clock();

+ 39 - 39
test/assets/triples.h

@@ -1,7 +1,7 @@
 #ifndef _TEST_ASSETS_TRIPLES_H
 #define _TEST_ASSETS_TRIPLES_H
 
-#include "lsup/term.h"
+#include "volksdata/term.h"
 
 #define NUM_TRP 10
 
@@ -16,63 +16,63 @@
  * <urn:s:1> <urn:p:6> "String 1"@es-ES .
  * <urn:s:0> <urn:p:2> "String 1"^^<urn:mydatatype:string> .
  */
-LSUP_Triple **create_triples()
+VOLK_Triple **create_triples()
 {
-    LSUP_nsmap_add ("ns1", "urn:s:");
-    LSUP_nsmap_add ("ns2", "urn:p:");
+    VOLK_nsmap_add ("ns1", "urn:s:");
+    VOLK_nsmap_add ("ns2", "urn:p:");
 
-    LSUP_Term
-        *s0 = LSUP_iriref_new ("urn:s:0"),
-        *s5 = LSUP_iriref_new_ns ("ns1:0"),
-        *p2 = LSUP_iriref_new ("urn:p:2"),
-        *p4 = LSUP_iriref_new_ns ("ns2:2"),
-        *o5 = LSUP_literal_new (
+    VOLK_Term
+        *s0 = VOLK_iriref_new ("urn:s:0"),
+        *s5 = VOLK_iriref_new_ns ("ns1:0"),
+        *p2 = VOLK_iriref_new ("urn:p:2"),
+        *p4 = VOLK_iriref_new_ns ("ns2:2"),
+        *o5 = VOLK_literal_new (
                     "String 1",
-                    LSUP_iriref_new ("urn:mydatatype:string"));
+                    VOLK_iriref_new ("urn:mydatatype:string"));
 
-    LSUP_Triple **trp = calloc (sizeof (*trp), NUM_TRP + 1);
-    trp[0] = LSUP_triple_new (
+    VOLK_Triple **trp = calloc (sizeof (*trp), NUM_TRP + 1);
+    trp[0] = VOLK_triple_new (
             s0,
-            LSUP_iriref_new ("urn:p:0"),
-            LSUP_iriref_new ("urn:o:0"));
-    trp[1] = LSUP_triple_new (
-            LSUP_iriref_new ("urn:s:1"),
-            LSUP_iriref_new ("urn:p:1"),
-            LSUP_iriref_new ("urn:o:1"));
-    trp[2] = LSUP_triple_new (
-            LSUP_iriref_new ("urn:s:2"),
+            VOLK_iriref_new ("urn:p:0"),
+            VOLK_iriref_new ("urn:o:0"));
+    trp[1] = VOLK_triple_new (
+            VOLK_iriref_new ("urn:s:1"),
+            VOLK_iriref_new ("urn:p:1"),
+            VOLK_iriref_new ("urn:o:1"));
+    trp[2] = VOLK_triple_new (
+            VOLK_iriref_new ("urn:s:2"),
             p2,
-            LSUP_iriref_new ("urn:o:2"));
-    trp[3] = LSUP_triple_new (
-            LSUP_iriref_new ("urn:s:0"),
-            LSUP_iriref_new ("urn:p:1"),
-            LSUP_iriref_new ("urn:o:2"));
-    trp[4] = LSUP_triple_new (
-            LSUP_iriref_new ("urn:s:0"),
+            VOLK_iriref_new ("urn:o:2"));
+    trp[3] = VOLK_triple_new (
+            VOLK_iriref_new ("urn:s:0"),
+            VOLK_iriref_new ("urn:p:1"),
+            VOLK_iriref_new ("urn:o:2"));
+    trp[4] = VOLK_triple_new (
+            VOLK_iriref_new ("urn:s:0"),
             p4,
-            LSUP_literal_new ("String 1", NULL));
-    trp[5] = LSUP_triple_new (s5, LSUP_iriref_new ("urn:p:5"), o5);
-    trp[6] = LSUP_triple_new (
-            LSUP_iriref_new ("urn:s:1"),
-            LSUP_iriref_new ("urn:p:6"),
-            LSUP_lt_literal_new ("String 1", "es-ES"));
+            VOLK_literal_new ("String 1", NULL));
+    trp[5] = VOLK_triple_new (s5, VOLK_iriref_new ("urn:p:5"), o5);
+    trp[6] = VOLK_triple_new (
+            VOLK_iriref_new ("urn:s:1"),
+            VOLK_iriref_new ("urn:p:6"),
+            VOLK_lt_literal_new ("String 1", "es-ES"));
     // Unique triple from reused pointers. Do not double-free.
-    trp[7] = LSUP_triple_new (s0, p2, o5);
+    trp[7] = VOLK_triple_new (s0, p2, o5);
     // Duplicate of trp[7]. Do not double-free.
-    trp[8] = LSUP_triple_new (s0, p2, o5);
+    trp[8] = VOLK_triple_new (s0, p2, o5);
     // Duplicate of trp[7] from different reused terms but semantically
     // identical. Do not double-free.
-    trp[9] = LSUP_triple_new (s5, p4, o5);
+    trp[9] = VOLK_triple_new (s5, p4, o5);
 
     return trp;
 }
 
 
-void free_triples (LSUP_Triple **trp)
+void free_triples (VOLK_Triple **trp)
 {
     // Last three triples are second pointers.
     for (int i=0; i < NUM_TRP - 3; i++)
-        LSUP_triple_free (trp[i]);
+        VOLK_triple_free (trp[i]);
     free (trp[7]);
     free (trp[8]);
     free (trp[9]);

+ 10 - 10
test/test.h

@@ -1,10 +1,10 @@
-#ifndef _LSUP_TEST_H
-#define _LSUP_TEST_H
+#ifndef _VOLK_TEST_H
+#define _VOLK_TEST_H
 
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "lsup_rdf.h"
+#include "volksdata.h"
 
 /**
  * Minimal unit testing framework.
@@ -15,12 +15,12 @@
 // NT tests are exposed to multiple test units.
 char *start_nt_doc, *bad_nt_doc;
 char *end_nt_doc[7];
-LSUP_Codec codec;
+VOLK_Codec codec;
 
 // These are used by other codecs than just NT.
-LSUP_Term **init_terms (void);
-void init_triples(LSUP_Term **terms);
-void free_terms (LSUP_Term **terms);
+VOLK_Term **init_terms (void);
+void init_triples(VOLK_Term **terms);
+void free_terms (VOLK_Term **terms);
 int test_encode_nt_term();
 int test_encode_nt_graph();
 int test_decode_nt_graph();
@@ -65,10 +65,10 @@ int test_decode_nt_bad_graph();
 
 #define EXPECT_PASS(exp) do { \
     int _rc = (exp); \
-    if (_rc != LSUP_OK) {\
+    if (_rc != VOLK_OK) {\
         log_error (\
                 "!!! Test failed at %s:%d. Error: %s (%d)\n",\
-                __FILE__, __LINE__, LSUP_strerror(_rc), _rc); \
+                __FILE__, __LINE__, VOLK_strerror(_rc), _rc); \
         return -1; \
     }\
 } while (0)
@@ -83,4 +83,4 @@ int test_decode_nt_bad_graph();
 
 int tests_run;
 
-#endif  /* _LSUP_TEST_H */
+#endif  /* _VOLK_TEST_H */

+ 48 - 48
test/test_codec_nt.c

@@ -1,4 +1,4 @@
-#include "lsup/codec/codec_nt.h"
+#include "volksdata/codec/codec_nt.h"
 #include "test.h"
 
 #define TERM_CT 11
@@ -7,23 +7,23 @@
 typedef char nt_str[64];
 
 
-LSUP_Term **
+VOLK_Term **
 init_terms (void)
 {
-    LSUP_Term **terms = malloc (TERM_CT * sizeof (*terms));
-    terms[0] = LSUP_iriref_new("urn:local:s1");
-    terms[1] = LSUP_iriref_new("http://example.org/p1");
-    terms[2] = LSUP_iriref_new("http://example.org/p2");
-    terms[3] = LSUP_literal_new ("hello", NULL);
-    terms[4] = LSUP_lt_literal_new ("hello", "en-US");
-    terms[5] = LSUP_lt_literal_new ("hello", "es-ES");
-    terms[6] = LSUP_literal_new (
+    VOLK_Term **terms = malloc (TERM_CT * sizeof (*terms));
+    terms[0] = VOLK_iriref_new("urn:local:s1");
+    terms[1] = VOLK_iriref_new("http://example.org/p1");
+    terms[2] = VOLK_iriref_new("http://example.org/p2");
+    terms[3] = VOLK_literal_new ("hello", NULL);
+    terms[4] = VOLK_lt_literal_new ("hello", "en-US");
+    terms[5] = VOLK_lt_literal_new ("hello", "es-ES");
+    terms[6] = VOLK_literal_new (
             "25",
-            LSUP_iriref_new ("http://www.w3.org/2001/XMLSchema#integer"));
-    terms[7] = LSUP_literal_new (
+            VOLK_iriref_new ("http://www.w3.org/2001/XMLSchema#integer"));
+    terms[7] = VOLK_literal_new (
             "This \\is\\ a \"multi-line\"\n'literal'\t.", NULL);
-    terms[8] = LSUP_bnode_new ("bn1");
-    terms[9] = LSUP_term_new (LSUP_TERM_UNDEFINED, "bogus", NULL);
+    terms[8] = VOLK_bnode_new ("bn1");
+    terms[9] = VOLK_term_new (VOLK_TERM_UNDEFINED, "bogus", NULL);
     terms[10] = TERM_DUMMY;
 
     return terms;
@@ -100,28 +100,28 @@ char *end_nt_doc[7] = {
 };
 
 
-static LSUP_Triple *trp[TRP_CT];
+static VOLK_Triple *trp[TRP_CT];
 
 
 void
-init_triples (LSUP_Term **terms)
+init_triples (VOLK_Term **terms)
 {
-    trp[0] = LSUP_triple_new (terms[0], terms[1], terms[3]);
-    trp[1] = LSUP_triple_new (terms[0], terms[2], terms[4]);
-    trp[2] = LSUP_triple_new (terms[0], terms[2], terms[5]);
-    trp[3] = LSUP_triple_new (terms[0], terms[2], terms[8]);
-    trp[4] = LSUP_triple_new (terms[8], terms[1], terms[5]);
-    trp[5] = LSUP_triple_new (terms[8], terms[1], terms[6]);
-    trp[6] = LSUP_triple_new (terms[8], terms[1], terms[7]);
+    trp[0] = VOLK_triple_new (terms[0], terms[1], terms[3]);
+    trp[1] = VOLK_triple_new (terms[0], terms[2], terms[4]);
+    trp[2] = VOLK_triple_new (terms[0], terms[2], terms[5]);
+    trp[3] = VOLK_triple_new (terms[0], terms[2], terms[8]);
+    trp[4] = VOLK_triple_new (terms[8], terms[1], terms[5]);
+    trp[5] = VOLK_triple_new (terms[8], terms[1], terms[6]);
+    trp[6] = VOLK_triple_new (terms[8], terms[1], terms[7]);
     trp[7] = NULL;
 }
 
 
 void
-free_terms (LSUP_Term **terms)
+free_terms (VOLK_Term **terms)
 {
     for (int i = 0; i < TERM_CT; i++)
-        LSUP_term_free (terms[i]);
+        VOLK_term_free (terms[i]);
     free (terms);
 }
 
@@ -129,10 +129,10 @@ free_terms (LSUP_Term **terms)
 int
 test_encode_nt_term()
 {
-    LSUP_Term **terms = init_terms();
+    VOLK_Term **terms = init_terms();
 
-    LSUP_nsmap_add ("local", "urn:local:");
-    LSUP_nsmap_add ("ext", "http://example.org");
+    VOLK_nsmap_add ("local", "urn:local:");
+    VOLK_nsmap_add ("ext", "http://example.org");
 
     char *out = NULL;
 
@@ -146,9 +146,9 @@ test_encode_nt_term()
         EXPECT_STR_EQ (out, end_nt[i]);
     }
 
-    EXPECT_INT_EQ (codec.encode_term (terms[9], &out), LSUP_PARSE_ERR);
+    EXPECT_INT_EQ (codec.encode_term (terms[9], &out), VOLK_PARSE_ERR);
 
-    EXPECT_INT_EQ (codec.encode_term (terms[10], &out), LSUP_PARSE_ERR);
+    EXPECT_INT_EQ (codec.encode_term (terms[10], &out), VOLK_PARSE_ERR);
 
     free (out);
     free_terms (terms);
@@ -161,26 +161,26 @@ int
 test_encode_nt_graph()
 {
     log_info ("Test encoding graph document.");
-    LSUP_Graph *gr = LSUP_graph_new (NULL, NULL);
-    if (!gr) return LSUP_MEM_ERR;
+    VOLK_Graph *gr = VOLK_graph_new (NULL, NULL);
+    if (!gr) return VOLK_MEM_ERR;
 
     size_t ins;
-    LSUP_graph_add (gr, trp, &ins);
+    VOLK_graph_add (gr, trp, &ins);
 
     char *out = calloc (1, 1);
     void *it = codec.encode_graph_init (gr);
     ASSERT (it != NULL, "Error creating codec iterator!");
 
     char *tmp = NULL;
-    LSUP_rc rc;
-    while ((rc = codec.encode_graph_iter (it, &tmp)) != LSUP_END) {
+    VOLK_rc rc;
+    while ((rc = codec.encode_graph_iter (it, &tmp)) != VOLK_END) {
         ASSERT (rc >= 0, "Encoding step failed!");
         out = realloc (out, strlen(out) + strlen (tmp) + 1);
         out = strcat (out, tmp);
     }
     codec.encode_graph_done (it);
     free (tmp);
-    LSUP_graph_free (gr);
+    VOLK_graph_free (gr);
     //log_info ("Serialized graph: %s\n", out);
 
     for (int i = 0; i < 7; i++)
@@ -198,9 +198,9 @@ test_decode_nt_term()
     log_info ("Test decoding terms.");
     for (int i = 0; i < TERM_CT - 2; i++) {
         LOG_DEBUG("Decoding term %d/%d.", i, TERM_CT - 3);
-        LSUP_Term *term;
+        VOLK_Term *term;
         EXPECT_PASS (codec.decode_term (start_nt[i], &term));
-        LSUP_term_free (term);
+        VOLK_term_free (term);
     }
 
     return 0;
@@ -212,7 +212,7 @@ test_decode_nt_graph()
 {
     FILE *input = fmemopen ((void *)start_nt_doc, strlen (start_nt_doc), "r");
 
-    LSUP_Graph *gr;
+    VOLK_Graph *gr;
     size_t ct;
     char *err;
     EXPECT_PASS (codec.decode_graph (input, &gr, &ct, &err));
@@ -226,7 +226,7 @@ test_decode_nt_graph()
     char *out = calloc (1, 1);
     char *tmp = NULL;
     void *it = codec.encode_graph_init (gr);
-    while (codec.encode_graph_iter (it, &tmp) != LSUP_END) {
+    while (codec.encode_graph_iter (it, &tmp) != VOLK_END) {
         out = realloc (out, strlen(out) + strlen (tmp) + 1);
         out = strcat (out, tmp);
     }
@@ -237,14 +237,14 @@ test_decode_nt_graph()
 
 #endif
     EXPECT_INT_EQ (ct, 8);
-    EXPECT_INT_EQ (LSUP_graph_size (gr), 7);
+    EXPECT_INT_EQ (VOLK_graph_size (gr), 7);
 
     for (int i = 0; i < 7; i++) {
         log_info ("Checking triple #%d.", i);
-        EXPECT_INT_EQ (LSUP_graph_contains (gr, trp[i]), 1);
+        EXPECT_INT_EQ (VOLK_graph_contains (gr, trp[i]), 1);
     }
 
-    LSUP_graph_free (gr);
+    VOLK_graph_free (gr);
 
     return 0;
 }
@@ -256,11 +256,11 @@ test_decode_nt_bad_graph()
     log_info ("testing illegal NT document.");
     FILE *input = fmemopen ((void *)bad_nt_doc, strlen (bad_nt_doc), "r");
 
-    LSUP_Graph *gr;
+    VOLK_Graph *gr;
     size_t ct;
     char *err;
-    LSUP_rc rc = codec.decode_graph (input, &gr, &ct, &err);
-    EXPECT_INT_EQ (rc, LSUP_PARSE_ERR);
+    VOLK_rc rc = codec.decode_graph (input, &gr, &ct, &err);
+    EXPECT_INT_EQ (rc, VOLK_PARSE_ERR);
 
     log_info ("Error: %s", err);
     ASSERT (strstr (err, "`@ \"Bad Data.\"") != NULL, "Wrong error string report!");
@@ -269,7 +269,7 @@ test_decode_nt_bad_graph()
 
     free (err);
     fclose (input);
-    LSUP_graph_free (gr);
+    VOLK_graph_free (gr);
 
     return 0;
 }
@@ -277,7 +277,7 @@ test_decode_nt_bad_graph()
 
 int codec_nt_tests()
 {
-    LSUP_Term **terms = init_terms();
+    VOLK_Term **terms = init_terms();
     init_triples (terms);
 
     codec = nt_codec;

+ 15 - 15
test/test_codec_ttl.c

@@ -1,4 +1,4 @@
-#include "lsup/codec/codec_ttl.h"
+#include "volksdata/codec/codec_ttl.h"
 #include "test.h"
 
 #define W3C_POS_TEST_CT 30
@@ -7,7 +7,7 @@
 
 
 #define TRP_CT 8
-static LSUP_Triple *trp[TRP_CT];
+static VOLK_Triple *trp[TRP_CT];
 
 
 /// Encode a graph as TTL.
@@ -15,19 +15,19 @@ int
 test_encode_ttl_graph()
 {
     log_info ("Test encoding graph document.");
-    LSUP_Graph *gr = LSUP_graph_new (NULL, NULL);
-    if (!gr) return LSUP_MEM_ERR;
+    VOLK_Graph *gr = VOLK_graph_new (NULL, NULL);
+    if (!gr) return VOLK_MEM_ERR;
 
     size_t ins;
-    LSUP_graph_add (gr, trp, &ins);
+    VOLK_graph_add (gr, trp, &ins);
 
     char *out = calloc (1, 1);
     void *it = codec.encode_graph_init (gr);
     ASSERT (it != NULL, "Error creating codec iterator!");
 
     char *tmp = NULL;
-    LSUP_rc rc;
-    while ((rc = codec.encode_graph_iter (it, &tmp)) != LSUP_END) {
+    VOLK_rc rc;
+    while ((rc = codec.encode_graph_iter (it, &tmp)) != VOLK_END) {
         log_info ("Serialized fragment: %s\n", tmp);
         ASSERT (rc >= 0, "Encoding step failed!");
         out = realloc (out, strlen(out) + strlen (tmp) + 1);
@@ -36,7 +36,7 @@ test_encode_ttl_graph()
     log_info ("Serialized graph: %s\n", out);
     codec.encode_graph_done (it);
     free (tmp);
-    LSUP_graph_free (gr);
+    VOLK_graph_free (gr);
 
     /*
     for (int i = 0; i < 7; i++)
@@ -53,7 +53,7 @@ int
 test_w3c_pos()
 {
     char test_fname[36], out_fname[36];
-    LSUP_Graph *gr;
+    VOLK_Graph *gr;
     size_t ct;
     char *err;
     char ch;
@@ -78,8 +78,8 @@ test_w3c_pos()
         }
 
         EXPECT_PASS (codec.decode_graph (test_stream, &gr, &ct, &err));
-        EXPECT_INT_EQ (LSUP_graph_size (gr), nt_ct); // Just count NT lines.
-        LSUP_graph_free (gr);
+        EXPECT_INT_EQ (VOLK_graph_size (gr), nt_ct); // Just count NT lines.
+        VOLK_graph_free (gr);
         fclose (test_stream);
         fclose (out_stream);
         free (err);
@@ -94,7 +94,7 @@ int
 test_w3c_neg()
 {
     char test_fname[36];
-    LSUP_Graph *gr;
+    VOLK_Graph *gr;
     size_t ct;
     char *err;
 
@@ -103,9 +103,9 @@ test_w3c_neg()
         FILE *test_stream = fopen (test_fname, "r");
         log_info ("Testing %s", test_fname);
 
-        LSUP_rc rc = codec.decode_graph (test_stream, &gr, &ct, &err);
+        VOLK_rc rc = codec.decode_graph (test_stream, &gr, &ct, &err);
         log_info ("rc: %d", rc);
-        ASSERT (rc == LSUP_PARSE_ERR, "Bad test did not raise a parse error!");
+        ASSERT (rc == VOLK_PARSE_ERR, "Bad test did not raise a parse error!");
         fclose (test_stream);
         free (err);
     }
@@ -116,7 +116,7 @@ test_w3c_neg()
 
 int codec_ttl_tests()
 {
-    LSUP_Term **terms = init_terms();
+    VOLK_Term **terms = init_terms();
     init_triples (terms);
 
     codec = ttl_codec;

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 304 - 304
test/test_graph.c


+ 25 - 25
test/test_namespace.c

@@ -1,4 +1,4 @@
-#include "lsup/namespace.h"
+#include "volksdata/namespace.h"
 #include "test.h"
 
 static int
@@ -7,27 +7,27 @@ test_namespace()
     // Use nonconventional prefix names to avoid clashes with default
     // namespace prefixes already registered.
 
-    ASSERT (LSUP_default_nsm != NULL, "Error creating namespace map on init!");
+    ASSERT (VOLK_default_nsm != NULL, "Error creating namespace map on init!");
 
     EXPECT_PASS (
-            LSUP_nsmap_add ("tdc", "http://purl.org/dc/elements/1.1/"));
-    EXPECT_PASS (LSUP_nsmap_add ("tdcterms", "http://purl.org/dc/terms/"));
-    EXPECT_PASS (LSUP_nsmap_add ("ns1", "urn:ns1:"));
-    EXPECT_PASS (LSUP_nsmap_add ("ns2", "urn:ns2:"));
+            VOLK_nsmap_add ("tdc", "http://purl.org/dc/elements/1.1/"));
+    EXPECT_PASS (VOLK_nsmap_add ("tdcterms", "http://purl.org/dc/terms/"));
+    EXPECT_PASS (VOLK_nsmap_add ("ns1", "urn:ns1:"));
+    EXPECT_PASS (VOLK_nsmap_add ("ns2", "urn:ns2:"));
 
     // Look up prefix.
     EXPECT_STR_EQ (
-            LSUP_nsmap_get_ns ("tdc"), "http://purl.org/dc/elements/1.1/");
+            VOLK_nsmap_get_ns ("tdc"), "http://purl.org/dc/elements/1.1/");
     EXPECT_STR_EQ (
-            LSUP_nsmap_get_ns ("tdcterms"), "http://purl.org/dc/terms/");
+            VOLK_nsmap_get_ns ("tdcterms"), "http://purl.org/dc/terms/");
     // Prefixes longer than 7 chars are truncated.
     EXPECT_STR_EQ (
-            LSUP_nsmap_get_ns ("dctermsxx"), "http://purl.org/dc/terms/");
-    ASSERT (LSUP_nsmap_get_ns ("none") == NULL, "Non-existent NS found!");
+            VOLK_nsmap_get_ns ("dctermsxx"), "http://purl.org/dc/terms/");
+    ASSERT (VOLK_nsmap_get_ns ("none") == NULL, "Non-existent NS found!");
 
     // Lookup NS.
-    EXPECT_STR_EQ (LSUP_nsmap_get_pfx ("urn:ns1:"), "ns1");
-    EXPECT_STR_EQ (LSUP_nsmap_get_pfx ("urn:ns2:"), "ns2");
+    EXPECT_STR_EQ (VOLK_nsmap_get_pfx ("urn:ns1:"), "ns1");
+    EXPECT_STR_EQ (VOLK_nsmap_get_pfx ("urn:ns2:"), "ns2");
     // Cannot test tdc and tdcterms reverse lookup because dc and dcterms are
     // also mapped to the same ns, and either one can come up.
 
@@ -35,44 +35,44 @@ test_namespace()
     char *fq_uri, *pfx_uri;
     fq_uri = "urn:ns1:res1";
 
-    EXPECT_PASS (LSUP_nsmap_denormalize_uri (fq_uri, &pfx_uri));
+    EXPECT_PASS (VOLK_nsmap_denormalize_uri (fq_uri, &pfx_uri));
     EXPECT_STR_EQ (pfx_uri, "ns1:res1");
 
     fq_uri = NULL;
-    EXPECT_PASS (LSUP_nsmap_normalize_uri (pfx_uri, &fq_uri));
+    EXPECT_PASS (VOLK_nsmap_normalize_uri (pfx_uri, &fq_uri));
     EXPECT_STR_EQ (fq_uri, "urn:ns1:res1");
     free (fq_uri);
     free (pfx_uri);
 
     ASSERT (
-            LSUP_nsmap_normalize_uri ("dctermsxxtitle", &fq_uri)
-            == LSUP_NORESULT, "Wrong RC for normalizing long ns!");
+            VOLK_nsmap_normalize_uri ("dctermsxxtitle", &fq_uri)
+            == VOLK_NORESULT, "Wrong RC for normalizing long ns!");
     ASSERT (!fq_uri, "Faulty normalization output should be NULL!");
     free (fq_uri);
 
     ASSERT (
-            LSUP_nsmap_normalize_uri ("bogus:ns:123", &fq_uri)
-            == LSUP_NORESULT, "Wrong RC for normalizing non-existent ns!");
+            VOLK_nsmap_normalize_uri ("bogus:ns:123", &fq_uri)
+            == VOLK_NORESULT, "Wrong RC for normalizing non-existent ns!");
     ASSERT (!fq_uri, "Faulty normalization output should be NULL!");
     free (fq_uri);
 
     ASSERT (
-            LSUP_nsmap_normalize_uri ("bogus", &fq_uri)
-            == LSUP_NORESULT, "Wrong RC for normalizing non-prefixed URI!");
+            VOLK_nsmap_normalize_uri ("bogus", &fq_uri)
+            == VOLK_NORESULT, "Wrong RC for normalizing non-prefixed URI!");
     ASSERT (!fq_uri, "Faulty normalization output should be NULL!");
     free (fq_uri);
 
-    EXPECT_PASS (LSUP_nsmap_remove ("tdc"));
-    ASSERT (LSUP_nsmap_get_ns ("tdc") == NULL, "Deleted NS found!");
+    EXPECT_PASS (VOLK_nsmap_remove ("tdc"));
+    ASSERT (VOLK_nsmap_get_ns ("tdc") == NULL, "Deleted NS found!");
 
     ASSERT (
-            LSUP_nsmap_remove ("none") == LSUP_NOACTION,
+            VOLK_nsmap_remove ("none") == VOLK_NOACTION,
             "Wrong result for removal of non-existent prefix!");
 
     // Test normalization after removal.
     ASSERT (
-            LSUP_nsmap_normalize_uri ("tdc:title", &fq_uri)
-            == LSUP_NORESULT, "Wrong RC for normalizing non-prefixed URI!");
+            VOLK_nsmap_normalize_uri ("tdc:title", &fq_uri)
+            == VOLK_NORESULT, "Wrong RC for normalizing non-prefixed URI!");
     ASSERT (!fq_uri, "Faulty normalization output should be NULL!");
     free (fq_uri);
 

+ 109 - 109
test/test_store.c

@@ -1,12 +1,12 @@
-#include "lsup/store.h"
+#include "volksdata/store.h"
 #include "assets/triples.h"
 #include "test.h"
 
 
 #define STORE_ID_MDB "file:///tmp/testdb"
-#define STORE_ID_HTABLE LSUP_NS "dummy"
+#define STORE_ID_HTABLE VOLK_NS "dummy"
 
-static LSUP_StoreType store_type;
+static VOLK_StoreType store_type;
 static char *store_id;
 
 
@@ -17,35 +17,35 @@ static char *store_id;
  */
 static int test_triple_store()
 {
-    LSUP_Store *store = LSUP_store_new (store_type, store_id, 0, true);
+    VOLK_Store *store = VOLK_store_new (store_type, store_id, 0, true);
     ASSERT (store != NULL, "Error creating store!"); \
 
     log_info ("Testing triple store for %s", store->id);
 
-    LSUP_Triple **trp = create_triples();
-    LSUP_BufferTriple ser_trp[NUM_TRP];
+    VOLK_Triple **trp = create_triples();
+    VOLK_BufferTriple ser_trp[NUM_TRP];
 
     for (int i = 0; i < NUM_TRP; i++) {
-        LSUP_BufferTriple *tmp = LSUP_triple_serialize (trp[i]);
+        VOLK_BufferTriple *tmp = VOLK_triple_serialize (trp[i]);
         ser_trp[i] = *tmp;
         free (tmp);
     }
 
     // Test adding.
-    void *it = LSUP_store_add_init (store, NULL);
+    void *it = VOLK_store_add_init (store, NULL);
     size_t ins = 0;
     for (size_t i = 0; i < NUM_TRP; i++) {
-        LSUP_rc rc = LSUP_store_add_iter (store, it, ser_trp + i);
+        VOLK_rc rc = VOLK_store_add_iter (store, it, ser_trp + i);
         ASSERT (rc >= 0, "Error inserting triples!");
-        if (rc == LSUP_OK) ins++;
+        if (rc == VOLK_OK) ins++;
     }
-    LSUP_store_add_done (store, it);
+    VOLK_store_add_done (store, it);
 
     EXPECT_INT_EQ (ins, 8);
-    EXPECT_INT_EQ (LSUP_store_size (store), ins);
+    EXPECT_INT_EQ (VOLK_store_size (store), ins);
 
     // Test lookups.
-    LSUP_Buffer *lut[12][3] = {
+    VOLK_Buffer *lut[12][3] = {
         {NULL, NULL, NULL},
 
         {ser_trp[0].s, NULL, NULL},
@@ -63,7 +63,7 @@ static int test_triple_store()
         {ser_trp[4].s, ser_trp[4].p, ser_trp[6].o},
     };
 
-    LSUP_Buffer *luc[12] = {
+    VOLK_Buffer *luc[12] = {
         NULL,
 
         NULL,
@@ -86,11 +86,11 @@ static int test_triple_store()
 
         5,
         // Lookup on nonexisting context is ignored by non-context store.
-        LSUP_store_features (store) & LSUP_STORE_CTX ? 0 : 1,
+        VOLK_store_features (store) & VOLK_STORE_CTX ? 0 : 1,
         1, 0, 1,
 
         2, 1, 2,
-        LSUP_store_features (store) & LSUP_STORE_CTX ? 0 : 2,
+        VOLK_store_features (store) & VOLK_STORE_CTX ? 0 : 2,
 
         1, 0,
     };
@@ -99,22 +99,22 @@ static int test_triple_store()
         size_t ct;
         log_info ("Testing triple lookup #%d.", i);
 
-        void *it = LSUP_store_lookup (
+        void *it = VOLK_store_lookup (
                 store, lut[i][0], lut[i][1], lut[i][2], luc[i], &ct);
         ASSERT (it != NULL, "Error creating iterator!");
         EXPECT_INT_EQ (ct, results[i]);
 
-        LSUP_store_iter_free (store, it);
+        VOLK_store_iter_free (store, it);
     }
 
     for (int i = 0; i < NUM_TRP; i++) {
-        LSUP_buffer_free (ser_trp[i].s);
-        LSUP_buffer_free (ser_trp[i].p);
-        LSUP_buffer_free (ser_trp[i].o);
+        VOLK_buffer_free (ser_trp[i].s);
+        VOLK_buffer_free (ser_trp[i].p);
+        VOLK_buffer_free (ser_trp[i].o);
     }
 
     free_triples (trp);
-    LSUP_store_free (store);
+    VOLK_store_free (store);
 
     return 0;
 }
@@ -128,21 +128,21 @@ static int test_triple_store()
  */
 static int test_quad_store()
 {
-    LSUP_Store *store = LSUP_store_new (store_type, store_id, 0, true);
+    VOLK_Store *store = VOLK_store_new (store_type, store_id, 0, true);
     ASSERT (store != NULL, "Error creating store!"); \
-    if (!(LSUP_store_features (store) & LSUP_STORE_TXN)) {
-        LSUP_store_free (store);
+    if (!(VOLK_store_features (store) & VOLK_STORE_TXN)) {
+        VOLK_store_free (store);
         return 0;
     }
 
 
     log_info ("Testing quad store for %s", store->id);
 
-    LSUP_Triple **trp = create_triples();
-    LSUP_BufferTriple ser_trp[NUM_TRP];
+    VOLK_Triple **trp = create_triples();
+    VOLK_BufferTriple ser_trp[NUM_TRP];
 
     for (int i = 0; i < NUM_TRP; i++) {
-        LSUP_BufferTriple *tmp = LSUP_triple_serialize (trp[i]);
+        VOLK_BufferTriple *tmp = VOLK_triple_serialize (trp[i]);
         ser_trp[i] = *tmp;
         free (tmp);
     }
@@ -151,44 +151,44 @@ static int test_quad_store()
     size_t ins;
 
     // Only triples 0÷5 in default context.
-    it = LSUP_store_add_init_txn (store, NULL, NULL);
+    it = VOLK_store_add_init_txn (store, NULL, NULL);
     ins = 0;
     for (size_t i = 0; i < 6; i++) {
         log_info ("Inserting triple #%d in default context.", i);
-        LSUP_rc rc = LSUP_store_add_iter (store, it, ser_trp + i);
+        VOLK_rc rc = VOLK_store_add_iter (store, it, ser_trp + i);
         EXPECT_PASS (rc);
-        if (rc == LSUP_OK) ins++;
+        if (rc == VOLK_OK) ins++;
     }
-    LSUP_store_add_done (store, it);
+    VOLK_store_add_done (store, it);
     EXPECT_INT_EQ (ins, 6);
 
-    LSUP_Buffer *sc1 = LSUP_default_ctx_buf;
+    VOLK_Buffer *sc1 = VOLK_default_ctx_buf;
 
-    LSUP_Term *ctx2 = LSUP_iriref_new("urn:c:2");
-    LSUP_Buffer *sc2 = LSUP_term_serialize (ctx2);
+    VOLK_Term *ctx2 = VOLK_iriref_new("urn:c:2");
+    VOLK_Buffer *sc2 = VOLK_term_serialize (ctx2);
 
     // Only triples 4÷9 in context 2 (effectively 4 non-duplicates).
-    it = LSUP_store_add_init (store, sc2);
+    it = VOLK_store_add_init (store, sc2);
     ASSERT (it != NULL, "Error creating iterator!");
     ins = 0;
     for (size_t i = 4; i < 10; i++) {
         log_info ("Inserting triple #%d in context 2.", i);
-        LSUP_rc rc = LSUP_store_add_iter (store, it, ser_trp + i);
-        ASSERT (rc == LSUP_OK || rc == LSUP_NOACTION, "Error adding triples!");
-        if (rc == LSUP_OK) ins++;
+        VOLK_rc rc = VOLK_store_add_iter (store, it, ser_trp + i);
+        ASSERT (rc == VOLK_OK || rc == VOLK_NOACTION, "Error adding triples!");
+        if (rc == VOLK_OK) ins++;
     }
-    LSUP_store_add_done (store, it);
+    VOLK_store_add_done (store, it);
     EXPECT_INT_EQ (ins, 4);
 
     // 6 triples in ctx1 + 6 in ctx2 - 2 duplicates
-    EXPECT_INT_EQ (LSUP_store_size (store), 10);
+    EXPECT_INT_EQ (VOLK_store_size (store), 10);
 
     // This context has no triples.
-    LSUP_Term *ctx3 = LSUP_iriref_new("urn:c:3");
-    LSUP_Buffer *sc3 = LSUP_term_serialize (ctx3);
+    VOLK_Term *ctx3 = VOLK_iriref_new("urn:c:3");
+    VOLK_Buffer *sc3 = VOLK_term_serialize (ctx3);
 
     // Test lookups.
-    LSUP_Buffer *lut[41][3] = {
+    VOLK_Buffer *lut[41][3] = {
         // Any context
         {NULL, NULL, NULL},                                 // #0
 
@@ -253,7 +253,7 @@ static int test_quad_store()
         {ser_trp[6].s, ser_trp[6].p, ser_trp[6].o},         // #40
     };
 
-    LSUP_Buffer *luc[41] = {
+    VOLK_Buffer *luc[41] = {
         // Any context
         NULL,                                               // #0
         NULL, NULL, NULL, NULL,                             // #1-#4
@@ -319,23 +319,23 @@ static int test_quad_store()
         size_t ct;
 
         log_info ("Checking triple #%d.", i);
-        void *it = LSUP_store_lookup (
+        void *it = VOLK_store_lookup (
                 store, lut[i][0], lut[i][1], lut[i][2], luc[i], &ct);
         ASSERT (it != NULL, "Lookup error!");
         EXPECT_INT_EQ (ct, results[i]);
 
-        LSUP_store_iter_free (store, it);
+        VOLK_store_iter_free (store, it);
     }
 
     // Check triple contexts.
     for (int i = 0; i < 10; i++) {
-        void *it = LSUP_store_lookup_txn (
+        void *it = VOLK_store_lookup_txn (
                 store, NULL, ser_trp[i].s, ser_trp[i].p, ser_trp[i].o,
                 NULL, NULL);
         log_info ("Checking contexts for triple %d.", i);
-        LSUP_Buffer *ctx_a;
-        EXPECT_PASS (LSUP_store_iter_next (store, it, NULL, &ctx_a));
-        LSUP_store_iter_free (store, it);
+        VOLK_Buffer *ctx_a;
+        EXPECT_PASS (VOLK_store_iter_next (store, it, NULL, &ctx_a));
+        VOLK_store_iter_free (store, it);
 
         ASSERT (ctx_a != NULL, "No contexts found!");
 
@@ -347,17 +347,17 @@ static int test_quad_store()
     }
 
     for (int i = 0; i < NUM_TRP; i++) {
-        LSUP_buffer_free (ser_trp[i].s);
-        LSUP_buffer_free (ser_trp[i].p);
-        LSUP_buffer_free (ser_trp[i].o);
+        VOLK_buffer_free (ser_trp[i].s);
+        VOLK_buffer_free (ser_trp[i].p);
+        VOLK_buffer_free (ser_trp[i].o);
     }
 
-    LSUP_term_free (ctx2);
-    LSUP_term_free (ctx3);
-    LSUP_buffer_free (sc2);
-    LSUP_buffer_free (sc3);
+    VOLK_term_free (ctx2);
+    VOLK_term_free (ctx3);
+    VOLK_buffer_free (sc2);
+    VOLK_buffer_free (sc3);
     free_triples (trp);
-    LSUP_store_free (store);
+    VOLK_store_free (store);
 
     return 0;
 }
@@ -365,10 +365,10 @@ static int test_quad_store()
 
 static int test_txn_commit (void)
 {
-    LSUP_Store *store = LSUP_store_new (store_type, store_id, 0, true);
+    VOLK_Store *store = VOLK_store_new (store_type, store_id, 0, true);
     ASSERT (store != NULL, "Error creating store!"); \
-    if (!(LSUP_store_features (store) & LSUP_STORE_TXN)) {
-        LSUP_store_free (store);
+    if (!(VOLK_store_features (store) & VOLK_STORE_TXN)) {
+        VOLK_store_free (store);
         return 0;
     }
 
@@ -390,61 +390,61 @@ static int test_txn_commit (void)
 
     log_info ("Testing transaction control for %s", store->id);
 
-    LSUP_Triple **trp = create_triples();
-    LSUP_BufferTriple ser_trp[NUM_TRP];
+    VOLK_Triple **trp = create_triples();
+    VOLK_BufferTriple ser_trp[NUM_TRP];
 
     for (int i = 0; i < NUM_TRP; i++) {
-        LSUP_BufferTriple *tmp = LSUP_triple_serialize (trp[i]);
+        VOLK_BufferTriple *tmp = VOLK_triple_serialize (trp[i]);
         ser_trp[i] = *tmp;
         free (tmp);
     }
 
     void *it;
     // Start adding then abort.
-    it = LSUP_store_add_init_txn (store, NULL, NULL);
+    it = VOLK_store_add_init_txn (store, NULL, NULL);
     for (size_t i = 0; i < NUM_TRP; i++) {
-        LSUP_rc rc = LSUP_store_add_iter (store, it, ser_trp + i);
+        VOLK_rc rc = VOLK_store_add_iter (store, it, ser_trp + i);
         ASSERT (rc >= 0, "Error inserting triples!");
     }
-    LSUP_store_add_abort (store, it);
+    VOLK_store_add_abort (store, it);
 
-    EXPECT_INT_EQ (LSUP_store_size (store), 0);
+    EXPECT_INT_EQ (VOLK_store_size (store), 0);
 
     // Add within a transaction, commit, then commit parent transaction.
     void *txn;
-    EXPECT_PASS (LSUP_store_begin (store, 0, &txn));
-    it = LSUP_store_add_init_txn (store, txn, NULL);
+    EXPECT_PASS (VOLK_store_begin (store, 0, &txn));
+    it = VOLK_store_add_init_txn (store, txn, NULL);
     for (size_t i = 0; i < NUM_TRP; i++) {
-        LSUP_rc rc = LSUP_store_add_iter (store, it, ser_trp + i);
+        VOLK_rc rc = VOLK_store_add_iter (store, it, ser_trp + i);
         ASSERT (rc >= 0, "Error inserting triples!");
     }
-    LSUP_store_add_done (store, it);
+    VOLK_store_add_done (store, it);
 
     // Triples are added in child txn but parent is still open.
     // Size function always calculates outside of all transactions.
-    EXPECT_INT_EQ (LSUP_store_size (store), 0);
+    EXPECT_INT_EQ (VOLK_store_size (store), 0);
 
     size_t ct;
-    it = LSUP_store_lookup_txn (store, txn, NULL, NULL, NULL, NULL, &ct);
-    LSUP_store_iter_free (store, it);
+    it = VOLK_store_lookup_txn (store, txn, NULL, NULL, NULL, NULL, &ct);
+    VOLK_store_iter_free (store, it);
     // Should show triples added within the parent txn.
     EXPECT_INT_EQ (ct, 8);
 
     // commit child txn operations.
-    EXPECT_PASS (LSUP_store_commit (store, txn));
-    it = LSUP_store_lookup (store, NULL, NULL, NULL, NULL, &ct);
-    LSUP_store_iter_free (store, it);
+    EXPECT_PASS (VOLK_store_commit (store, txn));
+    it = VOLK_store_lookup (store, NULL, NULL, NULL, NULL, &ct);
+    VOLK_store_iter_free (store, it);
     EXPECT_INT_EQ (ct, 8);
-    EXPECT_INT_EQ (LSUP_store_size (store), 8);
+    EXPECT_INT_EQ (VOLK_store_size (store), 8);
 
     for (int i = 0; i < NUM_TRP; i++) {
-        LSUP_buffer_free (ser_trp[i].s);
-        LSUP_buffer_free (ser_trp[i].p);
-        LSUP_buffer_free (ser_trp[i].o);
+        VOLK_buffer_free (ser_trp[i].s);
+        VOLK_buffer_free (ser_trp[i].p);
+        VOLK_buffer_free (ser_trp[i].o);
     }
 
     free_triples (trp);
-    LSUP_store_free (store);
+    VOLK_store_free (store);
 
     return 0;
 }
@@ -452,69 +452,69 @@ static int test_txn_commit (void)
 
 static int test_txn_abort (void)
 {
-    LSUP_Store *store = LSUP_store_new (store_type, store_id, 0, true);
+    VOLK_Store *store = VOLK_store_new (store_type, store_id, 0, true);
     ASSERT (store != NULL, "Error creating store!"); \
-    if (!(LSUP_store_features (store) & LSUP_STORE_TXN)) {
-        LSUP_store_free (store);
+    if (!(VOLK_store_features (store) & VOLK_STORE_TXN)) {
+        VOLK_store_free (store);
         return 0;
     }
 
     log_info ("Testing transaction control for %s", store->id);
 
-    LSUP_Triple **trp = create_triples();
-    LSUP_BufferTriple ser_trp[NUM_TRP];
+    VOLK_Triple **trp = create_triples();
+    VOLK_BufferTriple ser_trp[NUM_TRP];
 
     for (int i = 0; i < NUM_TRP; i++) {
-        LSUP_BufferTriple *tmp = LSUP_triple_serialize (trp[i]);
+        VOLK_BufferTriple *tmp = VOLK_triple_serialize (trp[i]);
         ser_trp[i] = *tmp;
         free (tmp);
     }
 
     void *it;
     // Start adding then abort.
-    it = LSUP_store_add_init (store, NULL);
+    it = VOLK_store_add_init (store, NULL);
     for (size_t i = 0; i < NUM_TRP; i++) {
-        LSUP_rc rc = LSUP_store_add_iter (store, it, ser_trp + i);
+        VOLK_rc rc = VOLK_store_add_iter (store, it, ser_trp + i);
         ASSERT (rc >= 0, "Error inserting triples!");
     }
-    LSUP_store_add_abort (store, it);
+    VOLK_store_add_abort (store, it);
 
-    EXPECT_INT_EQ (LSUP_store_size (store), 0);
+    EXPECT_INT_EQ (VOLK_store_size (store), 0);
 
     // Add within a transaction, commit, then abort parent transaction.
     void *txn;
-    EXPECT_PASS (LSUP_store_begin (store, 0, &txn));
-    it = LSUP_store_add_init_txn (store, txn, NULL);
+    EXPECT_PASS (VOLK_store_begin (store, 0, &txn));
+    it = VOLK_store_add_init_txn (store, txn, NULL);
     for (size_t i = 0; i < NUM_TRP; i++) {
-        LSUP_rc rc = LSUP_store_add_iter (store, it, ser_trp + i);
+        VOLK_rc rc = VOLK_store_add_iter (store, it, ser_trp + i);
         ASSERT (rc >= 0, "Error inserting triples!");
     }
-    LSUP_store_add_done (store, it);
+    VOLK_store_add_done (store, it);
 
     // Triples are added in child txn but parent is still open.
     // Size function always calculates outside of all transactions.
-    EXPECT_INT_EQ (LSUP_store_size (store), 0);
+    EXPECT_INT_EQ (VOLK_store_size (store), 0);
 
     size_t ct;
-    it = LSUP_store_lookup_txn (store, txn, NULL, NULL, NULL, NULL, &ct);
-    LSUP_store_iter_free (store, it);
+    it = VOLK_store_lookup_txn (store, txn, NULL, NULL, NULL, NULL, &ct);
+    VOLK_store_iter_free (store, it);
     // Should show triples added within the parent txn.
     EXPECT_INT_EQ (ct, 8);
 
     // Discard child txn operations.
-    LSUP_store_abort (store, txn);
-    it = LSUP_store_lookup (store, NULL, NULL, NULL, NULL, &ct);
-    LSUP_store_iter_free (store, it);
+    VOLK_store_abort (store, txn);
+    it = VOLK_store_lookup (store, NULL, NULL, NULL, NULL, &ct);
+    VOLK_store_iter_free (store, it);
     EXPECT_INT_EQ (ct, 0);
 
     for (int i = 0; i < NUM_TRP; i++) {
-        LSUP_buffer_free (ser_trp[i].s);
-        LSUP_buffer_free (ser_trp[i].p);
-        LSUP_buffer_free (ser_trp[i].o);
+        VOLK_buffer_free (ser_trp[i].s);
+        VOLK_buffer_free (ser_trp[i].p);
+        VOLK_buffer_free (ser_trp[i].o);
     }
 
     free_triples (trp);
-    LSUP_store_free (store);
+    VOLK_store_free (store);
 
     return 0;
 }
@@ -523,7 +523,7 @@ static int test_txn_abort (void)
 int store_tests()
 {
 #define ENTRY(a, b) \
-    store_type = LSUP_STORE_##a; \
+    store_type = VOLK_STORE_##a; \
     store_id = STORE_ID_##a; \
     RUN (test_triple_store); \
     RUN (test_quad_store); \

+ 17 - 17
test/test_store_ht.c

@@ -1,4 +1,4 @@
-#include "lsup/store_htable.h"
+#include "volksdata/store_htable.h"
 #include "test.h"
 #include "assets/triples.h"
 
@@ -6,31 +6,31 @@
  */
 static int test_htstore()
 {
-    LSUP_HTStore *store = LSUP_htstore_new(0);
+    VOLK_HTStore *store = VOLK_htstore_new(0);
     ASSERT (store != NULL, "Error initializing store!");
 
-    LSUP_Triple *trp = create_triples();
-    LSUP_BufferTriple *ser_trp[NUM_TRP];
+    VOLK_Triple *trp = create_triples();
+    VOLK_BufferTriple *ser_trp[NUM_TRP];
 
     for (int i = 0; i < NUM_TRP; i++)
-        ser_trp[i] = LSUP_triple_serialize (trp + i);
+        ser_trp[i] = VOLK_triple_serialize (trp + i);
 
     // Test adding.
-    LSUP_HTIterator *it = LSUP_htstore_add_init (store);
+    VOLK_HTIterator *it = VOLK_htstore_add_init (store);
     for (size_t i = 0; i < NUM_TRP; i++) {
         //printf("Insert #%lu\n", i);
-        LSUP_rc rc = LSUP_htstore_add_iter (it, ser_trp[i]);
+        VOLK_rc rc = VOLK_htstore_add_iter (it, ser_trp[i]);
         ASSERT (
-                (i < 8 && rc == LSUP_OK) || rc == LSUP_NOACTION,
+                (i < 8 && rc == VOLK_OK) || rc == VOLK_NOACTION,
                 "Wrong return code on insert!");
     }
 
-    EXPECT_INT_EQ (LSUP_htstore_size (store), 8);
+    EXPECT_INT_EQ (VOLK_htstore_size (store), 8);
 
-    LSUP_htstore_add_done (it);
+    VOLK_htstore_add_done (it);
 
     // Test lookups.
-    LSUP_Buffer *lut[12][3] = {
+    VOLK_Buffer *lut[12][3] = {
         {NULL, NULL, NULL},
 
         {ser_trp[0]->s, NULL, NULL},
@@ -55,26 +55,26 @@ static int test_htstore()
         1, 0,
     };
 
-    LSUP_BufferTriple *sspo = BTRP_DUMMY;
+    VOLK_BufferTriple *sspo = BTRP_DUMMY;
     for (int i = 0; i < NUM_TRP; i++) {
         size_t ct, ct2 = 0;
         log_info ("Testing triple lookup #%d.", i);
 
-        LSUP_HTIterator *it = LSUP_htstore_lookup(
+        VOLK_HTIterator *it = VOLK_htstore_lookup(
                 store, lut[i][0], lut[i][1], lut[i][2], &ct);
         EXPECT_INT_EQ (ct, results[i]);
         // Verify that the internal counter aligns with an external one.
-        while (LSUP_htiter_next (it, sspo) != LSUP_END) ct2++;
+        while (VOLK_htiter_next (it, sspo) != VOLK_END) ct2++;
         EXPECT_INT_EQ (ct, ct2);
 
-        LSUP_htiter_free (it);
+        VOLK_htiter_free (it);
     }
     free (sspo);
 
     for (int i = 0; i < NUM_TRP; i++)
-        LSUP_btriple_free (ser_trp[i]);
+        VOLK_btriple_free (ser_trp[i]);
 
-    LSUP_htstore_free (store);
+    VOLK_htstore_free (store);
     free_triples (trp);
 
     return 0;

+ 24 - 24
test/test_store_mdb.c

@@ -1,6 +1,6 @@
 #include <unistd.h>
 
-#include "lsup/store_mdb.h"
+#include "volksdata/store_mdb.h"
 #include "test.h"
 
 
@@ -11,40 +11,40 @@
  */
 static int test_ctx_switch()
 {
-    const LSUP_StoreInt *sif = LSUP_store_int (LSUP_STORE_MDB);
+    const VOLK_StoreInt *sif = VOLK_store_int (VOLK_STORE_MDB);
 
-    LSUP_Store *store = LSUP_store_new (LSUP_STORE_MDB, MDBSTORE_ID, 0, true);
+    VOLK_Store *store = VOLK_store_new (VOLK_STORE_MDB, MDBSTORE_ID, 0, true);
     ASSERT (store != NULL, "Error initializing store!");
 
     // Create enough triples to test a multi-page copy of triple data.
     // Add small buffer (4) to create a 3rd page.
     size_t num_trp = (getpagesize() * 2 / TRP_KLEN) + 4;
-    LSUP_BufferTriple **tdata = malloc (num_trp * sizeof (*tdata));
-    LSUP_Triple *trp = LSUP_triple_new (
-        LSUP_iriref_new ("urn:s:1"),
-        LSUP_iriref_new ("urn:p:1"),
+    VOLK_BufferTriple **tdata = malloc (num_trp * sizeof (*tdata));
+    VOLK_Triple *trp = VOLK_triple_new (
+        VOLK_iriref_new ("urn:s:1"),
+        VOLK_iriref_new ("urn:p:1"),
         NULL);
     char *o_str = malloc (8 * sizeof (*o_str));
-    if (UNLIKELY (!o_str)) return LSUP_MEM_ERR;
+    if (UNLIKELY (!o_str)) return VOLK_MEM_ERR;
 
     for (unsigned int i = 0; i < num_trp; i++) {
         sprintf (o_str, "%.7d", i);
-        if (trp->o) LSUP_term_free (trp->o);
-        trp->o = LSUP_literal_new (o_str, NULL);
-        tdata[i] = LSUP_triple_serialize (trp);
+        if (trp->o) VOLK_term_free (trp->o);
+        trp->o = VOLK_literal_new (o_str, NULL);
+        tdata[i] = VOLK_triple_serialize (trp);
     }
-    LSUP_triple_free (trp);
+    VOLK_triple_free (trp);
     free (o_str);
     LOG_DEBUG ("Created %lu triples.", num_trp);
 
-    LSUP_Term
-        *c1 = LSUP_iriref_new ("urn:c:1"),
-        *c2 = LSUP_iriref_new ("urn:c:2");
-    LSUP_Buffer
-        *sc1 = LSUP_term_serialize (c1),
-        *sc2 = LSUP_term_serialize (c2);
-    LSUP_term_free (c1);
-    LSUP_term_free (c2);
+    VOLK_Term
+        *c1 = VOLK_iriref_new ("urn:c:1"),
+        *c2 = VOLK_iriref_new ("urn:c:2");
+    VOLK_Buffer
+        *sc1 = VOLK_term_serialize (c1),
+        *sc2 = VOLK_term_serialize (c2);
+    VOLK_term_free (c1);
+    VOLK_term_free (c2);
 
     void *it = sif->add_init_fn (store->data, sc1, NULL);
     for (size_t i = 0; i < num_trp; i++)
@@ -52,7 +52,7 @@ static int test_ctx_switch()
     sif->add_done_fn (it);
 
     for (size_t i = 0; i < num_trp; i++)
-        LSUP_btriple_free (tdata[i]);
+        VOLK_btriple_free (tdata[i]);
     free (tdata);
 
     size_t check_ct;
@@ -71,10 +71,10 @@ static int test_ctx_switch()
     EXPECT_INT_EQ (check_ct, num_trp);
     sif->lu_free_fn (it);
 
-    LSUP_buffer_free (sc1);
-    LSUP_buffer_free (sc2);
+    VOLK_buffer_free (sc1);
+    VOLK_buffer_free (sc2);
 
-    LSUP_store_free (store);
+    VOLK_store_free (store);
 
     return 0;
 }

+ 159 - 159
test/test_term.c

@@ -7,14 +7,14 @@ static int test_iriref()
     char *uri2_data = "ns1:12345";
     char *uri3_data = "ns2:12345";
 
-    LSUP_nsmap_add ("ns1", "http://example.org/term#");
-    LSUP_nsmap_add ("ns2", "http://example.org/term#");
+    VOLK_nsmap_add ("ns1", "http://example.org/term#");
+    VOLK_nsmap_add ("ns2", "http://example.org/term#");
 
-    LSUP_Term *uri1 = LSUP_iriref_new (uri1_data);
+    VOLK_Term *uri1 = VOLK_iriref_new (uri1_data);
     ASSERT (uri1, "IRI is NULL!");
-    char *pfx = LSUP_iriref_prefix (uri1);
-    char *path = LSUP_iriref_path (uri1);
-    char *frag = LSUP_iriref_frag (uri1);
+    char *pfx = VOLK_iriref_prefix (uri1);
+    char *path = VOLK_iriref_path (uri1);
+    char *frag = VOLK_iriref_frag (uri1);
     EXPECT_STR_EQ (pfx, "http://example.org");
     EXPECT_STR_EQ (path, "/term#12345");
     EXPECT_STR_EQ (frag, "12345");
@@ -22,34 +22,34 @@ static int test_iriref()
     free (path);
     free (frag);
 
-    LSUP_Term *uri2 = LSUP_iriref_new_ns (uri2_data);
+    VOLK_Term *uri2 = VOLK_iriref_new_ns (uri2_data);
     ASSERT (uri2, "IRI is NULL!");
 
-    LSUP_Term *uri3 = LSUP_iriref_new_ns (uri3_data);
+    VOLK_Term *uri3 = VOLK_iriref_new_ns (uri3_data);
     ASSERT (uri3, "IRI is NULL!");
 
-    LSUP_Term *uri4 = LSUP_iriref_new (NULL);
+    VOLK_Term *uri4 = VOLK_iriref_new (NULL);
     ASSERT (uri4, "IRI is NULL!");
 
-    LSUP_Term *uri5 = LSUP_iriref_new (NULL);
+    VOLK_Term *uri5 = VOLK_iriref_new (NULL);
     ASSERT (uri5, "IRI is NULL!");
 
-    EXPECT_INT_EQ (uri1->type, LSUP_TERM_IRIREF);
-    EXPECT_INT_EQ (uri2->type, LSUP_TERM_IRIREF);
-    EXPECT_INT_EQ (uri3->type, LSUP_TERM_IRIREF);
-    EXPECT_INT_EQ (uri4->type, LSUP_TERM_IRIREF);
-    EXPECT_INT_EQ (uri5->type, LSUP_TERM_IRIREF);
+    EXPECT_INT_EQ (uri1->type, VOLK_TERM_IRIREF);
+    EXPECT_INT_EQ (uri2->type, VOLK_TERM_IRIREF);
+    EXPECT_INT_EQ (uri3->type, VOLK_TERM_IRIREF);
+    EXPECT_INT_EQ (uri4->type, VOLK_TERM_IRIREF);
+    EXPECT_INT_EQ (uri5->type, VOLK_TERM_IRIREF);
 
-    ASSERT (LSUP_term_equals (uri1, uri2), "IRIs don't match!");
-    ASSERT (LSUP_term_equals (uri2, uri3), "IRIs don't match!");
-    ASSERT (!LSUP_term_equals (uri3, uri4), "IRIs shouldn't match!");
-    ASSERT (!LSUP_term_equals (uri4, uri5), "IRIs shouldn't match!");
+    ASSERT (VOLK_term_equals (uri1, uri2), "IRIs don't match!");
+    ASSERT (VOLK_term_equals (uri2, uri3), "IRIs don't match!");
+    ASSERT (!VOLK_term_equals (uri3, uri4), "IRIs shouldn't match!");
+    ASSERT (!VOLK_term_equals (uri4, uri5), "IRIs shouldn't match!");
 
-    LSUP_term_free (uri1);
-    LSUP_term_free (uri2);
-    LSUP_term_free (uri3);
-    LSUP_term_free (uri4);
-    LSUP_term_free (uri5);
+    VOLK_term_free (uri1);
+    VOLK_term_free (uri2);
+    VOLK_term_free (uri3);
+    VOLK_term_free (uri4);
+    VOLK_term_free (uri5);
 
     return 0;
 }
@@ -80,8 +80,8 @@ static int test_iriref_parts()
                 "anchor"},
         {"ftp:///", "ftp://", "/", ""},
         {
-                "file:///usr/local/lib/liblsuprdf.so",
-                "file://", "/usr/local/lib/liblsuprdf.so", ""},
+                "file:///usr/local/lib/libvolksdata.so",
+                "file://", "/usr/local/lib/libvolksdata.so", ""},
         {"/", "", "/", ""},
         {"/tmp", "", "/tmp", ""},
         {"./tmp", "", "./tmp", ""},
@@ -94,11 +94,11 @@ static int test_iriref_parts()
     };
 
     for (size_t i = 0; i < 18; i++) {
-        LSUP_Term *iri = LSUP_iriref_new(data[i][0]);
+        VOLK_Term *iri = VOLK_iriref_new(data[i][0]);
         char
-            *pfx = LSUP_iriref_prefix (iri),
-            *path = LSUP_iriref_path (iri),
-            *frag = LSUP_iriref_frag (iri);
+            *pfx = VOLK_iriref_prefix (iri),
+            *path = VOLK_iriref_path (iri),
+            *frag = VOLK_iriref_frag (iri);
 
         EXPECT_STR_EQ (pfx, data[i][1]);
         EXPECT_STR_EQ (path, data[i][2]);
@@ -107,7 +107,7 @@ static int test_iriref_parts()
         free (pfx);
         free (path);
         free (frag);
-        LSUP_term_free (iri);
+        VOLK_term_free (iri);
     }
 
     return 0;
@@ -115,42 +115,42 @@ static int test_iriref_parts()
 
 static int test_iriref_abs_rel()
 {
-    EXPECT_PASS (LSUP_nsmap_add ("ns1", "http://example.org/res/"));
+    EXPECT_PASS (VOLK_nsmap_add ("ns1", "http://example.org/res/"));
 
-    LSUP_Term *root1 = LSUP_iriref_new ("http://example.org/res/");
-    LSUP_Term *root2 = LSUP_iriref_new ("urn:id:");
+    VOLK_Term *root1 = VOLK_iriref_new ("http://example.org/res/");
+    VOLK_Term *root2 = VOLK_iriref_new ("urn:id:");
 
-    LSUP_Term *rel_iri1 = LSUP_iriref_new ("http://anotherex.net/res/25");
-    LSUP_Term *rel_iri2 = LSUP_iriref_new ("/admin/32");
-    LSUP_Term *rel_iri3 = LSUP_iriref_new ("45/678");
+    VOLK_Term *rel_iri1 = VOLK_iriref_new ("http://anotherex.net/res/25");
+    VOLK_Term *rel_iri2 = VOLK_iriref_new ("/admin/32");
+    VOLK_Term *rel_iri3 = VOLK_iriref_new ("45/678");
 
-    LSUP_Term *abs_iri1 = LSUP_iriref_new_abs (root1, rel_iri1);
-    LSUP_Term *abs_iri2 = LSUP_iriref_new_abs (root1, rel_iri2);
-    LSUP_Term *abs_iri3 = LSUP_iriref_new_abs (root1, rel_iri3);
+    VOLK_Term *abs_iri1 = VOLK_iriref_new_abs (root1, rel_iri1);
+    VOLK_Term *abs_iri2 = VOLK_iriref_new_abs (root1, rel_iri2);
+    VOLK_Term *abs_iri3 = VOLK_iriref_new_abs (root1, rel_iri3);
 
     EXPECT_STR_EQ (abs_iri1->data, rel_iri1->data);
     EXPECT_STR_EQ (abs_iri2->data, "http://example.org/admin/32");
     EXPECT_STR_EQ (abs_iri3->data, "http://example.org/res/45/678");
 
-    LSUP_Term *rel_iri1a = LSUP_iriref_new_rel (root1, abs_iri1);
-    LSUP_Term *rel_iri2a = LSUP_iriref_new_rel (root1, abs_iri2);
-    LSUP_Term *rel_iri3a = LSUP_iriref_new_rel (root1, abs_iri3);
+    VOLK_Term *rel_iri1a = VOLK_iriref_new_rel (root1, abs_iri1);
+    VOLK_Term *rel_iri2a = VOLK_iriref_new_rel (root1, abs_iri2);
+    VOLK_Term *rel_iri3a = VOLK_iriref_new_rel (root1, abs_iri3);
 
     EXPECT_STR_EQ (rel_iri1a->data, rel_iri1->data);
     EXPECT_STR_EQ (rel_iri2a->data, abs_iri2->data);
     EXPECT_STR_EQ (rel_iri3a->data, "45/678");
 
-    LSUP_term_free (root1);
-    LSUP_term_free (root2);
-    LSUP_term_free (rel_iri1);
-    LSUP_term_free (rel_iri2);
-    LSUP_term_free (rel_iri3);
-    LSUP_term_free (abs_iri1);
-    LSUP_term_free (abs_iri2);
-    LSUP_term_free (abs_iri3);
-    LSUP_term_free (rel_iri1a);
-    LSUP_term_free (rel_iri2a);
-    LSUP_term_free (rel_iri3a);
+    VOLK_term_free (root1);
+    VOLK_term_free (root2);
+    VOLK_term_free (rel_iri1);
+    VOLK_term_free (rel_iri2);
+    VOLK_term_free (rel_iri3);
+    VOLK_term_free (abs_iri1);
+    VOLK_term_free (abs_iri2);
+    VOLK_term_free (abs_iri3);
+    VOLK_term_free (rel_iri1a);
+    VOLK_term_free (rel_iri2a);
+    VOLK_term_free (rel_iri3a);
 
     return 0;
 }
@@ -162,153 +162,153 @@ static int test_literal()
     char *datatype = "urn:my:datatype";
     char *lang = "en-US";
 
-    LSUP_Term *lit1 = LSUP_literal_new (data, LSUP_iriref_new (datatype));
-    EXPECT_INT_EQ (lit1->type, LSUP_TERM_LITERAL);
+    VOLK_Term *lit1 = VOLK_literal_new (data, VOLK_iriref_new (datatype));
+    EXPECT_INT_EQ (lit1->type, VOLK_TERM_LITERAL);
     EXPECT_STR_EQ (lit1->data, data);
     EXPECT_STR_EQ (lit1->datatype->data, datatype);
 
-    LSUP_Term *lit2 = LSUP_literal_new (data, LSUP_default_datatype);
-    EXPECT_INT_EQ (lit2->type, LSUP_TERM_LITERAL);
+    VOLK_Term *lit2 = VOLK_literal_new (data, VOLK_default_datatype);
+    EXPECT_INT_EQ (lit2->type, VOLK_TERM_LITERAL);
     EXPECT_STR_EQ (lit2->data, data);
     EXPECT_STR_EQ (lit2->datatype->data, DEFAULT_DTYPE);
 
-    LSUP_Term *lit3 = LSUP_literal_new (data, NULL);
-    EXPECT_INT_EQ (lit3->type, LSUP_TERM_LITERAL);
+    VOLK_Term *lit3 = VOLK_literal_new (data, NULL);
+    EXPECT_INT_EQ (lit3->type, VOLK_TERM_LITERAL);
     EXPECT_STR_EQ (lit3->data, data);
     EXPECT_STR_EQ (lit3->datatype->data, DEFAULT_DTYPE);
 
     ASSERT (lit1->datatype != lit2->datatype, "Wrong data type match!");
     ASSERT (lit2->datatype == lit3->datatype, "Data type mismatch!");
 
-    ASSERT (!LSUP_term_equals (lit1, lit2), "Wrong term match!");
-    ASSERT (LSUP_term_equals (lit2, lit3), "Term mismatch!");
+    ASSERT (!VOLK_term_equals (lit1, lit2), "Wrong term match!");
+    ASSERT (VOLK_term_equals (lit2, lit3), "Term mismatch!");
 
-    LSUP_Term *lt_lit1 = LSUP_lt_literal_new (data, lang);
-    EXPECT_INT_EQ (lt_lit1->type, LSUP_TERM_LT_LITERAL);
+    VOLK_Term *lt_lit1 = VOLK_lt_literal_new (data, lang);
+    EXPECT_INT_EQ (lt_lit1->type, VOLK_TERM_LT_LITERAL);
     EXPECT_STR_EQ (lt_lit1->data, data);
     EXPECT_STR_EQ (lt_lit1->lang, lang);
 
     // LT-literal without lang is a normal string literal.
-    LSUP_Term *lt_lit2 = LSUP_lt_literal_new (data, NULL);
-    EXPECT_INT_EQ (lt_lit2->type, LSUP_TERM_LITERAL);
+    VOLK_Term *lt_lit2 = VOLK_lt_literal_new (data, NULL);
+    EXPECT_INT_EQ (lt_lit2->type, VOLK_TERM_LITERAL);
     EXPECT_STR_EQ (lt_lit2->data, data);
 
-    ASSERT (LSUP_term_equals (lt_lit2, lit2), "Term mismatch!");
+    ASSERT (VOLK_term_equals (lt_lit2, lit2), "Term mismatch!");
     EXPECT_STR_EQ (lt_lit2->datatype->data, DEFAULT_DTYPE);
 
-    LSUP_term_free (lit1);
-    LSUP_term_free (lit2);
-    LSUP_term_free (lit3);
-    LSUP_term_free (lt_lit1);
-    LSUP_term_free (lt_lit2);
+    VOLK_term_free (lit1);
+    VOLK_term_free (lit2);
+    VOLK_term_free (lit3);
+    VOLK_term_free (lt_lit1);
+    VOLK_term_free (lt_lit2);
 
     return 0;
 }
 
 static int test_undefined()
 {
-    LSUP_Term *undef1 = LSUP_term_new (LSUP_TERM_UNDEFINED, NULL, NULL);
+    VOLK_Term *undef1 = VOLK_term_new (VOLK_TERM_UNDEFINED, NULL, NULL);
     ASSERT (undef1 != NULL, "Error creating undefined term without data!");
 
     char *data = "bogus";
-    LSUP_Term *undef2 = LSUP_term_new (LSUP_TERM_UNDEFINED, data, NULL);
+    VOLK_Term *undef2 = VOLK_term_new (VOLK_TERM_UNDEFINED, data, NULL);
     ASSERT (undef2 != NULL, "Error creating undefined term with data!");
     EXPECT_STR_EQ (undef2->data, data);
 
-    LSUP_term_free (undef1);
-    LSUP_term_free (undef2);
+    VOLK_term_free (undef1);
+    VOLK_term_free (undef2);
 
     return 0;
 }
 
 static int test_term_copy()
 {
-    LSUP_Term *uri1 = LSUP_iriref_new ("http://hello.org");
-    LSUP_Term *lit1 = LSUP_literal_new ("hello", NULL);
-    LSUP_Term *tlit1 = LSUP_literal_new (
-            "hello", LSUP_iriref_new ("urn:mydatatype:string"));
-    LSUP_Term *llit1 = LSUP_lt_literal_new ("hello", "en-US");
-
-    LSUP_Term *uri2 = LSUP_term_copy (uri1);
-    LSUP_Term *lit2 = LSUP_term_copy (lit1);
-    LSUP_Term *tlit2 = LSUP_term_copy (tlit1);
-    LSUP_Term *llit2 = LSUP_term_copy (llit1);
-
-    ASSERT (LSUP_term_equals (uri1, uri2), "Term mismatch!");
-    ASSERT (LSUP_term_equals (lit1, lit2), "Term mismatch!");
-    ASSERT (LSUP_term_equals (tlit1, tlit2), "Term mismatch!");
-    ASSERT (LSUP_term_equals (llit1, llit2), "Term mismatch!");
-
-    LSUP_term_free (uri1);
-    LSUP_term_free (uri2);
-    LSUP_term_free (lit1);
-    LSUP_term_free (lit2);
-    LSUP_term_free (tlit1);
-    LSUP_term_free (tlit2);
-    LSUP_term_free (llit1);
-    LSUP_term_free (llit2);
+    VOLK_Term *uri1 = VOLK_iriref_new ("http://hello.org");
+    VOLK_Term *lit1 = VOLK_literal_new ("hello", NULL);
+    VOLK_Term *tlit1 = VOLK_literal_new (
+            "hello", VOLK_iriref_new ("urn:mydatatype:string"));
+    VOLK_Term *llit1 = VOLK_lt_literal_new ("hello", "en-US");
+
+    VOLK_Term *uri2 = VOLK_term_copy (uri1);
+    VOLK_Term *lit2 = VOLK_term_copy (lit1);
+    VOLK_Term *tlit2 = VOLK_term_copy (tlit1);
+    VOLK_Term *llit2 = VOLK_term_copy (llit1);
+
+    ASSERT (VOLK_term_equals (uri1, uri2), "Term mismatch!");
+    ASSERT (VOLK_term_equals (lit1, lit2), "Term mismatch!");
+    ASSERT (VOLK_term_equals (tlit1, tlit2), "Term mismatch!");
+    ASSERT (VOLK_term_equals (llit1, llit2), "Term mismatch!");
+
+    VOLK_term_free (uri1);
+    VOLK_term_free (uri2);
+    VOLK_term_free (lit1);
+    VOLK_term_free (lit2);
+    VOLK_term_free (tlit1);
+    VOLK_term_free (tlit2);
+    VOLK_term_free (llit1);
+    VOLK_term_free (llit2);
 
     return 0;
 }
 
 static int test_term_serialize_deserialize()
 {
-    LSUP_Term *uri = LSUP_iriref_new ("http://hello.org");
-    LSUP_Term *lit = LSUP_literal_new ("hello", NULL);
-    LSUP_Term *tlit = LSUP_literal_new (
-            "hello", LSUP_iriref_new ("urn:mydatatype:string"));
-    LSUP_Term *llit = LSUP_lt_literal_new ("hello", "en-US");
+    VOLK_Term *uri = VOLK_iriref_new ("http://hello.org");
+    VOLK_Term *lit = VOLK_literal_new ("hello", NULL);
+    VOLK_Term *tlit = VOLK_literal_new (
+            "hello", VOLK_iriref_new ("urn:mydatatype:string"));
+    VOLK_Term *llit = VOLK_lt_literal_new ("hello", "en-US");
 
-    LSUP_Buffer *sterm;
-    LSUP_Term *dsterm;
+    VOLK_Buffer *sterm;
+    VOLK_Term *dsterm;
 
-    sterm = LSUP_term_serialize (uri);
+    sterm = VOLK_term_serialize (uri);
     ASSERT (sterm != NULL, "Error serializing term!");
     //log_info ("%s", "Serialized URI: ");
-    //LSUP_buffer_print (sterm);
+    //VOLK_buffer_print (sterm);
     //log_info ("%s", "\n");
-    dsterm = LSUP_term_new_from_buffer (sterm);
+    dsterm = VOLK_term_new_from_buffer (sterm);
     ASSERT (dsterm != NULL, "Error deserializing term!");
-    ASSERT (LSUP_term_equals (dsterm, uri), "URI serialization error!");
-    LSUP_term_free (uri);
-    LSUP_buffer_free (sterm);
-    LSUP_term_free (dsterm);
+    ASSERT (VOLK_term_equals (dsterm, uri), "URI serialization error!");
+    VOLK_term_free (uri);
+    VOLK_buffer_free (sterm);
+    VOLK_term_free (dsterm);
 
-    sterm = LSUP_term_serialize (lit);
+    sterm = VOLK_term_serialize (lit);
     ASSERT (sterm != NULL, "Error serializing term!");
     //log_info ("%s", "Serialized literal: ");
-    //LSUP_buffer_print (sterm);
+    //VOLK_buffer_print (sterm);
     //log_info ("%s", "\n");
-    dsterm = LSUP_term_new_from_buffer (sterm);
+    dsterm = VOLK_term_new_from_buffer (sterm);
     ASSERT (dsterm != NULL, "Error deserializing term!");
-    ASSERT (LSUP_term_equals (dsterm, lit), "lit serialization error!");
-    LSUP_term_free (lit);
-    LSUP_buffer_free (sterm);
-    LSUP_term_free (dsterm);
+    ASSERT (VOLK_term_equals (dsterm, lit), "lit serialization error!");
+    VOLK_term_free (lit);
+    VOLK_buffer_free (sterm);
+    VOLK_term_free (dsterm);
 
-    sterm = LSUP_term_serialize (tlit);
+    sterm = VOLK_term_serialize (tlit);
     ASSERT (sterm != NULL, "Error serializing term!");
     //log_info ("%s", "Serialized typed literal: ");
-    //LSUP_buffer_print (sterm);
+    //VOLK_buffer_print (sterm);
     //log_info ("%s", "\n");
-    dsterm = LSUP_term_new_from_buffer (sterm);
+    dsterm = VOLK_term_new_from_buffer (sterm);
     ASSERT (dsterm != NULL, "Error deserializing term!");
-    ASSERT (LSUP_term_equals (dsterm, tlit), "tlit serialization error!");
-    LSUP_term_free (tlit);
-    LSUP_buffer_free (sterm);
-    LSUP_term_free (dsterm);
+    ASSERT (VOLK_term_equals (dsterm, tlit), "tlit serialization error!");
+    VOLK_term_free (tlit);
+    VOLK_buffer_free (sterm);
+    VOLK_term_free (dsterm);
 
-    sterm = LSUP_term_serialize (llit);
+    sterm = VOLK_term_serialize (llit);
     ASSERT (sterm != NULL, "Error serializing term!");
     //log_info ("%s", "Serialized typed and language-tagged URI: ");
-    //LSUP_buffer_print (sterm);
+    //VOLK_buffer_print (sterm);
     //log_info ("%s", "\n");
-    dsterm = LSUP_term_new_from_buffer (sterm);
+    dsterm = VOLK_term_new_from_buffer (sterm);
     ASSERT (dsterm != NULL, "Error deserializing term!");
-    ASSERT (LSUP_term_equals (dsterm, llit), "URI serialization error!");
-    LSUP_term_free (llit);
-    LSUP_buffer_free (sterm);
-    LSUP_term_free (dsterm);
+    ASSERT (VOLK_term_equals (dsterm, llit), "URI serialization error!");
+    VOLK_term_free (llit);
+    VOLK_buffer_free (sterm);
+    VOLK_term_free (dsterm);
 
     return 0;
 }
@@ -316,23 +316,23 @@ static int test_term_serialize_deserialize()
 
 static int test_term_to_key()
 {
-    LSUP_nsmap_add ("ns1", "http://hello.org/term#");
-
-    LSUP_Term *uri1 = LSUP_iriref_new ("http://hello.org/term#bye");
-    LSUP_Term *uri2 = LSUP_iriref_new_ns ("ns1:bye");
-    LSUP_Term *lit = LSUP_literal_new ("hello", NULL);
-    LSUP_Term *tlit = LSUP_literal_new ("hello", LSUP_default_datatype);
-    LSUP_Term *llit1 = LSUP_lt_literal_new ("hello", "en-US");
-    LSUP_Term *llit2 = LSUP_lt_literal_new ("hello", "en-GB");
-    LSUP_Term *llit3 = LSUP_lt_literal_new ("hello", NULL);
-
-    LSUP_Key uri1_key = LSUP_term_hash (uri1);
-    LSUP_Key uri2_key = LSUP_term_hash (uri2);
-    LSUP_Key lit_key = LSUP_term_hash (lit);
-    LSUP_Key tlit_key = LSUP_term_hash (tlit);
-    LSUP_Key llit1_key = LSUP_term_hash (llit1);
-    LSUP_Key llit2_key = LSUP_term_hash (llit2);
-    LSUP_Key llit3_key = LSUP_term_hash (llit3);
+    VOLK_nsmap_add ("ns1", "http://hello.org/term#");
+
+    VOLK_Term *uri1 = VOLK_iriref_new ("http://hello.org/term#bye");
+    VOLK_Term *uri2 = VOLK_iriref_new_ns ("ns1:bye");
+    VOLK_Term *lit = VOLK_literal_new ("hello", NULL);
+    VOLK_Term *tlit = VOLK_literal_new ("hello", VOLK_default_datatype);
+    VOLK_Term *llit1 = VOLK_lt_literal_new ("hello", "en-US");
+    VOLK_Term *llit2 = VOLK_lt_literal_new ("hello", "en-GB");
+    VOLK_Term *llit3 = VOLK_lt_literal_new ("hello", NULL);
+
+    VOLK_Key uri1_key = VOLK_term_hash (uri1);
+    VOLK_Key uri2_key = VOLK_term_hash (uri2);
+    VOLK_Key lit_key = VOLK_term_hash (lit);
+    VOLK_Key tlit_key = VOLK_term_hash (tlit);
+    VOLK_Key llit1_key = VOLK_term_hash (llit1);
+    VOLK_Key llit2_key = VOLK_term_hash (llit2);
+    VOLK_Key llit3_key = VOLK_term_hash (llit3);
 
     ASSERT (uri1_key == uri2_key, "URI keys differ!");
     ASSERT (uri1_key != lit_key, "URI key conflict!");
@@ -342,13 +342,13 @@ static int test_term_to_key()
     ASSERT (llit1_key != llit2_key, "URI key conflict!");
     ASSERT (tlit_key == llit3_key, "URI keys differ!");
 
-    LSUP_term_free (uri1);
-    LSUP_term_free (uri2);
-    LSUP_term_free (lit);
-    LSUP_term_free (tlit);
-    LSUP_term_free (llit1);
-    LSUP_term_free (llit2);
-    LSUP_term_free (llit3);
+    VOLK_term_free (uri1);
+    VOLK_term_free (uri2);
+    VOLK_term_free (lit);
+    VOLK_term_free (tlit);
+    VOLK_term_free (llit1);
+    VOLK_term_free (llit2);
+    VOLK_term_free (llit3);
 
     return 0;
 }

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio