diff -Naru ori/wget-LFS-20041113/src/ftp.c wget-LFS/src/ftp.c --- ori/wget-LFS-20041113/src/ftp.c 2004-09-09 23:38:49.000000000 +0300 +++ wget-LFS/src/ftp.c 2005-11-08 15:06:12.000000000 +0200 @@ -61,6 +61,12 @@ extern LARGE_INT total_downloaded_bytes; +//jack add+ +extern int Download_Test_Flag; +extern int ftp_get_file_szie; //jack20051026+ +extern long FileLength; +extern int UpdateRetry; + /* File where the "ls -al" listing will be saved. */ #define LIST_FILENAME ".listing" @@ -605,6 +611,14 @@ else /* do not CWD */ logputs (LOG_VERBOSE, _("==> CWD not required.\n")); +//jack20051026+ for download ftp file can show percentage + if ( ftp_get_file_szie == 1) + { + ftp_size (csock, u->file, len); + FileLength = *len; + } +//jack20051026 end + if ((cmd & DO_RETR) && restval && *len == 0) { if (opt.verbose) @@ -839,6 +853,8 @@ } err = ftp_retr (csock, u->file); + + /* FTPRERR, WRITEFAILED, FTPNSFOD */ switch (err) { @@ -958,7 +974,14 @@ return err; } } - + + //jack + if ( Download_Test_Flag ==1 ) + { + //printf("ftp download test flat = 1\n"); + return RETRFINISHED; + } + /* Open the file -- if output_stream is set, use it instead. */ if (!output_stream || con->cmd & DO_LIST) { @@ -984,6 +1007,7 @@ if (*len) { + FileLength = *len; logprintf (LOG_VERBOSE, _("Length: %s"), legible_off_t (*len)); if (restval) logprintf (LOG_VERBOSE, _(" [%s to go]"), legible_off_t (*len - restval)); @@ -992,6 +1016,7 @@ } else if (expected_bytes) { + FileLength = expected_bytes; logprintf (LOG_VERBOSE, _("Length: %s"), legible_off_t (expected_bytes)); if (restval) logprintf (LOG_VERBOSE, _(" [%s to go]"), @@ -1227,7 +1252,12 @@ else len = 0; err = getftp (u, &len, restval, con); - + + //jack add 040108+ + if ( UpdateRetry == 1 ) + count =0; + //jack add 040108 + if (con->csock != -1) con->st &= ~DONE_CWD; else @@ -1729,6 +1759,12 @@ res = ftp_get_listing (u, con, &start); if (res != RETROK) return res; + + //jack20040522+ for download folder test + if ( Download_Test_Flag == 1 ) + return RETROK; + //jack20040522 end + /* First: weed out that do not conform the global rules given in opt.accepts and opt.rejects. */ if (opt.accepts || opt.rejects) diff -Naru ori/wget-LFS-20041113/src/http.c wget-LFS/src/http.c --- ori/wget-LFS-20041113/src/http.c 2004-09-10 05:28:26.000000000 +0300 +++ wget-LFS/src/http.c 2005-11-08 15:06:12.000000000 +0200 @@ -82,9 +82,18 @@ # define MIN(x, y) ((x) > (y) ? (y) : (x)) #endif +//jack +extern int Download_Test_Flag; +extern long FileLength; +extern int UpdateRetry; +//jack20040719 for URL has "?" and "&" character +extern char RealFileName[256]; +extern char Search_Real_FileName; +//jack20040719 end static int cookies_loaded_p; struct cookie_jar *wget_cookie_jar; +int DownloadTestStatus = 0; //jack #define TEXTHTML_S "text/html" #define TEXTXHTML_S "application/xhtml+xml" @@ -1069,6 +1078,11 @@ int host_lookup_failed = 0; +//jack20040719+ for URL has "?" and "&" character + strcpy(RealFileName , u->url ); +// printf("URL = %s\n",u->url); +//jack20040719 end + #ifdef HAVE_SSL if (u->scheme == SCHEME_HTTPS) { @@ -1469,7 +1483,12 @@ message = NULL; statcode = response_status (resp, &message); if (!opt.server_response) + { logprintf (LOG_VERBOSE, "%2d %s\n", statcode, message ? message : ""); + //jack add for http download test + if ( statcode != 200 ) + DownloadTestStatus=1; + } else { logprintf (LOG_VERBOSE, "\n"); @@ -1682,6 +1701,8 @@ /* No need to print this output if the body won't be downloaded at all, or if the original server response is printed. */ + //jack add 031226 + FileLength = contlen; logputs (LOG_VERBOSE, _("Length: ")); if (contlen != -1) { @@ -1716,6 +1737,13 @@ return RETRFINISHED; } + //jack + if ( Download_Test_Flag == 1 ) + { + //printf("http download test flat = 1\n"); + return RETRFINISHED; + } + /* Open the local file. */ if (!output_stream) { @@ -1793,6 +1821,14 @@ struct stat st; char *dummy = NULL; + DownloadTestStatus = 0; + //jack20040719+ for URL has "?" and "&" character + if (strchr (u->url, '?')) + { + Search_Real_FileName = 1; + } + //jack20040719 end + /* This used to be done in main(), but it's a better idea to do it here so that we don't go through the hoops if we're just using FTP or whatever. */ @@ -1974,7 +2010,14 @@ /* Try fetching the document, or at least its head. */ err = gethttp (u, &hstat, dt, proxy); - + + //jack add 040108+ + if ( UpdateRetry == 1 ) + { + count =0; + } + //jack add 040108 + /* It's unfortunate that wget determines the local filename before finding out the Content-Type of the file. Barring a major restructuring of the code, we need to re-set locf here, since gethttp() may have xrealloc()d @@ -2048,6 +2091,18 @@ break; case RETRFINISHED: /* Deal with you later. */ + //jack add + if ( Download_Test_Flag == 1 ) + { + if( DownloadTestStatus == 0 ) + { + return RETROK; + } + else + { + return URLERROR; + } + } break; default: /* All possibilities should have been exhausted. */ diff -Naru ori/wget-LFS-20041113/src/log.c wget-LFS/src/log.c --- ori/wget-LFS-20041113/src/log.c 2003-11-29 20:40:00.000000000 +0200 +++ wget-LFS/src/log.c 2005-11-08 15:06:12.000000000 +0200 @@ -312,6 +312,7 @@ void logputs (enum log_options o, const char *s) { + #ifdef wget_debug FILE *fp; check_redirect_output (); @@ -326,6 +327,7 @@ logflush (); else needs_flushing = 1; + #endif } struct logvprintf_state { @@ -483,6 +485,7 @@ void logprintf (enum log_options o, const char *fmt, ...) { +#ifdef wget_debug va_list args; struct logvprintf_state lpstate; int done; @@ -500,6 +503,7 @@ va_end (args); } while (!done); +#endif } #ifdef ENABLE_DEBUG diff -Naru ori/wget-LFS-20041113/src/main.c wget-LFS/src/main.c --- ori/wget-LFS-20041113/src/main.c 2004-06-29 17:55:39.000000000 +0300 +++ wget-LFS/src/main.c 2005-11-16 14:36:34.000000000 +0200 @@ -84,6 +84,22 @@ const char *exec_name; +//jack add 031226+ +int Download_Test_Flag =0; +int ftp_get_file_szie = 0; //jack20051026+ +long FileLength=0L; +int UpdateRetry=0; + +//jack20040719+ for URL has "?" and "&" character +char RealFileName[256]; +char Search_Real_FileName=0; +//jack20040719 end + +#define update_status "/web/S_DOWN " +#define StatusOK " 0" +#define StatusFail " -1" +//jack add 031226 + /* Initialize I18N. The initialization amounts to invoking setlocale(), bindtextdomain() and textdomain(). Does nothing if NLS is disabled or missing. */ @@ -303,11 +319,11 @@ { struct cmdline_option *opt = &option_data[i]; struct option *longopt; - + if (!opt->long_name) /* The option is disabled. */ continue; - + longopt = &long_options[o++]; longopt->name = opt->long_name; longopt->val = i; @@ -316,6 +332,7 @@ *p++ = opt->short_name; optmap[opt->short_name - 32] = longopt - long_options; } + switch (opt->type) { case OPT_VALUE: @@ -647,7 +664,58 @@ int i, ret, longindex; int nurl, status; int append_to_log = 0; - + int len; + int ScheduleFlag = 0; + int UpdateStatus = 0; + unsigned short wget_pid = 0; + int wait_count; + FILE *fp; + char buffer[80]; + char cmd_buf[80]; + char S_FileName[16]; + //jack add 031226 + + //jack add 031226+ + if ( (fp = fopen("/tmp/DSchedule","r")) != NULL ) + { + memset( RealFileName , 0 , 256 ); //jack20040719+ for URL has "?" and "&" character + memset( buffer , 0 , 80 ); + memset( cmd_buf , 0 , 80 ); + memset( S_FileName , 0 , 16 ); + + fgets(buffer , 80 , fp ); + len = strlen(buffer); + if ( len != 0 ) + { + #ifdef wget_debug + printf("Get Schedule\n"); + #endif + ScheduleFlag =1; + + fgets(buffer , 80 , fp ); + strcpy( S_FileName , buffer); + #ifdef wget_debug + printf("get S_FileName = %s\n",S_FileName); + #endif + } + fclose(fp); + system("rm /tmp/DSchedule"); + } +//jack add 031226 + + //jack20040408+ add for del download when status is downloading + if ( ScheduleFlag == 1 ) + { + wget_pid = getpid(); + if ( strlen(S_FileName) != 0 ) + { + //sprintf( cmd_buf , "/web/u_status %s 3 %d 2&", S_FileName , wget_pid); + sprintf( cmd_buf , "/web/S_DOWN %s 3 %d 2&", S_FileName , wget_pid); + system(cmd_buf); + } + } + //jack20040408 + i18n_initialize (); /* Construct the name of the executable, without the directory part. */ @@ -698,20 +766,34 @@ setoptval (opt->data, optarg); break; case OPT_BOOLEAN: - if (optarg) - /* The user has specified a value -- use it. */ - setoptval (opt->data, optarg); - else - { - /* NEG is true for `--no-FOO' style boolean options. */ - int neg = val & BOOLEAN_NEG_MARKER; - setoptval (opt->data, neg ? "0" : "1"); - } + if ( opt->short_name == 'm' ) + { + ftp_get_file_szie = 1; + } + else + { + if (optarg) + /* The user has specified a value -- use it. */ + setoptval (opt->data, optarg); + else + { + /* NEG is true for `--no-FOO' style boolean options. */ + int neg = val & BOOLEAN_NEG_MARKER; + setoptval (opt->data, neg ? "0" : "1"); + } + } break; case OPT_FUNCALL: { - void (*func) PARAMS ((void)) = opt->data; - func (); + if ( opt->short_name == 'V' ) + { + Download_Test_Flag =1; + } + else + { + void (*func) PARAMS ((void)) = opt->data; + func (); + } } break; case OPT__APPEND_OUTPUT: @@ -965,10 +1047,80 @@ #ifdef DEBUG_MALLOC print_malloc_debug_stats (); #endif + //jack add 031226+ + if ( ScheduleFlag == 1) + { + if ( (fp=fopen("/web/wget.log","r")) != NULL ) + { + fclose(fp); + UpdateStatus = 1; + strcpy(cmd_buf , update_status); + strcat(cmd_buf , S_FileName); + } + } + + //jack add 031226 + if (status == RETROK) + { + //jack add 031226+ + if( ( ScheduleFlag == 1 ) && ( UpdateStatus == 1) ) + { + strcat(cmd_buf , StatusOK); + strcat(cmd_buf , " 0" ); + strcat(cmd_buf , " 1" ); + system(cmd_buf); + } + + if ( Download_Test_Flag == 1 ) + { + wait_count = 0; + while ( wait_count < 5 ) + { + if ((fp = fopen("/tmp/FileLen","r")) == NULL ) + { + fp = fopen("/tmp/FileLen","w+"); + //jack20040719+ for URL has "?" and "&" character + if (( FileLength & 0x80000000 ) != 0 ) + FileLength = 0; + if ( Search_Real_FileName == 0 ) + sprintf(buffer , "%d" , FileLength ); + else + sprintf(buffer , "%d\n" , FileLength ); + + fputs( buffer , fp ); + if ( Search_Real_FileName == 1 ) + { + fputs( RealFileName , fp ); + } + //jack20040719 end + fclose(fp); + break; + } + else + { + fclose(fp); + } + wait_count++; + sleep(1); + } + } + //jack add 031226 return 0; + } else + { + //jack add 031226+ + if( ( ScheduleFlag == 1 ) && ( UpdateStatus == 1) ) + { + strcat(cmd_buf , StatusFail); + strcat(cmd_buf , " 0"); + strcat(cmd_buf , " 1" ); + system(cmd_buf); + } + //jack add 031226 return 1; + } } #ifdef HAVE_SIGNAL diff -Naru ori/wget-LFS-20041113/src/progress.c wget-LFS/src/progress.c --- ori/wget-LFS-20041113/src/progress.c 2004-06-30 05:42:32.000000000 +0300 +++ wget-LFS/src/progress.c 2005-11-08 15:06:12.000000000 +0200 @@ -77,6 +77,10 @@ static struct progress_implementation *current_impl; static int current_impl_locked; +//jack add 031226+ +extern int UpdateRetry; +//jack add 031226 + /* Progress implementation used by default. Can be overriden in wgetrc or by the fallback one. */ @@ -963,6 +967,8 @@ while (p < bp->buffer + bp->width) *p++ = ' '; *p = '\0'; + + UpdateRetry = 1; } /* Print the contents of the buffer as a one-line ASCII "image" so diff -Naru ori/wget-LFS-20041113/src/retr.c wget-LFS/src/retr.c --- ori/wget-LFS-20041113/src/retr.c 2004-11-14 16:17:51.000000000 +0200 +++ wget-LFS/src/retr.c 2005-11-08 15:06:12.000000000 +0200 @@ -581,6 +581,23 @@ char *saved_post_data = NULL; char *saved_post_file_name = NULL; +//jack20040719+ for URL has "?" and "&" character + int i; + + //printf("origurl = %s\n",origurl); + + i=0; + while( origurl[i] != 0x00 ) + { + if( origurl[i] == '#' ) + { + origurl[i] = '&'; + } + i++; + } + //printf("moidfy origurl = %s\n",origurl); + //jack20040719 end + /* If dt is NULL, use local storage. */ if (!dt) { diff -Naru ori/wget-LFS-20041113/src/wget.h wget-LFS/src/wget.h --- ori/wget-LFS-20041113/src/wget.h 2003-11-29 20:40:01.000000000 +0200 +++ wget-LFS/src/wget.h 2005-11-08 15:06:12.000000000 +0200 @@ -32,6 +32,8 @@ includes some often-needed system includes, like the obnoxious inclusion. */ +//#define wget_debug 1 + #ifndef WGET_H #define WGET_H