[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnurl] 218/411: ldap: reduce the amount of #ifdefs needed
From: |
gnunet |
Subject: |
[gnurl] 218/411: ldap: reduce the amount of #ifdefs needed |
Date: |
Wed, 13 Jan 2021 01:20:33 +0100 |
This is an automated email from the git hooks/post-receive script.
nikita pushed a commit to branch master
in repository gnurl.
commit 6497ed45bd7dc59a9da1d7e35db7456e8f1cf3bf
Author: Daniel Stenberg <daniel@haxx.se>
AuthorDate: Fri Oct 2 11:18:21 2020 +0200
ldap: reduce the amount of #ifdefs needed
Closes #6035
---
lib/ldap.c | 66 ++++++++++++++++++++------------------------------------------
1 file changed, 21 insertions(+), 45 deletions(-)
diff --git a/lib/ldap.c b/lib/ldap.c
index eca7fac30..8d1ee6445 100644
--- a/lib/ldap.c
+++ b/lib/ldap.c
@@ -259,6 +259,13 @@ static int ldap_win_bind(struct connectdata *conn, LDAP
*server,
}
#endif /* #if defined(USE_WIN32_LDAP) */
+#if defined(USE_WIN32_LDAP)
+#define FREE_ON_WINLDAP(x) curlx_unicodefree(x)
+#else
+#define FREE_ON_WINLDAP(x)
+#endif
+
+
static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
{
CURLcode result = CURLE_OK;
@@ -465,9 +472,6 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool
*done)
}
#ifdef USE_WIN32_LDAP
ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
-#endif
-
-#ifdef USE_WIN32_LDAP
rc = ldap_win_bind(conn, server, user, passwd);
#else
rc = ldap_simple_bind_s(server, user, passwd);
@@ -509,7 +513,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool
*done)
#if defined(USE_WIN32_LDAP)
TCHAR *attribute;
#else
- char *attribute; /*! suspicious that this isn't 'const' */
+ char *attribute;
#endif
int i;
@@ -534,30 +538,22 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool
*done)
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"DN: ", 4);
if(result) {
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(name);
-#endif
+ FREE_ON_WINLDAP(name);
ldap_memfree(dn);
-
goto quit;
}
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *) name,
name_len);
if(result) {
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(name);
-#endif
+ FREE_ON_WINLDAP(name);
ldap_memfree(dn);
-
goto quit;
}
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
if(result) {
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(name);
-#endif
+ FREE_ON_WINLDAP(name);
ldap_memfree(dn);
goto quit;
@@ -565,9 +561,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool
*done)
dlsize += name_len + 5;
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(name);
-#endif
+ FREE_ON_WINLDAP(name);
ldap_memfree(dn);
}
@@ -598,9 +592,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool
*done)
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1);
if(result) {
ldap_value_free_len(vals);
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(attr);
-#endif
+ FREE_ON_WINLDAP(attr);
ldap_memfree(attribute);
if(ber)
ber_free(ber, 0);
@@ -612,9 +604,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool
*done)
(char *) attr, attr_len);
if(result) {
ldap_value_free_len(vals);
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(attr);
-#endif
+ FREE_ON_WINLDAP(attr);
ldap_memfree(attribute);
if(ber)
ber_free(ber, 0);
@@ -625,9 +615,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool
*done)
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2);
if(result) {
ldap_value_free_len(vals);
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(attr);
-#endif
+ FREE_ON_WINLDAP(attr);
ldap_memfree(attribute);
if(ber)
ber_free(ber, 0);
@@ -647,9 +635,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool
*done)
&val_b64_sz);
if(result) {
ldap_value_free_len(vals);
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(attr);
-#endif
+ FREE_ON_WINLDAP(attr);
ldap_memfree(attribute);
if(ber)
ber_free(ber, 0);
@@ -663,9 +649,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool
*done)
free(val_b64);
if(result) {
ldap_value_free_len(vals);
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(attr);
-#endif
+ FREE_ON_WINLDAP(attr);
ldap_memfree(attribute);
if(ber)
ber_free(ber, 0);
@@ -681,9 +665,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool
*done)
vals[i]->bv_len);
if(result) {
ldap_value_free_len(vals);
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(attr);
-#endif
+ FREE_ON_WINLDAP(attr);
ldap_memfree(attribute);
if(ber)
ber_free(ber, 0);
@@ -697,9 +679,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool
*done)
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
if(result) {
ldap_value_free_len(vals);
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(attr);
-#endif
+ FREE_ON_WINLDAP(attr);
ldap_memfree(attribute);
if(ber)
ber_free(ber, 0);
@@ -715,9 +695,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool
*done)
}
/* Free the attribute as we are done with it */
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(attr);
-#endif
+ FREE_ON_WINLDAP(attr);
ldap_memfree(attribute);
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
@@ -747,9 +725,7 @@ quit:
ldapssl_client_deinit();
#endif /* HAVE_LDAP_SSL && CURL_HAS_NOVELL_LDAPSDK */
-#if defined(USE_WIN32_LDAP)
- curlx_unicodefree(host);
-#endif
+ FREE_ON_WINLDAP(host);
/* no data to transfer */
Curl_setup_transfer(data, -1, -1, FALSE, -1);
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnurl] 179/411: dynbuf: add Curl_dyn_vaddf, (continued)
- [gnurl] 179/411: dynbuf: add Curl_dyn_vaddf, gnunet, 2021/01/12
- [gnurl] 137/411: vtls: deduplicate client certificates in ssl_config_data, gnunet, 2021/01/12
- [gnurl] 196/411: TODO: SSH over HTTPS proxy with more backends, gnunet, 2021/01/12
- [gnurl] 138/411: tool_urlglob: fix compiler warning "unreachable code", gnunet, 2021/01/12
- [gnurl] 189/411: ftp: make a 552 response return CURLE_REMOTE_DISK_FULL, gnunet, 2021/01/12
- [gnurl] 236/411: projects/build-wolfssl.bat: fix the copyright year range, gnunet, 2021/01/12
- [gnurl] 212/411: curl: make --libcurl show binary posts correctly, gnunet, 2021/01/12
- [gnurl] 190/411: RELEASE-NOTES: synced, gnunet, 2021/01/12
- [gnurl] 240/411: test122[12]: remove these two tests, gnunet, 2021/01/12
- [gnurl] 250/411: tool_operate: fix compiler warning when --libcurl is disabled, gnunet, 2021/01/12
- [gnurl] 218/411: ldap: reduce the amount of #ifdefs needed,
gnunet <=
- [gnurl] 194/411: memdebug: remove 9 year old unused debug function, gnunet, 2021/01/12
- [gnurl] 187/411: test163[12]: require http to be built-in to run, gnunet, 2021/01/12
- [gnurl] 217/411: runtests: provide curl's version string as %VERSION for tests, gnunet, 2021/01/12
- [gnurl] 220/411: --help: move two options from the misc category, gnunet, 2021/01/12
- [gnurl] 243/411: connect: repair build without ipv6 availability, gnunet, 2021/01/12
- [gnurl] 206/411: tests/README: convert to markdown, gnunet, 2021/01/12
- [gnurl] 249/411: checksrc: warn on empty line before open brace, gnunet, 2021/01/12
- [gnurl] 208/411: TODO: Add OpenBSD libtool notice, gnunet, 2021/01/12
- [gnurl] 209/411: RELEASE-NOTES: synced, gnunet, 2021/01/12
- [gnurl] 213/411: tool_setopt: escape binary data to hex, not octal, gnunet, 2021/01/12