]> git.sesse.net Git - itkacl/blobdiff - php5-itkacl-2.0/itkacl.i
Add the PHP module.
[itkacl] / php5-itkacl-2.0 / itkacl.i
diff --git a/php5-itkacl-2.0/itkacl.i b/php5-itkacl-2.0/itkacl.i
new file mode 100644 (file)
index 0000000..18ae21c
--- /dev/null
@@ -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 <php5/Zend/zend_exceptions.h>
+
+       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;
+               }
+       }
+%}
+