summaryrefslogtreecommitdiff
path: root/lib/ldap.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2021-01-08 17:58:15 +0100
committerDaniel Stenberg <daniel@haxx.se>2021-01-17 23:56:09 +0100
commit215db086e09665ee7af9b646ad6c4d6e281001ac (patch)
tree50c74f8456df87e86de6d72e90190a3563083a1a /lib/ldap.c
parent0d26ab9ed3ac29da2a383d313e93df3e9f5295a2 (diff)
downloadcurl-215db086e09665ee7af9b646ad6c4d6e281001ac.tar.gz
lib: pass in 'struct Curl_easy *' to most functions
... in most cases instead of 'struct connectdata *' but in some cases in addition to. - We mostly operate on transfers and not connections. - We need the transfer handle to log, store data and more. Everything in libcurl is driven by a transfer (the CURL * in the public API). - This work clarifies and separates the transfers from the connections better. - We should avoid "conn->data". Since individual connections can be used by many transfers when multiplexing, making sure that conn->data points to the current and correct transfer at all times is difficult and has been notoriously error-prone over the years. The goal is to ultimately remove the conn->data pointer for this reason. Closes #6425
Diffstat (limited to 'lib/ldap.c')
-rw-r--r--lib/ldap.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/ldap.c b/lib/ldap.c
index 8e8aad1a7..9808ac132 100644
--- a/lib/ldap.c
+++ b/lib/ldap.c
@@ -126,7 +126,7 @@ static void _ldap_free_urldesc(LDAPURLDesc *ludp);
#endif
-static CURLcode ldap_do(struct connectdata *conn, bool *done);
+static CURLcode ldap_do(struct Curl_easy *data, bool *done);
/*
* LDAP protocol handler.
@@ -266,7 +266,7 @@ static int ldap_win_bind(struct connectdata *conn, LDAP *server,
#endif
-static CURLcode ldap_do(struct connectdata *conn, bool *done)
+static CURLcode ldap_do(struct Curl_easy *data, bool *done)
{
CURLcode result = CURLE_OK;
int rc = 0;
@@ -275,7 +275,7 @@ static CURLcode ldap_do(struct connectdata *conn, bool *done)
LDAPMessage *ldapmsg = NULL;
LDAPMessage *entryIterator;
int num = 0;
- struct Curl_easy *data = conn->data;
+ struct connectdata *conn = data->conn;
int ldap_proto = LDAP_VERSION3;
int ldap_ssl = 0;
char *val_b64 = NULL;
@@ -536,14 +536,14 @@ static CURLcode ldap_do(struct connectdata *conn, bool *done)
#endif
name_len = strlen(name);
- result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"DN: ", 4);
+ result = Curl_client_write(data, CLIENTWRITE_BODY, (char *)"DN: ", 4);
if(result) {
FREE_ON_WINLDAP(name);
ldap_memfree(dn);
goto quit;
}
- result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *) name,
+ result = Curl_client_write(data, CLIENTWRITE_BODY, (char *) name,
name_len);
if(result) {
FREE_ON_WINLDAP(name);
@@ -551,7 +551,7 @@ static CURLcode ldap_do(struct connectdata *conn, bool *done)
goto quit;
}
- result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
+ result = Curl_client_write(data, CLIENTWRITE_BODY, (char *)"\n", 1);
if(result) {
FREE_ON_WINLDAP(name);
ldap_memfree(dn);
@@ -589,7 +589,7 @@ static CURLcode ldap_do(struct connectdata *conn, bool *done)
vals = ldap_get_values_len(server, entryIterator, attribute);
if(vals != NULL) {
for(i = 0; (vals[i] != NULL); i++) {
- result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1);
+ result = Curl_client_write(data, CLIENTWRITE_BODY, (char *)"\t", 1);
if(result) {
ldap_value_free_len(vals);
FREE_ON_WINLDAP(attr);
@@ -600,7 +600,7 @@ static CURLcode ldap_do(struct connectdata *conn, bool *done)
goto quit;
}
- result = Curl_client_write(conn, CLIENTWRITE_BODY,
+ result = Curl_client_write(data, CLIENTWRITE_BODY,
(char *) attr, attr_len);
if(result) {
ldap_value_free_len(vals);
@@ -612,7 +612,7 @@ static CURLcode ldap_do(struct connectdata *conn, bool *done)
goto quit;
}
- result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2);
+ result = Curl_client_write(data, CLIENTWRITE_BODY, (char *)": ", 2);
if(result) {
ldap_value_free_len(vals);
FREE_ON_WINLDAP(attr);
@@ -644,7 +644,7 @@ static CURLcode ldap_do(struct connectdata *conn, bool *done)
}
if(val_b64_sz > 0) {
- result = Curl_client_write(conn, CLIENTWRITE_BODY, val_b64,
+ result = Curl_client_write(data, CLIENTWRITE_BODY, val_b64,
val_b64_sz);
free(val_b64);
if(result) {
@@ -661,7 +661,7 @@ static CURLcode ldap_do(struct connectdata *conn, bool *done)
}
}
else {
- result = Curl_client_write(conn, CLIENTWRITE_BODY, vals[i]->bv_val,
+ result = Curl_client_write(data, CLIENTWRITE_BODY, vals[i]->bv_val,
vals[i]->bv_len);
if(result) {
ldap_value_free_len(vals);
@@ -676,7 +676,7 @@ static CURLcode ldap_do(struct connectdata *conn, bool *done)
dlsize += vals[i]->bv_len;
}
- result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
+ result = Curl_client_write(data, CLIENTWRITE_BODY, (char *)"\n", 1);
if(result) {
ldap_value_free_len(vals);
FREE_ON_WINLDAP(attr);
@@ -698,7 +698,7 @@ static CURLcode ldap_do(struct connectdata *conn, bool *done)
FREE_ON_WINLDAP(attr);
ldap_memfree(attribute);
- result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
+ result = Curl_client_write(data, CLIENTWRITE_BODY, (char *)"\n", 1);
if(result)
goto quit;
dlsize++;