Skip to content

Instantly share code, notes, and snippets.

@sarahhodne
Created July 5, 2010 22:11
Show Gist options
  • Save sarahhodne/464747 to your computer and use it in GitHub Desktop.
Save sarahhodne/464747 to your computer and use it in GitHub Desktop.
static VALUE rldap_msg_get_val(VALUE obj, VALUE key)
{
RLDAP_MSG_WRAP* wrapper;
char* attr;
BerValue** values;
VALUE ary;
int i, length;
BerValue* value;
char* strval;
VALUE str;
wrapper = get_msg_wrapper(obj);
attr = StringValuePtr(key);
values = (BerValue**)ldap_get_values(wrapper->ld, wrapper->mesg, attr);
if (values == NULL) {
rldap_raise(rldap_errno_c(obj));
}
ary = rb_ary_new();
length = ldap_count_values_len(values);
for (i=0; i<length; i++) {
value = values[i];
fwrite(value->bv_val, 1, value->bv_len, stdout);
str = rb_str_new(value->bv_val, value->bv_len);
rb_ary_push(ary, str);
}
ldap_value_free_len(values);
return ary;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment