]> git.sesse.net Git - itkacl/blob - php7-itkacl-2.0/itkacl.i
Release a new version of the Apache module, with the context support.
[itkacl] / php7-itkacl-2.0 / itkacl.i
1 /* SWIG interface for libitkacl */
2 %module itkacl
3 %include exception.i     
4
5 /*
6  * ITKACL now threadsafe using exceptions found in PHP5.
7  * -1 is return on unexpected event, eg. realm doesn't exist.
8  *  
9  * The naming of the class is somewhat braindamaged due to SWIG
10  * restrictions.
11  */
12 %inline %{
13         extern "C" int itkacl_check(char *realm, char *user, char *errmsg, size_t errmsgsize);
14         
15         class itkaclwrap {
16         public:
17                 static int check(char *realm, char *user);
18         };
19         
20         int itkaclwrap::check(char *realm, char *user)
21         {
22                 char itkacl_errmsg[1024];
23                 int ret = itkacl_check(realm, user, itkacl_errmsg, 1024);
24                 if (ret == -1) {
25                         SWIG_exception(SWIG_RuntimeError,itkacl_errmsg);
26 thrown: return -1;
27                 } else {
28                         return ret == 0;
29                 }
30         }
31 %}
32
33 %pragma(php) code="
34 class itkacl {
35       static function check($realm,$user) {
36               return itkaclwrap_check($realm,$user);
37       }
38 } "
39