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 )
34 LDAP_LOG (( "getattr", LDAP_LEVEL_ENTRY, "ldap_first_attribute\n" ));
36 Debug( LDAP_DEBUG_TRACE, "ldap_first_attribute\n", 0, 0, 0 );
40 assert( LDAP_VALID( ld ) );
41 assert( entry != NULL );
42 assert( berout != NULL );
46 ber = ldap_alloc_ber_with_options( ld );
51 *ber = *entry->lm_ber;
54 * Skip past the sequence, dn, sequence of sequence leaving
55 * us at the first attribute.
58 tag = ber_scanf( ber, "{xl{" /*}}*/, &len );
59 if( tag == LBER_ERROR ) {
60 ld->ld_errno = LDAP_DECODING_ERROR;
65 /* set the length to avoid overrun */
66 rc = ber_set_option( ber, LBER_OPT_REMAINING_BYTES, &len );
67 if( rc != LBER_OPT_SUCCESS ) {
68 ld->ld_errno = LDAP_LOCAL_ERROR;
73 if ( ber_pvt_ber_remaining( ber ) == 0 ) {
80 /* snatch the first attribute */
81 tag = ber_scanf( ber, "{ax}", &attr );
82 if( tag == LBER_ERROR ) {
83 ld->ld_errno = LDAP_DECODING_ERROR;
94 ldap_next_attribute( LDAP *ld, LDAPMessage *entry, BerElement *ber )
100 LDAP_LOG (( "getattr", LDAP_LEVEL_ENTRY, "ldap_next_attribute\n" ));
102 Debug( LDAP_DEBUG_TRACE, "ldap_next_attribute\n", 0, 0, 0 );
105 assert( ld != NULL );
106 assert( LDAP_VALID( ld ) );
107 assert( entry != NULL );
108 assert( ber != NULL );
110 if ( ber_pvt_ber_remaining( ber ) == 0 ) {
114 /* skip sequence, snarf attribute type, skip values */
115 tag = ber_scanf( ber, "{ax}", &attr );
116 if( tag == LBER_ERROR ) {
117 ld->ld_errno = LDAP_DECODING_ERROR;