2 * Copyright (c) 1990 Regents of the University of Michigan.
11 static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
18 #include <ac/socket.h>
19 #include <ac/string.h>
25 ldap_get_values( LDAP *ld, LDAPMessage *entry, char *target )
28 char attr[LDAP_MAX_ATTR_LEN];
33 Debug( LDAP_DEBUG_TRACE, "ldap_get_values\n", 0, 0, 0 );
37 /* skip sequence, dn, sequence of, and snag the first attr */
39 if ( ber_scanf( &ber, "{x{{s", attr, &len ) == LBER_ERROR ) {
40 ld->ld_errno = LDAP_DECODING_ERROR;
44 if ( strcasecmp( target, attr ) == 0 )
47 /* break out on success, return out on error */
50 if ( ber_scanf( &ber, "x}{s", attr, &len ) == LBER_ERROR ) {
51 ld->ld_errno = LDAP_DECODING_ERROR;
55 if ( strcasecmp( target, attr ) == 0 )
60 * if we get this far, we've found the attribute and are sitting
61 * just before the set of values.
64 if ( ber_scanf( &ber, "[v]", &vals ) == LBER_ERROR ) {
65 ld->ld_errno = LDAP_DECODING_ERROR;
73 ldap_get_values_len( LDAP *ld, LDAPMessage *entry, char *target )
76 char attr[LDAP_MAX_ATTR_LEN];
81 Debug( LDAP_DEBUG_TRACE, "ldap_get_values_len\n", 0, 0, 0 );
85 /* skip sequence, dn, sequence of, and snag the first attr */
87 if ( ber_scanf( &ber, "{x{{s", attr, &len ) == LBER_ERROR ) {
88 ld->ld_errno = LDAP_DECODING_ERROR;
92 if ( strcasecmp( target, attr ) == 0 )
95 /* break out on success, return out on error */
98 if ( ber_scanf( &ber, "x}{s", attr, &len ) == LBER_ERROR ) {
99 ld->ld_errno = LDAP_DECODING_ERROR;
103 if ( strcasecmp( target, attr ) == 0 )
108 * if we get this far, we've found the attribute and are sitting
109 * just before the set of values.
112 if ( ber_scanf( &ber, "[V]", &vals ) == LBER_ERROR ) {
113 ld->ld_errno = LDAP_DECODING_ERROR;
121 ldap_count_values( char **vals )
128 for ( i = 0; vals[i] != NULL; i++ )
135 ldap_count_values_len( struct berval **vals )
137 return( ldap_count_values( (char **) vals ) );
141 ldap_value_free( char **vals )
147 for ( i = 0; vals[i] != NULL; i++ )
149 free( (char *) vals );
153 ldap_value_free_len( struct berval **vals )
159 for ( i = 0; vals[i] != NULL; i++ ) {
160 free( vals[i]->bv_val );
163 free( (char *) vals );