aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-11-24 07:34:42 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-11-24 07:34:42 +0000
commit00d8417631b1ae378d708e885dce74bafb02be96 (patch)
treee0537629e52b86a992f5e3abc45362bc07e620bb /networking
parent4b5709496bb00301f4df6a8e3c0ced23b4d36603 (diff)
downloadbusybox-w32-00d8417631b1ae378d708e885dce74bafb02be96.tar.gz
busybox-w32-00d8417631b1ae378d708e885dce74bafb02be96.tar.bz2
busybox-w32-00d8417631b1ae378d708e885dce74bafb02be96.zip
vi: speedup and code shrink (Walter Harms)
networking/interface.c: silence warning (Vladimir) wget: more robust EINTR detection
Diffstat (limited to 'networking')
-rw-r--r--networking/interface.c2
-rw-r--r--networking/wget.c26
2 files changed, 15 insertions, 13 deletions
diff --git a/networking/interface.c b/networking/interface.c
index b09148b27..00174d496 100644
--- a/networking/interface.c
+++ b/networking/interface.c
@@ -990,7 +990,7 @@ static void ife_print6(struct interface *ptr)
990 fclose(f); 990 fclose(f);
991} 991}
992#else 992#else
993static void ife_print6(struct interface *ptr) {} 993#define ife_print6(a) ((void)0)
994#endif 994#endif
995 995
996 996
diff --git a/networking/wget.c b/networking/wget.c
index d782cc4fe..3f80d615e 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -54,14 +54,14 @@ enum {
54 STALLTIME = 5 /* Seconds when xfer considered "stalled" */ 54 STALLTIME = 5 /* Seconds when xfer considered "stalled" */
55}; 55};
56 56
57static unsigned int getttywidth(void) 57static unsigned int get_tty2_width(void)
58{ 58{
59 unsigned width; 59 unsigned width;
60 get_terminal_width_height(0, &width, NULL); 60 get_terminal_width_height(2, &width, NULL);
61 return width; 61 return width;
62} 62}
63 63
64static void progressmeter(int flag) 64static void progress_meter(int flag)
65{ 65{
66 /* We can be called from signal handler */ 66 /* We can be called from signal handler */
67 int save_errno = errno; 67 int save_errno = errno;
@@ -70,7 +70,7 @@ static void progressmeter(int flag)
70 unsigned ratio; 70 unsigned ratio;
71 int barlength, i; 71 int barlength, i;
72 72
73 if (flag == -1) { /* first call to progressmeter */ 73 if (flag == -1) { /* first call to progress_meter */
74 start_sec = monotonic_sec(); 74 start_sec = monotonic_sec();
75 lastupdate_sec = start_sec; 75 lastupdate_sec = start_sec;
76 lastsize = 0; 76 lastsize = 0;
@@ -86,7 +86,7 @@ static void progressmeter(int flag)
86 86
87 fprintf(stderr, "\r%-20.20s%4d%% ", curfile, ratio); 87 fprintf(stderr, "\r%-20.20s%4d%% ", curfile, ratio);
88 88
89 barlength = getttywidth() - 49; 89 barlength = get_tty2_width() - 49;
90 if (barlength > 0) { 90 if (barlength > 0) {
91 /* god bless gcc for variable arrays :) */ 91 /* god bless gcc for variable arrays :) */
92 i = barlength * ratio / 100; 92 i = barlength * ratio / 100;
@@ -138,13 +138,13 @@ static void progressmeter(int flag)
138 } 138 }
139 139
140 if (flag == 0) { 140 if (flag == 0) {
141 /* last call to progressmeter */ 141 /* last call to progress_meter */
142 alarm(0); 142 alarm(0);
143 transferred = 0; 143 transferred = 0;
144 fputc('\n', stderr); 144 fputc('\n', stderr);
145 } else { 145 } else {
146 if (flag == -1) { /* first call to progressmeter */ 146 if (flag == -1) { /* first call to progress_meter */
147 signal_SA_RESTART_empty_mask(SIGALRM, progressmeter); 147 signal_SA_RESTART_empty_mask(SIGALRM, progress_meter);
148 } 148 }
149 alarm(1); 149 alarm(1);
150 } 150 }
@@ -188,7 +188,7 @@ static void progressmeter(int flag)
188 */ 188 */
189#else /* FEATURE_WGET_STATUSBAR */ 189#else /* FEATURE_WGET_STATUSBAR */
190 190
191static ALWAYS_INLINE void progressmeter(int flag UNUSED_PARAM) { } 191static ALWAYS_INLINE void progress_meter(int flag UNUSED_PARAM) { }
192 192
193#endif 193#endif
194 194
@@ -202,6 +202,7 @@ static size_t safe_fread(void *ptr, size_t nmemb, FILE *stream)
202 202
203 do { 203 do {
204 clearerr(stream); 204 clearerr(stream);
205 errno = 0;
205 ret = fread(p, 1, nmemb, stream); 206 ret = fread(p, 1, nmemb, stream);
206 p += ret; 207 p += ret;
207 nmemb -= ret; 208 nmemb -= ret;
@@ -218,6 +219,7 @@ static char *safe_fgets(char *s, int size, FILE *stream)
218 219
219 do { 220 do {
220 clearerr(stream); 221 clearerr(stream);
222 errno = 0;
221 ret = fgets(s, size, stream); 223 ret = fgets(s, size, stream);
222 } while (ret == NULL && ferror(stream) && errno == EINTR); 224 } while (ret == NULL && ferror(stream) && errno == EINTR);
223 225
@@ -765,7 +767,7 @@ However, in real world it was observed that some web servers
765 * Retrieve file 767 * Retrieve file
766 */ 768 */
767 769
768 /* Do it before progressmeter (want to have nice error message) */ 770 /* Do it before progress_meter (want to have nice error message) */
769 if (output_fd < 0) { 771 if (output_fd < 0) {
770 int o_flags = O_WRONLY | O_CREAT | O_TRUNC | O_EXCL; 772 int o_flags = O_WRONLY | O_CREAT | O_TRUNC | O_EXCL;
771 /* compat with wget: -O FILE can overwrite */ 773 /* compat with wget: -O FILE can overwrite */
@@ -775,7 +777,7 @@ However, in real world it was observed that some web servers
775 } 777 }
776 778
777 if (!(opt & WGET_OPT_QUIET)) 779 if (!(opt & WGET_OPT_QUIET))
778 progressmeter(-1); 780 progress_meter(-1);
779 781
780 if (chunked) 782 if (chunked)
781 goto get_clen; 783 goto get_clen;
@@ -817,7 +819,7 @@ However, in real world it was observed that some web servers
817 } 819 }
818 820
819 if (!(opt & WGET_OPT_QUIET)) 821 if (!(opt & WGET_OPT_QUIET))
820 progressmeter(0); 822 progress_meter(0);
821 823
822 if ((use_proxy == 0) && target.is_ftp) { 824 if ((use_proxy == 0) && target.is_ftp) {
823 fclose(dfp); 825 fclose(dfp);