File: LDAPObject.h

package info (click to toggle)
python-ldap 3.4.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,368 kB
  • sloc: python: 9,558; ansic: 3,052; makefile: 139; sh: 79
file content (38 lines) | stat: -rw-r--r-- 1,329 bytes parent folder | download | duplicates (3)
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
/* See https://www.python-ldap.org/ for details. */

#ifndef __h_LDAPObject
#define __h_LDAPObject

#include "common.h"

typedef struct {
    PyObject_HEAD LDAP *ldap;
    PyThreadState *_save;         /* for thread saving on referrals */
    int valid;
} LDAPObject;

extern PyTypeObject LDAP_Type;

#define LDAPObject_Check(v)     (Py_TYPE(v) == &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);                                         \
	  PyThreadState *_save = lo->_save;                               \
	  lo->_save = NULL;                                             \
	  PyEval_RestoreThread( _save );                                \
	}

#endif /* __h_LDAPObject */