/*
* call-seq:
* entry.get_values(attr) => Array of String
* entry.vals(attr) => Array of String
* entry[attr] => Array of String
*
* Return an array of all the values belonging to the attribute, +attr+, of
* the entry.
*/
VALUE
rb_ldap_entry_get_values (VALUE self, VALUE attr)
{
RB_LDAPENTRY_DATA *edata;
char *c_attr;
struct berval **c_vals;
int i;
int count;
VALUE vals;
GET_LDAPENTRY_DATA (self, edata);
c_attr = StringValueCStr (attr);
c_vals = ldap_get_values_len (edata->ldap, edata->msg, c_attr);
if (c_vals)
{
vals = rb_ary_new ();
count = ldap_count_values_len (c_vals);
for (i = 0; i < count; i++)
{
VALUE str;
str = rb_tainted_str_new (c_vals[i]->bv_val, c_vals[i]->bv_len);
rb_ary_push (vals, str);
}
ldap_value_free_len (c_vals);
}
else
{
vals = Qnil;
}
return vals;
}