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";
19 #if defined( DOS ) || defined( _WIN32 )
23 #include <sys/types.h>
24 #include <sys/socket.h>
32 ldap_get_values( LDAP *ld, LDAPMessage *entry, char *target )
35 char attr[LDAP_MAX_ATTR_LEN];
40 Debug( LDAP_DEBUG_TRACE, "ldap_get_values\n", 0, 0, 0 );
44 /* skip sequence, dn, sequence of, and snag the first attr */
46 if ( ber_scanf( &ber, "{x{{s", attr, &len ) == LBER_ERROR ) {
47 ld->ld_errno = LDAP_DECODING_ERROR;
51 if ( strcasecmp( target, attr ) == 0 )
54 /* break out on success, return out on error */
57 if ( ber_scanf( &ber, "x}{s", attr, &len ) == LBER_ERROR ) {
58 ld->ld_errno = LDAP_DECODING_ERROR;
62 if ( strcasecmp( target, attr ) == 0 )
67 * if we get this far, we've found the attribute and are sitting
68 * just before the set of values.
71 if ( ber_scanf( &ber, "[v]", &vals ) == LBER_ERROR ) {
72 ld->ld_errno = LDAP_DECODING_ERROR;
80 ldap_get_values_len( LDAP *ld, LDAPMessage *entry, char *target )
83 char attr[LDAP_MAX_ATTR_LEN];
88 Debug( LDAP_DEBUG_TRACE, "ldap_get_values_len\n", 0, 0, 0 );
92 /* skip sequence, dn, sequence of, and snag the first attr */
94 if ( ber_scanf( &ber, "{x{{s", attr, &len ) == LBER_ERROR ) {
95 ld->ld_errno = LDAP_DECODING_ERROR;
99 if ( strcasecmp( target, attr ) == 0 )
102 /* break out on success, return out on error */
105 if ( ber_scanf( &ber, "x}{s", attr, &len ) == LBER_ERROR ) {
106 ld->ld_errno = LDAP_DECODING_ERROR;
110 if ( strcasecmp( target, attr ) == 0 )
115 * if we get this far, we've found the attribute and are sitting
116 * just before the set of values.
119 if ( ber_scanf( &ber, "[V]", &vals ) == LBER_ERROR ) {
120 ld->ld_errno = LDAP_DECODING_ERROR;
128 ldap_count_values( char **vals )
135 for ( i = 0; vals[i] != NULL; i++ )
142 ldap_count_values_len( struct berval **vals )
144 return( ldap_count_values( (char **) vals ) );
148 ldap_value_free( char **vals )
154 for ( i = 0; vals[i] != NULL; i++ )
156 free( (char *) vals );
160 ldap_value_free_len( struct berval **vals )
166 for ( i = 0; vals[i] != NULL; i++ ) {
167 free( vals[i]->bv_val );
170 free( (char *) vals );