Skip to content

Commit

Permalink
Refer to new project home-page
Browse files Browse the repository at this point in the history
  • Loading branch information
stroeder committed Apr 17, 2009
1 parent ee42183 commit f0b197b
Show file tree
Hide file tree
Showing 12 changed files with 543 additions and 0 deletions.
52 changes: 52 additions & 0 deletions Modules/LDAPObject.h
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 */

19 changes: 19 additions & 0 deletions Modules/common.c
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);
}
}
39 changes: 39 additions & 0 deletions Modules/common.h
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_ */

19 changes: 19 additions & 0 deletions Modules/constants.h
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_ */
16 changes: 16 additions & 0 deletions Modules/errors.h
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 */
12 changes: 12 additions & 0 deletions Modules/functions.h
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_ */
49 changes: 49 additions & 0 deletions Modules/ldapmodule.c
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");
}
8 changes: 8 additions & 0 deletions Modules/options.h
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 );
Loading

0 comments on commit f0b197b

Please sign in to comment.