X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=php7-itkacl-2.0%2Fitkacl.i;fp=php7-itkacl-2.0%2Fitkacl.i;h=06eef1e77fc83b4656983ec3fe2e03a75bcd8c21;hb=e51368f580164e7324c706501758aaf56a4fa312;hp=0000000000000000000000000000000000000000;hpb=dd2c1b4524d195a4d191d9cb7bbe6c3adb0aa2bb;p=itkacl diff --git a/php7-itkacl-2.0/itkacl.i b/php7-itkacl-2.0/itkacl.i new file mode 100644 index 0000000..06eef1e --- /dev/null +++ b/php7-itkacl-2.0/itkacl.i @@ -0,0 +1,39 @@ +/* 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 %{ + 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); +thrown: return -1; + } else { + return ret == 0; + } + } +%} + +%pragma(php) code=" +class itkacl { + static function check($realm,$user) { + return itkaclwrap_check($realm,$user); + } +} " +