forked from python-ldap/python-ldap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathldapmodule.c
More file actions
66 lines (50 loc) · 1.42 KB
/
ldapmodule.c
File metadata and controls
66 lines (50 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* See https://www.python-ldap.org/ for details. */
#include "pythonldap.h"
#define _STR(x) #x
#define STR(x) _STR(x)
static char version_str[] = STR(LDAPMODULE_VERSION);
static char author_str[] = STR(LDAPMODULE_AUTHOR);
static char license_str[] = STR(LDAPMODULE_LICENSE);
static void
init_pkginfo(PyObject *m)
{
PyModule_AddStringConstant(m, "__version__", version_str);
PyModule_AddStringConstant(m, "__author__", author_str);
PyModule_AddStringConstant(m, "__license__", license_str);
}
/* dummy module methods */
static PyMethodDef methods[] = {
{NULL, NULL}
};
static struct PyModuleDef ldap_moduledef = {
PyModuleDef_HEAD_INIT,
"_ldap", /* m_name */
"", /* m_doc */
-1, /* m_size */
methods, /* m_methods */
};
/* module initialisation */
PyMODINIT_FUNC
PyInit__ldap()
{
PyObject *m, *d;
/* Create the module and add the functions */
m = PyModule_Create(&ldap_moduledef);
/* Initialize LDAP class */
if (PyType_Ready(&LDAP_Type) < 0) {
Py_DECREF(m);
return NULL;
}
/* Add some symbolic constants to the module */
d = PyModule_GetDict(m);
init_pkginfo(m);
if (LDAPinit_constants(m) == -1) {
return NULL;
}
LDAPinit_functions(d);
LDAPinit_control(d);
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module _ldap");
return m;
}