3 * Copyright 1998-2002 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{" /*}}*/, &len );
55 if( tag == LBER_ERROR ) {
56 ld->ld_errno = LDAP_DECODING_ERROR;
61 /* set the length to avoid overrun */
62 rc = ber_set_option( ber, LBER_OPT_REMAINING_BYTES, &len );
63 if( rc != LBER_OPT_SUCCESS ) {
64 ld->ld_errno = LDAP_LOCAL_ERROR;
69 if ( ber_pvt_ber_remaining( ber ) == 0 ) {
76 /* snatch the first attribute */
77 tag = ber_scanf( ber, "{ax}", &attr );
78 if( tag == LBER_ERROR ) {
79 ld->ld_errno = LDAP_DECODING_ERROR;
90 ldap_next_attribute( LDAP *ld, LDAPMessage *entry, BerElement *ber )
95 Debug( LDAP_DEBUG_TRACE, "ldap_next_attribute\n", 0, 0, 0 );
98 assert( LDAP_VALID( ld ) );
99 assert( entry != NULL );
100 assert( ber != NULL );
102 if ( ber_pvt_ber_remaining( ber ) == 0 ) {
106 /* skip sequence, snarf attribute type, skip values */
107 tag = ber_scanf( ber, "{ax}", &attr );
108 if( tag == LBER_ERROR ) {
109 ld->ld_errno = LDAP_DECODING_ERROR;