summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-08-06 06:10:10 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-08-06 06:10:10 +0000
commitd94dbed46deaa325a43b92c5005585b3fbb20766 (patch)
treec41359cf0dd78f80e4bc1ebbe69385309e013368
parent2270c16ff9b0c2076e09ab6c83f4f20a83d204e8 (diff)
* socket.c: wrap UNIX code by ifdef HAVE_SYS_UN_H.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ext/socket/socket.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index d3e3fd53f0..da30898e0d 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -2079,6 +2079,17 @@ sock_s_pack_sockaddr_in(self, port, host)
}
static VALUE
+sock_s_unpack_sockaddr_in(self, addr)
+ VALUE self, addr;
+{
+ struct sockaddr_in * sockaddr;
+
+ sockaddr = (struct sockaddr_in*)StringValuePtr(addr);
+ return rb_assoc_new(INT2NUM(ntohs(sockaddr->sin_port)), mkipaddr(sockaddr));
+}
+
+#ifdef HAVE_SYS_UN_H
+static VALUE
sock_s_pack_sockaddr_un(self, path)
VALUE self, path;
{
@@ -2095,16 +2106,6 @@ sock_s_pack_sockaddr_un(self, path)
}
static VALUE
-sock_s_unpack_sockaddr_in(self, addr)
- VALUE self, addr;
-{
- struct sockaddr_in * sockaddr;
-
- sockaddr = (struct sockaddr_in*)StringValuePtr(addr);
- return rb_assoc_new(INT2NUM(ntohs(sockaddr->sin_port)), mkipaddr(sockaddr));
-}
-
-static VALUE
sock_s_unpack_sockaddr_un(self, addr)
VALUE self, addr;
{
@@ -2114,6 +2115,7 @@ sock_s_unpack_sockaddr_un(self, addr)
/* xxx: should I check against sun_path size? */
return rb_tainted_str_new2(sockaddr->sun_path);
}
+#endif
static VALUE mConst;
@@ -2225,11 +2227,13 @@ Init_socket()
rb_define_singleton_method(rb_cSocket, "getaddrinfo", sock_s_getaddrinfo, -1);
rb_define_singleton_method(rb_cSocket, "getnameinfo", sock_s_getnameinfo, -1);
rb_define_singleton_method(rb_cSocket, "sockaddr_in", sock_s_pack_sockaddr_in, 2);
- rb_define_singleton_method(rb_cSocket, "sockaddr_un", sock_s_pack_sockaddr_un, 1);
rb_define_singleton_method(rb_cSocket, "pack_sockaddr_in", sock_s_pack_sockaddr_in, 2);
- rb_define_singleton_method(rb_cSocket, "pack_sockaddr_un", sock_s_pack_sockaddr_un, 1);
rb_define_singleton_method(rb_cSocket, "unpack_sockaddr_in", sock_s_unpack_sockaddr_in, 1);
+#ifdef HAVE_SYS_UN_H
+ rb_define_singleton_method(rb_cSocket, "sockaddr_un", sock_s_pack_sockaddr_un, 1);
+ rb_define_singleton_method(rb_cSocket, "pack_sockaddr_un", sock_s_pack_sockaddr_un, 1);
rb_define_singleton_method(rb_cSocket, "unpack_sockaddr_un", sock_s_unpack_sockaddr_un, 1);
+#endif
/* constants */
mConst = rb_define_module_under(rb_cSocket, "Constants");