summaryrefslogtreecommitdiff
path: root/ext/socket
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-09 16:23:36 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-09 16:23:36 +0000
commitb877fc2f15e231b80bd4d60280adf8579e75f0d9 (patch)
treea9e4e398eba52ae6346722696a793774dc86c4f4 /ext/socket
parent41f256b48452df2de253edf737e1543d7ce88e12 (diff)
* ext/socket/option.c (sockopt_inspect): refactored.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket')
-rw-r--r--ext/socket/option.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/ext/socket/option.c b/ext/socket/option.c
index 45559b6c00..f0f5806276 100644
--- a/ext/socket/option.c
+++ b/ext/socket/option.c
@@ -300,15 +300,25 @@ sockopt_inspect(VALUE self)
StringValue(data);
- ret = rb_sprintf("#<%s: ", rb_obj_classname(self));
+ ret = rb_sprintf("#<%s:", rb_obj_classname(self));
family_id = intern_family_noprefix(family);
if (family_id)
- rb_str_cat2(ret, rb_id2name(family_id));
+ rb_str_catf(ret, " %s", rb_id2name(family_id));
else
- rb_str_catf(ret, "family:%d", family);
+ rb_str_catf(ret, " family:%d", family);
- if (family == AF_UNIX && level == 0) {
+ if (level == SOL_SOCKET) {
+ rb_str_cat2(ret, " SOCKET");
+
+ optname_id = intern_so_optname(optname);
+ if (optname_id)
+ rb_str_catf(ret, " %s", rb_id2name(optname_id));
+ else
+ rb_str_catf(ret, " optname:%d", optname);
+ }
+#ifdef HAVE_SYS_UN_H
+ else if (family == AF_UNIX) {
rb_str_catf(ret, " level:%d", level);
optname_id = intern_local_optname(optname);
@@ -317,7 +327,8 @@ sockopt_inspect(VALUE self)
else
rb_str_catf(ret, " optname:%d", optname);
}
- else {
+#endif
+ else if (IS_IP_FAMILY(family)) {
level_id = intern_iplevel(level);
if (level_id)
rb_str_catf(ret, " %s", rb_id2name(level_id));
@@ -330,6 +341,10 @@ sockopt_inspect(VALUE self)
else
rb_str_catf(ret, " optname:%d", optname);
}
+ else {
+ rb_str_catf(ret, " level:%d", level);
+ rb_str_catf(ret, " optname:%d", optname);
+ }
inspected = 0;
@@ -397,7 +412,9 @@ sockopt_inspect(VALUE self)
break;
case AF_INET:
+#ifdef INET6
case AF_INET6:
+#endif
switch (level) {
# if defined(IPPROTO_IPV6)
case IPPROTO_IPV6:
@@ -434,6 +451,7 @@ sockopt_inspect(VALUE self)
}
break;
+#ifdef HAVE_SYS_UN_H
case AF_UNIX:
switch (level) {
case 0:
@@ -445,6 +463,7 @@ sockopt_inspect(VALUE self)
break;
}
break;
+#endif
}
if (!inspected) {