Fixed the LDAP_DEPRECATED #define as suggested by Daniel Johnson, and

indented some of the code to curl-style
This commit is contained in:
Daniel Stenberg 2007-08-12 22:25:50 +00:00
parent df3e8e19c1
commit 1b88990cbb
1 changed files with 19 additions and 19 deletions

View File

@ -46,7 +46,7 @@
#ifdef CURL_LDAP_WIN /* Use W$ LDAP implementation. */ #ifdef CURL_LDAP_WIN /* Use W$ LDAP implementation. */
# include <winldap.h> # include <winldap.h>
#else #else
#define LDAP_DEPRECATED /* Be sure ldap_init() is defined. */ #define LDAP_DEPRECATED 1 /* Be sure ldap_init() is defined. */
# include <ldap.h> # include <ldap.h>
#endif #endif
@ -376,9 +376,9 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
if (!conn->data || if (!conn->data ||
!conn->data->reqdata.path || !conn->data->reqdata.path ||
conn->data->reqdata.path[0] != '/' || conn->data->reqdata.path[0] != '/' ||
!checkprefix(conn->protostr, conn->data->change.url)) !checkprefix(conn->protostr, conn->data->change.url))
return LDAP_INVALID_SYNTAX; return LDAP_INVALID_SYNTAX;
ludp->lud_scope = LDAP_SCOPE_BASE; ludp->lud_scope = LDAP_SCOPE_BASE;
ludp->lud_port = conn->remote_port; ludp->lud_port = conn->remote_port;
@ -388,14 +388,14 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
*/ */
ludp->lud_dn = strdup(conn->data->reqdata.path+1); ludp->lud_dn = strdup(conn->data->reqdata.path+1);
if (!ludp->lud_dn) if (!ludp->lud_dn)
return LDAP_NO_MEMORY; return LDAP_NO_MEMORY;
p = strchr(ludp->lud_dn, '?'); p = strchr(ludp->lud_dn, '?');
LDAP_TRACE (("DN '%.*s'\n", p ? (size_t)(p-ludp->lud_dn) : LDAP_TRACE (("DN '%.*s'\n", p ? (size_t)(p-ludp->lud_dn) :
strlen(ludp->lud_dn), ludp->lud_dn)); strlen(ludp->lud_dn), ludp->lud_dn));
if (!p) if (!p)
goto success; goto success;
*p++ = '\0'; *p++ = '\0';
@ -403,65 +403,65 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
*/ */
q = strchr(p, '?'); q = strchr(p, '?');
if (q) if (q)
*q++ = '\0'; *q++ = '\0';
if (*p && *p != '?') { if (*p && *p != '?') {
ludp->lud_attrs = split_str(p); ludp->lud_attrs = split_str(p);
if (!ludp->lud_attrs) if (!ludp->lud_attrs)
return LDAP_NO_MEMORY; return LDAP_NO_MEMORY;
for (i = 0; ludp->lud_attrs[i]; i++) for (i = 0; ludp->lud_attrs[i]; i++)
LDAP_TRACE (("attr[%d] '%s'\n", i, ludp->lud_attrs[i])); LDAP_TRACE (("attr[%d] '%s'\n", i, ludp->lud_attrs[i]));
} }
p = q; p = q;
if (!p) if (!p)
goto success; goto success;
/* parse scope. skip "??" /* parse scope. skip "??"
*/ */
q = strchr(p, '?'); q = strchr(p, '?');
if (q) if (q)
*q++ = '\0'; *q++ = '\0';
if (*p && *p != '?') { if (*p && *p != '?') {
ludp->lud_scope = str2scope(p); ludp->lud_scope = str2scope(p);
if (ludp->lud_scope == -1) if (ludp->lud_scope == -1)
return LDAP_INVALID_SYNTAX; return LDAP_INVALID_SYNTAX;
LDAP_TRACE (("scope %d\n", ludp->lud_scope)); LDAP_TRACE (("scope %d\n", ludp->lud_scope));
} }
p = q; p = q;
if (!p) if (!p)
goto success; goto success;
/* parse filter /* parse filter
*/ */
q = strchr(p, '?'); q = strchr(p, '?');
if (q) if (q)
*q++ = '\0'; *q++ = '\0';
if (!*p) if (!*p)
return LDAP_INVALID_SYNTAX; return LDAP_INVALID_SYNTAX;
ludp->lud_filter = p; ludp->lud_filter = p;
LDAP_TRACE (("filter '%s'\n", ludp->lud_filter)); LDAP_TRACE (("filter '%s'\n", ludp->lud_filter));
p = q; p = q;
if (!p) if (!p)
goto success; goto success;
/* parse extensions /* parse extensions
*/ */
ludp->lud_exts = split_str(p); ludp->lud_exts = split_str(p);
if (!ludp->lud_exts) if (!ludp->lud_exts)
return LDAP_NO_MEMORY; return LDAP_NO_MEMORY;
for (i = 0; ludp->lud_exts[i]; i++) for (i = 0; ludp->lud_exts[i]; i++)
LDAP_TRACE (("exts[%d] '%s'\n", i, ludp->lud_exts[i])); LDAP_TRACE (("exts[%d] '%s'\n", i, ludp->lud_exts[i]));
success: success:
if (!unescape_elements(conn->data, ludp)) if (!unescape_elements(conn->data, ludp))
return LDAP_NO_MEMORY; return LDAP_NO_MEMORY;
return LDAP_SUCCESS; return LDAP_SUCCESS;
} }