* 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
This commit is contained in:
parent
ff95039936
commit
cc38f5f090
13
ChangeLog
13
ChangeLog
@ -9,6 +9,19 @@ Thu Mar 28 18:03:51 2002 Minero Aoki <aamine@loveruby.net>
|
|||||||
|
|
||||||
* ext/strscan/strscan.c: refactor struct strscanner.
|
* 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>
|
Wed Mar 27 14:47:32 2002 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||||
|
|
||||||
* io.c (READ_DATA_PENDING): configure.in has supported for uClibc,
|
* io.c (READ_DATA_PENDING): configure.in has supported for uClibc,
|
||||||
|
@ -540,11 +540,11 @@ mkinetaddr(host, buf, len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct addrinfo*
|
static struct addrinfo*
|
||||||
sock_addrinfo(host, port, flags)
|
sock_addrinfo(host, port, socktype, flags)
|
||||||
VALUE host, port;
|
VALUE host, port;
|
||||||
int flags;
|
int socktype, flags;
|
||||||
{
|
{
|
||||||
struct addrinfo hints, *res;
|
struct addrinfo hints, *hintsp, *res;
|
||||||
char *hostp, *portp;
|
char *hostp, *portp;
|
||||||
int error;
|
int error;
|
||||||
char hbuf[1024], pbuf[16];
|
char hbuf[1024], pbuf[16];
|
||||||
@ -589,11 +589,17 @@ sock_addrinfo(host, port, flags)
|
|||||||
portp = RSTRING(port)->ptr;
|
portp = RSTRING(port)->ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
MEMZERO(&hints, struct addrinfo, 1);
|
if (socktype == 0 && flags == 0) {
|
||||||
hints.ai_family = PF_UNSPEC;
|
hintsp = 0;
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
}
|
||||||
hints.ai_flags = flags;
|
else {
|
||||||
error = getaddrinfo(hostp, portp, &hints, &res);
|
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 (error) {
|
||||||
if (hostp && hostp[strlen(hostp)-1] == '\n') {
|
if (hostp && hostp[strlen(hostp)-1] == '\n') {
|
||||||
rb_raise(rb_eSocket, "newline at the end of hostname");
|
rb_raise(rb_eSocket, "newline at the end of hostname");
|
||||||
@ -609,7 +615,7 @@ setipaddr(name, addr)
|
|||||||
VALUE name;
|
VALUE name;
|
||||||
struct sockaddr_storage *addr;
|
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 */
|
/* just take the first one */
|
||||||
memcpy(addr, res->ai_addr, res->ai_addrlen);
|
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;
|
int fd, status;
|
||||||
char *syscall;
|
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);
|
(type == INET_SERVER) ? AI_PASSIVE : 0);
|
||||||
/*
|
/*
|
||||||
* Maybe also accept a local address
|
* Maybe also accept a local address
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (type != INET_SERVER && (!NIL_P(local_host) || !NIL_P(local_serv))) {
|
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);
|
(type == INET_SERVER) ? AI_PASSIVE : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1270,7 +1276,7 @@ udp_connect(sock, host, port)
|
|||||||
rb_secure(3);
|
rb_secure(3);
|
||||||
GetOpenFile(sock, fptr);
|
GetOpenFile(sock, fptr);
|
||||||
fd = fileno(fptr->f);
|
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) {
|
for (res = res0; res; res = res->ai_next) {
|
||||||
if (ruby_connect(fd, res->ai_addr, res->ai_addrlen, 0) >= 0) {
|
if (ruby_connect(fd, res->ai_addr, res->ai_addrlen, 0) >= 0) {
|
||||||
freeaddrinfo(res0);
|
freeaddrinfo(res0);
|
||||||
@ -1292,7 +1298,7 @@ udp_bind(sock, host, port)
|
|||||||
|
|
||||||
rb_secure(3);
|
rb_secure(3);
|
||||||
GetOpenFile(sock, fptr);
|
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) {
|
for (res = res0; res; res = res->ai_next) {
|
||||||
if (bind(fileno(fptr->f), res->ai_addr, res->ai_addrlen) < 0) {
|
if (bind(fileno(fptr->f), res->ai_addr, res->ai_addrlen) < 0) {
|
||||||
continue;
|
continue;
|
||||||
@ -1324,7 +1330,7 @@ udp_send(argc, argv, sock)
|
|||||||
rb_scan_args(argc, argv, "4", &mesg, &flags, &host, &port);
|
rb_scan_args(argc, argv, "4", &mesg, &flags, &host, &port);
|
||||||
|
|
||||||
GetOpenFile(sock, fptr);
|
GetOpenFile(sock, fptr);
|
||||||
res0 = sock_addrinfo(host, port, 0);
|
res0 = sock_addrinfo(host, port, SOCK_DGRAM, 0);
|
||||||
f = GetWriteFile(fptr);
|
f = GetWriteFile(fptr);
|
||||||
StringValue(mesg);
|
StringValue(mesg);
|
||||||
for (res = res0; res; res = res->ai_next) {
|
for (res = res0; res; res = res->ai_next) {
|
||||||
@ -2195,7 +2201,7 @@ static VALUE
|
|||||||
sock_s_pack_sockaddr_in(self, port, host)
|
sock_s_pack_sockaddr_in(self, port, host)
|
||||||
VALUE 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);
|
VALUE addr = rb_str_new((char*)res->ai_addr, res->ai_addrlen);
|
||||||
|
|
||||||
freeaddrinfo(res);
|
freeaddrinfo(res);
|
||||||
|
31
io.c
31
io.c
@ -255,6 +255,7 @@ io_fflush(f, path)
|
|||||||
n = fflush(f);
|
n = fflush(f);
|
||||||
TRAP_END;
|
TRAP_END;
|
||||||
if (n == EOF) rb_sys_fail(path);
|
if (n == EOF) rb_sys_fail(path);
|
||||||
|
fptr->mode &= ~FMODE_WBUF;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* writing functions */
|
/* writing functions */
|
||||||
@ -299,7 +300,6 @@ io_write(io, str)
|
|||||||
#endif
|
#endif
|
||||||
if (fptr->mode & FMODE_SYNC) {
|
if (fptr->mode & FMODE_SYNC) {
|
||||||
io_fflush(f, fptr->path);
|
io_fflush(f, fptr->path);
|
||||||
fptr->mode &= ~FMODE_WBUF;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fptr->mode |= FMODE_WBUF;
|
fptr->mode |= FMODE_WBUF;
|
||||||
@ -2668,19 +2668,6 @@ argf_forward()
|
|||||||
ruby_frame->argc, ruby_frame->argv);
|
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
|
static int
|
||||||
next_argv()
|
next_argv()
|
||||||
{
|
{
|
||||||
@ -3608,15 +3595,31 @@ argf_each_byte()
|
|||||||
static VALUE
|
static VALUE
|
||||||
argf_filename()
|
argf_filename()
|
||||||
{
|
{
|
||||||
|
next_argv();
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
argf_file()
|
argf_file()
|
||||||
{
|
{
|
||||||
|
next_argv();
|
||||||
return current_file;
|
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
|
static VALUE
|
||||||
argf_skip()
|
argf_skip()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user