]> git.sur5r.net Git - openldap/blob - libraries/libldap/getattr.c
Move LDAPServer, LDAPConn, LDAPRequest, and LDAPCache
[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 "ldap-int.h"
23
24 char *
25 ldap_first_attribute( LDAP *ld, LDAPMessage *entry, BerElement **ber )
26 {
27         long    len;
28
29         Debug( LDAP_DEBUG_TRACE, "ldap_first_attribute\n", 0, 0, 0 );
30
31         if ( (*ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
32                 return( NULL );
33         }
34
35         **ber = *entry->lm_ber;
36
37         /* 
38          * Skip past the sequence, dn, sequence of sequence, snarf the
39          * attribute type, and skip the set of values, leaving us
40          * positioned right before the next attribute type/value sequence.
41          */
42
43         len = LDAP_MAX_ATTR_LEN;
44         if ( ber_scanf( *ber, "{x{{sx}", ld->ld_attrbuffer, &len )
45             == LBER_ERROR ) {
46                 ld->ld_errno = LDAP_DECODING_ERROR;
47                 ber_free( *ber, 0 );
48                 return( NULL );
49         }
50
51         return( ld->ld_attrbuffer );
52 }
53
54 /* ARGSUSED */
55 char *
56 ldap_next_attribute( LDAP *ld, LDAPMessage *entry, BerElement *ber )
57 {
58         long    len;
59
60         Debug( LDAP_DEBUG_TRACE, "ldap_next_attribute\n", 0, 0, 0 );
61
62         /* skip sequence, snarf attribute type, skip values */
63         len = LDAP_MAX_ATTR_LEN;
64         if ( ber_scanf( ber, "{sx}", ld->ld_attrbuffer, &len ) 
65             == LBER_ERROR ) {
66                 ld->ld_errno = LDAP_DECODING_ERROR;
67                 ber_free( ber, 0 );
68                 return( NULL );
69         }
70
71         return( ld->ld_attrbuffer );
72 }