mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/socket/socket.c (bsock_shutdown): accept symbol/string as how.
(shutdown_how_arg): new function. * ext/socket/mkconstants.rb: generate shutdown_how_to_int. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2f31ea3c86
commit
80618e75aa
4 changed files with 22 additions and 6 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
Thu Jan 8 23:19:38 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* ext/socket/socket.c (bsock_shutdown): accept symbol/string as how.
|
||||||
|
(shutdown_how_arg): new function.
|
||||||
|
|
||||||
|
* ext/socket/mkconstants.rb: generate shutdown_how_to_int.
|
||||||
|
|
||||||
Thu Jan 8 22:59:30 2009 Tanaka Akira <akr@fsij.org>
|
Thu Jan 8 22:59:30 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* ext/socket/mkconstants.rb (gen_name_to_int_func): generate
|
* ext/socket/mkconstants.rb (gen_name_to_int_func): generate
|
||||||
|
|
5
NEWS
5
NEWS
|
@ -78,8 +78,9 @@ with all sufficient information, see the ChangeLog file.
|
||||||
returns a sender address as AddrInfo object instead of a string.
|
returns a sender address as AddrInfo object instead of a string.
|
||||||
* BasicSocket#local_address
|
* BasicSocket#local_address
|
||||||
* BasicSocket#remote_address
|
* BasicSocket#remote_address
|
||||||
* string/symbol as protocol/address family, socket type, protocol level and
|
* string/symbol as protocol/address family, socket type, protocol level,
|
||||||
socket option name can be specified as a string/symbol.
|
socket option name and shutdown's how argument can be specified as a
|
||||||
|
string/symbol.
|
||||||
|
|
||||||
=== Compatibility issues (excluding feature bug fixes)
|
=== Compatibility issues (excluding feature bug fixes)
|
||||||
|
|
||||||
|
|
|
@ -219,6 +219,7 @@ init_constants(VALUE mConst)
|
||||||
<%= gen_name_to_int_func("ipv6_optname_to_int", /\AIPV6_/, "IPV6_", "IPPROTO_IPV6") %>
|
<%= gen_name_to_int_func("ipv6_optname_to_int", /\AIPV6_/, "IPV6_", "IPPROTO_IPV6") %>
|
||||||
<%= gen_name_to_int_func("tcp_optname_to_int", /\ATCP_/, "TCP_") %>
|
<%= gen_name_to_int_func("tcp_optname_to_int", /\ATCP_/, "TCP_") %>
|
||||||
<%= gen_name_to_int_func("udp_optname_to_int", /\AUDP_/, "UDP_") %>
|
<%= gen_name_to_int_func("udp_optname_to_int", /\AUDP_/, "UDP_") %>
|
||||||
|
<%= gen_name_to_int_func("shutdown_how_to_int", /\ASHUT_/, "SHUT_") %>
|
||||||
|
|
||||||
<%= INTERN_DEFS.map {|decl, gen_hash, func| func }.join("\n") %>
|
<%= INTERN_DEFS.map {|decl, gen_hash, func| func }.join("\n") %>
|
||||||
|
|
||||||
|
|
|
@ -375,6 +375,13 @@ optname_arg(int level, VALUE optname)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
shutdown_how_arg(VALUE how)
|
||||||
|
{
|
||||||
|
/* convert SHUT_RD, SHUT_WR, SHUT_RDWR. */
|
||||||
|
return constant_arg(how, shutdown_how_to_int, "unknown shutdown argument");
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
init_sock(VALUE sock, int fd)
|
init_sock(VALUE sock, int fd)
|
||||||
{
|
{
|
||||||
|
@ -415,11 +422,11 @@ bsock_shutdown(int argc, VALUE *argv, VALUE sock)
|
||||||
}
|
}
|
||||||
rb_scan_args(argc, argv, "01", &howto);
|
rb_scan_args(argc, argv, "01", &howto);
|
||||||
if (howto == Qnil)
|
if (howto == Qnil)
|
||||||
how = 2;
|
how = SHUT_RDWR;
|
||||||
else {
|
else {
|
||||||
how = NUM2INT(howto);
|
how = shutdown_how_arg(howto);
|
||||||
if (how < 0 || 2 < how) {
|
if (how != SHUT_WR && how != SHUT_RD && how != SHUT_RDWR) {
|
||||||
rb_raise(rb_eArgError, "`how' should be either 0, 1, 2");
|
rb_raise(rb_eArgError, "`how' should be either :SHUT_RD, :SHUT_WR, :SHUT_RDWR");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GetOpenFile(sock, fptr);
|
GetOpenFile(sock, fptr);
|
||||||
|
|
Loading…
Add table
Reference in a new issue