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 )
27 #if LBER_SEQORSET_AVOID_OVERRUN
35 Debug( LDAP_DEBUG_TRACE, "ldap_first_attribute\n", 0, 0, 0 );
38 assert( LDAP_VALID( ld ) );
39 assert( entry != NULL );
40 assert( berout != NULL );
44 ber = ldap_alloc_ber_with_options( ld );
49 *ber = *entry->lm_ber;
52 * Skip past the sequence, dn, sequence of sequence leaving
53 * us at the first attribute.
56 tag = ber_scanf( ber, "{xl{" /*}}*/, &attr, &len );
57 if( tag == LBER_ERROR ) {
58 ld->ld_errno = LDAP_DECODING_ERROR;
63 #if LDAP_SEQORSET_BAILOUT
69 #if LBER_SEQORSET_AVOID_OVERRUN
70 /* set the length to avoid overrun */
71 rc = ber_set_option( ber, LBER_OPT_REMAINING_BYTES, &len );
72 if( rc != LBER_OPT_SUCCESS ) {
73 ld->ld_errno = LDAP_LOCAL_ERROR;
79 /* snatch the first attribute */
80 tag = ber_scanf( ber, "{ax}", &attr );
81 if( tag == LBER_ERROR ) {
82 ld->ld_errno = LDAP_DECODING_ERROR;
93 ldap_next_attribute( LDAP *ld, LDAPMessage *entry, BerElement *ber )
98 Debug( LDAP_DEBUG_TRACE, "ldap_next_attribute\n", 0, 0, 0 );
100 assert( ld != NULL );
101 assert( LDAP_VALID( ld ) );
102 assert( entry != NULL );
103 assert( ber != NULL );
105 #if LDAP_SEQORSET_BAILOUT
106 if ( ber_pvt_ber_remaining( ber ) == 0 ) {
111 /* skip sequence, snarf attribute type, skip values */
112 tag = ber_scanf( ber, "{ax}", &attr );
113 if( tag == LBER_ERROR ) {
114 ld->ld_errno = LDAP_DECODING_ERROR;