diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-17 16:39:03 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-17 16:39:03 +0000 |
commit | 861d4f126972a5232db466aeeb8963e47705e819 (patch) | |
tree | 53261e416788e28c116a55d2dd71c5b28c0e03ed /ext | |
parent | 3e3db16d40c37d16da0d2c2d8293f279a707ef38 (diff) | |
download | ruby-861d4f126972a5232db466aeeb8963e47705e819.tar.gz ruby-861d4f126972a5232db466aeeb8963e47705e819.tar.xz ruby-861d4f126972a5232db466aeeb8963e47705e819.zip |
* ext/socket/socket.c (sock_s_getnameinfo): accept AddrInfo object.
* ext/socket/raddrinfo.c (rb_check_sockaddr_string_type): defined.
* ext/socket/rubysocket.h (rb_check_sockaddr_string_type): declared.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@21641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/socket/raddrinfo.c | 8 | ||||
-rw-r--r-- | ext/socket/rubysocket.h | 1 | ||||
-rw-r--r-- | ext/socket/socket.c | 2 |
3 files changed, 10 insertions, 1 deletions
diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c index f3ed2ca4a..b32428347 100644 --- a/ext/socket/raddrinfo.c +++ b/ext/socket/raddrinfo.c @@ -1520,6 +1520,14 @@ sockaddr_string_value_ptr(volatile VALUE *v) } VALUE +rb_check_sockaddr_string_type(VALUE val) +{ + if (TYPE(val) == RUBY_T_DATA && IS_ADDRINFO(val)) + return addrinfo_to_sockaddr(val); + return rb_check_string_type(val); +} + +VALUE fd_socket_addrinfo(int fd, struct sockaddr *addr, socklen_t len) { int family; diff --git a/ext/socket/rubysocket.h b/ext/socket/rubysocket.h index 486409c5f..464649fc4 100644 --- a/ext/socket/rubysocket.h +++ b/ext/socket/rubysocket.h @@ -150,6 +150,7 @@ int Rconnect(); #define SockAddrStringValuePtr(v) sockaddr_string_value_ptr(&(v)) VALUE sockaddr_string_value(volatile VALUE *); char *sockaddr_string_value_ptr(volatile VALUE *); +VALUE rb_check_sockaddr_string_type(VALUE); NORETURN(void raise_socket_error(const char *, int)); diff --git a/ext/socket/socket.c b/ext/socket/socket.c index def79ba53..6334dd2a8 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -1134,7 +1134,7 @@ sock_s_getnameinfo(int argc, VALUE *argv) if (!NIL_P(flags)) { fl = NUM2INT(flags); } - tmp = rb_check_string_type(sa); + tmp = rb_check_sockaddr_string_type(sa); if (!NIL_P(tmp)) { sa = tmp; if (sizeof(ss) < RSTRING_LEN(sa)) { |