svn commit: trunk/busybox/networking

vda at busybox.net vda at busybox.net
Sat Sep 9 12:20:57 UTC 2006


Author: vda
Date: 2006-09-09 05:20:57 -0700 (Sat, 09 Sep 2006)
New Revision: 16080

Log:
wget: wrap one atrociously long line (around 200 chars long!).



Modified:
   trunk/busybox/networking/wget.c


Changeset:
Modified: trunk/busybox/networking/wget.c
===================================================================
--- trunk/busybox/networking/wget.c	2006-09-09 12:18:46 UTC (rev 16079)
+++ trunk/busybox/networking/wget.c	2006-09-09 12:20:57 UTC (rev 16080)
@@ -41,7 +41,7 @@
 
 static void close_and_delete_outfile(FILE* output, char *fname_out, int do_continue)
 {
-	if (output != stdout && do_continue==0) {
+	if (output != stdout && do_continue == 0) {
 		fclose(output);
 		unlink(fname_out);
 	}
@@ -100,8 +100,8 @@
 /*
  *  Base64-encode character string and return the string.
  */
-static char *base64enc(unsigned char *p, char *buf, int len) {
-
+static char *base64enc(unsigned char *p, char *buf, int len)
+{
 	bb_uuencode(p, buf, len, bb_uuenc_tbl_base64);
 	return buf;
 }
@@ -182,7 +182,8 @@
 		while (headers_llist) {
 			int arglen = strlen(headers_llist->data);
 			if (extra_headers_left - arglen - 2 <= 0)
-				bb_error_msg_and_die("extra_headers buffer too small(need %i)", extra_headers_left - arglen);
+				bb_error_msg_and_die("extra_headers buffer too small "
+					"(need %i)", extra_headers_left - arglen);
 			strcpy(extra_headers_ptr, headers_llist->data);
 			extra_headers_ptr += arglen;
 			extra_headers_left -= ( arglen + 2 );
@@ -213,14 +214,14 @@
 	if (!fname_out) {
 		// Dirty hack. Needed because bb_get_last_path_component
 		// will destroy trailing / by storing '\0' in last byte!
-		if(*target.path && target.path[strlen(target.path)-1]!='/') {
+		if (*target.path && target.path[strlen(target.path)-1] != '/') {
 			fname_out =
 #ifdef CONFIG_FEATURE_WGET_STATUSBAR
 				curfile =
 #endif
 				bb_get_last_path_component(target.path);
 		}
-		if (fname_out==NULL || strlen(fname_out)<1) {
+		if (fname_out == NULL || strlen(fname_out) < 1) {
 			fname_out =
 #ifdef CONFIG_FEATURE_WGET_STATUSBAR
 				curfile =
@@ -253,7 +254,7 @@
 	 */
 	if (do_continue) {
 		if (fstat(fileno(output), &sbuf) < 0)
-			bb_perror_msg_and_die("fstat()");
+			bb_perror_msg_and_die("fstat");
 		if (sbuf.st_size > 0)
 			beg_range = sbuf.st_size;
 		else
@@ -265,8 +266,8 @@
 	 * and we want to connect to only one IP... */
 	bb_lookup_host(&s_in, server.host);
 	s_in.sin_port = server.port;
-	if (quiet_flag==FALSE) {
-		fprintf(stdout, "Connecting to %s[%s]:%d\n",
+	if (quiet_flag == FALSE) {
+		printf("Connecting to %s[%s]:%d\n",
 				server.host, inet_ntoa(s_in.sin_addr), ntohs(server.port));
 	}
 
@@ -277,7 +278,7 @@
 		do {
 			got_clen = chunked = 0;
 
-			if (! --try)
+			if (!--try)
 				close_delete_and_die("too many redirections");
 
 			/*
@@ -401,7 +402,7 @@
 		/*
 		 *  FTP session
 		 */
-		if (! target.user)
+		if (!target.user)
 			target.user = xstrdup("anonymous:busybox@");
 
 		sfp = open_socket(&s_in);
@@ -476,11 +477,17 @@
 		filesize = strtol(buf, (char **) NULL, 16);
 	}
 
-	if (quiet_flag==FALSE)
+	if (quiet_flag == FALSE)
 		progressmeter(-1);
 
 	do {
-		while ((filesize > 0 || !got_clen) && (n = safe_fread(buf, 1, ((chunked || got_clen) && (filesize < sizeof(buf)) ? filesize : sizeof(buf)), dfp)) > 0) {
+		while (filesize > 0 || !got_clen) {
+			unsigned rdsz = sizeof(buf);
+			if (filesize < sizeof(buf) && (chunked || got_clen)) 
+				rdsz = filesize;
+			n = safe_fread(buf, 1, rdsz, dfp);
+			if (n <= 0)
+				break;
 			if (safe_fwrite(buf, 1, n, output) != n) {
 				bb_perror_msg_and_die(bb_msg_write_error);
 			}
@@ -496,7 +503,7 @@
 			safe_fgets(buf, sizeof(buf), dfp); /* This is a newline */
 			safe_fgets(buf, sizeof(buf), dfp);
 			filesize = strtol(buf, (char **) NULL, 16);
-			if (filesize==0) {
+			if (filesize == 0) {
 				chunked = 0; /* all done! */
 			}
 		}
@@ -506,7 +513,7 @@
 		}
 	} while (chunked);
 
-	if (quiet_flag==FALSE)
+	if (quiet_flag == FALSE)
 		progressmeter(1);
 
 	if ((use_proxy == 0) && target.is_ftp) {
@@ -580,7 +587,7 @@
 
 	fp = fdopen(xconnect(s_in), "r+");
 	if (fp == NULL)
-		bb_perror_msg_and_die("fdopen()");
+		bb_perror_msg_and_die("fdopen");
 
 	return fp;
 }
@@ -645,13 +652,13 @@
 		char *buf_ptr;
 
 		if (fgets(buf, 510, fp) == NULL) {
-			bb_perror_msg_and_die("fgets()");
+			bb_perror_msg_and_die("fgets");
 		}
 		buf_ptr = strstr(buf, "\r\n");
 		if (buf_ptr) {
 			*buf_ptr = '\0';
 		}
-	} while (! isdigit(buf[0]) || buf[3] != ' ');
+	} while (!isdigit(buf[0]) || buf[3] != ' ');
 
 	return atoi(buf);
 }




More information about the busybox-cvs mailing list