From: Kurt Zeilenga Date: Sun, 8 Jan 2006 19:34:01 +0000 (+0000) Subject: Update (and rename) Sort and VLV parse routines to expect actual X-Git-Tag: OPENLDAP_REL_ENG_2_4_BP~403 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=bca31173d80911d3a0a9e38f4fdbb855e08bdf6f;p=openldap Update (and rename) Sort and VLV parse routines to expect actual control to be directly passed in. --- diff --git a/include/ldap.h b/include/ldap.h index e34b5576ca..24133f614f 100644 --- a/include/ldap.h +++ b/include/ldap.h @@ -1940,7 +1940,7 @@ ldap_turn_s LDAP_P(( LDAP *ld, * LDAP Server Side Sort * in sortctrl.c */ -#define LDAP_API_FEATURE_SERVER_SIDE_SORT 1000 +#define LDAP_API_FEATURE_SERVER_SIDE_SORT 2000 /* structure for a sort-key */ typedef struct ldapsortkey { @@ -1962,11 +1962,11 @@ LDAP_F( int ) ldap_create_sort_control LDAP_P(( LDAP *ld, LDAPSortKey **keyList, - int ctl_iscritical, + int iscritical, LDAPControl **ctrlp )); LDAP_F( int ) -ldap_parse_sort_control LDAP_P(( +ldap_parse_sortresult_control LDAP_P(( LDAP *ld, LDAPControl **ctrlp, unsigned long *result, @@ -1977,7 +1977,7 @@ ldap_parse_sort_control LDAP_P(( * LDAP Virtual List View * in vlvctrl.c */ -#define LDAP_API_FEATURE_VIRTUAL_LIST_VIEW 1000 +#define LDAP_API_FEATURE_VIRTUAL_LIST_VIEW 2000 /* structure for virtual list */ typedef struct ldapvlvinfo { @@ -1998,9 +1998,9 @@ ldap_create_vlv_control LDAP_P(( LDAPControl **ctrlp )); LDAP_F( int ) -ldap_parse_vlv_control LDAP_P(( +ldap_parse_vlvresponse_control LDAP_P(( LDAP *ld, - LDAPControl **ctrls, + LDAPControl *ctrls, unsigned long *target_posp, unsigned long *list_countp, struct berval **contextp, diff --git a/libraries/libldap/sortctrl.c b/libraries/libldap/sortctrl.c index 63ccb283c2..0c14a133b3 100644 --- a/libraries/libldap/sortctrl.c +++ b/libraries/libldap/sortctrl.c @@ -356,16 +356,14 @@ exit: /* --------------------------------------------------------------------------- - ldap_parse_sort_control + ldap_parse_sortedresult_control Decode the server-side sort control return information. ld (IN) An LDAP session handle, as obtained from a call to ldap_init(). - ctrls (IN) The address of a NULL-terminated array of LDAPControl - structures, typically obtained by a call to - ldap_parse_result(). + ctrl (IN) The address of the LDAP Control Structure. returnCode (OUT) This result parameter is filled in with the sort control result code. This parameter MUST not be NULL. @@ -405,9 +403,9 @@ exit: ---------------------------------------------------------------------------*/ int -ldap_parse_sort_control( +ldap_parse_sortedresult_control( LDAP *ld, - LDAPControl **ctrls, + LDAPControl *ctrl, unsigned long *returnCode, char **attribute ) { @@ -422,8 +420,8 @@ ldap_parse_sort_control( return(ld->ld_errno); } - if (ctrls == NULL) { - ld->ld_errno = LDAP_CONTROL_NOT_FOUND; + if (ctrl == NULL) { + ld->ld_errno = LDAP_PARAM_ERROR; return(ld->ld_errno); } @@ -431,20 +429,14 @@ ldap_parse_sort_control( *attribute = NULL; } - /* Search the list of control responses for a sort control. */ - for (i=0; ctrls[i]; i++) { - pControl = ctrls[i]; - if (!strcmp(LDAP_CONTROL_SORTRESPONSE, pControl->ldctl_oid)) - goto foundSortControl; + if ( strcmp(LDAP_CONTROL_SORTRESPONSE, ctrl->ldctl_oid) != 0 ) { + /* Not sort result control */ + ld->ld_errno = LDAP_CONTROL_NOT_FOUND; + return(ld->ld_errno); } - /* No sort control was found. */ - ld->ld_errno = LDAP_CONTROL_NOT_FOUND; - return(ld->ld_errno); - -foundSortControl: /* Create a BerElement from the berval returned in the control. */ - ber = ber_init(&pControl->ldctl_value); + ber = ber_init(&ctrl->ldctl_value); if (ber == NULL) { ld->ld_errno = LDAP_NO_MEMORY; diff --git a/libraries/libldap/vlvctrl.c b/libraries/libldap/vlvctrl.c index 5396780011..c8896d4203 100644 --- a/libraries/libldap/vlvctrl.c +++ b/libraries/libldap/vlvctrl.c @@ -147,15 +147,13 @@ exit: /*--- - ldap_parse_vlv_control + ldap_parse_vlvresponse_control Decode the Virtual List View control return information. ld (IN) An LDAP session handle. - ctrls (IN) The address of a NULL-terminated array of - LDAPControl structures, typically obtained - by a call to ldap_parse_result(). + ctrl (IN) The address of the LDAPControl structure. target_posp (OUT) This result parameter is filled in with the list index of the target entry. If this parameter is @@ -203,9 +201,9 @@ exit: ---*/ int -ldap_parse_vlv_control( +ldap_parse_vlvresponse_control( LDAP *ld, - LDAPControl **ctrls, + LDAPControl *ctrl, unsigned long *target_posp, unsigned long *list_countp, struct berval **contextp, @@ -225,25 +223,19 @@ ldap_parse_vlv_control( *contextp = NULL; /* Make sure we return a NULL if error occurs. */ } - if (ctrls == NULL) { - ld->ld_errno = LDAP_CONTROL_NOT_FOUND; + if (ctrl == NULL) { + ld->ld_errno = LDAP_PARAM_ERROR; return(ld->ld_errno); } - /* Search the list of control responses for a VLV control. */ - for (i=0; ctrls[i]; i++) { - pControl = ctrls[i]; - if (!strcmp(LDAP_CONTROL_VLVRESPONSE, pControl->ldctl_oid)) - goto foundVLVControl; + if (strcmp(LDAP_CONTROL_VLVRESPONSE, ctrl->ldctl_oid) != 0) { + /* Not VLV Response control */ + ld->ld_errno = LDAP_CONTROL_NOT_FOUND; + return(ld->ld_errno); } - /* No sort control was found. */ - ld->ld_errno = LDAP_CONTROL_NOT_FOUND; - return(ld->ld_errno); - -foundVLVControl: /* Create a BerElement from the berval returned in the control. */ - ber = ber_init(&pControl->ldctl_value); + ber = ber_init(&ctrl->ldctl_value); if (ber == NULL) { ld->ld_errno = LDAP_NO_MEMORY;