2 * Copyright (c) 1990 Regents of the University of Michigan.
9 static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
20 #if defined( DOS ) || defined( _WIN32 )
24 #include <sys/types.h>
25 #include <sys/socket.h>
33 ldap_get_values( LDAP *ld, LDAPMessage *entry, char *target )
36 char attr[LDAP_MAX_ATTR_LEN];
41 Debug( LDAP_DEBUG_TRACE, "ldap_get_values\n", 0, 0, 0 );
45 /* skip sequence, dn, sequence of, and snag the first attr */
47 if ( ber_scanf( &ber, "{x{{s", attr, &len ) == LBER_ERROR ) {
48 ld->ld_errno = LDAP_DECODING_ERROR;
52 if ( strcasecmp( target, attr ) == 0 )
55 /* break out on success, return out on error */
58 if ( ber_scanf( &ber, "x}{s", attr, &len ) == LBER_ERROR ) {
59 ld->ld_errno = LDAP_DECODING_ERROR;
63 if ( strcasecmp( target, attr ) == 0 )
68 * if we get this far, we've found the attribute and are sitting
69 * just before the set of values.
72 if ( ber_scanf( &ber, "[v]", &vals ) == LBER_ERROR ) {
73 ld->ld_errno = LDAP_DECODING_ERROR;
81 ldap_get_values_len( LDAP *ld, LDAPMessage *entry, char *target )
84 char attr[LDAP_MAX_ATTR_LEN];
89 Debug( LDAP_DEBUG_TRACE, "ldap_get_values_len\n", 0, 0, 0 );
93 /* skip sequence, dn, sequence of, and snag the first attr */
95 if ( ber_scanf( &ber, "{x{{s", attr, &len ) == LBER_ERROR ) {
96 ld->ld_errno = LDAP_DECODING_ERROR;
100 if ( strcasecmp( target, attr ) == 0 )
103 /* break out on success, return out on error */
106 if ( ber_scanf( &ber, "x}{s", attr, &len ) == LBER_ERROR ) {
107 ld->ld_errno = LDAP_DECODING_ERROR;
111 if ( strcasecmp( target, attr ) == 0 )
116 * if we get this far, we've found the attribute and are sitting
117 * just before the set of values.
120 if ( ber_scanf( &ber, "[V]", &vals ) == LBER_ERROR ) {
121 ld->ld_errno = LDAP_DECODING_ERROR;
129 ldap_count_values( char **vals )
136 for ( i = 0; vals[i] != NULL; i++ )
143 ldap_count_values_len( struct berval **vals )
145 return( ldap_count_values( (char **) vals ) );
149 ldap_value_free( char **vals )
155 for ( i = 0; vals[i] != NULL; i++ )
157 free( (char *) vals );
161 ldap_value_free_len( struct berval **vals )
167 for ( i = 0; vals[i] != NULL; i++ ) {
168 free( vals[i]->bv_val );
171 free( (char *) vals );