]> git.sesse.net Git - itkacl/blob - python-itkacl-2.0/itkacl.i
Add a Python module.
[itkacl] / python-itkacl-2.0 / 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