-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
stroeder
committed
Apr 17, 2009
1 parent
ee42183
commit f0b197b
Showing
12 changed files
with
543 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* See http://www.python-ldap.org/ for details. | ||
* $Id: LDAPObject.h,v 1.10 2009/04/17 12:19:09 stroeder Exp $ */ | ||
|
||
#ifndef __h_LDAPObject | ||
#define __h_LDAPObject | ||
|
||
#include "common.h" | ||
|
||
#include "lber.h" | ||
#include "ldap.h" | ||
#if LDAP_API_VERSION < 2000 | ||
#error Current python-ldap requires OpenLDAP 2.x | ||
#endif | ||
|
||
#if PYTHON_API_VERSION < 1007 | ||
typedef PyObject* _threadstate; | ||
#else | ||
typedef PyThreadState* _threadstate; | ||
#endif | ||
|
||
typedef struct { | ||
PyObject_HEAD | ||
LDAP* ldap; | ||
_threadstate _save; /* for thread saving on referrals */ | ||
int valid; | ||
} LDAPObject; | ||
|
||
extern PyTypeObject LDAP_Type; | ||
#define LDAPObject_Check(v) ((v)->ob_type == &LDAP_Type) | ||
|
||
extern LDAPObject *newLDAPObject( LDAP* ); | ||
|
||
/* macros to allow thread saving in the context of an LDAP connection */ | ||
|
||
#define LDAP_BEGIN_ALLOW_THREADS( l ) \ | ||
{ \ | ||
LDAPObject *lo = (l); \ | ||
if (lo->_save != NULL) \ | ||
Py_FatalError( "saving thread twice?" ); \ | ||
lo->_save = PyEval_SaveThread(); \ | ||
} | ||
|
||
#define LDAP_END_ALLOW_THREADS( l ) \ | ||
{ \ | ||
LDAPObject *lo = (l); \ | ||
_threadstate _save = lo->_save; \ | ||
lo->_save = NULL; \ | ||
PyEval_RestoreThread( _save ); \ | ||
} | ||
|
||
#endif /* __h_LDAPObject */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* Miscellaneous common routines | ||
* See http://www.python-ldap.org/ for details. | ||
* $Id: common.c,v 1.3 2009/04/17 12:19:09 stroeder Exp $ */ | ||
|
||
#include "common.h" | ||
|
||
/* dynamically add the methods into the module dictionary d */ | ||
|
||
void | ||
LDAPadd_methods( PyObject* d, PyMethodDef* methods ) | ||
{ | ||
PyMethodDef *meth; | ||
|
||
for( meth = methods; meth->ml_meth; meth++ ) { | ||
PyObject *f = PyCFunction_New( meth, NULL ); | ||
PyDict_SetItemString( d, meth->ml_name, f ); | ||
Py_DECREF(f); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* common utility macros | ||
* See http://www.python-ldap.org/ for details. | ||
* $Id: common.h,v 1.8 2009/04/17 12:19:09 stroeder Exp $ */ | ||
|
||
#ifndef __h_common | ||
#define __h_common | ||
|
||
#define PY_SSIZE_T_CLEAN | ||
|
||
#include "Python.h" | ||
|
||
#if defined(HAVE_CONFIG_H) | ||
#include "config.h" | ||
#endif | ||
|
||
#if defined(MS_WINDOWS) | ||
#include <winsock.h> | ||
#else /* unix */ | ||
#include <netdb.h> | ||
#include <sys/time.h> | ||
#include <sys/types.h> | ||
#endif | ||
|
||
/* Backwards compability with Python prior 2.5 */ | ||
#if PY_VERSION_HEX < 0x02050000 | ||
typedef int Py_ssize_t; | ||
#define PY_SSIZE_T_MAX INT_MAX | ||
#define PY_SSIZE_T_MIN INT_MIN | ||
#endif | ||
|
||
#include <string.h> | ||
#define streq( a, b ) \ | ||
( (*(a)==*(b)) && 0==strcmp(a,b) ) | ||
|
||
void LDAPadd_methods( PyObject*d, PyMethodDef*methods ); | ||
#define PyNone_Check(o) ((o) == Py_None) | ||
|
||
#endif /* __h_common_ */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* See http://www.python-ldap.org/ for details. | ||
* $Id: constants.h,v 1.6 2009/04/17 12:19:09 stroeder Exp $ */ | ||
|
||
#ifndef __h_constants_ | ||
#define __h_constants_ | ||
|
||
#include "common.h" | ||
extern void LDAPinit_constants( PyObject* d ); | ||
extern PyObject* LDAPconstant( int ); | ||
|
||
#ifndef LDAP_CONTROL_PAGE_OID | ||
#define LDAP_CONTROL_PAGE_OID "1.2.840.113556.1.4.319" | ||
#endif /* !LDAP_CONTROL_PAGE_OID */ | ||
|
||
#ifndef LDAP_CONTROL_VALUESRETURNFILTER | ||
#define LDAP_CONTROL_VALUESRETURNFILTER "1.2.826.0.1.3344810.2.3" /* RFC 3876 */ | ||
#endif /* !LDAP_CONTROL_VALUESRETURNFILTER */ | ||
|
||
#endif /* __h_constants_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* See http://www.python-ldap.org/ for details. | ||
* $Id: errors.h,v 1.6 2009/04/17 12:19:09 stroeder Exp $ */ | ||
|
||
#ifndef __h_errors_ | ||
#define __h_errors_ | ||
|
||
#include "common.h" | ||
#include "lber.h" | ||
#include "ldap.h" | ||
|
||
extern PyObject* LDAPexception_class; | ||
extern PyObject* LDAPerror( LDAP*, char*msg ); | ||
extern void LDAPinit_errors( PyObject* ); | ||
PyObject* LDAPerr(int errnum); | ||
|
||
#endif /* __h_errors */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* See http://www.python-ldap.org/ for details. | ||
* $Id: functions.h,v 1.4 2009/04/17 12:19:09 stroeder Exp $ */ | ||
|
||
#ifndef __h_functions_ | ||
#define __h_functions_ | ||
|
||
/* $Id: functions.h,v 1.4 2009/04/17 12:19:09 stroeder Exp $ */ | ||
|
||
#include "common.h" | ||
extern void LDAPinit_functions( PyObject* ); | ||
|
||
#endif /* __h_functions_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* See http://www.python-ldap.org/ for details. | ||
* $Id: ldapmodule.c,v 1.9 2009/04/17 12:19:09 stroeder Exp $ */ | ||
|
||
#include "common.h" | ||
#include "version.h" | ||
#include "constants.h" | ||
#include "errors.h" | ||
#include "functions.h" | ||
#include "schema.h" | ||
#include "ldapcontrol.h" | ||
|
||
#include "LDAPObject.h" | ||
|
||
DL_EXPORT(void) init_ldap(void); | ||
|
||
/* dummy module methods */ | ||
|
||
static PyMethodDef methods[] = { | ||
{ NULL, NULL } | ||
}; | ||
|
||
/* module initialisation */ | ||
|
||
DL_EXPORT(void) | ||
init_ldap() | ||
{ | ||
PyObject *m, *d; | ||
|
||
#if defined(MS_WINDOWS) || defined(__CYGWIN__) | ||
LDAP_Type.ob_type = &PyType_Type; | ||
#endif | ||
|
||
/* Create the module and add the functions */ | ||
m = Py_InitModule("_ldap", methods); | ||
|
||
/* Add some symbolic constants to the module */ | ||
d = PyModule_GetDict(m); | ||
|
||
LDAPinit_version(d); | ||
LDAPinit_constants(d); | ||
LDAPinit_errors(d); | ||
LDAPinit_functions(d); | ||
LDAPinit_schema(d); | ||
LDAPinit_control(d); | ||
|
||
/* Check for errors */ | ||
if (PyErr_Occurred()) | ||
Py_FatalError("can't initialize module _ldap"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* See http://www.python-ldap.org/ for details. | ||
* $Id: options.h,v 1.4 2009/04/17 12:19:09 stroeder Exp $ */ | ||
|
||
int LDAP_optionval_by_name(const char *name); | ||
int LDAP_set_option(LDAPObject *self, int option, PyObject *value); | ||
PyObject *LDAP_get_option(LDAPObject *self, int option); | ||
|
||
void set_timeval_from_double( struct timeval *tv, double d ); |
Oops, something went wrong.