1diff -Nur wget-1.13.4.old/src/ftp.c wget-1.13.4/src/ftp.c 2--- wget-1.13.4.old/src/ftp.c 2012-05-23 12:27:31.238505252 -0400 3+++ wget-1.13.4/src/ftp.c 2012-05-23 12:28:01.298505260 -0400 4@@ -1246,13 +1246,16 @@ 5 else 6 fp = output_stream; 7 8+ wgint tolen; 9 if (passed_expected_bytes) 10 { 11 print_length (passed_expected_bytes, restval, true); 12+ tolen = passed_expected_bytes; 13 expected_bytes = passed_expected_bytes; 14 /* for fd_read_body's progress bar */ 15 } 16 else if (expected_bytes) 17+ tolen = expected_bytes; 18 print_length (expected_bytes, restval, false); 19 20 /* Get the contents of the document. */ 21@@ -1413,6 +1416,7 @@ 22 locf = opt.output_document; 23 } 24 25+ print_stat("(CONNECTING)"); 26 /* If the output_document was given, then this check was already done and 27 the file didn't exist. Hence the !opt.output_document */ 28 if (opt.noclobber && !opt.output_document && file_exists_p (con->target)) 29@@ -1510,6 +1514,7 @@ 30 case FTPNSFOD: case FTPLOGINC: case FTPNOPASV: case CONTNOTSUPPORTED: 31 case UNLINKERR: 32 /* Fatal errors, give up. */ 33+ print_stat("(ERROR)"); 34 return err; 35 case CONSOCKERR: case CONERROR: case FTPSRVERR: case FTPRERR: 36 case WRITEFAILED: case FTPUNKNOWNTYPE: case FTPSYSERR: 37@@ -1539,6 +1544,7 @@ 38 break; 39 default: 40 /* Not as great. */ 41+ print_stat("(ERROR)"); 42 abort (); 43 } 44 tms = datetime_str (time (NULL)); 45@@ -1565,6 +1571,7 @@ 46 tms, tmrate, 47 write_to_stdout ? "" : quote (locf), 48 number_to_static_string (qtyread)); 49+ print_stat("(COMPLETED %s)",tmrate); 50 } 51 if (!opt.verbose && !opt.quiet) 52 { 53diff -Nur wget-1.13.4.old/src/http.c wget-1.13.4/src/http.c 54--- wget-1.13.4.old/src/http.c 2012-05-23 12:27:31.248505252 -0400 55+++ wget-1.13.4/src/http.c 2012-05-23 12:28:01.298505260 -0400 56@@ -2625,7 +2625,8 @@ 57 bool send_head_first = true; 58 char *file_name; 59 bool force_full_retrieve = false; 60- 61+ 62+ print_stat("(CONNECTING)"); 63 /* Assert that no value for *LOCAL_FILE was passed. */ 64 assert (local_file == NULL || *local_file == NULL); 65 66@@ -2830,6 +2831,7 @@ 67 /* Deal with you later. */ 68 break; 69 default: 70+ print_stat("(ERROR)"); 71 /* All possibilities should have been exhausted. */ 72 abort (); 73 } 74@@ -3046,6 +3048,7 @@ 75 number_to_static_string (hstat.len), 76 number_to_static_string (hstat.contlen), 77 hstat.local_file, count); 78+ print_stat("(COMPLETED %s)",tmrate); 79 } 80 ++numurls; 81 total_downloaded_bytes += hstat.rd_size; 82@@ -3145,7 +3148,8 @@ 83 if (ret == RETROK && local_file) 84 *local_file = xstrdup (hstat.local_file); 85 free_hstat (&hstat); 86- 87+ if (ret != RETROK) 88+ print_stat("(ERROR)"); 89 return ret; 90 } 91 92diff -Nur wget-1.13.4.old/src/main.c wget-1.13.4/src/main.c 93--- wget-1.13.4.old/src/main.c 2012-05-23 12:27:31.238505252 -0400 94+++ wget-1.13.4/src/main.c 2012-05-23 12:28:01.298505260 -0400 95@@ -79,6 +79,37 @@ 96 97 struct options opt; 98 99+#include <fcntl.h> 100+#include <stdarg.h> 101+#include <sys/types.h> 102+#include <sys/stat.h> 103+#include <errno.h> 104+char statfile[32]; 105+int stat_fd = -1; 106+void print_stat(char * stat,...) 107+{ 108+ va_list ap; 109+ char buf[128]; 110+ int fd,nwrite; 111+ if(stat_fd == -1){ 112+ if((fd = open(statfile,O_WRONLY|O_NONBLOCK))< 0){ 113+ printf("open error\n"); 114+ return; 115+ } 116+ stat_fd = fd; 117+ } 118+ va_start(ap,stat); 119+ vsprintf(buf,stat,ap); 120+ va_end(ap); 121+ 122+ if((nwrite = write(stat_fd,buf,strlen(buf)))<0){ 123+ if(errno == EAGAIN){ 124+ printf("fifo has not been read yeat\n"); 125+ } 126+ } 127+} 128+ 129+ 130 /* defined in version.c */ 131 extern char *version_string; 132 extern char *compilation_string; 133@@ -239,6 +270,7 @@ 134 { "parent", 0, OPT__PARENT, NULL, optional_argument }, 135 { "passive-ftp", 0, OPT_BOOLEAN, "passiveftp", -1 }, 136 { "password", 0, OPT_VALUE, "password", -1 }, 137+ { "statfile", 0, OPT_VALUE, "statfile", -1 }, 138 { "post-data", 0, OPT_VALUE, "postdata", -1 }, 139 { "post-file", 0, OPT_VALUE, "postfile", -1 }, 140 { "prefer-family", 0, OPT_VALUE, "preferfamily", -1 }, 141@@ -517,6 +549,8 @@ 142 one of IPv6, IPv4, or none.\n"), 143 #endif 144 N_("\ 145+ --statfile=PATH set both ftp and http status file path.\n"), 146+ N_("\ 147 --user=USER set both ftp and http user to USER.\n"), 148 N_("\ 149 --password=PASS set both ftp and http password to PASS.\n"), 150@@ -1010,6 +1044,11 @@ 151 switch (opt->type) 152 { 153 case OPT_VALUE: 154+ if(strcmp(opt->data,"statfile") == 0) 155+ { 156+ strcpy(statfile,optarg); 157+ break; 158+ } 159 setoptval (opt->data, optarg, opt->long_name); 160 break; 161 case OPT_BOOLEAN: 162@@ -1242,6 +1281,9 @@ 163 if (opt.background) 164 fork_to_background (); 165 #endif 166+ char cmd[32]; 167+ sprintf(cmd,"echo '%d' > %s-pid",getpid(),statfile); 168+ system(cmd); 169 170 /* Initialize progress. Have to do this after the options are 171 processed so we know where the log file is. */ 172diff -Nur wget-1.13.4.old/src/progress.c wget-1.13.4/src/progress.c 173--- wget-1.13.4.old/src/progress.c 2012-05-23 12:27:31.248505252 -0400 174+++ wget-1.13.4/src/progress.c 2012-05-23 12:28:01.298505260 -0400 175@@ -275,6 +275,7 @@ 176 { 177 const wgint ROW_BYTES = opt.dot_bytes * opt.dots_in_line; 178 179+ int dl_per = 0; 180 /* bytes_displayed is the number of bytes indicated to the user by 181 dots printed so far, includes the initially "skipped" amount */ 182 wgint bytes_displayed = dp->rows * ROW_BYTES + dp->dots * opt.dot_bytes; 183@@ -289,6 +290,7 @@ 184 been retrieved. 12.8% will round to 12% because the 13% mark 185 has not yet been reached. 100% is only shown when done. */ 186 int percentage = 100.0 * bytes_displayed / dp->total_length; 187+ dl_per = percentage; 188 logprintf (LOG_VERBOSE, "%3d%%", percentage); 189 } 190 191@@ -310,6 +312,7 @@ 192 rate >= 99.95 ? 0 : rate >= 9.995 ? 1 : 2, 193 rate, names[units]); 194 dp->last_timer_value = dltime; 195+ print_stat("(DOWNLOADING %s %4.*f%c %d%%)",number_to_static_string(dp->total_length),rate >= 99.95 ? 0 : rate >= 9.995 ? 1 : 2,rate, names[units],dl_per); 196 } 197 198 if (!last) 199@@ -329,6 +332,7 @@ 200 } 201 else 202 { 203+ //print_stat("(COMPLETED)"); 204 /* When done, print the total download time */ 205 if (dltime >= 10) 206 logprintf (LOG_VERBOSE, "=%s", 207diff -Nur wget-1.13.4.old/src/wget.h wget-1.13.4/src/wget.h 208--- wget-1.13.4.old/src/wget.h 2012-05-23 12:27:31.238505252 -0400 209+++ wget-1.13.4/src/wget.h 2012-05-23 12:28:01.298505260 -0400 210@@ -314,6 +314,8 @@ 211 0-pad the address.) */ 212 #define PTR_FORMAT(p) (int) (2 * sizeof (void *)), (unsigned long) (p) 213 214+extern char statfile[]; 215+extern void print_stat(char * stat,...); 216 extern const char *exec_name; 217 218 /* Document type ("dt") flags */ 219