summaryrefslogtreecommitdiffstats
path: root/libsefs/swig
diff options
context:
space:
mode:
Diffstat (limited to 'libsefs/swig')
-rw-r--r--libsefs/swig/Makefile.am15
-rw-r--r--libsefs/swig/java/MANIFEST.MF.in14
-rw-r--r--libsefs/swig/java/Makefile.am85
-rw-r--r--libsefs/swig/python/Makefile.am39
-rw-r--r--libsefs/swig/sefs.i162
-rw-r--r--libsefs/swig/tcl/Makefile.am37
6 files changed, 352 insertions, 0 deletions
diff --git a/libsefs/swig/Makefile.am b/libsefs/swig/Makefile.am
new file mode 100644
index 0000000..6af1d63
--- /dev/null
+++ b/libsefs/swig/Makefile.am
@@ -0,0 +1,15 @@
+if DO_SWIGIFY_PYTHON
+ MAYBE_PYSWIG = python
+endif
+
+if DO_SWIGIFY_JAVA
+ MAYBE_JSWIG = java
+endif
+
+if DO_SWIGIFY_TCL
+ MAYBE_TCLSWIG = tcl
+endif
+
+SUBDIRS = $(MAYBE_PYSWIG) $(MAYBE_JSWIG) $(MAYBE_TCLSWIG)
+
+dist_noinst_DATA = sefs.i
diff --git a/libsefs/swig/java/MANIFEST.MF.in b/libsefs/swig/java/MANIFEST.MF.in
new file mode 100644
index 0000000..0ac9628
--- /dev/null
+++ b/libsefs/swig/java/MANIFEST.MF.in
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+
+Name: com/tresys/setools/
+Specification-Title: "SETools Java Libraries"
+Specification-Version: "@VERSION@"
+Specification-Vendor: "Tresys Technology"
+Implementation-Title: "com.tresys.setools.sefs"
+Implementation-Version: "@libsefs_version@"
+Implementation-Vendor: "Tresys Technology"
+Extension-List: qpol apol
+qpol-Extension-Name: com.tresys.setools.qpol
+qpol-Implementation-Version: @libqpol_version@
+apol-Extension-Name: com.tresys.setools.apol
+apol-Implementation-Version: @libapol_version@
diff --git a/libsefs/swig/java/Makefile.am b/libsefs/swig/java/Makefile.am
new file mode 100644
index 0000000..088b61b
--- /dev/null
+++ b/libsefs/swig/java/Makefile.am
@@ -0,0 +1,85 @@
+wrappedso_DATA = libjsefs.so.@libsefs_version@
+wrappedso_SONAME = @libsefs_jswig_soname@
+short_name = libjsefs.so
+wrappedsodir = $(libdir)
+
+package_name = com.tresys.setools.sefs
+package_dir = $(dir $(subst .,/,$(package_name)))sefs
+
+wrappedjar_DATA = sefs.jar
+wrappedjardir = $(setoolsdir)
+
+dist_noinst_DATA = $(srcdir)/../sefs.i
+BUILT_SOURCES = sefs_wrap.cc \
+ sefsConstants.java \
+ sefs_db.java \
+ sefs_entry.java \
+ sefs_fcfile.java \
+ sefs_fclist.java \
+ sefs_fclist_type_e.java \
+ sefs_filesystem.java \
+ sefs.java \
+ sefsJNI.java \
+ sefs_query.java \
+ SWIGTYPE_p_dev_t.java \
+ SWIGTYPE_p_f_p_sefs_fclist_p_q_const__sefs_entry_p_void__int.java \
+ SWIGTYPE_p_f_p_void_p_q_const__sefs_fclist_int_p_q_const__char_va_list__void.java \
+ SWIGTYPE_p_ino64_t.java \
+ SWIGTYPE_p_void.java
+
+AM_CXXFLAGS = @DEBUGCXXFLAGS@ @WARNCXXFLAGS@ @PROFILECFLAGS@ @SELINUX_CFLAGS@ \
+ @QPOL_CFLAGS@ -I$(top_builddir) -fpic \
+ -I$(top_srcdir)/libapol/include -I$(top_srcdir)/libsefs/include
+AM_JFLAGS = @DEBUGJFLAGS@ @WARNJFLAGS@ \
+ -classpath $(top_builddir)/libqpol/swig/java/qpol.jar:$(top_builddir)/libapol/swig/java/apol.jar
+AM_LDFLAGS = @DEBUGLDFLAGS@ @WARNLDFLAGS@ @PROFILELDFLAGS@ \
+ @APOL_LIB_FLAG@ @QPOL_LIB_FLAG@ @SEFS_LIB_FLAG@
+DEPENDENCIES = $(top_builddir)/libqpol/src/libqpol.so \
+ $(top_builddir)/libapol/src/libapol.so \
+ $(top_builddir)/libsefs/src/libsefs.so
+
+$(firstword $(BUILT_SOURCES)): $(dist_noinst_DATA) $(DEPENDENCIES)
+ $(SWIG) -c++ $(SWIG_JAVA_OPT) -package $(package_name) -o $@ \
+ -I$(top_srcdir)/libsefs/include -I$(top_srcdir)/libapol/include -I$(top_srcdir)/libqpol/include \
+ -I$(top_srcdir)/libqpol/swig -I$(top_srcdir)/libapol/swig $<
+
+$(wordlist 2,$(words $(BUILT_SOURCES)), $(BUILT_SOURCES)): $(firstword $(BUILT_SOURCES))
+
+$(wrappedso_DATA): $(filter %.cc, $(BUILT_SOURCES))
+ $(CXX) -shared -o $@ $^ $(AM_CXXFLAGS) $(CXXFLAGS) $(SWIG_JAVA_CFLAGS) -DSWIGJAVA=1 $(AM_LDFLAGS) $(LDFLAGS) -Wl,-soname,$(wrappedso_SONAME)
+ $(LN_S) -f $@ $(wrappedso_SONAME)
+ $(LN_S) -f $@ $(short_name)
+
+# Intentionally do not include SWIGTYPE_p_void.java below so that the
+# Java compiler uses the one created in package
+# com.tresys.setools.qpol instead of the one from package
+# com.tresys.setools.sefs.
+java_files = $(filter-out SWIGTYPE_p_void.java, $(filter %.java, $(BUILT_SOURCES)))
+
+classes = $(patsubst %.java, $(package_dir)/%.class, $(java_files))
+
+# Because the Java compiler can generate multiple class files from the
+# same source .java file, putting all of the classes below will result
+# in repeated invocations of javac. Therefore, an alternative is to
+# just depend upon the first class file, and let the Java compiler
+# create the rest of them.
+$(firstword $(classes)): $(java_files)
+ $(JAVAC) $(AM_JFLAGS) $(JAVAFLAGS) -d . $^
+
+$(wordlist 2,$(words $(classes)),$(classes)): $(firstword $(classes))
+
+$(wrappedjar_DATA): MANIFEST.MF
+
+$(wrappedjar_DATA): $(classes)
+ $(JAR) cfm $@ MANIFEST.MF $^
+
+install-data-hook:
+ cd $(DESTDIR)$(wrappedsodir) && $(LN_S) -f $(wrappedso_DATA) $(wrappedso_SONAME)
+ cd $(DESTDIR)$(wrappedsodir) && $(LN_S) -f $(wrappedso_DATA) $(short_name)
+ $(mkdir_p) $(DESTDIR)$(javadir) && cd $(DESTDIR)$(javadir) && $(LN_S) -f $(wrappedjardir)/$(wrappedjar_DATA)
+
+uninstall-local:
+ -rm -rf $(DESTDIR)$(wrappedsodir)/$(wrappedso_SONAME) $(DESTDIR)$(wrappedsodir)/$(short_name)
+ -rm -f $(DESTDIR)$(javadir)/$(wrappedjar_DATA)
+
+MOSTLYCLEANFILES = $(BUILT_SOURCES) $(classes) $(wrappedso_DATA) $(wrappedjar_DATA) $(wrappedso_SONAME) $(short_name)
diff --git a/libsefs/swig/python/Makefile.am b/libsefs/swig/python/Makefile.am
new file mode 100644
index 0000000..f7fb7b3
--- /dev/null
+++ b/libsefs/swig/python/Makefile.am
@@ -0,0 +1,39 @@
+wrappedso_DATA = _sefs.so.@libsefs_version@
+wrappedso_SONAME = @libsefs_pyswig_soname@
+wrappedsodir = $(pkgpyexecdir)
+
+wrappedpy_DATA = sefs.py
+wrappedpydir = $(pkgpyexecdir)
+
+dist_noinst_DATA = $(srcdir)/../sefs.i
+BUILT_SOURCES = sefs_wrap.cc
+
+AM_CXXFLAGS = @DEBUGCXXFLAGS@ @WARNCXXFLAGS@ @PROFILECFLAGS@ @SELINUX_CFLAGS@ \
+ @QPOL_CFLAGS@ @APOL_CFLAGS@ -I$(top_builddir) -fpic \
+ -I$(top_srcdir)/libsefs/include
+AM_LDFLAGS = @DEBUGLDFLAGS@ @WARNLDFLAGS@ @PROFILELDFLAGS@ @PYTHON_LDFLAGS@ \
+ @APOL_LIB_FLAG@ @QPOL_LIB_FLAG@ @SEFS_LIB_FLAG@ @XML_LIBS@
+DEPENDENCIES = $(top_builddir)/libqpol/src/libqpol.so \
+ $(top_builddir)/libapol/src/libapol.so \
+ $(top_builddir)/libsefs/src/libsefs.so
+
+$(BUILT_SOURCES): $(dist_noinst_DATA) $(DEPENDENCIES)
+ $(SWIG) -c++ $(SWIG_PYTHON_OPT) -o $@ \
+ -I$(top_srcdir)/libsefs/include -I$(top_srcdir)/libapol/include -I$(top_srcdir)/libqpol/include \
+ -I$(top_srcdir)/libqpol/swig -I$(top_srcdir)/libapol/swig $<
+
+$(wrappedso_DATA): $(BUILT_SOURCES)
+ $(CXX) -shared -o $@ $^ $(AM_CXXFLAGS) $(CXXFLAGS) $(SWIG_PYTHON_CPPFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -Wl,-soname,$(wrappedso_SONAME)
+ $(LN_S) -f $@ $(wrappedso_SONAME)
+ $(LN_S) -f $@ _sefs.so
+
+$(wrappedpy_DATA): $(BUILT_SOURCES)
+
+install-data-hook:
+ cd $(DESTDIR)$(wrappedsodir) && $(LN_S) -f $(wrappedso_DATA) $(wrappedso_SONAME)
+ cd $(DESTDIR)$(wrappedsodir) && $(LN_S) -f $(wrappedso_DATA) _sefs.so
+
+uninstall-local:
+ -rm -rf $(DESTDIR)$(wrappedsodir)/$(wrappedso_SONAME) $(DESTDIR)$(wrappedsodir)/_sefs.so
+
+MOSTLYCLEANFILES = $(BUILT_SOURCES) $(wrappedso_DATA) $(wrappedpy_DATA) $(wrappedso_SONAME) _sefs.so sefs.pyc
diff --git a/libsefs/swig/sefs.i b/libsefs/swig/sefs.i
new file mode 100644
index 0000000..adc5d7e
--- /dev/null
+++ b/libsefs/swig/sefs.i
@@ -0,0 +1,162 @@
+/**
+ * @file
+ * SWIG declarations for libsefs.
+ *
+ * @author Jeremy A. Mowery jmowery@tresys.com
+ * @author Jason Tang jtang@tresys.com
+ *
+ * Copyright (C) 2006-2007 Tresys Technology, LLC
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+%module sefs
+
+%{
+#include <sefs/db.hh>
+#include <sefs/entry.hh>
+#include <sefs/fcfile.hh>
+#include <sefs/fclist.hh>
+#include <sefs/filesystem.hh>
+#include <sefs/query.hh>
+#include <sefs/util.h>
+%}
+
+%import apol.i
+
+%exception;
+
+%include std_except.i
+
+%{
+#undef BEGIN_EXCEPTION
+#undef END_EXCEPTION
+%}
+
+%inline %{
+ typedef struct apol_string_vector apol_string_vector_t;
+%}
+
+#ifdef SWIGPYTHON
+
+%typemap(out) time_t {
+ $result = PyInt_FromLong((long) $1);
+}
+
+#endif // end of python specific code
+
+#ifdef SWIGJAVA
+
+/* handle size_t correctly in java as architecture independent */
+%typemap(jni) size_t "jlong"
+%typemap(jtype) size_t "long"
+%typemap(jstype) size_t "long"
+%typemap("javaimports") SWIGTYPE, FILE* %{
+import com.tresys.setools.qpol.*;
+import com.tresys.setools.apol.*;
+%}
+/* the following handles the dependencies on qpol and apol */
+%pragma(java) jniclassimports=%{
+import com.tresys.setools.qpol.*;
+import com.tresys.setools.apol.*;
+%}
+%pragma(java) jniclasscode=%{
+ static {
+ try
+ {
+ libsefs_get_version ();
+ }
+ catch (UnsatisfiedLinkError ule)
+ {
+ System.loadLibrary("jsefs");
+ }
+ }
+%}
+%pragma(java) moduleimports=%{
+import com.tresys.setools.qpol.*;
+import com.tresys.setools.apol.*;
+%}
+
+%apply long { time_t }
+
+%javaconst(1);
+
+#else
+/* not in java so handle size_t as architecture dependent */
+#ifdef SWIGWORDSIZE64
+typedef uint64_t size_t;
+#else
+typedef uint32_t size_t;
+#endif
+
+#endif // end of Java specific code
+
+#ifdef SWIGTCL
+
+%wrapper %{
+/* Tcl module's initialization routine is expected to be named
+ * Sefs_Init(), but the output file will be called libtsefs.so instead
+ * of libsefs.so. Therefore add an alias from Tsefs_Init() to the
+ * real Sefs_Init().
+ */
+SWIGEXPORT int Tsefs_Init(Tcl_Interp *interp) {
+ return SWIG_init(interp);
+}
+%}
+
+%typemap(out) time_t {
+ Tcl_SetObjResult(interp, Tcl_NewLongObj((long) $1));
+}
+
+#endif // end of Tcl specific code
+
+
+%nodefaultctor;
+
+#define __attribute__(x)
+
+%ignore sefs_fcfile::fileList() const;
+
+// don't wrap private friend functions
+#define SWIG_FRIENDS
+
+%newobject sefs_fclist::runQuery(sefs_query * query);
+%newobject sefs_entry::toString();
+%newobject sefs_default_file_contexts_get_path();
+
+%include <sefs/fclist.hh>
+%include <sefs/db.hh>
+%include <sefs/entry.hh>
+%include <sefs/fcfile.hh>
+%include <sefs/filesystem.hh>
+%include <sefs/query.hh>
+
+const char *libsefs_get_version (void);
+char *sefs_default_file_contexts_get_path(void);
+
+%inline %{
+ // needed to convert from the results of runQuery() to the entry
+ sefs_entry *sefs_entry_from_void(void *v) {
+ return static_cast<sefs_entry *>(v);
+ }
+%}
+
+%extend sefs_fcfile {
+ const apol_string_vector_t *fileListStrs() const
+ {
+ const apol_vector_t *v = self->fileList();
+ return reinterpret_cast<const apol_string_vector_t*>(v);
+ }
+}
diff --git a/libsefs/swig/tcl/Makefile.am b/libsefs/swig/tcl/Makefile.am
new file mode 100644
index 0000000..7964e52
--- /dev/null
+++ b/libsefs/swig/tcl/Makefile.am
@@ -0,0 +1,37 @@
+wrappedso_DATA = libtsefs.so.@libsefs_version@
+wrappedso_SONAME = @libsefs_tswig_soname@
+short_name = libtsefs.so
+wrappedsodir = $(libdir)/setools/sefs
+
+package_SCRIPTS = pkgIndex.tcl
+packagedir = $(wrappedsodir)
+
+dist_noinst_DATA = $(srcdir)/../sefs.i
+BUILT_SOURCES = sefs_wrap.cc
+
+AM_CXXFLAGS = @DEBUGCXXFLAGS@ @WARNCXXFLAGS@ @PROFILECFLAGS@ @SELINUX_CFLAGS@ \
+ @QPOL_CFLAGS@ @APOL_CFLAGS@ -I$(top_builddir) -fpic \
+ -I$(top_srcdir)/libsefs/include
+AM_LDFLAGS = @DEBUGLDFLAGS@ @WARNLDFLAGS@ @PROFILELDFLAGS@ @TCL_LIB_SPEC@ \
+ @SEFS_LIB_FLAG@ @APOL_LIB_FLAG@ @QPOL_LIB_FLAG@
+DEPENDENCIES = $(top_builddir)/libqpol/src/libqpol.so \
+ $(top_builddir)/libapol/src/libapol.so \
+ $(top_builddir)/libsefs/src/libsefs.so
+
+$(BUILT_SOURCES): $(dist_noinst_DATA) $(DEPENDENCIES)
+ $(SWIG) -c++ $(SWIG_TCL_OPT) -pkgversion @libsefs_version@ -o $@ -I$(top_srcdir)/libsefs/include -I$(top_srcdir)/libapol/include -I$(top_srcdir)/libapol/swig -I$(top_srcdir)/libqpol/swig $<
+
+$(wrappedso_DATA): $(BUILT_SOURCES)
+ $(CXX) -shared -o $@ $^ $(AM_CXXFLAGS) $(CXXFLAGS) $(SWIG_TCL_CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -Wl,-soname,$(wrappedso_SONAME)
+ $(LN_S) -f $@ $(wrappedso_SONAME)
+ $(LN_S) -f $@ $(short_name)
+
+$(package_SCRIPTS): $(wrappedso_DATA)
+ echo "pkg_mkIndex . $^" | LD_LIBRARY_PATH=$(top_builddir)/libqpol/src:$(top_builddir)/libapol/src:$(top_builddir)/libsefs/src $(TCLSH_PROG)
+ chmod 644 $@
+ $(mkdir_p) sefs
+ cp $(wrappedso_DATA) $@ sefs
+
+MOSTLYCLEANFILES = $(BUILT_SOURCES) $(wrappedso_DATA) $(wrappedso_SONAME) $(short_name) $(package_DATA) sefs/$(wrappedso_DATA) sefs/$(package_SCRIPTS)
+
+CLEANFILES = $(package_SCRIPTS)