diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-01 06:48:22 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-01 06:48:22 +0000 |
commit | 172d20878955c7b8eca9ebc782dfa7e91340dc8c (patch) | |
tree | 66243818fc9ea9d53404f371b088c304e8e1bb21 | |
parent | a6274c1e72689ad0425560a637f96beeb9e93ad2 (diff) | |
download | bundler-172d20878955c7b8eca9ebc782dfa7e91340dc8c.tar.gz |
* ext/socket/ (rsock_make_hostent): renamed from sock_make_hostent.
(rsock_addrinfo): renamed from sock_addrinfo.
(rsock_getaddrinfo): renamed from sock_getaddrinfo.
(rsock_socket): renamed from ruby_socket.
(rsock_sock_s_socketpair): renamed from sock_s_socketpair.
(rsock_connect): renamed from ruby_connect.
* ext/socket/socket.c (sock_listen): make it static.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | ext/socket/init.c | 4 | ||||
-rw-r--r-- | ext/socket/ipsocket.c | 12 | ||||
-rw-r--r-- | ext/socket/raddrinfo.c | 8 | ||||
-rw-r--r-- | ext/socket/rubysocket.h | 12 | ||||
-rw-r--r-- | ext/socket/socket.c | 18 | ||||
-rw-r--r-- | ext/socket/tcpsocket.c | 2 | ||||
-rw-r--r-- | ext/socket/udpsocket.c | 10 | ||||
-rw-r--r-- | ext/socket/unixsocket.c | 8 |
9 files changed, 47 insertions, 38 deletions
@@ -1,3 +1,14 @@ +Sun Mar 1 15:45:49 2009 Tanaka Akira <akr@fsij.org> + + * ext/socket/ (rsock_make_hostent): renamed from sock_make_hostent. + (rsock_addrinfo): renamed from sock_addrinfo. + (rsock_getaddrinfo): renamed from sock_getaddrinfo. + (rsock_socket): renamed from ruby_socket. + (rsock_sock_s_socketpair): renamed from sock_s_socketpair. + (rsock_connect): renamed from ruby_connect. + + * ext/socket/socket.c (sock_listen): make it static. + Sun Mar 1 15:29:31 2009 Tanaka Akira <akr@fsij.org> * ext/socket: add rsock_ prefix. diff --git a/ext/socket/init.c b/ext/socket/init.c index 9d550dfe29..c1caf2f87e 100644 --- a/ext/socket/init.c +++ b/ext/socket/init.c @@ -228,7 +228,7 @@ rsock_s_recvfrom_nonblock(VALUE sock, int argc, VALUE *argv, enum sock_recv_type } int -ruby_socket(int domain, int type, int proto) +rsock_socket(int domain, int type, int proto) { int fd; @@ -353,7 +353,7 @@ socks_connect_blocking(void *data) #endif int -ruby_connect(int fd, const struct sockaddr *sockaddr, int len, int socks) +rsock_connect(int fd, const struct sockaddr *sockaddr, int len, int socks) { int status; rb_blocking_function_t *func = connect_blocking; diff --git a/ext/socket/ipsocket.c b/ext/socket/ipsocket.c index 23b87f4ae3..78c85766ee 100644 --- a/ext/socket/ipsocket.c +++ b/ext/socket/ipsocket.c @@ -46,19 +46,19 @@ init_inetsock_internal(struct inetsock_arg *arg) int fd, status = 0; const char *syscall = 0; - arg->remote.res = sock_addrinfo(arg->remote.host, arg->remote.serv, SOCK_STREAM, + arg->remote.res = rsock_addrinfo(arg->remote.host, arg->remote.serv, SOCK_STREAM, (type == INET_SERVER) ? AI_PASSIVE : 0); /* * Maybe also accept a local address */ if (type != INET_SERVER && (!NIL_P(arg->local.host) || !NIL_P(arg->local.serv))) { - arg->local.res = sock_addrinfo(arg->local.host, arg->local.serv, SOCK_STREAM, 0); + arg->local.res = rsock_addrinfo(arg->local.host, arg->local.serv, SOCK_STREAM, 0); } arg->fd = fd = -1; for (res = arg->remote.res; res; res = res->ai_next) { - status = ruby_socket(res->ai_family,res->ai_socktype,res->ai_protocol); + status = rsock_socket(res->ai_family,res->ai_socktype,res->ai_protocol); syscall = "socket(2)"; fd = status; if (fd < 0) { @@ -81,8 +81,8 @@ init_inetsock_internal(struct inetsock_arg *arg) } if (status >= 0) { - status = ruby_connect(fd, res->ai_addr, res->ai_addrlen, - (type == INET_SOCKS)); + status = rsock_connect(fd, res->ai_addr, res->ai_addrlen, + (type == INET_SOCKS)); syscall = "connect(2)"; } } @@ -223,7 +223,7 @@ static VALUE ip_s_getaddress(VALUE obj, VALUE host) { struct sockaddr_storage addr; - struct addrinfo *res = sock_addrinfo(host, Qnil, SOCK_STREAM, 0); + struct addrinfo *res = rsock_addrinfo(host, Qnil, SOCK_STREAM, 0); /* just take the first one */ memcpy(&addr, res->ai_addr, res->ai_addrlen); diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c index b73feb3db4..1281d87cc8 100644 --- a/ext/socket/raddrinfo.c +++ b/ext/socket/raddrinfo.c @@ -291,7 +291,7 @@ port_str(VALUE port, char *pbuf, size_t len, int *flags_ptr) } struct addrinfo* -sock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack) +rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack) { struct addrinfo* res = NULL; char *hostp, *portp; @@ -337,7 +337,7 @@ sock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_ha } struct addrinfo* -sock_addrinfo(VALUE host, VALUE port, int socktype, int flags) +rsock_addrinfo(VALUE host, VALUE port, int socktype, int flags) { struct addrinfo hints; @@ -345,7 +345,7 @@ sock_addrinfo(VALUE host, VALUE port, int socktype, int flags) hints.ai_family = AF_UNSPEC; hints.ai_socktype = socktype; hints.ai_flags = flags; - return sock_getaddrinfo(host, port, &hints, 1); + return rsock_getaddrinfo(host, port, &hints, 1); } VALUE @@ -583,7 +583,7 @@ call_getaddrinfo(VALUE node, VALUE service, if (!NIL_P(flags)) { hints.ai_flags = NUM2INT(flags); } - res = sock_getaddrinfo(node, service, &hints, socktype_hack); + res = rsock_getaddrinfo(node, service, &hints, socktype_hack); if (res == NULL) rb_raise(rb_eSocket, "host not found"); diff --git a/ext/socket/rubysocket.h b/ext/socket/rubysocket.h index cba6121874..6a71c45b35 100644 --- a/ext/socket/rubysocket.h +++ b/ext/socket/rubysocket.h @@ -207,8 +207,8 @@ int rb_sock_getfamily(int sockfd); int rb_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res); int rb_getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags); -struct addrinfo *sock_addrinfo(VALUE host, VALUE port, int socktype, int flags); -struct addrinfo *sock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack); +struct addrinfo *rsock_addrinfo(VALUE host, VALUE port, int socktype, int flags); +struct addrinfo *rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack); VALUE rsock_fd_socket_addrinfo(int fd, struct sockaddr *addr, socklen_t len); VALUE rsock_io_socket_addrinfo(VALUE io, struct sockaddr *addr, socklen_t len); @@ -223,9 +223,9 @@ const char* rsock_unixpath(struct sockaddr_un *sockaddr, socklen_t len); VALUE rsock_unixaddr(struct sockaddr_un *sockaddr, socklen_t len); #endif -int ruby_socket(int domain, int type, int proto); +int rsock_socket(int domain, int type, int proto); VALUE rsock_init_sock(VALUE sock, int fd); -VALUE sock_s_socketpair(int argc, VALUE *argv, VALUE klass); +VALUE rsock_sock_s_socketpair(int argc, VALUE *argv, VALUE klass); VALUE rsock_init_inetsock(VALUE sock, VALUE remote_host, VALUE remote_serv, VALUE local_host, VALUE local_serv, int type); VALUE rsock_init_unixsock(VALUE sock, VALUE path, int server); @@ -250,9 +250,7 @@ enum sock_recv_type { VALUE rsock_s_recvfrom_nonblock(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from); VALUE rsock_s_recvfrom(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from); -int ruby_connect(int fd, const struct sockaddr *sockaddr, int len, int socks); - -VALUE sock_listen(VALUE sock, VALUE log); +int rsock_connect(int fd, const struct sockaddr *sockaddr, int len, int socks); VALUE rsock_s_accept(VALUE klass, int fd, struct sockaddr *sockaddr, socklen_t *len); VALUE rsock_s_accept_nonblock(VALUE klass, rb_io_t *fptr, struct sockaddr *sockaddr, socklen_t *len); diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 44b34c31c1..c1a2beb2c1 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -49,7 +49,7 @@ sock_initialize(int argc, VALUE *argv, VALUE sock) rb_secure(3); setup_domain_and_type(domain, &d, type, &t); - fd = ruby_socket(d, t, NUM2INT(protocol)); + fd = rsock_socket(d, t, NUM2INT(protocol)); if (fd < 0) rb_sys_fail("socket(2)"); return rsock_init_sock(sock, fd); @@ -97,7 +97,7 @@ pair_yield(VALUE pair) * */ VALUE -sock_s_socketpair(int argc, VALUE *argv, VALUE klass) +rsock_sock_s_socketpair(int argc, VALUE *argv, VALUE klass) { #if defined HAVE_SOCKETPAIR VALUE domain, type, protocol; @@ -253,7 +253,7 @@ sock_connect(VALUE sock, VALUE addr) addr = rb_str_new4(addr); GetOpenFile(sock, fptr); fd = fptr->fd; - n = ruby_connect(fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_LEN(addr), 0); + n = rsock_connect(fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_LEN(addr), 0); if (n < 0) { rb_sys_fail("connect(2)"); } @@ -481,7 +481,7 @@ sock_bind(VALUE sock, VALUE addr) * * listen manual pages on unix-based systems * * listen function in Microsoft's Winsock functions reference */ -VALUE +static VALUE sock_listen(VALUE sock, VALUE log) { rb_io_t *fptr; @@ -922,7 +922,7 @@ static VALUE sock_s_gethostbyname(VALUE obj, VALUE host) { rb_secure(3); - return rsock_make_hostent(host, sock_addrinfo(host, Qnil, SOCK_STREAM, AI_CANONNAME), sock_sockaddr); + return rsock_make_hostent(host, rsock_addrinfo(host, Qnil, SOCK_STREAM, AI_CANONNAME), sock_sockaddr); } /* @@ -1105,7 +1105,7 @@ sock_s_getaddrinfo(int argc, VALUE *argv) if (!NIL_P(flags)) { hints.ai_flags = NUM2INT(flags); } - res = sock_getaddrinfo(host, port, &hints, 0); + res = rsock_getaddrinfo(host, port, &hints, 0); ret = make_addrinfo(res); freeaddrinfo(res); @@ -1274,7 +1274,7 @@ sock_s_getnameinfo(int argc, VALUE *argv) static VALUE sock_s_pack_sockaddr_in(VALUE self, VALUE port, VALUE host) { - struct addrinfo *res = sock_addrinfo(host, port, 0, 0); + struct addrinfo *res = rsock_addrinfo(host, port, 0, 0); VALUE addr = rb_str_new((char*)res->ai_addr, res->ai_addrlen); freeaddrinfo(res); @@ -1787,8 +1787,8 @@ Init_socket() rb_define_method(rb_cSocket, "recvfrom", sock_recvfrom, -1); rb_define_method(rb_cSocket, "recvfrom_nonblock", sock_recvfrom_nonblock, -1); - rb_define_singleton_method(rb_cSocket, "socketpair", sock_s_socketpair, -1); - rb_define_singleton_method(rb_cSocket, "pair", sock_s_socketpair, -1); + rb_define_singleton_method(rb_cSocket, "socketpair", rsock_sock_s_socketpair, -1); + rb_define_singleton_method(rb_cSocket, "pair", rsock_sock_s_socketpair, -1); rb_define_singleton_method(rb_cSocket, "gethostname", sock_gethostname, 0); rb_define_singleton_method(rb_cSocket, "gethostbyname", sock_s_gethostbyname, 1); rb_define_singleton_method(rb_cSocket, "gethostbyaddr", sock_s_gethostbyaddr, -1); diff --git a/ext/socket/tcpsocket.c b/ext/socket/tcpsocket.c index 97ec90335f..1ab62459d1 100644 --- a/ext/socket/tcpsocket.c +++ b/ext/socket/tcpsocket.c @@ -51,7 +51,7 @@ static VALUE tcp_s_gethostbyname(VALUE obj, VALUE host) { rb_secure(3); - return rsock_make_hostent(host, sock_addrinfo(host, Qnil, SOCK_STREAM, AI_CANONNAME), + return rsock_make_hostent(host, rsock_addrinfo(host, Qnil, SOCK_STREAM, AI_CANONNAME), tcp_sockaddr); } diff --git a/ext/socket/udpsocket.c b/ext/socket/udpsocket.c index e238353ef0..2463c8325f 100644 --- a/ext/socket/udpsocket.c +++ b/ext/socket/udpsocket.c @@ -34,7 +34,7 @@ udp_init(int argc, VALUE *argv, VALUE sock) if (rb_scan_args(argc, argv, "01", &arg) == 1) { family = rsock_family_arg(arg); } - fd = ruby_socket(family, SOCK_DGRAM, 0); + fd = rsock_socket(family, SOCK_DGRAM, 0); if (fd < 0) { rb_sys_fail("socket(2) - udp"); } @@ -55,7 +55,7 @@ udp_connect_internal(struct udp_arg *arg) struct addrinfo *res; for (res = arg->res; res; res = res->ai_next) { - if (ruby_connect(fd, res->ai_addr, res->ai_addrlen, 0) >= 0) { + if (rsock_connect(fd, res->ai_addr, res->ai_addrlen, 0) >= 0) { return Qtrue; } } @@ -86,7 +86,7 @@ udp_connect(VALUE sock, VALUE host, VALUE port) VALUE ret; rb_secure(3); - arg.res = sock_addrinfo(host, port, SOCK_DGRAM, 0); + arg.res = rsock_addrinfo(host, port, SOCK_DGRAM, 0); GetOpenFile(sock, fptr); arg.fd = fptr->fd; ret = rb_ensure(udp_connect_internal, (VALUE)&arg, @@ -114,7 +114,7 @@ udp_bind(VALUE sock, VALUE host, VALUE port) struct addrinfo *res0, *res; rb_secure(3); - res0 = sock_addrinfo(host, port, SOCK_DGRAM, 0); + res0 = rsock_addrinfo(host, port, SOCK_DGRAM, 0); GetOpenFile(sock, fptr); for (res = res0; res; res = res->ai_next) { if (bind(fptr->fd, res->ai_addr, res->ai_addrlen) < 0) { @@ -166,7 +166,7 @@ udp_send(int argc, VALUE *argv, VALUE sock) rb_scan_args(argc, argv, "4", &arg.mesg, &flags, &host, &port); StringValue(arg.mesg); - res0 = sock_addrinfo(host, port, SOCK_DGRAM, 0); + res0 = rsock_addrinfo(host, port, SOCK_DGRAM, 0); GetOpenFile(sock, fptr); arg.fd = fptr->fd; arg.flags = NUM2INT(flags); diff --git a/ext/socket/unixsocket.c b/ext/socket/unixsocket.c index 0e0aff8ba2..79e4d6ee76 100644 --- a/ext/socket/unixsocket.c +++ b/ext/socket/unixsocket.c @@ -19,8 +19,8 @@ struct unixsock_arg { static VALUE unixsock_connect_internal(struct unixsock_arg *arg) { - return (VALUE)ruby_connect(arg->fd, (struct sockaddr*)arg->sockaddr, - sizeof(*arg->sockaddr), 0); + return (VALUE)rsock_connect(arg->fd, (struct sockaddr*)arg->sockaddr, + sizeof(*arg->sockaddr), 0); } VALUE @@ -31,7 +31,7 @@ rsock_init_unixsock(VALUE sock, VALUE path, int server) rb_io_t *fptr; SafeStringValue(path); - fd = ruby_socket(AF_UNIX, SOCK_STREAM, 0); + fd = rsock_socket(AF_UNIX, SOCK_STREAM, 0); if (fd < 0) { rb_sys_fail("socket(2)"); } @@ -482,7 +482,7 @@ unix_s_socketpair(int argc, VALUE *argv, VALUE klass) args[1] = type; args[2] = protocol; - return sock_s_socketpair(3, args, klass); + return rsock_sock_s_socketpair(3, args, klass); } #endif |