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 )
32 Debug( LDAP_DEBUG_TRACE, "ldap_first_attribute\n", 0, 0, 0 );
35 assert( LDAP_VALID( ld ) );
36 assert( entry != NULL );
37 assert( berout != NULL );
39 ber = ldap_alloc_ber_with_options( ld );
44 *ber = *entry->lm_ber;
47 * Skip past the sequence, dn, sequence of sequence leaving
48 * us at the first attribute.
51 rc = ber_scanf( ber, "{xl{" /*}}*/, &attr, &len );
53 if( rc == LBER_ERROR ) {
54 ld->ld_errno = LDAP_DECODING_ERROR;
65 /* set the length to avoid overrun */
66 rc = ber_set_option( ber, LBER_OPT_REMAINING_BYTES, &len );
68 if( rc != LBER_OPT_SUCCESS ) {
69 ld->ld_errno = LDAP_LOCAL_ERROR;
74 /* snatch the first attribute */
75 rc = ber_scanf( ber, "{ax}", &attr );
76 if( rc == LBER_ERROR ) {
77 ld->ld_errno = LDAP_DECODING_ERROR;
88 ldap_next_attribute( LDAP *ld, LDAPMessage *entry, BerElement *ber )
93 Debug( LDAP_DEBUG_TRACE, "ldap_next_attribute\n", 0, 0, 0 );
96 assert( LDAP_VALID( ld ) );
97 assert( entry != NULL );
98 assert( ber != NULL );
101 if ( ber_pvt_ber_remaining( ber ) == 0 ) {
106 /* skip sequence, snarf attribute type, skip values */
107 rc = ber_scanf( ber, "{ax}", &attr );
108 if( rc == LBER_ERROR ) {
109 ld->ld_errno = LDAP_DECODING_ERROR;