- for (i = 0; i < RARRAY (attrs)->len; i++)
+ for (i = 0; i < RARRAY_LEN(attrs); i++)
{
- VALUE mod = RARRAY (attrs)->ptr[i];
+ VALUE mod = RARRAY_PTR(attrs)[i];
RB_LDAPMOD_DATA *moddata;
Check_Kind (mod, rb_cLDAP_Mod);
GET_LDAPMOD_DATA (mod, moddata);
@@ -1435,13 +1435,13 @@
- for (i = 0; i < RARRAY (attrs)->len; i++)
+ for (i = 0; i < RARRAY_LEN(attrs); i++)
{
- VALUE mod = RARRAY (attrs)->ptr[i];
+ VALUE mod = RARRAY_PTR(attrs)[i];
RB_LDAPMOD_DATA *moddata;
Check_Kind (mod, rb_cLDAP_Mod);
GET_LDAPMOD_DATA (mod, moddata);
@@ -1489,11 +1489,11 @@
- for (i = 0; i < RARRAY (attrs)->len; i++)
+ for (i = 0; i < RARRAY_LEN(attrs); i++)
{
- VALUE mod = RARRAY (attrs)->ptr[i];
+ VALUE mod = RARRAY_PTR(attrs)[i];
RB_LDAPMOD_DATA *moddata;
Check_Kind (mod, rb_cLDAP_Mod);
GET_LDAPMOD_DATA (mod, moddata);
@@ -1543,13 +1543,13 @@
Sourceforge isn't letting me upload files, so I'm trying to paste the patch into a comment:
diff -ur ruby-ldap-0.9.7/conn.c ruby-ldap-0.9.7-1.9/conn.c
--- ruby-ldap-0.9.7/conn.c 2006-07-31 20:07:53.000000000 -0400
+++ ruby-ldap-0.9.7-1.9/conn.c 2009-02-20 15:09:00.000000000 -0500
@@ -210,10 +210,10 @@
VALUE ary = rb_iv_get (self, "@args");
if (rb_obj_is_kind_of (self, rb_cLDAP_SSLConn) == Qtrue)
- return rb_ldap_sslconn_initialize (RARRAY (ary)->len, RARRAY (ary)->ptr,
+ return rb_ldap_sslconn_initialize (RARRAY_LEN(ary), RARRAY_PTR(ary),
self);
else
- return rb_ldap_conn_initialize (RARRAY (ary)->len, RARRAY (ary)->ptr,
+ return rb_ldap_conn_initialize (RARRAY_LEN(ary), RARRAY_PTR(ary),
self);
}
@@ -847,18 +847,18 @@
else
Check_Type (attrs, T_ARRAY);
- if (RARRAY (attrs)->len == 0)
+ if (RARRAY_LEN(attrs) == 0)
{
cattrs = NULL;
}
else
{
- cattrs = ALLOCA_N (char *, (RARRAY (attrs)->len + 1));
- for (i = 0; i < RARRAY (attrs)->len; i++)
+ cattrs = ALLOCA_N (char *, (RARRAY_LEN(attrs) + 1));
+ for (i = 0; i < RARRAY_LEN(attrs); i++)
{
- cattrs[i] = StringValueCStr (RARRAY (attrs)->ptr[i]);
+ cattrs[i] = StringValueCStr (RARRAY_PTR(attrs)[i]);
};
- cattrs[RARRAY (attrs)->len] = NULL;
+ cattrs[RARRAY_LEN(attrs)] = NULL;
}
}
case 3:
@@ -1180,18 +1180,18 @@
else
Check_Type (attrs, T_ARRAY);
- if (RARRAY (attrs)->len == 0)
+ if (RARRAY_LEN(attrs) == 0)
{
cattrs = NULL;
}
else
{
- cattrs = ALLOCA_N (char *, (RARRAY (attrs)->len + 1));
- for (i = 0; i < RARRAY (attrs)->len; i++)
+ cattrs = ALLOCA_N (char *, (RARRAY_LEN(attrs) + 1));
+ for (i = 0; i < RARRAY_LEN(attrs); i++)
{
- cattrs[i] = StringValueCStr (RARRAY (attrs)->ptr[i]);
+ cattrs[i] = StringValueCStr (RARRAY_PTR(attrs)[i]);
};
- cattrs[RARRAY (attrs)->len] = NULL;
+ cattrs[RARRAY_LEN(attrs)] = NULL;
}
}
case 3:
@@ -1382,11 +1382,11 @@
GET_LDAP_DATA (self, ldapdata);
c_dn = StringValueCStr (dn);
- c_attrs = ALLOCA_N (LDAPMod *, (RARRAY (attrs)->len + 1));
+ c_attrs = ALLOCA_N (LDAPMod *, (RARRAY_LEN(attrs) + 1));
- for (i = 0; i < RARRAY (attrs)->len; i++)
+ for (i = 0; i < RARRAY_LEN(attrs); i++)
{
- VALUE mod = RARRAY (attrs)->ptr[i];
+ VALUE mod = RARRAY_PTR(attrs)[i];
RB_LDAPMOD_DATA *moddata;
Check_Kind (mod, rb_cLDAP_Mod);
GET_LDAPMOD_DATA (mod, moddata);
@@ -1435,13 +1435,13 @@
GET_LDAP_DATA (self, ldapdata);
c_dn = StringValueCStr (dn);
- c_attrs = ALLOCA_N (LDAPMod *, (RARRAY (attrs)->len + 1));
+ c_attrs = ALLOCA_N (LDAPMod *, (RARRAY_LEN(attrs) + 1));
sctrls = rb_ldap_get_controls (serverctrls);
cctrls = rb_ldap_get_controls (clientctrls);
- for (i = 0; i < RARRAY (attrs)->len; i++)
+ for (i = 0; i < RARRAY_LEN(attrs); i++)
{
- VALUE mod = RARRAY (attrs)->ptr[i];
+ VALUE mod = RARRAY_PTR(attrs)[i];
RB_LDAPMOD_DATA *moddata;
Check_Kind (mod, rb_cLDAP_Mod);
GET_LDAPMOD_DATA (mod, moddata);
@@ -1489,11 +1489,11 @@
GET_LDAP_DATA (self, ldapdata);
c_dn = StringValueCStr (dn);
- c_attrs = ALLOC_N (LDAPMod *, RARRAY (attrs)->len + 1);
+ c_attrs = ALLOC_N (LDAPMod *, RARRAY_LEN(attrs) + 1);
- for (i = 0; i < RARRAY (attrs)->len; i++)
+ for (i = 0; i < RARRAY_LEN(attrs); i++)
{
- VALUE mod = RARRAY (attrs)->ptr[i];
+ VALUE mod = RARRAY_PTR(attrs)[i];
RB_LDAPMOD_DATA *moddata;
Check_Kind (mod, rb_cLDAP_Mod);
GET_LDAPMOD_DATA (mod, moddata);
@@ -1543,13 +1543,13 @@
GET_LDAP_DATA (self, ldapdata);
c_dn = StringValueCStr (dn);
- c_attrs = ALLOC_N (LDAPMod *, RARRAY (attrs)->len + 1);
+ c_attrs = ALLOC_N (LDAPMod *, RARRAY_LEN(attrs) + 1);
sctrls = rb_ldap_get_controls (serverctrls);
cctrls = rb_ldap_get_controls (clientctrls);
- for (i = 0; i < RARRAY (attrs)->len; i++)
+ for (i = 0; i < RARRAY_LEN(attrs); i++)
{
- VALUE mod = RARRAY (attrs)->ptr[i];
+ VALUE mod = RARRAY_PTR(attrs)[i];
RB_LDAPMOD_DATA *moddata;
Check_Kind (mod, rb_cLDAP_Mod);
GET_LDAPMOD_DATA (mod, moddata);
@@ -1703,7 +1703,7 @@
c_val = StringValueCStr (val);
#endif
bval.bv_val = StringValueCStr (val);
- bval.bv_len = RSTRING (val)->len;
+ bval.bv_len = RSTRING_LEN(val);
sctrls = rb_ldap_get_controls (serverctrls);
cctrls = rb_ldap_get_controls (clientctrls);
diff -ur ruby-ldap-0.9.7/entry.c ruby-ldap-0.9.7-1.9/entry.c
--- ruby-ldap-0.9.7/entry.c 2005-03-15 05:15:32.000000000 -0500
+++ ruby-ldap-0.9.7-1.9/entry.c 2009-02-20 15:07:32.000000000 -0500
@@ -152,7 +152,7 @@
Check_Type (attrs, T_ARRAY);
rb_hash_aset (hash, rb_tainted_str_new2 ("dn"),
rb_ary_new3 (1, rb_ldap_entry_get_dn (self)));
- for (i = 0; i < RARRAY (attrs)->len; i++)
+ for (i = 0; i < RARRAY_LEN(attrs); i++)
{
attr = rb_ary_entry (attrs, i);
vals = rb_ldap_entry_get_values (self, attr);
@@ -173,11 +173,16 @@
{
VALUE str;
char *c;
+ char buf[1024];
c = rb_obj_classname (self);
str = rb_str_new (0, strlen (c) + 10 + 16 + 1); /* 10:tags 16:addr 1:nul */
- sprintf (RSTRING (str)->ptr, "#<%s:0x%lx\n", c, self);
- RSTRING (str)->len = strlen (RSTRING (str)->ptr);
+ /*
+ sprintf (RSTRING_PTR(str), "#<%s:0x%lx\n", c, self);
+ RSTRING_LEN(str) = strlen (RSTRING_PTR(str));
+ */
+ snprintf(buf, sizeof(buf), "#<%s:0x%lx\n", c, self);
+ rb_str_cat2(str, buf);
rb_str_concat (str, rb_inspect (rb_ldap_entry_to_hash (self)));
rb_str_cat2 (str, ">");
diff -ur ruby-ldap-0.9.7/misc.c ruby-ldap-0.9.7-1.9/misc.c
--- ruby-ldap-0.9.7/misc.c 2006-07-03 18:54:52.000000000 -0400
+++ ruby-ldap-0.9.7-1.9/misc.c 2009-02-20 15:09:17.000000000 -0500
@@ -53,11 +53,11 @@
info->ldapai_protocol_version =
FIX2INT (rb_struct_getmember (data, rb_intern ("protocol_version")));
r_extensions = rb_struct_getmember (data, rb_intern ("extensions"));
- len = RARRAY (r_extensions)->len;
+ len = RARRAY_LEN(r_extensions);
c_extensions = ALLOCA_N (char *, len);
for (i = 0; i <= len - 1; i++)
{
- VALUE str = RARRAY (r_extensions)->ptr[i];
+ VALUE str = RARRAY_PTR(r_extensions)[i];
RB_LDAP_SET_STR (c_extensions[i], str);
}
info->ldapai_extensions = c_extensions;
@@ -160,7 +160,7 @@
else
{
RB_LDAP_SET_STR (ctl->ldctl_value.bv_val, val);
- ctl->ldctl_value.bv_len = RSTRING (val)->len;
+ ctl->ldctl_value.bv_len = RSTRING_LEN(val);
}
return val;
@@ -449,7 +449,7 @@
return NULL;
Check_Type (data, T_ARRAY);
- len = RARRAY (data)->len;
+ len = RARRAY_LEN(data);
ctls = ALLOC_N (LDAPControl *, len + 1);
for (i = 0; i < len; i++)
{
diff -ur ruby-ldap-0.9.7/mod.c ruby-ldap-0.9.7-1.9/mod.c
--- ruby-ldap-0.9.7/mod.c 2005-03-07 17:57:34.000000000 -0500
+++ ruby-ldap-0.9.7-1.9/mod.c 2009-02-20 15:12:26.000000000 -0500
@@ -153,15 +153,15 @@
if (mod_op & LDAP_MOD_BVALUES)
{
- bvals = ALLOC_N (struct berval *, RARRAY (vals)->len + 1);
- for (i = 0; i < RARRAY (vals)->len; i++)
+ bvals = ALLOC_N (struct berval *, RARRAY_LEN(vals) + 1);
+ for (i = 0; i < RARRAY_LEN(vals); i++)
{
VALUE str;
struct berval *bval;
- str = RARRAY (vals)->ptr[i];
+ str = RARRAY_PTR(vals)[i];
Check_Type (str, T_STRING);
bval = ALLOC_N (struct berval, 1);
- bval->bv_len = RSTRING (str)->len;
+ bval->bv_len = RSTRING_LEN(str);
RB_LDAP_SET_STR (bval->bv_val, str);
bvals[i] = bval;
}
@@ -170,12 +170,12 @@
}
else
{
- strvals = ALLOC_N (char *, RARRAY (vals)->len + 1);
- for (i = 0; i < RARRAY (vals)->len; i++)
+ strvals = ALLOC_N (char *, RARRAY_LEN(vals) + 1);
+ for (i = 0; i < RARRAY_LEN(vals); i++)
{
VALUE str;
char *sval;
- str = RARRAY (vals)->ptr[i];
+ str = RARRAY_PTR(vals)[i];
RB_LDAP_SET_STR (sval, str);
strvals[i] = sval;
}
@@ -274,11 +274,16 @@
VALUE str;
VALUE hash = rb_hash_new ();
char *c;
+ char buf[1024];
c = rb_obj_classname (self);
str = rb_str_new (0, strlen (c) + 10 + 16 + 1); /* 10:tags 16:addr 1:nul */
- sprintf (RSTRING (str)->ptr, "#<%s:0x%lx ", c, self);
- RSTRING (str)->len = strlen (RSTRING (str)->ptr);
+ /*
+ sprintf (RSTRING_PTR(str), "#<%s:0x%lx ", c, self);
+ RSTRING_LEN(str) = strlen (RSTRING_PTR(str));
+ */
+ snprintf(buf, "#<%s:0x%lx ", c, self);
+ rb_str_cat2(str, buf);
switch (FIX2INT (rb_ldap_mod_op (self)) & ~LDAP_MOD_BVALUES)
{
diff -ur ruby-ldap-0.9.7/rbldap.h ruby-ldap-0.9.7-1.9/rbldap.h
--- ruby-ldap-0.9.7/rbldap.h 2006-08-09 07:23:04.000000000 -0400
+++ ruby-ldap-0.9.7-1.9/rbldap.h 2009-02-20 15:11:06.000000000 -0500
@@ -16,7 +16,9 @@
# include <ldap.h>
#endif
+#if 0
#include <version.h>
+#endif
#ifdef HAVE_LDAP_SSL_H
#include <ldap_ssl.h>
@@ -36,8 +38,8 @@
#define RB_LDAP_SET_STR(var,val) {\ Check_Type(val, T_STRING); \ - var = ALLOC_N(char, RSTRING(val)->len + 1); \ - memcpy(var, RSTRING(val)->ptr, RSTRING(val)->len + 1); \ + var = ALLOC_N(char, RSTRING_LEN(val) + 1); \ + memcpy(var, RSTRING_PTR(val), RSTRING_LEN(val) + 1); \ }
#if defined(HAVE_LDAP_SEARCH_EXT_S)
diff -ur ruby-ldap-0.9.7/saslconn.c ruby-ldap-0.9.7-1.9/saslconn.c
--- ruby-ldap-0.9.7/saslconn.c 2006-02-13 12:20:32.000000000 -0500
+++ ruby-ldap-0.9.7-1.9/saslconn.c 2009-02-20 15:09:10.000000000 -0500
@@ -95,20 +95,20 @@
dn = StringValuePtr (arg1);
mechanism = StringValuePtr (arg2);
cred->bv_val = StringValueCStr (arg3);
- cred->bv_len = RSTRING (arg3)->len;
+ cred->bv_len = RSTRING_LEN(arg3);
break;
case 4:
dn = StringValuePtr (arg1);
mechanism = StringValuePtr (arg2);
cred->bv_val = StringValueCStr (arg3);
- cred->bv_len = RSTRING (arg3)->len;
+ cred->bv_len = RSTRING_LEN(arg3);
serverctrls = rb_ldap_get_controls (arg4);
break;
case 5:
dn = StringValuePtr (arg1);
mechanism = StringValuePtr (arg2);
cred->bv_val = StringValueCStr (arg3);
- cred->bv_len = RSTRING (arg3)->len;
+ cred->bv_len = RSTRING_LEN(arg3);
serverctrls = rb_ldap_get_controls (arg4);
clientctrls = rb_ldap_get_controls (arg5);
break;
File Added: ruby-ldap-0.9.7-ruby-1.9.patch
Hello James. Thanks for Patch.
Ruby 1.9.x are supported in ruby-ldap-0.9.8 (http://code.google.com/p/ruby-activeldap/)