aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2000-10-25 16:25:50 +0000
committerMatt Kraai <kraai@debian.org>2000-10-25 16:25:50 +0000
commit97d26125665756acd40b8b7360f943b33a371791 (patch)
tree6fe4e4d19b5270afe0f5c0f11909b87f0b7fe230
parent324a778f31ac99f2c9d947a99dc4c37902bde6fe (diff)
downloadbusybox-w32-97d26125665756acd40b8b7360f943b33a371791.tar.gz
busybox-w32-97d26125665756acd40b8b7360f943b33a371791.tar.bz2
busybox-w32-97d26125665756acd40b8b7360f943b33a371791.zip
Cleaned up error message handling.
-rw-r--r--networking/wget.c32
-rw-r--r--wget.c32
2 files changed, 32 insertions, 32 deletions
diff --git a/networking/wget.c b/networking/wget.c
index 02adc5520..daa73240b 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -98,7 +98,7 @@ int wget_main(int argc, char **argv)
98 98
99 99
100 if (do_continue && !fname_out) 100 if (do_continue && !fname_out)
101 fatalError("wget: cannot specify continue (-c) without a filename (-O)\n"); 101 fatalError("cannot specify continue (-c) without a filename (-O)\n");
102 /* 102 /*
103 * Parse url into components. 103 * Parse url into components.
104 */ 104 */
@@ -115,7 +115,7 @@ int wget_main(int argc, char **argv)
115 if (fname_out != NULL) { 115 if (fname_out != NULL) {
116 if ( (output=fopen(fname_out, (do_continue ? "a" : "w"))) 116 if ( (output=fopen(fname_out, (do_continue ? "a" : "w")))
117 == NULL) 117 == NULL)
118 fatalError("wget: freopen(%s): %s\n", fname_out, strerror(errno)); 118 fatalPerror("fopen(%s)", fname_out);
119 } else { 119 } else {
120 output=stdout; 120 output=stdout;
121 } 121 }
@@ -126,7 +126,7 @@ int wget_main(int argc, char **argv)
126 if (do_continue) { 126 if (do_continue) {
127 struct stat sbuf; 127 struct stat sbuf;
128 if (fstat(fileno(output), &sbuf) < 0) 128 if (fstat(fileno(output), &sbuf) < 0)
129 fatalError("wget: fstat(): %s\n", strerror(errno)); 129 fatalError("fstat()");
130 if (sbuf.st_size > 0) 130 if (sbuf.st_size > 0)
131 beg_range = sbuf.st_size; 131 beg_range = sbuf.st_size;
132 else 132 else
@@ -145,7 +145,7 @@ int wget_main(int argc, char **argv)
145 * Retrieve HTTP response line and check for "200" status code. 145 * Retrieve HTTP response line and check for "200" status code.
146 */ 146 */
147 if (fgets(buf, sizeof(buf), sfp) == NULL) 147 if (fgets(buf, sizeof(buf), sfp) == NULL)
148 fatalError("wget: no response from server\n"); 148 fatalError("no response from server\n");
149 for (s = buf ; *s != '\0' && !isspace(*s) ; ++s) 149 for (s = buf ; *s != '\0' && !isspace(*s) ; ++s)
150 ; 150 ;
151 for ( ; isspace(*s) ; ++s) 151 for ( ; isspace(*s) ; ++s)
@@ -154,13 +154,13 @@ int wget_main(int argc, char **argv)
154 case 200: 154 case 200:
155 if (!do_continue) 155 if (!do_continue)
156 break; 156 break;
157 fatalError("wget: server does not support ranges\n"); 157 fatalError("server does not support ranges\n");
158 case 206: 158 case 206:
159 if (do_continue) 159 if (do_continue)
160 break; 160 break;
161 /*FALLTHRU*/ 161 /*FALLTHRU*/
162 default: 162 default:
163 fatalError("wget: server returned error: %s", buf); 163 fatalError("server returned error: %s", buf);
164 } 164 }
165 165
166 /* 166 /*
@@ -173,7 +173,7 @@ int wget_main(int argc, char **argv)
173 continue; 173 continue;
174 } 174 }
175 if (strcmp(buf, "transfer-encoding") == 0) { 175 if (strcmp(buf, "transfer-encoding") == 0) {
176 fatalError("wget: server wants to do %s transfer encoding\n", s); 176 fatalError("server wants to do %s transfer encoding\n", s);
177 continue; 177 continue;
178 } 178 }
179 } 179 }
@@ -195,7 +195,7 @@ int wget_main(int argc, char **argv)
195 filesize -= n; 195 filesize -= n;
196 } 196 }
197 if (n == 0 && ferror(sfp)) 197 if (n == 0 && ferror(sfp))
198 fatalError("wget: network read error: %s", strerror(errno)); 198 fatalPerror("network read error");
199 199
200 exit(0); 200 exit(0);
201} 201}
@@ -208,12 +208,12 @@ void parse_url(char *url, char **uri_host, int *uri_port, char **uri_path)
208 *uri_port = 80; 208 *uri_port = 80;
209 209
210 if (strncmp(url, "http://", 7) != 0) 210 if (strncmp(url, "http://", 7) != 0)
211 fatalError("wget: not an http url: %s\n", url); 211 fatalError("not an http url: %s\n", url);
212 212
213 /* pull the host portion to the front of the buffer */ 213 /* pull the host portion to the front of the buffer */
214 for (s = url, h = url+7 ; *h != '/' ; ++h) { 214 for (s = url, h = url+7 ; *h != '/' ; ++h) {
215 if (*h == '\0') 215 if (*h == '\0')
216 fatalError("wget: cannot parse url: %s\n", url); 216 fatalError("cannot parse url: %s\n", url);
217 if (*h == ':') { 217 if (*h == ':') {
218 *uri_port = atoi(h+1); 218 *uri_port = atoi(h+1);
219 *h = '\0'; 219 *h = '\0';
@@ -236,7 +236,7 @@ FILE *open_socket(char *host, int port)
236 memzero(&sin, sizeof(sin)); 236 memzero(&sin, sizeof(sin));
237 sin.sin_family = AF_INET; 237 sin.sin_family = AF_INET;
238 if ((hp = (struct hostent *) gethostbyname(host)) == NULL) 238 if ((hp = (struct hostent *) gethostbyname(host)) == NULL)
239 fatalError("wget: cannot resolve %s\n", host); 239 fatalError("cannot resolve %s\n", host);
240 memcpy(&sin.sin_addr, hp->h_addr_list[0], hp->h_length); 240 memcpy(&sin.sin_addr, hp->h_addr_list[0], hp->h_length);
241 sin.sin_port = htons(port); 241 sin.sin_port = htons(port);
242 242
@@ -244,11 +244,11 @@ FILE *open_socket(char *host, int port)
244 * Get the server onto a stdio stream. 244 * Get the server onto a stdio stream.
245 */ 245 */
246 if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) 246 if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
247 fatalError("wget: socket(): %s\n", strerror(errno)); 247 fatalPerror("socket()");
248 if (connect(fd, (struct sockaddr *) &sin, sizeof(sin)) < 0) 248 if (connect(fd, (struct sockaddr *) &sin, sizeof(sin)) < 0)
249 fatalError("wget: connect(%s): %s\n", host, strerror(errno)); 249 fatalPerror("connect(%s)", host);
250 if ((fp = fdopen(fd, "r+")) == NULL) 250 if ((fp = fdopen(fd, "r+")) == NULL)
251 fatalError("wget: fdopen(): %s\n", strerror(errno)); 251 fatalPerror("fdopen()");
252 252
253 return fp; 253 return fp;
254} 254}
@@ -277,7 +277,7 @@ char *gethdr(char *buf, size_t bufsiz, FILE *fp, int *istrunc)
277 277
278 /* verify we are at the end of the header name */ 278 /* verify we are at the end of the header name */
279 if (*s != ':') 279 if (*s != ':')
280 fatalError("wget: bad header line: %s\n", buf); 280 fatalError("bad header line: %s\n", buf);
281 281
282 /* locate the start of the header value */ 282 /* locate the start of the header value */
283 for (*s++ = '\0' ; *s == ' ' || *s == '\t' ; ++s) 283 for (*s++ = '\0' ; *s == ' ' || *s == '\t' ; ++s)
@@ -336,7 +336,7 @@ char *gethdr(char *buf, size_t bufsiz, FILE *fp, int *istrunc)
336 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 336 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
337 * SUCH DAMAGE. 337 * SUCH DAMAGE.
338 * 338 *
339 * $Id: wget.c,v 1.5 2000/10/03 00:21:45 andersen Exp $ 339 * $Id: wget.c,v 1.6 2000/10/25 16:25:50 kraai Exp $
340 */ 340 */
341 341
342 342
diff --git a/wget.c b/wget.c
index 02adc5520..daa73240b 100644
--- a/wget.c
+++ b/wget.c
@@ -98,7 +98,7 @@ int wget_main(int argc, char **argv)
98 98
99 99
100 if (do_continue && !fname_out) 100 if (do_continue && !fname_out)
101 fatalError("wget: cannot specify continue (-c) without a filename (-O)\n"); 101 fatalError("cannot specify continue (-c) without a filename (-O)\n");
102 /* 102 /*
103 * Parse url into components. 103 * Parse url into components.
104 */ 104 */
@@ -115,7 +115,7 @@ int wget_main(int argc, char **argv)
115 if (fname_out != NULL) { 115 if (fname_out != NULL) {
116 if ( (output=fopen(fname_out, (do_continue ? "a" : "w"))) 116 if ( (output=fopen(fname_out, (do_continue ? "a" : "w")))
117 == NULL) 117 == NULL)
118 fatalError("wget: freopen(%s): %s\n", fname_out, strerror(errno)); 118 fatalPerror("fopen(%s)", fname_out);
119 } else { 119 } else {
120 output=stdout; 120 output=stdout;
121 } 121 }
@@ -126,7 +126,7 @@ int wget_main(int argc, char **argv)
126 if (do_continue) { 126 if (do_continue) {
127 struct stat sbuf; 127 struct stat sbuf;
128 if (fstat(fileno(output), &sbuf) < 0) 128 if (fstat(fileno(output), &sbuf) < 0)
129 fatalError("wget: fstat(): %s\n", strerror(errno)); 129 fatalError("fstat()");
130 if (sbuf.st_size > 0) 130 if (sbuf.st_size > 0)
131 beg_range = sbuf.st_size; 131 beg_range = sbuf.st_size;
132 else 132 else
@@ -145,7 +145,7 @@ int wget_main(int argc, char **argv)
145 * Retrieve HTTP response line and check for "200" status code. 145 * Retrieve HTTP response line and check for "200" status code.
146 */ 146 */
147 if (fgets(buf, sizeof(buf), sfp) == NULL) 147 if (fgets(buf, sizeof(buf), sfp) == NULL)
148 fatalError("wget: no response from server\n"); 148 fatalError("no response from server\n");
149 for (s = buf ; *s != '\0' && !isspace(*s) ; ++s) 149 for (s = buf ; *s != '\0' && !isspace(*s) ; ++s)
150 ; 150 ;
151 for ( ; isspace(*s) ; ++s) 151 for ( ; isspace(*s) ; ++s)
@@ -154,13 +154,13 @@ int wget_main(int argc, char **argv)
154 case 200: 154 case 200:
155 if (!do_continue) 155 if (!do_continue)
156 break; 156 break;
157 fatalError("wget: server does not support ranges\n"); 157 fatalError("server does not support ranges\n");
158 case 206: 158 case 206:
159 if (do_continue) 159 if (do_continue)
160 break; 160 break;
161 /*FALLTHRU*/ 161 /*FALLTHRU*/
162 default: 162 default:
163 fatalError("wget: server returned error: %s", buf); 163 fatalError("server returned error: %s", buf);
164 } 164 }
165 165
166 /* 166 /*
@@ -173,7 +173,7 @@ int wget_main(int argc, char **argv)
173 continue; 173 continue;
174 } 174 }
175 if (strcmp(buf, "transfer-encoding") == 0) { 175 if (strcmp(buf, "transfer-encoding") == 0) {
176 fatalError("wget: server wants to do %s transfer encoding\n", s); 176 fatalError("server wants to do %s transfer encoding\n", s);
177 continue; 177 continue;
178 } 178 }
179 } 179 }
@@ -195,7 +195,7 @@ int wget_main(int argc, char **argv)
195 filesize -= n; 195 filesize -= n;
196 } 196 }
197 if (n == 0 && ferror(sfp)) 197 if (n == 0 && ferror(sfp))
198 fatalError("wget: network read error: %s", strerror(errno)); 198 fatalPerror("network read error");
199 199
200 exit(0); 200 exit(0);
201} 201}
@@ -208,12 +208,12 @@ void parse_url(char *url, char **uri_host, int *uri_port, char **uri_path)
208 *uri_port = 80; 208 *uri_port = 80;
209 209
210 if (strncmp(url, "http://", 7) != 0) 210 if (strncmp(url, "http://", 7) != 0)
211 fatalError("wget: not an http url: %s\n", url); 211 fatalError("not an http url: %s\n", url);
212 212
213 /* pull the host portion to the front of the buffer */ 213 /* pull the host portion to the front of the buffer */
214 for (s = url, h = url+7 ; *h != '/' ; ++h) { 214 for (s = url, h = url+7 ; *h != '/' ; ++h) {
215 if (*h == '\0') 215 if (*h == '\0')
216 fatalError("wget: cannot parse url: %s\n", url); 216 fatalError("cannot parse url: %s\n", url);
217 if (*h == ':') { 217 if (*h == ':') {
218 *uri_port = atoi(h+1); 218 *uri_port = atoi(h+1);
219 *h = '\0'; 219 *h = '\0';
@@ -236,7 +236,7 @@ FILE *open_socket(char *host, int port)
236 memzero(&sin, sizeof(sin)); 236 memzero(&sin, sizeof(sin));
237 sin.sin_family = AF_INET; 237 sin.sin_family = AF_INET;
238 if ((hp = (struct hostent *) gethostbyname(host)) == NULL) 238 if ((hp = (struct hostent *) gethostbyname(host)) == NULL)
239 fatalError("wget: cannot resolve %s\n", host); 239 fatalError("cannot resolve %s\n", host);
240 memcpy(&sin.sin_addr, hp->h_addr_list[0], hp->h_length); 240 memcpy(&sin.sin_addr, hp->h_addr_list[0], hp->h_length);
241 sin.sin_port = htons(port); 241 sin.sin_port = htons(port);
242 242
@@ -244,11 +244,11 @@ FILE *open_socket(char *host, int port)
244 * Get the server onto a stdio stream. 244 * Get the server onto a stdio stream.
245 */ 245 */
246 if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) 246 if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
247 fatalError("wget: socket(): %s\n", strerror(errno)); 247 fatalPerror("socket()");
248 if (connect(fd, (struct sockaddr *) &sin, sizeof(sin)) < 0) 248 if (connect(fd, (struct sockaddr *) &sin, sizeof(sin)) < 0)
249 fatalError("wget: connect(%s): %s\n", host, strerror(errno)); 249 fatalPerror("connect(%s)", host);
250 if ((fp = fdopen(fd, "r+")) == NULL) 250 if ((fp = fdopen(fd, "r+")) == NULL)
251 fatalError("wget: fdopen(): %s\n", strerror(errno)); 251 fatalPerror("fdopen()");
252 252
253 return fp; 253 return fp;
254} 254}
@@ -277,7 +277,7 @@ char *gethdr(char *buf, size_t bufsiz, FILE *fp, int *istrunc)
277 277
278 /* verify we are at the end of the header name */ 278 /* verify we are at the end of the header name */
279 if (*s != ':') 279 if (*s != ':')
280 fatalError("wget: bad header line: %s\n", buf); 280 fatalError("bad header line: %s\n", buf);
281 281
282 /* locate the start of the header value */ 282 /* locate the start of the header value */
283 for (*s++ = '\0' ; *s == ' ' || *s == '\t' ; ++s) 283 for (*s++ = '\0' ; *s == ' ' || *s == '\t' ; ++s)
@@ -336,7 +336,7 @@ char *gethdr(char *buf, size_t bufsiz, FILE *fp, int *istrunc)
336 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 336 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
337 * SUCH DAMAGE. 337 * SUCH DAMAGE.
338 * 338 *
339 * $Id: wget.c,v 1.5 2000/10/03 00:21:45 andersen Exp $ 339 * $Id: wget.c,v 1.6 2000/10/25 16:25:50 kraai Exp $
340 */ 340 */
341 341
342 342