diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-03-28 09:17:54 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-03-28 09:17:54 +0000 |
commit | cc38f5f090797b332633f8ead2dc1d34601fb03e (patch) | |
tree | c85f1303d657551e9717c9f2acd0bfaa9cccc6d8 | |
parent | ff95039936708914c3f973ce26f1991382b2c358 (diff) | |
download | ruby-cc38f5f090797b332633f8ead2dc1d34601fb03e.tar.gz |
* ext/socket/socket.c (sock_addrinfo): should specify socktype
from outside.
* io.c (argf_binmode): should call next_argv() to initialize ARGF.
* io.c (argf_filename): ditto.
* io.c (argf_file): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | ext/socket/socket.c | 36 | ||||
-rw-r--r-- | io.c | 31 |
3 files changed, 51 insertions, 29 deletions
@@ -9,6 +9,19 @@ Thu Mar 28 18:03:51 2002 Minero Aoki <aamine@loveruby.net> * ext/strscan/strscan.c: refactor struct strscanner. +Thu Mar 28 14:51:38 2002 Yukihiro Matsumoto <matz@ruby-lang.org> + + * ext/socket/socket.c (sock_addrinfo): should specify socktype + from outside. + +Wed Mar 27 17:04:30 2002 Yukihiro Matsumoto <matz@ruby-lang.org> + + * io.c (argf_binmode): should call next_argv() to initialize ARGF. + + * io.c (argf_filename): ditto. + + * io.c (argf_file): ditto. + Wed Mar 27 14:47:32 2002 WATANABE Hirofumi <eban@ruby-lang.org> * io.c (READ_DATA_PENDING): configure.in has supported for uClibc, diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 601455e878..b3cdf6248a 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -540,11 +540,11 @@ mkinetaddr(host, buf, len) } static struct addrinfo* -sock_addrinfo(host, port, flags) +sock_addrinfo(host, port, socktype, flags) VALUE host, port; - int flags; + int socktype, flags; { - struct addrinfo hints, *res; + struct addrinfo hints, *hintsp, *res; char *hostp, *portp; int error; char hbuf[1024], pbuf[16]; @@ -589,11 +589,17 @@ sock_addrinfo(host, port, flags) portp = RSTRING(port)->ptr; } - MEMZERO(&hints, struct addrinfo, 1); - hints.ai_family = PF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = flags; - error = getaddrinfo(hostp, portp, &hints, &res); + if (socktype == 0 && flags == 0) { + hintsp = 0; + } + else { + hintsp = &hints; + hints.ai_family = PF_UNSPEC; + hints.ai_protocol = 0; + hints.ai_socktype = socktype; + hints.ai_flags = flags; + } + error = getaddrinfo(hostp, portp, hintsp, &res); if (error) { if (hostp && hostp[strlen(hostp)-1] == '\n') { rb_raise(rb_eSocket, "newline at the end of hostname"); @@ -609,7 +615,7 @@ setipaddr(name, addr) VALUE name; struct sockaddr_storage *addr; { - struct addrinfo *res = sock_addrinfo(name, Qnil, 0); + struct addrinfo *res = sock_addrinfo(name, Qnil, SOCK_STREAM, 0); /* just take the first one */ memcpy(addr, res->ai_addr, res->ai_addrlen); @@ -842,14 +848,14 @@ init_inetsock(sock, remote_host, remote_serv, local_host, local_serv, type) int fd, status; char *syscall; - res_remote = sock_addrinfo(remote_host, remote_serv, + res_remote = sock_addrinfo(remote_host, remote_serv, SOCK_STREAM, (type == INET_SERVER) ? AI_PASSIVE : 0); /* * Maybe also accept a local address */ if (type != INET_SERVER && (!NIL_P(local_host) || !NIL_P(local_serv))) { - res_local = sock_addrinfo(local_host, local_serv, + res_local = sock_addrinfo(local_host, local_serv, SOCK_STREAM, (type == INET_SERVER) ? AI_PASSIVE : 0); } @@ -1270,7 +1276,7 @@ udp_connect(sock, host, port) rb_secure(3); GetOpenFile(sock, fptr); fd = fileno(fptr->f); - res0 = sock_addrinfo(host, port, 0); + res0 = sock_addrinfo(host, port, SOCK_DGRAM, 0); for (res = res0; res; res = res->ai_next) { if (ruby_connect(fd, res->ai_addr, res->ai_addrlen, 0) >= 0) { freeaddrinfo(res0); @@ -1292,7 +1298,7 @@ udp_bind(sock, host, port) rb_secure(3); GetOpenFile(sock, fptr); - res0 = sock_addrinfo(host, port, 0); + res0 = sock_addrinfo(host, port, SOCK_DGRAM, 0); for (res = res0; res; res = res->ai_next) { if (bind(fileno(fptr->f), res->ai_addr, res->ai_addrlen) < 0) { continue; @@ -1324,7 +1330,7 @@ udp_send(argc, argv, sock) rb_scan_args(argc, argv, "4", &mesg, &flags, &host, &port); GetOpenFile(sock, fptr); - res0 = sock_addrinfo(host, port, 0); + res0 = sock_addrinfo(host, port, SOCK_DGRAM, 0); f = GetWriteFile(fptr); StringValue(mesg); for (res = res0; res; res = res->ai_next) { @@ -2195,7 +2201,7 @@ static VALUE sock_s_pack_sockaddr_in(self, port, host) VALUE self, port, host; { - struct addrinfo *res = sock_addrinfo(host, port, 0); + struct addrinfo *res = sock_addrinfo(host, port, 0, 0); VALUE addr = rb_str_new((char*)res->ai_addr, res->ai_addrlen); freeaddrinfo(res); @@ -255,6 +255,7 @@ io_fflush(f, path) n = fflush(f); TRAP_END; if (n == EOF) rb_sys_fail(path); + fptr->mode &= ~FMODE_WBUF; } /* writing functions */ @@ -299,7 +300,6 @@ io_write(io, str) #endif if (fptr->mode & FMODE_SYNC) { io_fflush(f, fptr->path); - fptr->mode &= ~FMODE_WBUF; } else { fptr->mode |= FMODE_WBUF; @@ -2668,19 +2668,6 @@ argf_forward() ruby_frame->argc, ruby_frame->argv); } -static VALUE -argf_binmode() -{ - if (TYPE(current_file) != T_FILE) { - argf_forward(); - } - else { - rb_io_binmode(current_file); - } - binmode = 1; - return argf; -} - static int next_argv() { @@ -3608,16 +3595,32 @@ argf_each_byte() static VALUE argf_filename() { + next_argv(); return filename; } static VALUE argf_file() { + next_argv(); return current_file; } static VALUE +argf_binmode() +{ + binmode = 1; + next_argv(); + if (TYPE(current_file) != T_FILE) { + argf_forward(); + } + else { + rb_io_binmode(current_file); + } + return argf; +} + +static VALUE argf_skip() { if (next_p != -1) { |