From: Steinar H. Gunderson Date: Tue, 14 May 2013 20:46:36 +0000 (+0200) Subject: Add the PHP module. X-Git-Url: https://git.sesse.net/?p=itkacl;a=commitdiff_plain;h=de9a4d80bde793f8d6b266fa3c0e55ee618ecc1b;hp=984e5ade2fc82719cdb7404d4babc68755040055;ds=sidebyside Add the PHP module. --- diff --git a/php5-itkacl-2.0/Makefile b/php5-itkacl-2.0/Makefile new file mode 100644 index 0000000..74968dc --- /dev/null +++ b/php5-itkacl-2.0/Makefile @@ -0,0 +1,21 @@ +CXX=g++ +CXXFLAGS=-fPIC -O2 -g +EXT_DIR=$(DESTDIR)$(shell php-config --extension-dir)/ + +php_itkacl.so: itkacl_wrap.o + $(CXX) -shared -o php_itkacl.so itkacl_wrap.o -litkacl + +itkacl_wrap.o: itkacl_wrap.cpp + $(CXX) $(shell php-config --includes) $(CXXFLAGS) -c itkacl_wrap.cpp -o itkacl_wrap.o + +itkacl_wrap.cpp: + swig -php5 -c++ itkacl.i + +clean: + $(RM) itkacl.php itkacl_wrap.cpp itkacl_wrap.o php_itkacl.h php_itkacl.so + +install: + mkdir -p $(EXT_DIR) + install php_itkacl.so $(EXT_DIR) + +.PHONY: clean install diff --git a/php5-itkacl-2.0/debian/changelog b/php5-itkacl-2.0/debian/changelog new file mode 100644 index 0000000..9f4f4b3 --- /dev/null +++ b/php5-itkacl-2.0/debian/changelog @@ -0,0 +1,5 @@ +php5-itkacl (2.0) unstable; urgency=low + + * Initial release. + + -- Steinar H. Gunderson Tue, 14 May 2013 19:02:22 +0200 diff --git a/php5-itkacl-2.0/debian/compat b/php5-itkacl-2.0/debian/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/php5-itkacl-2.0/debian/compat @@ -0,0 +1 @@ +7 diff --git a/php5-itkacl-2.0/debian/control b/php5-itkacl-2.0/debian/control new file mode 100644 index 0000000..288ecb1 --- /dev/null +++ b/php5-itkacl-2.0/debian/control @@ -0,0 +1,13 @@ +Source: php5-itkacl +Priority: extra +Maintainer: Steinar H. Gunderson +Build-Depends: debhelper (>= 7.0.50~), libitkacl-dev, php5-dev +Standards-Version: 3.9.1 +Section: php + +Package: php5-itkacl +Section: php +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, ${php:Depends} +Description: PHP bindings for ITKACL + PHP module to interface to ITKACL. diff --git a/php5-itkacl-2.0/debian/itkacl.ini b/php5-itkacl-2.0/debian/itkacl.ini new file mode 100644 index 0000000..9cc3ed4 --- /dev/null +++ b/php5-itkacl-2.0/debian/itkacl.ini @@ -0,0 +1,2 @@ +; configuration for php itkacl module +extension=php_itkacl.so diff --git a/php5-itkacl-2.0/debian/php5-itkacl.dirs b/php5-itkacl-2.0/debian/php5-itkacl.dirs new file mode 100644 index 0000000..8ca3a0f --- /dev/null +++ b/php5-itkacl-2.0/debian/php5-itkacl.dirs @@ -0,0 +1 @@ +etc/php5/conf.d diff --git a/php5-itkacl-2.0/debian/rules b/php5-itkacl-2.0/debian/rules new file mode 100755 index 0000000..f177e9e --- /dev/null +++ b/php5-itkacl-2.0/debian/rules @@ -0,0 +1,34 @@ +#!/usr/bin/make -f +# -*- makefile -*- + +clean: + dh_testdir + dh_clean + $(MAKE) clean + +build: + dh_testdir + $(MAKE) + +binary-indep: + +binary-arch: + dh_testroot + dh_prep + dh_installdirs + $(MAKE) install DESTDIR=debian/php5-itkacl + install -m 0644 -o root -g root debian/itkacl.ini debian/php5-itkacl/etc/php5/conf.d/ + dh_installdocs + dh_installchangelogs + dh_compress + dh_fixperms + dh_strip + dh_makeshlibs + dh_shlibdeps + echo "php:Depends=phpapi-$(shell php-config --phpapi)" >> debian/php5-itkacl.substvars + dh_installdeb + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-arch diff --git a/php5-itkacl-2.0/itkacl.i b/php5-itkacl-2.0/itkacl.i new file mode 100644 index 0000000..18ae21c --- /dev/null +++ b/php5-itkacl-2.0/itkacl.i @@ -0,0 +1,34 @@ +/* SWIG interface for libitkacl */ +%module itkacl +%include exception.i + +/* + * ITKACL now threadsafe using exceptions found in PHP5. + * -1 is return on unexpected event, eg. realm doesn't exist. + * + * The naming of the class is somewhat braindamaged due to SWIG + * restrictions. + */ +%inline %{ + /* This is due to Swig forgetting one file */ + #include + + extern "C" int itkacl_check(char *realm, char *user, char *errmsg, size_t errmsgsize); + + class itkaclwrap { + public: + static int check(char *realm, char *user); + }; + + int itkaclwrap::check(char *realm, char *user) + { + char itkacl_errmsg[1024]; + int ret = itkacl_check(realm, user, itkacl_errmsg, 1024); + if (ret == -1) { + SWIG_exception(SWIG_RuntimeError,itkacl_errmsg); + } else { + return ret == 0; + } + } +%} +