diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-26 01:09:46 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-26 01:09:46 +0000 |
commit | 1457915afcb8fb0697f441dce1697b278d25f4a5 (patch) | |
tree | 4f61a7fd5a6a3ebbca053c55dc68b8a3edb7700b | |
parent | 940b2e4b734e92cd6dd10c33910439478812d106 (diff) | |
download | busybox-w32-1457915afcb8fb0697f441dce1697b278d25f4a5.tar.gz busybox-w32-1457915afcb8fb0697f441dce1697b278d25f4a5.tar.bz2 busybox-w32-1457915afcb8fb0697f441dce1697b278d25f4a5.zip |
xconnect is non-conforming to "xfunc like libc" rule. Fixing
-rw-r--r-- | include/libbb.h | 4 | ||||
-rw-r--r-- | libbb/xconnect.c | 18 | ||||
-rw-r--r-- | networking/ftpgetput.c | 4 | ||||
-rw-r--r-- | networking/telnet.c | 2 | ||||
-rw-r--r-- | networking/wget.c | 2 | ||||
-rw-r--r-- | util-linux/rdate.c | 2 |
6 files changed, 20 insertions, 12 deletions
diff --git a/include/libbb.h b/include/libbb.h index 7b8327ff5..a2267f942 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -452,7 +452,9 @@ extern struct hostent *xgethostbyname(const char *name); | |||
452 | extern struct hostent *xgethostbyname2(const char *name, int af); | 452 | extern struct hostent *xgethostbyname2(const char *name, int af); |
453 | extern int create_icmp_socket(void); | 453 | extern int create_icmp_socket(void); |
454 | extern int create_icmp6_socket(void); | 454 | extern int create_icmp6_socket(void); |
455 | extern int xconnect(struct sockaddr_in *s_addr); | 455 | extern void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen); |
456 | extern int xconnect_tcp_v4(struct sockaddr_in *s_addr); | ||
457 | |||
456 | extern unsigned short bb_lookup_port(const char *port, const char *protocol, unsigned short default_port); | 458 | extern unsigned short bb_lookup_port(const char *port, const char *protocol, unsigned short default_port); |
457 | extern void bb_lookup_host(struct sockaddr_in *s_in, const char *host); | 459 | extern void bb_lookup_host(struct sockaddr_in *s_in, const char *host); |
458 | 460 | ||
diff --git a/libbb/xconnect.c b/libbb/xconnect.c index f88136a1a..7cf9d00e9 100644 --- a/libbb/xconnect.c +++ b/libbb/xconnect.c | |||
@@ -49,14 +49,20 @@ void bb_lookup_host(struct sockaddr_in *s_in, const char *host) | |||
49 | memcpy(&(s_in->sin_addr), he->h_addr_list[0], he->h_length); | 49 | memcpy(&(s_in->sin_addr), he->h_addr_list[0], he->h_length); |
50 | } | 50 | } |
51 | 51 | ||
52 | int xconnect(struct sockaddr_in *s_addr) | 52 | void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen) |
53 | { | 53 | { |
54 | int s = xsocket(AF_INET, SOCK_STREAM, 0); | 54 | if (connect(s, s_addr, addrlen) < 0) { |
55 | if (connect(s, (struct sockaddr *)s_addr, sizeof(struct sockaddr_in)) < 0) | ||
56 | { | ||
57 | if (ENABLE_FEATURE_CLEAN_UP) close(s); | 55 | if (ENABLE_FEATURE_CLEAN_UP) close(s); |
58 | bb_perror_msg_and_die("unable to connect to remote host (%s)", | 56 | if (s_addr->sa_family == AF_INET) |
59 | inet_ntoa(s_addr->sin_addr)); | 57 | bb_perror_msg_and_die("unable to connect to remote host (%s)", |
58 | inet_ntoa(((struct sockaddr_in *)s_addr)->sin_addr)); | ||
59 | bb_perror_msg_and_die("unable to connect to remote host"); | ||
60 | } | 60 | } |
61 | } | ||
62 | |||
63 | int xconnect_tcp_v4(struct sockaddr_in *s_addr) | ||
64 | { | ||
65 | int s = xsocket(AF_INET, SOCK_STREAM, 0); | ||
66 | xconnect(s, (struct sockaddr*) s_addr, sizeof(*s_addr)); | ||
61 | return s; | 67 | return s; |
62 | } | 68 | } |
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c index aafeaf6e9..6608e6830 100644 --- a/networking/ftpgetput.c +++ b/networking/ftpgetput.c | |||
@@ -67,7 +67,7 @@ static int xconnect_ftpdata(ftp_host_info_t *server, const char *buf) | |||
67 | port_num += xatoul_range(buf_ptr + 1, 0, 255) * 256; | 67 | port_num += xatoul_range(buf_ptr + 1, 0, 255) * 256; |
68 | 68 | ||
69 | server->s_in->sin_port = htons(port_num); | 69 | server->s_in->sin_port = htons(port_num); |
70 | return xconnect(server->s_in); | 70 | return xconnect_tcp_v4(server->s_in); |
71 | } | 71 | } |
72 | 72 | ||
73 | static FILE *ftp_login(ftp_host_info_t *server) | 73 | static FILE *ftp_login(ftp_host_info_t *server) |
@@ -76,7 +76,7 @@ static FILE *ftp_login(ftp_host_info_t *server) | |||
76 | char buf[512]; | 76 | char buf[512]; |
77 | 77 | ||
78 | /* Connect to the command socket */ | 78 | /* Connect to the command socket */ |
79 | control_stream = fdopen(xconnect(server->s_in), "r+"); | 79 | control_stream = fdopen(xconnect_tcp_v4(server->s_in), "r+"); |
80 | if (control_stream == NULL) { | 80 | if (control_stream == NULL) { |
81 | bb_perror_msg_and_die("cannot open control stream"); | 81 | bb_perror_msg_and_die("cannot open control stream"); |
82 | } | 82 | } |
diff --git a/networking/telnet.c b/networking/telnet.c index cd4c33a86..5b8c885e2 100644 --- a/networking/telnet.c +++ b/networking/telnet.c | |||
@@ -639,7 +639,7 @@ int telnet_main(int argc, char** argv) | |||
639 | s_in.sin_port = bb_lookup_port((argc == 3) ? argv[2] : "telnet", "tcp", 23); | 639 | s_in.sin_port = bb_lookup_port((argc == 3) ? argv[2] : "telnet", "tcp", 23); |
640 | #endif | 640 | #endif |
641 | 641 | ||
642 | G.netfd = xconnect(&s_in); | 642 | G.netfd = xconnect_tcp_v4(&s_in); |
643 | 643 | ||
644 | setsockopt(G.netfd, SOL_SOCKET, SO_KEEPALIVE, &one, sizeof one); | 644 | setsockopt(G.netfd, SOL_SOCKET, SO_KEEPALIVE, &one, sizeof one); |
645 | 645 | ||
diff --git a/networking/wget.c b/networking/wget.c index 090b58d9a..425abc13f 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
@@ -585,7 +585,7 @@ static FILE *open_socket(struct sockaddr_in *s_in) | |||
585 | { | 585 | { |
586 | FILE *fp; | 586 | FILE *fp; |
587 | 587 | ||
588 | fp = fdopen(xconnect(s_in), "r+"); | 588 | fp = fdopen(xconnect_tcp_v4(s_in), "r+"); |
589 | if (fp == NULL) | 589 | if (fp == NULL) |
590 | bb_perror_msg_and_die("fdopen"); | 590 | bb_perror_msg_and_die("fdopen"); |
591 | 591 | ||
diff --git a/util-linux/rdate.c b/util-linux/rdate.c index 6ad055434..645b0b929 100644 --- a/util-linux/rdate.c +++ b/util-linux/rdate.c | |||
@@ -42,7 +42,7 @@ static time_t askremotedate(const char *host) | |||
42 | alarm(10); | 42 | alarm(10); |
43 | signal(SIGALRM, socket_timeout); | 43 | signal(SIGALRM, socket_timeout); |
44 | 44 | ||
45 | fd = xconnect(&s_in); | 45 | fd = xconnect_tcp_v4(&s_in); |
46 | 46 | ||
47 | if (safe_read(fd, (void *)&nett, 4) != 4) /* read time from server */ | 47 | if (safe_read(fd, (void *)&nett, 4) != 4) /* read time from server */ |
48 | bb_error_msg_and_die("%s did not send the complete time", host); | 48 | bb_error_msg_and_die("%s did not send the complete time", host); |