From 5d8f3512f3eca35b1dfa6a531b8cb62cd99b43dd Mon Sep 17 00:00:00 2001 From: eknauel Date: Thu, 12 Feb 2004 12:45:29 +0000 Subject: [PATCH] * c/ldap.c (scsh_ldap_next_attribute): don't confuse test for NULL (scsh_ldap_search_s): fixed pointer type (scsh_ldap_search_st): ditto (scsh_ldap_next_attribute): fixed test for NULL (scsh_ldap_get_set_option): dispatch by value type, added string types * c/ldap.c (scsh_ldap_search_st): arguments base and filter may be NULL, fixed bug in pointer handling * c/ldap.c (scsh_ldap_unbind_s): got rid of superfluos type check (scsh_ldap_abandon): ditto (scsh_ldap_add): ditto (scsh_ldap_compare_s): ditto (scsh_ldap_count_entries): ditto (scsh_ldap_count_messages): ditto (scsh_ldap_count_references): ditto (scsh_ldap_delete): ditto (scsh_ldap_first_entry): ditto (scsh_ldap_first_message): ditto (scsh_ldap_first_reference): ditto (scsh_ldap_get_dn): ditto (scsh_ldap_get_values): ditto (scsh_ldap_memfree): ditto (scsh_ldap_modify): ditto (scsh_ldap_msgfree): ditto (scsh_ldap_msgid): ditto (scsh_ldap_msgtype): ditto (scsh_ldap_next_entry): ditto (scsh_ldap_next_message): ditto (scsh_ldap_next_reference): ditto (scsh_ldap_search_s): ditto, and filter may be NULL (scsh_ldap_search_st): ditto --- c/ldap.c | 68 ++++++++++++++++++++++++++------------------------------ 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/c/ldap.c b/c/ldap.c index 2f1676a..7009ca2 100644 --- a/c/ldap.c +++ b/c/ldap.c @@ -130,23 +130,20 @@ s48_value scsh_ldap_search_s(s48_value ldap, s48_value base, { int r; char** a; - LDAPMessage **msg; + LDAPMessage *msg; s48_value res; S48_DECLARE_GC_PROTECT(7); S48_GC_PROTECT_7(ldap, base, scope, filter, attrs, attrsonly, res); - a = ffit_extract_list_of_strings(attrs); - r = ldap_search_s(scsh_extract_ldap(ldap), - S48_FALSE_P(base) ? NULL : s48_extract_string(base), + r = ldap_search_s(scsh_extract_ldap(ldap), + S48_FALSE_P(base) ? NULL : s48_extract_string(base), s48_extract_integer(scope), S48_FALSE_P(filter) ? NULL : s48_extract_string(filter), - a, - S48_TRUE_P(attrsonly), - msg); + a, S48_TRUE_P(attrsonly), &msg); free(a); res = s48_list_2(s48_enter_integer(r), - r == LDAP_SUCCESS ? scsh_enter_ldapmessage(*msg) : S48_FALSE); + r == LDAP_SUCCESS ? scsh_enter_ldapmessage(msg) : S48_FALSE); S48_GC_UNPROTECT(); return res; } @@ -158,9 +155,9 @@ s48_value scsh_ldap_search_st(s48_value ldap, s48_value base, { int r; char** a; - LDAPMessage **msg; + LDAPMessage *msg; struct timeval timeout; - s48_value res = S48_FALSE; + s48_value res; S48_DECLARE_GC_PROTECT(9); S48_GC_PROTECT_9(ldap, base, scope, filter, attrs, attrsonly, res, @@ -169,13 +166,14 @@ s48_value scsh_ldap_search_st(s48_value ldap, s48_value base, timeout.tv_sec = s48_extract_integer(timeout_sec); timeout.tv_usec = s48_extract_integer(timeout_usec); a = ffit_extract_list_of_strings(attrs); - - r = ldap_search_st(scsh_extract_ldap(ldap), s48_extract_string(base), - s48_extract_integer(scope), s48_extract_string(filter), - a, S48_TRUE_P(attrsonly), &timeout, msg); + r = ldap_search_st(scsh_extract_ldap(ldap), + S48_FALSE_P(base) ? NULL : s48_extract_string(base), + s48_extract_integer(scope), + S48_FALSE_P(filter) ? NULL : s48_extract_string(filter), + a, S48_TRUE_P(attrsonly), &timeout, &msg); free(a); - res = s48_list_2(s48_enter_integer(r), - r == LDAP_SUCCESS ? scsh_enter_ldapmessage(*msg) : S48_FALSE); + res = s48_list_2(s48_enter_integer(r), + r == LDAP_SUCCESS ? scsh_enter_ldapmessage(msg) : S48_FALSE); S48_GC_UNPROTECT(); return res; } @@ -342,7 +340,7 @@ s48_value scsh_ldap_next_attribute(s48_value ldap, s48_value entry, s48_value be name = ldap_next_attribute(scsh_extract_ldap(ldap), scsh_extract_ldapmessage(entry), scsh_extract_berelement(ber)); - res = (name == NULL) ? s48_enter_string(name) : S48_FALSE; + res = (name != NULL) ? s48_enter_string(name) : S48_FALSE; S48_GC_UNPROTECT(); return res; } @@ -495,7 +493,6 @@ s48_value scsh_ldap_get_set_option(s48_value ldap, s48_value option, { int opt, rc; LDAP *ld; - void *outvalue; s48_value res, res_list; S48_DECLARE_GC_PROTECT(6); @@ -508,18 +505,20 @@ s48_value scsh_ldap_get_set_option(s48_value ldap, s48_value option, switch (opt) { case LDAP_OPT_API_INFO: { + LDAPAPIInfo *inf; if (S48_TRUE_P(set)) raise_ldap_read_only_option(); - rc = ldap_get_option(ld, opt, outvalue); + + rc = ldap_get_option(ld, opt, &inf); if (rc == LDAP_OPT_SUCCESS) - res = scsh_enter_ldapiinfo((LDAPAPIInfo *) outvalue); + res = scsh_enter_ldapiinfo(inf); break; } case LDAP_OPT_DEREF: - { - } case LDAP_OPT_SIZELIMIT: case LDAP_OPT_TIMELIMIT: + case LDAP_OPT_PROTOCOL_VERSION: + case LDAP_OPT_ERROR_NUMBER: { int l; int ov; @@ -546,27 +545,24 @@ s48_value scsh_ldap_get_set_option(s48_value ldap, s48_value option, res = ov == 0 ? S48_TRUE : S48_FALSE; break; } - case LDAP_OPT_PROTOCOL_VERSION: - { - int v, ov; - if (S48_TRUE_P(set)) { - FFIT_CHECK_INTEGER(inval); - v = s48_extract_integer(inval); - rc = ldap_set_option(ld, opt, &v); - } - else - if ((rc = ldap_get_option(ld, opt, &ov)) == LDAP_SUCCESS) - res = s48_enter_integer(ov); - break; - } case LDAP_OPT_SERVER_CONTROLS: case LDAP_OPT_CLIENT_CONTROLS: { raise_ldap_read_only_option(); } + case LDAP_OPT_ERROR_STRING: + { + char *ov; + if (S48_TRUE_P(set)) + raise_ldap_read_only_option(); + + if ((rc = ldap_get_option(ld, opt, &ov)) == LDAP_SUCCESS) + res = s48_enter_string(ov); + break; + } default: { - printf("Alles ficken!\n"); + raise_ldap_feature_not_supported(); } }