summaryrefslogtreecommitdiffstats
path: root/external/redland
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--external/redland/ExternalPackage_raptor.mk22
-rw-r--r--external/redland/ExternalPackage_rasqal.mk22
-rw-r--r--external/redland/ExternalPackage_redland.mk22
-rw-r--r--external/redland/ExternalProject_raptor.mk47
-rw-r--r--external/redland/ExternalProject_rasqal.mk54
-rw-r--r--external/redland/ExternalProject_redland.mk57
-rw-r--r--external/redland/Library_raptor.mk88
-rw-r--r--external/redland/Library_rasqal.mk127
-rw-r--r--external/redland/Library_rdf.mk78
-rw-r--r--external/redland/Makefile7
-rw-r--r--external/redland/Module_redland.mk34
-rw-r--r--external/redland/README24
-rw-r--r--external/redland/UnpackedTarball_raptor.mk35
-rw-r--r--external/redland/UnpackedTarball_rasqal.mk34
-rw-r--r--external/redland/UnpackedTarball_redland.mk38
-rw-r--r--external/redland/raptor/0001-CVE-2020-25713-raptor2-malformed-input-file-can-lead.patch.133
-rw-r--r--external/redland/raptor/0001-Calcualte-max-nspace-declarations-correctly-for-XML-.patch.143
-rw-r--r--external/redland/raptor/libtool.patch27
-rw-r--r--external/redland/raptor/raptor-android.patch.113
-rw-r--r--external/redland/raptor/raptor-bundled-soname.patch.113
-rw-r--r--external/redland/raptor/raptor-freebsd.patch.128
-rw-r--r--external/redland/raptor/raptor-msvc.patch.123
-rw-r--r--external/redland/raptor/raptor2.h2187
-rw-r--r--external/redland/raptor/raptor_config.h402
-rw-r--r--external/redland/raptor/rpath.patch21
-rw-r--r--external/redland/raptor/ubsan.patch25
-rw-r--r--external/redland/raptor/xml2-config.patch22
-rw-r--r--external/redland/rasqal/clang-cl.patch11
-rw-r--r--external/redland/rasqal/libtool.patch27
-rw-r--r--external/redland/rasqal/rasqal-aix.patch.125
-rw-r--r--external/redland/rasqal/rasqal-android.patch.114
-rw-r--r--external/redland/rasqal/rasqal-bundled-soname.patch.113
-rw-r--r--external/redland/rasqal/rasqal-freebsd.patch.128
-rw-r--r--external/redland/rasqal/rasqal-msvc.patch.164
-rw-r--r--external/redland/rasqal/rasqal-pkgconfig.patch.114
-rw-r--r--external/redland/rasqal/rasqal-xcompile.patch.116
-rw-r--r--external/redland/rasqal/rasqal.h2259
-rw-r--r--external/redland/rasqal/rpath.patch21
-rw-r--r--external/redland/redland/clang-cl.patch20
-rw-r--r--external/redland/redland/librdf.h434
-rw-r--r--external/redland/redland/libtool.patch27
-rw-r--r--external/redland/redland/redland-android.patch.114
-rw-r--r--external/redland/redland/redland-bundled-soname.patch.113
-rw-r--r--external/redland/redland/redland-format.patch.010
-rw-r--r--external/redland/redland/redland-freebsd.patch.128
-rw-r--r--external/redland/redland/redland-msvc.patch.1123
-rw-r--r--external/redland/redland/redland-xcompile.patch.115
-rw-r--r--external/redland/redland/rpath.patch10
48 files changed, 6712 insertions, 0 deletions
diff --git a/external/redland/ExternalPackage_raptor.mk b/external/redland/ExternalPackage_raptor.mk
new file mode 100644
index 000000000..119e52f9e
--- /dev/null
+++ b/external/redland/ExternalPackage_raptor.mk
@@ -0,0 +1,22 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_ExternalPackage_ExternalPackage,raptor,raptor))
+
+$(eval $(call gb_ExternalPackage_use_external_project,raptor,raptor))
+
+ifeq ($(OS),MACOSX)
+$(eval $(call gb_ExternalPackage_add_file,raptor,$(LIBO_LIB_FOLDER)/libraptor2-lo.$(RAPTOR_MAJOR).dylib,src/.libs/libraptor2-lo.$(RAPTOR_MAJOR).dylib))
+else ifeq ($(COM),MSC)
+$(eval $(call gb_ExternalPackage_add_file,raptor,$(LIBO_LIB_FOLDER)/libraptor2.dll,src/.libs/libraptor2.dll))
+else ifeq ($(DISABLE_DYNLOADING),)
+$(eval $(call gb_ExternalPackage_add_file,raptor,$(LIBO_LIB_FOLDER)/libraptor2-lo.so.$(RAPTOR_MAJOR),src/.libs/libraptor2-lo.so.$(RAPTOR_MAJOR).0.0))
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/redland/ExternalPackage_rasqal.mk b/external/redland/ExternalPackage_rasqal.mk
new file mode 100644
index 000000000..57fe97c38
--- /dev/null
+++ b/external/redland/ExternalPackage_rasqal.mk
@@ -0,0 +1,22 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_ExternalPackage_ExternalPackage,rasqal,rasqal))
+
+$(eval $(call gb_ExternalPackage_use_external_project,rasqal,rasqal))
+
+ifeq ($(OS),MACOSX)
+$(eval $(call gb_ExternalPackage_add_file,rasqal,$(LIBO_LIB_FOLDER)/librasqal-lo.$(RASQAL_MAJOR).dylib,src/.libs/librasqal-lo.$(RASQAL_MAJOR).dylib))
+else ifeq ($(COM),MSC)
+$(eval $(call gb_ExternalPackage_add_file,rasqal,$(LIBO_LIB_FOLDER)/librasqal.dll,src/.libs/librasqal.dll))
+else ifeq ($(DISABLE_DYNLOADING),)
+$(eval $(call gb_ExternalPackage_add_file,rasqal,$(LIBO_LIB_FOLDER)/librasqal-lo.so.$(RASQAL_MAJOR),src/.libs/librasqal-lo.so.$(RASQAL_MAJOR).0.0))
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/redland/ExternalPackage_redland.mk b/external/redland/ExternalPackage_redland.mk
new file mode 100644
index 000000000..8c35d850e
--- /dev/null
+++ b/external/redland/ExternalPackage_redland.mk
@@ -0,0 +1,22 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_ExternalPackage_ExternalPackage,redland,redland))
+
+$(eval $(call gb_ExternalPackage_use_external_project,redland,redland))
+
+ifeq ($(OS),MACOSX)
+$(eval $(call gb_ExternalPackage_add_file,redland,$(LIBO_LIB_FOLDER)/librdf-lo.$(REDLAND_MAJOR).dylib,src/.libs/librdf-lo.$(REDLAND_MAJOR).dylib))
+else ifeq ($(COM),MSC)
+$(eval $(call gb_ExternalPackage_add_file,redland,$(LIBO_LIB_FOLDER)/librdf.dll,src/.libs/librdf.dll))
+else ifeq ($(DISABLE_DYNLOADING),)
+$(eval $(call gb_ExternalPackage_add_file,redland,$(LIBO_LIB_FOLDER)/librdf-lo.so.$(REDLAND_MAJOR),src/.libs/librdf-lo.so.$(REDLAND_MAJOR).0.0))
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/redland/ExternalProject_raptor.mk b/external/redland/ExternalProject_raptor.mk
new file mode 100644
index 000000000..b3ae74c10
--- /dev/null
+++ b/external/redland/ExternalProject_raptor.mk
@@ -0,0 +1,47 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_ExternalProject_ExternalProject,raptor))
+
+$(eval $(call gb_ExternalProject_use_external,raptor,libxml2))
+
+$(eval $(call gb_ExternalProject_register_targets,raptor,\
+ build \
+))
+
+$(call gb_ExternalProject_get_state_target,raptor,build):
+ $(call gb_Trace_StartRange,raptor,EXTERNAL)
+ $(call gb_ExternalProject_run,build,\
+ $(if $(filter iOS,$(OS)),LIBS="-liconv") \
+ CFLAGS="$(CFLAGS) \
+ $(call gb_ExternalProject_get_build_flags,raptor) \
+ $(if $(filter TRUE,$(DISABLE_DYNLOADING)),-fvisibility=hidden) \
+ $(if $(filter GCCLINUXPOWERPC64,$(COM)$(OS)$(CPUNAME)),-mminimal-toc)" \
+ LDFLAGS=" \
+ $(if $(filter LINUX FREEBSD,$(OS)),-Wl$(COMMA)-z$(COMMA)origin -Wl$(COMMA)-rpath$(COMMA)\\"\$$\$$ORIGIN") \
+ $(if $(SYSBASE),$(if $(filter LINUX SOLARIS,$(OS)),-L$(SYSBASE)/lib -L$(SYSBASE)/usr/lib -lpthread -ldl))" \
+ CPPFLAGS="$(if $(SYSBASE),-I$(SYSBASE)/usr/include) $(gb_EMSCRIPTEN_CPPFLAGS)" \
+ $(gb_RUN_CONFIGURE) ./configure --disable-gtk-doc \
+ --enable-parsers="rdfxml ntriples turtle trig guess rss-tag-soup" \
+ --with-www=xml \
+ --without-xslt-config \
+ $(gb_CONFIGURE_PLATFORMS) \
+ $(if $(CROSS_COMPILING),$(if $(filter INTEL ARM,$(CPUNAME)),ac_cv_c_bigendian=no)) \
+ $(if $(filter MACOSX,$(OS)),--prefix=/@.__________________________________________________OOO) \
+ $(if $(DISABLE_DYNLOADING), \
+ --enable-static --disable-shared \
+ , \
+ --enable-shared --disable-static \
+ ) \
+ $(if $(SYSTEM_LIBXML),$(if $(filter-out MACOSX,$(OS)),--without-xml2-config),--with-xml2-config=$(call gb_UnpackedTarball_get_dir,libxml2)/xml2-config) \
+ && $(MAKE) \
+ )
+ $(call gb_Trace_EndRange,raptor,EXTERNAL)
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/redland/ExternalProject_rasqal.mk b/external/redland/ExternalProject_rasqal.mk
new file mode 100644
index 000000000..e7d1fdb11
--- /dev/null
+++ b/external/redland/ExternalProject_rasqal.mk
@@ -0,0 +1,54 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_ExternalProject_ExternalProject,rasqal))
+
+$(eval $(call gb_ExternalProject_use_external,rasqal,libxml2))
+
+$(eval $(call gb_ExternalProject_use_package,rasqal,raptor))
+
+$(eval $(call gb_ExternalProject_register_targets,rasqal,\
+ build \
+))
+
+# note: this can intentionally only build against internal raptor (not system)
+
+$(call gb_ExternalProject_get_state_target,rasqal,build):
+ $(call gb_Trace_StartRange,rasqal,EXTERNAL)
+ $(call gb_ExternalProject_run,build,\
+ CFLAGS="$(CFLAGS) $(if $(filter TRUE,$(DISABLE_DYNLOADING)),-fvisibility=hidden) $(call gb_ExternalProject_get_build_flags,rasqal) $(gb_EMSCRIPTEN_CPPFLAGS)" \
+ LDFLAGS=" \
+ $(if $(filter LINUX FREEBSD,$(OS)),-Wl$(COMMA)-z$(COMMA)origin -Wl$(COMMA)-rpath$(COMMA)\\"\$$\$$ORIGIN") \
+ $(if $(SYSBASE),$(if $(filter LINUX SOLARIS,$(OS)),-L$(SYSBASE)/lib -L$(SYSBASE)/usr/lib -lpthread -ldl))" \
+ $(if $(SYSBASE),CPPFLAGS="-I$(SYSBASE)/usr/include") \
+ PKG_CONFIG="" \
+ RAPTOR2_CFLAGS="-I$(call gb_UnpackedTarball_get_dir,raptor)/src" \
+ RAPTOR2_LIBS="-L$(call gb_UnpackedTarball_get_dir,raptor)/src/.libs -lraptor2" \
+ $(gb_RUN_CONFIGURE) ./configure --disable-gtk-doc \
+ --with-regex-library=posix \
+ --with-decimal=none \
+ --with-uuid-library=internal \
+ --with-digest-library=internal \
+ $(gb_CONFIGURE_PLATFORMS) \
+ $(if $(CROSS_COMPILING),$(if $(filter INTEL ARM,$(CPUNAME)),ac_cv_c_bigendian=no)) \
+ $(if $(filter MACOSX,$(OS)),--prefix=/@.__________________________________________________OOO) \
+ $(if $(DISABLE_DYNLOADING), \
+ --enable-static --disable-shared \
+ , \
+ --enable-shared --disable-static \
+ ) \
+ $(if $(SYSTEM_LIBXML),,--with-xml2-config=$(call gb_UnpackedTarball_get_dir,libxml2)/xml2-config) \
+ && $(MAKE) \
+ $(if $(filter MACOSX,$(OS)),&& $(PERL) \
+ $(SRCDIR)/solenv/bin/macosx-change-install-names.pl shl OOO \
+ $(EXTERNAL_WORKDIR)/src/.libs/librasqal-lo.$(RASQAL_MAJOR).dylib) \
+ )
+ $(call gb_Trace_EndRange,rasqal,EXTERNAL)
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/redland/ExternalProject_redland.mk b/external/redland/ExternalProject_redland.mk
new file mode 100644
index 000000000..d92c642b9
--- /dev/null
+++ b/external/redland/ExternalProject_redland.mk
@@ -0,0 +1,57 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_ExternalProject_ExternalProject,redland))
+
+$(eval $(call gb_ExternalProject_use_packages,redland, \
+ raptor \
+ rasqal \
+))
+
+$(eval $(call gb_ExternalProject_register_targets,redland,\
+ build \
+))
+
+# note: this can intentionally only build against internal raptor/rasqal
+
+$(call gb_ExternalProject_get_state_target,redland,build):
+ $(call gb_Trace_StartRange,redland,EXTERNAL)
+ $(call gb_ExternalProject_run,build,\
+ CFLAGS="$(CFLAGS) $(if $(filter TRUE,$(DISABLE_DYNLOADING)),-fvisibility=hidden) $(call gb_ExternalProject_get_build_flags,redland) $(gb_EMSCRIPTEN_CPPFLAGS)" \
+ LDFLAGS=" \
+ $(if $(filter LINUX FREEBSD,$(OS)),-Wl$(COMMA)-z$(COMMA)origin -Wl$(COMMA)-rpath$(COMMA)\\"\$$\$$ORIGIN") \
+ $(if $(SYSBASE),$(if $(filter LINUX SOLARIS,$(OS)),-L$(SYSBASE)/lib -L$(SYSBASE)/usr/lib -lpthread -ldl))" \
+ CPPFLAGS="$(if $(SYSBASE),-I$(SYSBASE)/usr/include)" \
+ PKG_CONFIG="" \
+ RAPTOR2_CFLAGS="-I$(call gb_UnpackedTarball_get_dir,raptor)/src" \
+ RAPTOR2_LIBS="-L$(call gb_UnpackedTarball_get_dir,raptor)/src/.libs -lraptor2 $(LIBXML_LIBS)" \
+ RASQAL_CFLAGS="-I$(call gb_UnpackedTarball_get_dir,rasqal)/src" \
+ RASQAL_LIBS="-L$(call gb_UnpackedTarball_get_dir,rasqal)/src/.libs -lrasqal" \
+ $(gb_RUN_CONFIGURE) ./configure --disable-gtk-doc \
+ --disable-modular \
+ --without-threads \
+ --without-bdb --without-sqlite --without-mysql \
+ --without-postgresql --without-threestone --without-virtuoso \
+ $(gb_CONFIGURE_PLATFORMS) \
+ $(if $(CROSS_COMPILING),$(if $(filter INTEL ARM,$(CPUNAME)),ac_cv_c_bigendian=no)) \
+ $(if $(filter MACOSX,$(OS)),--prefix=/@.__________________________________________________OOO) \
+ $(if $(ENABLE_DEBUG),--enable-debug) \
+ $(if $(DISABLE_DYNLOADING), \
+ --enable-static --disable-shared \
+ , \
+ --enable-shared --disable-static \
+ ) \
+ && $(MAKE) \
+ $(if $(filter MACOSX,$(OS)),&& $(PERL) \
+ $(SRCDIR)/solenv/bin/macosx-change-install-names.pl shl OOO \
+ $(EXTERNAL_WORKDIR)/src/.libs/librdf-lo.$(REDLAND_MAJOR).dylib) \
+ )
+ $(call gb_Trace_EndRange,redland,EXTERNAL)
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/redland/Library_raptor.mk b/external/redland/Library_raptor.mk
new file mode 100644
index 000000000..b2779f7de
--- /dev/null
+++ b/external/redland/Library_raptor.mk
@@ -0,0 +1,88 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Library_Library,raptor2))
+
+$(eval $(call gb_Library_set_include,raptor2, \
+ -I$(call gb_UnpackedTarball_get_dir,raptor)/src \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_Library_use_unpacked,raptor2,raptor))
+
+$(eval $(call gb_Library_use_externals,raptor2,\
+ libxml2 \
+ libxslt \
+))
+
+$(eval $(call gb_Library_set_warnings_disabled,raptor2))
+
+$(eval $(call gb_Library_add_defs,raptor2,\
+ -DHAVE_CONFIG_H \
+ -DRAPTOR_INTERNAL \
+ -DWIN32 \
+ -DNDEBUG \
+ -D_WINDOWS \
+ -D_USRDLL \
+ -DWIN32_EXPORTS \
+ -DYY_NO_UNISTD_H \
+ -DHAVE__ACCESS \
+ -UHAVE_ACCESS \
+))
+
+$(eval $(call gb_Library_add_generated_cobjects,raptor2,\
+ UnpackedTarball/raptor/src/ntriples_parse \
+ UnpackedTarball/raptor/src/parsedate \
+ UnpackedTarball/raptor/src/raptor_abbrev \
+ UnpackedTarball/raptor/src/raptor_avltree \
+ UnpackedTarball/raptor/src/raptor_concepts \
+ UnpackedTarball/raptor/src/raptor_escaped \
+ UnpackedTarball/raptor/src/raptor_general \
+ UnpackedTarball/raptor/src/raptor_guess \
+ UnpackedTarball/raptor/src/raptor_iostream \
+ UnpackedTarball/raptor/src/raptor_json_writer \
+ UnpackedTarball/raptor/src/raptor_libxml \
+ UnpackedTarball/raptor/src/raptor_locator \
+ UnpackedTarball/raptor/src/raptor_log \
+ UnpackedTarball/raptor/src/raptor_memstr \
+ UnpackedTarball/raptor/src/raptor_namespace \
+ UnpackedTarball/raptor/src/raptor_ntriples \
+ UnpackedTarball/raptor/src/raptor_option \
+ UnpackedTarball/raptor/src/raptor_parse \
+ UnpackedTarball/raptor/src/raptor_qname \
+ UnpackedTarball/raptor/src/raptor_rdfxml \
+ UnpackedTarball/raptor/src/raptor_rfc2396 \
+ UnpackedTarball/raptor/src/raptor_sax2 \
+ UnpackedTarball/raptor/src/raptor_sequence \
+ UnpackedTarball/raptor/src/raptor_serialize \
+ UnpackedTarball/raptor/src/raptor_serialize_ntriples \
+ UnpackedTarball/raptor/src/raptor_serialize_rdfxml \
+ UnpackedTarball/raptor/src/raptor_serialize_rdfxmla \
+ UnpackedTarball/raptor/src/raptor_serialize_turtle \
+ UnpackedTarball/raptor/src/raptor_set \
+ UnpackedTarball/raptor/src/raptor_statement \
+ UnpackedTarball/raptor/src/raptor_stringbuffer \
+ UnpackedTarball/raptor/src/raptor_syntax_description \
+ UnpackedTarball/raptor/src/raptor_term \
+ UnpackedTarball/raptor/src/raptor_turtle_writer \
+ UnpackedTarball/raptor/src/raptor_unicode \
+ UnpackedTarball/raptor/src/raptor_uri \
+ UnpackedTarball/raptor/src/raptor_www \
+ UnpackedTarball/raptor/src/raptor_xml \
+ UnpackedTarball/raptor/src/raptor_xml_writer \
+ UnpackedTarball/raptor/src/snprintf \
+ UnpackedTarball/raptor/src/sort_r \
+ UnpackedTarball/raptor/src/strcasecmp \
+ UnpackedTarball/raptor/src/turtle_common \
+ UnpackedTarball/raptor/src/turtle_lexer \
+ UnpackedTarball/raptor/src/turtle_parser \
+))
+
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/redland/Library_rasqal.mk b/external/redland/Library_rasqal.mk
new file mode 100644
index 000000000..79171d904
--- /dev/null
+++ b/external/redland/Library_rasqal.mk
@@ -0,0 +1,127 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Library_Library,rasqal))
+
+$(eval $(call gb_Library_use_unpacked,rasqal,rasqal))
+
+$(eval $(call gb_Library_set_warnings_disabled,rasqal))
+
+$(eval $(call gb_Library_use_external,rasqal,raptor_headers))
+
+$(eval $(call gb_Library_use_libraries,rasqal,raptor2))
+
+$(eval $(call gb_Library_add_defs,rasqal,\
+ -DSV_CONFIG \
+ -DRASQAL_INTERNAL \
+ -DWIN32 \
+ -DNDEBUG \
+ -D_WINDOWS \
+ -D_USRDLL \
+ -DWIN32_EXPORTS \
+ -D_MT \
+ -DHAVE_STDLIB_H \
+ -DHAVE_STDINT_H \
+ -DHAVE_TIME_H \
+ -DHAVE_MATH_H \
+ -DHAVE_FLOAT_H \
+ -DHAVE___FUNCTION__ \
+))
+
+$(eval $(call gb_Library_set_include,rasqal,\
+ -I$(call gb_UnpackedTarball_get_dir,rasqal)/libmtwist \
+ -I$(call gb_UnpackedTarball_get_dir,rasqal)/libsv \
+ -I$(call gb_UnpackedTarball_get_dir,rasqal)/src \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_Library_add_generated_cobjects,rasqal,\
+ UnpackedTarball/rasqal/libmtwist/mt \
+ UnpackedTarball/rasqal/libmtwist/seed \
+ UnpackedTarball/rasqal/libsv/sv \
+ UnpackedTarball/rasqal/src/rasqal_algebra \
+ UnpackedTarball/rasqal/src/rasqal_bindings \
+ UnpackedTarball/rasqal/src/rasqal_data_graph \
+ UnpackedTarball/rasqal/src/rasqal_dataset \
+ UnpackedTarball/rasqal/src/rasqal_datetime \
+ UnpackedTarball/rasqal/src/rasqal_decimal \
+ UnpackedTarball/rasqal/src/rasqal_digest \
+ UnpackedTarball/rasqal/src/rasqal_digest_md5 \
+ UnpackedTarball/rasqal/src/rasqal_digest_sha1 \
+ UnpackedTarball/rasqal/src/rasqal_double \
+ UnpackedTarball/rasqal/src/rasqal_engine \
+ UnpackedTarball/rasqal/src/rasqal_engine_algebra \
+ UnpackedTarball/rasqal/src/rasqal_engine_sort \
+ UnpackedTarball/rasqal/src/rasqal_expr \
+ UnpackedTarball/rasqal/src/rasqal_expr_datetimes \
+ UnpackedTarball/rasqal/src/rasqal_expr_evaluate \
+ UnpackedTarball/rasqal/src/rasqal_expr_numerics \
+ UnpackedTarball/rasqal/src/rasqal_expr_strings \
+ UnpackedTarball/rasqal/src/rasqal_feature \
+ UnpackedTarball/rasqal/src/rasqal_format_html \
+ UnpackedTarball/rasqal/src/rasqal_format_json \
+ UnpackedTarball/rasqal/src/rasqal_format_rdf \
+ UnpackedTarball/rasqal/src/rasqal_format_sparql_xml \
+ UnpackedTarball/rasqal/src/rasqal_format_sv \
+ UnpackedTarball/rasqal/src/rasqal_format_table \
+ UnpackedTarball/rasqal/src/rasqal_formula \
+ UnpackedTarball/rasqal/src/rasqal_general \
+ UnpackedTarball/rasqal/src/rasqal_graph_pattern \
+ UnpackedTarball/rasqal/src/rasqal_iostream \
+ UnpackedTarball/rasqal/src/rasqal_literal \
+ UnpackedTarball/rasqal/src/rasqal_map \
+ UnpackedTarball/rasqal/src/rasqal_ntriples \
+ UnpackedTarball/rasqal/src/rasqal_prefix \
+ UnpackedTarball/rasqal/src/rasqal_projection \
+ UnpackedTarball/rasqal/src/rasqal_query \
+ UnpackedTarball/rasqal/src/rasqal_query_results \
+ UnpackedTarball/rasqal/src/rasqal_query_transform \
+ UnpackedTarball/rasqal/src/rasqal_query_write \
+ UnpackedTarball/rasqal/src/rasqal_random \
+ UnpackedTarball/rasqal/src/rasqal_raptor \
+ UnpackedTarball/rasqal/src/rasqal_regex \
+ UnpackedTarball/rasqal/src/rasqal_result_formats \
+ UnpackedTarball/rasqal/src/rasqal_results_compare \
+ UnpackedTarball/rasqal/src/rasqal_row \
+ UnpackedTarball/rasqal/src/rasqal_row_compatible \
+ UnpackedTarball/rasqal/src/rasqal_rowsource \
+ UnpackedTarball/rasqal/src/rasqal_rowsource_aggregation \
+ UnpackedTarball/rasqal/src/rasqal_rowsource_assignment \
+ UnpackedTarball/rasqal/src/rasqal_rowsource_bindings \
+ UnpackedTarball/rasqal/src/rasqal_rowsource_distinct \
+ UnpackedTarball/rasqal/src/rasqal_rowsource_empty \
+ UnpackedTarball/rasqal/src/rasqal_rowsource_filter \
+ UnpackedTarball/rasqal/src/rasqal_rowsource_graph \
+ UnpackedTarball/rasqal/src/rasqal_rowsource_groupby \
+ UnpackedTarball/rasqal/src/rasqal_rowsource_having \
+ UnpackedTarball/rasqal/src/rasqal_rowsource_join \
+ UnpackedTarball/rasqal/src/rasqal_rowsource_project \
+ UnpackedTarball/rasqal/src/rasqal_rowsource_rowsequence \
+ UnpackedTarball/rasqal/src/rasqal_rowsource_service \
+ UnpackedTarball/rasqal/src/rasqal_rowsource_slice \
+ UnpackedTarball/rasqal/src/rasqal_rowsource_sort \
+ UnpackedTarball/rasqal/src/rasqal_rowsource_triples \
+ UnpackedTarball/rasqal/src/rasqal_rowsource_union \
+ UnpackedTarball/rasqal/src/rasqal_service \
+ UnpackedTarball/rasqal/src/rasqal_solution_modifier \
+ UnpackedTarball/rasqal/src/rasqal_sort \
+ UnpackedTarball/rasqal/src/rasqal_triple \
+ UnpackedTarball/rasqal/src/rasqal_triples_source \
+ UnpackedTarball/rasqal/src/rasqal_update \
+ UnpackedTarball/rasqal/src/rasqal_variable \
+ UnpackedTarball/rasqal/src/rasqal_xsd_datatypes \
+ UnpackedTarball/rasqal/src/snprintf \
+ UnpackedTarball/rasqal/src/sparql_lexer \
+ UnpackedTarball/rasqal/src/sparql_parser \
+ UnpackedTarball/rasqal/src/timegm \
+ UnpackedTarball/rasqal/src/gettimeofday \
+))
+
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/redland/Library_rdf.mk b/external/redland/Library_rdf.mk
new file mode 100644
index 000000000..cc427b339
--- /dev/null
+++ b/external/redland/Library_rdf.mk
@@ -0,0 +1,78 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Library_Library,rdf))
+
+$(eval $(call gb_Library_set_include,rdf, \
+ -I$(call gb_UnpackedTarball_get_dir,redland)/src \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_Library_use_unpacked,rdf,redland))
+
+$(eval $(call gb_Library_set_warnings_disabled,rdf))
+
+$(eval $(call gb_Library_use_libraries,rdf,\
+ raptor2 \
+ rasqal \
+))
+
+$(eval $(call gb_Library_use_externals,rdf,\
+ raptor_headers \
+ rasqal_headers \
+))
+
+$(eval $(call gb_Library_add_defs,rdf,\
+ -DLIBRDF_INTERNAL \
+ -DWIN32 \
+ -DNDEBUG \
+ -D_WINDOWS \
+ -D_USRDLL \
+ -DWIN32_EXPORTS \
+))
+
+$(eval $(call gb_Library_add_generated_cobjects,rdf,\
+ UnpackedTarball/redland/src/rdf_concepts \
+ UnpackedTarball/redland/src/rdf_digest \
+ UnpackedTarball/redland/src/rdf_digest_md5 \
+ UnpackedTarball/redland/src/rdf_digest_sha1 \
+ UnpackedTarball/redland/src/rdf_files \
+ UnpackedTarball/redland/src/rdf_hash \
+ UnpackedTarball/redland/src/rdf_hash_cursor \
+ UnpackedTarball/redland/src/rdf_hash_memory \
+ UnpackedTarball/redland/src/rdf_heuristics \
+ UnpackedTarball/redland/src/rdf_init \
+ UnpackedTarball/redland/src/rdf_iterator \
+ UnpackedTarball/redland/src/rdf_list \
+ UnpackedTarball/redland/src/rdf_log \
+ UnpackedTarball/redland/src/rdf_model \
+ UnpackedTarball/redland/src/rdf_model_storage \
+ UnpackedTarball/redland/src/rdf_node \
+ UnpackedTarball/redland/src/rdf_node_common \
+ UnpackedTarball/redland/src/rdf_parser \
+ UnpackedTarball/redland/src/rdf_parser_raptor \
+ UnpackedTarball/redland/src/rdf_raptor \
+ UnpackedTarball/redland/src/rdf_query \
+ UnpackedTarball/redland/src/rdf_query_rasqal \
+ UnpackedTarball/redland/src/rdf_query_results \
+ UnpackedTarball/redland/src/rdf_serializer \
+ UnpackedTarball/redland/src/rdf_serializer_raptor \
+ UnpackedTarball/redland/src/rdf_statement \
+ UnpackedTarball/redland/src/rdf_statement_common \
+ UnpackedTarball/redland/src/rdf_storage \
+ UnpackedTarball/redland/src/rdf_storage_file \
+ UnpackedTarball/redland/src/rdf_storage_list \
+ UnpackedTarball/redland/src/rdf_storage_hashes \
+ UnpackedTarball/redland/src/rdf_storage_trees \
+ UnpackedTarball/redland/src/rdf_stream \
+ UnpackedTarball/redland/src/rdf_uri \
+ UnpackedTarball/redland/src/rdf_utf8 \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/redland/Makefile b/external/redland/Makefile
new file mode 100644
index 000000000..e4968cf85
--- /dev/null
+++ b/external/redland/Makefile
@@ -0,0 +1,7 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+
+module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
+
+include $(module_directory)/../../solenv/gbuild/partial_build.mk
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/redland/Module_redland.mk b/external/redland/Module_redland.mk
new file mode 100644
index 000000000..adc81b462
--- /dev/null
+++ b/external/redland/Module_redland.mk
@@ -0,0 +1,34 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Module_Module,redland))
+
+$(eval $(call gb_Module_add_targets,redland,\
+ UnpackedTarball_raptor \
+ UnpackedTarball_rasqal \
+ UnpackedTarball_redland \
+))
+ifeq ($(COM),MSC)
+$(eval $(call gb_Module_add_targets,redland,\
+ Library_raptor \
+ Library_rasqal \
+ Library_rdf \
+))
+else
+$(eval $(call gb_Module_add_targets,redland,\
+ ExternalPackage_raptor \
+ ExternalPackage_rasqal \
+ ExternalPackage_redland \
+ ExternalProject_raptor \
+ ExternalProject_rasqal \
+ ExternalProject_redland \
+))
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/redland/README b/external/redland/README
new file mode 100644
index 000000000..591e93398
--- /dev/null
+++ b/external/redland/README
@@ -0,0 +1,24 @@
+Redland RDF library (librdf) from [http://librdf.org/]
+
+== License ==
+[git:redland/LICENSE.txt]
+Triple-licensed: LGPL v2+/GPL v2+/Apache v2
+
+== Description ==
+This module contains the third-party Redland RDF / librdf library, which
+is needed to support data in RDF (Resource Description Framework) format.
+It consists of 3 parts:
+- raptor: parsers and serializers for numerous RDF file formats
+- rasqal: query engine which supports SPARQL queries
+- redland: librdf integrates raptor and rasqal, and provides numerous storage
+ engines for storing RDF graphs (in memory, SQL, ...)
+
+Libraries: libraptor, librasqal, librdf
+
+== Patches ==
+There are several patches, most of which contain only hacks to get it to
+build with the LO build system.
+
+Upstream may merge patches that are attached to the bug tracker, but don't
+send patches to the mailing list, those will most likely be ignored.
+
diff --git a/external/redland/UnpackedTarball_raptor.mk b/external/redland/UnpackedTarball_raptor.mk
new file mode 100644
index 000000000..fbdc8b6f5
--- /dev/null
+++ b/external/redland/UnpackedTarball_raptor.mk
@@ -0,0 +1,35 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_UnpackedTarball_UnpackedTarball,raptor))
+
+$(eval $(call gb_UnpackedTarball_set_tarball,raptor,$(RAPTOR_TARBALL),,redland))
+
+$(eval $(call gb_UnpackedTarball_update_autoconf_configs,raptor,build))
+
+# configure generated files for MSVC
+$(eval $(call gb_UnpackedTarball_add_file,raptor,src/raptor2.h,external/redland/raptor/raptor2.h))
+$(eval $(call gb_UnpackedTarball_add_file,raptor,src/raptor_config.h,external/redland/raptor/raptor_config.h))
+
+$(eval $(call gb_UnpackedTarball_set_patchlevel,raptor,0))
+
+$(eval $(call gb_UnpackedTarball_add_patches,raptor,\
+ external/redland/raptor/raptor-freebsd.patch.1 \
+ external/redland/raptor/raptor-msvc.patch.1 \
+ $(if $(filter-out WNT,$(OS)),external/redland/raptor/raptor-bundled-soname.patch.1) \
+ $(if $(filter ANDROID,$(OS)),external/redland/raptor/raptor-android.patch.1) \
+ external/redland/raptor/ubsan.patch \
+ $(if $(SYSTEM_LIBXML),,external/redland/raptor/rpath.patch) \
+ external/redland/raptor/xml2-config.patch \
+ external/redland/raptor/0001-Calcualte-max-nspace-declarations-correctly-for-XML-.patch.1 \
+ external/redland/raptor/0001-CVE-2020-25713-raptor2-malformed-input-file-can-lead.patch.1 \
+ external/redland/raptor/libtool.patch \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/redland/UnpackedTarball_rasqal.mk b/external/redland/UnpackedTarball_rasqal.mk
new file mode 100644
index 000000000..bb44f39a6
--- /dev/null
+++ b/external/redland/UnpackedTarball_rasqal.mk
@@ -0,0 +1,34 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_UnpackedTarball_UnpackedTarball,rasqal))
+
+$(eval $(call gb_UnpackedTarball_set_tarball,rasqal,$(RASQAL_TARBALL),,redland))
+
+$(eval $(call gb_UnpackedTarball_update_autoconf_configs,rasqal,build))
+
+# configure generated files for MSVC
+$(eval $(call gb_UnpackedTarball_add_file,rasqal,src/rasqal.h,external/redland/rasqal/rasqal.h))
+
+$(eval $(call gb_UnpackedTarball_set_patchlevel,rasqal,0))
+
+$(eval $(call gb_UnpackedTarball_add_patches,rasqal,\
+ external/redland/rasqal/rasqal-pkgconfig.patch.1 \
+ external/redland/rasqal/rasqal-freebsd.patch.1 \
+ external/redland/rasqal/rasqal-msvc.patch.1 \
+ external/redland/rasqal/rasqal-aix.patch.1 \
+ $(if $(filter-out WNT,$(OS)),external/redland/rasqal/rasqal-bundled-soname.patch.1) \
+ $(if $(filter ANDROID,$(OS)),external/redland/rasqal/rasqal-android.patch.1) \
+ $(if $(CROSS_COMPILING),external/redland/rasqal/rasqal-xcompile.patch.1) \
+ external/redland/rasqal/rpath.patch \
+ external/redland/rasqal/clang-cl.patch \
+ external/redland/rasqal/libtool.patch \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/redland/UnpackedTarball_redland.mk b/external/redland/UnpackedTarball_redland.mk
new file mode 100644
index 000000000..66e766d20
--- /dev/null
+++ b/external/redland/UnpackedTarball_redland.mk
@@ -0,0 +1,38 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_UnpackedTarball_UnpackedTarball,redland))
+
+$(eval $(call gb_UnpackedTarball_set_tarball,redland,$(REDLAND_TARBALL),,redland))
+
+$(eval $(call gb_UnpackedTarball_update_autoconf_configs,redland,\
+ build \
+ libltdl/config \
+))
+
+# configure generated files for MSVC
+$(eval $(call gb_UnpackedTarball_add_file,redland,src/librdf.h,external/redland/redland/librdf.h))
+
+$(eval $(call gb_UnpackedTarball_set_patchlevel,redland,0))
+
+# redland-format.patch.0 sent upstream as
+# <https://github.com/dajobe/librdf/pull/6>
+$(eval $(call gb_UnpackedTarball_add_patches,redland,\
+ external/redland/redland/redland-freebsd.patch.1 \
+ external/redland/redland/redland-msvc.patch.1 \
+ $(if $(filter-out WNT,$(OS)),external/redland/redland/redland-bundled-soname.patch.1) \
+ $(if $(filter ANDROID,$(OS)),external/redland/redland/redland-android.patch.1) \
+ $(if $(CROSS_COMPILING),external/redland/redland/redland-xcompile.patch.1) \
+ external/redland/redland/redland-format.patch.0 \
+ external/redland/redland/rpath.patch \
+ external/redland/redland/clang-cl.patch \
+ external/redland/redland/libtool.patch \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/redland/raptor/0001-CVE-2020-25713-raptor2-malformed-input-file-can-lead.patch.1 b/external/redland/raptor/0001-CVE-2020-25713-raptor2-malformed-input-file-can-lead.patch.1
new file mode 100644
index 000000000..1fb279df3
--- /dev/null
+++ b/external/redland/raptor/0001-CVE-2020-25713-raptor2-malformed-input-file-can-lead.patch.1
@@ -0,0 +1,33 @@
+From a549457461874157c8c8e8e8a6e0eec06da4fbd0 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
+Date: Tue, 24 Nov 2020 10:30:20 +0000
+Subject: [PATCH] CVE-2020-25713 raptor2: malformed input file can lead to a
+ segfault
+
+due to an out of bounds array access in
+raptor_xml_writer_start_element_common
+
+See:
+https://bugs.mageia.org/show_bug.cgi?id=27605
+https://www.openwall.com/lists/oss-security/2020/11/13/1
+https://gerrit.libreoffice.org/c/core/+/106249
+---
+ src/raptor_xml_writer.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/raptor_xml_writer.c b/src/raptor_xml_writer.c
+index 56993dc3..4426d38c 100644
+--- a/src/raptor_xml_writer.c
++++ b/src/raptor_xml_writer.c
+@@ -227,7 +227,7 @@ raptor_xml_writer_start_element_common(raptor_xml_writer* xml_writer,
+
+ /* check it wasn't an earlier declaration too */
+ for(j = 0; j < nspace_declarations_count; j++)
+- if(nspace_declarations[j].nspace == element->attributes[j]->nspace) {
++ if(nspace_declarations[j].nspace == element->attributes[i]->nspace) {
+ declare_me = 0;
+ break;
+ }
+--
+2.28.0
+
diff --git a/external/redland/raptor/0001-Calcualte-max-nspace-declarations-correctly-for-XML-.patch.1 b/external/redland/raptor/0001-Calcualte-max-nspace-declarations-correctly-for-XML-.patch.1
new file mode 100644
index 000000000..6fa726cae
--- /dev/null
+++ b/external/redland/raptor/0001-Calcualte-max-nspace-declarations-correctly-for-XML-.patch.1
@@ -0,0 +1,43 @@
+From 590681e546cd9aa18d57dc2ea1858cb734a3863f Mon Sep 17 00:00:00 2001
+From: Dave Beckett <dave@dajobe.org>
+Date: Sun, 16 Apr 2017 23:15:12 +0100
+Subject: [PATCH] Calcualte max nspace declarations correctly for XML writer
+
+(raptor_xml_writer_start_element_common): Calculate max including for
+each attribute a potential name and value.
+
+Fixes Issues #0000617 http://bugs.librdf.org/mantis/view.php?id=617
+and #0000618 http://bugs.librdf.org/mantis/view.php?id=618
+---
+ src/raptor_xml_writer.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/src/raptor_xml_writer.c b/src/raptor_xml_writer.c
+index 693b946..0d3a36a 100644
+--- a/src/raptor_xml_writer.c
++++ b/src/raptor_xml_writer.c
+@@ -181,9 +181,10 @@ raptor_xml_writer_start_element_common(raptor_xml_writer* xml_writer,
+ size_t nspace_declarations_count = 0;
+ unsigned int i;
+
+- /* max is 1 per element and 1 for each attribute + size of declared */
+ if(nstack) {
+- int nspace_max_count = element->attribute_count+1;
++ int nspace_max_count = element->attribute_count * 2; /* attr and value */
++ if(element->name->nspace)
++ nspace_max_count++;
+ if(element->declared_nspaces)
+ nspace_max_count += raptor_sequence_size(element->declared_nspaces);
+ if(element->xml_language)
+@@ -237,7 +238,7 @@ raptor_xml_writer_start_element_common(raptor_xml_writer* xml_writer,
+ }
+ }
+
+- /* Add the attribute + value */
++ /* Add the attribute's value */
+ nspace_declarations[nspace_declarations_count].declaration=
+ raptor_qname_format_as_xml(element->attributes[i],
+ &nspace_declarations[nspace_declarations_count].length);
+--
+2.9.3
+
diff --git a/external/redland/raptor/libtool.patch b/external/redland/raptor/libtool.patch
new file mode 100644
index 000000000..b0baae661
--- /dev/null
+++ b/external/redland/raptor/libtool.patch
@@ -0,0 +1,27 @@
+--- build/ltmain.sh
++++ build/ltmain.sh
+@@ -5301,6 +5301,12 @@
+ prev=
+ continue
+ ;;
++ mllvm)
++ # Clang does not use LLVM to link, so we can simply discard any
++ # '-mllvm $arg' options when doing the link step.
++ prev=
++ continue
++ ;;
+ objectlist)
+ if test -f "$arg"; then
+ save_arg=$arg
+@@ -5639,6 +5645,11 @@
+ continue
+ ;;
+
++ -mllvm)
++ prev=mllvm
++ continue
++ ;;
++
+ -module)
+ module=yes
+ continue
diff --git a/external/redland/raptor/raptor-android.patch.1 b/external/redland/raptor/raptor-android.patch.1
new file mode 100644
index 000000000..cb843839c
--- /dev/null
+++ b/external/redland/raptor/raptor-android.patch.1
@@ -0,0 +1,13 @@
+No sonames on Android
+
+--- a/configure 2013-03-29 19:46:34.922901756 +0100
++++ b/configure 2013-03-29 19:46:56.051901574 +0100
+@@ -9866,7 +9866,7 @@
+ *Sun\ F*) # Sun Fortran 8.3
+ tmp_sharedflag='-G' ;;
+ esac
+- archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags -o $lib'
+
+ if test "x$supports_anon_versioning" = xyes; then
+ archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
diff --git a/external/redland/raptor/raptor-bundled-soname.patch.1 b/external/redland/raptor/raptor-bundled-soname.patch.1
new file mode 100644
index 000000000..cce2482d1
--- /dev/null
+++ b/external/redland/raptor/raptor-bundled-soname.patch.1
@@ -0,0 +1,13 @@
+rhbz#809466 change soname of bundled redland libs
+
+--- a/src/Makefile.in 2013-03-29 19:11:27.944919859 +0100
++++ b/src/Makefile.in 2013-03-29 19:17:42.173916644 +0100
+@@ -507,7 +507,7 @@
+ $(am__append_21) $(am__append_22) $(am__append_23) \
+ $(am__append_24) $(am__append_25) $(am__append_26)
+ libraptor2_la_LIBADD = $(am__append_29) @LTLIBOBJS@
+-libraptor2_la_LDFLAGS = -version-info @RAPTOR_LIBTOOL_VERSION@ \
++libraptor2_la_LDFLAGS = -version-info @RAPTOR_LIBTOOL_VERSION@ -release lo \
+ @RAPTOR_LDFLAGS@ $(MEM_LIBS)
+
+ EXTRA_DIST = \
diff --git a/external/redland/raptor/raptor-freebsd.patch.1 b/external/redland/raptor/raptor-freebsd.patch.1
new file mode 100644
index 000000000..349f3a197
--- /dev/null
+++ b/external/redland/raptor/raptor-freebsd.patch.1
@@ -0,0 +1,28 @@
+Usual patch to produce Linux-like .so files on FreeBSD
+
+--- a/build/ltmain.sh 2008-02-02 22:28:24.000000000 +0900
++++ b/build/ltmain.sh 2008-07-08 11:58:42.000000000 +0900
+@@ -7341,9 +7341,9 @@
+ revision="$number_revision"
+ ;;
+ freebsd-aout|freebsd-elf|qnx|sunos)
+- current="$number_major"
+- revision="$number_minor"
+- age="0"
++ current=`expr $number_major + $number_minor`
++ age="$number_minor"
++ revision="$number_revision"
+ ;;
+ irix|nonstopux)
+ func_arith $number_major + $number_minor
+@@ -7420,8 +7420,8 @@
+ ;;
+
+ freebsd-elf)
+- major=".$current"
+- versuffix=".$current"
++ major=.`expr $current - $age`
++ versuffix="$major.$age.$revision"
+ ;;
+
+ irix | nonstopux)
diff --git a/external/redland/raptor/raptor-msvc.patch.1 b/external/redland/raptor/raptor-msvc.patch.1
new file mode 100644
index 000000000..245b19bdc
--- /dev/null
+++ b/external/redland/raptor/raptor-msvc.patch.1
@@ -0,0 +1,23 @@
+--- raptor/src/raptor2.h.in.orig 2016-08-26 23:45:34.543400074 +0200
++++ raptor/src/raptor2.h.in 2016-08-26 23:45:40.479399614 +0200
+@@ -2176,6 +2176,7 @@
+ void* raptor_avltree_iterator_get(raptor_avltree_iterator* iterator);
+
+ /* utility methods */
++RAPTOR_API
+ void raptor_sort_r(void *base, size_t nel, size_t width, raptor_data_compare_arg_handler compar, void *user_data);
+
+
+--- raptor/src/raptor_uri.c 2016-08-26 23:45:34.543400074 +0200
++++ raptor/src/raptor_uri.c 2016-08-26 23:45:40.479399614 +0200
+@@ -51,6 +51,10 @@
+ #include <sys/stat.h>
+ #endif
+
++#if !defined(HAVE_ACCESS) && defined(HAVE__ACCESS)
++#include <io.h>
++#endif
++
+ /* Raptor includes */
+ #include "raptor2.h"
+ #include "raptor_internal.h"
diff --git a/external/redland/raptor/raptor2.h b/external/redland/raptor/raptor2.h
new file mode 100644
index 000000000..4929117e7
--- /dev/null
+++ b/external/redland/raptor/raptor2.h
@@ -0,0 +1,2187 @@
+/* -*- Mode: c; c-basic-offset: 2 -*-
+ *
+ * raptor.h - Redland Parser Toolkit for RDF (Raptor) - public API
+ *
+ * Copyright (C) 2000-2013, David Beckett http://www.dajobe.org/
+ * Copyright (C) 2000-2005, University of Bristol, UK http://www.bristol.ac.uk/
+ *
+ * This package is Free Software and part of Redland http://librdf.org/
+ *
+ * It is licensed under the following three licenses as alternatives:
+ * 1. GNU Lesser General Public License (LGPL) V2.1 or any newer version
+ * 2. GNU General Public License (GPL) V2 or any newer version
+ * 3. Apache License, V2.0 or any newer version
+ *
+ * You may not use this file except in compliance with at least one of
+ * the above three licenses.
+ *
+ * See LICENSE.html or LICENSE.txt at the top of this package for the
+ * complete terms and further detail along with the license texts for
+ * the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively.
+ *
+ *
+ */
+
+
+
+#ifndef RAPTOR_H
+#define RAPTOR_H
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdio.h>
+
+/* Required for va_list in raptor_vsnprintf */
+#include <stdarg.h>
+
+
+/**
+ * RAPTOR_V2_AVAILABLE
+ *
+ * Flag for marking raptor2 API availability.
+ */
+#define RAPTOR_V2_AVAILABLE 1
+
+
+/**
+ * RAPTOR_VERSION:
+ *
+ * Raptor library version number
+ *
+ * Format: major * 10000 + minor * 100 + release
+ */
+#define RAPTOR_VERSION 20015
+
+/**
+ * RAPTOR_VERSION_STRING:
+ *
+ * Raptor library version string
+ */
+#define RAPTOR_VERSION_STRING "2.0.15"
+
+/**
+ * RAPTOR_VERSION_MAJOR:
+ *
+ * Raptor library major version
+ */
+#define RAPTOR_VERSION_MAJOR 2
+
+/**
+ * RAPTOR_VERSION_MINOR:
+ *
+ * Raptor library minor version
+ */
+#define RAPTOR_VERSION_MINOR 0
+
+/**
+ * RAPTOR_VERSION_RELEASE:
+ *
+ * Raptor library release
+ */
+#define RAPTOR_VERSION_RELEASE 15
+
+/**
+ * RAPTOR_API:
+ *
+ * Macro for wrapping API function call declarations.
+ *
+ */
+#ifndef RAPTOR_API
+# ifdef _WIN32
+# ifdef __GNUC__
+# undef _declspec
+# define _declspec(x) __declspec(x)
+# endif
+# ifdef RAPTOR_STATIC
+# define RAPTOR_API
+# else
+# ifdef RAPTOR_INTERNAL
+# define RAPTOR_API _declspec(dllexport)
+# else
+# define RAPTOR_API _declspec(dllimport)
+# endif
+# endif
+# else
+# define RAPTOR_API
+# endif
+#endif
+
+/* Use gcc 3.1+ feature to allow marking of deprecated API calls.
+ * This gives a warning during compiling.
+ */
+#if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
+#define RAPTOR_DEPRECATED __attribute__((deprecated))
+#define RAPTOR_NORETURN __attribute__((__noreturn__))
+#else
+#define RAPTOR_DEPRECATED
+#define RAPTOR_NORETURN
+#endif
+
+/**
+ * RAPTOR_PRINTF_FORMAT:
+ * @string_index: ignore me
+ * @first_to_check_index: ignore me
+ *
+ * Internal macro
+ */
+#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
+#define RAPTOR_PRINTF_FORMAT(string_index, first_to_check_index) \
+ __attribute__((__format__(__printf__, string_index, first_to_check_index)))
+#else
+#define RAPTOR_PRINTF_FORMAT(string_index, first_to_check_index)
+#endif
+
+/**
+ * raptor_uri:
+ *
+ * Raptor URI Class.
+ */
+typedef struct raptor_uri_s raptor_uri;
+
+
+/* Public statics */
+
+/**
+ * raptor_short_copyright_string:
+ *
+ * Short copyright string (one line).
+ */
+RAPTOR_API
+extern const char * const raptor_short_copyright_string;
+
+/**
+ * raptor_copyright_string:
+ *
+ * Copyright string (multiple lines).
+ */
+RAPTOR_API
+extern const char * const raptor_copyright_string;
+
+/**
+ * raptor_version_string:
+ *
+ * Raptor version as a string.
+ */
+RAPTOR_API
+extern const char * const raptor_version_string;
+
+/**
+ * raptor_version_major:
+ *
+ * Raptor major version number.
+ */
+RAPTOR_API
+extern const unsigned int raptor_version_major;
+
+/**
+ * raptor_version_minor:
+ *
+ * Raptor minor version number.
+ */
+RAPTOR_API
+extern const unsigned int raptor_version_minor;
+
+/**
+ * raptor_version_release:
+ *
+ * Raptor release version number.
+ */
+RAPTOR_API
+extern const unsigned int raptor_version_release;
+
+/**
+ * raptor_version_decimal:
+ *
+ * Raptor version as a decimal number.
+ *
+ * Format: major * 10000 + minor * 100 + release
+ */
+RAPTOR_API
+extern const unsigned int raptor_version_decimal;
+
+/**
+ * raptor_license_string:
+ *
+ * Raptor license string.
+ */
+RAPTOR_API
+extern const char * const raptor_license_string;
+
+/**
+ * raptor_home_url_string:
+ *
+ * Raptor home page URL.
+ */
+RAPTOR_API
+extern const char * const raptor_home_url_string;
+
+/**
+ * raptor_xml_namespace_uri:
+ *
+ * XML Namespace (xml:) URI string.
+ */
+RAPTOR_API
+extern const unsigned char * const raptor_xml_namespace_uri;
+
+
+/**
+ * raptor_rdf_namespace_uri:
+ *
+ * RDF Namespace (rdf:) URI string.
+ */
+RAPTOR_API
+extern const unsigned char * const raptor_rdf_namespace_uri;
+
+/**
+ * raptor_rdf_namespace_uri_len:
+ *
+ * Length of #raptor_rdf_namespace_uri string
+ */
+RAPTOR_API
+extern const unsigned int raptor_rdf_namespace_uri_len;
+
+/**
+ * raptor_rdf_schema_namespace_uri:
+ *
+ * RDF Schema (rdfs:) Namespace URI string.
+ */
+RAPTOR_API
+extern const unsigned char * const raptor_rdf_schema_namespace_uri;
+
+/**
+ * raptor_xmlschema_datatypes_namespace_uri:
+ *
+ * XML Schema datatypes (xsd:) namespace URI string.
+ */
+RAPTOR_API
+extern const unsigned char * const raptor_xmlschema_datatypes_namespace_uri;
+
+/**
+ * raptor_owl_namespace_uri:
+ *
+ * OWL (owl:) Namespace URI string.
+ */
+RAPTOR_API
+extern const unsigned char * const raptor_owl_namespace_uri;
+
+/**
+ * raptor_xml_literal_datatype_uri_string:
+ *
+ * XML Literal datatype (rdf:XMLLiteral) URI string.
+ */
+RAPTOR_API
+extern const unsigned char * const raptor_xml_literal_datatype_uri_string;
+
+/**
+ * raptor_xml_literal_datatype_uri_string_len:
+ *
+ * Length of #raptor_xml_literal_datatype_uri_string
+ */
+RAPTOR_API
+extern const unsigned int raptor_xml_literal_datatype_uri_string_len;
+
+
+/* Public structure */
+/**
+ * raptor_world:
+ *
+ * Raptor world class.
+ */
+typedef struct raptor_world_s raptor_world;
+/**
+ * raptor_parser:
+ *
+ * Raptor Parser class
+ */
+typedef struct raptor_parser_s raptor_parser;
+/**
+ * raptor_serializer:
+ *
+ * Raptor Serializer class
+ */
+typedef struct raptor_serializer_s raptor_serializer;
+
+/**
+ * raptor_www:
+ *
+ * Raptor WWW class
+ */
+typedef struct raptor_www_s raptor_www;
+/**
+ * raptor_iostream:
+ *
+ * Raptor I/O Stream class
+ */
+typedef struct raptor_iostream_s raptor_iostream;
+/**
+ * raptor_xml_element:
+ *
+ * Raptor XML Element class
+ */
+typedef struct raptor_xml_element_s raptor_xml_element;
+/**
+ * raptor_xml_writer:
+ *
+ * Raptor XML Writer class
+ */
+typedef struct raptor_xml_writer_s raptor_xml_writer;
+/**
+ * raptor_qname:
+ *
+ * Raptor XML qname class
+ */
+typedef struct raptor_qname_s raptor_qname;
+/**
+ * raptor_namespace:
+ *
+ * Raptor XML Namespace class
+ */
+typedef struct raptor_namespace_s raptor_namespace;
+/**
+ * raptor_namespace_stack:
+ *
+ * Raptor XML Namespace Stack class
+ */
+typedef struct raptor_namespace_stack_s raptor_namespace_stack;
+
+/**
+ * raptor_sax2:
+ *
+ * Raptor SAX2 class
+ */
+typedef struct raptor_sax2_s raptor_sax2;
+
+
+/**
+ * raptor_type_q:
+ * @mime_type: MIME type string
+ * @mime_type_len: length of @mime_type
+ * @q: Q value 0-10 standing for decimal 0.0-1.0
+ *
+ * (MIME Type, Q) pair
+ */
+typedef struct {
+ const char* mime_type;
+ size_t mime_type_len;
+ unsigned char q;
+} raptor_type_q;
+
+
+/**
+ * raptor_syntax_bitflags:
+ * @RAPTOR_SYNTAX_NEED_BASE_URI: the syntax requires a base URI
+ *
+ * Bit flags for #raptor_syntax_description flags field
+ */
+typedef enum {
+ RAPTOR_SYNTAX_NEED_BASE_URI = 1
+} raptor_syntax_bitflags;
+
+
+/**
+ * raptor_syntax_description:
+ * @names: array of syntax names - the first one (required) is the public name, the rest are aliases. The array is NULL terminated.
+ * @names_count: size of @names array
+ * @label: long descriptive label for syntax
+ * @mime_types: Array of (MIME type, Q) values associated with the syntax (or NULL). If present the array is NULL terminated.
+ * @mime_types_count: size of @mime_types array
+ * @uri_strings: array of URIs identifying the syntax (or NULL). The first one if present is the main URI, the rest are aliases. The array is NULL terminated.
+ * @uri_strings_count: size of @uri_strings array
+ * @flags: See #raptor_syntax_bitflags for the bits
+ *
+ * Description of a syntax or file format.
+ *
+ */
+typedef struct {
+ const char* const* names;
+ unsigned int names_count;
+
+ const char* label;
+
+ const raptor_type_q* mime_types;
+ unsigned int mime_types_count;
+
+ const char* const* uri_strings;
+ unsigned int uri_strings_count;
+
+ unsigned int flags;
+} raptor_syntax_description;
+
+
+/**
+ * raptor_term_type:
+ * @RAPTOR_TERM_TYPE_URI: RDF URI
+ * @RAPTOR_TERM_TYPE_LITERAL: RDF literal
+ * @RAPTOR_TERM_TYPE_BLANK: RDF blank node
+ * @RAPTOR_TERM_TYPE_UNKNOWN: Internal
+ *
+ * Type of term in a #raptor_statement
+ *
+ * Node type 3 is unused but exists to preserve numeric compatibility
+ * with librdf_node_type values.
+ */
+typedef enum {
+ RAPTOR_TERM_TYPE_UNKNOWN = 0,
+ RAPTOR_TERM_TYPE_URI = 1,
+ RAPTOR_TERM_TYPE_LITERAL = 2,
+ /* unused type 3 */
+ RAPTOR_TERM_TYPE_BLANK = 4
+} raptor_term_type;
+
+
+/**
+ * raptor_locator:
+ * @uri: URI of location (or NULL)
+ * @file: Filename of location (or NULL)
+ * @line: Line number of location (or <0 for no line)
+ * @column: Column number of location (or <0 for no column)
+ * @byte: Byte number of location (or <0 for no byte)
+ *
+ * Location information for an error, warning or information message.
+ */
+typedef struct {
+ raptor_uri *uri;
+ const char *file;
+ int line;
+ int column;
+ int byte;
+} raptor_locator;
+
+/**
+ * raptor_option:
+ * @RAPTOR_OPTION_SCANNING: If true (default false), the RDF/XML
+ * parser will look for embedded rdf:RDF elements inside the XML
+ * content, and not require that the XML start with an rdf:RDF root
+ * element.
+ * @RAPTOR_OPTION_ALLOW_NON_NS_ATTRIBUTES: If true (default true)
+ * then the RDF/XML parser will allow non-XML namespaced attributes
+ * to be accepted as well as rdf: namespaced ones. For example,
+ * 'about' and 'ID' will be interpreted as if they were rdf:about
+ * and rdf:ID respectively.
+ * @RAPTOR_OPTION_ALLOW_OTHER_PARSETYPES: If true (default true)
+ * then the RDF/XML parser will allow unknown parsetypes to be
+ * present and will pass them on to the user. Unimplemented at
+ * present.
+ * @RAPTOR_OPTION_ALLOW_BAGID: If true (default true) then the
+ * RDF/XML parser will support the rdf:bagID attribute that was
+ * removed from the RDF/XML language when it was revised. This
+ * support may be removed in future.
+ * @RAPTOR_OPTION_ALLOW_RDF_TYPE_RDF_LIST: If true (default false)
+ * then the RDF/XML parser will generate the idList rdf:type
+ * rdf:List triple in the handling of rdf:parseType="Collection".
+ * This triple was removed during the revising of RDF/XML after
+ * collections were initially added.
+ * @RAPTOR_OPTION_NORMALIZE_LANGUAGE: If true (default true) then
+ * XML language values such as from xml:lang will be normalized to
+ * lowercase.
+ * @RAPTOR_OPTION_NON_NFC_FATAL: If true (default false) then
+ * illegal Unicode Normal Form C in literals will give a fatal
+ * error, otherwise just a warning.
+ * @RAPTOR_OPTION_WARN_OTHER_PARSETYPES: If true (default true) then
+ * the RDF/XML parser will warn about unknown rdf:parseType values.
+ * @RAPTOR_OPTION_CHECK_RDF_ID: If true (default true) then the
+ * RDF/XML will check rdf:ID attribute values for duplicates and
+ * cause an error if any are found.
+ * @RAPTOR_OPTION_RELATIVE_URIS: If true (default true) then
+ * relative URIs will be used wherever possible when serializing.
+ * @RAPTOR_OPTION_WRITER_AUTO_INDENT: Automatically indent elements when
+ * seriailizing.
+ * @RAPTOR_OPTION_WRITER_AUTO_EMPTY: Automatically detect and
+ * abbreviate empty elements when serializing.
+ * @RAPTOR_OPTION_WRITER_INDENT_WIDTH: Integer number of spaces to use
+ * for each indent level when serializing with auto indent.
+ * @RAPTOR_OPTION_WRITER_XML_VERSION: Integer XML version XML 1.0 (10) or XML 1.1 (11)
+ * @RAPTOR_OPTION_WRITER_XML_DECLARATION: Write XML 1.0 or 1.1 declaration.
+ * @RAPTOR_OPTION_NO_NET: Deny network requests inside other requests.
+ * @RAPTOR_OPTION_RESOURCE_BORDER: Border color of resource
+ * nodes for GraphViz DOT serializer.
+ * @RAPTOR_OPTION_LITERAL_BORDER: Border color of literal nodes
+ * for GraphViz DOT serializer.
+ * @RAPTOR_OPTION_BNODE_BORDER: Border color of blank nodes for
+ * GraphViz DOT serializer.
+ * @RAPTOR_OPTION_RESOURCE_FILL: Fill color of resource nodes
+ * for GraphViz DOT serializer.
+ * @RAPTOR_OPTION_LITERAL_FILL: Fill color of literal nodes for
+ * GraphViz DOT serializer.
+ * @RAPTOR_OPTION_BNODE_FILL: Fill color of blank nodes for
+ * GraphViz DOT serializer.
+ * @RAPTOR_OPTION_HTML_TAG_SOUP: Use a lax HTML parser if an XML parser
+ * fails when read HTML for GRDDL parser.
+ * @RAPTOR_OPTION_MICROFORMATS: Look for microformats for GRDDL parser.
+ * @RAPTOR_OPTION_HTML_LINK: Look for head &lt;link&gt; to type rdf/xml
+ * for GRDDL parser.
+ * @RAPTOR_OPTION_WWW_TIMEOUT: Set timeout for internal WWW URI requests
+ * for GRDDL parser.
+ * @RAPTOR_OPTION_WRITE_BASE_URI: Write @base directive for Turtle/N3.
+ * @RAPTOR_OPTION_WWW_HTTP_CACHE_CONTROL: HTTP Cache-Control: header
+ * @RAPTOR_OPTION_WWW_HTTP_USER_AGENT: HTTP User-Agent: header
+ * @RAPTOR_OPTION_JSON_CALLBACK: JSON serializer callback function.
+ * @RAPTOR_OPTION_JSON_EXTRA_DATA: JSON serializer extra top-level data
+ * @RAPTOR_OPTION_RSS_TRIPLES: Atom/RSS serializer writes extra RDF triples it finds (none, rdf-xml, atom-triples)
+ * @RAPTOR_OPTION_ATOM_ENTRY_URI: Atom entry URI. If given, generate an Atom Entry Document with the item having the given URI, otherwise generate an Atom Feed Document with any items found.
+ * @RAPTOR_OPTION_PREFIX_ELEMENTS: Integer. If set, generate Atom/RSS1.0 documents with prefixed elements, otherwise unprefixed.
+ * @RAPTOR_OPTION_STRICT: Boolean. If set, operate in strict conformance mode.
+ * @RAPTOR_OPTION_WWW_CERT_FILENAME: String. SSL client certificate filename
+ * @RAPTOR_OPTION_WWW_CERT_TYPE: String. SSL client certificate type
+ * @RAPTOR_OPTION_WWW_CERT_PASSPHRASE: String. SSL client certificate passphrase
+ * @RAPTOR_OPTION_WWW_SSL_VERIFY_PEER: Integer. SSL verify peer - non-0 to verify peer SSL certificate (default)
+ * @RAPTOR_OPTION_WWW_SSL_VERIFY_HOST: Integer. SSL verify host - 0 none, 1 CN match, 2 host match (default). Other values are ignored.
+ * @RAPTOR_OPTION_NO_FILE: Deny file reading requests inside other requests.
+ * @RAPTOR_OPTION_LOAD_EXTERNAL_ENTITIES: When reading XML, load external entities.
+ * @RAPTOR_OPTION_LAST: Internal
+ *
+ * Raptor parser, serializer or XML writer options.
+ */
+typedef enum {
+ RAPTOR_OPTION_SCANNING,
+ RAPTOR_OPTION_ALLOW_NON_NS_ATTRIBUTES,
+ RAPTOR_OPTION_ALLOW_OTHER_PARSETYPES,
+ RAPTOR_OPTION_ALLOW_BAGID,
+ RAPTOR_OPTION_ALLOW_RDF_TYPE_RDF_LIST,
+ RAPTOR_OPTION_NORMALIZE_LANGUAGE,
+ RAPTOR_OPTION_NON_NFC_FATAL,
+ RAPTOR_OPTION_WARN_OTHER_PARSETYPES,
+ RAPTOR_OPTION_CHECK_RDF_ID,
+ RAPTOR_OPTION_RELATIVE_URIS,
+ RAPTOR_OPTION_WRITER_AUTO_INDENT,
+ RAPTOR_OPTION_WRITER_AUTO_EMPTY,
+ RAPTOR_OPTION_WRITER_INDENT_WIDTH,
+ RAPTOR_OPTION_WRITER_XML_VERSION,
+ RAPTOR_OPTION_WRITER_XML_DECLARATION,
+ RAPTOR_OPTION_NO_NET,
+ RAPTOR_OPTION_RESOURCE_BORDER,
+ RAPTOR_OPTION_LITERAL_BORDER,
+ RAPTOR_OPTION_BNODE_BORDER,
+ RAPTOR_OPTION_RESOURCE_FILL,
+ RAPTOR_OPTION_LITERAL_FILL,
+ RAPTOR_OPTION_BNODE_FILL,
+ RAPTOR_OPTION_HTML_TAG_SOUP,
+ RAPTOR_OPTION_MICROFORMATS,
+ RAPTOR_OPTION_HTML_LINK,
+ RAPTOR_OPTION_WWW_TIMEOUT,
+ RAPTOR_OPTION_WRITE_BASE_URI,
+ RAPTOR_OPTION_WWW_HTTP_CACHE_CONTROL,
+ RAPTOR_OPTION_WWW_HTTP_USER_AGENT,
+ RAPTOR_OPTION_JSON_CALLBACK,
+ RAPTOR_OPTION_JSON_EXTRA_DATA,
+ RAPTOR_OPTION_RSS_TRIPLES,
+ RAPTOR_OPTION_ATOM_ENTRY_URI,
+ RAPTOR_OPTION_PREFIX_ELEMENTS,
+ RAPTOR_OPTION_STRICT,
+ RAPTOR_OPTION_WWW_CERT_FILENAME,
+ RAPTOR_OPTION_WWW_CERT_TYPE,
+ RAPTOR_OPTION_WWW_CERT_PASSPHRASE,
+ RAPTOR_OPTION_NO_FILE,
+ RAPTOR_OPTION_WWW_SSL_VERIFY_PEER,
+ RAPTOR_OPTION_WWW_SSL_VERIFY_HOST,
+ RAPTOR_OPTION_LOAD_EXTERNAL_ENTITIES,
+ RAPTOR_OPTION_LAST = RAPTOR_OPTION_LOAD_EXTERNAL_ENTITIES
+} raptor_option;
+
+
+/**
+ * raptor_term_literal_value:
+ * @string: literal string
+ * @string_len: length of string
+ * @datatype: datatype URI (or NULL)
+ * @language: literal language (or NULL)
+ * @language_len: length of language
+ *
+ * Literal term value - this typedef exists solely for use in #raptor_term
+ *
+ * Either @datatype or @language may be non-NULL but not both.
+ */
+typedef struct {
+ unsigned char *string;
+ unsigned int string_len;
+
+ raptor_uri *datatype;
+
+ unsigned char *language;
+ unsigned char language_len;
+} raptor_term_literal_value;
+
+
+/**
+ * raptor_term_blank_value:
+ * @string: literal string
+ * @string_len: length of string
+ *
+ * Blank term value - this typedef exists solely for use in #raptor_term
+ *
+ */
+typedef struct {
+ unsigned char *string;
+ unsigned int string_len;
+} raptor_term_blank_value;
+
+
+/**
+ * raptor_term_value:
+ * @uri: uri value when term type is #RAPTOR_TERM_TYPE_URI
+ * @literal: literal value when term type is #RAPTOR_TERM_TYPE_LITERAL
+ * @blank: blank value when term type is #RAPTOR_TERM_TYPE_BLANK
+ *
+ * Term value - this typedef exists solely for use in #raptor_term
+ *
+ **/
+typedef union {
+ raptor_uri *uri;
+
+ raptor_term_literal_value literal;
+
+ raptor_term_blank_value blank;
+} raptor_term_value;
+
+
+/**
+ * raptor_term:
+ * @world: world
+ * @usage: usage reference count (if >0)
+ * @type: term type
+ * @value: term values per type
+ *
+ * An RDF statement term
+ *
+ */
+typedef struct {
+ raptor_world* world;
+
+ int usage;
+
+ raptor_term_type type;
+
+ raptor_term_value value;
+
+} raptor_term;
+
+
+/**
+ * raptor_statement:
+ * @world: world pointer
+ * @usage: usage count
+ * @subject: statement subject
+ * @predicate: statement predicate
+ * @object: statement object
+ * @graph: statement graph name (or NULL if not present)
+ *
+ * An RDF triple with optional graph name (quad)
+ *
+ * See #raptor_term for a description of how the fields may be used.
+ * As returned by a parser statement_handler.
+ */
+typedef struct {
+ raptor_world* world;
+ int usage;
+ raptor_term* subject;
+ raptor_term* predicate;
+ raptor_term* object;
+ raptor_term* graph;
+} raptor_statement;
+
+
+/**
+ * raptor_log_level:
+ * @RAPTOR_LOG_LEVEL_NONE: Internal
+ * @RAPTOR_LOG_LEVEL_TRACE: very fine-grained tracing messages information
+ * @RAPTOR_LOG_LEVEL_DEBUG: fine-grained tracing messages suitable for debugging
+ * @RAPTOR_LOG_LEVEL_INFO: coarse-grained information messages
+ * @RAPTOR_LOG_LEVEL_WARN: warning messages of potentially harmful problems
+ * @RAPTOR_LOG_LEVEL_ERROR: error messages where the application can continue
+ * @RAPTOR_LOG_LEVEL_FATAL: fatal error message where the application will likely abort
+ * @RAPTOR_LOG_LEVEL_LAST: Internal
+ *
+ * Log levels
+ */
+typedef enum {
+ RAPTOR_LOG_LEVEL_NONE,
+ RAPTOR_LOG_LEVEL_TRACE,
+ RAPTOR_LOG_LEVEL_DEBUG,
+ RAPTOR_LOG_LEVEL_INFO,
+ RAPTOR_LOG_LEVEL_WARN,
+ RAPTOR_LOG_LEVEL_ERROR,
+ RAPTOR_LOG_LEVEL_FATAL,
+ RAPTOR_LOG_LEVEL_LAST = RAPTOR_LOG_LEVEL_FATAL
+} raptor_log_level;
+
+
+/**
+ * raptor_domain:
+ * @RAPTOR_DOMAIN_IOSTREAM: I/O stream
+ * @RAPTOR_DOMAIN_NAMESPACE: XML Namespace / namespace stack
+ * @RAPTOR_DOMAIN_PARSER: RDF Parser
+ * @RAPTOR_DOMAIN_QNAME: XML QName
+ * @RAPTOR_DOMAIN_SAX2: XML SAX2
+ * @RAPTOR_DOMAIN_SERIALIZER: RDF Serializer
+ * @RAPTOR_DOMAIN_TERM: RDF Term
+ * @RAPTOR_DOMAIN_TURTLE_WRITER: Turtle Writer
+ * @RAPTOR_DOMAIN_URI: RDF Uri
+ * @RAPTOR_DOMAIN_WORLD: RDF world
+ * @RAPTOR_DOMAIN_WWW: WWW
+ * @RAPTOR_DOMAIN_XML_WRITER: XML Writer
+ * @RAPTOR_DOMAIN_NONE: Internal
+ * @RAPTOR_DOMAIN_LAST: Internal
+ *
+ * Log domain
+ */
+typedef enum {
+ RAPTOR_DOMAIN_NONE,
+ RAPTOR_DOMAIN_IOSTREAM,
+ RAPTOR_DOMAIN_NAMESPACE,
+ RAPTOR_DOMAIN_PARSER,
+ RAPTOR_DOMAIN_QNAME,
+ RAPTOR_DOMAIN_SAX2,
+ RAPTOR_DOMAIN_SERIALIZER,
+ RAPTOR_DOMAIN_TERM,
+ RAPTOR_DOMAIN_TURTLE_WRITER,
+ RAPTOR_DOMAIN_URI,
+ RAPTOR_DOMAIN_WORLD,
+ RAPTOR_DOMAIN_WWW,
+ RAPTOR_DOMAIN_XML_WRITER,
+ RAPTOR_DOMAIN_LAST = RAPTOR_DOMAIN_XML_WRITER
+} raptor_domain;
+
+
+/**
+ * raptor_log_message:
+ * @code: error code or < 0 if not used or known
+ * @domain: message domain or #RAPTOR_DOMAIN_NONE if not used or known
+ * @level: log message level
+ * @locator: location associated with message or NULL if not known
+ * @text: message string
+ *
+ * Log message.
+ */
+typedef struct {
+ int code;
+ raptor_domain domain;
+ raptor_log_level level;
+ raptor_locator *locator;
+ const char *text;
+} raptor_log_message;
+
+
+/**
+ * raptor_log_handler:
+ * @user_data: user data
+ * @message: log message
+ *
+ * Handler function for log messages with location
+ *
+ * Used during parsing and serializing for errors and warnings that
+ * may include location information. Handlers may be set
+ * by raptor_world_set_log_handler().
+ *
+ */
+typedef void (*raptor_log_handler)(void *user_data, raptor_log_message *message);
+
+
+/**
+ * raptor_statement_handler:
+ * @user_data: user data
+ * @statement: statement to report
+ *
+ * Statement (triple) reporting handler function.
+ *
+ * This handler function set with
+ * raptor_parser_set_statement_handler() on a parser receives
+ * statements as the parsing proceeds. The @statement argument to the
+ * handler is shared and must be copied by the caller with
+ * raptor_statement_copy().
+ */
+typedef void (*raptor_statement_handler)(void *user_data, raptor_statement *statement);
+
+/**
+ * raptor_graph_mark_flags:
+ * @RAPTOR_GRAPH_MARK_START: mark is start of graph (otherwise is end)
+ * @RAPTOR_GRAPH_MARK_DECLARED: mark was declared in syntax rather than implict
+ *
+ * Graph mark handler bitmask flags
+ */
+typedef enum {
+ RAPTOR_GRAPH_MARK_START = 1,
+ RAPTOR_GRAPH_MARK_DECLARED = 2
+} raptor_graph_mark_flags;
+
+
+/**
+ * raptor_graph_mark_handler:
+ * @user_data: user data
+ * @graph: graph to report, NULL for the default graph
+ * @flags: bitmask of #raptor_graph_mark_flags flags
+ *
+ * Graph start/end mark handler function.
+ *
+ * Records start and end of graphs happening in a stream of generated
+ * #raptor_statement via the statement handler. The callback starts a
+ * graph when @flags has #RAPTOR_GRAPH_MARK_START bit set.
+ *
+ * The start and ends may be either declared in the syntax via some
+ * keyword or mechanism such as TRiG {} syntax when @flags has bit
+ * #RAPTOR_GRAPH_MARK_DECLARED set, or be implied by the start/end of
+ * the data in other syntaxes, and the bit will be unset.
+ */
+typedef void (*raptor_graph_mark_handler)(void *user_data, raptor_uri *graph, int flags);
+
+/**
+ * raptor_generate_bnodeid_handler:
+ * @user_data: user data
+ * @user_bnodeid: a user-specified ID or NULL if none available.
+ *
+ * Generate a blank node identifier handler function.
+ *
+ * Return value: new blank node ID to use
+ */
+typedef unsigned char* (*raptor_generate_bnodeid_handler)(void *user_data, unsigned char* user_bnodeid);
+
+/**
+ * raptor_namespace_handler:
+ * @user_data: user data
+ * @nspace: #raptor_namespace declared
+ *
+ * XML Namespace declaration reporting handler set by
+ * raptor_parser_set_namespace_handler().
+ */
+typedef void (*raptor_namespace_handler)(void* user_data, raptor_namespace *nspace);
+
+
+/**
+ * raptor_www_write_bytes_handler:
+ * @www: WWW object
+ * @userdata: user data
+ * @ptr: data pointer
+ * @size: size of individual item
+ * @nmemb: number of items
+ *
+ * Receiving bytes of data from WWW retrieval handler.
+ *
+ * Set by raptor_www_set_write_bytes_handler().
+ */
+typedef void (*raptor_www_write_bytes_handler)(raptor_www* www, void *userdata, const void *ptr, size_t size, size_t nmemb);
+
+/**
+ * raptor_www_content_type_handler:
+ * @www: WWW object
+ * @userdata: user data
+ * @content_type: content type seen
+ *
+ * Receiving Content-Type: header from WWW retrieval handler.
+ *
+ * Set by raptor_www_set_content_type_handler().
+ */
+typedef void (*raptor_www_content_type_handler)(raptor_www* www, void *userdata, const char *content_type);
+
+/**
+ * raptor_www_final_uri_handler:
+ * @www: WWW object
+ * @userdata: user data
+ * @final_uri: final URI seen
+ *
+ * Receiving the final resolved URI from a WWW retrieval
+ *
+ * Set by raptor_www_set_final_uri_handler().
+ */
+typedef void (*raptor_www_final_uri_handler)(raptor_www* www, void *userdata, raptor_uri *final_uri);
+
+/**
+ * raptor_uri_filter_func:
+ * @user_data: user data
+ * @uri: #raptor_uri URI to check
+ *
+ * Callback function for #raptor_www_set_uri_filter
+ *
+ * Return value: non-0 to filter the URI
+ */
+typedef int (*raptor_uri_filter_func)(void *user_data, raptor_uri* uri);
+
+
+/**
+ * raptor_world_flag:
+ * @RAPTOR_WORLD_FLAG_LIBXML_GENERIC_ERROR_SAVE: if set (non-0 value) - save/restore the libxml generic error handler when raptor library initializes (default set)
+ * @RAPTOR_WORLD_FLAG_LIBXML_STRUCTURED_ERROR_SAVE: if set (non-0 value) - save/restore the libxml structured error handler when raptor library terminates (default set)
+ * @RAPTOR_WORLD_FLAG_URI_INTERNING: if set (non-0 value) - each URI is saved interned in-memory and reused (default set)
+ * @RAPTOR_WORLD_FLAG_WWW_SKIP_INIT_FINISH: if set (non-0 value) the raptor will neither initialise or terminate the lower level WWW library. Usually in raptor initialising either curl_global_init (for libcurl) are called and in raptor cleanup, curl_global_cleanup is called. This flag allows the application finer control over these libraries such as setting other global options or potentially calling and terminating raptor several times. It does mean that applications which use this call must do their own extra work in order to allocate and free all resources to the system.
+ *
+ * Raptor world flags
+ *
+ * These are used by raptor_world_set_flags() to control raptor-wide
+ * options across classes. These must be set before
+ * raptor_world_open() is called explicitly or implicitly (by
+ * creating a raptor object). There is no enumeration function for
+ * these flags because they are not user options and must be set
+ * before the library is initialised. For similar reasons, there is
+ * no get function.
+ *
+ * If any libxml handler saving/restoring is enabled, any existing
+ * handler and context is saved before parsing and restored
+ * afterwards. Otherwise, no saving/restoring is performed.
+ *
+ */
+typedef enum {
+ RAPTOR_WORLD_FLAG_LIBXML_GENERIC_ERROR_SAVE = 1,
+ RAPTOR_WORLD_FLAG_LIBXML_STRUCTURED_ERROR_SAVE = 2,
+ RAPTOR_WORLD_FLAG_URI_INTERNING = 3,
+ RAPTOR_WORLD_FLAG_WWW_SKIP_INIT_FINISH = 4
+} raptor_world_flag;
+
+
+/**
+ * raptor_data_compare_arg_handler:
+ * @data1: first object
+ * @data2: second object
+ * @user_data: user data argument
+ *
+ * Function to compare two data objects with a user data argument
+ *
+ * Designed to be used with raptor_sort_r() and compatible functions
+ * such as raptor_sequence_sort_r() which uses it.
+ *
+ * Return value: compare value <0 if @data1 is before @data2, =0 if equal, >0 if @data1 is after @data2
+ */
+typedef int (*raptor_data_compare_arg_handler)(const void *data1, const void *data2, void *user_data);
+
+
+/**
+ * raptor_data_compare_handler:
+ * @data1: first data object
+ * @data2: second data object
+ *
+ * Function to compare two data objects - signature like strcmp() and function pssed to qsort()
+ *
+ * Designed to be passed into generic data structure constructors
+ * like raptor_new_avltree().
+ *
+ * Return value: compare value <0 if @data1 is before @data2, =0 if equal, >0 if @data1 is after @data2
+ */
+typedef int (*raptor_data_compare_handler)(const void* data1, const void* data2);
+
+
+/**
+ * raptor_data_malloc_handler:
+ * @size: data size
+ *
+ * Typedef for a function to allocate memory - signature like malloc()
+ *
+ * Designed to be passed into constructors
+ * like raptor_www_fetch_to_string
+ *
+ * Return value: pointer to newly allocated memory or NULL on failure
+ */
+typedef void* (*raptor_data_malloc_handler)(size_t size);
+
+
+/**
+ * raptor_data_free_handler:
+ * @data: data object or NULL
+ *
+ * Typedef for function to free a data object - signature like free()
+ *
+ * Designed to be passed into generic data structure constructors
+ * like raptor_new_avltree(). If @data is NULL, nothing should be done.
+ */
+typedef void (*raptor_data_free_handler)(void* data);
+
+
+/**
+ * raptor_data_context_free_handler:
+ * @context: context data for the free function
+ * @object: object to free
+ *
+ * Handler function for freeing a sequence item with a contextual pointer.
+ *
+ * Set by raptor_new_sequence_with_context().
+*/
+typedef void (*raptor_data_context_free_handler)(void* context, void* object);
+
+/**
+ * raptor_data_print_handler:
+ * @object: object to print
+ * @fh: FILE* to print to
+ *
+ * Handler function for printing an object to a stream.
+ *
+ * Set by raptor_new_sequence()
+ *
+ * Return value: non-0 on failure
+ */
+typedef int (*raptor_data_print_handler)(void *object, FILE *fh);
+
+/**
+ * raptor_data_context_print_handler:
+ * @context: context data for the print function
+ * @object: object to print
+ * @fh: FILE* to print to
+ *
+ * Function function for printing an object with data context to a stream.
+ *
+ * Set by raptor_new_sequence_with_context()
+ *
+ * Return value: non-0 on failure
+ */
+typedef int (*raptor_data_context_print_handler)(void *context, void *object, FILE *fh);
+
+/**
+ * raptor_stringbuffer:
+ *
+ * Raptor string buffer class
+ */
+typedef struct raptor_stringbuffer_s raptor_stringbuffer;
+
+
+/* Public functions */
+
+#define raptor_new_world() raptor_new_world_internal(RAPTOR_VERSION)
+/* The real target of the raptor_new_world() macro */
+RAPTOR_API
+raptor_world *raptor_new_world_internal(unsigned int version_decimal);
+RAPTOR_API
+int raptor_world_open(raptor_world* world);
+RAPTOR_API
+void raptor_free_world(raptor_world* world);
+RAPTOR_API
+int raptor_world_set_libxslt_security_preferences(raptor_world *world, void *security_preferences);
+RAPTOR_API
+int raptor_world_set_flag(raptor_world *world, raptor_world_flag flag, int value);
+RAPTOR_API
+int raptor_world_set_log_handler(raptor_world *world, void *user_data, raptor_log_handler handler);
+RAPTOR_API
+void raptor_world_set_generate_bnodeid_handler(raptor_world* world, void *user_data, raptor_generate_bnodeid_handler handler);
+RAPTOR_API
+unsigned char* raptor_world_generate_bnodeid(raptor_world *world);
+RAPTOR_API
+void raptor_world_set_generate_bnodeid_parameters(raptor_world* world, char *prefix, int base);
+RAPTOR_API
+const char* raptor_log_level_get_label(raptor_log_level level);
+RAPTOR_API
+const char* raptor_domain_get_label(raptor_domain domain);
+
+/* Names */
+RAPTOR_API
+int raptor_world_is_parser_name(raptor_world* world, const char *name);
+RAPTOR_API
+const char* raptor_world_guess_parser_name(raptor_world* world, raptor_uri *uri, const char *mime_type, const unsigned char *buffer, size_t len, const unsigned char *identifier);
+RAPTOR_API
+int raptor_world_is_serializer_name(raptor_world* world, const char *name);
+
+/* Syntax descriptions */
+RAPTOR_API
+int raptor_world_get_parsers_count(raptor_world* world);
+RAPTOR_API
+int raptor_world_get_serializers_count(raptor_world* world);
+RAPTOR_API
+const raptor_syntax_description* raptor_world_get_parser_description(raptor_world* world, unsigned int counter);
+RAPTOR_API
+const raptor_syntax_description* raptor_world_get_serializer_description(raptor_world* world, unsigned int counter);
+RAPTOR_API
+int raptor_syntax_description_validate(raptor_syntax_description* desc);
+
+RAPTOR_API
+raptor_option raptor_world_get_option_from_uri(raptor_world* world, raptor_uri *uri);
+
+
+/* Term Class */
+RAPTOR_API
+raptor_term* raptor_new_term_from_uri(raptor_world* world, raptor_uri* uri);
+RAPTOR_API
+raptor_term* raptor_new_term_from_counted_uri_string(raptor_world* world, const unsigned char *uri_string, size_t length);
+RAPTOR_API
+raptor_term* raptor_new_term_from_uri_string(raptor_world* world, const unsigned char *uri_string);
+RAPTOR_API
+raptor_term* raptor_new_term_from_literal(raptor_world* world, const unsigned char* literal, raptor_uri* datatype, const unsigned char* language);
+RAPTOR_API
+raptor_term* raptor_new_term_from_counted_literal(raptor_world* world, const unsigned char* literal, size_t literal_len, raptor_uri* datatype, const unsigned char* language, unsigned char language_len);
+RAPTOR_API
+raptor_term* raptor_new_term_from_blank(raptor_world* world, const unsigned char* blank);
+RAPTOR_API
+raptor_term* raptor_new_term_from_counted_blank(raptor_world* world, const unsigned char* blank, size_t length);
+RAPTOR_API
+raptor_term* raptor_new_term_from_counted_string(raptor_world* world, unsigned char* string, size_t length);
+RAPTOR_API
+raptor_term* raptor_term_copy(raptor_term* term);
+RAPTOR_API
+int raptor_term_compare(const raptor_term *t1, const raptor_term *t2);
+RAPTOR_API
+int raptor_term_equals(raptor_term* t1, raptor_term* t2);
+RAPTOR_API
+void raptor_free_term(raptor_term *term);
+
+RAPTOR_API
+unsigned char* raptor_term_to_counted_string(raptor_term *term, size_t* len_p);
+RAPTOR_API
+unsigned char* raptor_term_to_string(raptor_term *term);
+RAPTOR_API
+int raptor_term_escaped_write(const raptor_term *term, unsigned int flags, raptor_iostream* iostr);
+RAPTOR_API RAPTOR_DEPRECATED
+int raptor_term_ntriples_write(const raptor_term *term, raptor_iostream* iostr);
+RAPTOR_API
+int raptor_uri_turtle_write(raptor_world *world, raptor_iostream* iostr, raptor_uri* uri, raptor_namespace_stack *nstack, raptor_uri *base_uri);
+RAPTOR_API
+int raptor_term_turtle_write(raptor_iostream* iostr, raptor_term* term, raptor_namespace_stack *nstack, raptor_uri *base_uri);
+RAPTOR_API
+unsigned char* raptor_uri_to_turtle_counted_string(raptor_world *world, raptor_uri* uri, raptor_namespace_stack *nstack, raptor_uri *base_uri, size_t *len_p);
+RAPTOR_API
+unsigned char* raptor_uri_to_turtle_string(raptor_world *world, raptor_uri* uri, raptor_namespace_stack *nstack, raptor_uri *base_uri);
+RAPTOR_API
+unsigned char* raptor_term_to_turtle_counted_string(raptor_term* term, raptor_namespace_stack *nstack, raptor_uri *base_uri, size_t *len_p);
+RAPTOR_API
+unsigned char* raptor_term_to_turtle_string(raptor_term* term, raptor_namespace_stack *nstack, raptor_uri *base_uri);
+
+
+/* Statement Class */
+RAPTOR_API
+void raptor_statement_init(raptor_statement *statement, raptor_world *world);
+RAPTOR_API
+void raptor_statement_clear(raptor_statement *statement);
+RAPTOR_API
+raptor_statement* raptor_new_statement(raptor_world *world);
+RAPTOR_API
+raptor_statement* raptor_new_statement_from_nodes(raptor_world* world, raptor_term *subject, raptor_term *predicate, raptor_term *object, raptor_term *graph);
+RAPTOR_API
+raptor_statement* raptor_statement_copy(raptor_statement *statement);
+RAPTOR_API
+void raptor_free_statement(raptor_statement *statement);
+
+RAPTOR_API
+int raptor_statement_print(const raptor_statement * statement, FILE *stream);
+RAPTOR_API
+int raptor_statement_print_as_ntriples(const raptor_statement * statement, FILE *stream);
+RAPTOR_API
+int raptor_statement_compare(const raptor_statement *s1, const raptor_statement *s2);
+RAPTOR_API
+int raptor_statement_equals(const raptor_statement* s1, const raptor_statement* s2);
+
+
+/* Parser Class */
+RAPTOR_API
+raptor_parser* raptor_new_parser(raptor_world* world, const char *name);
+RAPTOR_API
+raptor_parser* raptor_new_parser_for_content(raptor_world* world, raptor_uri *uri, const char *mime_type, const unsigned char *buffer, size_t len, const unsigned char *identifier);
+RAPTOR_API
+void raptor_free_parser(raptor_parser* parser);
+
+/* methods */
+
+/* Handlers */
+RAPTOR_API
+void raptor_parser_set_statement_handler(raptor_parser* parser, void *user_data, raptor_statement_handler handler);
+RAPTOR_API
+void raptor_parser_set_graph_mark_handler(raptor_parser* parser, void *user_data, raptor_graph_mark_handler handler);
+RAPTOR_API
+void raptor_parser_set_namespace_handler(raptor_parser* parser, void *user_data, raptor_namespace_handler handler);
+RAPTOR_API
+void raptor_parser_set_uri_filter(raptor_parser* parser, raptor_uri_filter_func filter, void* user_data);
+RAPTOR_API
+raptor_locator* raptor_parser_get_locator(raptor_parser* rdf_parser);
+
+
+/* Parsing functions */
+RAPTOR_API
+int raptor_parser_parse_start(raptor_parser *rdf_parser, raptor_uri *uri);
+RAPTOR_API
+int raptor_parser_parse_chunk(raptor_parser* rdf_parser, const unsigned char *buffer, size_t len, int is_end);
+RAPTOR_API
+int raptor_parser_parse_file_stream(raptor_parser* rdf_parser, FILE *stream, const char *filename, raptor_uri *base_uri);
+RAPTOR_API
+int raptor_parser_parse_file(raptor_parser* rdf_parser, raptor_uri *uri, raptor_uri *base_uri);
+RAPTOR_API
+int raptor_parser_parse_uri(raptor_parser* rdf_parser, raptor_uri *uri, raptor_uri *base_uri);
+RAPTOR_API
+int raptor_parser_parse_uri_with_connection(raptor_parser* rdf_parser, raptor_uri *uri, raptor_uri *base_uri, void *connection);
+RAPTOR_API
+int raptor_parser_parse_iostream(raptor_parser* rdf_parser, raptor_iostream *iostr, raptor_uri *base_uri);
+RAPTOR_API
+void raptor_parser_parse_abort(raptor_parser* rdf_parser);
+RAPTOR_API
+const char* raptor_parser_get_name(raptor_parser *rdf_parser);
+RAPTOR_API
+const raptor_syntax_description* raptor_parser_get_description(raptor_parser *rdf_parser);
+
+/* parser option methods */
+RAPTOR_API
+int raptor_parser_set_option(raptor_parser *parser, raptor_option option, const char* string, int integer);
+RAPTOR_API
+int raptor_parser_get_option(raptor_parser *parser, raptor_option option, char** string_p, int* integer_p);
+
+/* parser utility methods */
+RAPTOR_API
+const char* raptor_parser_get_accept_header(raptor_parser* rdf_parser);
+RAPTOR_API
+raptor_world* raptor_parser_get_world(raptor_parser* rdf_parser);
+RAPTOR_API
+raptor_uri* raptor_parser_get_graph(raptor_parser* rdf_parser);
+
+
+/* Locator Class */
+/* methods */
+RAPTOR_API
+int raptor_locator_print(raptor_locator* locator, FILE *stream);
+RAPTOR_API
+int raptor_locator_format(char *buffer, size_t length, raptor_locator* locator);
+RAPTOR_API
+int raptor_locator_line(raptor_locator *locator);
+RAPTOR_API
+int raptor_locator_column(raptor_locator *locator);
+RAPTOR_API
+int raptor_locator_byte(raptor_locator *locator);
+RAPTOR_API
+const char* raptor_locator_file(raptor_locator *locator);
+RAPTOR_API
+const char* raptor_locator_uri(raptor_locator *locator);
+
+
+/* Serializer Class */
+RAPTOR_API
+raptor_serializer* raptor_new_serializer(raptor_world* world, const char *name);
+RAPTOR_API
+void raptor_free_serializer(raptor_serializer* rdf_serializer);
+
+/* methods */
+RAPTOR_API
+int raptor_serializer_start_to_iostream(raptor_serializer *rdf_serializer, raptor_uri *uri, raptor_iostream *iostream);
+RAPTOR_API
+int raptor_serializer_start_to_filename(raptor_serializer *rdf_serializer, const char *filename);
+RAPTOR_API
+int raptor_serializer_start_to_string(raptor_serializer *rdf_serializer, raptor_uri *uri, void **string_p, size_t *length_p);
+RAPTOR_API
+int raptor_serializer_start_to_file_handle(raptor_serializer *rdf_serializer, raptor_uri *uri, FILE *fh);
+RAPTOR_API
+int raptor_serializer_set_namespace(raptor_serializer* rdf_serializer, raptor_uri *uri, const unsigned char *prefix);
+RAPTOR_API
+int raptor_serializer_set_namespace_from_namespace(raptor_serializer* rdf_serializer, raptor_namespace *nspace);
+RAPTOR_API
+int raptor_serializer_serialize_statement(raptor_serializer* rdf_serializer, raptor_statement *statement);
+RAPTOR_API
+int raptor_serializer_serialize_end(raptor_serializer *rdf_serializer);
+RAPTOR_API
+raptor_iostream* raptor_serializer_get_iostream(raptor_serializer *serializer);
+RAPTOR_API
+raptor_locator* raptor_serializer_get_locator(raptor_serializer *rdf_serializer);
+RAPTOR_API
+int raptor_serializer_flush(raptor_serializer *rdf_serializer);
+RAPTOR_API
+const raptor_syntax_description* raptor_serializer_get_description(raptor_serializer *rdf_serializer);
+
+/* serializer option methods */
+RAPTOR_API
+int raptor_serializer_set_option(raptor_serializer *serializer, raptor_option option, const char* string, int integer);
+RAPTOR_API
+int raptor_serializer_get_option(raptor_serializer *serializer, raptor_option option, char** string_p, int* integer_p);
+
+/* utility methods */
+RAPTOR_API
+raptor_world* raptor_serializer_get_world(raptor_serializer* rdf_serializer);
+
+
+/* memory functions */
+RAPTOR_API
+void raptor_free_memory(void *ptr);
+RAPTOR_API
+void* raptor_alloc_memory(size_t size);
+RAPTOR_API
+void* raptor_calloc_memory(size_t nmemb, size_t size);
+
+
+/* URI Class */
+RAPTOR_API
+raptor_uri* raptor_new_uri_from_counted_string(raptor_world* world, const unsigned char *uri_string, size_t length);
+RAPTOR_API
+raptor_uri* raptor_new_uri(raptor_world* world, const unsigned char *uri_string);
+RAPTOR_API
+raptor_uri* raptor_new_uri_from_uri_local_name(raptor_world* world, raptor_uri *uri, const unsigned char *local_name);
+RAPTOR_API
+raptor_uri* raptor_new_uri_relative_to_base(raptor_world* world, raptor_uri *base_uri, const unsigned char *uri_string);
+RAPTOR_API
+raptor_uri* raptor_new_uri_relative_to_base_counted(raptor_world* world, raptor_uri *base_uri, const unsigned char *uri_string, size_t uri_len);
+RAPTOR_API
+raptor_uri* raptor_new_uri_from_id(raptor_world* world, raptor_uri *base_uri, const unsigned char *id);
+RAPTOR_API
+raptor_uri* raptor_new_uri_from_uri_or_file_string(raptor_world* world, raptor_uri* base_uri, const unsigned char* uri_or_file_string);
+RAPTOR_API
+raptor_uri* raptor_new_uri_for_rdf_concept(raptor_world* world, const unsigned char *name);
+RAPTOR_API
+raptor_uri* raptor_new_uri_for_xmlbase(raptor_uri* old_uri);
+RAPTOR_API
+raptor_uri* raptor_new_uri_for_retrieval(raptor_uri* old_uri);
+RAPTOR_API
+void raptor_free_uri(raptor_uri *uri);
+
+/* methods */
+RAPTOR_API
+int raptor_uri_equals(raptor_uri* uri1, raptor_uri* uri2);
+RAPTOR_API
+int raptor_uri_compare(raptor_uri* uri1, raptor_uri* uri2);
+RAPTOR_API
+raptor_uri* raptor_uri_copy(raptor_uri *uri);
+RAPTOR_API
+unsigned char* raptor_uri_as_string(raptor_uri *uri);
+RAPTOR_API
+unsigned char* raptor_uri_as_counted_string(raptor_uri *uri, size_t* len_p);
+RAPTOR_API
+unsigned char* raptor_uri_to_relative_counted_uri_string(raptor_uri *base_uri, raptor_uri *reference_uri, size_t *length_p);
+RAPTOR_API
+unsigned char* raptor_uri_to_relative_uri_string(raptor_uri *base_uri, raptor_uri *reference_uri);
+RAPTOR_API
+int raptor_uri_print(const raptor_uri* uri, FILE *stream);
+RAPTOR_API
+unsigned char* raptor_uri_to_counted_string(raptor_uri *uri, size_t *len_p);
+RAPTOR_API
+unsigned char* raptor_uri_to_string(raptor_uri *uri);
+RAPTOR_API
+raptor_world* raptor_uri_get_world(raptor_uri *uri);
+RAPTOR_API
+int raptor_uri_file_exists(raptor_uri* uri);
+RAPTOR_API
+int raptor_uri_escaped_write(raptor_uri* uri, raptor_uri* base_uri, unsigned int flags, raptor_iostream *iostr);
+
+/* XML utility functions */
+RAPTOR_API
+int raptor_xml_escape_string_any(raptor_world* world, const unsigned char *string, size_t len, unsigned char *buffer, size_t length, char quote, int xml_version);
+RAPTOR_API
+int raptor_xml_escape_string_any_write(const unsigned char *string, size_t len, char quote, int xml_version, raptor_iostream* iostr);
+RAPTOR_API
+int raptor_xml_escape_string(raptor_world *world, const unsigned char *string, size_t len, unsigned char *buffer, size_t length, char quote);
+RAPTOR_API
+int raptor_xml_escape_string_write(const unsigned char *string, size_t len, char quote, raptor_iostream* iostr);
+RAPTOR_API
+int raptor_xml_name_check(const unsigned char *string, size_t length, int xml_version);
+
+
+/* portable vsnprintf utility function */
+RAPTOR_API RAPTOR_DEPRECATED
+char* raptor_vsnprintf(const char *format, va_list arguments) RAPTOR_PRINTF_FORMAT(1, 0);
+RAPTOR_API
+int raptor_vsnprintf2(char *buffer, size_t size, const char *format, va_list arguments) RAPTOR_PRINTF_FORMAT(3, 0);
+RAPTOR_API
+int raptor_snprintf(char *buffer, size_t size, const char *format, ...) RAPTOR_PRINTF_FORMAT(3, 4);
+RAPTOR_API
+int raptor_vasprintf(char **ret, const char *format, va_list arguments) RAPTOR_PRINTF_FORMAT(2, 0);
+
+/* RFC2396 URI resolving functions */
+RAPTOR_API
+size_t raptor_uri_resolve_uri_reference(const unsigned char *base_uri, const unsigned char *reference_uri, unsigned char* buffer, size_t length);
+
+/* URI String utility functions */
+RAPTOR_API
+unsigned char* raptor_uri_counted_filename_to_uri_string(const char *filename, size_t filename_len);
+RAPTOR_API
+unsigned char* raptor_uri_filename_to_uri_string(const char *filename);
+RAPTOR_API
+int raptor_uri_filename_exists(const unsigned char* path);
+RAPTOR_API
+char* raptor_uri_uri_string_to_filename(const unsigned char *uri_string);
+RAPTOR_API
+char* raptor_uri_uri_string_to_filename_fragment(const unsigned char *uri_string, unsigned char **fragment_p);
+RAPTOR_API
+int raptor_uri_uri_string_is_file_uri(const unsigned char* uri_string);
+RAPTOR_API
+int raptor_stringbuffer_append_uri_escaped_counted_string(raptor_stringbuffer* sb, const char* string, size_t length, int space_is_plus);
+RAPTOR_API
+char* raptor_uri_uri_string_to_counted_filename_fragment(const unsigned char *uri_string, size_t* len_p, unsigned char **fragment_p, size_t* fragment_len_p);
+RAPTOR_API
+int raptor_uri_uri_string_is_absolute(const unsigned char* uri_string);
+
+
+/**
+ * RAPTOR_RDF_MS_URI:
+ *
+ * RDF Namespace URI (rdf:).
+ *
+ * Copy with raptor_uri_copy() to use.
+ */
+#define RAPTOR_RDF_MS_URI raptor_rdf_namespace_uri
+
+/**
+ * RAPTOR_RDF_SCHEMA_URI:
+ *
+ * RDF Schema Namespace URI (rdfs:).
+ *
+ * Copy with raptor_uri_copy() to use.
+ */
+#define RAPTOR_RDF_SCHEMA_URI raptor_rdf_schema_namespace_uri
+
+/**
+ * RAPTOR_XMLSCHEMA_DATATYPES_URI:
+ *
+ * XML Schema Datatypes URI (xsd:).
+ *
+ * Copy with raptor_uri_copy() to use.
+ */
+#define RAPTOR_XMLSCHEMA_DATATYPES_URI raptor_xmlschema_datatypes_namespace_uri
+
+/**
+ * RAPTOR_OWL_URI:
+ *
+ * OWL Namespace URI (owl:).
+ *
+ * Copy with raptor_uri_copy() to use.
+ */
+#define RAPTOR_OWL_URI raptor_owl_namespace_uri
+
+
+/* raptor_www */
+RAPTOR_API
+raptor_www* raptor_new_www(raptor_world* world);
+RAPTOR_API
+raptor_www* raptor_new_www_with_connection(raptor_world* world, void* connection);
+RAPTOR_API
+void raptor_free_www(raptor_www *www);
+RAPTOR_API
+int raptor_www_set_ssl_cert_options(raptor_www* www, const char* cert_filename, const char* cert_type, const char* cert_passphrase);
+RAPTOR_API
+int raptor_www_set_ssl_verify_options(raptor_www* www, int verify_peer, int verify_host);
+RAPTOR_API
+void raptor_www_set_user_agent(raptor_www *www, const char *user_agent);
+RAPTOR_API
+void raptor_www_set_proxy(raptor_www *www, const char *proxy);
+RAPTOR_API
+void raptor_www_set_http_accept(raptor_www *www, const char *value);
+RAPTOR_API
+void raptor_www_set_write_bytes_handler(raptor_www *www, raptor_www_write_bytes_handler handler, void *user_data);
+RAPTOR_API
+void raptor_www_set_content_type_handler(raptor_www *www, raptor_www_content_type_handler handler, void *user_data);
+RAPTOR_API
+void raptor_www_set_final_uri_handler(raptor_www* www, raptor_www_final_uri_handler handler, void *user_data);
+RAPTOR_API
+void raptor_www_set_uri_filter(raptor_www* www, raptor_uri_filter_func filter, void* user_data);
+RAPTOR_API
+void raptor_www_set_connection_timeout(raptor_www* www, int timeout);
+RAPTOR_API
+int raptor_www_set_http_cache_control(raptor_www* www, const char* cache_control);
+RAPTOR_API
+int raptor_www_fetch(raptor_www *www, raptor_uri *uri);
+RAPTOR_API
+int raptor_www_fetch_to_string(raptor_www *www, raptor_uri *uri, void **string_p, size_t *length_p, raptor_data_malloc_handler const malloc_handler);
+RAPTOR_API
+void* raptor_www_get_connection(raptor_www *www);
+RAPTOR_API
+void raptor_www_abort(raptor_www *www, const char *reason);
+RAPTOR_API
+raptor_uri* raptor_www_get_final_uri(raptor_www* www);
+
+
+/* XML QNames Class */
+RAPTOR_API
+raptor_qname* raptor_new_qname(raptor_namespace_stack *nstack, const unsigned char *name, const unsigned char *value);
+RAPTOR_API
+raptor_qname* raptor_new_qname_from_namespace_local_name(raptor_world* world, raptor_namespace *ns, const unsigned char *local_name, const unsigned char *value);
+
+/* methods */
+RAPTOR_API
+raptor_qname* raptor_qname_copy(raptor_qname *qname);
+RAPTOR_API
+void raptor_free_qname(raptor_qname* name);
+RAPTOR_API
+int raptor_qname_equal(raptor_qname *name1, raptor_qname *name2);
+RAPTOR_API
+unsigned char* raptor_qname_to_counted_name(raptor_qname *qname, size_t* length_p);
+RAPTOR_API
+const raptor_namespace* raptor_qname_get_namespace(raptor_qname* name);
+RAPTOR_API
+const unsigned char* raptor_qname_get_local_name(raptor_qname* name);
+RAPTOR_API
+const unsigned char* raptor_qname_get_value(raptor_qname* name);
+RAPTOR_API
+const unsigned char* raptor_qname_get_counted_value(raptor_qname* name, size_t* length_p);
+RAPTOR_API
+int raptor_qname_write(raptor_qname *qname, raptor_iostream* iostr);
+
+/* QName String utility functions */
+RAPTOR_API
+raptor_uri* raptor_qname_string_to_uri(raptor_namespace_stack *nstack, const unsigned char *name, size_t name_len);
+RAPTOR_API
+unsigned char* raptor_qname_format_as_xml(const raptor_qname *qname, size_t *length_p);
+
+/* XML Namespaces Stack class */
+RAPTOR_API
+raptor_namespace* raptor_new_namespace_from_uri(raptor_namespace_stack *nstack, const unsigned char *prefix, raptor_uri* ns_uri, int depth);
+RAPTOR_API
+raptor_namespace_stack* raptor_new_namespaces(raptor_world* world, int defaults);
+RAPTOR_API
+int raptor_namespaces_init(raptor_world* world, raptor_namespace_stack *nstack, int defaults);
+RAPTOR_API
+void raptor_namespaces_clear(raptor_namespace_stack *nstack);
+RAPTOR_API
+void raptor_free_namespaces(raptor_namespace_stack *nstack);
+
+/* methods */
+RAPTOR_API
+void raptor_namespaces_start_namespace(raptor_namespace_stack *nstack, raptor_namespace *nspace);
+RAPTOR_API
+int raptor_namespaces_start_namespace_full(raptor_namespace_stack *nstack, const unsigned char *prefix, const unsigned char *ns_uri_string, int depth);
+RAPTOR_API
+void raptor_namespaces_end_for_depth(raptor_namespace_stack *nstack, int depth);
+RAPTOR_API
+raptor_namespace* raptor_namespaces_get_default_namespace(raptor_namespace_stack *nstack);
+RAPTOR_API
+raptor_namespace* raptor_namespaces_find_namespace(raptor_namespace_stack *nstack, const unsigned char *prefix, int prefix_length);
+RAPTOR_API
+raptor_namespace* raptor_namespaces_find_namespace_by_uri(raptor_namespace_stack *nstack, raptor_uri *ns_uri);
+RAPTOR_API
+int raptor_namespaces_namespace_in_scope(raptor_namespace_stack *nstack, const raptor_namespace *nspace);
+RAPTOR_API
+raptor_qname* raptor_new_qname_from_namespace_uri(raptor_namespace_stack *nstack, raptor_uri *uri, int xml_version);
+
+
+/* XML Namespace Class */
+RAPTOR_API
+raptor_namespace* raptor_new_namespace(raptor_namespace_stack *nstack, const unsigned char *prefix, const unsigned char *ns_uri_string, int depth);
+RAPTOR_API
+void raptor_free_namespace(raptor_namespace *ns);
+RAPTOR_API
+int raptor_namespace_stack_start_namespace(raptor_namespace_stack *nstack, raptor_namespace *ns, int new_depth);
+RAPTOR_API
+raptor_uri* raptor_namespace_get_uri(const raptor_namespace *ns);
+RAPTOR_API
+const unsigned char* raptor_namespace_get_prefix(const raptor_namespace *ns);
+RAPTOR_API
+const unsigned char* raptor_namespace_get_counted_prefix(const raptor_namespace *ns, size_t *length_p);
+RAPTOR_API
+unsigned char* raptor_namespace_format_as_xml(const raptor_namespace *ns, size_t *length_p);
+RAPTOR_API
+int raptor_namespace_write(raptor_namespace *ns, raptor_iostream* iostr);
+
+/* namespace string utility function */
+RAPTOR_API
+int raptor_xml_namespace_string_parse(const unsigned char *string, unsigned char **prefix, unsigned char **uri_string);
+
+/* Sequence class */
+/**
+ * raptor_sequence:
+ *
+ * Raptor sequence class
+ */
+typedef struct raptor_sequence_s raptor_sequence;
+
+/* Sequence Class */
+RAPTOR_API
+raptor_sequence* raptor_new_sequence(raptor_data_free_handler free_handler, raptor_data_print_handler print_handler);
+RAPTOR_API
+raptor_sequence* raptor_new_sequence_with_context(raptor_data_context_free_handler free_handler, raptor_data_context_print_handler print_handler, void* handler_context);
+RAPTOR_API
+void raptor_free_sequence(raptor_sequence* seq);
+
+/* methods */
+RAPTOR_API
+int raptor_sequence_size(raptor_sequence* seq);
+RAPTOR_API
+int raptor_sequence_set_at(raptor_sequence* seq, int idx, void *data);
+RAPTOR_API
+int raptor_sequence_push(raptor_sequence* seq, void *data);
+RAPTOR_API
+int raptor_sequence_shift(raptor_sequence* seq, void *data);
+RAPTOR_API
+void* raptor_sequence_get_at(raptor_sequence* seq, int idx);
+RAPTOR_API
+void* raptor_sequence_pop(raptor_sequence* seq);
+RAPTOR_API
+void* raptor_sequence_unshift(raptor_sequence* seq);
+RAPTOR_API
+void* raptor_sequence_delete_at(raptor_sequence* seq, int idx);
+
+RAPTOR_API
+void raptor_sequence_sort(raptor_sequence* seq, raptor_data_compare_handler compare);
+RAPTOR_API
+void raptor_sequence_sort_r(raptor_sequence* seq, raptor_data_compare_arg_handler compare, void* user_data);
+RAPTOR_API
+int raptor_sequence_swap(raptor_sequence* seq, int i, int j);
+RAPTOR_API
+int raptor_sequence_reverse(raptor_sequence* seq, int start_index, int length);
+RAPTOR_API
+int raptor_sequence_next_permutation(raptor_sequence *seq, raptor_data_compare_handler compare);
+
+/* helper for printing sequences of strings */
+RAPTOR_API
+int raptor_sequence_print(raptor_sequence* seq, FILE* fh);
+RAPTOR_API
+int raptor_sequence_join(raptor_sequence* dest, raptor_sequence *src);
+
+
+/* Unicode and UTF8 */
+
+/**
+ * raptor_unichar:
+ *
+ * raptor Unicode codepoint
+ */
+typedef unsigned long raptor_unichar;
+RAPTOR_API
+int raptor_unicode_utf8_string_put_char(raptor_unichar c, unsigned char *output, size_t length);
+RAPTOR_API
+int raptor_unicode_utf8_string_get_char(const unsigned char *input, size_t length, raptor_unichar *output);
+RAPTOR_API
+int raptor_unicode_is_xml11_namestartchar(raptor_unichar c);
+RAPTOR_API
+int raptor_unicode_is_xml10_namestartchar(raptor_unichar c);
+RAPTOR_API
+int raptor_unicode_is_xml11_namechar(raptor_unichar c);
+RAPTOR_API
+int raptor_unicode_is_xml10_namechar(raptor_unichar c);
+RAPTOR_API
+int raptor_unicode_check_utf8_string(const unsigned char *string, size_t length);
+RAPTOR_API
+int raptor_unicode_utf8_strlen(const unsigned char *string, size_t length);
+RAPTOR_API
+size_t raptor_unicode_utf8_substr(unsigned char* dest, size_t* dest_length_p, const unsigned char* src, size_t src_length, int startingLoc, int length);
+
+/* Stringbuffer Class */
+RAPTOR_API
+raptor_stringbuffer* raptor_new_stringbuffer(void);
+RAPTOR_API
+void raptor_free_stringbuffer(raptor_stringbuffer *stringbuffer);
+
+/* methods */
+RAPTOR_API
+int raptor_stringbuffer_append_counted_string(raptor_stringbuffer* stringbuffer, const unsigned char *string, size_t length, int do_copy);
+RAPTOR_API
+int raptor_stringbuffer_append_string(raptor_stringbuffer* stringbuffer, const unsigned char *string, int do_copy);
+RAPTOR_API
+int raptor_stringbuffer_append_decimal(raptor_stringbuffer* stringbuffer, int integer);
+RAPTOR_API
+int raptor_stringbuffer_append_hexadecimal(raptor_stringbuffer* stringbuffer, int hex);
+RAPTOR_API
+int raptor_stringbuffer_append_stringbuffer(raptor_stringbuffer* stringbuffer, raptor_stringbuffer* append);
+RAPTOR_API
+int raptor_stringbuffer_prepend_counted_string(raptor_stringbuffer* stringbuffer, const unsigned char *string, size_t length, int do_copy);
+RAPTOR_API
+int raptor_stringbuffer_prepend_string(raptor_stringbuffer* stringbuffer, const unsigned char *string, int do_copy);
+RAPTOR_API
+unsigned char* raptor_stringbuffer_as_string(raptor_stringbuffer* stringbuffer);
+RAPTOR_API
+size_t raptor_stringbuffer_length(raptor_stringbuffer* stringbuffer);
+RAPTOR_API
+int raptor_stringbuffer_copy_to_string(raptor_stringbuffer* stringbuffer, unsigned char *string, size_t length);
+
+/**
+ * raptor_iostream_init_func:
+ * @context: stream context data
+ *
+ * Handler function for #raptor_iostream initialising.
+ *
+ * Return value: non-0 on failure.
+ */
+typedef int (*raptor_iostream_init_func) (void *context);
+
+/**
+ * raptor_iostream_finish_func:
+ * @context: stream context data
+ *
+ * Handler function for #raptor_iostream terminating.
+ *
+ */
+typedef void (*raptor_iostream_finish_func) (void *context);
+
+/**
+ * raptor_iostream_write_byte_func
+ * @context: stream context data
+ * @byte: byte to write
+ *
+ * Handler function for implementing raptor_iostream_write_byte().
+ *
+ * Return value: non-0 on failure.
+ */
+typedef int (*raptor_iostream_write_byte_func) (void *context, const int byte);
+
+/**
+ * raptor_iostream_write_bytes_func:
+ * @context: stream context data
+ * @ptr: pointer to bytes to write
+ * @size: size of item
+ * @nmemb: number of items
+ *
+ * Handler function for implementing raptor_iostream_write_bytes().
+ *
+ * Return value: non-0 on failure.
+ */
+typedef int (*raptor_iostream_write_bytes_func) (void *context, const void *ptr, size_t size, size_t nmemb);
+
+/**
+ * raptor_iostream_write_end_func:
+ * @context: stream context data
+ *
+ * Handler function for implementing raptor_iostream_write_end().
+ *
+ * Return value: non-0 on failure.
+ */
+typedef int (*raptor_iostream_write_end_func) (void *context);
+
+/**
+ * raptor_iostream_read_bytes_func:
+ * @context: stream context data
+ * @ptr: pointer to buffer to read into
+ * @size: size of buffer
+ * @nmemb: number of items
+ *
+ * Handler function for implementing raptor_iostream_read_bytes().
+ *
+ * Return value: number of items read, 0 or < @size on EOF, <0 on failure
+ */
+typedef int (*raptor_iostream_read_bytes_func) (void *context, void *ptr, size_t size, size_t nmemb);
+
+/**
+ * raptor_iostream_read_eof_func:
+ * @context: stream context data
+ *
+ * Handler function for implementing raptor_iostream_read_eof().
+ *
+ * Return value: non-0 if EOF
+ */
+typedef int (*raptor_iostream_read_eof_func) (void *context);
+
+/**
+ * raptor_iostream_handler:
+ * @version: interface version. Presently 1 or 2.
+ * @init: initialisation handler - optional, called at most once (V1)
+ * @finish: finishing handler - optional, called at most once (V1)
+ * @write_byte: write byte handler - required (for writing) (V1)
+ * @write_bytes: write bytes handler - required (for writing) (V1)
+ * @write_end: write end handler - optional (for writing), called at most once (V1)
+ * @read_bytes: read bytes handler - required (for reading) (V2)
+ * @read_eof: read EOF handler - required (for reading) (V2)
+ *
+ * I/O stream implementation handler structure.
+ *
+ */
+typedef struct {
+ int version;
+
+ /* V1 functions */
+ raptor_iostream_init_func init;
+ raptor_iostream_finish_func finish;
+ raptor_iostream_write_byte_func write_byte;
+ raptor_iostream_write_bytes_func write_bytes;
+ raptor_iostream_write_end_func write_end;
+
+ /* V2 functions */
+ raptor_iostream_read_bytes_func read_bytes;
+ raptor_iostream_read_eof_func read_eof;
+} raptor_iostream_handler;
+
+
+/* I/O Stream Class */
+RAPTOR_API
+raptor_iostream* raptor_new_iostream_from_handler(raptor_world* world, void *user_data, const raptor_iostream_handler* const handler);
+RAPTOR_API
+raptor_iostream* raptor_new_iostream_to_sink(raptor_world* world);
+RAPTOR_API
+raptor_iostream* raptor_new_iostream_to_filename(raptor_world* world, const char *filename);
+RAPTOR_API
+raptor_iostream* raptor_new_iostream_to_file_handle(raptor_world* world, FILE *handle);
+RAPTOR_API
+raptor_iostream* raptor_new_iostream_to_string(raptor_world* world, void **string_p, size_t *length_p, raptor_data_malloc_handler const malloc_handler);
+RAPTOR_API
+raptor_iostream* raptor_new_iostream_from_sink(raptor_world* world);
+RAPTOR_API
+raptor_iostream* raptor_new_iostream_from_filename(raptor_world* world, const char *filename);
+RAPTOR_API
+raptor_iostream* raptor_new_iostream_from_file_handle(raptor_world* world, FILE *handle);
+RAPTOR_API
+raptor_iostream* raptor_new_iostream_from_string(raptor_world* world, void *string, size_t length);
+RAPTOR_API
+void raptor_free_iostream(raptor_iostream *iostr);
+
+RAPTOR_API
+int raptor_iostream_write_bytes(const void *ptr, size_t size, size_t nmemb, raptor_iostream *iostr);
+RAPTOR_API
+int raptor_iostream_write_byte(const int byte, raptor_iostream *iostr);
+RAPTOR_API
+int raptor_iostream_write_end(raptor_iostream *iostr);
+RAPTOR_API
+int raptor_iostream_string_write(const void *string, raptor_iostream *iostr);
+RAPTOR_API
+int raptor_iostream_counted_string_write(const void *string, size_t len, raptor_iostream *iostr);
+RAPTOR_API
+unsigned long raptor_iostream_tell(raptor_iostream *iostr);
+RAPTOR_API
+int raptor_iostream_decimal_write(int integer, raptor_iostream* iostr);
+RAPTOR_API
+int raptor_iostream_hexadecimal_write(unsigned int integer, int width, raptor_iostream* iostr);
+RAPTOR_API
+int raptor_stringbuffer_write(raptor_stringbuffer *sb, raptor_iostream* iostr);
+RAPTOR_API
+int raptor_uri_write(raptor_uri *uri, raptor_iostream *iostr);
+RAPTOR_API
+int raptor_iostream_read_bytes(void *ptr, size_t size, size_t nmemb, raptor_iostream* iostr);
+RAPTOR_API
+int raptor_iostream_read_eof(raptor_iostream *iostr);
+
+/* I/O Stream utility functions */
+
+/**
+ * raptor_escaped_write_bitflags:
+ * @RAPTOR_ESCAPED_WRITE_BITFLAG_BS_ESCAPES_BF : Allow \b \f,
+ * @RAPTOR_ESCAPED_WRITE_BITFLAG_BS_ESCAPES_TNRU : ALlow \t \n \r \u
+ * @RAPTOR_ESCAPED_WRITE_BITFLAG_UTF8 : Allow UTF-8 for printable U *
+ * @RAPTOR_ESCAPED_WRITE_BITFLAG_SPARQL_URI_ESCAPES: Must escape #x00-#x20<>\"{}|^` in URIs
+ * @RAPTOR_ESCAPED_WRITE_NTRIPLES_LITERAL: N-Triples literal
+ * @RAPTOR_ESCAPED_WRITE_NTRIPLES_URI: N-Triples URI
+ * @RAPTOR_ESCAPED_WRITE_SPARQL_LITERAL: SPARQL literal: allows raw UTF8 for printable literals
+ * @RAPTOR_ESCAPED_WRITE_SPARQL_LONG_LITERAL: SPARQL long literal: no BS-escapes allowed
+ * @RAPTOR_ESCAPED_WRITE_SPARQL_URI: SPARQL uri: have to escape certain characters
+ * @RAPTOR_ESCAPED_WRITE_TURTLE_URI: Turtle 2013 URIs (like SPARQL)
+ * @RAPTOR_ESCAPED_WRITE_TURTLE_LITERAL: Turtle 2013 literals (like SPARQL)
+ * @RAPTOR_ESCAPED_WRITE_TURTLE_LONG_LITERAL: Turtle 2013 long literals (like SPARQL)
+ * @RAPTOR_ESCAPED_WRITE_JSON_LITERAL: JSON literals: \b \f \t \r \n and \u \U
+ *
+ * Bit flags for raptor_string_escaped_write() and friends.
+ */
+typedef enum {
+ RAPTOR_ESCAPED_WRITE_BITFLAG_BS_ESCAPES_BF = 1,
+ RAPTOR_ESCAPED_WRITE_BITFLAG_BS_ESCAPES_TNRU = 2,
+ RAPTOR_ESCAPED_WRITE_BITFLAG_UTF8 = 4,
+ RAPTOR_ESCAPED_WRITE_BITFLAG_SPARQL_URI_ESCAPES = 8,
+
+ /* N-Triples - favour writing \u, \U over UTF8 */
+ RAPTOR_ESCAPED_WRITE_NTRIPLES_LITERAL = RAPTOR_ESCAPED_WRITE_BITFLAG_BS_ESCAPES_TNRU | RAPTOR_ESCAPED_WRITE_BITFLAG_BS_ESCAPES_BF,
+ RAPTOR_ESCAPED_WRITE_NTRIPLES_URI = RAPTOR_ESCAPED_WRITE_BITFLAG_SPARQL_URI_ESCAPES,
+
+ /* SPARQL literal: allows raw UTF8 for printable literals */
+ RAPTOR_ESCAPED_WRITE_SPARQL_LITERAL = RAPTOR_ESCAPED_WRITE_BITFLAG_UTF8,
+
+ /* SPARQL long literal: no BS-escapes allowed */
+ RAPTOR_ESCAPED_WRITE_SPARQL_LONG_LITERAL = RAPTOR_ESCAPED_WRITE_BITFLAG_UTF8,
+
+ /* SPARQL uri: have to escape certain characters */
+ RAPTOR_ESCAPED_WRITE_SPARQL_URI = RAPTOR_ESCAPED_WRITE_BITFLAG_UTF8 | RAPTOR_ESCAPED_WRITE_BITFLAG_SPARQL_URI_ESCAPES,
+
+ /* Turtle (2013) escapes are like SPARQL */
+ RAPTOR_ESCAPED_WRITE_TURTLE_URI = RAPTOR_ESCAPED_WRITE_SPARQL_URI,
+ RAPTOR_ESCAPED_WRITE_TURTLE_LITERAL = RAPTOR_ESCAPED_WRITE_SPARQL_LITERAL,
+ RAPTOR_ESCAPED_WRITE_TURTLE_LONG_LITERAL = RAPTOR_ESCAPED_WRITE_SPARQL_LONG_LITERAL,
+
+ /* JSON literals: \b \f \t \r \n and \u \U */
+ RAPTOR_ESCAPED_WRITE_JSON_LITERAL = RAPTOR_ESCAPED_WRITE_BITFLAG_BS_ESCAPES_TNRU | RAPTOR_ESCAPED_WRITE_BITFLAG_BS_ESCAPES_BF
+} raptor_escaped_write_bitflags;
+
+
+RAPTOR_API
+int raptor_string_ntriples_write(const unsigned char *string, size_t len, const char delim, raptor_iostream *iostr);
+RAPTOR_API
+int raptor_bnodeid_ntriples_write(const unsigned char *bnodeid, size_t len, raptor_iostream *iostr);
+RAPTOR_API RAPTOR_DEPRECATED
+int raptor_string_python_write(const unsigned char *string, size_t len, const char delim, unsigned int mode, raptor_iostream *iostr);
+RAPTOR_API
+int raptor_statement_ntriples_write(const raptor_statement *statement, raptor_iostream* iostr, int write_graph_term);
+RAPTOR_API
+int raptor_string_escaped_write(const unsigned char *string, size_t len, const char delim, unsigned int flags, raptor_iostream *iostr);
+
+
+/* Parser and Serializer options */
+
+/**
+ * raptor_option_value_type:
+ * @RAPTOR_OPTION_VALUE_TYPE_BOOL: Boolean integer value. Non-0 is true
+ * @RAPTOR_OPTION_VALUE_TYPE_INT: Decimal integer value
+ * @RAPTOR_OPTION_VALUE_TYPE_STRING: String value
+ * @RAPTOR_OPTION_VALUE_TYPE_URI: URI String value.
+ * @RAPTOR_OPTION_VALUE_TYPE_LAST: internal
+ *
+ * Option value types.
+ */
+typedef enum {
+ RAPTOR_OPTION_VALUE_TYPE_BOOL,
+ RAPTOR_OPTION_VALUE_TYPE_INT,
+ RAPTOR_OPTION_VALUE_TYPE_STRING,
+ RAPTOR_OPTION_VALUE_TYPE_URI,
+ RAPTOR_OPTION_VALUE_TYPE_LAST = RAPTOR_OPTION_VALUE_TYPE_URI
+} raptor_option_value_type;
+
+
+/**
+ * raptor_option_description:
+ * @domain: domain ID
+ * @option: option ID
+ * @value_type: data type of option value
+ * @name: short name for option
+ * @name_len: length of @name
+ * @label: description of option
+ * @uri: URI identifying option
+ *
+ * Description of an option for a domain.
+ */
+typedef struct {
+ raptor_domain domain;
+ raptor_option option;
+ raptor_option_value_type value_type;
+ const char* name;
+ size_t name_len;
+ const char* label;
+ raptor_uri* uri;
+} raptor_option_description;
+
+
+RAPTOR_API
+unsigned int raptor_option_get_count(void);
+RAPTOR_API
+const char* raptor_option_get_value_type_label(const raptor_option_value_type type);
+RAPTOR_API
+void raptor_free_option_description(raptor_option_description* option_description);
+RAPTOR_API
+raptor_option_description* raptor_world_get_option_description(raptor_world* world, const raptor_domain domain, const raptor_option option);
+
+
+/* SAX2 element Class (raptor_xml_element) */
+RAPTOR_API
+raptor_xml_element* raptor_new_xml_element(raptor_qname* name, const unsigned char* xml_language, raptor_uri* xml_base);
+RAPTOR_API
+raptor_xml_element* raptor_new_xml_element_from_namespace_local_name(raptor_namespace *ns, const unsigned char *name, const unsigned char *xml_language, raptor_uri *xml_base);
+RAPTOR_API
+void raptor_free_xml_element(raptor_xml_element *element);
+
+/* methods */
+RAPTOR_API
+raptor_qname* raptor_xml_element_get_name(raptor_xml_element *xml_element);
+RAPTOR_API
+void raptor_xml_element_set_attributes(raptor_xml_element* xml_element, raptor_qname **attributes, int count);
+RAPTOR_API
+raptor_qname** raptor_xml_element_get_attributes(raptor_xml_element* xml_element);
+RAPTOR_API
+int raptor_xml_element_get_attributes_count(raptor_xml_element* xml_element);
+RAPTOR_API
+int raptor_xml_element_declare_namespace(raptor_xml_element* xml_element, raptor_namespace *nspace);
+RAPTOR_API
+int raptor_xml_element_write(raptor_xml_element *element, raptor_namespace_stack *nstack, int is_empty, int is_end, int depth, raptor_iostream *iostr);
+RAPTOR_API
+int raptor_xml_element_is_empty(raptor_xml_element* xml_element);
+RAPTOR_API
+const unsigned char* raptor_xml_element_get_language(raptor_xml_element* xml_element);
+
+
+/* XML Writer Class (raptor_xml_writer) */
+RAPTOR_API
+raptor_xml_writer* raptor_new_xml_writer(raptor_world* world, raptor_namespace_stack *nstack, raptor_iostream* iostr);
+RAPTOR_API
+void raptor_free_xml_writer(raptor_xml_writer* xml_writer);
+
+/* methods */
+RAPTOR_API
+void raptor_xml_writer_empty_element(raptor_xml_writer* xml_writer, raptor_xml_element *element);
+RAPTOR_API
+void raptor_xml_writer_start_element(raptor_xml_writer* xml_writer, raptor_xml_element *element);
+RAPTOR_API
+void raptor_xml_writer_end_element(raptor_xml_writer* xml_writer, raptor_xml_element *element);
+RAPTOR_API
+void raptor_xml_writer_newline(raptor_xml_writer* xml_writer);
+RAPTOR_API
+void raptor_xml_writer_cdata(raptor_xml_writer* xml_writer, const unsigned char *s);
+RAPTOR_API
+void raptor_xml_writer_cdata_counted(raptor_xml_writer* xml_writer, const unsigned char *s, unsigned int len);
+RAPTOR_API
+void raptor_xml_writer_raw(raptor_xml_writer* xml_writer, const unsigned char *s);
+RAPTOR_API
+void raptor_xml_writer_raw_counted(raptor_xml_writer* xml_writer, const unsigned char *s, unsigned int len);
+RAPTOR_API
+void raptor_xml_writer_comment(raptor_xml_writer* xml_writer, const unsigned char *s);
+RAPTOR_API
+void raptor_xml_writer_comment_counted(raptor_xml_writer* xml_writer, const unsigned char *s, unsigned int len);
+RAPTOR_API
+void raptor_xml_writer_flush(raptor_xml_writer* xml_writer);
+RAPTOR_API
+int raptor_xml_writer_set_option(raptor_xml_writer *xml_writer, raptor_option option, char* string, int integer);
+RAPTOR_API
+int raptor_xml_writer_get_option(raptor_xml_writer *xml_writer, raptor_option option, char** string_p, int* integer_p);
+RAPTOR_API
+int raptor_xml_writer_get_depth(raptor_xml_writer *xml_writer);
+
+/**
+ * raptor_sax2_start_element_handler:
+ * @user_data: user data
+ * @xml_element: XML element
+ *
+ * SAX2 start element handler
+ */
+typedef void (*raptor_sax2_start_element_handler)(void *user_data, raptor_xml_element *xml_element);
+
+/**
+ * raptor_sax2_end_element_handler:
+ * @user_data: user data
+ * @xml_element: XML element
+ *
+ * SAX2 end element handler
+ */
+typedef void (*raptor_sax2_end_element_handler)(void *user_data, raptor_xml_element* xml_element);
+
+/**
+ * raptor_sax2_characters_handler:
+ * @user_data: user data
+ * @xml_element: XML element
+ * @s: string
+ * @len: string len
+ *
+ * SAX2 characters handler
+ */
+typedef void (*raptor_sax2_characters_handler)(void *user_data, raptor_xml_element* xml_element, const unsigned char *s, int len);
+
+/**
+ * raptor_sax2_cdata_handler:
+ * @user_data: user data
+ * @xml_element: XML element
+ * @s: string
+ * @len: string len
+
+ * SAX2 CDATA section handler
+ */
+typedef void (*raptor_sax2_cdata_handler)(void *user_data, raptor_xml_element* xml_element, const unsigned char *s, int len);
+
+/**
+ * raptor_sax2_comment_handler:
+ * @user_data: user data
+ * @xml_element: XML element
+ * @s: string
+ *
+ * SAX2 XML comment handler
+ */
+typedef void (*raptor_sax2_comment_handler)(void *user_data, raptor_xml_element* xml_element, const unsigned char *s);
+
+/**
+ * raptor_sax2_unparsed_entity_decl_handler:
+ * @user_data: user data
+ * @entityName: entity name
+ * @base: base URI
+ * @systemId: system ID
+ * @publicId: public ID
+ * @notationName: notation name
+ *
+ * SAX2 unparsed entity (NDATA) handler
+ */
+typedef void (*raptor_sax2_unparsed_entity_decl_handler)(void *user_data, const unsigned char* entityName, const unsigned char* base, const unsigned char* systemId, const unsigned char* publicId, const unsigned char* notationName);
+
+/**
+ * raptor_sax2_external_entity_ref_handler:
+ * @user_data: user data
+ * @context: context
+ * @base: base URI
+ * @systemId: system ID
+ * @publicId: public ID
+ *
+ * SAX2 external entity reference handler
+ *
+ * Return value: 0 if processing should not continue because of a
+ * fatal error in the handling of the external entity.
+ */
+typedef int (*raptor_sax2_external_entity_ref_handler)(void *user_data, const unsigned char* context, const unsigned char* base, const unsigned char* systemId, const unsigned char* publicId);
+
+
+/* SAX2 API */
+RAPTOR_API
+raptor_sax2* raptor_new_sax2(raptor_world *world, raptor_locator *locator, void* user_data);
+RAPTOR_API
+void raptor_free_sax2(raptor_sax2 *sax2);
+
+/* methods */
+RAPTOR_API
+void raptor_sax2_set_start_element_handler(raptor_sax2* sax2, raptor_sax2_start_element_handler handler);
+RAPTOR_API
+void raptor_sax2_set_end_element_handler(raptor_sax2* sax2, raptor_sax2_end_element_handler handler);
+RAPTOR_API
+void raptor_sax2_set_characters_handler(raptor_sax2* sax2, raptor_sax2_characters_handler handler);
+RAPTOR_API
+void raptor_sax2_set_cdata_handler(raptor_sax2* sax2, raptor_sax2_cdata_handler handler);
+RAPTOR_API
+void raptor_sax2_set_comment_handler(raptor_sax2* sax2, raptor_sax2_comment_handler handler);
+RAPTOR_API
+void raptor_sax2_set_unparsed_entity_decl_handler(raptor_sax2* sax2, raptor_sax2_unparsed_entity_decl_handler handler);
+RAPTOR_API
+void raptor_sax2_set_external_entity_ref_handler(raptor_sax2* sax2, raptor_sax2_external_entity_ref_handler handler);
+RAPTOR_API
+void raptor_sax2_set_namespace_handler(raptor_sax2* sax2, raptor_namespace_handler handler);
+RAPTOR_API
+void raptor_sax2_set_uri_filter(raptor_sax2* sax2, raptor_uri_filter_func filter, void *user_data);
+RAPTOR_API
+void raptor_sax2_parse_start(raptor_sax2 *sax2, raptor_uri *base_uri);
+RAPTOR_API
+int raptor_sax2_parse_chunk(raptor_sax2* sax2, const unsigned char *buffer, size_t len, int is_end);
+RAPTOR_API
+const unsigned char* raptor_sax2_inscope_xml_language(raptor_sax2* sax2);
+RAPTOR_API
+raptor_uri* raptor_sax2_inscope_base_uri(raptor_sax2* sax2);
+
+
+
+/* AVL Trees */
+
+/**
+ * raptor_avltree:
+ *
+ * AVL Tree
+ */
+typedef struct raptor_avltree_s raptor_avltree;
+
+/**
+ * raptor_avltree_iterator:
+ *
+ * AVL Tree Iterator as created by raptor_new_avltree_iterator()
+ */
+typedef struct raptor_avltree_iterator_s raptor_avltree_iterator;
+
+/**
+ * raptor_avltree_visit_handler:
+ * @depth: depth of object in tree
+ * @data: data object being visited
+ * @user_data: user data arg to raptor_avltree_visit()
+ *
+ * AVL Tree visitor function as given to raptor_avltree_visit()
+ *
+ * Return value: non-0 to terminate visit early.
+ */
+typedef int (*raptor_avltree_visit_handler)(int depth, void* data, void *user_data);
+
+
+/**
+ * raptor_avltree_bitflags:
+ * @RAPTOR_AVLTREE_FLAG_REPLACE_DUPLICATES: If set raptor_avltree_add() will replace any duplicate items. If not set, raptor_avltree_add() will not replace them and will return status >0 when adding a duplicate. (Default is not set)
+ *
+ * Bit flags for AVL Tree class constructor raptor_new_avltree()
+ **/
+typedef enum {
+ RAPTOR_AVLTREE_FLAG_REPLACE_DUPLICATES = 1
+} raptor_avltree_bitflags;
+
+
+RAPTOR_API
+raptor_avltree* raptor_new_avltree(raptor_data_compare_handler compare_handler, raptor_data_free_handler free_handler, unsigned int flags);
+RAPTOR_API
+void raptor_free_avltree(raptor_avltree* tree);
+
+/* methods */
+RAPTOR_API
+int raptor_avltree_add(raptor_avltree* tree, void* p_data);
+RAPTOR_API
+void* raptor_avltree_remove(raptor_avltree* tree, void* p_data);
+RAPTOR_API
+int raptor_avltree_delete(raptor_avltree* tree, void* p_data);
+RAPTOR_API
+void* raptor_avltree_search(raptor_avltree* tree, const void* p_data);
+RAPTOR_API
+int raptor_avltree_visit(raptor_avltree* tree, raptor_avltree_visit_handler visit_handler, void* user_data);
+RAPTOR_API
+int raptor_avltree_size(raptor_avltree* tree);
+RAPTOR_API
+void raptor_avltree_set_print_handler(raptor_avltree* tree, raptor_data_print_handler print_handler);
+RAPTOR_API
+int raptor_avltree_print(raptor_avltree* tree, FILE* stream);
+
+RAPTOR_API
+raptor_avltree_iterator* raptor_new_avltree_iterator(raptor_avltree* tree, void* range, raptor_data_free_handler range_free_handler, int direction);
+RAPTOR_API
+void raptor_free_avltree_iterator(raptor_avltree_iterator* iterator);
+
+RAPTOR_API
+int raptor_avltree_iterator_is_end(raptor_avltree_iterator* iterator);
+RAPTOR_API
+int raptor_avltree_iterator_next(raptor_avltree_iterator* iterator);
+RAPTOR_API
+void* raptor_avltree_iterator_get(raptor_avltree_iterator* iterator);
+
+/* utility methods */
+RAPTOR_API
+void raptor_sort_r(void *base, size_t nel, size_t width, raptor_data_compare_arg_handler compar, void *user_data);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/external/redland/raptor/raptor_config.h b/external/redland/raptor/raptor_config.h
new file mode 100644
index 000000000..74f58de95
--- /dev/null
+++ b/external/redland/raptor/raptor_config.h
@@ -0,0 +1,402 @@
+/* src/raptor_config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define if building universal (internal helper macro) */
+#undef AC_APPLE_UNIVERSAL_BUILD
+
+/* have to check C99 vsnprintf at runtime because cross compiling */
+#undef CHECK_VSNPRINTF_RUNTIME
+
+/* vsnprintf has C99 compatible return value */
+#undef HAVE_C99_VSNPRINTF
+
+/* Have curl/curl.h */
+#undef HAVE_CURL_CURL_H
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the <errno.h> header file. */
+#define HAVE_ERRNO_H 1
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
+/* Define to 1 if you have the <fetch.h> header file. */
+#undef HAVE_FETCH_H
+
+/* Define to 1 if you have the `getopt' function. */
+#undef HAVE_GETOPT
+
+/* Define to 1 if you have the <getopt.h> header file. */
+#undef HAVE_GETOPT_H
+
+/* Define to 1 if you have the `getopt_long' function. */
+#undef HAVE_GETOPT_LONG
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#undef HAVE_GETTIMEOFDAY
+
+/* INN parsedate function present */
+#undef HAVE_INN_PARSEDATE
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the `isascii' function. */
+#undef HAVE_ISASCII
+
+/* Define to 1 if you have the <libxml/hash.h> header file. */
+#define HAVE_LIBXML_HASH_H 1
+
+/* Define to 1 if you have the <libxml/HTMLparser.h> header file. */
+#define HAVE_LIBXML_HTMLPARSER_H 1
+
+/* Define to 1 if you have the <libxml/nanohttp.h> header file. */
+#define HAVE_LIBXML_NANOHTTP_H 1
+
+/* Define to 1 if you have the <libxml/parser.h> header file. */
+#define HAVE_LIBXML_PARSER_H 1
+
+/* Define to 1 if you have the <libxml/SAX2.h> header file. */
+#define HAVE_LIBXML_SAX2_H 1
+
+/* Define to 1 if you have the <libxslt/xslt.h> header file. */
+#define HAVE_LIBXSLT_XSLT_H 1
+
+/* Define to 1 if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define to 1 if you have the <math.h> header file. */
+#define HAVE_MATH_H 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the `qsort_r' function. */
+#undef HAVE_QSORT_R
+
+/* Define to 1 if you have the `qsort_s' function. */
+/* note: MSVC has qsort_s but the sort_r.h code uses advanced features like
+ * "inline" that MSVC 2013 doesn't understand; fortunately there's another
+ * level of fallback... */
+#undef HAVE_QSORT_S
+
+/* Raptor raptor_parse_date available */
+#undef HAVE_RAPTOR_PARSE_DATE
+
+/* Define to 1 if you have the `setjmp' function. */
+#undef HAVE_SETJMP
+
+/* Define to 1 if you have the <setjmp.h> header file. */
+#undef HAVE_SETJMP_H
+
+/* Define to 1 if you have the `stat' function. */
+#undef HAVE_STAT
+
+/* Define to 1 if you have the <stddef.h> header file. */
+#define HAVE_STDDEF_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the `strcasecmp' function. */
+#undef HAVE_STRCASECMP
+
+/* Define to 1 if you have the `stricmp' function. */
+#define HAVE_STRICMP 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strtok_r' function. */
+#undef HAVE_STRTOK_R
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#undef HAVE_SYS_PARAM_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if you have the `vasprintf' function. */
+#undef HAVE_VASPRINTF
+
+/* Define to 1 if you have the `vsnprintf' function. */
+#define HAVE_VSNPRINTF 1
+
+/* Flex version as a decimal */
+#define FLEX_VERSION_DECIMAL 20539
+
+/* Define to 1 if you have the `xmlCtxtUseOptions' function. */
+#define HAVE_XMLCTXTUSEOPTIONS 1
+
+/* Define to 1 if you have the `xmlSAX2InternalSubset' function. */
+#define HAVE_XMLSAX2INTERNALSUBSET 1
+
+/* YAJL has API version 2 */
+#undef HAVE_YAJL2
+
+/* Define to 1 if you have the <yajl/yajl_parse.h> header file. */
+#undef HAVE_YAJL_YAJL_PARSE_H
+
+/* Is __FUNCTION__ available */
+#define HAVE___FUNCTION__ 1
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#undef LT_OBJDIR
+
+/* Define to 1 if maintainer mode is enabled. */
+#undef MAINTAINER_MODE
+
+/* need 'extern int optind' declaration? */
+#undef NEED_OPTIND_DECLARATION
+
+/* Define to 1 if your C compiler doesn't accept -c and -o together. */
+#undef NO_MINUS_C_MINUS_O
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to 1 if debug messages are enabled. */
+#undef RAPTOR_DEBUG
+
+/* Use ICU for Unicode NFC check */
+#undef RAPTOR_ICU_NFC
+
+/* does libxml struct xmlEntity have a field etype */
+#define RAPTOR_LIBXML_ENTITY_ETYPE 1
+
+/* does libxml struct xmlEntity have a field name_length */
+#undef RAPTOR_LIBXML_ENTITY_NAME_LENGTH
+
+/* does libxml have HTML_PARSE_NONET */
+#define RAPTOR_LIBXML_HTML_PARSE_NONET 1
+
+/* does libxml xmlSAXHandler have externalSubset field */
+#define RAPTOR_LIBXML_XMLSAXHANDLER_EXTERNALSUBSET 1
+
+/* does libxml xmlSAXHandler have initialized field */
+#define RAPTOR_LIBXML_XMLSAXHANDLER_INITIALIZED 1
+
+/* does libxml have XML_PARSE_NONET */
+#define RAPTOR_LIBXML_XML_PARSE_NONET 1
+
+/* Minimum supported package version */
+#define RAPTOR_MIN_VERSION_DECIMAL 20000
+
+/* Building GRDDL parser */
+#undef RAPTOR_PARSER_GRDDL
+
+/* Building guess parser */
+#undef RAPTOR_PARSER_GUESS
+
+/* Building JSON parser */
+#undef RAPTOR_PARSER_JSON
+
+/* Building N-Quads parser */
+#undef RAPTOR_PARSER_NQUADS
+
+/* Building N-Triples parser */
+#define RAPTOR_PARSER_NTRIPLES 1
+
+/* Building RDFA parser */
+#undef RAPTOR_PARSER_RDFA
+
+/* Building RDF/XML parser */
+#define RAPTOR_PARSER_RDFXML 1
+
+/* Building RSS Tag Soup parser */
+#undef RAPTOR_PARSER_RSS
+
+/* Building TRiG parser */
+#undef RAPTOR_PARSER_TRIG
+
+/* Building Turtle parser */
+#undef RAPTOR_PARSER_TURTLE
+
+/* Building Atom 1.0 serializer */
+#undef RAPTOR_SERIALIZER_ATOM
+
+/* Building GraphViz DOT serializer */
+#undef RAPTOR_SERIALIZER_DOT
+
+/* Building HTML Table serializer */
+#undef RAPTOR_SERIALIZER_HTML
+
+/* Building JSON serializer */
+#undef RAPTOR_SERIALIZER_JSON
+
+/* Building N-Quads serializer */
+#undef RAPTOR_SERIALIZER_NQUADS
+
+/* Building N-Triples serializer */
+#define RAPTOR_SERIALIZER_NTRIPLES 1
+
+/* Building RDF/XML serializer */
+#define RAPTOR_SERIALIZER_RDFXML 1
+
+/* Building RDF/XML-abbreviated serializer */
+#define RAPTOR_SERIALIZER_RDFXML_ABBREV 1
+
+/* Building RSS 1.0 serializer */
+#undef RAPTOR_SERIALIZER_RSS_1_0
+
+/* Building Turtle serializer */
+#undef RAPTOR_SERIALIZER_TURTLE
+
+/* Release version as a decimal */
+#define RAPTOR_VERSION_DECIMAL 20015
+
+/* Major version number */
+#define RAPTOR_VERSION_MAJOR 2
+
+/* Minor version number */
+#define RAPTOR_VERSION_MINOR 0
+
+/* Release version number */
+#define RAPTOR_VERSION_RELEASE 15
+
+/* Have libcurl WWW library */
+#undef RAPTOR_WWW_LIBCURL
+
+/* Have libfetch WWW library */
+#undef RAPTOR_WWW_LIBFETCH
+
+/* Have libxml available as a WWW library */
+#undef RAPTOR_WWW_LIBXML
+
+/* No WWW library */
+#define RAPTOR_WWW_NONE
+
+/* Check XML 1.1 Names */
+#undef RAPTOR_XML_1_1
+
+/* Use libxml XML parser */
+#define RAPTOR_XML_LIBXML 1
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#undef TIME_WITH_SYS_TIME
+
+/* Version number of package */
+#define VERSION "2.0.15"
+
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
+ significant byte first (like Motorola and SPARC, unlike Intel). */
+#if defined AC_APPLE_UNIVERSAL_BUILD
+# if defined __BIG_ENDIAN__
+# define WORDS_BIGENDIAN 1
+# endif
+#else
+# ifndef WORDS_BIGENDIAN
+# undef WORDS_BIGENDIAN
+# endif
+#endif
+
+/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
+ `char[]'. */
+#undef YYTEXT_POINTER
+
+/* Enable large inode numbers on macOS 10.5. */
+#ifndef _DARWIN_USE_64_BIT_INODE
+# define _DARWIN_USE_64_BIT_INODE 1
+#endif
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#undef _FILE_OFFSET_BITS
+
+/* Define for large files, on AIX-style hosts. */
+#undef _LARGE_FILES
+
+/* Define to empty if `const' does not conform to ANSI C. */
+#undef const
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+ calls it, or to nothing if 'inline' is not supported under any name. */
+#ifndef __cplusplus
+#undef inline
+#endif
+
+// from raptor_config_cmake.h.in ////////////////////////////////////////////
+
+#ifdef _WIN32
+# define WIN32_LEAN_AND_MEAN
+# ifndef _CRT_NONSTDC_NO_DEPRECATE
+# define _CRT_NONSTDC_NO_DEPRECATE
+# endif
+# ifndef _CRT_SECURE_NO_DEPRECATE
+# define _CRT_SECURE_NO_DEPRECATE
+# endif
+
+# ifdef _MSC_VER
+# define __func__ __FUNCTION__
+# endif
+
+# define RAPTOR_INLINE __inline
+
+# define S_ISTYPE(mode, mask) (((mode) & _S_IFMT) == (mask))
+# define S_ISDIR(mode) S_ISTYPE((mode), _S_IFDIR)
+# define S_ISREG(mode) S_ISTYPE((mode), _S_IFREG)
+
+ /* Mode bits for access() */
+# define R_OK 04
+# define W_OK 02
+
+# if !defined(HAVE_ACCESS) && defined(HAVE__ACCESS)
+# define access(p,m) _access(p,m)
+# endif
+# ifndef HAVE_STRCASECMP
+# if defined(HAVE__STRICMP)
+# define strcasecmp(a,b) _stricmp(a,b)
+# elif defined(HAVE_STRICMP)
+# define strcasecmp(a,b) stricmp(a,b)
+# endif
+# endif
+# if !defined(HAVE_SNPRINTF) && defined(HAVE__SNPRINTF)
+# define snprintf _snprintf
+# endif
+# if !defined(HAVE_VSNPRINTF) && defined(HAVE__VSNPRINTF)
+# define vsnprintf _vsnprintf
+# endif
+
+ /* These prevent parsedate.c from declaring malloc() and free() */
+# define YYMALLOC malloc
+# define YYFREE free
+#endif
+
+
diff --git a/external/redland/raptor/rpath.patch b/external/redland/raptor/rpath.patch
new file mode 100644
index 000000000..7863f61cd
--- /dev/null
+++ b/external/redland/raptor/rpath.patch
@@ -0,0 +1,21 @@
+--- configure
++++ configure
+@@ -9892,6 +9892,7 @@
+ else
+ ld_shlibs=no
+ fi
++hardcode_libdir_flag_spec=
+ ;;
+
+ netbsd* | netbsdelf*-gnu)
+--- utils/Makefile.in
++++ utils/Makefile.in
+@@ -343,7 +343,7 @@
+ rapper_LDADD = $(top_builddir)/src/libraptor2.la
+ rdfdiff_SOURCES = rdfdiff.c $(am__append_2)
+ rdfdiff_LDADD = $(top_builddir)/src/libraptor2.la
+-all: all-am
++all:
+
+ .SUFFIXES:
+ .SUFFIXES: .c .lo .o .obj
diff --git a/external/redland/raptor/ubsan.patch b/external/redland/raptor/ubsan.patch
new file mode 100644
index 000000000..641d60bb7
--- /dev/null
+++ b/external/redland/raptor/ubsan.patch
@@ -0,0 +1,25 @@
+--- src/raptor_rfc2396.c
++++ src/raptor_rfc2396.c
+@@ -386,7 +386,7 @@
+ }
+
+
+- if(prev && s == (cur+2) && cur[0] == '.' && cur[1] == '.') {
++ if(prev && cur && s == (cur+2) && cur[0] == '.' && cur[1] == '.') {
+ /* Remove <component>/.. at the end of the path */
+ *prev = '\0';
+ path_len -= (s-prev);
+--- src/raptor_uri.c
++++ src/raptor_uri.c
+@@ -1336,9 +1336,9 @@
+ !strncmp((const char*)base_detail->scheme,
+ (const char*)reference_detail->scheme,
+ base_detail->scheme_len) &&
+- !strncmp((const char*)base_detail->authority,
++ (base_detail->authority_len == 0 || !strncmp((const char*)base_detail->authority,
+ (const char*)reference_detail->authority,
+- base_detail->authority_len)) {
++ base_detail->authority_len))) {
+
+ if(!base_detail->path) {
+ if(reference_detail->path) {
diff --git a/external/redland/raptor/xml2-config.patch b/external/redland/raptor/xml2-config.patch
new file mode 100644
index 000000000..2550acee0
--- /dev/null
+++ b/external/redland/raptor/xml2-config.patch
@@ -0,0 +1,22 @@
+--- configure
++++ configure
+@@ -14197,6 +14197,11 @@
+ test -n "$XML_CONFIG" && break
+ done
+
++ if test -n "$XML_CONFIG"; then
++ if ! "$XML_CONFIG" --version; then
++ XML_CONFIG=
++ fi
++ fi
+ fi
+ fi
+
+@@ -14481,6 +14481,7 @@
+
+ LIBXML_VERSION=`$PKG_CONFIG libxml-2.0 --modversion`
+ libxml_source="pkg-config"
++ XML_CONFIG="$PKG_CONFIG libxml-2.0"
+
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libxml via pkg-config" >&5
diff --git a/external/redland/rasqal/clang-cl.patch b/external/redland/rasqal/clang-cl.patch
new file mode 100644
index 000000000..e35a2b4ee
--- /dev/null
+++ b/external/redland/rasqal/clang-cl.patch
@@ -0,0 +1,11 @@
+--- src/rasqal.h
++++ src/rasqal.h
+@@ -99,7 +99,7 @@
+ /* Use gcc 3.1+ feature to allow marking of deprecated API calls.
+ * This gives a warning during compiling.
+ */
+-#if ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3
++#if (defined __GNUC__ && (( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3)) || defined __clang__
+ #define RASQAL_DEPRECATED __attribute__((deprecated))
+ #else
+ #define RASQAL_DEPRECATED
diff --git a/external/redland/rasqal/libtool.patch b/external/redland/rasqal/libtool.patch
new file mode 100644
index 000000000..b0baae661
--- /dev/null
+++ b/external/redland/rasqal/libtool.patch
@@ -0,0 +1,27 @@
+--- build/ltmain.sh
++++ build/ltmain.sh
+@@ -5301,6 +5301,12 @@
+ prev=
+ continue
+ ;;
++ mllvm)
++ # Clang does not use LLVM to link, so we can simply discard any
++ # '-mllvm $arg' options when doing the link step.
++ prev=
++ continue
++ ;;
+ objectlist)
+ if test -f "$arg"; then
+ save_arg=$arg
+@@ -5639,6 +5645,11 @@
+ continue
+ ;;
+
++ -mllvm)
++ prev=mllvm
++ continue
++ ;;
++
+ -module)
+ module=yes
+ continue
diff --git a/external/redland/rasqal/rasqal-aix.patch.1 b/external/redland/rasqal/rasqal-aix.patch.1
new file mode 100644
index 000000000..d755aa2e5
--- /dev/null
+++ b/external/redland/rasqal/rasqal-aix.patch.1
@@ -0,0 +1,25 @@
+--- a/src/rasqal_literal.c 2013-03-29 21:22:57.413852072 +0100
++++ b/src/rasqal_literal.c 2013-03-29 21:23:34.092851757 +0100
+@@ -46,10 +46,22 @@
+ #include <stddef.h>
+ #endif
+ #include <stdarg.h>
++#ifdef _AIX
++# ifndef isnan
++# define isnan(x) \
++ (sizeof (x) == sizeof (long double) ? isnan_ld (x) \
++ : sizeof (x) == sizeof (double) ? isnan_d (x) \
++ : isnan_f (x))
++ static inline int isnan_f (float x) { return x != x; }
++ static inline int isnan_d (double x) { return x != x; }
++ static inline int isnan_ld (long double x) { return x != x; }
++# endif
++#else
+ /* for isnan() */
+ #ifdef HAVE_MATH_H
+ #include <math.h>
+ #endif
++#endif
+ /* for INT_MIN and INT_MAX */
+ #ifdef HAVE_LIMITS_H
+ #include <limits.h>
diff --git a/external/redland/rasqal/rasqal-android.patch.1 b/external/redland/rasqal/rasqal-android.patch.1
new file mode 100644
index 000000000..b14aa5758
--- /dev/null
+++ b/external/redland/rasqal/rasqal-android.patch.1
@@ -0,0 +1,14 @@
+No sonames on Android
+
+--- a/configure 2013-03-29 19:46:34.922901756 +0100
++++ b/configure 2013-03-29 19:46:56.051901574 +0100
+@@ -9809,7 +9809,7 @@
+ *Sun\ F*) # Sun Fortran 8.3
+ tmp_sharedflag='-G' ;;
+ esac
+- archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags -o $lib'
+
+ if test "x$supports_anon_versioning" = xyes; then
+ archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
+
diff --git a/external/redland/rasqal/rasqal-bundled-soname.patch.1 b/external/redland/rasqal/rasqal-bundled-soname.patch.1
new file mode 100644
index 000000000..2c674516d
--- /dev/null
+++ b/external/redland/rasqal/rasqal-bundled-soname.patch.1
@@ -0,0 +1,13 @@
+rhbz#809466 change soname of bundled redland libs
+
+--- a/src/Makefile.in 2013-03-29 21:44:58.115840724 +0100
++++ b/src/Makefile.in 2013-03-29 21:45:01.252840697 +0100
+@@ -621,7 +621,7 @@
+ $(am__append_2) $(am__append_3) $(am__append_4) \
+ $(am__append_5) $(am__append_6) $(am__append_7)
+ nodist_librasqal_la_SOURCES = $(am__append_8)
+-librasqal_la_LDFLAGS = -version-info @RASQAL_LIBTOOL_VERSION@
++librasqal_la_LDFLAGS = -version-info @RASQAL_LIBTOOL_VERSION@ -release lo
+ librasqal_la_LIBADD = @LTLIBOBJS@ @RASQAL_INTERNAL_LIBS@ \
+ @RASQAL_EXTERNAL_LIBS@ $(MEM_LIBS) \
+ $(top_builddir)/libsv/libsv.la $(am__append_10)
diff --git a/external/redland/rasqal/rasqal-freebsd.patch.1 b/external/redland/rasqal/rasqal-freebsd.patch.1
new file mode 100644
index 000000000..349f3a197
--- /dev/null
+++ b/external/redland/rasqal/rasqal-freebsd.patch.1
@@ -0,0 +1,28 @@
+Usual patch to produce Linux-like .so files on FreeBSD
+
+--- a/build/ltmain.sh 2008-02-02 22:28:24.000000000 +0900
++++ b/build/ltmain.sh 2008-07-08 11:58:42.000000000 +0900
+@@ -7341,9 +7341,9 @@
+ revision="$number_revision"
+ ;;
+ freebsd-aout|freebsd-elf|qnx|sunos)
+- current="$number_major"
+- revision="$number_minor"
+- age="0"
++ current=`expr $number_major + $number_minor`
++ age="$number_minor"
++ revision="$number_revision"
+ ;;
+ irix|nonstopux)
+ func_arith $number_major + $number_minor
+@@ -7420,8 +7420,8 @@
+ ;;
+
+ freebsd-elf)
+- major=".$current"
+- versuffix=".$current"
++ major=.`expr $current - $age`
++ versuffix="$major.$age.$revision"
+ ;;
+
+ irix | nonstopux)
diff --git a/external/redland/rasqal/rasqal-msvc.patch.1 b/external/redland/rasqal/rasqal-msvc.patch.1
new file mode 100644
index 000000000..f32f6720b
--- /dev/null
+++ b/external/redland/rasqal/rasqal-msvc.patch.1
@@ -0,0 +1,64 @@
+diff -ru rasqal.orig/src/win32_rasqal_config.h rasqal/src/win32_rasqal_config.h
+--- rasqal.orig/src/win32_rasqal_config.h 2015-09-02 23:12:00.733125322 +0200
++++ rasqal/src/win32_rasqal_config.h 2015-09-02 23:28:10.152190403 +0200
+@@ -31,7 +31,6 @@
+ /* MS names for these functions */
+ // next line breaks build on wntmsci12
+ //#define vsnprintf _vsnprintf
+-#define snprintf _snprintf
+ #define access _access
+ #define stricmp _stricmp
+ #define strnicmp _strnicmp
+@@ -42,10 +43,10 @@
+ int rasqal_gettimeofday(struct timeval *tv, struct timezone *tz);
+ #undef HAVE_GETTIMEOFDAY
+
+-#include <float.h>
+-#define isnan(n) _isnan(n)
+-/* no round function available */
+-#define round(x) floor(x+0.5)
++// #include <float.h>
++// #define isnan(n) _isnan(n)
++// /* no round function available */
++// #define round(x) floor(x+0.5)
+
+ /* These are SPARQL token definitions */
+ #ifdef OPTIONAL
+--- rasqal/src/rasqal_ntriples.c.orig 2016-08-26 23:29:58.343472683 +0200
++++ rasqal/src/rasqal_ntriples.c 2016-08-26 23:30:10.553471736 +0200
+@@ -25,6 +25,10 @@
+ #include <rasqal_config.h>
+ #endif
+
++#ifdef _WIN32
++#include <win32_rasqal_config.h>
++#endif
++
+ #include <stdio.h>
+ #include <string.h>
+ #include <ctype.h>
+--- rasqal/src/sv_config.h.orig 2016-08-26 23:29:42.408473919 +0200
++++ rasqal/src/sv_config.h 2016-08-26 23:29:44.760473737 +0200
+@@ -29,7 +29,11 @@
+ extern "C" {
+ #endif
+
++#ifdef _WIN32
++#include <win32_rasqal_config.h>
++#else
+ #include <rasqal_config.h>
++#endif
+
+ #define sv_new rasqal_sv_new
+ #define sv_free rasqal_sv_free
+--- rasqal/src/rasqal.h.in.orig 2016-08-26 23:42:23.198414915 +0200
++++ rasqal/src/rasqal.h.in 2016-08-26 23:42:34.627414028 +0200
+@@ -1473,7 +1473,7 @@
+
+ RASQAL_API
+ int rasqal_query_results_formats_check2(rasqal_world* world, const char *name, raptor_uri* uri, const char *mime_type, int flags);
+-RASQAL_API RASQAL_API RASQAL_DEPRECATED
++RASQAL_API RASQAL_DEPRECATED
+ int rasqal_query_results_formats_check(rasqal_world* world, const char *name, raptor_uri* uri, const char *mime_type, int flags);
+ RASQAL_API
+ rasqal_query_results_formatter* rasqal_new_query_results_formatter(rasqal_world* world, const char *name, const char *mime_type, raptor_uri* format_uri);
diff --git a/external/redland/rasqal/rasqal-pkgconfig.patch.1 b/external/redland/rasqal/rasqal-pkgconfig.patch.1
new file mode 100644
index 000000000..ac3eab07c
--- /dev/null
+++ b/external/redland/rasqal/rasqal-pkgconfig.patch.1
@@ -0,0 +1,14 @@
+Let the pkg-config stuff be overridden by variables
+
+--- a/configure
++++ b/configure
+@@ -14119,7 +14119,7 @@
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+ $as_echo "yes" >&6; }
+
+- RAPTOR_VERSION=`$PKG_CONFIG raptor2 --modversion 2>/dev/null`
++ RAPTOR_VERSION=2.0.15
+ raptor_too_old=0
+ as_arg_v1=$RAPTOR_VERSION
+ as_arg_v2=$RAPTOR_MIN_VERSION
+
diff --git a/external/redland/rasqal/rasqal-xcompile.patch.1 b/external/redland/rasqal/rasqal-xcompile.patch.1
new file mode 100644
index 000000000..65efc3047
--- /dev/null
+++ b/external/redland/rasqal/rasqal-xcompile.patch.1
@@ -0,0 +1,16 @@
+No point in creating util or test executables when cross-compiling.
+(Especially as doing it anyway wouldn't work without tweaks to have it find
+libxml2 and libm, at least for Android.)
+
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -358,7 +358,7 @@
+ top_srcdir = @top_srcdir@
+ noinst_SCRIPTS = rasqal-src-config
+ ACLOCAL_AMFLAGS = -I build
+-SUBDIRS = libsv $(am__append_1) $(am__append_2) src utils tests docs \
++SUBDIRS = libsv $(am__append_1) $(am__append_2) src docs \
+ data win32 scripts
+ DIST_SUBDIRS = libsv libmtwist getopt src utils tests docs data win32 scripts
+ pkgconfigdir = $(libdir)/pkgconfig
+ pkgconfig_DATA = rasqal.pc
diff --git a/external/redland/rasqal/rasqal.h b/external/redland/rasqal/rasqal.h
new file mode 100644
index 000000000..cd5d64604
--- /dev/null
+++ b/external/redland/rasqal/rasqal.h
@@ -0,0 +1,2259 @@
+/* -*- Mode: c; c-basic-offset: 2 -*-
+ *
+ * rasqal.h - Rasqal RDF Query library interfaces and definition
+ *
+ * Copyright (C) 2003-2010, David Beckett http://www.dajobe.org/
+ * Copyright (C) 2003-2005, University of Bristol, UK http://www.bristol.ac.uk/
+ *
+ * This package is Free Software and part of Redland http://librdf.org/
+ *
+ * It is licensed under the following three licenses as alternatives:
+ * 1. GNU Lesser General Public License (LGPL) V2.1 or any newer version
+ * 2. GNU General Public License (GPL) V2 or any newer version
+ * 3. Apache License, V2.0 or any newer version
+ *
+ * You may not use this file except in compliance with at least one of
+ * the above three licenses.
+ *
+ * See LICENSE.html or LICENSE.txt at the top of this package for the
+ * complete terms and further detail along with the license texts for
+ * the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively.
+ *
+ */
+
+
+
+#ifndef RASQAL_H
+#define RASQAL_H
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * RASQAL_VERSION:
+ *
+ * Rasqal library version number
+ *
+ * Format: major * 10000 + minor * 100 + release
+ */
+#define RASQAL_VERSION 933
+
+/**
+ * RASQAL_VERSION_STRING:
+ *
+ * Rasqal library version string
+ */
+#define RASQAL_VERSION_STRING "0.9.33"
+
+/**
+ * RASQAL_VERSION_MAJOR:
+ *
+ * Rasqal library major version
+ */
+#define RASQAL_VERSION_MAJOR 0
+
+/**
+ * RASQAL_VERSION_MINOR:
+ *
+ * Rasqal library minor version
+ */
+#define RASQAL_VERSION_MINOR 9
+
+/**
+ * RASQAL_VERSION_RELEASE:
+ *
+ * Rasqal library release
+ */
+#define RASQAL_VERSION_RELEASE 33
+
+
+/**
+ * RASQAL_API:
+ *
+ * Macro for wrapping API function call declarations.
+ *
+ */
+#ifndef RASQAL_API
+# ifdef _WIN32
+# ifdef __GNUC__
+# undef _declspec
+# define _declspec(x) __declspec(x)
+# endif
+# ifdef RASQAL_STATIC
+# define RASQAL_API
+# else
+# ifdef RASQAL_INTERNAL
+# define RASQAL_API _declspec(dllexport)
+# else
+# define RASQAL_API _declspec(dllimport)
+# endif
+# endif
+# else
+# define RASQAL_API
+# endif
+#endif
+
+/* Use gcc 3.1+ feature to allow marking of deprecated API calls.
+ * This gives a warning during compiling.
+ */
+#if ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3
+#define RASQAL_DEPRECATED __attribute__((deprecated))
+#else
+#define RASQAL_DEPRECATED
+#endif
+
+
+#ifndef LIBRDF_OBJC_FRAMEWORK
+#include <raptor.h>
+#else
+#include <Redland/raptor.h>
+#endif
+
+#if 0
+#include <sys/time.h>
+#endif
+#if 1
+#include <time.h>
+#endif
+
+/* Public statics */
+
+/**
+ * rasqal_short_copyright_string:
+ *
+ * Short copyright string (one line).
+ */
+RASQAL_API
+extern const char * const rasqal_short_copyright_string;
+
+/**
+ * rasqal_copyright_string:
+ *
+ * Copyright string (multiple lines).
+ */
+RASQAL_API
+extern const char * const rasqal_copyright_string;
+
+/**
+ * rasqal_version_string:
+ *
+ * Rasqal version as a string.
+ */
+RASQAL_API
+extern const char * const rasqal_version_string;
+
+/**
+ * rasqal_version_major:
+ *
+ * Rasqal major version number.
+ */
+RASQAL_API
+extern const unsigned int rasqal_version_major;
+
+/**
+ * rasqal_version_minor:
+ *
+ * Rasqal minor version number.
+ */
+RASQAL_API
+extern const unsigned int rasqal_version_minor;
+
+/**
+ * rasqal_version_release:
+ *
+ * Rasqal release version number.
+ */
+RASQAL_API
+extern const unsigned int rasqal_version_release;
+
+/**
+ * rasqal_version_decimal:
+ *
+ * Rasqal version as a decimal number.
+ *
+ * Format: major * 10000 + minor * 100 + release
+ */
+RASQAL_API
+extern const unsigned int rasqal_version_decimal;
+
+/**
+ * rasqal_license_string:
+ *
+ * Rasqal license string.
+ */
+RASQAL_API
+extern const char * const rasqal_license_string;
+
+/**
+ * rasqal_home_url_string:
+ *
+ * Rasqal home page URL.
+ */
+RASQAL_API
+extern const char * const rasqal_home_url_string;
+
+
+
+/**
+ * RASQAL_RAPTOR_VERSION:
+ *
+ * Version of Raptor that Rasqal was configured against.
+ */
+#define RASQAL_RAPTOR_VERSION 20015
+
+
+/* Public structures */
+
+#ifndef RASQAL_WORLD_DECLARED
+#define RASQAL_WORLD_DECLARED 1
+/**
+ * rasqal_world:
+ *
+ * Rasqal world class.
+ */
+typedef struct rasqal_world_s rasqal_world;
+#endif
+
+/**
+ * rasqal_query:
+ *
+ * Rasqal query class.
+ */
+typedef struct rasqal_query_s rasqal_query;
+
+/**
+ * rasqal_query_results:
+ *
+ * Rasqal query results class.
+ */
+typedef struct rasqal_query_results_s rasqal_query_results;
+
+
+#ifndef RASQAL_QUERY_RESULTS_FORMATTER_DECLARED
+#define RASQAL_QUERY_RESULTS_FORMATTER_DECLARED 1
+/**
+ * rasqal_query_results_formatter:
+ *
+ * Rasqal query results formatter class.
+ */
+typedef struct rasqal_query_results_formatter_s rasqal_query_results_formatter;
+#endif
+
+
+typedef struct rasqal_literal_s rasqal_literal;
+
+/**
+ * rasqal_graph_pattern:
+ *
+ * Rasqal graph pattern class.
+ */
+typedef struct rasqal_graph_pattern_s rasqal_graph_pattern;
+
+
+/**
+ * rasqal_variables_table:
+ *
+ * Rasqal variables table class.
+ */
+typedef struct rasqal_variables_table_s rasqal_variables_table;
+
+
+/**
+ * rasqal_feature:
+ * @RASQAL_FEATURE_NO_NET: Deny network requests.
+ * @RASQAL_FEATURE_RAND_SEED: Set rand() / rand_r() seed
+ * @RASQAL_FEATURE_LAST: Internal.
+ *
+ * Query features.
+ *
+ * None currently defined.
+ */
+typedef enum {
+ RASQAL_FEATURE_NO_NET,
+ RASQAL_FEATURE_RAND_SEED,
+ RASQAL_FEATURE_LAST = RASQAL_FEATURE_RAND_SEED
+} rasqal_feature;
+
+
+/**
+ * rasqal_prefix:
+ * @world: rasqal_world object
+ * @prefix: short prefix string
+ * @uri: URI associated with the prefix.
+ * @declared: Internal flag.
+ * @depth: Internal flag.
+ *
+ * Namespace (prefix, uri) pair.
+ *
+ * Includes internal flags used for marking when prefixes are
+ * declared and at what XML element depth when used in XML formats.
+ */
+typedef struct {
+ rasqal_world* world;
+ const unsigned char *prefix;
+ raptor_uri* uri;
+ int declared;
+ int depth;
+} rasqal_prefix;
+
+
+/**
+ * rasqal_variable_type:
+ * @RASQAL_VARIABLE_TYPE_NORMAL: The regular variable type.
+ * @RASQAL_VARIABLE_TYPE_ANONYMOUS: Anonymous variable type.
+ * @RASQAL_VARIABLE_TYPE_UNKNOWN: Internal.
+ *
+ * Rasqal variable types.
+ *
+ * ANONYMOUS can be used in queries but cannot be returned in a
+ * result.
+ */
+typedef enum {
+ RASQAL_VARIABLE_TYPE_UNKNOWN = 0,
+ RASQAL_VARIABLE_TYPE_NORMAL = 1,
+ RASQAL_VARIABLE_TYPE_ANONYMOUS = 2
+} rasqal_variable_type;
+
+
+/* forward reference */
+struct rasqal_expression_s;
+
+/**
+ * rasqal_variable:
+ * @vars_table: variables table that owns this variable
+ * @name: Variable name.
+ * @value: Variable value or NULL if unbound.
+ * @offset: Internal.
+ * @type: Variable type.
+ * @expression: Expression when the variable is a computed SELECT expression
+ * @user_data: Pointer to user data associated with a variable. This is not used by rasqal.
+ * @usage: reference count
+ *
+ * Binding between a variable name and a value.
+ *
+ * Includes internal field @offset for recording the offset into the
+ * (internal) rasqal_query variables array.
+ */
+typedef struct {
+ rasqal_variables_table* vars_table;
+ const unsigned char *name;
+ rasqal_literal* value;
+ int offset;
+ rasqal_variable_type type;
+ struct rasqal_expression_s* expression;
+ void *user_data;
+ int usage;
+} rasqal_variable;
+
+
+/**
+ * rasqal_data_graph_flags:
+ * @RASQAL_DATA_GRAPH_NONE: Internal.
+ * @RASQAL_DATA_GRAPH_NAMED: Graphs with a source and name.
+ * @RASQAL_DATA_GRAPH_BACKGROUND: Graphs with a source only.
+ *
+ * Flags for the type of #rasqal_data_graph.
+ *
+ * These are used by rasqal_new_data_graph_from_uri() and
+ * rasqal_new_data_graph_from_iostream(). See #rasqal_data_graph.
+ */
+typedef enum {
+ RASQAL_DATA_GRAPH_NONE = 0,
+ RASQAL_DATA_GRAPH_NAMED = 1,
+ RASQAL_DATA_GRAPH_BACKGROUND = 2
+} rasqal_data_graph_flags;
+
+
+/**
+ * rasqal_data_graph:
+ * @world: rasqal_world object
+ * @uri: source URI
+ * @name_uri: name of graph for %RASQAL_DATA_GRAPH_NAMED
+ * @flags: %RASQAL_DATA_GRAPH_NAMED or %RASQAL_DATA_GRAPH_BACKGROUND
+ * @format_type: MIME Type of data format at @uri (or NULL)
+ * @format_name: Raptor parser Name of data format at @uri (or NULL)
+ * @format_uri: URI of data format at @uri (or NULL)
+ * @iostr: Raptor iostream for content, overriding @uri if present (or NULL)
+ * @base_uri: base URI for reading from iostream
+ * @usage: usage count of this object
+ *
+ * A source of RDF data for querying.
+ *
+ * If @iostr is present, the graph can be constructed by parsing the
+ * iostream and using @base_uri as a base uri. Otherwise the graph
+ * can be constructed from the graph at URI @uri.
+ *
+ * In either case the @name_uri is the graph name as long as @flags
+ * is %RASQAL_DATA_GRAPH_NAMED
+ */
+typedef struct {
+ rasqal_world* world;
+ raptor_uri* uri;
+ raptor_uri* name_uri;
+ unsigned int flags;
+ char* format_type;
+ char* format_name;
+ raptor_uri* format_uri;
+ raptor_iostream* iostr;
+ raptor_uri* base_uri;
+ int usage;
+} rasqal_data_graph;
+
+
+/**
+ * rasqal_literal_type:
+ * @RASQAL_LITERAL_BLANK: RDF blank node literal (SPARQL r:bNode)
+ * @RASQAL_LITERAL_URI: RDF URI Literal (SPARQL r:URI)
+ * @RASQAL_LITERAL_STRING: RDF Plain Literal - no datatype (SPARQL r:Literal)
+ * @RASQAL_LITERAL_XSD_STRING: String xsd:string
+ * @RASQAL_LITERAL_BOOLEAN: Boolean literal xsd:boolean.
+ * @RASQAL_LITERAL_INTEGER: Integer literal xsd:integer.
+ * @RASQAL_LITERAL_DOUBLE: Double floating point literal xsd:double.
+ * @RASQAL_LITERAL_FLOAT: Floating point literal xsd:float.
+ * @RASQAL_LITERAL_DECIMAL: Decimal integer xsd:decimal.
+ * @RASQAL_LITERAL_DATETIME: Date/Time literal xsd:dateTime.
+ * @RASQAL_LITERAL_UDT: User defined typed literal with unknown datatype URI
+ * @RASQAL_LITERAL_PATTERN: Pattern literal for a regex.
+ * @RASQAL_LITERAL_QNAME: XML Qname literal.
+ * @RASQAL_LITERAL_VARIABLE: Variable literal.
+ * @RASQAL_LITERAL_DATE: Date literal xsd:date.
+ * @RASQAL_LITERAL_INTEGER_SUBTYPE: Internal.
+ * @RASQAL_LITERAL_UNKNOWN: Internal.
+ * @RASQAL_LITERAL_FIRST_XSD: Internal.
+ * @RASQAL_LITERAL_LAST_XSD: Internal.
+ * @RASQAL_LITERAL_LAST: Internal.
+ *
+ * Types of literal.
+ *
+ * The order in the enumeration is significant as it encodes
+ * the SPARQL term ordering conditions:
+ *
+ * Blank Nodes << IRIs << RDF literals << typed literals
+ *
+ * which coresponds to in enum values
+ *
+ * BLANK << URI << STRING <<
+ * (BOOLEAN | INTEGER | DOUBLE | FLOAT | DECIMAL | DATETIME | XSD_STRING)
+ *
+ * (RASQAL_LITERAL_FIRST_XSD ... RASQAL_LITERAL_LAST_XSD)
+ *
+ * Not used (internal): PATTERN, QNAME, VARIABLE
+ *
+ * See rasqal_literal_compare() when used with flags
+ * %RASQAL_COMPARE_XQUERY
+ */
+typedef enum {
+ /* internal */
+ RASQAL_LITERAL_UNKNOWN,
+ RASQAL_LITERAL_BLANK,
+ RASQAL_LITERAL_URI,
+ RASQAL_LITERAL_STRING,
+ RASQAL_LITERAL_XSD_STRING,
+ RASQAL_LITERAL_BOOLEAN,
+ RASQAL_LITERAL_INTEGER,
+ RASQAL_LITERAL_FLOAT,
+ RASQAL_LITERAL_DOUBLE,
+ RASQAL_LITERAL_DECIMAL,
+ RASQAL_LITERAL_DATETIME,
+ /* internal */
+ RASQAL_LITERAL_FIRST_XSD = RASQAL_LITERAL_XSD_STRING,
+ /* internal */
+ RASQAL_LITERAL_LAST_XSD = RASQAL_LITERAL_DATETIME,
+ RASQAL_LITERAL_UDT,
+ RASQAL_LITERAL_PATTERN,
+ RASQAL_LITERAL_QNAME,
+ RASQAL_LITERAL_VARIABLE,
+ /* internal */
+ RASQAL_LITERAL_INTEGER_SUBTYPE,
+ RASQAL_LITERAL_DATE,
+ /* internal */
+ RASQAL_LITERAL_LAST = RASQAL_LITERAL_DATE
+} rasqal_literal_type;
+
+#define RASQAL_LITERAL_UDT_DEFINED 1
+
+
+/**
+ * rasqal_row:
+ *
+ * Rasqal Result Row class.
+ */
+typedef struct rasqal_row_s rasqal_row;
+
+
+/**
+ * rasqal_xsd_decimal:
+ *
+ * Rasqal XSD Decimal class.
+ */
+typedef struct rasqal_xsd_decimal_s rasqal_xsd_decimal;
+
+
+/**
+ * RASQAL_XSD_DATETIME_NO_TZ:
+ *
+ * Sentinel XSD Decimal timezone value indicating no timezone is present.
+ */
+#define RASQAL_XSD_DATETIME_NO_TZ (9999)
+
+/**
+ * rasqal_xsd_date:
+ * @year: year
+ * @month: month 1-12
+ * @day: 1-31
+ * @timezone_minutes: minutes +/- against UTC or RASQAL_XSD_DATETIME_NO_TZ if there is no timezone in the dateTime.
+ * @time_on_timeline: time on timeline of first instant of date in timezone
+ * @have_tz: timezone flag: 'Z' if Zulu, 'Y' if has other timezone offset in @timezone_minutes, 'N' if there is no timezone
+ *
+ * XML schema date datatype (xsd:date)
+ *
+ * Examples of timezone fields:
+ * "2010-01-02" : timezone_minutes RASQAL_XSD_DATETIME_NO_TZ, have_tz 'N'
+ * "2010-01-02Z" : timezone_minutes 0, have_tz 'Z'
+ * "2010-01-02+00:00" : timezone_minutes 0, have_tz 'Y'
+ * "2010-01-02-01:00" : timezone_minutes -60, have_tz 'Y'
+ */
+typedef struct {
+ signed int year;
+ /* the following fields are integer values not characters */
+ unsigned char month;
+ unsigned char day;
+ signed short timezone_minutes;
+ time_t time_on_timeline;
+ char have_tz;
+} rasqal_xsd_date;
+
+
+/**
+ * rasqal_xsd_datetime:
+ * @year: year
+ * @month: month 1-12
+ * @day: 1-31
+ * @hour: hour 0-23
+ * @minute: minute 0-59
+ * @second: second 0-60 (yes 60 is allowed for leap seconds)
+ * @microseconds: microseconds
+ * @timezone_minutes: minutes +/- against UTC or RASQAL_XSD_DATETIME_NO_TZ if there is no timezone in the dateTime.
+ * @time_on_timeline: time on timeline
+ * @have_tz: timezone flag: 'Z' if Zulu, 'Y' if has other timezone offset in @timezone_minutes, 'N' if there is no timezone
+ *
+ * XML Schema dateTime datatype (xsd:dateTime)
+ *
+ * Signed types are required for normalization process where a value
+ * can be negative temporarily.
+ *
+ * Examples of timezone fields:
+ * "2010-01-02T01:02:03" : timezone_minutes RASQAL_XSD_DATETIME_NO_TZ, have_tz 'N'
+ * "2010-01-02T01:02:03Z" : timezone_minutes 0, have_tz 'Z'
+ * "2010-01-02T01:02:03+00:00" : timezone_minutes 0, have_tz 'Y'
+ * "2010-01-02T01:02:03-01:00" : timezone_minutes -60, have_tz 'Y'
+ */
+typedef struct {
+ signed int year;
+ unsigned char month;
+ unsigned char day;
+ /* the following fields are integer values not characters */
+ signed char hour;
+ signed char minute;
+ signed char second;
+ signed int microseconds;
+ signed short timezone_minutes;
+ time_t time_on_timeline;
+ char have_tz;
+} rasqal_xsd_datetime;
+
+
+/**
+ * rasqal_literal:
+ * @world: world object pointer
+ * @usage: Usage count.
+ * @type: Type of literal.
+ * @string: String form of literal for literal types UTF-8 string, pattern, qname, blank, double, float, decimal, datetime.
+ * @string_len: Length of @string.
+ * @value: Alternate value content.
+ * @language: Language for string literal type.
+ * @datatype: Datatype for string literal type.
+ * @flags: Flags for literal types
+ * @parent_type: parent XSD type if any or RASQAL_LITERAL_UNKNOWN
+ * @valid: >0 if literal format is a valid lexical form for this datatype. 0 if not valid. <0 if this has not been checked yet
+ *
+ * Rasqal literal class.
+ *
+ */
+struct rasqal_literal_s {
+ rasqal_world *world;
+
+ int usage;
+
+ rasqal_literal_type type;
+
+ /* UTF-8 string, pattern, qname, blank, double, float, decimal, datetime */
+ const unsigned char *string;
+ unsigned int string_len;
+
+ union {
+ /* integer and boolean types */
+ int integer;
+ /* double and float */
+ double floating;
+ /* uri (can be temporarily NULL if a qname, see flags below) */
+ raptor_uri* uri;
+ /* variable */
+ rasqal_variable* variable;
+ /* decimal */
+ rasqal_xsd_decimal* decimal;
+ /* datetime */
+ rasqal_xsd_datetime* datetime;
+ /* date */
+ rasqal_xsd_date* date;
+ } value;
+
+ /* for string */
+ char *language;
+ raptor_uri *datatype;
+
+ /* various flags for literal types:
+ * pattern regex flags
+ * string datatype of qname
+ * uri qname of URI not yet expanded (temporary)
+ */
+ const unsigned char *flags;
+
+ rasqal_literal_type parent_type;
+
+ int valid;
+};
+
+
+/**
+ * rasqal_op:
+ * @RASQAL_EXPR_AND: Expression for AND(A, B)
+ * @RASQAL_EXPR_OR: Expression for OR(A, B)
+ * @RASQAL_EXPR_EQ: Expression for A equals B
+ * @RASQAL_EXPR_NEQ: Expression for A not equals B.
+ * @RASQAL_EXPR_LT: Expression for A less than B.
+ * @RASQAL_EXPR_GT: Expression for A greather than B.
+ * @RASQAL_EXPR_LE: Expression for A less than or equal to B.
+ * @RASQAL_EXPR_GE: Expression for A greater than or equal to B.
+ * @RASQAL_EXPR_UMINUS: Expression for -A.
+ * @RASQAL_EXPR_PLUS: Expression for +A.
+ * @RASQAL_EXPR_MINUS: Expression for A-B.
+ * @RASQAL_EXPR_STAR: Expression for A*B.
+ * @RASQAL_EXPR_SLASH: Expression for A/B.
+ * @RASQAL_EXPR_REM: Expression for A/B remainder.
+ * @RASQAL_EXPR_STR_EQ: Expression for A string equals B.
+ * @RASQAL_EXPR_STR_NEQ: Expression for A string not-equals B.
+ * @RASQAL_EXPR_STR_MATCH: Expression for string A matches literal regex B with flags.
+ * @RASQAL_EXPR_STR_NMATCH: Expression for string A not-matches literal regex B with flags.
+ * @RASQAL_EXPR_REGEX: Expression for string A matches expression regex B with flags.
+ * @RASQAL_EXPR_TILDE: Expression for binary not A.
+ * @RASQAL_EXPR_BANG: Expression for logical not A.
+ * @RASQAL_EXPR_LITERAL: Expression for a #rasqal_literal.
+ * @RASQAL_EXPR_FUNCTION: Expression for a function A with arguments (B...).
+ * @RASQAL_EXPR_BOUND: Expression for SPARQL ISBOUND(A).
+ * @RASQAL_EXPR_STR: Expression for SPARQL STR(A).
+ * @RASQAL_EXPR_LANG: Expression for SPARQL LANG(A).
+ * @RASQAL_EXPR_LANGMATCHES: Expression for SPARQL LANGMATCHES(A, B).
+ * @RASQAL_EXPR_DATATYPE: Expression for SPARQL DATATYPE(A).
+ * @RASQAL_EXPR_ISURI: Expression for SPARQL ISURI(A).
+ * @RASQAL_EXPR_ISBLANK: Expression for SPARQL ISBLANK(A).
+ * @RASQAL_EXPR_ISLITERAL: Expression for SPARQL ISLITERAL(A).
+ * @RASQAL_EXPR_CAST: Expression for cast literal A to type B.
+ * @RASQAL_EXPR_ORDER_COND_ASC: Expression for SPARQL order condition ascending.
+ * @RASQAL_EXPR_ORDER_COND_DESC: Expression for SPARQL order condition descending.
+ * @RASQAL_EXPR_GROUP_COND_ASC: Obsolete - not used
+ * @RASQAL_EXPR_GROUP_COND_DESC: Obsolete - not used
+ * @RASQAL_EXPR_COUNT: Expression for LAQRS select COUNT() aggregate function
+ * @RASQAL_EXPR_VARSTAR: Expression for LAQRS select Variable *
+ * @RASQAL_EXPR_SAMETERM: Expression for SPARQL sameTerm
+ * @RASQAL_EXPR_SUM: Expression for LAQRS select SUM() aggregate function
+ * @RASQAL_EXPR_AVG: Expression for LAQRS select AVG() aggregate function
+ * @RASQAL_EXPR_MIN: Expression for LAQRS select MIN() aggregate function
+ * @RASQAL_EXPR_MAX: Expression for LAQRS select MAX() aggregate function
+ * @RASQAL_EXPR_COALESCE: Expression for LAQRS COALESCE(Expr+)
+ * @RASQAL_EXPR_IF: Expression for LAQRS IF(expr, expr, expr)
+ * @RASQAL_EXPR_URI: Expression for LAQRS URI(expr)
+ * @RASQAL_EXPR_IRI: Expression for LAQRS IRI(expr)
+ * @RASQAL_EXPR_STRLANG: Expression for LAQRS STRLANG(expr, expr)
+ * @RASQAL_EXPR_STRDT: Expression for LAQRS STRDT(expr, expr)
+ * @RASQAL_EXPR_BNODE: Expression for LAQRS BNODE() and BNODE(expr)
+ * @RASQAL_EXPR_GROUP_CONCAT: Expression for LAQRS GROUP_CONCAT(arglist) aggregate function
+ * @RASQAL_EXPR_SAMPLE: Expression for LAQRS SAMPLE(expr) aggregate function
+ * @RASQAL_EXPR_IN: Expression for LAQRS expr IN ( list of expr )
+ * @RASQAL_EXPR_NOT_IN: Expression for LAQRS expr NOT IN ( list of expr )
+ * @RASQAL_EXPR_ISNUMERIC: Expression for SPARQL 1.1 isNUMERIC(expr)
+ * @RASQAL_EXPR_YEAR: Expression for SPARQL 1.1 YEAR(datetime)
+ * @RASQAL_EXPR_MONTH: Expression for SPARQL 1.1 MONTH(datetime)
+ * @RASQAL_EXPR_DAY: Expression for SPARQL 1.1 DAY(datetime)
+ * @RASQAL_EXPR_HOURS: Expression for SPARQL 1.1 HOURS(datetime)
+ * @RASQAL_EXPR_MINUTES: Expression for SPARQL 1.1 MINUTES(datetime)
+ * @RASQAL_EXPR_SECONDS: Expression for SPARQL 1.1 SECONDS(datetime)
+ * @RASQAL_EXPR_TIMEZONE: Expression for SPARQL 1.1 TIMEZONE(datetime)
+ * @RASQAL_EXPR_CURRENT_DATETIME: Expression for LAQRS CURRENT_DATETIME( void )
+ * @RASQAL_EXPR_NOW: Expression for LAQRS NOW( void )
+ * @RASQAL_EXPR_FROM_UNIXTIME: Expression for LAQRS FROM_UNIXTIME(int)
+ * @RASQAL_EXPR_TO_UNIXTIME: Expression for LAQRS TO_UNIXTIME(datetime)
+ * @RASQAL_EXPR_CONCAT: Expression for SPARQL 1.1 CONCAT(strings)
+ * @RASQAL_EXPR_STRLEN: Expression for SPARQL 1.1 STRLEN(str)
+ * @RASQAL_EXPR_SUBSTR: Expression for SPARQL 1.1 SUBSTR(str, start[,offset])
+ * @RASQAL_EXPR_UCASE: Expression for SPARQL 1.1 UCASE(str)
+ * @RASQAL_EXPR_LCASE: Expression for SPARQL 1.1 LCASE(str)
+ * @RASQAL_EXPR_STRSTARTS: Expression for SPARQL 1.1 STRSTARTS(str, str)
+ * @RASQAL_EXPR_STRENDS: Expression for SPARQL 1.1 STRENDS(str, str)
+ * @RASQAL_EXPR_CONTAINS: Expression for SPARQL 1.1 CONTAINS(str, str)
+ * @RASQAL_EXPR_ENCODE_FOR_URI: Expression for SPARQL 1.1 ENCODE_FOR_URI(str)
+ * @RASQAL_EXPR_TZ: Expression for SPARQL 1.1 TZ()
+ * @RASQAL_EXPR_RAND: Expression for SPARQL 1.1 RAND()
+ * @RASQAL_EXPR_ABS: Expression for SPARQL 1.1 ABS()
+ * @RASQAL_EXPR_ROUND: Expression for SPARQL 1.1 ROUND()
+ * @RASQAL_EXPR_CEIL: Expression for SPARQL 1.1 CEIL()
+ * @RASQAL_EXPR_FLOOR: Expression for SPARQL 1.1 FLOOR()
+ * @RASQAL_EXPR_MD5: Expression for SPARQL 1.1 MD5()
+ * @RASQAL_EXPR_SHA1: Expression for SPARQL 1.1 SHA1()
+ * @RASQAL_EXPR_SHA224: Expression for SPARQL 1.1 SHA224()
+ * @RASQAL_EXPR_SHA256: Expression for SPARQL 1.1 SHA256()
+ * @RASQAL_EXPR_SHA384: Expression for SPARQL 1.1 SHA384()
+ * @RASQAL_EXPR_SHA512: Expression for SPARQL 1.1 SHA512()
+ * @RASQAL_EXPR_STRBEFORE: Expression for SPARQL 1.1 STRBEFORE()
+ * @RASQAL_EXPR_STRAFTER: Expression for SPARQL 1.1 STRAFTER()
+ * @RASQAL_EXPR_REPLACE: Expression for SPARQL 1.1 REPLACE()
+ * @RASQAL_EXPR_UUID: Expression for SPARQL 1.1 UUID()
+ * @RASQAL_EXPR_STRUUID: Expression for SPARQL 1.1 STRUUID()
+ * @RASQAL_EXPR_UNKNOWN: Internal
+ * @RASQAL_EXPR_LAST: Internal
+ *
+ * Rasqal expression operators. A mixture of unary, binary and
+ * tertiary operators (string matches). Also includes casting and
+ * two ordering operators from ORDER BY in SPARQL.
+ */
+typedef enum {
+ /* internal */
+ RASQAL_EXPR_UNKNOWN,
+ RASQAL_EXPR_AND,
+ RASQAL_EXPR_OR,
+ RASQAL_EXPR_EQ,
+ RASQAL_EXPR_NEQ,
+ RASQAL_EXPR_LT,
+ RASQAL_EXPR_GT,
+ RASQAL_EXPR_LE,
+ RASQAL_EXPR_GE,
+ RASQAL_EXPR_UMINUS,
+ RASQAL_EXPR_PLUS,
+ RASQAL_EXPR_MINUS,
+ RASQAL_EXPR_STAR,
+ RASQAL_EXPR_SLASH,
+ RASQAL_EXPR_REM,
+ RASQAL_EXPR_STR_EQ,
+ RASQAL_EXPR_STR_NEQ,
+ RASQAL_EXPR_STR_MATCH,
+ RASQAL_EXPR_STR_NMATCH,
+ RASQAL_EXPR_TILDE,
+ RASQAL_EXPR_BANG,
+ RASQAL_EXPR_LITERAL,
+ RASQAL_EXPR_FUNCTION,
+ RASQAL_EXPR_BOUND,
+ RASQAL_EXPR_STR,
+ RASQAL_EXPR_LANG,
+ RASQAL_EXPR_DATATYPE,
+ RASQAL_EXPR_ISURI,
+ RASQAL_EXPR_ISBLANK,
+ RASQAL_EXPR_ISLITERAL,
+ RASQAL_EXPR_CAST,
+ RASQAL_EXPR_ORDER_COND_ASC,
+ RASQAL_EXPR_ORDER_COND_DESC,
+ RASQAL_EXPR_LANGMATCHES,
+ RASQAL_EXPR_REGEX,
+ RASQAL_EXPR_GROUP_COND_ASC,
+ RASQAL_EXPR_GROUP_COND_DESC,
+ RASQAL_EXPR_COUNT,
+ RASQAL_EXPR_VARSTAR,
+ RASQAL_EXPR_SAMETERM,
+ RASQAL_EXPR_SUM,
+ RASQAL_EXPR_AVG,
+ RASQAL_EXPR_MIN,
+ RASQAL_EXPR_MAX,
+ RASQAL_EXPR_COALESCE,
+ RASQAL_EXPR_IF,
+ RASQAL_EXPR_URI,
+ RASQAL_EXPR_IRI,
+ RASQAL_EXPR_STRLANG,
+ RASQAL_EXPR_STRDT,
+ RASQAL_EXPR_BNODE,
+ RASQAL_EXPR_GROUP_CONCAT,
+ RASQAL_EXPR_SAMPLE,
+ RASQAL_EXPR_IN,
+ RASQAL_EXPR_NOT_IN,
+ RASQAL_EXPR_ISNUMERIC,
+ RASQAL_EXPR_YEAR,
+ RASQAL_EXPR_MONTH,
+ RASQAL_EXPR_DAY,
+ RASQAL_EXPR_HOURS,
+ RASQAL_EXPR_MINUTES,
+ RASQAL_EXPR_SECONDS,
+ RASQAL_EXPR_TIMEZONE,
+ RASQAL_EXPR_CURRENT_DATETIME,
+ RASQAL_EXPR_NOW,
+ RASQAL_EXPR_FROM_UNIXTIME,
+ RASQAL_EXPR_TO_UNIXTIME,
+ RASQAL_EXPR_CONCAT,
+ RASQAL_EXPR_STRLEN,
+ RASQAL_EXPR_SUBSTR,
+ RASQAL_EXPR_UCASE,
+ RASQAL_EXPR_LCASE,
+ RASQAL_EXPR_STRSTARTS,
+ RASQAL_EXPR_STRENDS,
+ RASQAL_EXPR_CONTAINS,
+ RASQAL_EXPR_ENCODE_FOR_URI,
+ RASQAL_EXPR_TZ,
+ RASQAL_EXPR_RAND,
+ RASQAL_EXPR_ABS,
+ RASQAL_EXPR_ROUND,
+ RASQAL_EXPR_CEIL,
+ RASQAL_EXPR_FLOOR,
+ RASQAL_EXPR_MD5,
+ RASQAL_EXPR_SHA1,
+ RASQAL_EXPR_SHA224,
+ RASQAL_EXPR_SHA256,
+ RASQAL_EXPR_SHA384,
+ RASQAL_EXPR_SHA512,
+ RASQAL_EXPR_STRBEFORE,
+ RASQAL_EXPR_STRAFTER,
+ RASQAL_EXPR_REPLACE,
+ RASQAL_EXPR_UUID,
+ RASQAL_EXPR_STRUUID,
+ /* internal */
+ RASQAL_EXPR_LAST = RASQAL_EXPR_STRUUID
+} rasqal_op;
+
+
+/**
+ * rasqal_expression_flags:
+ * @RASQAL_EXPR_FLAG_DISTINCT: Distinct
+ * @RASQAL_EXPR_FLAG_AGGREGATE: Aggregate function expression
+ *
+ * Flags for expressions.
+ */
+typedef enum {
+ RASQAL_EXPR_FLAG_DISTINCT = 1,
+ RASQAL_EXPR_FLAG_AGGREGATE = 2
+} rasqal_expression_flags;
+
+
+/**
+ * rasqal_expression:
+ * @world: rasqal_world object
+ * @usage: reference count - 1 for itself
+ * @op: expression operation
+ * @arg1: first argument
+ * @arg2: second argument
+ * @arg3: third argument (for #RASQAL_EXPR_REGEX )
+ * @literal: literal argument
+ * @value: UTF-8 value
+ * @name: name for extension function qname(args...) and cast-to-uri
+ * @args: args for extension function qname(args...), cast-to-uri and COALESCE
+ * @params: args for extension function parameters (SPARQL 1.1) (Rasqal 0.9.20+)
+ * @flags: bitflags from #rasqal_expression_flags for expressions (Rasqal 0.9.20+)
+ * @arg4: fourth argument (for #RASQAL_EXPR_REPLACE )
+ *
+ * Expression with arguments
+ *
+ */
+struct rasqal_expression_s {
+ rasqal_world* world;
+
+ int usage;
+
+ rasqal_op op;
+
+ struct rasqal_expression_s* arg1;
+ struct rasqal_expression_s* arg2;
+ struct rasqal_expression_s* arg3;
+ rasqal_literal* literal;
+ unsigned char *value;
+
+ raptor_uri* name;
+ raptor_sequence* args;
+
+ raptor_sequence* params;
+ unsigned int flags;
+ struct rasqal_expression_s* arg4;
+};
+typedef struct rasqal_expression_s rasqal_expression;
+
+
+/**
+ * rasqal_triple:
+ * @subject: Triple subject.
+ * @predicate: Triple predicate.
+ * @object: Triple object.
+ * @origin: Triple origin.
+ * @flags: Or of enum #rasqal_triple_flags bits.
+ *
+ * A triple pattern or RDF triple.
+ *
+ * This is used as a triple pattern in queries and
+ * an RDF triple when generating RDF triples such as with SPARQL CONSTRUCT.
+ */
+typedef struct {
+ rasqal_literal* subject;
+ rasqal_literal* predicate;
+ rasqal_literal* object;
+ rasqal_literal* origin;
+ unsigned int flags;
+} rasqal_triple;
+
+
+/**
+ * rasqal_pattern_flags:
+ * @RASQAL_PATTERN_FLAGS_OPTIONAL: True when the graph pattern is an optional match.
+ * @RASQAL_PATTERN_FLAGS_LAST: Internal
+ *
+ * Flags for #rasqal_graph_pattern.
+ */
+typedef enum {
+ RASQAL_PATTERN_FLAGS_OPTIONAL = 1,
+
+ RASQAL_PATTERN_FLAGS_LAST = RASQAL_PATTERN_FLAGS_OPTIONAL
+} rasqal_pattern_flags;
+
+
+/**
+ * rasqal_generate_bnodeid_handler:
+ * @world: world arg
+ * @user_data: user data given to
+ * @user_bnodeid: user blank node ID string passed in
+ *
+ * User handler used with rasqal_world_set_generate_bnodeid_handler() to set method for generating a blank node ID.
+ *
+ * Return value: blank node ID string or NULL on failure.
+ */
+typedef unsigned char* (*rasqal_generate_bnodeid_handler)(rasqal_world* world, void *user_data, unsigned char *user_bnodeid);
+
+
+/**
+ * rasqal_query_verb:
+ * @RASQAL_QUERY_VERB_SELECT: SPARQL query select verb.
+ * @RASQAL_QUERY_VERB_CONSTRUCT: SPARQL query construct verb.
+ * @RASQAL_QUERY_VERB_DESCRIBE: SPARQL query describe verb.
+ * @RASQAL_QUERY_VERB_ASK: SPARQL query ask verb.
+ * @RASQAL_QUERY_VERB_DELETE: LAQRS query delete verb.
+ * @RASQAL_QUERY_VERB_INSERT: LAQRS query insert verb.
+ * @RASQAL_QUERY_VERB_UPDATE: SPARQL 1.1 (draft) update operation
+ * @RASQAL_QUERY_VERB_UNKNOWN: Internal
+ * @RASQAL_QUERY_VERB_LAST: Internal
+ *
+ * Query main operation verbs describing the major type of query
+ * being performed.
+ */
+typedef enum {
+ /* internal */
+ RASQAL_QUERY_VERB_UNKNOWN = 0,
+ RASQAL_QUERY_VERB_SELECT = 1,
+ RASQAL_QUERY_VERB_CONSTRUCT = 2,
+ RASQAL_QUERY_VERB_DESCRIBE = 3,
+ RASQAL_QUERY_VERB_ASK = 4,
+ RASQAL_QUERY_VERB_DELETE = 5,
+ RASQAL_QUERY_VERB_INSERT = 6,
+ RASQAL_QUERY_VERB_UPDATE = 7,
+
+ /* internal */
+ RASQAL_QUERY_VERB_LAST = RASQAL_QUERY_VERB_UPDATE
+} rasqal_query_verb;
+
+
+/**
+ * rasqal_query_results_type:
+ * @RASQAL_QUERY_RESULTS_BINDINGS: variable binding
+ * @RASQAL_QUERY_RESULTS_BOOLEAN: a single boolean
+ * @RASQAL_QUERY_RESULTS_GRAPH: an RDF graph
+ * @RASQAL_QUERY_RESULTS_SYNTAX: a syntax
+ * @RASQAL_QUERY_RESULTS_UNKNOWN: unknown type
+ * @RASQAL_QUERY_RESULTS_LAST: internal
+ *
+ * Query result type.
+ */
+
+typedef enum {
+ RASQAL_QUERY_RESULTS_BINDINGS,
+ RASQAL_QUERY_RESULTS_BOOLEAN,
+ RASQAL_QUERY_RESULTS_GRAPH,
+ RASQAL_QUERY_RESULTS_SYNTAX,
+ RASQAL_QUERY_RESULTS_UNKNOWN,
+ RASQAL_QUERY_RESULTS_LAST = RASQAL_QUERY_RESULTS_UNKNOWN
+} rasqal_query_results_type;
+
+
+/**
+ * rasqal_update_type:
+ * @RASQAL_UPDATE_TYPE_CLEAR: Clear graph.
+ * @RASQAL_UPDATE_TYPE_CREATE: Create graph.
+ * @RASQAL_UPDATE_TYPE_DROP: Drop graph.
+ * @RASQAL_UPDATE_TYPE_LOAD: Load graph.
+ * @RASQAL_UPDATE_TYPE_UPDATE: Insert or Delete graph or triples.
+ * @RASQAL_UPDATE_TYPE_ADD: Add graph to another graph.
+ * @RASQAL_UPDATE_TYPE_MOVE: Move graph to another grpah.
+ * @RASQAL_UPDATE_TYPE_COPY: Copy graph to another graph.
+ * @RASQAL_UPDATE_TYPE_UNKNOWN: Internal
+ * @RASQAL_UPDATE_TYPE_LAST: Internal
+ *
+ * Update type being performed.
+ *
+ */
+typedef enum {
+ /* internal */
+ RASQAL_UPDATE_TYPE_UNKNOWN = 0,
+ RASQAL_UPDATE_TYPE_CLEAR = 1,
+ RASQAL_UPDATE_TYPE_CREATE = 2,
+ RASQAL_UPDATE_TYPE_DROP = 3,
+ RASQAL_UPDATE_TYPE_LOAD = 4,
+ RASQAL_UPDATE_TYPE_UPDATE = 5,
+ RASQAL_UPDATE_TYPE_ADD = 6,
+ RASQAL_UPDATE_TYPE_MOVE = 7,
+ RASQAL_UPDATE_TYPE_COPY = 8,
+
+ /* internal */
+ RASQAL_UPDATE_TYPE_LAST = RASQAL_UPDATE_TYPE_COPY
+} rasqal_update_type;
+
+
+/**
+ * rasqal_update_flags:
+ * @RASQAL_UPDATE_FLAGS_SILENT: the update operation should be silent
+ * @RASQAL_UPDATE_FLAGS_DATA: the update operation is triple data not templates
+ *
+ * Bitflags for graph update operations
+ */
+typedef enum {
+ RASQAL_UPDATE_FLAGS_SILENT = 1,
+ RASQAL_UPDATE_FLAGS_DATA = 2
+} rasqal_update_flags;
+
+
+/**
+ * rasqal_update_graph_applies:
+ * @RASQAL_UPDATE_GRAPH_ONE: the update operation applies to 1 graph
+ * @RASQAL_UPDATE_GRAPH_DEFAULT: the update operation applies to the default graph
+ * @RASQAL_UPDATE_GRAPH_NAMED: the update operation applies to all named graphs
+ * @RASQAL_UPDATE_GRAPH_ALL: the update operation applies ALL graphs
+ *
+ * The graph(s) that the update operation applies to.
+ */
+typedef enum {
+ RASQAL_UPDATE_GRAPH_ONE = 0,
+ RASQAL_UPDATE_GRAPH_DEFAULT = 1,
+ RASQAL_UPDATE_GRAPH_NAMED = 2,
+ RASQAL_UPDATE_GRAPH_ALL = 3
+} rasqal_update_graph_applies;
+
+
+/**
+ * rasqal_update_operation:
+ * @type: type of update
+ * @graph_uri: optional graph URI (clear, drop, load, with ... delete, insert); source graph (add, move, copy)
+ * @document_uri: optional document URI (load); destination graph (add, move, copy)
+ * @insert_templates: optional sequence of #rasqal_triple to insert. Data triples if @flags is #RASQAL_UPDATE_FLAGS_DATA set, templates otherwise.
+ * @delete_templates: optional sequence of #rasqal_triple templates to delete
+ * @where: optional where template (insert/delete)
+ * @flags: update flags - bit-or of flags defined in #rasqal_update_flags
+ * @applies: the graph(s) that the update operation applies to, or @graph_uri if #RASQAL_UPDATE_GRAPH_ONE
+ *
+ * Update operation - changing the dataset
+ *
+ * For LOAD and CLEAR if @applies is set (not 0) then the operation
+ * applies to just those graph(), otherwise it applies to the @graph_uri.
+ *
+ * For ADD, MOVE and COPY the source graph is stored in @graph_uri
+ * field and the destination graph in the @document_uri field. The
+ * field names have no meaning in this case since both values are
+ * always present, always graphs and a NULL value signifies the
+ * default graph.
+ *
+ */
+typedef struct {
+ rasqal_update_type type;
+
+ raptor_uri* graph_uri;
+
+ raptor_uri* document_uri;
+
+ raptor_sequence* insert_templates;
+
+ raptor_sequence* delete_templates;
+
+ rasqal_graph_pattern* where;
+
+ int flags;
+
+ rasqal_update_graph_applies applies;
+} rasqal_update_operation;
+
+
+/**
+ * rasqal_graph_pattern_operator:
+ * @RASQAL_GRAPH_PATTERN_OPERATOR_BASIC: Just triple patterns and constraints.
+ * @RASQAL_GRAPH_PATTERN_OPERATOR_OPTIONAL: Set of graph patterns (ANDed) and constraints.
+ * @RASQAL_GRAPH_PATTERN_OPERATOR_UNION: Set of graph patterns (UNIONed) and constraints.
+ * @RASQAL_GRAPH_PATTERN_OPERATOR_GROUP: Set of graph patterns (ANDed) and constraints.
+ * @RASQAL_GRAPH_PATTERN_OPERATOR_GRAPH: A graph term + a graph pattern and constraints.
+ * @RASQAL_GRAPH_PATTERN_OPERATOR_FILTER: A filter graph pattern with an expression
+ * @RASQAL_GRAPH_PATTERN_OPERATOR_LET: LET ?var := Expression (LAQRS)
+ * @RASQAL_GRAPH_PATTERN_OPERATOR_SELECT: SELECT graph pattern
+ * @RASQAL_GRAPH_PATTERN_OPERATOR_SERVICE: SERVICE graph pattern
+ * @RASQAL_GRAPH_PATTERN_OPERATOR_MINUS: MINUS graph pattern
+ * @RASQAL_GRAPH_PATTERN_OPERATOR_VALUES: VALUES graph pattern
+ * @RASQAL_GRAPH_PATTERN_OPERATOR_UNKNOWN: Internal.
+ * @RASQAL_GRAPH_PATTERN_OPERATOR_LAST: Internal.
+ *
+ * Graph pattern operators
+ */
+typedef enum {
+ RASQAL_GRAPH_PATTERN_OPERATOR_UNKNOWN = 0,
+ RASQAL_GRAPH_PATTERN_OPERATOR_BASIC = 1,
+ RASQAL_GRAPH_PATTERN_OPERATOR_OPTIONAL = 2,
+ RASQAL_GRAPH_PATTERN_OPERATOR_UNION = 3,
+ RASQAL_GRAPH_PATTERN_OPERATOR_GROUP = 4,
+ RASQAL_GRAPH_PATTERN_OPERATOR_GRAPH = 5,
+ RASQAL_GRAPH_PATTERN_OPERATOR_FILTER = 6,
+ RASQAL_GRAPH_PATTERN_OPERATOR_LET = 7,
+ RASQAL_GRAPH_PATTERN_OPERATOR_SELECT = 8,
+ RASQAL_GRAPH_PATTERN_OPERATOR_SERVICE = 9,
+ RASQAL_GRAPH_PATTERN_OPERATOR_MINUS = 10,
+ RASQAL_GRAPH_PATTERN_OPERATOR_VALUES = 11,
+
+ RASQAL_GRAPH_PATTERN_OPERATOR_LAST = RASQAL_GRAPH_PATTERN_OPERATOR_VALUES
+} rasqal_graph_pattern_operator;
+
+
+/**
+ * rasqal_graph_pattern_visit_fn:
+ * @query: #rasqal_query containing the graph pattern
+ * @gp: current graph_pattern
+ * @user_data: user data passed in
+ *
+ * User function to visit a graph_pattern and operate on it with
+ * rasqal_graph_pattern_visit() or rasqal_query_graph_pattern_visit()
+ *
+ * Return value: non-0 to truncate the visit
+ */
+typedef int (*rasqal_graph_pattern_visit_fn)(rasqal_query* query, rasqal_graph_pattern* gp, void *user_data);
+
+
+/* RASQAL API */
+
+/* Public functions */
+
+RASQAL_API
+rasqal_world *rasqal_new_world(void);
+RASQAL_API
+int rasqal_world_open(rasqal_world* world);
+RASQAL_API
+void rasqal_free_world(rasqal_world* world);
+
+RASQAL_API
+void rasqal_world_set_raptor(rasqal_world* world, raptor_world* raptor_world_ptr);
+RASQAL_API
+raptor_world *rasqal_world_get_raptor(rasqal_world* world);
+
+RASQAL_API
+void rasqal_world_set_log_handler(rasqal_world* world, void *user_data, raptor_log_handler handler);
+
+RASQAL_API
+int rasqal_world_set_default_generate_bnodeid_parameters(rasqal_world* world, char *prefix, int base);
+RASQAL_API
+int rasqal_world_set_generate_bnodeid_handler(rasqal_world* world, void *user_data, rasqal_generate_bnodeid_handler handler);
+
+RASQAL_API
+int rasqal_world_set_warning_level(rasqal_world* world, unsigned int warning_level);
+
+RASQAL_API
+const raptor_syntax_description* rasqal_world_get_query_results_format_description(rasqal_world* world, unsigned int counter);
+
+RASQAL_API
+const char* rasqal_world_guess_query_results_format_name(rasqal_world* world, raptor_uri *uri, const char *mime_type, const unsigned char *buffer, size_t len, const unsigned char *identifier);
+
+/* Features */
+RASQAL_API
+int rasqal_features_enumerate(rasqal_world* world, const rasqal_feature feature, const char **name, raptor_uri **uri, const char **label);
+RASQAL_API
+unsigned int rasqal_get_feature_count(void);
+RASQAL_API
+rasqal_feature rasqal_feature_from_uri(rasqal_world* world, raptor_uri *uri);
+RASQAL_API
+int rasqal_feature_value_type(const rasqal_feature feature);
+
+
+RASQAL_API
+const raptor_syntax_description* rasqal_world_get_query_language_description(rasqal_world* world, unsigned int counter);
+
+RASQAL_API RASQAL_DEPRECATED
+int rasqal_languages_enumerate(rasqal_world* world, unsigned int counter, const char **name, const char **label, const unsigned char **uri_string);
+
+RASQAL_API
+int rasqal_language_name_check(rasqal_world* world, const char *name);
+
+
+/* Query class */
+
+/* Create */
+RASQAL_API
+rasqal_query* rasqal_new_query(rasqal_world* world, const char *name, const unsigned char *uri);
+
+/* Destroy */
+RASQAL_API
+void rasqal_free_query(rasqal_query* query);
+
+/* Methods */
+RASQAL_API
+const char* rasqal_query_get_name(rasqal_query* query);
+RASQAL_API
+const char* rasqal_query_get_label(rasqal_query* query);
+
+
+RASQAL_API
+int rasqal_query_set_feature(rasqal_query* query, rasqal_feature feature, int value);
+RASQAL_API
+int rasqal_query_set_feature_string(rasqal_query *query, rasqal_feature feature, const unsigned char *value);
+RASQAL_API
+int rasqal_query_get_feature(rasqal_query *query, rasqal_feature feature);
+RASQAL_API
+const unsigned char* rasqal_query_get_feature_string(rasqal_query *query, rasqal_feature feature);
+
+RASQAL_API
+rasqal_query_verb rasqal_query_get_verb(rasqal_query* query);
+RASQAL_API
+int rasqal_query_get_wildcard(rasqal_query* query);
+RASQAL_API
+void rasqal_query_set_wildcard(rasqal_query* query, int wildcard);
+RASQAL_API
+int rasqal_query_get_distinct(rasqal_query* query);
+RASQAL_API
+void rasqal_query_set_distinct(rasqal_query* query, int distinct_mode);
+RASQAL_API
+int rasqal_query_get_explain(rasqal_query* query);
+RASQAL_API
+void rasqal_query_set_explain(rasqal_query* query, int is_explain);
+RASQAL_API
+int rasqal_query_get_limit(rasqal_query* query);
+RASQAL_API
+void rasqal_query_set_limit(rasqal_query* query, int limit);
+RASQAL_API
+int rasqal_query_get_offset(rasqal_query* query);
+RASQAL_API
+void rasqal_query_set_offset(rasqal_query* query, int offset);
+
+RASQAL_API
+int rasqal_query_add_data_graph(rasqal_query* query, rasqal_data_graph* data_graph);
+RASQAL_API
+int rasqal_query_add_data_graphs(rasqal_query* query, raptor_sequence* data_graphs);
+
+RASQAL_API
+raptor_sequence* rasqal_query_get_data_graph_sequence(rasqal_query* query);
+RASQAL_API
+rasqal_data_graph* rasqal_query_get_data_graph(rasqal_query* query, int idx);
+RASQAL_API
+int rasqal_query_dataset_contains_named_graph(rasqal_query* query, raptor_uri *graph_uri);
+
+RASQAL_API
+int rasqal_query_add_variable(rasqal_query* query, rasqal_variable* var);
+RASQAL_API
+raptor_sequence* rasqal_query_get_bound_variable_sequence(rasqal_query* query);
+RASQAL_API
+raptor_sequence* rasqal_query_get_describe_sequence(rasqal_query* query);
+RASQAL_API
+raptor_sequence* rasqal_query_get_anonymous_variable_sequence(rasqal_query* query);
+RASQAL_API
+raptor_sequence* rasqal_query_get_all_variable_sequence(rasqal_query* query);
+RASQAL_API
+rasqal_variable* rasqal_query_get_variable(rasqal_query* query, int idx);
+RASQAL_API
+int rasqal_query_has_variable2(rasqal_query* query, rasqal_variable_type type, const unsigned char *name);
+RASQAL_API RASQAL_DEPRECATED
+int rasqal_query_has_variable(rasqal_query* query, const unsigned char *name);
+RASQAL_API
+int rasqal_query_set_variable2(rasqal_query* query, rasqal_variable_type type, const unsigned char *name, rasqal_literal* value);
+RASQAL_API RASQAL_DEPRECATED
+int rasqal_query_set_variable(rasqal_query* query, const unsigned char *name, rasqal_literal* value);
+RASQAL_API
+raptor_sequence* rasqal_query_get_triple_sequence(rasqal_query* query);
+RASQAL_API
+rasqal_triple* rasqal_query_get_triple(rasqal_query* query, int idx);
+RASQAL_API
+int rasqal_query_add_prefix(rasqal_query* query, rasqal_prefix* prefix);
+RASQAL_API
+raptor_sequence* rasqal_query_get_prefix_sequence(rasqal_query* query);
+RASQAL_API
+rasqal_prefix* rasqal_query_get_prefix(rasqal_query* query, int idx);
+RASQAL_API
+raptor_sequence* rasqal_query_get_order_conditions_sequence(rasqal_query* query);
+RASQAL_API
+rasqal_expression* rasqal_query_get_order_condition(rasqal_query* query, int idx);
+RASQAL_API
+raptor_sequence* rasqal_query_get_group_conditions_sequence(rasqal_query* query);
+RASQAL_API
+rasqal_expression* rasqal_query_get_group_condition(rasqal_query* query, int idx);
+RASQAL_API
+raptor_sequence* rasqal_query_get_having_conditions_sequence(rasqal_query* query);
+RASQAL_API
+rasqal_expression* rasqal_query_get_having_condition(rasqal_query* query, int idx);
+RASQAL_API
+raptor_sequence* rasqal_query_get_construct_triples_sequence(rasqal_query* query);
+RASQAL_API
+rasqal_triple* rasqal_query_get_construct_triple(rasqal_query* query, int idx);
+RASQAL_API RASQAL_DEPRECATED
+void rasqal_query_graph_pattern_visit(rasqal_query* query, rasqal_graph_pattern_visit_fn visit_fn, void* data);
+RASQAL_API
+int rasqal_query_graph_pattern_visit2(rasqal_query* query, rasqal_graph_pattern_visit_fn visit_fn, void* data);
+RASQAL_API
+int rasqal_query_write(raptor_iostream* iostr, rasqal_query* query, raptor_uri* format_uri, raptor_uri* base_uri);
+
+/* update */
+RASQAL_API
+raptor_sequence* rasqal_query_get_update_operations_sequence(rasqal_query* query);
+RASQAL_API
+rasqal_update_operation* rasqal_query_get_update_operation(rasqal_query* query, int idx);
+
+/* results */
+int rasqal_query_set_store_results(rasqal_query* query, int store_results);
+
+/* graph patterns */
+RASQAL_API
+rasqal_graph_pattern* rasqal_query_get_query_graph_pattern(rasqal_query* query);
+RASQAL_API
+raptor_sequence* rasqal_query_get_graph_pattern_sequence(rasqal_query* query);
+RASQAL_API
+rasqal_graph_pattern* rasqal_query_get_graph_pattern(rasqal_query* query, int idx);
+RASQAL_API
+int rasqal_graph_pattern_add_sub_graph_pattern(rasqal_graph_pattern* graph_pattern, rasqal_graph_pattern* sub_graph_pattern);
+RASQAL_API
+rasqal_triple* rasqal_graph_pattern_get_triple(rasqal_graph_pattern* graph_pattern, int idx);
+RASQAL_API
+raptor_sequence* rasqal_graph_pattern_get_sub_graph_pattern_sequence(rasqal_graph_pattern* graph_pattern);
+RASQAL_API
+rasqal_graph_pattern* rasqal_graph_pattern_get_sub_graph_pattern(rasqal_graph_pattern* graph_pattern, int idx);
+RASQAL_API
+rasqal_graph_pattern_operator rasqal_graph_pattern_get_operator(rasqal_graph_pattern* graph_pattern);
+RASQAL_API
+const char* rasqal_graph_pattern_operator_as_string(rasqal_graph_pattern_operator op);
+RASQAL_API
+int rasqal_graph_pattern_print(rasqal_graph_pattern* gp, FILE* fh);
+RASQAL_API
+int rasqal_graph_pattern_set_filter_expression(rasqal_graph_pattern* gp, rasqal_expression* expr);
+RASQAL_API
+rasqal_expression* rasqal_graph_pattern_get_filter_expression(rasqal_graph_pattern* gp);
+RASQAL_API
+int rasqal_graph_pattern_visit(rasqal_query* query, rasqal_graph_pattern *gp, rasqal_graph_pattern_visit_fn fn, void* user_data);
+RASQAL_API
+int rasqal_graph_pattern_get_index(rasqal_graph_pattern* gp);
+RASQAL_API
+int rasqal_graph_pattern_variable_bound_in(rasqal_graph_pattern *gp, rasqal_variable *v);
+RASQAL_API
+rasqal_literal* rasqal_graph_pattern_get_origin(rasqal_graph_pattern* graph_pattern);
+RASQAL_API
+rasqal_variable* rasqal_graph_pattern_get_variable(rasqal_graph_pattern* graph_pattern);
+RASQAL_API
+rasqal_literal* rasqal_graph_pattern_get_service(rasqal_graph_pattern* graph_pattern);
+RASQAL_API
+raptor_sequence* rasqal_graph_pattern_get_flattened_triples(rasqal_query* query, rasqal_graph_pattern* graph_pattern);
+RASQAL_API
+raptor_sequence* rasqal_graph_pattern_get_triples(rasqal_query* query, rasqal_graph_pattern* graph_pattern);
+
+
+/* Utility methods */
+RASQAL_API
+const char* rasqal_query_verb_as_string(rasqal_query_verb verb);
+RASQAL_API
+int rasqal_query_print(rasqal_query* query, FILE* fh);
+
+/* Query */
+RASQAL_API
+int rasqal_query_prepare(rasqal_query* query, const unsigned char *query_string, raptor_uri *base_uri);
+RASQAL_API
+rasqal_query_results* rasqal_query_execute(rasqal_query* query);
+
+RASQAL_API
+void* rasqal_query_get_user_data(rasqal_query* query);
+RASQAL_API
+void rasqal_query_set_user_data(rasqal_query* query, void *user_data);
+
+RASQAL_API
+raptor_sequence* rasqal_query_get_bindings_variables_sequence(rasqal_query* query);
+RASQAL_API
+rasqal_variable* rasqal_query_get_bindings_variable(rasqal_query* query, int idx);
+RASQAL_API
+raptor_sequence* rasqal_query_get_bindings_rows_sequence(rasqal_query* query);
+RASQAL_API
+rasqal_row* rasqal_query_get_bindings_row(rasqal_query* query, int idx);
+RASQAL_API
+rasqal_query_results_type rasqal_query_get_result_type(rasqal_query* query);
+
+/* query results */
+RASQAL_API
+rasqal_query_results* rasqal_new_query_results2(rasqal_world* world, rasqal_query* query, rasqal_query_results_type type);
+RASQAL_API RASQAL_DEPRECATED
+rasqal_query_results* rasqal_new_query_results(rasqal_world* world, rasqal_query* query, rasqal_query_results_type type, rasqal_variables_table* vars_table);
+RASQAL_API
+rasqal_query_results* rasqal_new_query_results_from_string(rasqal_world* world, rasqal_query_results_type type, raptor_uri* base_uri, const char* string, size_t string_len);
+RASQAL_API
+void rasqal_free_query_results(rasqal_query_results *query_results);
+
+RASQAL_API
+rasqal_query* rasqal_query_results_get_query(rasqal_query_results* query_results);
+
+/* Bindings result format */
+RASQAL_API
+rasqal_query_results_type rasqal_query_results_get_type(rasqal_query_results* query_results);
+RASQAL_API
+const char* rasqal_query_results_type_label(rasqal_query_results_type type);
+RASQAL_API
+int rasqal_query_results_is_bindings(rasqal_query_results *query_results);
+RASQAL_API
+int rasqal_query_results_get_count(rasqal_query_results *query_results);
+RASQAL_API
+int rasqal_query_results_next(rasqal_query_results *query_results);
+RASQAL_API
+int rasqal_query_results_finished(rasqal_query_results *query_results);
+RASQAL_API
+int rasqal_query_results_get_bindings(rasqal_query_results *query_results, const unsigned char ***names, rasqal_literal ***values);
+RASQAL_API
+rasqal_literal* rasqal_query_results_get_binding_value(rasqal_query_results *query_results, int offset);
+RASQAL_API
+const unsigned char* rasqal_query_results_get_binding_name(rasqal_query_results *query_results, int offset);
+RASQAL_API
+rasqal_literal* rasqal_query_results_get_binding_value_by_name(rasqal_query_results *query_results, const unsigned char *name);
+RASQAL_API
+int rasqal_query_results_get_bindings_count(rasqal_query_results *query_results);
+RASQAL_API
+int rasqal_query_results_add_row(rasqal_query_results* query_results, rasqal_row* row);
+RASQAL_API
+rasqal_row* rasqal_query_results_get_row_by_offset(rasqal_query_results* query_results, int result_offset);
+
+/* Boolean result format */
+RASQAL_API
+int rasqal_query_results_is_boolean(rasqal_query_results *query_results);
+RASQAL_API
+int rasqal_query_results_get_boolean(rasqal_query_results *query_results);
+
+/* Graph result format */
+RASQAL_API
+int rasqal_query_results_is_graph(rasqal_query_results *query_results);
+RASQAL_API
+raptor_statement* rasqal_query_results_get_triple(rasqal_query_results *query_results);
+RASQAL_API
+int rasqal_query_results_next_triple(rasqal_query_results *query_results);
+
+/* Syntax result format */
+RASQAL_API
+int rasqal_query_results_is_syntax(rasqal_query_results* query_results);
+
+RASQAL_API
+int rasqal_query_results_write(raptor_iostream *iostr, rasqal_query_results *results, const char* name, const char* mime_type, raptor_uri *format_uri, raptor_uri *base_uri);
+RASQAL_API
+int rasqal_query_results_read(raptor_iostream *iostr, rasqal_query_results *results, const char* name, const char* mime_type, raptor_uri *format_uri, raptor_uri *base_uri);
+
+/* One more time */
+RASQAL_API
+int rasqal_query_results_rewind(rasqal_query_results* query_results);
+
+
+/**
+ * rasqal_query_results_format_flags:
+ * @RASQAL_QUERY_RESULTS_FORMAT_FLAG_READER: format can be read.
+ * @RASQAL_QUERY_RESULTS_FORMAT_FLAG_WRITER: format can be written.
+ *
+ * Bitflags for rasqal_query_results_formats_check() to find formats with features.
+ */
+typedef enum {
+ RASQAL_QUERY_RESULTS_FORMAT_FLAG_READER = 1,
+ RASQAL_QUERY_RESULTS_FORMAT_FLAG_WRITER = 2
+} rasqal_query_results_format_flags;
+
+
+RASQAL_API
+int rasqal_query_results_formats_check2(rasqal_world* world, const char *name, raptor_uri* uri, const char *mime_type, int flags);
+RASQAL_API RASQAL_DEPRECATED
+int rasqal_query_results_formats_check(rasqal_world* world, const char *name, raptor_uri* uri, const char *mime_type, int flags);
+RASQAL_API
+rasqal_query_results_formatter* rasqal_new_query_results_formatter(rasqal_world* world, const char *name, const char *mime_type, raptor_uri* format_uri);
+RASQAL_API
+rasqal_query_results_formatter* rasqal_new_query_results_formatter_for_content(rasqal_world* world, raptor_uri *uri, const char *mime_type, const unsigned char *buffer, size_t len, const unsigned char *identifier);
+RASQAL_API
+void rasqal_free_query_results_formatter(rasqal_query_results_formatter* formatter);
+RASQAL_API
+int rasqal_query_results_formatter_write(raptor_iostream *iostr, rasqal_query_results_formatter* formatter, rasqal_query_results* results, raptor_uri *base_uri);
+RASQAL_API
+int rasqal_query_results_formatter_read(rasqal_world* world, raptor_iostream *iostr, rasqal_query_results_formatter* formatter, rasqal_query_results* results, raptor_uri *base_uri);
+
+RASQAL_API
+int rasqal_query_iostream_write_escaped_counted_string(rasqal_query* query, raptor_iostream* iostr, const unsigned char* string, size_t len);
+RASQAL_API
+unsigned char* rasqal_query_escape_counted_string(rasqal_query* query, const unsigned char *string, size_t len, size_t* output_len_p);
+
+
+/* Data graph class */
+RASQAL_API
+rasqal_data_graph* rasqal_new_data_graph_from_uri(rasqal_world* world, raptor_uri* uri, raptor_uri* name_uri, unsigned int flags, const char* format_type, const char* format_name, raptor_uri* format_uri);
+RASQAL_API
+rasqal_data_graph* rasqal_new_data_graph_from_iostream(rasqal_world* world, raptor_iostream* iostr, raptor_uri* base_uri, raptor_uri* name_uri, unsigned int flags, const char* format_type, const char* format_name, raptor_uri* format_uri);
+RASQAL_API
+rasqal_data_graph* rasqal_new_data_graph_from_data_graph(rasqal_data_graph* dg);
+RASQAL_API
+void rasqal_free_data_graph(rasqal_data_graph* dg);
+RASQAL_API
+int rasqal_data_graph_print(rasqal_data_graph* dg, FILE* fh);
+
+
+/**
+ * rasqal_compare_flags:
+ * @RASQAL_COMPARE_NOCASE: String comparisons are case independent.
+ * @RASQAL_COMPARE_XQUERY: XQuery comparsion rules apply.
+ * @RASQAL_COMPARE_RDF: RDF Term comparsion rules apply.
+ * @RASQAL_COMPARE_URI: Allow comparison of URIs and allow strings to have a boolean value (unused; was for RDQL)
+ * @RASQAL_COMPARE_SAMETERM: SPARQL sameTerm() builtin rules apply.
+ *
+ * Flags for rasqal_expression_evaluate(), rasqal_literal_compare() or
+ * rasqal_literal_as_string_flags()
+ */
+typedef enum {
+ RASQAL_COMPARE_NOCASE = 1,
+ RASQAL_COMPARE_XQUERY = 2,
+ RASQAL_COMPARE_RDF = 4,
+ RASQAL_COMPARE_URI = 8,
+ RASQAL_COMPARE_SAMETERM = 16
+} rasqal_compare_flags;
+
+
+/**
+ * rasqal_random:
+ *
+ * Internal
+ */
+typedef struct rasqal_random_s rasqal_random;
+
+
+/**
+ * rasqal_evaluation_context:
+ * @world: rasqal world
+ * @base_uri: base URI of expression context (or NULL)
+ * @locator: locator or NULL
+ * @flags: expression comparison flags
+ * @seed: random seeed
+ * @random: random number generator object
+ *
+ * A context for evaluating an expression such as with
+ * rasqal_expression_evaluate2()
+ */
+typedef struct {
+ rasqal_world *world;
+ raptor_uri* base_uri;
+ raptor_locator *locator;
+ int flags;
+ unsigned int seed;
+ rasqal_random* random;
+} rasqal_evaluation_context;
+
+
+/* Expression class */
+RASQAL_API
+rasqal_expression* rasqal_new_0op_expression(rasqal_world* world, rasqal_op op);
+RASQAL_API
+rasqal_expression* rasqal_new_1op_expression(rasqal_world* world, rasqal_op op, rasqal_expression* arg);
+RASQAL_API
+rasqal_expression* rasqal_new_2op_expression(rasqal_world* world, rasqal_op op, rasqal_expression* arg1, rasqal_expression* arg2);
+RASQAL_API
+rasqal_expression* rasqal_new_3op_expression(rasqal_world* world, rasqal_op op, rasqal_expression* arg1, rasqal_expression* arg2, rasqal_expression* arg3);
+RASQAL_API
+rasqal_expression* rasqal_new_4op_expression(rasqal_world* world, rasqal_op op, rasqal_expression* arg1, rasqal_expression* arg2, rasqal_expression* arg3, rasqal_expression* arg4);
+RASQAL_API
+rasqal_expression* rasqal_new_string_op_expression(rasqal_world* world, rasqal_op op, rasqal_expression* arg1, rasqal_literal* literal);
+RASQAL_API
+rasqal_expression* rasqal_new_literal_expression(rasqal_world* world, rasqal_literal* literal);
+RASQAL_API
+rasqal_expression* rasqal_new_function_expression(rasqal_world* world, raptor_uri* name, raptor_sequence* args, raptor_sequence* params, unsigned int flags);
+RASQAL_API
+rasqal_expression* rasqal_new_aggregate_function_expression(rasqal_world* world, rasqal_op op, rasqal_expression* arg1, raptor_sequence* params, unsigned int flags);
+RASQAL_API
+rasqal_expression* rasqal_new_cast_expression(rasqal_world* world, raptor_uri* name, rasqal_expression *value);
+RASQAL_API
+rasqal_expression* rasqal_new_expr_seq_expression(rasqal_world* world, rasqal_op op, raptor_sequence* args);
+RASQAL_API
+rasqal_expression* rasqal_new_set_expression(rasqal_world* world, rasqal_op op, rasqal_expression* arg1, raptor_sequence* args);
+RASQAL_API
+rasqal_expression* rasqal_new_group_concat_expression(rasqal_world* world, unsigned int flags, raptor_sequence* args, rasqal_literal* separator);
+RASQAL_API
+rasqal_expression* rasqal_new_expression_from_expression(rasqal_expression* e);
+
+RASQAL_API
+void rasqal_free_expression(rasqal_expression* e);
+RASQAL_API
+void rasqal_expression_print_op(rasqal_expression* e, FILE* fh);
+RASQAL_API
+int rasqal_expression_print(rasqal_expression* e, FILE* fh);
+RASQAL_API RASQAL_DEPRECATED
+rasqal_literal* rasqal_expression_evaluate(rasqal_world *world, raptor_locator *locator, rasqal_expression* e, int flags);
+RASQAL_API
+rasqal_literal* rasqal_expression_evaluate2(rasqal_expression *e, rasqal_evaluation_context* eval_context, int *error_p);
+RASQAL_API
+const char* rasqal_expression_op_label(rasqal_op op);
+RASQAL_API
+int rasqal_expression_compare(rasqal_expression* e1, rasqal_expression* e2, int flags, int* error_p);
+
+/**
+ * rasqal_expression_visit_fn:
+ * @user_data: user data passed in with rasqal_expression_visit()
+ * @e: current expression
+ *
+ * User function to visit an expression and operate on it with
+ * rasqal_expression_visit()
+ *
+ * Return value: non-0 to truncate the visit
+ */
+typedef int (*rasqal_expression_visit_fn)(void *user_data, rasqal_expression *e);
+RASQAL_API
+int rasqal_expression_visit(rasqal_expression* e, rasqal_expression_visit_fn fn, void *user_data);
+
+RASQAL_API
+rasqal_evaluation_context* rasqal_new_evaluation_context(rasqal_world* world, raptor_locator* locator, int flags);
+RASQAL_API
+void rasqal_free_evaluation_context(rasqal_evaluation_context* eval_context);
+RASQAL_API
+int rasqal_evaluation_context_set_base_uri(rasqal_evaluation_context* eval_context, raptor_uri *base_uri);
+RASQAL_API
+int rasqal_evaluation_context_set_rand_seed(rasqal_evaluation_context* eval_context, unsigned int seed);
+
+
+/* Literal class */
+RASQAL_API
+rasqal_literal* rasqal_new_integer_literal(rasqal_world* world, rasqal_literal_type type, int integer);
+RASQAL_API
+rasqal_literal* rasqal_new_numeric_literal_from_long(rasqal_world* world, rasqal_literal_type type, long value);
+RASQAL_API
+rasqal_literal* rasqal_new_typed_literal(rasqal_world* world, rasqal_literal_type type, const unsigned char* string);
+RASQAL_API
+rasqal_literal* rasqal_new_double_literal(rasqal_world* world, double d);
+RASQAL_API
+rasqal_literal* rasqal_new_floating_literal(rasqal_world *world, rasqal_literal_type type, double d);
+RASQAL_API RASQAL_DEPRECATED
+rasqal_literal* rasqal_new_float_literal(rasqal_world* world, float f);
+RASQAL_API
+rasqal_literal* rasqal_new_uri_literal(rasqal_world* world, raptor_uri* uri);
+RASQAL_API
+rasqal_literal* rasqal_new_pattern_literal(rasqal_world* world, const unsigned char *pattern, const char *flags);
+RASQAL_API
+rasqal_literal* rasqal_new_string_literal(rasqal_world* world, const unsigned char *string, const char *language, raptor_uri *datatype, const unsigned char *datatype_qname);
+RASQAL_API
+rasqal_literal* rasqal_new_simple_literal(rasqal_world* world, rasqal_literal_type type, const unsigned char *string);
+RASQAL_API
+rasqal_literal* rasqal_new_boolean_literal(rasqal_world* world, int value);
+RASQAL_API
+rasqal_literal* rasqal_new_variable_literal(rasqal_world* world, rasqal_variable *variable);
+RASQAL_API
+rasqal_literal* rasqal_new_decimal_literal(rasqal_world* world, const unsigned char *string);
+RASQAL_API
+rasqal_literal* rasqal_new_decimal_literal_from_decimal(rasqal_world* world, const unsigned char *string, rasqal_xsd_decimal* decimal);
+RASQAL_API
+rasqal_literal* rasqal_new_datetime_literal_from_datetime(rasqal_world* world, rasqal_xsd_datetime* dt);
+
+
+RASQAL_API
+rasqal_literal* rasqal_new_literal_from_literal(rasqal_literal* l);
+RASQAL_API
+void rasqal_free_literal(rasqal_literal* l);
+RASQAL_API
+int rasqal_literal_print(rasqal_literal* l, FILE* fh);
+RASQAL_API
+const char* rasqal_literal_type_label(rasqal_literal_type type);
+RASQAL_API
+void rasqal_literal_print_type(rasqal_literal* l, FILE* fh);
+RASQAL_API
+rasqal_variable* rasqal_literal_as_variable(rasqal_literal* l);
+RASQAL_API
+const unsigned char* rasqal_literal_as_counted_string(rasqal_literal* l, size_t *len_p, int flags, int *error_p);
+RASQAL_API
+const unsigned char* rasqal_literal_as_string(rasqal_literal* l);
+RASQAL_API
+const unsigned char* rasqal_literal_as_string_flags(rasqal_literal* l, int flags, int *error_p);
+RASQAL_API
+rasqal_literal* rasqal_literal_as_node(rasqal_literal* l);
+RASQAL_API
+raptor_uri* rasqal_literal_datatype(rasqal_literal* l);
+RASQAL_API
+rasqal_literal* rasqal_literal_value(rasqal_literal* l);
+
+RASQAL_API
+int rasqal_literal_compare(rasqal_literal* l1, rasqal_literal* l2, int flags, int *error_p);
+RASQAL_API
+int rasqal_literal_equals(rasqal_literal* l1, rasqal_literal* l2);
+RASQAL_API
+int rasqal_literal_same_term(rasqal_literal* l1, rasqal_literal* l2);
+RASQAL_API
+rasqal_literal_type rasqal_literal_get_rdf_term_type(rasqal_literal* l);
+RASQAL_API
+rasqal_literal_type rasqal_literal_get_type(rasqal_literal* l);
+RASQAL_API
+char* rasqal_literal_get_language(rasqal_literal* l);
+RASQAL_API
+int rasqal_literal_is_rdf_literal(rasqal_literal* l);
+
+
+RASQAL_API
+rasqal_prefix* rasqal_new_prefix(rasqal_world* world, const unsigned char* prefix, raptor_uri* uri);
+RASQAL_API
+void rasqal_free_prefix(rasqal_prefix* p);
+RASQAL_API
+int rasqal_prefix_print(rasqal_prefix* p, FILE* fh);
+
+
+/* Row class */
+RASQAL_API
+rasqal_row* rasqal_new_row_for_size(rasqal_world* world, int size);
+RASQAL_API
+void rasqal_free_row(rasqal_row* row);
+RASQAL_API
+int rasqal_row_set_value_at(rasqal_row* row, int offset, rasqal_literal* value);
+
+
+/* Triple class */
+RASQAL_API
+rasqal_triple* rasqal_new_triple(rasqal_literal* subject, rasqal_literal* predicate, rasqal_literal* object);
+RASQAL_API
+rasqal_triple* rasqal_new_triple_from_triple(rasqal_triple* t);
+RASQAL_API
+void rasqal_free_triple(rasqal_triple* t);
+RASQAL_API
+int rasqal_triple_print(rasqal_triple* t, FILE* fh);
+RASQAL_API
+void rasqal_triple_set_origin(rasqal_triple* t, rasqal_literal *l);
+RASQAL_API
+rasqal_literal* rasqal_triple_get_origin(rasqal_triple* t);
+
+/* Variable class */
+RASQAL_API
+rasqal_variable* rasqal_new_variable_from_variable(rasqal_variable* v);
+RASQAL_API
+void rasqal_free_variable(rasqal_variable* v);
+RASQAL_API
+int rasqal_variable_print(rasqal_variable* v, FILE* fh);
+RASQAL_API
+void rasqal_variable_set_value(rasqal_variable* v, rasqal_literal* l);
+
+
+/* Variables Table */
+RASQAL_API
+rasqal_variables_table* rasqal_new_variables_table(rasqal_world* world);
+RASQAL_API
+void rasqal_free_variables_table(rasqal_variables_table* vt);
+RASQAL_API RASQAL_DEPRECATED
+rasqal_variable* rasqal_variables_table_add(rasqal_variables_table* vt, rasqal_variable_type type, const unsigned char *name, rasqal_literal *value);
+RASQAL_API
+rasqal_variable* rasqal_variables_table_add2(rasqal_variables_table* vt, rasqal_variable_type type, const unsigned char *name, size_t name_len, rasqal_literal *value);
+RASQAL_API
+int rasqal_variables_table_add_variable(rasqal_variables_table* vt, rasqal_variable* variable);
+RASQAL_API
+rasqal_variable* rasqal_variables_table_get_by_name(rasqal_variables_table* vt, rasqal_variable_type type, const unsigned char *name);
+RASQAL_API
+int rasqal_variables_table_contains(rasqal_variables_table* vt, rasqal_variable_type type, const unsigned char *name);
+
+/* memory functions */
+RASQAL_API
+void rasqal_free_memory(void *ptr);
+RASQAL_API
+void* rasqal_alloc_memory(size_t size);
+RASQAL_API
+void* rasqal_calloc_memory(size_t nmemb, size_t size);
+
+
+/* decimal functions */
+RASQAL_API
+rasqal_xsd_decimal* rasqal_new_xsd_decimal(rasqal_world* world);
+RASQAL_API
+void rasqal_free_xsd_decimal(rasqal_xsd_decimal* dec);
+RASQAL_API
+int rasqal_xsd_decimal_set_string(rasqal_xsd_decimal* dec, const char* string);
+RASQAL_API
+double rasqal_xsd_decimal_get_double(rasqal_xsd_decimal* dec);
+RASQAL_API
+long rasqal_xsd_decimal_get_long(rasqal_xsd_decimal* dec, int* error_p);
+RASQAL_API
+char* rasqal_xsd_decimal_as_string(rasqal_xsd_decimal* dec);
+RASQAL_API
+char* rasqal_xsd_decimal_as_counted_string(rasqal_xsd_decimal* dec, size_t* len_p);
+RASQAL_API
+int rasqal_xsd_decimal_set_long(rasqal_xsd_decimal* dec, long l);
+RASQAL_API
+int rasqal_xsd_decimal_set_double(rasqal_xsd_decimal* dec, double d);
+RASQAL_API
+int rasqal_xsd_decimal_print(rasqal_xsd_decimal* dec, FILE* stream);
+RASQAL_API
+int rasqal_xsd_decimal_add(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a, rasqal_xsd_decimal* b);
+RASQAL_API
+int rasqal_xsd_decimal_subtract(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a, rasqal_xsd_decimal* b);
+RASQAL_API
+int rasqal_xsd_decimal_multiply(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a, rasqal_xsd_decimal* b);
+RASQAL_API
+int rasqal_xsd_decimal_divide(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a, rasqal_xsd_decimal* b);
+RASQAL_API
+int rasqal_xsd_decimal_negate(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a);
+RASQAL_API
+int rasqal_xsd_decimal_compare(rasqal_xsd_decimal* a, rasqal_xsd_decimal* b);
+RASQAL_API
+int rasqal_xsd_decimal_equals(rasqal_xsd_decimal* a, rasqal_xsd_decimal* b);
+RASQAL_API
+int rasqal_xsd_decimal_is_zero(rasqal_xsd_decimal* d);
+RASQAL_API
+int rasqal_xsd_decimal_abs(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a);
+RASQAL_API
+int rasqal_xsd_decimal_round(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a);
+RASQAL_API
+int rasqal_xsd_decimal_ceil(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a);
+RASQAL_API
+int rasqal_xsd_decimal_floor(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a);
+
+
+/* date functions */
+RASQAL_API
+rasqal_xsd_date* rasqal_new_xsd_date(rasqal_world* world, const char *date_string);
+RASQAL_API
+void rasqal_free_xsd_date(rasqal_xsd_date* d);
+RASQAL_API
+char* rasqal_xsd_date_to_counted_string(const rasqal_xsd_date *date, size_t *len_p);
+RASQAL_API
+char* rasqal_xsd_date_to_string(const rasqal_xsd_date *d);
+RASQAL_API
+int rasqal_xsd_date_equals(const rasqal_xsd_date *d1, const rasqal_xsd_date *d2, int *incomparible_p);
+RASQAL_API
+int rasqal_xsd_date_compare(const rasqal_xsd_date *d1, const rasqal_xsd_date *d2, int *incomparible_p);
+
+/* datetime functions */
+RASQAL_API
+rasqal_xsd_datetime* rasqal_new_xsd_datetime(rasqal_world* world, const char *datetime_string);
+RASQAL_API
+rasqal_xsd_datetime* rasqal_new_xsd_datetime_from_unixtime(rasqal_world* world, time_t secs);
+RASQAL_API
+rasqal_xsd_datetime* rasqal_new_xsd_datetime_from_timeval(rasqal_world* world, struct timeval *tv);
+RASQAL_API
+rasqal_xsd_datetime* rasqal_new_xsd_datetime_from_xsd_date(rasqal_world* world, rasqal_xsd_date *date);
+RASQAL_API
+void rasqal_free_xsd_datetime(rasqal_xsd_datetime* dt);
+RASQAL_API
+char* rasqal_xsd_datetime_to_counted_string(const rasqal_xsd_datetime *dt, size_t *len_p);
+RASQAL_API
+char* rasqal_xsd_datetime_to_string(const rasqal_xsd_datetime *dt);
+RASQAL_API
+int rasqal_xsd_datetime_equals2(const rasqal_xsd_datetime *dt1, const rasqal_xsd_datetime *dt2, int *incomparible_p);
+RASQAL_API RASQAL_DEPRECATED
+int rasqal_xsd_datetime_equals(const rasqal_xsd_datetime *dt1, const rasqal_xsd_datetime *dt2);
+RASQAL_API
+int rasqal_xsd_datetime_compare2(const rasqal_xsd_datetime *dt1, const rasqal_xsd_datetime *dt2, int *incomparible_p);
+RASQAL_API RASQAL_DEPRECATED
+int rasqal_xsd_datetime_compare(const rasqal_xsd_datetime *dt1, const rasqal_xsd_datetime *dt2);
+RASQAL_API
+rasqal_xsd_decimal* rasqal_xsd_datetime_get_seconds_as_decimal(rasqal_world* world, rasqal_xsd_datetime* dt);
+RASQAL_API
+int rasqal_xsd_datetime_set_from_timeval(rasqal_xsd_datetime *dt, struct timeval *tv);
+RASQAL_API
+int rasqal_xsd_datetime_set_from_unixtime(rasqal_xsd_datetime* dt, time_t clock);
+RASQAL_API
+time_t rasqal_xsd_datetime_get_as_unixtime(rasqal_xsd_datetime* dt);
+RASQAL_API
+struct timeval* rasqal_xsd_datetime_get_as_timeval(rasqal_xsd_datetime *dt);
+RASQAL_API
+char* rasqal_xsd_datetime_get_timezone_as_counted_string(rasqal_xsd_datetime *dt, size_t *len_p);
+RASQAL_API
+char* rasqal_xsd_datetime_get_tz_as_counted_string(rasqal_xsd_datetime* dt, size_t *len_p);
+
+
+/* regex utilities */
+RASQAL_API
+char* rasqal_regex_replace(rasqal_world* world, raptor_locator* locator, const char* pattern, const char* regex_flags, const char* subject, size_t subject_len, const char* replace, size_t replace_len, size_t* result_len_p);
+
+
+/**
+ * rasqal_service:
+ *
+ * Rasqal SPARQL Protocol Service
+ */
+typedef struct rasqal_service_s rasqal_service;
+
+RASQAL_API
+rasqal_service* rasqal_new_service(rasqal_world* world, raptor_uri* service_uri, const unsigned char* query_string, raptor_sequence* data_graphs);
+RASQAL_API
+void rasqal_free_service(rasqal_service* svc);
+RASQAL_API
+rasqal_query_results* rasqal_service_execute(rasqal_service* svc);
+RASQAL_API
+int rasqal_service_set_www(rasqal_service* svc, raptor_www* www);
+RASQAL_API
+int rasqal_service_set_format(rasqal_service* svc, const char *format);
+
+
+
+/**
+ * rasqal_triple_parts:
+ * @RASQAL_TRIPLE_NONE: no parts
+ * @RASQAL_TRIPLE_SUBJECT: Subject present in a triple.
+ * @RASQAL_TRIPLE_PREDICATE: Predicate present in a triple.
+ * @RASQAL_TRIPLE_OBJECT: Object present in a triple.
+ * @RASQAL_TRIPLE_ORIGIN: Origin/graph present in a triple.
+ * @RASQAL_TRIPLE_GRAPH: Alias for RASQAL_TRIPLE_ORIGIN
+ * @RASQAL_TRIPLE_SPO: Subject, Predicate and Object present in a triple.
+ * @RASQAL_TRIPLE_SPOG: Subject, Predicate, Object, Graph present in a triple.
+ *
+ * Flags for parts of a triple.
+ */
+typedef enum {
+ RASQAL_TRIPLE_NONE = 0,
+ RASQAL_TRIPLE_SUBJECT = 1,
+ RASQAL_TRIPLE_PREDICATE= 2,
+ RASQAL_TRIPLE_OBJECT = 4,
+ RASQAL_TRIPLE_ORIGIN = 8,
+ RASQAL_TRIPLE_GRAPH = RASQAL_TRIPLE_ORIGIN,
+ RASQAL_TRIPLE_SPO = RASQAL_TRIPLE_SUBJECT | RASQAL_TRIPLE_PREDICATE | RASQAL_TRIPLE_OBJECT,
+ RASQAL_TRIPLE_SPOG = RASQAL_TRIPLE_SPO | RASQAL_TRIPLE_GRAPH
+} rasqal_triple_parts;
+
+
+
+/**
+ * rasqal_triples_match:
+ * @world: rasqal_world object
+ * @user_data: User data pointer for factory methods.
+ * @bind_match: The [4]array (s,p,o,origin) bindings against the current triple match only touching triple parts given. Returns parts that were bound or 0 on failure.
+ * @next_match: Move to next match.
+ * @is_end: Check for end of triple match - return non-0 if is end.
+ * @finish: Finish triples match and destroy any allocated memory.
+ * @is_exact: non-0 if triple to match is all literal constants
+ * @finished: >0 if the match has finished
+ *
+ * Triples match structure as initialised by #rasqal_triples_source
+ * method init_triples_match.
+ */
+struct rasqal_triples_match_s {
+ rasqal_world *world;
+
+ void *user_data;
+
+ rasqal_triple_parts (*bind_match)(struct rasqal_triples_match_s* rtm, void *user_data, rasqal_variable *bindings[4], rasqal_triple_parts parts);
+
+ void (*next_match)(struct rasqal_triples_match_s* rtm, void *user_data);
+
+ int (*is_end)(struct rasqal_triples_match_s* rtm, void *user_data);
+
+ void (*finish)(struct rasqal_triples_match_s* rtm, void *user_data);
+
+ int is_exact;
+
+ int finished;
+};
+typedef struct rasqal_triples_match_s rasqal_triples_match;
+
+
+/**
+ * rasqal_triple_meta:
+ * @bindings: Variable bindings for this triple+origin to set.
+ * @triples_match: The matcher that is setting these bindings.
+ * @context: Context data used by the matcher.
+ * @parts: Bitmask of #rasqal_triple_parts flags describing the parts of the triple pattern that will bind to variables. There may also be variables mentioned that are bound in other triple patterns even if @parts is 0.
+ * @is_exact: unused
+ * @executed: unused
+ *
+ * Metadata for triple pattern matching for one triple pattern.
+ */
+typedef struct {
+ /* triple (subject, predicate, object) and origin */
+ rasqal_variable* bindings[4];
+
+ rasqal_triples_match *triples_match;
+
+ void *context;
+
+ rasqal_triple_parts parts;
+
+ int is_exact;
+
+ int executed;
+} rasqal_triple_meta;
+
+
+/**
+ * RASQAL_TRIPLES_SOURCE_MIN_VERSION:
+ *
+ * Lowest accepted @rasqal_triples_source API version
+ */
+#define RASQAL_TRIPLES_SOURCE_MIN_VERSION 1
+
+/**
+ * RASQAL_TRIPLES_SOURCE_MAX_VERSION:
+ *
+ * Highest accepted @rasqal_triples_source API version
+ */
+#define RASQAL_TRIPLES_SOURCE_MAX_VERSION 2
+
+
+/**
+ * rasqal_triples_source_feature:
+ * @RASQAL_TRIPLES_SOURCE_FEATURE_NONE: No feature
+ * @RASQAL_TRIPLES_SOURCE_FEATURE_IOSTREAM_DATA_GRAPH: Support raptor_iostream data graphs
+ *
+ * Optional features that may be supported by a triple source factory
+ */
+typedef enum {
+ RASQAL_TRIPLES_SOURCE_FEATURE_NONE,
+ RASQAL_TRIPLES_SOURCE_FEATURE_IOSTREAM_DATA_GRAPH
+} rasqal_triples_source_feature;
+
+
+/**
+ * rasqal_triples_source:
+ * @version: API version - only V1 is defined for now
+ * @query: Source for this query.
+ * @user_data: Context user data passed into the factory methods.
+ * @init_triples_match: Factory method to initialize a new #rasqal_triples_match.
+ * @triple_present: Factory method to return presence or absence of a complete triple.
+ * @free_triples_source: Factory method to deallocate resources.
+ * @support_feature: Factory method to test support for a feature, returning non-0 if supported
+ *
+ * Triples source as initialised by a #rasqal_triples_source_factory.
+ */
+struct rasqal_triples_source_s {
+ int version;
+
+ rasqal_query* query;
+
+ void *user_data;
+
+ /* API v1 */
+ int (*init_triples_match)(rasqal_triples_match* rtm, struct rasqal_triples_source_s* rts, void *user_data, rasqal_triple_meta *m, rasqal_triple *t);
+
+ int (*triple_present)(struct rasqal_triples_source_s* rts, void *user_data, rasqal_triple *t);
+
+ void (*free_triples_source)(void *user_data);
+
+ /* API v2 onwards */
+ int (*support_feature)(void *user_data, rasqal_triples_source_feature feature);
+};
+typedef struct rasqal_triples_source_s rasqal_triples_source;
+
+
+/**
+ * RASQAL_TRIPLES_SOURCE_FACTORY_MIN_VERSION:
+ *
+ * Lowest accepted @rasqal_triples_source_factory API version
+ */
+#define RASQAL_TRIPLES_SOURCE_FACTORY_MIN_VERSION 1
+
+/**
+ * RASQAL_TRIPLES_SOURCE_FACTORY_MAX_VERSION:
+ *
+ * Highest accepted @rasqal_triples_source_factory API version
+ */
+#define RASQAL_TRIPLES_SOURCE_FACTORY_MAX_VERSION 3
+
+
+/**
+ * rasqal_triples_error_handler:
+ * @query: query object
+ * @locator: error locator (or NULL)
+ * @message: error message
+ *
+ * Triples source factory error handler callback.
+ */
+typedef void (*rasqal_triples_error_handler)(rasqal_query* query, raptor_locator* locator, const char* message);
+
+
+/**
+ * rasqal_triples_error_handler2:
+ * @world: world object
+ * @locator: error locator (or NULL)
+ * @message: error message
+ *
+ * Triples source factory error handler callback.
+ */
+typedef void (*rasqal_triples_error_handler2)(rasqal_world* world, raptor_locator* locator, const char* message);
+
+
+/**
+ * rasqal_triples_source_factory:
+ * @version: API factory version from 1 to 3
+ * @user_data: User data for triples_source_factory.
+ * @user_data_size: Size of @user_data for new_triples_source.
+ * @new_triples_source: Create a new triples source - returns non-zero on failure &lt; 0 is a 'no rdf data error', &gt; 0 is an unspecified error. Error messages are generated by rasqal internally. (V1)
+ * @init_triples_source: Initialise a new triples source V2 for a particular source URI/base URI and syntax. Returns non-zero on failure with errors reported via the handler callback by the implementation. (V2)
+ * @init_triples_source2: Initialise a new triples source V3 for a particular source URI/base URI and syntax and given data graphs. Returns non-zero on failure with errors reported via the handler callback by the implementation. If bit 0 of flags is 1, enforce RAPTOR_FEATURE_NO_NET (V3)
+ *
+ * A factory that initialises #rasqal_triples_source structures to
+ * returning matches to a triple pattern across the dataset formed
+ * from the data graphs recorded in the @query object.
+ */
+typedef struct {
+ int version;
+
+ void *user_data;
+ size_t user_data_size;
+
+ /* API v1 */
+ int (*new_triples_source)(rasqal_query* query, void *factory_user_data, void *user_data, rasqal_triples_source* rts);
+ /* API v2 onwards */
+ int (*init_triples_source)(rasqal_query* query, void *factory_user_data, void *user_data, rasqal_triples_source* rts, rasqal_triples_error_handler handler);
+ /* API v3 onwards */
+ int (*init_triples_source2)(rasqal_world* world, raptor_sequence* data_graphs, void *factory_user_data, void *user_data, rasqal_triples_source *rts, rasqal_triples_error_handler2 handler, unsigned int flags);
+} rasqal_triples_source_factory;
+
+
+/**
+ * rasqal_triples_source_factory_register_fn:
+ * @factory: factory to register
+ *
+ * Register a factory for generating triples sources #rasqal_triples_source
+ *
+ * Return value: non-0 on failure
+ */
+typedef int (*rasqal_triples_source_factory_register_fn)(rasqal_triples_source_factory *factory);
+
+
+/* set the triples_source_factory */
+RASQAL_API
+int rasqal_set_triples_source_factory(rasqal_world* world, rasqal_triples_source_factory_register_fn register_fn, void* user_data);
+
+
+
+/* The info below is solely for gtk-doc - ignore it */
+
+/**
+ * raptor_world:
+ *
+ * Internal
+ */
+
+/**
+ * RASQAL_QUERY_RESULTS_FORMATTER_DECLARED:
+ *
+ * Internal
+ */
+
+/**
+ * RASQAL_WORLD_DECLARED:
+ *
+ * Internal
+ */
+
+
+/**
+ * RASQAL_LITERAL_UDT_DEFINED
+ *
+ * Internal
+ */
+
+/**
+ * rasqal_expression_s:
+ * @world: Internal
+ * @usage: Internal
+ * @op: Internal
+ * @arg1: Internal
+ * @arg2: Internal
+ * @arg3: Internal
+ * @literal: Internal
+ * @value: Internal
+ * @name: Internal
+ * @args: Internal
+ * @params: Internal
+ * @flags: Internal
+ * @arg4: Internal
+ *
+ * Internal - see #rasqal_expression.
+ *
+ */
+
+/**
+ * bind_match:
+ * @rtm: triples match context
+ * @user_data: user data
+ * @bindings: variable binding for parts of triple (s, p, o, g)
+ * @parts: parts of triple to match
+ *
+ * Internal - see #rasqal_triples_match
+ *
+ * Return value: match parts
+*/
+
+/**
+ * next_match:
+ * @rtm: triples match context
+ * @user_data: user data
+ *
+ * Internal - see #rasqal_triples_match
+ */
+
+/**
+ * is_end:
+ * @rtm: triples match context
+ * @user_data: user data
+ *
+ * Internal - see #rasqal_triples_match
+ *
+ * Return value: non-0 if end of match
+ */
+
+/**
+ * finish:
+ * @rtm: triples match context
+ * @user_data: user data
+ *
+ * Internal - see #rasqal_triples_match
+ */
+
+/**
+ * init_triples_match:
+ * @rtm: triples match context
+ * @rts: triples match source
+ * @user_data: user data
+ * @m: triple meta
+ * @t: triple
+ *
+ * Internal - see #rasqal_triples_source
+ *
+ * Return value: non-0 on failure
+ */
+
+/**
+ * triple_present:
+ * @rts: triples match source
+ * @user_data: user data
+ * @t: triple to test for presence
+ *
+ * Internal - see #rasqal_triples_source
+ *
+ * Return value: non-0 on failure
+ */
+
+/**
+ * free_triples_source:
+ * @user_data: user data
+ *
+ * Internal - see #rasqal_triples_source
+ */
+
+/**
+ * support_feature:
+ * @user_data: user data
+ * @feature: feature to test
+ *
+ * Internal - see #rasqal_triples_source
+ *
+ * Return value: non-0 if supported
+ */
+
+/**
+ * rasqal_variables_table:
+ *
+ * Internal - for now
+ */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/external/redland/rasqal/rpath.patch b/external/redland/rasqal/rpath.patch
new file mode 100644
index 000000000..c0eed7725
--- /dev/null
+++ b/external/redland/rasqal/rpath.patch
@@ -0,0 +1,21 @@
+--- configure
++++ configure
+@@ -9843,6 +9843,7 @@
+ else
+ ld_shlibs=no
+ fi
++hardcode_libdir_flag_spec=
+ ;;
+
+ netbsd* | netbsdelf*-gnu)
+--- utils/Makefile.in
++++ utils/Makefile.in
+@@ -373,7 +373,7 @@
+ $(man_MANS) \
+ roqet.html
+
+-all: all-am
++all:
+
+ .SUFFIXES:
+ .SUFFIXES: .c .lo .o .obj
diff --git a/external/redland/redland/clang-cl.patch b/external/redland/redland/clang-cl.patch
new file mode 100644
index 000000000..b5a7271fb
--- /dev/null
+++ b/external/redland/redland/clang-cl.patch
@@ -0,0 +1,20 @@
+--- src/librdf.h
++++ src/librdf.h
+@@ -74,7 +74,7 @@
+ /* Use gcc 3.1+ feature to allow marking of deprecated API calls.
+ * This gives a warning during compiling.
+ */
+-#if ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3
++#if (defined __GNUC__ && (( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3)) || defined __clang__
+ #define REDLAND_DEPRECATED __attribute__((deprecated))
+ #define REDLAND_NORETURN __attribute__((__noreturn__))
+ #else
+@@ -83,7 +83,7 @@
+ #endif
+
+
+-#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
++#if (defined __GNUC__ && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4))) || defined __clang__
+ #define REDLAND_PRINTF_FORMAT(string_index, first_to_check_index) \
+ __attribute__((__format__(__printf__, string_index, first_to_check_index)))
+ #else
diff --git a/external/redland/redland/librdf.h b/external/redland/redland/librdf.h
new file mode 100644
index 000000000..44674c583
--- /dev/null
+++ b/external/redland/redland/librdf.h
@@ -0,0 +1,434 @@
+/* -*- Mode: c; c-basic-offset: 2 -*-
+ *
+ * redland.h - Redland RDF Application Framework public API
+ *
+ * Copyright (C) 2000-2011, David Beckett http://www.dajobe.org/
+ * Copyright (C) 2000-2005, University of Bristol, UK http://www.bristol.ac.uk/
+ *
+ * This package is Free Software and part of Redland http://librdf.org/
+ *
+ * It is licensed under the following three licenses as alternatives:
+ * 1. GNU Lesser General Public License (LGPL) V2.1 or any newer version
+ * 2. GNU General Public License (GPL) V2 or any newer version
+ * 3. Apache License, V2.0 or any newer version
+ *
+ * You may not use this file except in compliance with at least one of
+ * the above three licenses.
+ *
+ * See LICENSE.html or LICENSE.txt at the top of this package for the
+ * complete terms and further detail along with the license texts for
+ * the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively.
+ *
+ *
+ */
+
+
+#ifndef LIBRDF_H
+#define LIBRDF_H
+
+#ifndef LIBRDF_OBJC_FRAMEWORK
+/* raptor */
+#include <raptor2.h>
+/* rasqal: uses raptor */
+#include <rasqal.h>
+/* librdf: uses rasqal and raptor */
+#else
+#include <Redland/raptor2.h>
+#include <Redland/rasqal.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdio.h>
+
+#ifndef REDLAND_API
+# ifdef _WIN32
+# ifdef __GNUC__
+# undef _declspec
+# define _declspec(x) __declspec(x)
+# endif
+# ifdef REDLAND_STATIC
+# define REDLAND_API
+# else
+# ifdef LIBRDF_INTERNAL
+# define REDLAND_API _declspec(dllexport)
+# else
+# define REDLAND_API _declspec(dllimport)
+# endif
+# endif
+# else
+# define REDLAND_API
+# endif
+#endif
+
+#ifndef REDLAND_CALLBACK_STDCALL
+# if defined(_WIN32) && defined(USE_STDCALL_CALLBACKS)
+# define REDLAND_CALLBACK_STDCALL _stdcall
+# else
+# define REDLAND_CALLBACK_STDCALL
+# endif
+#endif
+
+/* Use gcc 3.1+ feature to allow marking of deprecated API calls.
+ * This gives a warning during compiling.
+ */
+#if ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3
+#define REDLAND_DEPRECATED __attribute__((deprecated))
+#define REDLAND_NORETURN __attribute__((__noreturn__))
+#else
+#define REDLAND_DEPRECATED
+#define REDLAND_NORETURN
+#endif
+
+
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
+#define REDLAND_PRINTF_FORMAT(string_index, first_to_check_index) \
+ __attribute__((__format__(__printf__, string_index, first_to_check_index)))
+#else
+#define REDLAND_PRINTF_FORMAT(string_index, first_to_check_index)
+#endif
+
+
+/* Public defines */
+
+/**
+ * LIBRDF_VERSION:
+ *
+ * Redland librdf library version number
+ *
+ * Format: major * 10000 + minor * 100 + release
+ */
+#define LIBRDF_VERSION 10017
+
+/**
+ * LIBRDF_VERSION_STRING:
+ *
+ * Redland librdf library version string
+ */
+#define LIBRDF_VERSION_STRING "1.0.17"
+
+/**
+ * LIBRDF_VERSION_MAJOR:
+ *
+ * Redland librdf library major version
+ */
+#define LIBRDF_VERSION_MAJOR 1
+
+/**
+ * LIBRDF_VERSION_MINOR:
+ *
+ * Redland librdf library minor version
+ */
+#define LIBRDF_VERSION_MINOR 0
+
+/**
+ * LIBRDF_VERSION_RELEASE:
+ *
+ * Redland librdf library release
+ */
+#define LIBRDF_VERSION_RELEASE 17
+
+
+
+/* Public typedefs (references to private structures) */
+
+/**
+ * librdf_world:
+ *
+ * Redland world class.
+ */
+typedef struct librdf_world_s librdf_world;
+
+/**
+ * librdf_hash:
+ *
+ * Redland hash class.
+ */
+typedef struct librdf_hash_s librdf_hash;
+
+/**
+ * librdf_hash_cursor:
+ *
+ * Redland hash cursor class.
+ */
+typedef struct librdf_hash_cursor_s librdf_hash_cursor;
+
+/**
+ * librdf_digest:
+ *
+ * Redland content digest class.
+ */
+typedef struct librdf_digest_s librdf_digest;
+
+/**
+ * librdf_digest_factory:
+ *
+ * Redland digest factory class.
+ */
+typedef struct librdf_digest_factory_s librdf_digest_factory;
+
+/**
+ * librdf_uri:
+ *
+ * Redland URI class.
+ */
+typedef struct raptor_uri_s librdf_uri;
+
+/**
+ * librdf_list:
+ *
+ * Redland list class.
+ */
+typedef struct librdf_list_s librdf_list;
+
+/**
+ * librdf_iterator:
+ *
+ * Redland iterator class.
+ */
+typedef struct librdf_iterator_s librdf_iterator;
+
+/**
+ * librdf_node:
+ *
+ * Redland node class.
+ */
+typedef raptor_term librdf_node;
+
+/**
+ * librdf_statement:
+ *
+ * Redland statement class.
+ */
+typedef raptor_statement librdf_statement;
+
+/**
+ * librdf_model:
+ *
+ * Redland model class.
+ */
+typedef struct librdf_model_s librdf_model;
+
+/**
+ * librdf_model_factory:
+ *
+ * Redland model factory class.
+ */
+typedef struct librdf_model_factory_s librdf_model_factory;
+
+/**
+ * librdf_storage:
+ *
+ * Redland storage class.
+ */
+typedef struct librdf_storage_s librdf_storage;
+
+/**
+ * librdf_storage_factory:
+ *
+ * Redland storage factory class.
+ */
+typedef struct librdf_storage_factory_s librdf_storage_factory;
+
+/**
+ * librdf_stream:
+ *
+ * Redland stream class.
+ */
+typedef struct librdf_stream_s librdf_stream;
+
+/**
+ * librdf_parser:
+ *
+ * Redland parser class.
+ */
+typedef struct librdf_parser_s librdf_parser;
+
+/**
+ * librdf_parser_factory:
+ *
+ * Redland parser factory class.
+ */
+typedef struct librdf_parser_factory_s librdf_parser_factory;
+
+/**
+ * librdf_query:
+ *
+ * Redland query class.
+ */
+typedef struct librdf_query_s librdf_query;
+
+/**
+ * librdf_query_factory:
+ *
+ * Redland query factory class.
+ */
+typedef struct librdf_query_factory_s librdf_query_factory;
+
+/**
+ * librdf_query_results:
+ *
+ * Redland query results class.
+ */
+typedef struct librdf_query_results_s librdf_query_results;
+
+/**
+ * librdf_query_results_formatter:
+ *
+ * Redland query results formatter class.
+ */
+typedef struct librdf_query_results_formatter_s librdf_query_results_formatter;
+
+/**
+ * librdf_serializer:
+ *
+ * Redland serializer class.
+ */
+typedef struct librdf_serializer_s librdf_serializer;
+
+/**
+ * librdf_serializer_factory:
+ *
+ * Redland serializer factory class.
+ */
+typedef struct librdf_serializer_factory_s librdf_serializer_factory;
+
+
+/* Public statics */
+
+/**
+ * librdf_short_copyright_string:
+ *
+ * Short copyright string (one line).
+ */
+REDLAND_API
+extern const char * const librdf_short_copyright_string;
+
+/**
+ * librdf_copyright_string:
+ *
+ * Copyright string (multiple lines).
+ */
+REDLAND_API
+extern const char * const librdf_copyright_string;
+
+/**
+ * librdf_version_string:
+ *
+ * Redland librdf version as a string.
+ */
+REDLAND_API
+extern const char * const librdf_version_string;
+
+/**
+ * librdf_version_major:
+ *
+ * Redland librdf major version number.
+ */
+REDLAND_API
+extern const unsigned int librdf_version_major;
+
+/**
+ * librdf_version_minor:
+ *
+ * Redland librdf minor version number.
+ */
+REDLAND_API
+extern const unsigned int librdf_version_minor;
+
+/**
+ * librdf_version_release:
+ *
+ * Redland librdf release version number.
+ */
+REDLAND_API
+extern const unsigned int librdf_version_release;
+
+/**
+ * librdf_version_decimal:
+ *
+ * Redland librdf version as a decimal number.
+ *
+ * Format: major * 10000 + minor * 100 + release
+ */
+REDLAND_API
+extern const unsigned int librdf_version_decimal;
+
+/**
+ * librdf_license_string:
+ *
+ * Redland librdf license string.
+ */
+REDLAND_API
+extern const char * const librdf_license_string;
+
+/**
+ * librdf_home_url_string:
+ *
+ * Redland librdf home page URL.
+ */
+REDLAND_API
+extern const char * const librdf_home_url_string;
+
+/* Required for va_list in error handler function registrations
+ * which are in the public API
+ */
+#include <stdarg.h>
+
+
+/* internal interfaces */
+#ifdef LIBRDF_INTERNAL
+#include <rdf_internal.h>
+#endif
+
+/* public interfaces */
+
+/* FIXME: Should be replaced with automatically pulled
+ * definitions from the listed rdf_*.h header files.
+ */
+
+#ifndef LIBRDF_OBJC_FRAMEWORK
+#include <rdf_log.h>
+#include <rdf_digest.h>
+#include <rdf_hash.h>
+#include <rdf_init.h>
+#include <rdf_iterator.h>
+#include <rdf_uri.h>
+#include <rdf_node.h>
+#include <rdf_concepts.h>
+#include <rdf_statement.h>
+#include <rdf_model.h>
+#include <rdf_storage.h>
+#include <rdf_parser.h>
+#include <rdf_raptor.h>
+#include <rdf_serializer.h>
+#include <rdf_stream.h>
+#include <rdf_query.h>
+#include <rdf_utf8.h>
+#else
+#include <Redland/rdf_log.h>
+#include <Redland/rdf_digest.h>
+#include <Redland/rdf_hash.h>
+#include <Redland/rdf_init.h>
+#include <Redland/rdf_iterator.h>
+#include <Redland/rdf_uri.h>
+#include <Redland/rdf_node.h>
+#include <Redland/rdf_concepts.h>
+#include <Redland/rdf_statement.h>
+#include <Redland/rdf_model.h>
+#include <Redland/rdf_storage.h>
+#include <Redland/rdf_parser.h>
+#include <Redland/rdf_raptor.h>
+#include <Redland/rdf_serializer.h>
+#include <Redland/rdf_stream.h>
+#include <Redland/rdf_query.h>
+#include <Redland/rdf_utf8.h>
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/external/redland/redland/libtool.patch b/external/redland/redland/libtool.patch
new file mode 100644
index 000000000..b0baae661
--- /dev/null
+++ b/external/redland/redland/libtool.patch
@@ -0,0 +1,27 @@
+--- build/ltmain.sh
++++ build/ltmain.sh
+@@ -5301,6 +5301,12 @@
+ prev=
+ continue
+ ;;
++ mllvm)
++ # Clang does not use LLVM to link, so we can simply discard any
++ # '-mllvm $arg' options when doing the link step.
++ prev=
++ continue
++ ;;
+ objectlist)
+ if test -f "$arg"; then
+ save_arg=$arg
+@@ -5639,6 +5645,11 @@
+ continue
+ ;;
+
++ -mllvm)
++ prev=mllvm
++ continue
++ ;;
++
+ -module)
+ module=yes
+ continue
diff --git a/external/redland/redland/redland-android.patch.1 b/external/redland/redland/redland-android.patch.1
new file mode 100644
index 000000000..c28fa19ff
--- /dev/null
+++ b/external/redland/redland/redland-android.patch.1
@@ -0,0 +1,14 @@
+No sonames on Android
+
+--- a/configure 2013-03-29 19:46:34.922901756 +0100
++++ b/configure 2013-03-29 19:46:56.051901574 +0100
+@@ -10267,7 +10267,7 @@
+ *Sun\ F*) # Sun Fortran 8.3
+ tmp_sharedflag='-G' ;;
+ esac
+- archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
++ archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags -o $lib'
+
+ if test "x$supports_anon_versioning" = xyes; then
+ archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
+
diff --git a/external/redland/redland/redland-bundled-soname.patch.1 b/external/redland/redland/redland-bundled-soname.patch.1
new file mode 100644
index 000000000..867cd81e2
--- /dev/null
+++ b/external/redland/redland/redland-bundled-soname.patch.1
@@ -0,0 +1,13 @@
+rhbz#809466 change soname of bundled redland libs
+
+--- a/src/Makefile.in 2013-03-30 17:43:48.127008037 +0100
++++ b/src/Makefile.in 2013-03-30 17:44:19.294007769 +0100
+@@ -625,7 +625,7 @@
+ rdf_parser_raptor.c
+
+ EXTRA_DIST = redland.spec redland.spec.in mysql-v1.ttl mysql-v2.ttl
+-librdf_la_LDFLAGS = -version-info @LIBRDF_LIBTOOL_VERSION@ \
++librdf_la_LDFLAGS = -version-info @LIBRDF_LIBTOOL_VERSION@ -release lo \
+ @LIBRDF_LDFLAGS@ @LIBRDF_EXTERNAL_LIBS@
+
+ pkgdata_DATA = $(am__append_13)
diff --git a/external/redland/redland/redland-format.patch.0 b/external/redland/redland/redland-format.patch.0
new file mode 100644
index 000000000..7bd62a8bb
--- /dev/null
+++ b/external/redland/redland/redland-format.patch.0
@@ -0,0 +1,10 @@
+--- src/rdf_log.c
++++ src/rdf_log.c
+@@ -136,6 +136,7 @@
+ char *buffer = LIBRDF_MALLOC(char*, slocator_len + 2);
+ *buffer=' ';
+ raptor_locator_format(buffer + 1, slocator_len, (raptor_locator*)locator);
++ buffer[slocator_len + 1] = '\0';
+ fputs(buffer, stderr);
+ LIBRDF_FREE(char*, buffer);
+ }
diff --git a/external/redland/redland/redland-freebsd.patch.1 b/external/redland/redland/redland-freebsd.patch.1
new file mode 100644
index 000000000..349f3a197
--- /dev/null
+++ b/external/redland/redland/redland-freebsd.patch.1
@@ -0,0 +1,28 @@
+Usual patch to produce Linux-like .so files on FreeBSD
+
+--- a/build/ltmain.sh 2008-02-02 22:28:24.000000000 +0900
++++ b/build/ltmain.sh 2008-07-08 11:58:42.000000000 +0900
+@@ -7341,9 +7341,9 @@
+ revision="$number_revision"
+ ;;
+ freebsd-aout|freebsd-elf|qnx|sunos)
+- current="$number_major"
+- revision="$number_minor"
+- age="0"
++ current=`expr $number_major + $number_minor`
++ age="$number_minor"
++ revision="$number_revision"
+ ;;
+ irix|nonstopux)
+ func_arith $number_major + $number_minor
+@@ -7420,8 +7420,8 @@
+ ;;
+
+ freebsd-elf)
+- major=".$current"
+- versuffix=".$current"
++ major=.`expr $current - $age`
++ versuffix="$major.$age.$revision"
+ ;;
+
+ irix | nonstopux)
diff --git a/external/redland/redland/redland-msvc.patch.1 b/external/redland/redland/redland-msvc.patch.1
new file mode 100644
index 000000000..e1f96b42a
--- /dev/null
+++ b/external/redland/redland/redland-msvc.patch.1
@@ -0,0 +1,123 @@
+--- redland.orig/src/win32_rdf_config.h 2015-09-02 23:12:12.894126138 +0200
++++ redland/src/win32_rdf_config.h 2015-09-02 23:23:54.600173246 +0200
+@@ -43,7 +43,6 @@
+ /* MS names for these functions */
+ // next line breaks build on wntmsci12
+ //#define vsnprintf _vsnprintf
+-#define snprintf _snprintf
+ #define access _access
+ #define stricmp _stricmp
+ #define strnicmp _strnicmp
+@@ -75,40 +78,40 @@
+ */
+
+ /* BDB has close method with 2 args */
+-#define HAVE_BDB_CLOSE_2_ARGS 1
++// #define HAVE_BDB_CLOSE_2_ARGS 1
+
+ /* BDB defines DBC */
+-#define HAVE_BDB_CURSOR 1
++// #define HAVE_BDB_CURSOR 1
+
+ /* BDB cursor method has 4 arguments */
+-#define HAVE_BDB_CURSOR_4_ARGS 1
++// #define HAVE_BDB_CURSOR_4_ARGS 1
+
+ /* BDB defines DB_TXN */
+-#define HAVE_BDB_DB_TXN 1
++// #define HAVE_BDB_DB_TXN 1
+
+ /* BDB has fd method with 2 args */
+-#define HAVE_BDB_FD_2_ARGS 1
++// #define HAVE_BDB_FD_2_ARGS 1
+
+ /* Have BDB hash support */
+-#define HAVE_BDB_HASH 1
++// #define HAVE_BDB_HASH 1
+
+ /* BDB has open method with 6 args */
+ /* #undef HAVE_BDB_OPEN_6_ARGS */
+
+ /* BDB has open method with 7 args */
+-#define HAVE_BDB_OPEN_7_ARGS 1
++// #define HAVE_BDB_OPEN_7_ARGS 1
+
+ /* BDB has set_flags method */
+-#define HAVE_BDB_SET_FLAGS 1
++// #define HAVE_BDB_SET_FLAGS 1
+
+ /* BDB has dbopen method */
+ /* #undef HAVE_DBOPEN */
+
+ /* BDB has db_create method */
+-#define HAVE_DB_CREATE 1
++// #define HAVE_DB_CREATE 1
+
+ /* Define to 1 if you have the <db.h> header file. */
+-#define HAVE_DB_H 1
++// #define HAVE_DB_H 1
+
+ /* Define to 1 if you have the <dlfcn.h> header file. */
+ /* undef HAVE_DLFCN_H */
+@@ -141,13 +144,13 @@
+ /* #undef HAVE_LIBWWW */
+
+ /* Have local MD5 digest */
+-#define HAVE_LOCAL_MD5_DIGEST 1
++// #define HAVE_LOCAL_MD5_DIGEST 1
+
+ /* Have local RIPEMD160 digest */
+ /* #undef HAVE_LOCAL_RIPEMD160_DIGEST */
+
+ /* Have local SHA1 digest */
+-#define HAVE_LOCAL_SHA1_DIGEST 1
++// #define HAVE_LOCAL_SHA1_DIGEST 1
+
+ /* Define to 1 if you have the <memory.h> header file. */
+ #define HAVE_MEMORY_H 1
+@@ -159,7 +162,7 @@
+ #define HAVE_MKTEMP 1
+
+ /* MySQL libraries are present */
+-#define HAVE_MYSQL 1
++// #define HAVE_MYSQL 1
+
+ /* Define to 1 if you have the <openssl/crypto.h> header file. */
+ /* #undef HAVE_OPENSSL_CRYPTO_H */
+@@ -261,7 +267,7 @@
+ /*#undef STORAGE_POSTGRESQL*/
+
+ /* Building SQLite storage */
+-#define STORAGE_SQLITE 1
++// #define STORAGE_SQLITE 1
+
+ /* Building 3store storage */
+ /*#undef STORAGE_TSTORE*/
+@@ -288,11 +288,11 @@
+ #include <io.h>
+ #include <memory.h>
+
+-/* get _isnan() since it is not in math.h */
+-#include <float.h>
+-#ifndef isnan
+-#define isnan(d) (_isnan(d))
+-#endif
++// /* get _isnan() since it is not in math.h */
++// #include <float.h>
++// #ifndef isnan
++// #define isnan(d) (_isnan(d))
++// #endif
+
+ #ifdef __cplusplus
+ }
+--- redland.orig/src/rdf_init.c 2015-09-02 23:12:12.894126138 +0200
++++ redland/src/rdf_init.c 2015-09-02 23:23:54.600173246 +0200
+@@ -42,6 +42,8 @@
+ #endif
+ #ifdef HAVE_UNISTD_H
+ #include <unistd.h> /* for getpid() */
++#else
++#include <process.h>
+ #endif
+
+ /* for gettimeofday */
diff --git a/external/redland/redland/redland-xcompile.patch.1 b/external/redland/redland/redland-xcompile.patch.1
new file mode 100644
index 000000000..2635359e7
--- /dev/null
+++ b/external/redland/redland/redland-xcompile.patch.1
@@ -0,0 +1,15 @@
+No point in creating example or util executables when cross-compiling.
+(Especially as doing it anyway wouldn't work without tweaks to have it find
+libxml2 and libm, at least for Android.)
+
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -395,7 +395,7 @@
+ DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc
+
+ # Subdirectories to build/install/distribute etc.
+-SUBDIRS = $(subdirs) src examples utils demos docs data scripts
++SUBDIRS = $(subdirs) src docs data scripts
+ EXTRA_DIST = \
+ ChangeLog.1 ChangeLog.2 ChangeLog.3 ChangeLog.4 \
+ ChangeLog.5 ChangeLog.6 ChangeLog.7 ChangeLog.8 ChangeLog.9 ChangeLog.10 \
diff --git a/external/redland/redland/rpath.patch b/external/redland/redland/rpath.patch
new file mode 100644
index 000000000..ec8c765d5
--- /dev/null
+++ b/external/redland/redland/rpath.patch
@@ -0,0 +1,10 @@
+--- configure
++++ configure
+@@ -10308,6 +10308,7 @@
+ else
+ ld_shlibs=no
+ fi
++hardcode_libdir_flag_spec=
+ ;;
+
+ netbsd* | netbsdelf*-gnu)