3 * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
7 * Copyright (c) 1990 Regents of the University of Michigan.
16 #include <ac/stdlib.h>
18 #include <ac/socket.h>
19 #include <ac/string.h>
25 ldap_first_attribute( LDAP *ld, LDAPMessage *entry, BerElement **berout )
33 Debug( LDAP_DEBUG_TRACE, "ldap_first_attribute\n", 0, 0, 0 );
36 assert( LDAP_VALID( ld ) );
37 assert( entry != NULL );
38 assert( berout != NULL );
42 ber = ldap_alloc_ber_with_options( ld );
47 *ber = *entry->lm_ber;
50 * Skip past the sequence, dn, sequence of sequence leaving
51 * us at the first attribute.
54 tag = ber_scanf( ber, "{xl{" /*}}*/, &attr, &len );
55 if( tag == LBER_ERROR ) {
56 ld->ld_errno = LDAP_DECODING_ERROR;
61 #if LDAP_SEQORSET_BAILOUT
67 #if LBER_SEQORSET_AVOID_OVERRUN
68 /* set the length to avoid overrun */
69 rc = ber_set_option( ber, LBER_OPT_REMAINING_BYTES, &len );
70 if( rc != LBER_OPT_SUCCESS ) {
71 ld->ld_errno = LDAP_LOCAL_ERROR;
77 /* snatch the first attribute */
78 tag = ber_scanf( ber, "{ax}", &attr );
79 if( tag == LBER_ERROR ) {
80 ld->ld_errno = LDAP_DECODING_ERROR;
91 ldap_next_attribute( LDAP *ld, LDAPMessage *entry, BerElement *ber )
96 Debug( LDAP_DEBUG_TRACE, "ldap_next_attribute\n", 0, 0, 0 );
99 assert( LDAP_VALID( ld ) );
100 assert( entry != NULL );
101 assert( ber != NULL );
103 #if LDAP_SEQORSET_BAILOUT
104 if ( ber_pvt_ber_remaining( ber ) == 0 ) {
109 /* skip sequence, snarf attribute type, skip values */
110 tag = ber_scanf( ber, "{ax}", &attr );
111 if( tag == LBER_ERROR ) {
112 ld->ld_errno = LDAP_DECODING_ERROR;