]> git.sesse.net Git - itkacl/blob - php5-itkacl-2.0/itkacl.i
Release version 2.1 of the core library.
[itkacl] / php5-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         /* This is due to Swig forgetting one file */
14         #include <php5/Zend/zend_exceptions.h>
15
16         extern "C" int itkacl_check(char *realm, char *user, char *errmsg, size_t errmsgsize);
17         
18         class itkaclwrap {
19         public:
20                 static int check(char *realm, char *user);
21         };
22         
23         int itkaclwrap::check(char *realm, char *user)
24         {
25                 char itkacl_errmsg[1024];
26                 int ret = itkacl_check(realm, user, itkacl_errmsg, 1024);
27                 if (ret == -1) {
28                         SWIG_exception(SWIG_RuntimeError,itkacl_errmsg);
29                 } else {
30                         return ret == 0;
31                 }
32         }
33 %}
34