Update (and rename) Sort and VLV parse routines to expect actual

control to be directly passed in.
This commit is contained in:
Kurt Zeilenga 2006-01-08 19:34:01 +00:00
parent 8ab4786ef2
commit bca31173d8
3 changed files with 29 additions and 45 deletions

View file

@ -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,

View file

@ -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;

View file

@ -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) {
if (ctrl == NULL) {
ld->ld_errno = LDAP_PARAM_ERROR;
return(ld->ld_errno);
}
if (strcmp(LDAP_CONTROL_VLVRESPONSE, ctrl->ldctl_oid) != 0) {
/* Not VLV Response control */
ld->ld_errno = LDAP_CONTROL_NOT_FOUND;
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;
}
/* 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;