Commits

Michael Granger  committed 0509599

More work on the toplevel module

  • Participants
  • Parent commits e49a9da

Comments (0)

Files changed (1)

  
  	self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
  end
+diff --git a/ext/extconf.rb b/ext/extconf.rb
+--- a/ext/extconf.rb
++++ b/ext/extconf.rb
+@@ -13,6 +13,8 @@
+ 
+ find_library( 'ldap', 'ldap_initialize' ) or
+ 	abort( "Could not find LDAP library (http://openldap.org/)." )
+-find_header( 'ldap.h' )  	or abort( "missing ldap.h" )
++find_header( 'ldap.h' ) or abort( "missing ldap.h" )
++
++have_const( 'LDAP_API_VERSION', 'ldap.h' ) or abort "no LDAP_API_VERSION constant defined"
+ 
+ create_makefile( 'openldap_ext' )
 diff --git a/ext/openldap.c b/ext/openldap.c
 --- a/ext/openldap.c
 +++ b/ext/openldap.c
-@@ -43,9 +43,170 @@
+@@ -43,9 +43,176 @@
  
  VALUE ropenldap_mOpenLDAP;
  
 +	/* Scheme */
 +	if ( urldesc->lud_scheme ) {
 +		ropenldap_log( "debug", "  parsed scheme: %s", urldesc->lud_scheme );
-+		RARRAY_PTR( rval )[0] = rb_str_new2( urldesc->lud_scheme );
-+		OBJ_INFECT( urlstring, RARRAY_PTR(rval)[0] );
++		obj = rb_str_new2( urldesc->lud_scheme );
++		OBJ_INFECT( obj, urlstring );
++		rb_ary_store( rval, 0L, obj );
 +	}
 +
-+	ropenldap_log( "debug", "  rval is: %s", RSTRING_PTR(rb_inspect(rval)) );
-+
 +	/* LDAP host to contact */
 +	if ( urldesc->lud_host ) {
 +		ropenldap_log( "debug", "  parsed host: %s", urldesc->lud_host );
-+		RARRAY_PTR( rval )[1] = rb_str_new2( urldesc->lud_host );
-+		OBJ_INFECT( RARRAY_PTR(rval)[1], urlstring );
++		obj = rb_str_new2( urldesc->lud_host );
++		OBJ_INFECT( obj, urlstring );
++		rb_ary_store( rval, 1L, obj );
 +	}
 +
 +	/* Port */
-+	RARRAY_PTR( rval )[2] = INT2FIX( urldesc->lud_port );
++	rb_ary_store( rval, 2L, INT2FIX(urldesc->lud_port) );
 +
 +	/* Base DN */
 +	if ( urldesc->lud_dn ) {
 +		ropenldap_log( "debug", "  parsed DN: %s", urldesc->lud_dn );
-+		RARRAY_PTR( rval )[3] = rb_str_new2( urldesc->lud_dn );
-+		OBJ_INFECT( RARRAY_PTR(rval)[3], urlstring );
++		obj = rb_str_new2( urldesc->lud_dn );
++		OBJ_INFECT( obj, urlstring );
++		rb_ary_store( rval, 3L, obj );
 +	}
 +
++	/* Attributes */
++	rb_ary_store( rval, 4L, ropenldap_rb_string_array(urldesc->lud_attrs) );
++
 +	/* Numeric scope (LDAP_SCOPE_*) */
-+	RARRAY_PTR( rval )[5] = INT2FIX( urldesc->lud_scope );
++	rb_ary_store( rval, 5L, INT2FIX(urldesc->lud_scope) );
 +
 +	/* Filter */
 +	if ( urldesc->lud_filter ) {
 +		ropenldap_log( "debug", "  parsed filter: %s", urldesc->lud_filter );
-+		RARRAY_PTR( rval )[6] = rb_str_new2( urldesc->lud_filter );
-+		OBJ_INFECT( RARRAY_PTR(rval)[6], urlstring );
++		obj = rb_str_new2( urldesc->lud_filter );
++		OBJ_INFECT( obj, urlstring );
++		rb_ary_store( rval, 6L, obj );
 +	}
 +
++	/* lists of LDAP extensions */
++	rb_ary_store( rval, 7L, ropenldap_rb_string_array(urldesc->lud_exts) );
++
 +	/* Critical extension/s flag */
-+	RARRAY_PTR( rval )[8] = urldesc->lud_crit_exts ? Qtrue : Qfalse;  /* true if any extension is critical */
-+
-+	/* lists of attributes and LDAP extensions */
-+	RARRAY_PTR( rval )[4] = ropenldap_rb_string_array( urldesc->lud_attrs );
-+	RARRAY_PTR( rval )[7] = ropenldap_rb_string_array( urldesc->lud_exts );
++	rb_ary_store( rval, 8L, urldesc->lud_crit_exts ? Qtrue : Qfalse );
 +
 +	ldap_free_urldesc( urldesc );
 +
  {
  	ropenldap_mOpenLDAP = rb_define_module( "OpenLDAP" );
 +
++	
++
 +	rb_define_singleton_method( ropenldap_mOpenLDAP, "split_url", ropenldap_s_split_url, 1 );
 +
  }
 diff --git a/spec/openldap_spec.rb b/spec/openldap_spec.rb
 --- a/spec/openldap_spec.rb
 +++ b/spec/openldap_spec.rb
-@@ -5,16 +5,59 @@
+@@ -5,16 +5,67 @@
  	basedir = Pathname( __FILE__ ).dirname.parent
  	libdir = basedir + 'lib'
  
 +			'ldap.acme.com',
 +			389,
 +			'dc=acme,dc=com',
++			[],
++			OpenLDAP::LDAP_SCOPE_BASE,
++			nil,
++			[],
++			false,
 +		]
 +	end
 +
 +		result = OpenLDAP.split_url( url )
 +
 +		result[0].should be_tainted()
++		result[1].should be_tainted()
++		# port is an immediate object, so it's not tainted
++		result[3].should be_tainted()
  	end
  
  end