/*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
/* vlistctrl.c - virtual list control implementation. */
#include "ldap-int.h"
/*
* function to create a VirtualListViewRequest control that can be passed
* to ldap_search_ext() or ldap_search_ext_s(). *ctrlp will be set to a
* freshly allocated LDAPControl structure. Returns an LDAP error code
* (LDAP_SUCCESS if all goes well).
*
* Parameters
* ld LDAP pointer to the desired connection
*
* ldvlistp the control structure.
*
* ctrlp the address of a place to put the constructed control
The controlValue is an OCTET STRING
whose value is the BER-encoding of the following SEQUENCE:
VirtualListViewRequest ::= SEQUENCE {
beforeCount INTEGER (0 .. maxInt),
afterCount INTEGER (0 .. maxInt),
CHOICE {
byIndex [0] SEQUENCE {
index INTEGER (0 .. maxInt),
contentCount INTEGER (0 .. maxInt) }
byValue [1] greaterThanOrEqual assertionValue }
beforeCount indicates how many entries before the target entry the
client wants the server to send. afterCount indicates the number of
entries after the target entry the client wants the server to send.
index and contentCount identify the target entry
greaterThanOrEqual is an attribute assertion value defined in
[LDAPv3]. If present, the value supplied in greaterThanOrEqual is used
to determine the target entry by comparison with the values of the
attribute specified as the primary sort key. The first list entry who's
value is no less than the supplied value is the target entry.
*/
int
)
{
int rc;
if (!NSLDAPI_VALID_LDAP_POINTER( ld )) {
return( LDAP_PARAM_ERROR );
}
return ( LDAP_PARAM_ERROR );
}
/* create a ber package to hold the controlValue */
{
return( LDAP_NO_MEMORY );
}
"{ii",
(int)ldvlistp->ldvlist_before_count,
(int)ldvlistp->ldvlist_after_count ))
/* XXX lossy casts */
{
return( LDAP_ENCODING_ERROR );
}
{
"t{ii}}",
(int)ldvlistp->ldvlist_index,
(int)ldvlistp->ldvlist_size ) )
/* XXX lossy casts */
{
return( LDAP_ENCODING_ERROR );
}
}
else
{
"to}",
return( LDAP_ENCODING_ERROR );
}
}
ber,
1,
1,
ctrlp );
return( rc );
}
/*
* function to find and parse a VirtualListViewResponse control contained in
* "ctrls" *target_posp, *list_sizep, and *errcodep are set based on its
* contents. Returns an LDAP error code that indicates whether the parsing
* itself was successful (LDAP_SUCCESS if all goes well).
The controlValue is an OCTET STRING, whose value
is the BER encoding of a value of the following SEQUENCE:
VirtualListViewResponse ::= SEQUENCE {
targetPosition INTEGER (0 .. maxInt),
contentCount INTEGER (0 .. maxInt),
virtualListViewResult ENUMERATED {
success (0),
operatonsError (1),
unwillingToPerform (53),
insufficientAccessRights (50),
busy (51),
timeLimitExceeded (3),
adminLimitExceeded (11),
sortControlMissing (60),
indexRangeError (61),
other (80) } }
*/
int
(
LDAPControl **ctrls,
unsigned long *target_posp,
unsigned long *list_sizep,
int *errcodep
)
{
if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) {
return( LDAP_PARAM_ERROR );
}
/* only ldapv3 or higher can do virtual lists. */
return( LDAP_NOT_SUPPORTED );
}
/* find the listControl in the list of controls if it exists */
return ( LDAP_CONTROL_NOT_FOUND );
}
foundListControl = 0;
}
if ( !foundListControl ) {
return ( LDAP_CONTROL_NOT_FOUND );
} else {
/* let local var point to the listControl */
}
/* allocate a Ber element with the contents of the list_control's struct berval */
return( LDAP_NO_MEMORY );
}
/* decode the result from the Berelement */
&errcode ) ) {
return( LDAP_DECODING_ERROR );
}
if ( target_posp != NULL ) {
}
if ( list_sizep != NULL ) {
*list_sizep = list_size;
}
}
/* the ber encoding is no longer needed */
return(LDAP_SUCCESS);
}