]> git.sur5r.net Git - openldap/blob - libraries/libldap/getattr.c
More files that didn't get merged properly.
[openldap] / libraries / libldap / getattr.c
1 /*
2  *  Copyright (c) 1990 Regents of the University of Michigan.
3  *  All rights reserved.
4  *
5  *  getattr.c
6  */
7
8 #include "portable.h"
9
10 #ifndef lint 
11 static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
12 #endif
13
14 #include <stdio.h>
15 #include <stdlib.h>
16
17 #include <ac/ctype.h>
18 #include <ac/socket.h>
19 #include <ac/string.h>
20 #include <ac/time.h>
21
22 #include "lber.h"
23 #include "ldap.h"
24 #include "ldap-int.h"
25
26 char *
27 ldap_first_attribute( LDAP *ld, LDAPMessage *entry, BerElement **ber )
28 {
29         long    len;
30
31         Debug( LDAP_DEBUG_TRACE, "ldap_first_attribute\n", 0, 0, 0 );
32
33         if ( (*ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
34                 return( NULL );
35         }
36
37         **ber = *entry->lm_ber;
38
39         /* 
40          * Skip past the sequence, dn, sequence of sequence, snarf the
41          * attribute type, and skip the set of values, leaving us
42          * positioned right before the next attribute type/value sequence.
43          */
44
45         len = LDAP_MAX_ATTR_LEN;
46         if ( ber_scanf( *ber, "{x{{sx}", ld->ld_attrbuffer, &len )
47             == LBER_ERROR ) {
48                 ld->ld_errno = LDAP_DECODING_ERROR;
49                 ber_free( *ber, 0 );
50                 return( NULL );
51         }
52
53         return( ld->ld_attrbuffer );
54 }
55
56 /* ARGSUSED */
57 char *
58 ldap_next_attribute( LDAP *ld, LDAPMessage *entry, BerElement *ber )
59 {
60         long    len;
61
62         Debug( LDAP_DEBUG_TRACE, "ldap_next_attribute\n", 0, 0, 0 );
63
64         /* skip sequence, snarf attribute type, skip values */
65         len = LDAP_MAX_ATTR_LEN;
66         if ( ber_scanf( ber, "{sx}", ld->ld_attrbuffer, &len ) 
67             == LBER_ERROR ) {
68                 ld->ld_errno = LDAP_DECODING_ERROR;
69                 ber_free( ber, 0 );
70                 return( NULL );
71         }
72
73         return( ld->ld_attrbuffer );
74 }