8c5c63ba0998d8ce1cc0f74f0506fb4031559a72
[itkacl] / itkacl.i
1 /* SWIG interface for libitkacl */
2 %module itkacl
3
4 /* Same as for Perl, except that we return a boolean, not an int. */
5 %inline %{
6         extern int itkacl_check(char *realm, char *user, char *errmsg, size_t errmsgsize);
7         PyObject *check(char *realm, char *user)
8         {
9                 char errmsg[1024];
10                 int ret = itkacl_check(realm, user, errmsg, 1024);
11                 if (ret == -1) {
12                         PyErr_SetString(PyExc_RuntimeError, errmsg);
13                         return NULL;
14                 } else {
15                         if (ret == 0) {
16                                 Py_INCREF(Py_True);
17                                 return Py_True;
18                         } else {
19                                 Py_INCREF(Py_False);
20                                 return Py_False;
21                         }
22                 }
23         }
24 %}
25