summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-05-26 18:11:29 +0000
committergotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-05-26 18:11:29 +0000
commitfde5c3ff928fb42d30595f7e2a75bf7e123e5973 (patch)
treec80e70158d1368ce82e8f0281a7d91fb4cf16775
parent6dee0fab9b72b9c185fa742685f6486de9373243 (diff)
* ext/openssl/ossl_ssl.c (ossl_ssl_read): take optional second argument
to specify a string to be written. * ext/openssl/lib/openssl/buffering.rb (OpenSSL::Buffering#read): take optional second argument to specify a string to be written. * ext/openssl/lib/openssl/buffering.rb (OpenSSL::Buffering#gets): refine regexp for end-of-line. * ext/opnessl/lib/openssl/ssl.rb (OpenSSL::SSL::SocketForwarder#listen): fix typo. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ext/openssl/lib/openssl/buffering.rb11
-rw-r--r--ext/openssl/lib/openssl/ssl.rb2
-rw-r--r--ext/openssl/ossl_ssl.c14
3 files changed, 19 insertions, 8 deletions
diff --git a/ext/openssl/lib/openssl/buffering.rb b/ext/openssl/lib/openssl/buffering.rb
index fdbd71bc0c1..6fcb143fc8b 100644
--- a/ext/openssl/lib/openssl/buffering.rb
+++ b/ext/openssl/lib/openssl/buffering.rb
@@ -54,14 +54,19 @@ module Buffering
public
- def read(size=nil)
+ def read(size=nil, buf=nil)
fill_rbuff unless defined? @rbuffer
@eof ||= nil
until @eof
break if size && size <= @rbuffer.size
fill_rbuff
end
- consume_rbuff(size)
+ ret = consume_rbuff(size) || ""
+ if buf
+ buf.replace(ret)
+ ret = buf
+ end
+ (size && ret.empty?) ? nil : ret
end
def gets(eol=$/)
@@ -164,7 +169,7 @@ module Buffering
s = ""
args.each{|arg|
s << arg.to_s
- unless /#{$/}\Z/o =~ s
+ unless /#{$/}\z/o =~ s
s << $/
end
}
diff --git a/ext/openssl/lib/openssl/ssl.rb b/ext/openssl/lib/openssl/ssl.rb
index f63ff7cc956..629109a1dec 100644
--- a/ext/openssl/lib/openssl/ssl.rb
+++ b/ext/openssl/lib/openssl/ssl.rb
@@ -68,7 +68,7 @@ module OpenSSL
@svr
end
- def listen(basklog=5)
+ def listen(backlog=5)
@svr.listen(backlog)
end
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index d115b3aeb4f..031f2334f7f 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -484,16 +484,22 @@ ossl_ssl_accept(VALUE self)
}
static VALUE
-ossl_ssl_read(VALUE self, VALUE len)
+ossl_ssl_read(int argc, VALUE *argv, VALUE self)
{
SSL *ssl;
int ilen, nread = 0;
- VALUE str;
+ VALUE len, str;
OpenFile *fptr;
Data_Get_Struct(self, SSL, ssl);
+ rb_scan_args(argc, argv, "11", &len, &str);
ilen = NUM2INT(len);
- str = rb_str_new(0, ilen);
+ if(NIL_P(str)) str = rb_str_new(0, ilen);
+ else{
+ StringValue(str);
+ rb_str_modify(str);
+ rb_str_resize(str, ilen);
+ }
if (ssl) {
for (;;){
@@ -730,7 +736,7 @@ Init_ossl_ssl()
rb_define_method(cSSLSocket, "initialize", ossl_ssl_initialize, -1);
rb_define_method(cSSLSocket, "connect", ossl_ssl_connect, 0);
rb_define_method(cSSLSocket, "accept", ossl_ssl_accept, 0);
- rb_define_method(cSSLSocket, "sysread", ossl_ssl_read, 1);
+ rb_define_method(cSSLSocket, "sysread", ossl_ssl_read, -1);
rb_define_method(cSSLSocket, "syswrite", ossl_ssl_write, 1);
rb_define_method(cSSLSocket, "sysclose", ossl_ssl_close, 0);
rb_define_method(cSSLSocket, "cert", ossl_ssl_get_cert, 0);