summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-17 16:39:03 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-17 16:39:03 +0000
commite2f88006670866382c47efb8a10318d7ca0bcb1a (patch)
tree53261e416788e28c116a55d2dd71c5b28c0e03ed /ext
parent858987b06bac789b9de8c1e99571ef1d2cd6845d (diff)
* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@21641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/socket/raddrinfo.c8
-rw-r--r--ext/socket/rubysocket.h1
-rw-r--r--ext/socket/socket.c2
3 files changed, 10 insertions, 1 deletions
diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c
index f3ed2ca..b324283 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 486409c..464649f 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 def79ba..6334dd2 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)) {