Skip to content

Commit 9a74c29

Browse files
automaticencukou
authored andcommitted
Reformat and indent all C files
Generated with: make indent make indent
1 parent 613b074 commit 9a74c29

17 files changed

+1320
-1209
lines changed

Modules/LDAPObject.c

Lines changed: 586 additions & 490 deletions
Large diffs are not rendered by default.

Modules/LDAPObject.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* See https://www.python-ldap.org/ for details. */
22

3-
#ifndef __h_LDAPObject
4-
#define __h_LDAPObject
3+
#ifndef __h_LDAPObject
4+
#define __h_LDAPObject
55

66
#include "common.h"
77

@@ -12,22 +12,22 @@
1212
#endif
1313

1414
#if PYTHON_API_VERSION < 1007
15-
typedef PyObject* _threadstate;
15+
typedef PyObject *_threadstate;
1616
#else
17-
typedef PyThreadState* _threadstate;
17+
typedef PyThreadState *_threadstate;
1818
#endif
1919

2020
typedef struct {
21-
PyObject_HEAD
22-
LDAP* ldap;
23-
_threadstate _save; /* for thread saving on referrals */
24-
int valid;
21+
PyObject_HEAD LDAP *ldap;
22+
_threadstate _save; /* for thread saving on referrals */
23+
int valid;
2524
} LDAPObject;
2625

2726
extern PyTypeObject LDAP_Type;
27+
2828
#define LDAPObject_Check(v) (Py_TYPE(v) == &LDAP_Type)
2929

30-
extern LDAPObject *newLDAPObject( LDAP* );
30+
extern LDAPObject *newLDAPObject(LDAP *);
3131

3232
/* macros to allow thread saving in the context of an LDAP connection */
3333

@@ -48,4 +48,3 @@ extern LDAPObject *newLDAPObject( LDAP* );
4848
}
4949

5050
#endif /* __h_LDAPObject */
51-

Modules/berval.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* See https://www.python-ldap.org/ for details. */
22

3-
#ifndef __h_berval
4-
#define __h_berval
3+
#ifndef __h_berval
4+
#define __h_berval
55

66
#include "common.h"
77
#include "lber.h"

Modules/common.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,24 @@
66
/* dynamically add the methods into the module dictionary d */
77

