]> git.sur5r.net Git - openldap/blob - libraries/libldap/getattr.c
Use getpassphrase() instead of getpass() if available.
[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/ctype.h>
19 #include <ac/socket.h>
20 #include <ac/string.h>
21 #include <ac/time.h>
22
23 #include "ldap-int.h"
24
25 char *
26 ldap_first_attribute( LDAP *ld, LDAPMessage *entry, BerElement **ber )
27 {
28         char *attr;
29
30         Debug( LDAP_DEBUG_TRACE, "ldap_first_attribute\n", 0, 0, 0 );
31
32         assert( ld != NULL );
33         assert( LDAP_VALID( ld ) );
34         assert( entry != NULL );
35         assert( ber != NULL );
36
37         if ( (*ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
38                 *ber = NULL;
39                 return( NULL );
40         }
41
42         **ber = *entry->lm_ber;
43
44         /* 
45          * Skip past the sequence, dn, sequence of sequence, snarf the
46          * attribute type, and skip the set of values, leaving us
47          * positioned right before the next attribute type/value sequence.
48          */
49
50         if ( ber_scanf( *ber, "{x{{ax}" /*}}*/, &attr )
51             == LBER_ERROR ) {
52                 ld->ld_errno = LDAP_DECODING_ERROR;
53                 ber_free( *ber, 0 );
54                 *ber = NULL;
55                 return( NULL );
56         }
57
58         return( attr );
59 }
60
61 /* ARGSUSED */
62 char *
63 ldap_next_attribute( LDAP *ld, LDAPMessage *entry, BerElement *ber )
64 {
65         char *attr;
66
67         Debug( LDAP_DEBUG_TRACE, "ldap_next_attribute\n", 0, 0, 0 );
68
69         assert( ld != NULL );
70         assert( LDAP_VALID( ld ) );
71         assert( entry != NULL );
72         assert( ber != NULL );
73
74         /* skip sequence, snarf attribute type, skip values */
75         if ( ber_scanf( ber, "{ax}", &attr ) 
76             == LBER_ERROR ) {
77                 ld->ld_errno = LDAP_DECODING_ERROR;
78                 return( NULL );
79         }
80
81         return( attr );
82 }