diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/CMakeLists.txt | 26 | ||||
-rw-r--r-- | utils/Makefile.am | 91 | ||||
-rw-r--r-- | utils/Makefile.in | 877 | ||||
-rw-r--r-- | utils/getopt.c | 157 | ||||
-rw-r--r-- | utils/rapper.1 | 192 | ||||
-rw-r--r-- | utils/rapper.c | 972 | ||||
-rw-r--r-- | utils/rapper.html | 0 | ||||
-rw-r--r-- | utils/raptor_getopt.h | 21 | ||||
-rw-r--r-- | utils/rdfdiff.c | 1069 |
9 files changed, 3405 insertions, 0 deletions
diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt new file mode 100644 index 0000000..0067e4c --- /dev/null +++ b/utils/CMakeLists.txt @@ -0,0 +1,26 @@ +# raptor/utils/CMakeLists.txt +# +# Original listfile by Daniel Richard G. <skunk@iSKUNK.ORG> +# This file is in the public domain. +# + +INCLUDE_DIRECTORIES(BEFORE + ${CMAKE_CURRENT_SOURCE_DIR}/../src + ${CMAKE_BINARY_DIR}/src + ${CMAKE_CURRENT_SOURCE_DIR} +) + +IF(NOT HAVE_GETOPT AND NOT HAVE_GETOPT_LONG) + SET(getopt_sources getopt.c raptor_getopt.h) +ENDIF(NOT HAVE_GETOPT AND NOT HAVE_GETOPT_LONG) + +ADD_EXECUTABLE(rapper rapper.c ${getopt_sources}) +TARGET_LINK_LIBRARIES(rapper raptor2) + +ADD_EXECUTABLE(rdfdiff rdfdiff.c ${getopt_sources}) +TARGET_LINK_LIBRARIES(rdfdiff raptor2) + +INSTALL(FILES rapper.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) +INSTALL(TARGETS rapper DESTINATION ${CMAKE_INSTALL_BINDIR}) + +# end raptor/utils/CMakeLists.txt diff --git a/utils/Makefile.am b/utils/Makefile.am new file mode 100644 index 0000000..58fcdb8 --- /dev/null +++ b/utils/Makefile.am @@ -0,0 +1,91 @@ +# -*- Mode: Makefile -*- +# +# Makefile.am - automake file for Raptor utils +# +# Copyright (C) 2000-2009, David Beckett http://www.dajobe.org/ +# Copyright (C) 2000-2004, 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. +# +# + + +bin_PROGRAMS = rapper +noinst_PROGRAMS = rdfdiff + +man_MANS = rapper.1 + +CLEANFILES = *.plist + +# Memory debugging +MEM=@MEM@ +MEM_LIBS=@MEM_LIBS@ + +AM_CPPFLAGS= $(MEM) -I$(top_srcdir)/src +LIBS=@LIBS@ $(MEM_LIBS) + + +ANALYZE = clang +ANALYZE_FLAGS = "--analyze" +# Based on COMPILE target +ANALYZE_COMMAND = $(ANALYZE) \ + $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) \ + $(ANALYZE_FLAGS) + + +EXTRA_DIST= \ +CMakeLists.txt \ +rapper.html \ +$(man_MANS) + +rapper_SOURCES = rapper.c +if GETOPT +rapper_SOURCES += getopt.c raptor_getopt.h +endif +rapper_LDADD= $(top_builddir)/src/libraptor2.la + +rdfdiff_SOURCES = rdfdiff.c +if GETOPT +rdfdiff_SOURCES += getopt.c raptor_getopt.h +endif +rdfdiff_LDADD= $(top_builddir)/src/libraptor2.la + + +if MAINTAINER_MODE +rapper.html: $(srcdir)/rapper.1 $(srcdir)/../scripts/fix-groff-xhtml.pl + -groff -man -Thtml -P-l $< | tidy -asxml -wrap 1000 2>/dev/null | $(PERL) $(srcdir)/../scripts/fix-groff-xhtml.pl $@ +endif + +$(top_builddir)/src/libraptor2.la: + cd $(top_builddir)/src && $(MAKE) libraptor2.la + +if MAINTAINER_MODE +# Run Clang static analyzer over sources. +analyze: $(SOURCES) + @list='$(SOURCES)'; \ + result=0; \ + for file in $$list; do \ + if echo $$file | grep '\.c$$' >/dev/null 2>&1; then \ + $(RECHO) "Analyzing $$file"; \ + $(ANALYZE_COMMAND) $(srcdir)/$$file; \ + status=$$?; \ + if test $$status != 0; then \ + result=1; \ + fi; \ + fi; \ + done; \ + set -e; exit $$result +endif diff --git a/utils/Makefile.in b/utils/Makefile.in new file mode 100644 index 0000000..0e549b5 --- /dev/null +++ b/utils/Makefile.in @@ -0,0 +1,877 @@ +# Makefile.in generated by automake 1.16.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2021 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# -*- Mode: Makefile -*- +# +# Makefile.am - automake file for Raptor utils +# +# Copyright (C) 2000-2009, David Beckett http://www.dajobe.org/ +# Copyright (C) 2000-2004, 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. +# +# + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +bin_PROGRAMS = rapper$(EXEEXT) +noinst_PROGRAMS = rdfdiff$(EXEEXT) +@GETOPT_TRUE@am__append_1 = getopt.c raptor_getopt.h +@GETOPT_TRUE@am__append_2 = getopt.c raptor_getopt.h +subdir = utils +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/build/gtk-doc.m4 \ + $(top_srcdir)/build/libtool.m4 \ + $(top_srcdir)/build/ltoptions.m4 \ + $(top_srcdir)/build/ltsugar.m4 \ + $(top_srcdir)/build/ltversion.m4 \ + $(top_srcdir)/build/lt~obsolete.m4 $(top_srcdir)/build/pkg.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/src/raptor_config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" +PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) +am__rapper_SOURCES_DIST = rapper.c getopt.c raptor_getopt.h +@GETOPT_TRUE@am__objects_1 = getopt.$(OBJEXT) +am_rapper_OBJECTS = rapper.$(OBJEXT) $(am__objects_1) +rapper_OBJECTS = $(am_rapper_OBJECTS) +rapper_DEPENDENCIES = $(top_builddir)/src/libraptor2.la +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +am__rdfdiff_SOURCES_DIST = rdfdiff.c getopt.c raptor_getopt.h +am_rdfdiff_OBJECTS = rdfdiff.$(OBJEXT) $(am__objects_1) +rdfdiff_OBJECTS = $(am_rdfdiff_OBJECTS) +rdfdiff_DEPENDENCIES = $(top_builddir)/src/libraptor2.la +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src +depcomp = $(SHELL) $(top_srcdir)/build/depcomp +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/getopt.Po ./$(DEPDIR)/rapper.Po \ + ./$(DEPDIR)/rdfdiff.Po +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(rapper_SOURCES) $(rdfdiff_SOURCES) +DIST_SOURCES = $(am__rapper_SOURCES_DIST) $(am__rdfdiff_SOURCES_DIST) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +man1dir = $(mandir)/man1 +NROFF = nroff +MANS = $(man_MANS) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/build/depcomp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BISON = @BISON@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +CSCOPE = @CSCOPE@ +CTAGS = @CTAGS@ +CURL_CONFIG = @CURL_CONFIG@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ETAGS = @ETAGS@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +FILECMD = @FILECMD@ +GREP = @GREP@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ +GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ +GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +HTML_DIR = @HTML_DIR@ +ICU_CFLAGS = @ICU_CFLAGS@ +ICU_LIBS = @ICU_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +JING = @JING@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBCURL_CFLAGS = @LIBCURL_CFLAGS@ +LIBCURL_LIBS = @LIBCURL_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ $(MEM_LIBS) +LIBTOOL = @LIBTOOL@ +LIBXML_CFLAGS = @LIBXML_CFLAGS@ +LIBXML_LIBS = @LIBXML_LIBS@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ + +# Memory debugging +MEM = @MEM@ +MEM_LIBS = @MEM_LIBS@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +PKG_CONFIG_REQUIRES = @PKG_CONFIG_REQUIRES@ +RANLIB = @RANLIB@ +RAPTOR_LDFLAGS = @RAPTOR_LDFLAGS@ +RAPTOR_LIBTOOLLIBS = @RAPTOR_LIBTOOLLIBS@ +RAPTOR_LIBTOOL_VERSION = @RAPTOR_LIBTOOL_VERSION@ +RAPTOR_PARSERS = @RAPTOR_PARSERS@ +RAPTOR_SERIALIZERS = @RAPTOR_SERIALIZERS@ +RAPTOR_VERSION = @RAPTOR_VERSION@ +RAPTOR_VERSION_DECIMAL = @RAPTOR_VERSION_DECIMAL@ +RAPTOR_VERSION_MAJOR = @RAPTOR_VERSION_MAJOR@ +RAPTOR_VERSION_MINOR = @RAPTOR_VERSION_MINOR@ +RAPTOR_VERSION_RELEASE = @RAPTOR_VERSION_RELEASE@ +RAPTOR_WWW_LIBRARY = @RAPTOR_WWW_LIBRARY@ +RAPTOR_XML_PARSER = @RAPTOR_XML_PARSER@ +RECHO = @RECHO@ +RECHO_C = @RECHO_C@ +RECHO_N = @RECHO_N@ +RPM_RELEASE = @RPM_RELEASE@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TAR = @TAR@ +VERSION = @VERSION@ +XML_CONFIG = @XML_CONFIG@ +XSLT_CFLAGS = @XSLT_CFLAGS@ +XSLT_CONFIG = @XSLT_CONFIG@ +XSLT_LIBS = @XSLT_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +man_MANS = rapper.1 +CLEANFILES = *.plist +AM_CPPFLAGS = $(MEM) -I$(top_srcdir)/src +ANALYZE = clang +ANALYZE_FLAGS = "--analyze" +# Based on COMPILE target +ANALYZE_COMMAND = $(ANALYZE) \ + $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) \ + $(ANALYZE_FLAGS) + +EXTRA_DIST = \ +CMakeLists.txt \ +rapper.html \ +$(man_MANS) + +rapper_SOURCES = rapper.c $(am__append_1) +rapper_LDADD = $(top_builddir)/src/libraptor2.la +rdfdiff_SOURCES = rdfdiff.c $(am__append_2) +rdfdiff_LDADD = $(top_builddir)/src/libraptor2.la +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu utils/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu utils/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p \ + || test -f $$p1 \ + ; then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' \ + -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' \ + `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +installcheck-binPROGRAMS: $(bin_PROGRAMS) + bad=0; pid=$$$$; list="$(bin_PROGRAMS)"; for p in $$list; do \ + case ' $(AM_INSTALLCHECK_STD_OPTIONS_EXEMPT) ' in \ + *" $$p "* | *" $(srcdir)/$$p "*) continue;; \ + esac; \ + f=`echo "$$p" | \ + sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + for opt in --help --version; do \ + if "$(DESTDIR)$(bindir)/$$f" $$opt >c$${pid}_.out \ + 2>c$${pid}_.err </dev/null \ + && test -n "`cat c$${pid}_.out`" \ + && test -z "`cat c$${pid}_.err`"; then :; \ + else echo "$$f does not support $$opt" 1>&2; bad=1; fi; \ + done; \ + done; rm -f c$${pid}_.???; exit $$bad + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +rapper$(EXEEXT): $(rapper_OBJECTS) $(rapper_DEPENDENCIES) $(EXTRA_rapper_DEPENDENCIES) + @rm -f rapper$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(rapper_OBJECTS) $(rapper_LDADD) $(LIBS) + +rdfdiff$(EXEEXT): $(rdfdiff_OBJECTS) $(rdfdiff_DEPENDENCIES) $(EXTRA_rdfdiff_DEPENDENCIES) + @rm -f rdfdiff$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(rdfdiff_OBJECTS) $(rdfdiff_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rapper.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rdfdiff.Po@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-man1: $(man_MANS) + @$(NORMAL_INSTALL) + @list1=''; \ + list2='$(man_MANS)'; \ + test -n "$(man1dir)" \ + && test -n "`echo $$list1$$list2`" \ + || exit 0; \ + echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \ + { for i in $$list1; do echo "$$i"; done; \ + if test -n "$$list2"; then \ + for i in $$list2; do echo "$$i"; done \ + | sed -n '/\.1[a-z]*$$/p'; \ + fi; \ + } | while read p; do \ + if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; echo "$$p"; \ + done | \ + sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ + sed 'N;N;s,\n, ,g' | { \ + list=; while read file base inst; do \ + if test "$$base" = "$$inst"; then list="$$list $$file"; else \ + echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ + fi; \ + done; \ + for i in $$list; do echo "$$i"; done | $(am__base_list) | \ + while read files; do \ + test -z "$$files" || { \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ + done; } + +uninstall-man1: + @$(NORMAL_UNINSTALL) + @list=''; test -n "$(man1dir)" || exit 0; \ + files=`{ for i in $$list; do echo "$$i"; done; \ + l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ + sed -n '/\.1[a-z]*$$/p'; \ + } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ + dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir) + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) $(MANS) +installdirs: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libtool \ + clean-noinstPROGRAMS mostlyclean-am + +distclean: distclean-am + -rm -f ./$(DEPDIR)/getopt.Po + -rm -f ./$(DEPDIR)/rapper.Po + -rm -f ./$(DEPDIR)/rdfdiff.Po + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-man + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: install-man1 + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: installcheck-binPROGRAMS + +maintainer-clean: maintainer-clean-am + -rm -f ./$(DEPDIR)/getopt.Po + -rm -f ./$(DEPDIR)/rapper.Po + -rm -f ./$(DEPDIR)/rdfdiff.Po + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-man + +uninstall-man: uninstall-man1 + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ + clean-binPROGRAMS clean-generic clean-libtool \ + clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-binPROGRAMS install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-man1 install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installcheck-binPROGRAMS \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ + uninstall-am uninstall-binPROGRAMS uninstall-man \ + uninstall-man1 + +.PRECIOUS: Makefile + + +@MAINTAINER_MODE_TRUE@rapper.html: $(srcdir)/rapper.1 $(srcdir)/../scripts/fix-groff-xhtml.pl +@MAINTAINER_MODE_TRUE@ -groff -man -Thtml -P-l $< | tidy -asxml -wrap 1000 2>/dev/null | $(PERL) $(srcdir)/../scripts/fix-groff-xhtml.pl $@ + +$(top_builddir)/src/libraptor2.la: + cd $(top_builddir)/src && $(MAKE) libraptor2.la + +# Run Clang static analyzer over sources. +@MAINTAINER_MODE_TRUE@analyze: $(SOURCES) +@MAINTAINER_MODE_TRUE@ @list='$(SOURCES)'; \ +@MAINTAINER_MODE_TRUE@ result=0; \ +@MAINTAINER_MODE_TRUE@ for file in $$list; do \ +@MAINTAINER_MODE_TRUE@ if echo $$file | grep '\.c$$' >/dev/null 2>&1; then \ +@MAINTAINER_MODE_TRUE@ $(RECHO) "Analyzing $$file"; \ +@MAINTAINER_MODE_TRUE@ $(ANALYZE_COMMAND) $(srcdir)/$$file; \ +@MAINTAINER_MODE_TRUE@ status=$$?; \ +@MAINTAINER_MODE_TRUE@ if test $$status != 0; then \ +@MAINTAINER_MODE_TRUE@ result=1; \ +@MAINTAINER_MODE_TRUE@ fi; \ +@MAINTAINER_MODE_TRUE@ fi; \ +@MAINTAINER_MODE_TRUE@ done; \ +@MAINTAINER_MODE_TRUE@ set -e; exit $$result + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/utils/getopt.c b/utils/getopt.c new file mode 100644 index 0000000..28dad21 --- /dev/null +++ b/utils/getopt.c @@ -0,0 +1,157 @@ +/* + * Public Domain getopt - history below + * + */ + +/* + * From: gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) Newsgroups: net.sources + * Subject: getopt library routine Date: 30 Mar 85 04:45:33 GMT + */ + +/* + * getopt -- public domain version of standard System V routine + * + * Strictly enforces the System V Command Syntax Standard; provided by D A + * Gwyn of BRL for generic ANSI C implementations + * + * #define STRICT to prevent acceptance of clustered options with arguments + * and ommision of whitespace between option and arg. + */ + +/* + * Modified by Manuel Novoa III on 1/5/01 to use weak symbols. + * Programs needing long options will link gnu_getopt instead. + */ + +/* + * Last public domain version 1.5 downloaded from uclibc CVS: + * http://www.uclibc.org/cgi-bin/cvsweb/uClibc/libc/unistd/getopt.c + * on 2003-02-18 by Dave Beckett and tidied: + * Ran through "indent getopt.c -gnu" then fixed up the mess + * Removed register - compilers are smart these days + * ANSI-fied the declarations + * Prefixed with raptor_ so that it doesn't clash with any getopt + * linked in later. + */ + + +#include <stdio.h> +#include <string.h> + +#include <raptor_getopt.h> + +int opterr; /* error => print message */ +int optind; /* next argv[] index */ +int optopt; /* Set for unknown arguments */ +char *optarg; /* option parameter if any */ + +/* + * Err: + * program name argv[0] + * specific message + * defective option letter + */ +static int +Err (char *name, char *mess, int c) /* returns '?' */ +{ + optopt = c; + if(opterr) + { + (void) fprintf (stderr, "%s: %s -- %c\n", name, mess, c); + } + + return '?'; /* erroneous-option marker */ +} + + +int +getopt (int argc, char * const argv[], const char *optstring) +{ + static int sp = 1; /* position within argument */ + int osp; /* saved `sp' for param test */ + +#ifndef STRICT + int oind; /* saved `optind' for param test */ +#endif + int c; /* option letter */ + char *cp; /* -> option in `optstring' */ + + optarg = NULL; + + /* initialise getopt vars */ + if(optind == 0) + { + optind = 1; + opterr = 1; + optopt = 1; + optarg = NULL; + } + + if(sp == 1) + { /* fresh argument */ + if(optind >= argc /* no more arguments */ + || argv[optind][0] != '-' /* no more options */ + || argv[optind][1] == '\0' /* not option; stdin */ + ) + return EOF; + else if(strcmp (argv[optind], "--") == 0) + { + ++optind; /* skip over "--" */ + return EOF; /* "--" marks end of options */ + } + } + + c = argv[optind][sp]; /* option letter */ + osp = sp++; /* get ready for next letter */ + +#ifndef STRICT + oind = optind; /* save optind for param test */ +#endif + if(argv[optind][sp] == '\0') + { /* end of argument */ + ++optind; /* get ready for next try */ + sp = 1; /* beginning of next argument */ + } + + if(c == ':' + || c == '?' /* optstring syntax conflict */ + || (cp = strchr (optstring, c)) == NULL) /* not found */ + { + return Err (argv[0], "illegal option", c); + } + + if(cp[1] == ':') + { /* option takes parameter */ +#ifdef STRICT + if(osp != 1) + { + return Err (argv[0], "option must not be clustered", c); + } + + /* reset by end of argument */ + if(sp != 1) + { + return Err (argv[0], "option must be followed by white space", c); + } +#else + if(oind == optind) + { /* argument w/o whitespace */ + optarg = &argv[optind][sp]; + sp = 1; /* beginning of next argument */ + } + + else +#endif + if(optind >= argc) + { + return Err (argv[0], "option requires an argument", c); + } + + else /* argument w/ whitespace */ + optarg = argv[optind]; + + ++optind; /* skip over parameter */ + } + + return c; +} diff --git a/utils/rapper.1 b/utils/rapper.1 new file mode 100644 index 0000000..43459df --- /dev/null +++ b/utils/rapper.1 @@ -0,0 +1,192 @@ +.\" Hey, EMACS: -*- nroff -*- +.\" +.\" rapper.1 - Raptor RDF parsing and serializing utility manual page +.\" +.\" Copyright (C) 2002-2010 David Beckett - http://www.dajobe.org/ +.\" Copyright (C) 2002-2005 University of Bristol - http://www.bristol.ac.uk/ +.\" +.TH rapper 1 "2010-04-28" +.\" Please adjust this date whenever revising the manpage. +.SH NAME +rapper \- Raptor RDF parsing and serializing utility +.SH SYNOPSIS +.B rapper +.RB [ OPTIONS ] +.IR "INPUT-URI" +.IR "[INPUT-BASE-URI]" +.SH EXAMPLE +.nf +.B rapper -o ntriples http://planetrdf.com/guide/rss.rdf +.br +.B rapper -i rss-tag-soup -o rss-1.0 pile-of-rss.xml http://example.org/base/ +.br +.B rapper --count http://example.org/index.rdf +.SH DESCRIPTION +The +.B rapper +utility allows parsing of RDF content by the +.B Raptor +RDF parser toolkit emitting the results as RDF triples in +a choice of syntaxes. The \fIINPUT-URI\fR can be a file name, '-' +for standard input or if Raptor is built with a WWW retrieval +library, a general URI. The optional \fIINPUT-BASE-URI\fR is used as the +document parser base URI if present otherwise defaults to the \fIINPUT-URI\fR. +A value of '-' means no base URI. +.SH OPTIONS +rapper uses the usual GNU command line syntax, with long +options starting with two dashes (`-') if supported by the +getopt_long function. Otherwise the short options are only available. +.TP +.B \-h, \-\-help +Show a summary of the options. +.TP +.B \-i, \-\-input FORMAT +Set the input +.I FORMAT +to one of 'rdfxml' (RDF/XML, default), 'ntriples' +(N-Triples, see below), 'turtle' (Turtle, see below) +or 'rss-tag-soup' (RSS Tag Soup). The RSS Tag Soup parser +can turn the many XML RSS formats, Atom 0.3 and Atom 1.0 into RDF +triples. +.IP +The list of +parsers depends on how libraptor(3) was built. The list of +supported parsers is given in the help summary given by \-h. +.TP +.B \-I, \-\-input-uri URI +Set the input/parser base +.I URI +or use value '-' for no base. +The default is the INPUT-URI argument value. +.TP +.B \-o, \-\-output FORMAT +Set the output +.I FORMAT +to 'ntriples' (N-Triples, default), 'rdfxml' (RDF/XML), 'rdfxml-abbrev' +(RDF/XML with abbreviations) or 'rss-1.0' (RSS 1.0, also an RDF/XML syntax). +.IP +The list of +serializers depends on how libraptor(3) was built. The list of +supported serializers is given in the help summary given by \-h. +.TP +.B \-O, \-\-output-uri URI +Set the output/serializer base +.I URI +or use value '-' for no base. +The default is the input base uri, either set by the argument +INPUT-BASE-URI or via options +.B \-I, \-\-input-uri URI +.TP +.B \-c, \-\-count +Only count the triples and produce no other output. +.TP +.B \-e, \-\-ignore-errors +Ignore errors, do not emit the messages and try to continue parsing. +.TP +.B \-f, \-\-feature FEATURE[=VALUE] +Set a parser or serializer feature +.I FEATURE +to a value, or to 1 if +.I VALUE +is omitted, +Use \-f help to get lists of valid parser and serializer features. +.IP +If the form \-f 'xmlns:\fIprefix\fP=\(dq\fIuri\fP\(dq' is used, +the prefix and namespace uri given will be set for serializing. +The syntax matches XML in that either or both of \fIprefix\fP +or \fIuri\fP can be omitted. +.TP +.B \-g, \-\-guess +Guess the parser to use from the source-URI rather than use +the \-i FORMAT. +.TP +.B \-q, \-\-quiet +No extra information messages. +.TP +.B \-r, \-\-replace-newlines +Replace newlines in multi-line literals with spaces. +.TP +.B \-\-show-graphs +Print graph names (URIs) as they are seen in the input. This only +has a meaning for parsers that support graph names such as the TRiG parser. +.TP +.B \-\-show-namespaces +Print namespaces as they are seen in the input. +.TP +.B \-t, \-\-trace +Print URIs retrieved during parsing. Especially useful for +monitoring what the guess and GRDDL parsers are doing. +.TP +.B \-w, \-\-ignore-warnings +Ignore warnings, do not emit the messages. +.TP +.B \-v, \-\-version +Print the raptor version and exit. +.SH "EXAMPLES" +.br +.B rapper -q -i ntriples -o rdfxml -f 'xmlns:rss="http://purl.org/rss/1.0/"' -f 'xmlns:ex="http://example.org/"' tests/test.nt +.br +.B rapper -q -o rdfxml -f 'xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"' tests/rdf-schema.rdf 'http://www.w3.org/2000/01/rdf-schema#' +.SH "CONFORMING TO" +\fIRDF/XML Syntax (Revised)\fR, +W3C Recommendation, +.UR http://www.w3.org/TR/rdf-syntax-grammar/ +http://www.w3.org/TR/rdf-syntax-grammar/ +.UE + +\fIN-Triples\fR, in \fIRDF Test Cases\fR, Jan Grant and Dave Beckett (eds.), +W3C Recommendation, +.UR http://www.w3.org/TR/rdf-testcases/#ntriples +http://www.w3.org/TR/rdf-testcases/#ntriples +.UE + +\fITurtle Terse RDF Triple Language\fR, Dave Beckett, +.UR http://www.dajobe.org/2004/01/turtle/ +http://www.dajobe.org/2004/01/turtle/ +.UE + +\fIRDFA in XHTML: Syntax and Processing\fR, Ben Adida, Mark Birbeck, +Shane McCarron and Steven Pemberton (eds.), +W3C Candidate Recommendation, 20 June 2008 +.UR http://www.w3.org/TR/2008/CR-rdfa-syntax-20080620/ +http://www.w3.org/TR/2008/CR-rdfa-syntax-20080620/ +.UE + +\fIRDF Site Summary (RSS) 1.0\fR, 2000-12-06 +.UR http://purl.org/rss/1.0/spec +http://purl.org/rss/1.0/spec +.UE +.SH SEE ALSO +.BR libraptor(3), raptor-config(1) +.SH CHANGES +.SS 2.0.0 +Removed \-a option that did nothing. +.LP +Removed \-m option from rapper but it was never documented here. +.LP +Removed \-n option that was long hidden. +.LP +Removed \-s option that was equivalent to \-f scanForRDF +.SS 1.4.16 +Added \-I/\-\-input-uri and \-O/\-\-output\-uri to set the input and output +(parser and serializer) base URIs separately. +.SS 1.4.15 +Added \-t/\-\-trace to do URI traces. +.SS 1.4.5 +Updated to add serializer rdfxml-abbrev +.SS 1.4.3 +Updated potential parser and serializers and described \-f for +defining namespaces. +.SS 1.3.0 +Added \-f for features. +.br +Added \-g for guessing the parser to use. +.SS 1.1.0 +Removed \-a, \-\-assume since rdf:RDF is now always optional. +.br +.SH AUTHOR +Dave Beckett - +.UR http://www.dajobe.org/ +http://www.dajobe.org/ +.UE +.br diff --git a/utils/rapper.c b/utils/rapper.c new file mode 100644 index 0000000..03b163f --- /dev/null +++ b/utils/rapper.c @@ -0,0 +1,972 @@ +/* -*- Mode: c; c-basic-offset: 2 -*- + * + * rapper.c - Raptor RDF Parsing and Serializing utility + * + * Copyright (C) 2000-2010, 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. + * + * + */ + + +#ifdef HAVE_CONFIG_H +#include <raptor_config.h> +#endif + +#include <stdio.h> +#include <string.h> + +/* Raptor includes */ +#include <raptor2.h> + +/* for access() and R_OK */ +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif +#ifdef WIN32 +#include <io.h> +#endif + +/* many places for getopt */ +#ifdef HAVE_GETOPT_H +#include <getopt.h> +#else +#include <raptor_getopt.h> +#endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + + + + +#ifdef NEED_OPTIND_DECLARATION +extern int optind; +extern char *optarg; +#endif + +static void print_triples(void *user_data, raptor_statement *statement); +static void print_graph(void *user_data, raptor_uri *graph, int flags); +static void print_namespaces(void* user_data, raptor_namespace *nspace); +static void relay_namespaces(void* user_data, raptor_namespace *nspace); +int main(int argc, char *argv[]); + + +static char *program = NULL; + +/* replace newlines in literal string output with spaces */ +static int replace_newlines = 0; + +/* extra noise? */ +static int quiet = 0; +/* just count, no printing */ +static int count = 0; + +static long triple_count = 0; + +static raptor_serializer* serializer = NULL; + +static int guess = 0; + +static int reported_guess = 0; + +static int report_namespace = 0; + +static int report_graph = 0; + + +static +void print_triples(void *user_data, raptor_statement *triple) +{ + raptor_parser* rdf_parser = (raptor_parser*)user_data; + triple_count++; + + if(guess && !quiet && !reported_guess) { + fprintf(stderr, "%s: Guessed parser name '%s'\n", + program, raptor_parser_get_name(rdf_parser)); + reported_guess = 1; + } + + + if(count) + return; + + /* replace newlines with spaces if object is a literal string */ + if(replace_newlines && + triple->object->type == RAPTOR_TERM_TYPE_LITERAL) { + char *s; + for(s = (char*)triple->object->value.literal.string; *s; s++) + if(*s == '\n') + *s=' '; + } + + raptor_serializer_serialize_statement(serializer, triple); + return; +} + + +static +void print_graph(void *user_data, raptor_uri *graph, int flags) +{ + /* raptor_parser *parser = (raptor_parser *)user_data; */ + const char* const label = (flags & RAPTOR_GRAPH_MARK_START) + ? (const char*)"start" : (const char*)"end"; + + if(!report_graph) + return; + + if(graph) + fprintf(stderr, "%s: Graph URI %s %s\n", + program, raptor_uri_as_string(graph), label); + else + fprintf(stderr, "%s: Default graph %s\n", + program, label); +} + + +static void +print_namespaces(void* user_data, raptor_namespace *nspace) +{ + /* raptor_parser* rdf_parser = (raptor_parser*)user_data; */ + unsigned char *s; + + if(!report_namespace) + return; + + s = raptor_namespace_format_as_xml(nspace, NULL); + fprintf(stderr, "%s: Namespace declared: %s\n", + program, s); + raptor_free_memory(s); + + return; +} + + +static void +relay_namespaces(void* user_data, raptor_namespace *nspace) +{ + raptor_serializer* rdf_serializer = (raptor_serializer*)user_data; + + if(report_namespace) + print_namespaces(user_data, nspace); + + raptor_serializer_set_namespace_from_namespace(rdf_serializer, nspace); +} + + + +#ifdef HAVE_GETOPT_LONG +#define HELP_TEXT(short, long, description) " -" short ", --" long " " description +#define HELP_TEXT_LONG(long, description) " --" long " " description +#define HELP_ARG(short, long) "--" #long +#define HELP_ARG_BOTH(short, long) " \"-" short "\" or \"--" long "\"" +#define HELP_PAD "\n " +#else +#define HELP_TEXT(short, long, description) " -" short " " description +#define HELP_TEXT_LONG(long, description) +#define HELP_ARG(short, long) "-" #short +#define HELP_ARG_BOTH(short, long) "\"-" short "\"" +#define HELP_PAD "\n " +#endif + + +#define GETOPT_STRING "cef:ghi:I:o:O:qrtvw" + +#ifdef HAVE_GETOPT_LONG +#define SHOW_NAMESPACES_FLAG 0x100 +#define SHOW_GRAPHS_FLAG 0x200 + +static const struct option long_options[] = +{ + /* name, has_arg, flag, val */ + {"count", 0, 0, 'c'}, + {"ignore-errors", 0, 0, 'e'}, + {"feature", 1, 0, 'f'}, + {"guess", 0, 0, 'g'}, + {"help", 0, 0, 'h'}, + {"input", 1, 0, 'i'}, + {"input-uri", 1, 0, 'I'}, + {"output", 1, 0, 'o'}, + {"output-uri", 1, 0, 'O'}, + {"quiet", 0, 0, 'q'}, + {"replace-newlines", 0, 0, 'r'}, + {"show-graphs", 0, 0, SHOW_GRAPHS_FLAG}, + {"show-namespaces", 0, 0, SHOW_NAMESPACES_FLAG}, + {"trace", 0, 0, 't'}, + {"version", 0, 0, 'v'}, + {"ignore-warnings", 0, 0, 'w'}, + {NULL, 0, 0, 0} +}; +#endif + + +static int error_count = 0; +static int warning_count = 0; + +static int ignore_warnings = 0; +static int ignore_errors = 0; + +static const char * const title_string = + "Raptor RDF syntax parsing and serializing utility"; + + +static void +rapper_log_handler(void *data, raptor_log_message *message) +{ + raptor_parser *parser = (raptor_parser *)data; + + switch(message->level) { + case RAPTOR_LOG_LEVEL_FATAL: + case RAPTOR_LOG_LEVEL_ERROR: + if(!ignore_errors) { + fprintf(stderr, "%s: Error - ", program); + raptor_locator_print(message->locator, stderr); + fprintf(stderr, " - %s\n", message->text); + + raptor_parser_parse_abort(parser); + } + + error_count++; + break; + + case RAPTOR_LOG_LEVEL_WARN: + if(!ignore_warnings) { + fprintf(stderr, "%s: Warning - ", program); + raptor_locator_print(message->locator, stderr); + fprintf(stderr, " - %s\n", message->text); + } + + warning_count++; + break; + + case RAPTOR_LOG_LEVEL_NONE: + case RAPTOR_LOG_LEVEL_TRACE: + case RAPTOR_LOG_LEVEL_DEBUG: + case RAPTOR_LOG_LEVEL_INFO: + + fprintf(stderr, "%s: Unexpected %s message - ", program, + raptor_log_level_get_label(message->level)); + raptor_locator_print(message->locator, stderr); + fprintf(stderr, " - %s\n", message->text); + break; + } + +} + +struct namespace_decl +{ + unsigned char *prefix; + unsigned char *uri_string; +}; + + +static void +rapper_free_namespace_decl(void* data) { + struct namespace_decl* nsd = (struct namespace_decl*)data; + if(nsd->prefix) + raptor_free_memory(nsd->prefix); + if(nsd->uri_string) + raptor_free_memory(nsd->uri_string); + raptor_free_memory(nsd); +} + + +static int +rapper_uri_trace(void *user_data, raptor_uri* uri) +{ + fprintf(stderr, "%s: Tracing retrieval of URI %s\n", + program, raptor_uri_as_string(uri)); + return 0; +} + + +typedef struct +{ + raptor_option option; + int i_value; + const char* s_value; +} option_value; + + + +int +main(int argc, char *argv[]) +{ + /* input variables - parser + * 'uri_string' is set to a URI otherwise 'filename' is file name + * or if NULL, stdin. Base URI in 'base_uri_string' is required for stdin. + */ + raptor_world* world = NULL; + raptor_parser* rdf_parser = NULL; + char *filename = NULL; +#define FILENAME_LABEL(name) ((name) ? (name) : "<stdin>") + unsigned char *uri_string = NULL; + int free_uri_string = 0; + raptor_uri *uri; + unsigned char *base_uri_string = NULL; + raptor_uri *base_uri = NULL; + const char *syntax_name="rdfxml"; + raptor_sequence* parser_options = NULL; + int trace = 0; + + /* output variables - serializer */ + /* 'serializer' object variable is a global */ + const char *serializer_syntax_name = "ntriples"; + const unsigned char *output_base_uri_string = NULL; + raptor_uri *output_base_uri = NULL; + raptor_sequence* serializer_options = NULL; + raptor_sequence *namespace_declarations = NULL; + + /* other variables */ + int rc; + int usage = 0; + int help = 0; + char *p; + + program = argv[0]; + if((p = strrchr(program, '/'))) + program = p + 1; + else if((p = strrchr(program, '\\'))) + program = p + 1; + argv[0] = program; + + world = raptor_new_world(); + if(!world) + exit(1); + rc = raptor_world_open(world); + if(rc) + exit(1); + + while(!usage && !help) + { + int c; +#ifdef HAVE_GETOPT_LONG + int option_index = 0; + + c = getopt_long (argc, argv, GETOPT_STRING, long_options, &option_index); +#else + c = getopt (argc, argv, GETOPT_STRING); +#endif + if(c == -1) + break; + + switch (c) { + case 0: + case '?': /* getopt() - unknown option */ + usage = 1; + break; + + case 'c': + count = 1; + if(serializer_syntax_name) + serializer_syntax_name = NULL; + break; + + case 'f': + if(optarg) { + if(!strcmp(optarg, "help")) { + int option_count = (int)raptor_option_get_count(); + int i; + + fprintf(stderr, "%s: Valid parser options are:\n", + program); + for(i = 0; i < option_count; i++) { + raptor_option_description *od; + + od = raptor_world_get_option_description(world, + RAPTOR_DOMAIN_PARSER, + (raptor_option)i); + if(od) { + fprintf(stderr, " %-21s %s (%s)\n", + od->name, od->label, + raptor_option_get_value_type_label(od->value_type)); + } + } + fprintf(stderr, "%s: Valid serializer options are:\n", + program); + for(i = 0; i < option_count; i++) { + raptor_option_description *od; + + od = raptor_world_get_option_description(world, + RAPTOR_DOMAIN_SERIALIZER, + (raptor_option)i); + if(od) { + fprintf(stderr, " %-21s %s (%s)\n", + od->name, od->label, + raptor_option_get_value_type_label(od->value_type)); + raptor_free_option_description(od); + } + } + fputs("Options are set with `" HELP_ARG(f, option) " OPTION = VALUE or `-f OPTION'\n" + "and take a decimal integer VALUE except where noted, defaulting to 1 if omitted.\n", stderr); + fputs("\nA option of the form xmlns:PREFIX=\"URI\" can be used to declare output\n" + "namespace prefixes and names for serializing using an XML-style syntax\n" + "Either or both of PREFIX or URI can be omitted such as -f xmlns=\"URI\"\n" + "This form can be repeated for multiple declarations.\n", + stderr); + + raptor_free_world(world); + exit(0); + } else if(!strncmp(optarg, "xmlns", 5)) { + struct namespace_decl *nd; + nd = (struct namespace_decl *)raptor_alloc_memory(sizeof(*nd)); + if(raptor_xml_namespace_string_parse((unsigned char*)optarg, + &nd->prefix, + &nd->uri_string)) { + fprintf(stderr, "%s: Bad xmlns syntax in '%s'\n", + program, optarg); + rapper_free_namespace_decl(nd); + + raptor_free_world(world); + exit(0); + } + + if(!namespace_declarations) + namespace_declarations = raptor_new_sequence(rapper_free_namespace_decl, NULL); + + raptor_sequence_push(namespace_declarations, nd); + } else { + int option_count = (int)raptor_option_get_count(); + int i; + size_t arg_len = strlen(optarg); + option_value* fv; + int ok = 0; + + /* parser options */ + for(i = 0; i < option_count; i++) { + raptor_domain domain; + raptor_option_description *od; + size_t name_len; + + domain = RAPTOR_DOMAIN_PARSER; + od = raptor_world_get_option_description(world, + domain, + (raptor_option)i); + if(!od) { + domain = RAPTOR_DOMAIN_SERIALIZER; + od = raptor_world_get_option_description(world, + domain, + (raptor_option)i); + if(!od) + /* Neither a parser or serializer option - skip */ + continue; + } + + name_len = od->name_len; + if(!strncmp(optarg, od->name, name_len)) { + fv = (option_value*)raptor_calloc_memory(sizeof(option_value), + 1); + + fv->option = (raptor_option)i; + if(od->value_type == RAPTOR_OPTION_VALUE_TYPE_BOOL || + od->value_type == RAPTOR_OPTION_VALUE_TYPE_INT) { + if(name_len < arg_len && optarg[name_len] == '=') + fv->i_value = atoi(&optarg[name_len + 1]); + else if(name_len == arg_len) + fv->i_value = 1; + } else { + if(name_len < arg_len && optarg[name_len] == '=') + fv->s_value = &optarg[name_len + 1]; + else if(name_len == arg_len) + fv->s_value = (const char*)""; + } + + if(domain == RAPTOR_DOMAIN_PARSER) { + if(!parser_options) + parser_options = raptor_new_sequence(raptor_free_memory, + NULL); + raptor_sequence_push(parser_options, fv); + } else { + /* RAPTOR_DOMAIN_SERIALIZER */ + if(!serializer_options) + serializer_options = raptor_new_sequence(raptor_free_memory, + NULL); + raptor_sequence_push(serializer_options, fv); + } + + ok = 1; + } + raptor_free_option_description(od); + + if(ok) + break; + } + + + if(!ok) { + fprintf(stderr, + "%s: invalid argument `%s' for `" HELP_ARG(f, option) "'\n" + "Try '%s " HELP_ARG(f, option) " help' for a list of valid options\n", + program, optarg, program); + usage = 1; + } + } + } + break; + + case 'g': + guess = 1; + break; + + case 'h': + help = 1; + break; + + case 't': + trace = 1; + break; + + case 'q': + quiet = 1; + break; + + case 'r': + replace_newlines = 1; + break; + + case 'o': + if(optarg) { + if(raptor_world_is_serializer_name(world, optarg)) + serializer_syntax_name = optarg; + else { + int i; + + fprintf(stderr, + "%s: invalid argument `%s' for `" HELP_ARG(o, output) "'\n", + program, optarg); + fprintf(stderr, "Valid arguments are:\n"); + for(i = 0; 1; i++) { + const raptor_syntax_description* sd; + sd = raptor_world_get_serializer_description(world, i); + if(!sd) + break; + fprintf(stderr, " %-14s for %s\n", sd->names[0], sd->label); + } + usage = 1; + break; + + } + } + break; + + case 'O': + if(optarg) + output_base_uri_string = (const unsigned char*)optarg; + break; + + case 'i': + if(optarg) { + if(raptor_world_is_parser_name(world, optarg)) + syntax_name = optarg; + else { + int i; + + fprintf(stderr, + "%s: invalid argument `%s' for `" HELP_ARG(i, input) "'\n", + program, optarg); + fprintf(stderr, "Valid arguments are:\n"); + for(i = 0; 1; i++) { + const raptor_syntax_description* sd; + sd = raptor_world_get_parser_description(world, i); + if(!sd) + break; + fprintf(stderr, " %-14s for %s\n", sd->names[0], sd->label); + } + usage = 1; + break; + + } + } + break; + + case 'I': + if(optarg) + base_uri_string = (unsigned char*)optarg; + break; + + case 'w': + ignore_warnings = 1; + break; + + case 'e': + ignore_errors = 1; + break; + + case 'v': + fputs(raptor_version_string, stdout); + fputc('\n', stdout); + + raptor_free_world(world); + exit(0); + +#ifdef SHOW_NAMESPACES_FLAG + case SHOW_NAMESPACES_FLAG: + report_namespace = 1; + break; +#endif + +#ifdef SHOW_GRAPHS_FLAG + case SHOW_GRAPHS_FLAG: + report_graph = 1; + break; +#endif + + } /* end switch */ + + } + + if(optind != argc-1 && optind != argc-2 && !help && !usage) { + usage = 2; /* Title and usage */ + } + + + if(usage) { + if(usage > 1) { + fputs(title_string, stderr); putc(' ', stderr); fputs(raptor_version_string, stderr); putc('\n', stderr); + fputs("Raptor home page: ", stderr); + fputs(raptor_home_url_string, stderr); + fputc('\n', stderr); + fputs(raptor_copyright_string, stderr); + fputs("\nLicense: ", stderr); + fputs(raptor_license_string, stderr); + fputs("\n\n", stderr); + } + fprintf(stderr, "Try `%s " HELP_ARG(h, help) "' for more information.\n", + program); + + raptor_free_world(world); + exit(1); + } + + if(help) { + int i; + + puts(title_string); putchar(' '); puts(raptor_version_string); putchar('\n'); + puts("Parse RDF syntax from a source into serialized RDF triples."); + printf("Usage: %s [OPTIONS] INPUT-URI [INPUT-BASE-URI]\n\n", program); + + fputs(raptor_copyright_string, stdout); + fputs("\nLicense: ", stdout); + puts(raptor_license_string); + fputs("Raptor home page: ", stdout); + puts(raptor_home_url_string); + + puts("\nArguments:"); + puts(" INPUT-URI a filename, URI or '-' for standard input (stdin)."); + puts(" INPUT-BASE-URI the input/parser base URI or '-' for none.\n" + " Default is INPUT-URI\n" + " Equivalent to" HELP_ARG_BOTH("I INPUT-BASE-URI", "input-uri INPUT-BASE-URI")); + + puts("\nMain options:"); + puts(HELP_TEXT("i FORMAT", "input FORMAT ", "Set the input format/parser to one of:")); + for(i = 0; 1; i++) { + const raptor_syntax_description* sd; + sd = raptor_world_get_parser_description(world, i); + if(!sd) + break; + printf(" %-14s %s", sd->names[0], sd->label); + if(!i) + puts(" (default)"); + else + putchar('\n'); + } + puts(HELP_TEXT("I URI", "input-uri URI ", "Set the input/parser base URI. '-' for none.") HELP_PAD " Default is INPUT-BASE-URI argument value."); + putchar('\n'); + + puts(HELP_TEXT("o FORMAT", "output FORMAT", "Set the output format/serializer to one of:")); + for(i = 0; 1; i++) { + const raptor_syntax_description* sd; + sd = raptor_world_get_serializer_description(world, i); + if(!sd) + break; + printf(" %-14s %s", sd->names[0], sd->label); + if(!i) + puts(" (default)"); + else + putchar('\n'); + } + puts(HELP_TEXT("O URI", "output-uri URI ", "Set the output/serializer base URI. '-' for none.") HELP_PAD " Default is input/parser base URI."); + putchar('\n'); + + puts("General options:"); + puts(HELP_TEXT("c", "count ", "Count triples only - do not print them.")); + puts(HELP_TEXT("e", "ignore-errors ", "Ignore error messages")); + puts(HELP_TEXT("f OPTION(=VALUE)", "feature OPTION(=VALUE)", HELP_PAD "Set parser or serializer options" HELP_PAD "Use `-f help' for a list of valid options")); + puts(HELP_TEXT("g", "guess ", "Guess the input syntax (same as -i guess)")); + puts(HELP_TEXT("h", "help ", "Print this help, then exit")); + puts(HELP_TEXT("q", "quiet ", "No extra information messages")); + puts(HELP_TEXT("r", "replace-newlines", "Replace newlines with spaces in literals")); +#ifdef SHOW_GRAPHS_FLAG + puts(HELP_TEXT_LONG("show-graphs ", "Show named graphs as they are declared")); +#endif +#ifdef SHOW_NAMESPACES_FLAG + puts(HELP_TEXT_LONG("show-namespaces ", "Show namespaces as they are declared")); +#endif + puts(HELP_TEXT("t", "trace ", "Trace URIs retrieved during parsing")); + puts(HELP_TEXT("w", "ignore-warnings ", "Ignore warning messages")); + puts(HELP_TEXT("v", "version ", "Print the Raptor version")); + puts("\nReport bugs to http://bugs.librdf.org/"); + + raptor_free_world(world); + exit(0); + } + + + if(optind == argc-1) + uri_string = (unsigned char*)argv[optind]; + else { + uri_string = (unsigned char*)argv[optind++]; + base_uri_string = (unsigned char*)argv[optind]; + } + + /* If uri_string is "path-to-file", turn it into a file: URI */ + if(!strcmp((const char*)uri_string, "-")) { + if(!base_uri_string) { + fprintf(stderr, + "%s: A Base URI is required when reading from standard input.\n", + program); + return(1); + } + uri_string = NULL; + } else if(!access((const char*)uri_string, R_OK)) { + filename = (char*)uri_string; + uri_string = raptor_uri_filename_to_uri_string(filename); + if(!uri_string) { + fprintf(stderr, "%s: Failed to create URI for file %s.\n", + program, filename); + return(1); + } + free_uri_string = 1; + } + + if(uri_string) { + uri = raptor_new_uri(world, uri_string); + if(!uri) { + fprintf(stderr, "%s: Failed to create URI for %s\n", + program, uri_string); + return(1); + } + } else + uri = NULL; /* stdin */ + + + /* Set the input/parser base URI */ + if(base_uri_string) { + if(strcmp((const char*)base_uri_string, "-")) { + base_uri = raptor_new_uri(world, base_uri_string); + if(!base_uri) { + fprintf(stderr, "%s: Failed to create URI for %s\n", + program, base_uri_string); + return(1); + } + } + } + + + /* Set the output/serializer base URI from the argument if explicitly + * set, otherwise default to the input base URI if present. + */ + if(!output_base_uri_string) { + if(base_uri) + output_base_uri = raptor_uri_copy(base_uri); + } else { + if(strcmp((const char*)output_base_uri_string, "-")) { + output_base_uri = raptor_new_uri(world, output_base_uri_string); + if(!output_base_uri) { + fprintf(stderr, "%s: Failed to create output base URI for %s\n", + program, output_base_uri_string); + return(1); + } + } else + output_base_uri = NULL; + } + + + if(guess) + syntax_name="guess"; + + rdf_parser = raptor_new_parser(world, syntax_name); + if(!rdf_parser) { + fprintf(stderr, "%s: Failed to create raptor parser type %s\n", + program, syntax_name); + return(1); + } + + raptor_world_set_log_handler(world, rdf_parser, rapper_log_handler); + + if(parser_options) { + option_value *fv; + while((fv = (option_value*)raptor_sequence_pop(parser_options))) { + raptor_parser_set_option(rdf_parser, fv->option, + fv->s_value, fv->i_value); + raptor_free_memory(fv); + } + raptor_free_sequence(parser_options); + parser_options = NULL; + } + + if(trace) + raptor_parser_set_uri_filter(rdf_parser, rapper_uri_trace, rdf_parser); + + + if(!quiet) { + if(uri_string) { + if(base_uri_string) + fprintf(stderr, "%s: Parsing URI %s with parser %s and base URI %s\n", + program, uri_string, syntax_name, base_uri_string); + else + fprintf(stderr, "%s: Parsing URI %s with parser %s\n", program, + uri_string, syntax_name); + } else { + if(base_uri_string) + fprintf(stderr, + "%s: Parsing file %s with parser %s and base URI %s\n", program, + FILENAME_LABEL(filename), syntax_name, base_uri_string); + else + fprintf(stderr, "%s: Parsing file %s with parser %s\n", program, + FILENAME_LABEL(filename), syntax_name); + } + } + + raptor_parser_set_statement_handler(rdf_parser, rdf_parser, print_triples); + + if(report_graph) + raptor_parser_set_graph_mark_handler(rdf_parser, rdf_parser, print_graph); + + if(report_namespace) + raptor_parser_set_namespace_handler(rdf_parser, rdf_parser, + print_namespaces); + + + if(serializer_syntax_name) { + if(!quiet) { + if(output_base_uri) + fprintf(stderr, "%s: Serializing with serializer %s and base URI %s\n", + program, serializer_syntax_name, + raptor_uri_as_string(output_base_uri)); + else + fprintf(stderr, "%s: Serializing with serializer %s\n", + program, serializer_syntax_name); + } + + serializer = raptor_new_serializer(world, serializer_syntax_name); + if(!serializer) { + fprintf(stderr, + "%s: Failed to create raptor serializer type %s\n", program, + serializer_syntax_name); + return(1); + } + + if(namespace_declarations) { + int i; + for(i = 0; i< raptor_sequence_size(namespace_declarations); i++) { + struct namespace_decl *nd; + raptor_uri *ns_uri = NULL; + + nd = (struct namespace_decl*)raptor_sequence_get_at(namespace_declarations, i); + if(nd->uri_string) + ns_uri = raptor_new_uri(world, nd->uri_string); + + raptor_serializer_set_namespace(serializer, ns_uri, nd->prefix); + if(ns_uri) + raptor_free_uri(ns_uri); + } + raptor_free_sequence(namespace_declarations); + namespace_declarations = NULL; + } + + if(serializer_options) { + option_value *fv; + while((fv = (option_value*)raptor_sequence_pop(serializer_options))) { + raptor_serializer_set_option(serializer, fv->option, + fv->s_value, fv->i_value); + raptor_free_memory(fv); + } + raptor_free_sequence(serializer_options); + serializer_options = NULL; + } + + raptor_serializer_start_to_file_handle(serializer, + output_base_uri, stdout); + + if(!report_namespace) + raptor_parser_set_namespace_handler(rdf_parser, serializer, + relay_namespaces); + } + + + /* Begin the parsing of the content from file or URI, + * sending it to serializer via callback print_triples() + */ + rc = 0; + if(!uri || filename) { + if(raptor_parser_parse_file(rdf_parser, uri, base_uri)) { + fprintf(stderr, "%s: Failed to parse file %s %s content\n", + program, FILENAME_LABEL(filename), syntax_name); + rc = 1; + } + } else { + if(raptor_parser_parse_uri(rdf_parser, uri, base_uri)) { + fprintf(stderr, "%s: Failed to parse URI %s %s content\n", + program, uri_string, syntax_name); + rc = 1; + } + } + + raptor_free_parser(rdf_parser); + + if(serializer) { + raptor_serializer_serialize_end(serializer); + raptor_free_serializer(serializer); + } + + + if(!quiet) { + if(triple_count == 1) + fprintf(stderr, "%s: Parsing returned 1 triple\n", + program); + else + fprintf(stderr, "%s: Parsing returned %ld triples\n", + program, triple_count); + } + + if(output_base_uri) + raptor_free_uri(output_base_uri); + if(base_uri) + raptor_free_uri(base_uri); + if(uri) + raptor_free_uri(uri); + if(free_uri_string) + raptor_free_memory(uri_string); + + if(namespace_declarations) + raptor_free_sequence(namespace_declarations); + if(parser_options) + raptor_free_sequence(parser_options); + if(serializer_options) + raptor_free_sequence(serializer_options); + + raptor_free_world(world); + + if(error_count && !ignore_errors) + return 1; + + if(warning_count && !ignore_warnings) + return 2; + + return(rc); +} diff --git a/utils/rapper.html b/utils/rapper.html new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/utils/rapper.html diff --git a/utils/raptor_getopt.h b/utils/raptor_getopt.h new file mode 100644 index 0000000..56ba8ea --- /dev/null +++ b/utils/raptor_getopt.h @@ -0,0 +1,21 @@ +/* + * Public Domain getopt header + * + */ + +#ifndef RAPTOR_GETOPT_H +#define RAPTOR_GETOPT_H + +#ifdef __cplusplus +extern "C" { +#endif + +int getopt(int argc, char * const argv[], const char *optstring); +extern char *optarg; +extern int optind, opterr, optopt; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/utils/rdfdiff.c b/utils/rdfdiff.c new file mode 100644 index 0000000..fa604e5 --- /dev/null +++ b/utils/rdfdiff.c @@ -0,0 +1,1069 @@ +/* -*- Mode: c; c-basic-offset: 2 -*- + * + * rdfdiff.c - Raptor RDF diff tool + * + * Copyright (C) 2000-2008, David Beckett http://www.dajobe.org/ + * Copyright (C) 2000-2005, University of Bristol, UK http://www.bristol.ac.uk/ + * Copyright (C) 2005, Steve Shepard steveshep@gmail.com + * + * 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. + * + * + */ + + +#ifdef HAVE_CONFIG_H +#include <raptor_config.h> +#endif + +#include <stdio.h> +#include <string.h> + +/* Raptor includes */ +#include <raptor2.h> +#include <raptor_internal.h> + +/* for access() and R_OK */ +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif +#ifdef WIN32 +#include <io.h> +#endif + +/* many places for getopt */ +#ifdef HAVE_GETOPT_H +#include <getopt.h> +#else +#include <raptor_getopt.h> +#endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + +#if 0 +#undef RAPTOR_DEBUG +#define RAPTOR_DEBUG 2 +#endif + +#ifndef RAPTOR_INTERNAL +#define RAPTOR_MALLOC(type, size) (type)malloc(size) +#define RAPTOR_CALLOC(type, nmemb, size) (type)calloc(nmemb, size) +#define RAPTOR_FREE(type, ptr) free((void*)ptr) +#endif + +#ifdef NEED_OPTIND_DECLARATION +extern int optind; +extern char *optarg; +#endif + +#define MAX_ASCII_INT_SIZE 13 +#define RDF_NAMESPACE_URI_LEN 43 +#define ORDINAL_STRING_LEN (RDF_NAMESPACE_URI_LEN + MAX_ASCII_INT_SIZE + 1) + +#define GETOPT_STRING "bhf:t:u:" + +#ifdef HAVE_GETOPT_LONG +static const struct option long_options[] = +{ + /* name, has_arg, flag, val */ + {"brief" , 0, 0, 'b'}, + {"help" , 0, 0, 'h'}, + {"from-format" , 1, 0, 'f'}, + {"to-format" , 1, 0, 't'}, + {"base-uri" , 1, 0, 'u'}, + {NULL , 0, 0, 0} +}; +#endif + +#ifdef HAVE_GETOPT_LONG +#define HELP_TEXT(short, long, description) " -" short ", --" long " " description +#define HELP_ARG(short, long) "--" #long +#define HELP_PAD "\n " +#else +#define HELP_TEXT(short, long, description) " -" short " " description +#define HELP_ARG(short, long) "-" #short +#define HELP_PAD "\n " +#endif + +typedef struct rdfdiff_link_s { + struct rdfdiff_link_s *next; + raptor_statement *statement; +} rdfdiff_link; + +typedef struct rdfdiff_blank_s { + struct rdfdiff_blank_s *next; + raptor_world *world; + char *blank_id; + raptor_statement *owner; + rdfdiff_link *first; + rdfdiff_link *last; + int matched; +} rdfdiff_blank; + +typedef struct { + raptor_world *world; + char *name; + raptor_parser *parser; + rdfdiff_link *first; + rdfdiff_link *last; + rdfdiff_blank *first_blank; + rdfdiff_blank *last_blank; + int statement_count; + int error_count; + int warning_count; + int difference_count; +} rdfdiff_file; + +static int brief = 0; +static char *program = NULL; +static const char * const title_string="Raptor RDF diff utility"; +static int ignore_errors = 0; +static int ignore_warnings = 0; +static int emit_from_header = 1; +static int emit_to_header = 1; + +static rdfdiff_file* from_file = NULL; +static rdfdiff_file*to_file = NULL; + +static rdfdiff_file* rdfdiff_new_file(raptor_world* world, const unsigned char *name, const char *syntax); +static void rdfdiff_free_file(rdfdiff_file* file); + +static rdfdiff_blank *rdfdiff_find_blank(rdfdiff_blank *first, char *blank_id); +static rdfdiff_blank *rdfdiff_new_blank(raptor_world *world, char *blank_id); +static void rdfdiff_free_blank(rdfdiff_blank *blank); + +static int rdfdiff_blank_equals(const rdfdiff_blank *b1, const rdfdiff_blank *b2, + rdfdiff_file*b1_file, rdfdiff_file*b2_file); + +static void rdfdiff_log_handler(void *data, raptor_log_message *message); + +static void rdfdiff_collect_statements(void *user_data, raptor_statement *statement); + +int main(int argc, char *argv[]); + + +/* Version of strcmp that can take NULL parameters. Assume that + * Non-NULL strings are lexically greater than NULL strings + */ +static int +safe_strcmp(const char *s1, const char *s2) +{ + if(s1 == NULL && s2 == NULL) { + return 0; + } else if(s1 == NULL && s2 != NULL) { + return -1; + } else if(s1 != NULL && s2 == NULL) { + return 1; + } else { + return strcmp(s1, s2); + } + +} + + +static rdfdiff_file* +rdfdiff_new_file(raptor_world *world, const unsigned char *name, const char *syntax) +{ + rdfdiff_file* file = RAPTOR_CALLOC(rdfdiff_file*, 1, sizeof(*file)); + if(file) { + size_t name_len = strlen((const char*)name); + file->world = world; + file->name = RAPTOR_MALLOC(char*, name_len + 1); + if(!file->name) { + rdfdiff_free_file(file); + return(0); + } + memcpy(file->name, name, name_len + 1); + + file->parser = raptor_new_parser(world, syntax); + if(file->parser) { + raptor_world_set_log_handler(world, file, rdfdiff_log_handler); + } else { + fprintf(stderr, "%s: Failed to create raptor parser type %s for %s\n", + program, syntax, name); + rdfdiff_free_file(file); + return(0); + } + + + } + + return file; +} + + +static void +rdfdiff_free_file(rdfdiff_file* file) +{ + rdfdiff_link *cur, *next; + rdfdiff_blank *cur1, *next1; + + if(file->name) + RAPTOR_FREE(char*, file->name); + + if(file->parser) + raptor_free_parser(file->parser); + + for(cur = file->first; cur; cur = next) { + next = cur->next; + + raptor_free_statement(cur->statement); + RAPTOR_FREE(rdfdiff_link, cur); + } + + for(cur1 = file->first_blank; cur1; cur1 = next1) { + next1 = cur1->next; + + rdfdiff_free_blank(cur1); + } + + RAPTOR_FREE(rdfdiff_file, file); + +} + + +static rdfdiff_blank * +rdfdiff_new_blank(raptor_world* world, char *blank_id) +{ + rdfdiff_blank *blank = RAPTOR_CALLOC(rdfdiff_blank*, 1, sizeof(*blank)); + + if(blank) { + size_t blank_id_len = strlen(blank_id); + blank->world = world; + blank->blank_id = RAPTOR_MALLOC(char*, blank_id_len + 1); + if(!blank->blank_id) { + rdfdiff_free_blank(blank); + return NULL; + } + + memcpy(blank->blank_id, blank_id, blank_id_len + 1); + } + + return blank; +} + + +static void +rdfdiff_free_blank(rdfdiff_blank *blank) +{ + rdfdiff_link *cur, *next; + + if(blank->blank_id) + RAPTOR_FREE(char*, blank->blank_id); + + if(blank->owner) + raptor_free_statement(blank->owner); + + for(cur = blank->first; cur; cur = next) { + next = cur->next; + + raptor_free_statement(cur->statement); + RAPTOR_FREE(rdfdiff_link, cur); + } + + RAPTOR_FREE(rdfdiff_blank, blank); + +} + + +static int +rdfdiff_statement_equals(raptor_world *world, const raptor_statement *s1, const raptor_statement *s2) +{ + int rv = 0; + + if(!s1 || !s2) + return 0; + +#if defined(RAPTOR_DEBUG) && RAPTOR_DEBUG > 1 + fprintf(stderr, "(rdfdiff_statement_equals) Comparing "); + raptor_statement_print_as_ntriples(s1, stderr); + fprintf(stderr, " to "); + raptor_statement_print_as_ntriples(s2, stderr); +#endif + + /* normal comparison */ + if(s1->subject->type != s2->subject->type) { + rv = 0; + goto done; + } + + if(s1->subject->type == RAPTOR_TERM_TYPE_BLANK) { + /* Here for completeness. Anonymous nodes are taken care of + * elsewhere */ + /*if(strcmp((const char *)s1->subject, (const char *)s2->subject->value) != 0) + return 0;*/ + } else { + if(!raptor_uri_equals(s1->subject->value.uri, + s2->subject->value.uri)) { + rv = 0; + goto done; + } + } + + if(s1->predicate->type != s2->predicate->type) { + rv = 0; + goto done; + } + + if(!raptor_uri_equals(s1->predicate->value.uri, + s2->predicate->value.uri)) { + rv = 0; + goto done; + } + + if(s1->object->type != s2->object->type) { + rv = 0; + goto done; + } + + if(s1->object->type == RAPTOR_TERM_TYPE_LITERAL) { + int equal; + + equal= !safe_strcmp((char *)s1->object->value.literal.string, + (char *)s2->object->value.literal.string); + + if(equal) { + if(s1->object->value.literal.language && s2->object->value.literal.language) + equal = !strcmp((char *)s1->object->value.literal.language, + (char *)s2->object->value.literal.language); + else if(s1->object->value.literal.language || s2->object->value.literal.language) + equal = 0; + else + equal = 1; + + if(equal) + equal = raptor_uri_equals(s1->object->value.literal.datatype, + s2->object->value.literal.datatype); + } + + rv = equal; + goto done; + } else if(s1->object->type == RAPTOR_TERM_TYPE_BLANK) { + /* Here for completeness. Anonymous nodes are taken care of + * elsewhere */ + /* if(strcmp((const char *)s1->object, (const char *)s2->object->value) != 0) + return 0; */ + } else { + if(!raptor_uri_equals(s1->object->value.uri, + s2->object->value.uri)) { + rv = 0; + goto done; + } + } + + rv = 1; + done: + +#if defined(RAPTOR_DEBUG) && RAPTOR_DEBUG > 1 + fprintf(stderr, " : %s\n", (rv ? "equal" : "not equal")); +#endif + return rv; +} + + +static int +rdfdiff_blank_equals(const rdfdiff_blank *b1, const rdfdiff_blank *b2, + rdfdiff_file *b1_file, rdfdiff_file *b2_file) +{ + /* first compare "owners". Owners are subject/predicate or arcs + * in. */ + int equal = 0; + + if(b1->owner == NULL && b2->owner == NULL) { + /* Both are "top-level" anonymous objects. I.E. Neither is the + * object of a statement. Fall through and compare based on their + * contents. */ + equal = 1; + } else if(b1->owner == NULL || b2->owner == NULL) { + equal = 0; + } else if(b1->owner->subject->type != RAPTOR_TERM_TYPE_BLANK && + b2->owner->subject->type != RAPTOR_TERM_TYPE_BLANK) { + /* Neither are anonymous. Normal comparison. This will return + * false if both the subject and the predicates don't match. We + * know the objects are blank nodes. */ + equal = rdfdiff_statement_equals(b1->world, b1->owner, b2->owner); + + } else if(b1->owner->subject->type == RAPTOR_TERM_TYPE_BLANK && + b2->owner->subject->type == RAPTOR_TERM_TYPE_BLANK) { + rdfdiff_blank *p1; + rdfdiff_blank *p2; + + /* Both are anonymous. Need further testing. Check that the + * containing anononymous nodes are eaual. */ +#if 0 + fprintf(stderr, "b1->owner: "); + raptor_statement_print_as_ntriples(b1->owner, stderr); + fprintf(stderr, "\n"); + + fprintf(stderr, "b2->owner: "); + raptor_statement_print_as_ntriples(b2->owner, stderr); + fprintf(stderr, "\n"); +#endif + p1 = rdfdiff_find_blank(b1_file->first_blank, + (char *)b1->owner->subject->value.blank.string); + p2 = rdfdiff_find_blank(b2_file->first_blank, + (char *)b2->owner->subject->value.blank.string); + equal = rdfdiff_blank_equals(p1, p2, b1_file, b2_file); + } else { + equal = 0; + } + + /* Now compare the contents. This accounts for the case where a + * subject has several properties (of the same predicate value) with + * different blank nodes as values. */ + if(equal) { + rdfdiff_link *s1 = b1->first; + while(s1) { + + rdfdiff_link *s2 = b2->first; + while(s2) { + + if(rdfdiff_statement_equals(b1->world, s1->statement, s2->statement)) + break; + + s2 = s2->next; + + } + + if(s2 == 0) { + equal = 0; + break; + } + + s1 = s1->next; + + } + + } + + return equal; +} + + +static void +rdfdiff_log_handler(void *data, raptor_log_message *message) +{ + rdfdiff_file* file = (rdfdiff_file*)data; + + switch(message->level) { + case RAPTOR_LOG_LEVEL_FATAL: + case RAPTOR_LOG_LEVEL_ERROR: + if(!ignore_errors) { + fprintf(stderr, "%s: Error - ", program); + raptor_locator_print(message->locator, stderr); + fprintf(stderr, " - %s\n", message->text); + + raptor_parser_parse_abort(file->parser); + } + + file->error_count++; + break; + + case RAPTOR_LOG_LEVEL_WARN: + if(!ignore_warnings) { + fprintf(stderr, "%s: Warning - ", program); + raptor_locator_print(message->locator, stderr); + fprintf(stderr, " - %s\n", message->text); + } + + file->warning_count++; + break; + + case RAPTOR_LOG_LEVEL_NONE: + case RAPTOR_LOG_LEVEL_TRACE: + case RAPTOR_LOG_LEVEL_DEBUG: + case RAPTOR_LOG_LEVEL_INFO: + + fprintf(stderr, "%s: Unexpected %s message - ", program, + raptor_log_level_get_label(message->level)); + raptor_locator_print(message->locator, stderr); + fprintf(stderr, " - %s\n", message->text); + break; + } + +} + + + +static rdfdiff_blank * +rdfdiff_find_blank(rdfdiff_blank *first, char *blank_id) +{ + rdfdiff_blank *rv_blank = 0; + rdfdiff_blank *cur = first; + + while(cur) { + + if(strcmp(cur->blank_id, blank_id) == 0) { + rv_blank = cur; + break; + } + + cur = cur->next; + + } + + return rv_blank; + +} + + +static rdfdiff_blank * +rdfdiff_lookup_blank(rdfdiff_file* file, char *blank_id) +{ + rdfdiff_blank *rv_blank = rdfdiff_find_blank(file->first_blank, blank_id); + + if(!rv_blank) { + rv_blank = rdfdiff_new_blank(file->world, blank_id); + if(rv_blank) { + + if(!file->first_blank) { + file->first_blank = rv_blank; + file->last_blank = rv_blank; + } else { + file->last_blank->next = rv_blank; + file->last_blank = rv_blank; + } + } + } + + return rv_blank; + +} + + +static int +rdfdiff_add_blank_statement(rdfdiff_file* file, + raptor_statement *statement) +{ + rdfdiff_blank *blank; + rdfdiff_link *dlink; + + blank = rdfdiff_lookup_blank(file, (char *)statement->subject->value.blank.string); + if(!blank) + goto failed; + + dlink = RAPTOR_MALLOC(rdfdiff_link*, sizeof(*dlink)); + if(!dlink) + goto failed; + + dlink->statement = raptor_statement_copy(statement); + if(!dlink->statement) { + RAPTOR_FREE(rdfdiff_link, dlink); + goto failed; + } + + dlink->next = NULL; + if(!blank->first) { + blank->first = dlink; + blank->last = dlink; + } else { + blank->last->next = dlink; + blank->last = dlink; + } + + return 0; + +failed: + fprintf(stderr, "%s: Internal Error\n", program); + return 1; +} + + +static int +rdfdiff_add_blank_statement_owner(rdfdiff_file* file, + raptor_statement *statement) +{ + rdfdiff_blank *blank; + + blank = rdfdiff_lookup_blank(file, + (char*)statement->object->value.blank.string); + if(!blank) + goto failed; + + if(blank->owner) + raptor_free_statement(blank->owner); + + blank->owner = raptor_statement_copy(statement); + if(!blank->owner) + goto failed; + + return 0; + +failed: + fprintf(stderr, "%s: Internal Error\n", program); + return 1; +} + + +static int +rdfdiff_add_statement(rdfdiff_file* file, raptor_statement *statement) +{ + int rv = 0; + + rdfdiff_link *dlink = RAPTOR_MALLOC(rdfdiff_link*, sizeof(*dlink)); + + if(dlink) { + + dlink->statement = raptor_statement_copy(statement); + + if(dlink->statement) { + + dlink->next = NULL; + + if(!file->first) { + file->first = dlink; + file->last = dlink; + } else { + file->last->next = dlink; + file->last = dlink; + } + + } else { + RAPTOR_FREE(rdfdiff_link, dlink); + rv = 1; + } + + } else { + rv = 1; + } + + if(rv != 0) + fprintf(stderr, "%s: Internal Error\n", program); + + return rv; + +} + + +static rdfdiff_link* +rdfdiff_statement_find(rdfdiff_file* file, const raptor_statement *statement, + rdfdiff_link** prev_p) +{ + rdfdiff_link* prev = NULL; + rdfdiff_link* cur = file->first; + + while(cur) { + if(rdfdiff_statement_equals(file->world, cur->statement, statement)) { + if(prev_p) + *prev_p=prev; + return cur; + } + prev = cur; + cur = cur->next; + } + + return NULL; +} + + +static int +rdfdiff_statement_exists(rdfdiff_file* file, const raptor_statement *statement) +{ + rdfdiff_link* node; + rdfdiff_link* prev = NULL; + node = rdfdiff_statement_find(file, statement, &prev); + return (node != NULL); +} + + +/* + * rdfdiff_collect_statements - Called when parsing "from" file to build a + * list of statements for comparison with those in the "to" file. + */ +static void +rdfdiff_collect_statements(void *user_data, raptor_statement *statement) +{ + int rv = 0; + rdfdiff_file* file = (rdfdiff_file*)user_data; + + if(rdfdiff_statement_exists(file, statement)) + return; + + file->statement_count++; + + if(statement->subject->type == RAPTOR_TERM_TYPE_BLANK || + statement->object->type == RAPTOR_TERM_TYPE_BLANK) { + + if(statement->subject->type == RAPTOR_TERM_TYPE_BLANK) + rv = rdfdiff_add_blank_statement(file, statement); + + if(rv == 0 && statement->object->type == RAPTOR_TERM_TYPE_BLANK) + rv = rdfdiff_add_blank_statement_owner(file, statement); + + } else { + rv = rdfdiff_add_statement(file, statement); + } + + if(rv != 0) { + raptor_parser_parse_abort(file->parser); + } + +} + + + +int +main(int argc, char *argv[]) +{ + raptor_world *world = NULL; + unsigned char *from_string = NULL; + unsigned char *to_string = NULL; + raptor_uri *from_uri = NULL; + raptor_uri *to_uri = NULL; + raptor_uri *base_uri = NULL; + const char *from_syntax = "rdfxml"; + const char *to_syntax = "rdfxml"; + int free_from_string = 0; + int free_to_string = 0; + int usage = 0; + int help = 0; + char *p; + int rv = 0; + rdfdiff_blank *b1; + rdfdiff_link *cur; + + program = argv[0]; + if((p = strrchr(program, '/'))) + program = p+1; + else if((p = strrchr(program, '\\'))) + program = p+1; + argv[0] = program; + + world = raptor_new_world(); + if(!world) + exit(1); + rv = raptor_world_open(world); + if(rv) + exit(1); + + while(!usage && !help) + { + int c; +#ifdef HAVE_GETOPT_LONG + int option_index = 0; + + c = getopt_long (argc, argv, GETOPT_STRING, long_options, &option_index); +#else + c = getopt (argc, argv, GETOPT_STRING); +#endif + if(c == -1) + break; + + switch (c) { + case 0: + case '?': /* getopt() - unknown option */ + usage = 1; + break; + + case 'b': + brief = 1; + break; + + case 'h': + help = 1; + break; + + case 'f': + if(optarg) + from_syntax = optarg; + break; + + case 't': + if(optarg) + to_syntax = optarg; + break; + + case 'u': + if(optarg) + base_uri = raptor_new_uri(world, (const unsigned char*)optarg); + break; + + } + + } + + if(optind != argc-2 && !help && !usage) { + usage = 2; /* Title and usage */ + } + + if(usage) { + if(usage > 1) { + fputs(title_string, stderr); putc(' ', stderr); fputs(raptor_version_string, stderr); putc('\n', stderr); + fputs(raptor_short_copyright_string, stderr); + fputc('\n', stderr); + } + fprintf(stderr, "Try `%s " HELP_ARG(h, help) "' for more information.\n", + program); + rv = 1; + goto exit; + } + + if(help) { + printf("Usage: %s [OPTIONS] <from URI> <to URI>\n", program); + puts(title_string); putchar(' '); puts(raptor_version_string); putchar('\n'); + puts(raptor_short_copyright_string); + puts("Find differences between two RDF files."); + puts("\nOPTIONS:"); + puts(HELP_TEXT("h", "help ", "Print this help, then exit")); + puts(HELP_TEXT("b", "brief ", "Report only whether files differ")); + puts(HELP_TEXT("u BASE-URI", "base-uri BASE-URI ", "Set the base URI for the files")); + puts(HELP_TEXT("f FORMAT", "from-format FORMAT ", "Format of <from URI> (default is rdfxml)")); + puts(HELP_TEXT("t FORMAT", "to-format FORMAT ", "Format of <to URI> (default is rdfxml)")); + rv = 1; + goto exit; + } + + from_string = (unsigned char *)argv[optind++]; + to_string = (unsigned char *)argv[optind]; + + if(!access((const char *)from_string, R_OK)) { + char *filename = (char *)from_string; + from_string = raptor_uri_filename_to_uri_string(filename); + if(!from_string) { + fprintf(stderr, "%s: Failed to create URI for file %s.\n", program, filename); + rv = 2; + goto exit; + } + free_from_string = 1; + } + + if(!access((const char *)to_string, R_OK)) { + char *filename = (char *)to_string; + to_string = raptor_uri_filename_to_uri_string(filename); + if(!to_string) { + fprintf(stderr, "%s: Failed to create URI for file %s.\n", program, filename); + rv = 2; + goto exit; + } + free_to_string = 1; + } + + from_uri = raptor_new_uri(world, from_string); + if(!from_uri) { + fprintf(stderr, "%s: Failed to create URI for %s\n", program, from_string); + rv = 2; + goto exit; + } + + to_uri = raptor_new_uri(world, to_string); + if(!to_uri) { + fprintf(stderr, "%s: Failed to create URI for %s\n", program, from_string); + rv = 2; + goto exit; + } + + /* create and init "from" data structures */ + from_file = rdfdiff_new_file(world, from_string, from_syntax); + if(!from_file) { + rv = 2; + goto exit; + } + + /* create and init "to" data structures */ + to_file = rdfdiff_new_file(world, to_string, to_syntax); + if(!to_file) { + rv = 2; + goto exit; + } + + /* parse the files */ + raptor_parser_set_statement_handler(from_file->parser, from_file, + rdfdiff_collect_statements); + + if(raptor_parser_parse_uri(from_file->parser, from_uri, base_uri)) { + fprintf(stderr, "%s: Failed to parse URI %s as %s content\n", program, + from_string, from_syntax); + rv = 1; + goto exit; + } else { + + /* Note intentional from_uri as base_uri */ + raptor_parser_set_statement_handler(to_file->parser, to_file, + rdfdiff_collect_statements); + if(raptor_parser_parse_uri(to_file->parser, to_uri, base_uri ? base_uri: from_uri)) { + fprintf(stderr, "%s: Failed to parse URI %s as %s content\n", program, + to_string, to_syntax); + rv = 1; + goto exit; + } + } + + + /* Compare triples with no blank nodes */ + cur = to_file->first; + while(cur) { + rdfdiff_link* node; + rdfdiff_link* prev; + node = rdfdiff_statement_find(from_file, cur->statement, &prev); + if(node) { + /* exists in from file - remove it from the list */ + if(from_file->first == node) { + from_file->first = node->next; + } else { + prev->next = node->next; + } + raptor_free_statement(node->statement); + RAPTOR_FREE(rdfdiff_link, node); + } else { + if(!brief) { + if(emit_from_header) { + fprintf(stderr, "Statements in %s but not in %s\n", + to_file->name, from_file->name); + emit_from_header = 0; + } + + fprintf(stderr, "< "); + raptor_statement_print_as_ntriples(cur->statement, stderr); + fprintf(stderr, "\n"); + } + + to_file->difference_count++; + } + cur = cur->next; + } + + + /* Now compare the blank nodes */ + b1 = to_file->first_blank; + while(b1) { + + rdfdiff_blank *b2 = from_file->first_blank; + + while(b2) { + + if(!b2->matched && rdfdiff_blank_equals(b1, b2, to_file, from_file)) { + b1->matched = 1; + b2->matched = 1; + break; + } + + b2 = b2->next; + + } + + if(b2 == 0) { + if(!brief) { +#if 0 + fprintf(stderr, "< "); + raptor_statement_print_as_ntriples(b1->owner, stderr); + fprintf(stderr, "\n"); +#else + if(emit_from_header) { + fprintf(stderr, "Statements in %s but not in %s\n", to_file->name, from_file->name); + emit_from_header = 0; + } + + fprintf(stderr, "< anonymous node %s\n", b1->blank_id); +#endif + } + + to_file->difference_count++; + } + + b1 = b1->next; + + } + + if(from_file->first) { + /* The entrys left in from_file have not been found in to_file. */ + if(!brief) { + + if(emit_to_header) { + fprintf(stderr, "Statements in %s but not in %s\n", from_file->name, + to_file->name); + emit_to_header = 0; + } + + cur = from_file->first; + while(cur) { + if(!brief) { + fprintf(stderr, "> "); + raptor_statement_print_as_ntriples(cur->statement, stderr); + fprintf(stderr, "\n"); + } + + cur = cur->next; + from_file->difference_count++; + } + } + + } + + if(from_file->first_blank) { + rdfdiff_blank *blank = from_file->first_blank; + while(blank) { + + if(!blank->matched) { + if(!brief) { +#if 0 + fprintf(stderr, "> "); + raptor_statement_print_as_ntriples(blank->owner, stderr); + fprintf(stderr, "\n"); +#else + if(emit_to_header) { + fprintf(stderr, "Statements in %s but not in %s\n", from_file->name, to_file->name); + emit_to_header = 0; + } + fprintf(stderr, "> anonymous node %s\n", blank->blank_id); +#endif + } + from_file->difference_count++; + } + + blank = blank->next; + + } + + } + + if(!(from_file->difference_count == 0 && + to_file->difference_count == 0)) { + + if(brief) + fprintf(stderr, "Files differ\n"); + + rv = 1; + } + +exit: + + if(base_uri) + raptor_free_uri(base_uri); + + if(from_file) + rdfdiff_free_file(from_file); + + if(to_file) + rdfdiff_free_file(to_file); + + if(free_from_string) + raptor_free_memory(from_string); + + if(free_to_string) + raptor_free_memory(to_string); + + if(from_uri) + raptor_free_uri(from_uri); + + if(to_uri) + raptor_free_uri(to_uri); + + raptor_free_world(world); + + return rv; + +} + |