Created
July 5, 2010 22:11
-
-
Save sarahhodne/464747 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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