88
void
9-
LDAPadd_methods( PyObject* d, PyMethodDef* methods )
9+
LDAPadd_methods(PyObject *d, PyMethodDef *methods)
1010
{
1111
PyMethodDef *meth;
1212

13-
for( meth = methods; meth->ml_meth; meth++ ) {
14-
PyObject *f = PyCFunction_New( meth, NULL );
15-
PyDict_SetItemString( d, meth->ml_name, f );
13+
for (meth = methods; meth->ml_meth; meth++) {
14+
PyObject *f = PyCFunction_New(meth, NULL);
15+
16+
PyDict_SetItemString(d, meth->ml_name, f);
1617
Py_DECREF(f);
1718
}
1819
}
1920

2021
/* Raise TypeError with custom message and object */
21-
PyObject*
22-
LDAPerror_TypeError(const char *msg, PyObject *obj) {
22+
PyObject *
23+
LDAPerror_TypeError(const char *msg, PyObject *obj)
24+
{
2325
PyObject *args = Py_BuildValue("sO", msg, obj);
26+
2427
if (args == NULL) {
2528
return NULL;
2629
}

Modules/common.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* common utility macros
22
* See https://www.python-ldap.org/ for details. */
33

4-
#ifndef __h_common
5-
#define __h_common
4+
#ifndef __h_common
5+
#define __h_common
66

77
#define PY_SSIZE_T_CLEAN
88

@@ -24,9 +24,10 @@
2424
#define streq( a, b ) \
2525
( (*(a)==*(b)) && 0==strcmp(a,b) )
2626

27-
extern PyObject* LDAPerror_TypeError(const char *, PyObject *);
27+
extern PyObject *LDAPerror_TypeError(const char *, PyObject *);
28+
29+
void LDAPadd_methods(PyObject *d, PyMethodDef *methods);
2830

29-
void LDAPadd_methods( PyObject*d, PyMethodDef*methods );
3031
#define PyNone_Check(o) ((o) == Py_None)
3132

3233
/* Py2/3 compatibility */
@@ -36,4 +37,3 @@ void LDAPadd_methods( PyObject*d, PyMethodDef*methods );
3637
#endif
3738

3839
#endif /* __h_common_ */
39-

Modules/constants.c

Lines changed: 97 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -8,133 +8,136 @@
88

99
/* the base exception class */
1010

11-
PyObject*
12-
LDAPexception_class;
11+
PyObject *LDAPexception_class;
1312

1413
/* list of exception classes */
1514

1615
#define LDAP_ERROR_MIN LDAP_REFERRAL_LIMIT_EXCEEDED
1716

1817
#ifdef LDAP_PROXIED_AUTHORIZATION_DENIED
19-
#define LDAP_ERROR_MAX LDAP_PROXIED_AUTHORIZATION_DENIED
18+
#define LDAP_ERROR_MAX LDAP_PROXIED_AUTHORIZATION_DENIED
2019
#else
21-
#ifdef LDAP_ASSERTION_FAILED
22-
#define LDAP_ERROR_MAX LDAP_ASSERTION_FAILED
23-
#else
24-
#define LDAP_ERROR_MAX LDAP_OTHER
25-
#endif
20+
#ifdef LDAP_ASSERTION_FAILED
21+
#define LDAP_ERROR_MAX LDAP_ASSERTION_FAILED
22+
#else
23+
#define LDAP_ERROR_MAX LDAP_OTHER
24+
#endif
2625
#endif
2726

2827
#define LDAP_ERROR_OFFSET -LDAP_ERROR_MIN
2928

30-
static PyObject* errobjects[ LDAP_ERROR_MAX-LDAP_ERROR_MIN+1 ];
31-
29+
static PyObject *errobjects[LDAP_ERROR_MAX - LDAP_ERROR_MIN + 1];
3230

3331
/* Convert a bare LDAP error number into an exception */
34-
PyObject*
32+
PyObject *
3533
LDAPerr(int errnum)
3634
{
37-
if (errnum >= LDAP_ERROR_MIN && errnum <= LDAP_ERROR_MAX) {
38-
PyErr_SetNone(errobjects[errnum+LDAP_ERROR_OFFSET]);
39-
} else {
40-
PyObject *args = Py_BuildValue("{s:i}", "errnum", errnum);
41-
if (args == NULL)
42-
return NULL;
43-
PyErr_SetObject(LDAPexception_class, args);
44-
Py_DECREF(args);
45-
}
46-
return NULL;
35+
if (errnum >= LDAP_ERROR_MIN && errnum <= LDAP_ERROR_MAX) {
36+
PyErr_SetNone(errobjects[errnum + LDAP_ERROR_OFFSET]);
37+
}
38+
else {
39+
PyObject *args = Py_BuildValue("{s:i}", "errnum", errnum);
40+
41+
if (args == NULL)
42+
return NULL;
43+
PyErr_SetObject(LDAPexception_class, args);
44+
Py_DECREF(args);
45+
}
46+
return NULL;
4747
}
4848

4949
/* Convert an LDAP error into an informative python exception */
50-
PyObject*
51-
LDAPerror( LDAP *l, char *msg )
50+
PyObject *
51+
LDAPerror(LDAP *l, char *msg)
5252
{
53-
if (l == NULL) {
54-
PyErr_SetFromErrno( LDAPexception_class );
55-
return NULL;
56-
}
57-
else {
58-
int myerrno, errnum, opt_errnum;
59-
PyObject *errobj;
60-
PyObject *info;
61-
PyObject *str;
62-
PyObject *pyerrno;
63-
char *matched, *error;
64-
65-
/* at first save errno for later use before it gets overwritten by another call */
66-
myerrno = errno;
67-
68-
opt_errnum = ldap_get_option(l, LDAP_OPT_ERROR_NUMBER, &errnum);
69-
if (opt_errnum != LDAP_OPT_SUCCESS)
70-
errnum = opt_errnum;
71-
72-
if (errnum == LDAP_NO_MEMORY)
73-
return PyErr_NoMemory();
74-
75-
if (errnum >= LDAP_ERROR_MIN && errnum <= LDAP_ERROR_MAX)
76-
errobj = errobjects[errnum+LDAP_ERROR_OFFSET];
77-
else
78-
errobj = LDAPexception_class;
79-
80-
info = PyDict_New();
81-
if (info == NULL)
82-
return NULL;
83-
84-
str = PyUnicode_FromString(ldap_err2string(errnum));
85-
if (str)
86-
PyDict_SetItemString( info, "desc", str );
87-
Py_XDECREF(str);
88-
89-
if (myerrno != 0) {
90-
pyerrno = PyInt_FromLong(myerrno);
91-
if (pyerrno)
92-
PyDict_SetItemString( info, "errno", pyerrno );
93-
Py_XDECREF(pyerrno);
53+
if (l == NULL) {
54+
PyErr_SetFromErrno(LDAPexception_class);
55+
return NULL;
9456
}
57+
else {
58+
int myerrno, errnum, opt_errnum;
59+
PyObject *errobj;
60+
PyObject *info;
61+
PyObject *str;
62+
PyObject *pyerrno;
63+
char *matched, *error;
64+
65+
/* at first save errno for later use before it gets overwritten by another call */
66+
myerrno = errno;
67+
68+
opt_errnum = ldap_get_option(l, LDAP_OPT_ERROR_NUMBER, &errnum);
69+
if (opt_errnum != LDAP_OPT_SUCCESS)
70+
errnum = opt_errnum;
71+
72+
if (errnum == LDAP_NO_MEMORY)
73+
return PyErr_NoMemory();
74+
75+
if (errnum >= LDAP_ERROR_MIN && errnum <= LDAP_ERROR_MAX)
76+
errobj = errobjects[errnum + LDAP_ERROR_OFFSET];
77+
else
78+
errobj = LDAPexception_class;
79+
80+
info = PyDict_New();
81+
if (info == NULL)
82+
return NULL;
83+
84+
str = PyUnicode_FromString(ldap_err2string(errnum));
85+
if (str)
86+
PyDict_SetItemString(info, "desc", str);
87+
Py_XDECREF(str);
9588

96-
if (ldap_get_option(l, LDAP_OPT_MATCHED_DN, &matched) >= 0
97-
&& matched != NULL) {
98-
if (*matched != '\0') {
99-
str = PyUnicode_FromString(matched);
100-
if (str)
101-
PyDict_SetItemString( info, "matched", str );
102-
Py_XDECREF(str);
89+
if (myerrno != 0) {
90+
pyerrno = PyInt_FromLong(myerrno);
91+
if (pyerrno)
92+
PyDict_SetItemString(info, "errno", pyerrno);
93+
Py_XDECREF(pyerrno);
10394
}
104-
ldap_memfree(matched);
105-
}
10695

107-
if (errnum == LDAP_REFERRAL) {
108-
str = PyUnicode_FromString(msg);
109-
if (str)
110-
PyDict_SetItemString( info, "info", str );
111-
Py_XDECREF(str);
112-
} else if (ldap_get_option(l, LDAP_OPT_ERROR_STRING, &error) >= 0) {
113-
if (error != NULL && *error != '\0') {
114-
str = PyUnicode_FromString(error);
96+
if (ldap_get_option(l, LDAP_OPT_MATCHED_DN, &matched) >= 0
97+
&& matched != NULL) {
98+
if (*matched != '\0') {
99+
str = PyUnicode_FromString(matched);
100+
if (str)
101+
PyDict_SetItemString(info, "matched", str);
102+
Py_XDECREF(str);
103+
}
104+
ldap_memfree(matched);
105+
}
106+
107+
if (errnum == LDAP_REFERRAL) {
108+
str = PyUnicode_FromString(msg);
115109
if (str)
116-
PyDict_SetItemString( info, "info", str );
110+
PyDict_SetItemString(info, "info", str);
117111
Py_XDECREF(str);
118112
}
119-
ldap_memfree(error);
113+
else if (ldap_get_option(l, LDAP_OPT_ERROR_STRING, &error) >= 0) {
114+
if (error != NULL && *error != '\0') {
115+
str = PyUnicode_FromString(error);
116+
if (str)
117+
PyDict_SetItemString(info, "info", str);
118+
Py_XDECREF(str);
119+
}
120+
ldap_memfree(error);
121+
}
122+
PyErr_SetObject(errobj, info);
123+
Py_DECREF(info);
124+
return NULL;
120125
}
121-
PyErr_SetObject( errobj, info );
122-
Py_DECREF(info);
123-
return NULL;
124-
}
125126
}
126127

127128
/* initialise the module constants */
128129

129130
int
130-
LDAPinit_constants( PyObject* m )
131+
LDAPinit_constants(PyObject *m)
131132
{
132133
PyObject *exc;
133134

134135
/* simple constants */
135136

136-
if (PyModule_AddIntConstant(m, "OPT_ON", 1) != 0) return -1;
137-
if (PyModule_AddIntConstant(m, "OPT_OFF", 0) != 0) return -1;
137+
if (PyModule_AddIntConstant(m, "OPT_ON", 1) != 0)
138+
return -1;
139+
if (PyModule_AddIntConstant(m, "OPT_OFF", 0) != 0)
140+
return -1;
138141

139142
/* exceptions */
140143

@@ -143,11 +146,13 @@ LDAPinit_constants( PyObject* m )
143146
return -1;
144147
}
145148

146-
if (PyModule_AddObject(m, "LDAPError", LDAPexception_class) != 0) return -1;
149+
if (PyModule_AddObject(m, "LDAPError", LDAPexception_class) != 0)
150+
return -1;
147151
Py_INCREF(LDAPexception_class);
148152

149153
/* XXX - backward compatibility with pre-1.8 */
150-
if (PyModule_AddObject(m, "error", LDAPexception_class) != 0) return -1;
154+
if (PyModule_AddObject(m, "error", LDAPexception_class) != 0)
155+
return -1;
151156
Py_INCREF(LDAPexception_class);
152157

153158
/* Generated constants -- see Lib/ldap/constants.py */

Modules/constants.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77
#include "lber.h"
88
#include "ldap.h"
99

10-
extern int LDAPinit_constants( PyObject* m );
11-
extern PyObject* LDAPconstant( int );
10+
extern int LDAPinit_constants(PyObject *m);
11+
extern PyObject *LDAPconstant(int);
1212

13-
extern PyObject* LDAPexception_class;
14-
extern PyObject* LDAPerror( LDAP*, char*msg );
15-
PyObject* LDAPerr(int errnum);
13+
extern PyObject *LDAPexception_class;
14+
extern PyObject *LDAPerror(LDAP *, char *msg);
15+
PyObject *LDAPerr(int errnum);
1616

1717
#ifndef LDAP_CONTROL_PAGE_OID
1818
#define LDAP_CONTROL_PAGE_OID "1.2.840.113556.1.4.319"
1919
#endif /* !LDAP_CONTROL_PAGE_OID */
2020

2121
#ifndef LDAP_CONTROL_VALUESRETURNFILTER
22-
#define LDAP_CONTROL_VALUESRETURNFILTER "1.2.826.0.1.3344810.2.3" /* RFC 3876 */
22+
#define LDAP_CONTROL_VALUESRETURNFILTER "1.2.826.0.1.3344810.2.3" /* RFC 3876 */
2323
#endif /* !LDAP_CONTROL_VALUESRETURNFILTER */
2424

2525
#endif /* __h_constants_ */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy