]> asedeno.scripts.mit.edu Git - 1ts-debian.git/blob - python-gss/gssmodule.h
finalize -3
[1ts-debian.git] / python-gss / gssmodule.h
1 #ifndef Py_GSS_H
2 #define Py_GSS_H
3 #ifdef __cplusplus
4 extern C {
5 #endif
6
7 #include <Python.h>
8
9 #define PyGSS_raiseGssError_NUM 0
10 #define PyGSS_raiseGssError_RETURN void *
11 #define PyGSS_raiseGssError_PROTO (OM_uint32, OM_uint32)
12
13 #define PyGSS_API_pointers 1
14
15 #ifdef PY_GSS_MODULE
16
17 static PyGSS_raiseGssError_RETURN raiseGssError PyGSS_raiseGssError_PROTO;
18
19 #else
20
21 static void **PyGSS_API;
22
23 #define raiseGssError \
24  (*(PyGSS_raiseGssError_RETURN (*)PyGSS_raiseGssError_PROTO) PyGSS_API[PyGSS_raiseGssError_NUM])
25
26 /* Return -1 and set exception on error, 0 on success. */
27 static int
28 import_gss(void)
29 {
30     PyObject *module = PyImport_ImportModule("gss");
31
32     if (module != NULL) {
33         PyObject *c_api_object = PyObject_GetAttrString(module, "_C_API");
34         if (c_api_object == NULL)
35             return -1;
36         if (PyCObject_Check(c_api_object))
37             PyGSS_API = (void **)PyCObject_AsVoidPtr(c_api_object);
38         Py_DECREF(c_api_object);
39     }
40     return 0;
41 }
42
43 #endif
44
45 #ifdef __cplusplus
46 }
47 #endif
48
49 #endif /* !defined(Py_GSSMODULE_H) */