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>
26 ldap_get_values( LDAP *ld, LDAPMessage *entry, char *target )
29 char attr[LDAP_MAX_ATTR_LEN];
34 Debug( LDAP_DEBUG_TRACE, "ldap_get_values\n", 0, 0, 0 );
38 /* skip sequence, dn, sequence of, and snag the first attr */
40 if ( ber_scanf( &ber, "{x{{s", attr, &len ) == LBER_ERROR ) {
41 ld->ld_errno = LDAP_DECODING_ERROR;
45 if ( strcasecmp( target, attr ) == 0 )
48 /* break out on success, return out on error */
51 if ( ber_scanf( &ber, "x}{s", attr, &len ) == LBER_ERROR ) {
52 ld->ld_errno = LDAP_DECODING_ERROR;
56 if ( strcasecmp( target, attr ) == 0 )
61 * if we get this far, we've found the attribute and are sitting
62 * just before the set of values.
65 if ( ber_scanf( &ber, "[v]", &vals ) == LBER_ERROR ) {
66 ld->ld_errno = LDAP_DECODING_ERROR;
74 ldap_get_values_len( LDAP *ld, LDAPMessage *entry, char *target )
77 char attr[LDAP_MAX_ATTR_LEN];
82 Debug( LDAP_DEBUG_TRACE, "ldap_get_values_len\n", 0, 0, 0 );
86 /* skip sequence, dn, sequence of, and snag the first attr */
88 if ( ber_scanf( &ber, "{x{{s", attr, &len ) == LBER_ERROR ) {
89 ld->ld_errno = LDAP_DECODING_ERROR;
93 if ( strcasecmp( target, attr ) == 0 )
96 /* break out on success, return out on error */
99 if ( ber_scanf( &ber, "x}{s", attr, &len ) == LBER_ERROR ) {
100 ld->ld_errno = LDAP_DECODING_ERROR;
104 if ( strcasecmp( target, attr ) == 0 )
109 * if we get this far, we've found the attribute and are sitting
110 * just before the set of values.
113 if ( ber_scanf( &ber, "[V]", &vals ) == LBER_ERROR ) {
114 ld->ld_errno = LDAP_DECODING_ERROR;
122 ldap_count_values( char **vals )
129 for ( i = 0; vals[i] != NULL; i++ )
136 ldap_count_values_len( struct berval **vals )
138 return( ldap_count_values( (char **) vals ) );
142 ldap_value_free( char **vals )
148 for ( i = 0; vals[i] != NULL; i++ )
150 free( (char *) vals );
154 ldap_value_free_len( struct berval **vals )
160 for ( i = 0; vals[i] != NULL; i++ ) {
161 free( vals[i]->bv_val );
164 free( (char *) vals );