2 * Copyright (c) 2001 by Sun Microsystems, Inc.
6 #pragma ident "%Z%%M% %I% %E% SMI"
9 * The contents of this file are subject to the Netscape Public
10 * License Version 1.1 (the "License"); you may not use this file
11 * except in compliance with the License. You may obtain a copy of
12 * the License at http://www.mozilla.org/NPL/
14 * Software distributed under the License is distributed on an "AS
15 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
16 * implied. See the License for the specific language governing
17 * rights and limitations under the License.
19 * The Original Code is Mozilla Communicator client code, released
22 * The Initial Developer of the Original Code is Netscape
23 * Communications Corporation. Portions created by Netscape are
24 * Copyright (C) 1998-1999 Netscape Communications Corporation. All
30 * Copyright (c) 1990 Regents of the University of Michigan.
31 * All rights reserved.
38 static char copyright
[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
45 bytes_remaining( BerElement
*ber
)
49 if ( ber_get_option( ber
, LBER_OPT_REMAINING_BYTES
, &len
) != 0 ) {
50 return( 0 ); /* not sure what else to do.... */
58 ldap_first_attribute( LDAP
*ld
, LDAPMessage
*entry
, BerElement
**ber
)
64 LDAPDebug( LDAP_DEBUG_TRACE
, "ldap_first_attribute\n", 0, 0, 0 );
66 if ( !NSLDAPI_VALID_LDAP_POINTER( ld
)) {
67 return( NULL
); /* punt */
70 if ( ber
== NULL
|| !NSLDAPI_VALID_LDAPMESSAGE_ENTRY_POINTER( entry
)) {
71 LDAP_SET_LDERRNO( ld
, LDAP_PARAM_ERROR
, NULL
, NULL
);
75 if ( nsldapi_alloc_ber_with_options( ld
, ber
) != LDAP_SUCCESS
) {
79 **ber
= *entry
->lm_ber
;
81 attr
= NULL
; /* pessimistic */
82 err
= LDAP_DECODING_ERROR
; /* ditto */
85 * Skip past the sequence, dn, and sequence of sequence.
86 * Reset number of bytes remaining so we confine the rest of our
87 * decoding to the current sequence.
89 if ( ber_scanf( *ber
, "{xl{", &seqlength
) != LBER_ERROR
&&
90 ber_set_option( *ber
, LBER_OPT_REMAINING_BYTES
, &seqlength
)
92 /* snarf the attribute type, and skip the set of values,
93 * leaving us positioned right before the next attribute
94 * type/value sequence.
96 if ( ber_scanf( *ber
, "{ax}", &attr
) != LBER_ERROR
||
97 bytes_remaining( *ber
) == 0 ) {
102 LDAP_SET_LDERRNO( ld
, err
, NULL
, NULL
);
103 if ( attr
== NULL
|| err
!= LDAP_SUCCESS
) {
113 ldap_next_attribute( LDAP
*ld
, LDAPMessage
*entry
, BerElement
*ber
)
118 LDAPDebug( LDAP_DEBUG_TRACE
, "ldap_next_attribute\n", 0, 0, 0 );
120 if ( !NSLDAPI_VALID_LDAP_POINTER( ld
)) {
121 return( NULL
); /* punt */
124 if ( ber
== NULL
|| !NSLDAPI_VALID_LDAPMESSAGE_ENTRY_POINTER( entry
)) {
125 LDAP_SET_LDERRNO( ld
, LDAP_PARAM_ERROR
, NULL
, NULL
);
129 attr
= NULL
; /* pessimistic */
130 err
= LDAP_DECODING_ERROR
; /* ditto */
132 /* skip sequence, snarf attribute type, skip values */
133 if ( ber_scanf( ber
, "{ax}", &attr
) != LBER_ERROR
||
134 bytes_remaining( ber
) == 0 ) {
138 LDAP_SET_LDERRNO( ld
, err
, NULL
, NULL
);