File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /* See http://www.python-ldap.org/ for details.
2+ * $Id: LDAPObject.h,v 1.10 2009/04/17 12:19:09 stroeder Exp $ */
3+
4+ #ifndef __h_LDAPObject
5+ #define __h_LDAPObject
6+
7+ #include "common.h"
8+
9+ #include "lber.h"
10+ #include "ldap.h"
11+ #if LDAP_API_VERSION < 2000
12+ #error Current python-ldap requires OpenLDAP 2.x
13+ #endif
14+
15+ #if PYTHON_API_VERSION < 1007
16+ typedef PyObject * _threadstate ;
17+ #else
18+ typedef PyThreadState * _threadstate ;
19+ #endif
20+
21+ typedef struct {
22+ PyObject_HEAD
23+ LDAP * ldap ;
24+ _threadstate _save ; /* for thread saving on referrals */
25+ int valid ;
26+ } LDAPObject ;
27+
28+ extern PyTypeObject LDAP_Type ;
29+ #define LDAPObject_Check (v ) ((v)->ob_type == &LDAP_Type)
30+
31+ extern LDAPObject * newLDAPObject ( LDAP * );
32+
33+ /* macros to allow thread saving in the context of an LDAP connection */
34+
35+ #define LDAP_BEGIN_ALLOW_THREADS ( l ) \
36+ { \
37+ LDAPObject *lo = (l); \
38+ if (lo->_save != NULL) \
39+ Py_FatalError( "saving thread twice?" ); \
40+ lo->_save = PyEval_SaveThread(); \
41+ }
42+
43+ #define LDAP_END_ALLOW_THREADS ( l ) \
44+ { \
45+ LDAPObject *lo = (l); \
46+ _threadstate _save = lo->_save; \
47+ lo->_save = NULL; \
48+ PyEval_RestoreThread( _save ); \
49+ }
50+
51+ #endif /* __h_LDAPObject */
52+
Original file line number Diff line number Diff line change 1+ /* Miscellaneous common routines
2+ * See http://www.python-ldap.org/ for details.
3+ * $Id: common.c,v 1.3 2009/04/17 12:19:09 stroeder Exp $ */
4+
5+ #include "common.h"
6+
7+ /* dynamically add the methods into the module dictionary d */
8+
9+ void
10+ LDAPadd_methods ( PyObject * d , PyMethodDef * methods )
11+ {
12+ PyMethodDef * meth ;
13+
14+ for ( meth = methods ; meth -> ml_meth ; meth ++ ) {
15+ PyObject * f = PyCFunction_New ( meth , NULL );
16+ PyDict_SetItemString ( d , meth -> ml_name , f );
17+ Py_DECREF (f );
18+ }
19+ }
Original file line number Diff line number Diff line change 1+ /* common utility macros
2+ * See http://www.python-ldap.org/ for details.
3+ * $Id: common.h,v 1.8 2009/04/17 12:19:09 stroeder Exp $ */
4+
5+ #ifndef __h_common
6+ #define __h_common
7+
8+ #define PY_SSIZE_T_CLEAN
9+
10+ #include "Python.h"
11+
12+ #if defined(HAVE_CONFIG_H )
13+ #include "config.h"
14+ #endif
15+
16+ #if defined(MS_WINDOWS )
17+ #include <winsock.h>
18+ #else /* unix */
19+ #include <netdb.h>
20+ #include <sys/time.h>
21+ #include <sys/types.h>
22+ #endif
23+
24+ /* Backwards compability with Python prior 2.5 */
25+ #if PY_VERSION_HEX < 0x02050000
26+ typedef int Py_ssize_t ;
27+ #define PY_SSIZE_T_MAX INT_MAX
28+ #define PY_SSIZE_T_MIN INT_MIN
29+ #endif
30+
31+ #include <string.h>
32+ #define streq ( a , b ) \
33+ ( (*(a)==*(b)) && 0==strcmp(a,b) )
34+
35+ void LDAPadd_methods ( PyObject * d , PyMethodDef * methods );
36+ #define PyNone_Check (o ) ((o) == Py_None)
37+
38+ #endif /* __h_common_ */
39+
Original file line number Diff line number Diff line change 1+ /* See http://www.python-ldap.org/ for details.
2+ * $Id: constants.h,v 1.6 2009/04/17 12:19:09 stroeder Exp $ */
3+
4+ #ifndef __h_constants_
5+ #define __h_constants_
6+
7+ #include "common.h"
8+ extern void LDAPinit_constants ( PyObject * d );
9+ extern PyObject * LDAPconstant ( int );
10+
11+ #ifndef LDAP_CONTROL_PAGE_OID
12+ #define LDAP_CONTROL_PAGE_OID "1.2.840.113556.1.4.319"
13+ #endif /* !LDAP_CONTROL_PAGE_OID */
14+
15+ #ifndef LDAP_CONTROL_VALUESRETURNFILTER
16+ #define LDAP_CONTROL_VALUESRETURNFILTER "1.2.826.0.1.3344810.2.3" /* RFC 3876 */
17+ #endif /* !LDAP_CONTROL_VALUESRETURNFILTER */
18+
19+ #endif /* __h_constants_ */
Original file line number Diff line number Diff line change 1+ /* See http://www.python-ldap.org/ for details.
2+ * $Id: errors.h,v 1.6 2009/04/17 12:19:09 stroeder Exp $ */
3+
4+ #ifndef __h_errors_
5+ #define __h_errors_
6+
7+ #include "common.h"
8+ #include "lber.h"
9+ #include "ldap.h"
10+
11+ extern PyObject * LDAPexception_class ;
12+ extern PyObject * LDAPerror ( LDAP * , char * msg );
13+ extern void LDAPinit_errors ( PyObject * );
14+ PyObject * LDAPerr (int errnum );
15+
16+ #endif /* __h_errors */
Original file line number Diff line number Diff line change 1+ /* See http://www.python-ldap.org/ for details.
2+ * $Id: functions.h,v 1.4 2009/04/17 12:19:09 stroeder Exp $ */
3+
4+ #ifndef __h_functions_
5+ #define __h_functions_
6+
7+ /* $Id: functions.h,v 1.4 2009/04/17 12:19:09 stroeder Exp $ */
8+
9+ #include "common.h"
10+ extern void LDAPinit_functions ( PyObject * );
11+
12+ #endif /* __h_functions_ */
Original file line number Diff line number Diff line change 1+ /* See http://www.python-ldap.org/ for details.
2+ * $Id: ldapmodule.c,v 1.9 2009/04/17 12:19:09 stroeder Exp $ */
3+
4+ #include "common.h"
5+ #include "version.h"
6+ #include "constants.h"
7+ #include "errors.h"
8+ #include "functions.h"
9+ #include "schema.h"
10+ #include "ldapcontrol.h"
11+
12+ #include "LDAPObject.h"
13+
14+ DL_EXPORT (void ) init_ldap (void );
15+
16+ /* dummy module methods */
17+
18+ static PyMethodDef methods [] = {
19+ { NULL , NULL }
20+ };
21+
22+ /* module initialisation */
23+
24+ DL_EXPORT (void )
25+ init_ldap ()
26+ {
27+ PyObject * m , * d ;
28+
29+ #if defined(MS_WINDOWS ) || defined(__CYGWIN__ )
30+ LDAP_Type .ob_type = & PyType_Type ;
31+ #endif
32+
33+ /* Create the module and add the functions */
34+ m = Py_InitModule ("_ldap" , methods );
35+
36+ /* Add some symbolic constants to the module */
37+ d = PyModule_GetDict (m );
38+
39+ LDAPinit_version (d );
40+ LDAPinit_constants (d );
41+ LDAPinit_errors (d );
42+ LDAPinit_functions (d );
43+ LDAPinit_schema (d );
44+ LDAPinit_control (d );
45+
46+ /* Check for errors */
47+ if (PyErr_Occurred ())
48+ Py_FatalError ("can't initialize module _ldap" );
49+ }
Original file line number Diff line number Diff line change 1+ /* See http://www.python-ldap.org/ for details.
2+ * $Id: options.h,v 1.4 2009/04/17 12:19:09 stroeder Exp $ */
3+
4+ int LDAP_optionval_by_name (const char * name );
5+ int LDAP_set_option (LDAPObject * self , int option , PyObject * value );
6+ PyObject * LDAP_get_option (LDAPObject * self , int option );
7+
8+ void set_timeval_from_double ( struct timeval * tv , double d );
You can’t perform that action at this time.
0 commit comments