]> git.sur5r.net Git - openldap/blob - libraries/libldap/getattr.c
Avoid locale specific ctype routines.
[openldap] / libraries / libldap / getattr.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6 /*  Portions
7  *  Copyright (c) 1990 Regents of the University of Michigan.
8  *  All rights reserved.
9  *
10  *  getattr.c
11  */
12
13 #include "portable.h"
14
15 #include <stdio.h>
16 #include <ac/stdlib.h>
17
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         char *attr;
28
29         Debug( LDAP_DEBUG_TRACE, "ldap_first_attribute\n", 0, 0, 0 );
30
31         assert( ld != NULL );
32         assert( LDAP_VALID( ld ) );
33         assert( entry != NULL );
34         assert( ber != NULL );
35
36         if ( (*ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
37                 *ber = NULL;
38                 return( NULL );
39         }
40
41         **ber = *entry->lm_ber;
42
43         /* 
44          * Skip past the sequence, dn, sequence of sequence, snarf the
45          * attribute type, and skip the set of values, leaving us
46          * positioned right before the next attribute type/value sequence.
47          */
48
49         if ( ber_scanf( *ber, "{x{{ax}" /*}}*/, &attr )
50             == LBER_ERROR ) {
51                 ld->ld_errno = LDAP_DECODING_ERROR;
52                 ber_free( *ber, 0 );
53                 *ber = NULL;
54                 return( NULL );
55         }
56
57         return( attr );
58 }
59
60 /* ARGSUSED */
61 char *
62 ldap_next_attribute( LDAP *ld, LDAPMessage *entry, BerElement *ber )
63 {
64         char *attr;
65
66         Debug( LDAP_DEBUG_TRACE, "ldap_next_attribute\n", 0, 0, 0 );
67
68         assert( ld != NULL );
69         assert( LDAP_VALID( ld ) );
70         assert( entry != NULL );
71         assert( ber != NULL );
72
73         /* skip sequence, snarf attribute type, skip values */
74         if ( ber_scanf( ber, "{ax}", &attr ) 
75             == LBER_ERROR ) {
76                 ld->ld_errno = LDAP_DECODING_ERROR;
77                 return( NULL );
78         }
79
80         return( attr );
81 }