From 211c870cbaf49795e5e15b7726f5f52da7a8cf4a Mon Sep 17 00:00:00 2001 From: Xavier Roche Date: Mon, 19 Mar 2012 13:02:05 +0000 Subject: httrack 3.43.5 --- src/htsback.c | 36 +-- src/htsbasenet.h | 10 +- src/htscatchurl.c | 4 +- src/htscoremain.c | 12 +- src/htsftp.c | 4 +- src/htsglobal.h | 6 +- src/htsindex.c | 2 +- src/htslib.c | 22 +- src/htslib.h | 9 +- src/htsmodules.c | 47 ++-- src/htsparse.c | 7 +- src/htsserver.c | 7 +- src/httrack.vcproj | 600 ++++++++----------------------------------------- src/minizip/mztools.c | 572 +++++++++++++++++++++++----------------------- src/proxy/proxytrack.c | 5 +- src/webhttrack | 21 +- 16 files changed, 443 insertions(+), 921 deletions(-) (limited to 'src') diff --git a/src/htsback.c b/src/htsback.c index 723ad60..280dba0 100644 --- a/src/htsback.c +++ b/src/htsback.c @@ -479,23 +479,8 @@ int back_finalize(httrackp* opt,cache_back* cache,struct_back* sback,int p) { back[p].compressed_size=back[p].r.size; // en mémoire -> passage sur disque if (!back[p].r.is_write) { -#if 1 -#ifdef _WIN32 -#undef tempnam -#define tempnam _tempnam -#endif - char *const tmp = tempnam(NULL, "httrack_temporaryGzipFile_"); - if (tmp != NULL) { - strcpybuff(back[p].tmpfile_buffer, tmp); - free(tmp); - back[p].tmpfile = back[p].tmpfile_buffer; - } else { - back[p].tmpfile = NULL; - } -#else back[p].tmpfile_buffer[0]='\0'; - back[p].tmpfile=tmpnam(back[p].tmpfile_buffer); -#endif + back[p].tmpfile=tmpnam(back[p].tmpfile_buffer); if (back[p].tmpfile != NULL && back[p].tmpfile[0] != '\0') { back[p].r.out=fopen(back[p].tmpfile,"wb"); if (back[p].r.out) { @@ -512,7 +497,7 @@ int back_finalize(httrackp* opt,cache_back* cache,struct_back* sback,int p) { } else { back[p].tmpfile[0]='\0'; back[p].r.statuscode=STATUSCODE_INVALID; - strcpybuff(back[p].r.msg,"Open error when decompressing (can not create a temporary file)"); + strcpybuff(back[p].r.msg,"Open error when decompressing"); } } } @@ -2734,23 +2719,8 @@ void back_wait(struct_back* sback,httrackp* opt,cache_back* cache,TStamp stat_ti /* .gz are *NOT* depacked!! */ (strfield(get_ext(catbuff,back[i].url_sav),"gz") == 0) ) { -#if 1 -#ifdef _WIN32 -#undef tempnam -#define tempnam _tempnam -#endif - char *const tmp = tempnam(NULL, "httrack_temporaryGzipFile_"); - if (tmp != NULL) { - strcpybuff(back[i].tmpfile_buffer, tmp); - free(tmp); - back[i].tmpfile = back[i].tmpfile_buffer; - } else { - back[i].tmpfile = NULL; - } -#else back[i].tmpfile_buffer[0]='\0'; - back[i].tmpfile=tmpnam(back[p].tmpfile_buffer); -#endif + back[i].tmpfile=tmpnam(back[i].tmpfile_buffer); if (back[i].tmpfile != NULL && back[i].tmpfile[0]) { if ((back[i].r.out=fopen(back[i].tmpfile,"wb")) == NULL) { last_errno = errno; diff --git a/src/htsbasenet.h b/src/htsbasenet.h index d717654..26f1392 100644 --- a/src/htsbasenet.h +++ b/src/htsbasenet.h @@ -47,15 +47,9 @@ Please visit our Website: http://www.httrack.com #ifndef _WIN32_WCE #undef HTS_USESCOPEID #define WIN32_LEAN_AND_MEAN -// KB955045 (http://support.microsoft.com/kb/955045) -// To execute an application using this function on earlier versions of Windows -// (Windows 2000, Windows NT, and Windows Me/98/95), then it is mandatary to #include Ws2tcpip.h -// and also Wspiapi.h. When the Wspiapi.h header file is included, the 'getaddrinfo' function is -// #defined to the 'WspiapiGetAddrInfo' inline function in Wspiapi.h. +#include #include -#include -//#include -//#include +#include #else #include #include diff --git a/src/htscatchurl.c b/src/htscatchurl.c index 2cb10f0..74a2439 100644 --- a/src/htscatchurl.c +++ b/src/htscatchurl.c @@ -160,7 +160,9 @@ HTSEXT_API int catch_url(T_SOC soc,char* url,char* method,char* data) { // connexion (accept) if (soc != INVALID_SOCKET) { T_SOC soc2; - while ( (soc2 = (T_SOC) accept(soc, NULL, NULL)) == INVALID_SOCKET); + struct sockaddr dummyaddr; + int dummylen = sizeof(struct sockaddr); + while ( (soc2 = (T_SOC) accept(soc,&dummyaddr,&dummylen)) == INVALID_SOCKET); /* #ifdef _WIN32 closesocket(soc); diff --git a/src/htscoremain.c b/src/htscoremain.c index bfaebaf..634bf86 100644 --- a/src/htscoremain.c +++ b/src/htscoremain.c @@ -1605,13 +1605,11 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp *opt) { return 0; break; case '~': /* internal lib test */ - //Disabled because choke on GCC 4.3 (toni from links2linux.de) - //{ - // char thisIsATestYouShouldSeeAnError[12]; - // const char *const bufferOverflowTest = "0123456789012345678901234567890123456789"; - // strcpybuff(thisIsATestYouShouldSeeAnError, bufferOverflowTest); - // return 0; - //} + { + char thisIsATestYouShouldSeeAnError[12]; + strcpybuff(thisIsATestYouShouldSeeAnError, "0123456789012345678901234567890123456789"); + return 0; + } break; case 'f': opt->flush=1; break; case 'h': diff --git a/src/htsftp.c b/src/htsftp.c index f6df65e..e8797ca 100644 --- a/src/htsftp.c +++ b/src/htsftp.c @@ -653,7 +653,9 @@ int run_launch_ftp(FTPDownloadStruct *pStruct) { _CHECK_HALT_FTP; if (line[0]=='1') { //T_SOC soc_dat; - if ( (soc_dat=accept(soc_servdat, NULL, NULL)) == INVALID_SOCKET) { + struct sockaddr dummyaddr; + int dummylen = sizeof(struct sockaddr); + if ( (soc_dat=accept(soc_servdat,&dummyaddr,&dummylen)) == INVALID_SOCKET) { strcpybuff(back->r.msg,"Unable to accept connection"); // back->status=STATUS_FTP_READY; // fini back->r.statuscode=STATUSCODE_INVALID; diff --git a/src/htsglobal.h b/src/htsglobal.h index be06e5d..f20f7c1 100644 --- a/src/htsglobal.h +++ b/src/htsglobal.h @@ -40,8 +40,8 @@ Please visit our Website: http://www.httrack.com #define HTTRACK_GLOBAL_DEFH // Version (also check external version information) -#define HTTRACK_VERSION "3.43-12" -#define HTTRACK_VERSIONID "3.43.12" +#define HTTRACK_VERSION "3.43-5" +#define HTTRACK_VERSIONID "3.43.5" #define HTTRACK_AFF_VERSION "3.x" #define HTTRACK_LIB_VERSION "2.0" @@ -266,7 +266,7 @@ Please visit our Website: http://www.httrack.com #endif /* Copyright (C) Xavier Roche and other contributors */ -#define HTTRACK_AFF_AUTHORS "[XR&CO'2010]" +#define HTTRACK_AFF_AUTHORS "[XR&CO'2008]" #define HTS_DEFAULT_FOOTER "" #define HTTRACK_WEB "http://www.httrack.com" #define HTS_UPDATE_WEBSITE "http://www.httrack.com/update.php3?Product=HTTrack&Version="HTTRACK_VERSIONID"&VersionStr="HTTRACK_VERSION"&Platform=%d&Language=%s" diff --git a/src/htsindex.c b/src/htsindex.c index 4ab69d0..4a7bd67 100644 --- a/src/htsindex.c +++ b/src/htsindex.c @@ -172,7 +172,7 @@ int index_keyword(const char* html_data,LLint size,const char* mime,const char* } // Check MIME type - if (is_html_mime_type(mime)) { + if (strfield2(mime,"text/html")) { inscript=0; } // FIXME - temporary fix for image/svg+xml (svg) diff --git a/src/htslib.c b/src/htslib.c index ff41d4f..e691902 100644 --- a/src/htslib.c +++ b/src/htslib.c @@ -3105,7 +3105,7 @@ int ishtml(httrackp *opt,const char* fil) { *a = '\0'; } if (get_userhttptype(opt, mime, fil_noquery)) { - if (is_html_mime_type(mime)) { + if (strfield2(mime, "text/html")) { return 1; } else { return 0; @@ -3702,15 +3702,15 @@ HTSEXT_API char* unescape_http(char *catbuff, const char* s) { } // unescape in URL/URI ONLY what has to be escaped, to form a standard URL/URI -// DOES NOT DECODE %25 (part of CHAR_DELIM) +// DOES NOT DECODE %25 HTSEXT_API char* unescape_http_unharm(char *catbuff, const char* s, int no_high) { int i,j=0; for (i=0;i<(int) strlen(s);i++) { if (s[i]=='%') { int nchar=(char) ehex(s+i+1); - int test = ( ( CHAR_RESERVED(nchar) && nchar != '+' ) /* %2B => + (not in query!) */ - || CHAR_DELIM(nchar) + int test = ( CHAR_RESERVED(nchar) + || ( nchar != '%' && CHAR_DELIM(nchar) ) || CHAR_UNWISE(nchar) || CHAR_LOW(nchar) /* CHAR_SPECIAL */ || CHAR_XXAVOID(nchar) @@ -3822,13 +3822,9 @@ HTSEXT_API void x_escape_http(char* s,int mode) { || CHAR_XXAVOID(*s) ); } else if (mode==30) { // échapper que ce qui est nécessaire - test = - ( *s != '/' && CHAR_RESERVED(*s) ) - || CHAR_DELIM(*s) - || CHAR_UNWISE(*s) - || CHAR_SPECIAL(*s) - || CHAR_XXAVOID(*s) - ; + test = ( + CHAR_LOW(*s) + || CHAR_XXAVOID(*s) ); } if (test) { @@ -4159,7 +4155,7 @@ HTSEXT_API int is_knowntype(httrackp *opt,const char *fil) { ext = get_ext(catbuff, fil); while(strnotempty(hts_mime[j][1])) { if (strfield2(hts_mime[j][1], ext)) { - if (is_html_mime_type(hts_mime[j][0])) + if (strfield2(hts_mime[j][0], "text/html")) return 2; else return 1; @@ -4205,7 +4201,7 @@ HTSEXT_API int is_userknowntype(httrackp *opt,const char *fil) { get_userhttptype(opt, mime, fil); if (!strnotempty(mime)) return 0; - else if (is_html_mime_type(mime)) + else if (strfield2(mime,"text/html")) return 2; else return 1; diff --git a/src/htslib.h b/src/htslib.h index 19d7adc..504d436 100644 --- a/src/htslib.h +++ b/src/htslib.h @@ -554,14 +554,8 @@ HTS_STATIC int strcmpnocase(char* a,char* b) { #else #define OPT_MMS(a) (0) #endif - -#define is_html_mime_type(a) \ - ( (strfield2((a),"text/html")!=0)\ - || (strfield2((a),"application/xhtml+xml")!=0) \ - ) #define is_hypertext_mime__(a) \ - ( \ - is_html_mime_type(a)\ + ( (strfield2((a),"text/html")!=0)\ || (strfield2((a),"application/x-javascript")!=0) \ || (strfield2((a),"text/css")!=0) \ /*|| (strfield2((a),"text/vnd.wap.wml")!=0)*/ \ @@ -578,6 +572,7 @@ HTS_STATIC int strcmpnocase(char* a,char* b) { || OPT_MMS(a) \ ) + /* Library internal definictions */ #ifdef HTS_INTERNAL_BYTECODE diff --git a/src/htsmodules.c b/src/htsmodules.c index 07291bd..8f7facc 100644 --- a/src/htsmodules.c +++ b/src/htsmodules.c @@ -263,35 +263,30 @@ void htspe_init(void) { handle = LoadLibraryA((char*)"ssleay32"); #else /* We are compatible with 0.9.6/7/8/8b and potentially above */ - static const char *const libs[] = { - "libssl.so.1.0", - "libssl.so.1", - "libssl.so.1.0.0", - /* */ - "libssl.so.0", - "libssl.so.0.9", - "libssl.so.0.9.8p", - "libssl.so.0.9.8o", - "libssl.so.0.9.8n", - "libssl.so.0.9.8m", - "libssl.so.0.9.8l", - "libssl.so.0.9.8k", /* (Debarshi Ray) */ - "libssl.so.0.9.8j", /* (Debarshi Ray) */ - "libssl.so.0.9.8g", /* Added 8g release too (Debarshi Ray) */ - "libssl.so.0.9.8b", - "libssl.so.0.9.8", - "libssl.so.0.9.7", - "libssl.so.0.9.6", - "libssl.so", /* Try harder with devel link */ - NULL - }; - int i; - for(i = 0, handle = NULL ; handle == NULL && libs[i] != NULL ; i++) { - handle = dlopen(libs[i], RTLD_LAZY); + handle = dlopen("libssl.so.0.9.8g", RTLD_LAZY); /* added 8g release too (Debarshi Ray) */ + if (handle == NULL) { + handle = dlopen("libssl.so.0.9.8b", RTLD_LAZY); + } + if (handle == NULL) { + handle = dlopen("libssl.so.0.9.8", RTLD_LAZY); + } + if (handle == NULL) { + handle = dlopen("libssl.so.0.9.7", RTLD_LAZY); + } + if (handle == NULL) { + handle = dlopen("libssl.so.0.9.6", RTLD_LAZY); + } + if (handle == NULL) { + /* Try harder with .0 if any */ + handle = dlopen("libssl.so.0", RTLD_LAZY); + } + if (handle == NULL) { + /* Try harder with devel link */ + handle = dlopen("libssl.so", RTLD_LAZY); } #endif ssl_handle = handle; - if (handle != NULL) { + if (handle) { SSL_shutdown = (t_SSL_shutdown) DynamicGet(handle, (char*)"SSL_shutdown"); SSL_free = (t_SSL_free) DynamicGet(handle, (char*)"SSL_free"); SSL_new = (t_SSL_new) DynamicGet(handle, (char*)"SSL_new"); diff --git a/src/htsparse.c b/src/htsparse.c index 34ef831..e2f955a 100644 --- a/src/htsparse.c +++ b/src/htsparse.c @@ -1953,12 +1953,12 @@ int htsparse(htsmoduleStruct* str, htsmoduleStructExtended* stre) { unescape_amp(lien); unescape_amp(query); // décoder l'inutile (%2E par exemple) et coder espaces - // Bad: strcpybuff(lien,unescape_http(lien)); - // Bad: strcpybuff(lien,unescape_http_unharm(lien, (no_esc_utf)?0:1)); + // XXXXXXXXXXXXXXXXX strcpybuff(lien,unescape_http(lien)); + //strcpybuff(lien,unescape_http_unharm(lien, (no_esc_utf)?0:1)); /* Never unescape high-chars (we don't know the encoding!!) */ strcpybuff(lien,unescape_http_unharm(catbuff,lien, 1)); /* note: '%' is still escaped */ escape_remove_control(lien); - // ???? No! escape_spc_url(lien); + escape_spc_url(lien); strcatbuff(lien,query); /* restore */ } @@ -2752,7 +2752,6 @@ int htsparse(htsmoduleStruct* str, htsmoduleStructExtended* stre) { if (!in_media) { // In media (such as real audio): don't patch /* Never escape high-chars (we don't know the encoding!!) */ escape_uri_utf(tempo); - //if (!no_esc_utf) // escape_uri(tempo); // escape with %xx //else { diff --git a/src/htsserver.c b/src/htsserver.c index 855db75..abcd1be 100644 --- a/src/htsserver.c +++ b/src/htsserver.c @@ -302,7 +302,7 @@ int smallserver(T_SOC soc,char* url,char* method,char* data, char* path) { }; initStrElt initStr[] = { { "user", "Mozilla/4.5 (compatible; HTTrack 3.0x; Windows 98)" }, - { "footer", "" }, + { "footer", "" }, { "url2", "+*.png +*.gif +*.jpg +*.css +*.js -ad.doubleclick.net/*" }, { NULL, NULL } }; @@ -332,6 +332,8 @@ int smallserver(T_SOC soc,char* url,char* method,char* data, char* path) { char line[8192]; char line2[1024]; T_SOC soc_c; + struct sockaddr dummyaddr; + int dummylen = sizeof(struct sockaddr); LLint length = 0; char* error_redirect = NULL; @@ -347,6 +349,7 @@ int smallserver(T_SOC soc,char* url,char* method,char* data, char* path) { StringCat(tmpbuff, ""); StringCat(tmpbuff2, ""); StringCat(fspath, ""); + memset(&dummyaddr, 0, sizeof(dummyaddr)); /* UnLock */ webhttrack_release(); @@ -357,7 +360,7 @@ int smallserver(T_SOC soc,char* url,char* method,char* data, char* path) { #endif /* Accept */ - while ( (soc_c = (T_SOC) accept(soc, NULL, NULL)) == INVALID_SOCKET); + while ( (soc_c = (T_SOC) accept(soc, &dummyaddr, &dummylen)) == INVALID_SOCKET); /* Lock */ webhttrack_lock(); diff --git a/src/httrack.vcproj b/src/httrack.vcproj index 95b63ae..144b464 100755 --- a/src/httrack.vcproj +++ b/src/httrack.vcproj @@ -1,62 +1,36 @@ + SccProjectName="" + SccLocalPath=""> - + Name="Win32"/> - - - - - - - + ATLMinimizesCRunTimeLibraryUsage="FALSE" + CharacterSet="2"> - - + CompileAs="0"/> + Name="VCCustomBuildTool"/> - - - - - - - - - - - - - + TargetMachine="1"/> + HeaderFileName=""/> + Name="VCPostBuildEventTool"/> + + Name="VCPreLinkEventTool"/> + Culture="1033"/> + Name="VCWebServiceProxyGeneratorTool"/> - - - - + Name="VCXMLDataGeneratorTool"/> + Name="VCWebDeploymentTool"/> + Name="VCManagedWrapperGeneratorTool"/> + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - - - - - + ATLMinimizesCRunTimeLibraryUsage="FALSE" + CharacterSet="2"> - - + CompileAs="0"/> + Name="VCCustomBuildTool"/> - - - - - - - - - - - - - + TargetMachine="1"/> + HeaderFileName=""/> + Name="VCPostBuildEventTool"/> + Name="VCPreBuildEventTool"/> + - + Culture="1033"/> + Name="VCWebServiceProxyGeneratorTool"/> + Name="VCXMLDataGeneratorTool"/> + Name="VCWebDeploymentTool"/> + Name="VCManagedWrapperGeneratorTool"/> - - - + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - - - - - + ATLMinimizesCRunTimeLibraryUsage="FALSE" + CharacterSet="2"> + SuppressStartupBanner="TRUE" + Detect64BitPortabilityProblems="TRUE" + CompileAs="0"/> - - + Name="VCCustomBuildTool"/> - - - - - - - - - - - - - + TargetMachine="1"/> + HeaderFileName=""/> + Name="VCPostBuildEventTool"/> + + Name="VCPreLinkEventTool"/> - - - - + Culture="1033"/> + Name="VCWebServiceProxyGeneratorTool"/> + Name="VCXMLDataGeneratorTool"/> + Name="VCWebDeploymentTool"/> + Name="VCManagedWrapperGeneratorTool"/> + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + RelativePath="httrack.c"> + Name="Release avec debug|Win32"> + BrowseInformation="1"/> - - - + Name="Debug|Win32"> + BrowseInformation="1"/> - - - - - - + Name="Release|Win32"> + PreprocessorDefinitions=""/> + RelativePath=".\httrack.h"> diff --git a/src/minizip/mztools.c b/src/minizip/mztools.c index a09bfb7..6021c49 100644 --- a/src/minizip/mztools.c +++ b/src/minizip/mztools.c @@ -1,287 +1,287 @@ -/* - Additional tools for Minizip - Code: Xavier Roche '2004 - License: Same as ZLIB (www.gzip.org) -*/ - -/* Code */ -#include -#ifndef _WIN32_WCE -#include -#include -#else +/* + Additional tools for Minizip + Code: Xavier Roche '2004 + License: Same as ZLIB (www.gzip.org) +*/ + +/* Code */ +#include +#ifndef _WIN32_WCE #include -#include -#include "celib.h" -#endif -#include "zlib.h" -#include "unzip.h" - -#define READ_8(adr) ((unsigned char)*(adr)) -#define READ_16(adr) ( READ_8(adr) | (READ_8(adr+1) << 8) ) -#define READ_32(adr) ( READ_16(adr) | (READ_16((adr)+2) << 16) ) - -#define WRITE_8(buff, n) do { \ - *((unsigned char*)(buff)) = (unsigned char) ((n) & 0xff); \ -} while(0) -#define WRITE_16(buff, n) do { \ - WRITE_8((unsigned char*)(buff), n); \ - WRITE_8(((unsigned char*)(buff)) + 1, (n) >> 8); \ -} while(0) -#define WRITE_32(buff, n) do { \ - WRITE_16((unsigned char*)(buff), (n) & 0xffff); \ - WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \ -} while(0) - -extern int ZEXPORT unzRepair(file, fileOut, fileOutTmp, nRecovered, bytesRecovered) -const char* file; -const char* fileOut; -const char* fileOutTmp; -uLong* nRecovered; -uLong* bytesRecovered; -{ - int err = Z_OK; - FILE* fpZip = fopen(file, "rb"); - FILE* fpOut = fopen(fileOut, "wb"); - FILE* fpOutCD = fopen(fileOutTmp, "wb"); - if (fpZip != NULL && fpOut != NULL) { - int entries = 0; - uLong totalBytes = 0; - char header[30]; - char filename[1024]; - char extra[1024]; - int offset = 0; - int offsetCD = 0; - while ( fread(header, 1, 30, fpZip) == 30 ) { - int currentOffset = offset; - - /* File entry */ - if (READ_32(header) == 0x04034b50) { - unsigned int version = READ_16(header + 4); - unsigned int gpflag = READ_16(header + 6); - unsigned int method = READ_16(header + 8); - unsigned int filetime = READ_16(header + 10); - unsigned int filedate = READ_16(header + 12); - unsigned int crc = READ_32(header + 14); /* crc */ - unsigned int cpsize = READ_32(header + 18); /* compressed size */ - unsigned int uncpsize = READ_32(header + 22); /* uncompressed sz */ - unsigned int fnsize = READ_16(header + 26); /* file name length */ - unsigned int extsize = READ_16(header + 28); /* extra field length */ - filename[0] = extra[0] = '\0'; - - /* Header */ - if (fwrite(header, 1, 30, fpOut) == 30) { - offset += 30; - } else { - err = Z_ERRNO; - break; - } - - /* Filename */ - if (fnsize > 0) { - if (fnsize < sizeof(filename) && fread(filename, 1, fnsize, fpZip) == fnsize) { - if (fwrite(filename, 1, fnsize, fpOut) == fnsize) { - offset += fnsize; - } else { - err = Z_ERRNO; - break; - } - } else { - err = Z_ERRNO; - break; - } - } else { - err = Z_STREAM_ERROR; - break; - } - - /* Extra field */ - if (extsize > 0) { - if (extsize < sizeof(extra) && fread(extra, 1, extsize, fpZip) == extsize) { - if (fwrite(extra, 1, extsize, fpOut) == extsize) { - offset += extsize; - } else { - err = Z_ERRNO; - break; - } - } else { - err = Z_ERRNO; - break; - } - } - - /* Data */ - { - int dataSize = cpsize; - if (dataSize == 0) { - dataSize = uncpsize; - } - if (dataSize > 0) { - char* data = malloc(dataSize); - if (data != NULL) { - if ((int)fread(data, 1, dataSize, fpZip) == dataSize) { - if ((int)fwrite(data, 1, dataSize, fpOut) == dataSize) { - offset += dataSize; - totalBytes += dataSize; - } else { - err = Z_ERRNO; - } - } else { - err = Z_ERRNO; - } - free(data); - if (err != Z_OK) { - break; - } - } else { - err = Z_MEM_ERROR; - break; - } - } - } - - /* Central directory entry */ - { - char header[46]; - char* comment = ""; - int comsize = (int) strlen(comment); - WRITE_32(header, 0x02014b50); - WRITE_16(header + 4, version); - WRITE_16(header + 6, version); - WRITE_16(header + 8, gpflag); - WRITE_16(header + 10, method); - WRITE_16(header + 12, filetime); - WRITE_16(header + 14, filedate); - WRITE_32(header + 16, crc); - WRITE_32(header + 20, cpsize); - WRITE_32(header + 24, uncpsize); - WRITE_16(header + 28, fnsize); - WRITE_16(header + 30, extsize); - WRITE_16(header + 32, comsize); - WRITE_16(header + 34, 0); /* disk # */ - WRITE_16(header + 36, 0); /* int attrb */ - WRITE_32(header + 38, 0); /* ext attrb */ - WRITE_32(header + 42, currentOffset); - /* Header */ - if (fwrite(header, 1, 46, fpOutCD) == 46) { - offsetCD += 46; - - /* Filename */ - if (fnsize > 0) { - if (fwrite(filename, 1, fnsize, fpOutCD) == fnsize) { - offsetCD += fnsize; - } else { - err = Z_ERRNO; - break; - } - } else { - err = Z_STREAM_ERROR; - break; - } - - /* Extra field */ - if (extsize > 0) { - if (fwrite(extra, 1, extsize, fpOutCD) == extsize) { - offsetCD += extsize; - } else { - err = Z_ERRNO; - break; - } - } - - /* Comment field */ - if (comsize > 0) { - if ((int)fwrite(comment, 1, comsize, fpOutCD) == comsize) { - offsetCD += comsize; - } else { - err = Z_ERRNO; - break; - } - } - - - } else { - err = Z_ERRNO; - break; - } - } - - /* Success */ - entries++; - - } else { - break; - } - } - - /* Final central directory */ - { - int entriesZip = entries; - char header[22]; - char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools"; - int comsize = (int) strlen(comment); - if (entriesZip > 0xffff) { - entriesZip = 0xffff; - } - WRITE_32(header, 0x06054b50); - WRITE_16(header + 4, 0); /* disk # */ - WRITE_16(header + 6, 0); /* disk # */ - WRITE_16(header + 8, entriesZip); /* hack */ - WRITE_16(header + 10, entriesZip); /* hack */ - WRITE_32(header + 12, offsetCD); /* size of CD */ - WRITE_32(header + 16, offset); /* offset to CD */ - WRITE_16(header + 20, comsize); /* comment */ - - /* Header */ - if (fwrite(header, 1, 22, fpOutCD) == 22) { - - /* Comment field */ - if (comsize > 0) { - if ((int)fwrite(comment, 1, comsize, fpOutCD) != comsize) { - err = Z_ERRNO; - } - } - - } else { - err = Z_ERRNO; - } - } - - /* Final merge (file + central directory) */ - fclose(fpOutCD); - if (err == Z_OK) { - fpOutCD = fopen(fileOutTmp, "rb"); - if (fpOutCD != NULL) { - int nRead; - char buffer[8192]; - while ( (nRead = fread(buffer, 1, sizeof(buffer), fpOutCD)) > 0) { - if ((int)fwrite(buffer, 1, nRead, fpOut) != nRead) { - err = Z_ERRNO; - break; - } - } - fclose(fpOutCD); - } - } - - /* Close */ - fclose(fpZip); - fclose(fpOut); - - /* Wipe temporary file */ - (void)remove(fileOutTmp); - - /* Number of recovered entries */ - if (err == Z_OK) { - if (nRecovered != NULL) { - *nRecovered = entries; - } - if (bytesRecovered != NULL) { - *bytesRecovered = totalBytes; - } - } - } else { - err = Z_STREAM_ERROR; - } - return err; -} +#include +#else +#include +#include +#include "celib.h" +#endif +#include "zlib.h" +#include "unzip.h" + +#define READ_8(adr) ((unsigned char)*(adr)) +#define READ_16(adr) ( READ_8(adr) | (READ_8(adr+1) << 8) ) +#define READ_32(adr) ( READ_16(adr) | (READ_16((adr)+2) << 16) ) + +#define WRITE_8(buff, n) do { \ + *((unsigned char*)(buff)) = (unsigned char) ((n) & 0xff); \ +} while(0) +#define WRITE_16(buff, n) do { \ + WRITE_8((unsigned char*)(buff), n); \ + WRITE_8(((unsigned char*)(buff)) + 1, (n) >> 8); \ +} while(0) +#define WRITE_32(buff, n) do { \ + WRITE_16((unsigned char*)(buff), (n) & 0xffff); \ + WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \ +} while(0) + +extern int ZEXPORT unzRepair(file, fileOut, fileOutTmp, nRecovered, bytesRecovered) +const char* file; +const char* fileOut; +const char* fileOutTmp; +uLong* nRecovered; +uLong* bytesRecovered; +{ + int err = Z_OK; + FILE* fpZip = fopen(file, "rb"); + FILE* fpOut = fopen(fileOut, "wb"); + FILE* fpOutCD = fopen(fileOutTmp, "wb"); + if (fpZip != NULL && fpOut != NULL) { + int entries = 0; + uLong totalBytes = 0; + char header[30]; + char filename[256]; + char extra[1024]; + int offset = 0; + int offsetCD = 0; + while ( fread(header, 1, 30, fpZip) == 30 ) { + int currentOffset = offset; + + /* File entry */ + if (READ_32(header) == 0x04034b50) { + unsigned int version = READ_16(header + 4); + unsigned int gpflag = READ_16(header + 6); + unsigned int method = READ_16(header + 8); + unsigned int filetime = READ_16(header + 10); + unsigned int filedate = READ_16(header + 12); + unsigned int crc = READ_32(header + 14); /* crc */ + unsigned int cpsize = READ_32(header + 18); /* compressed size */ + unsigned int uncpsize = READ_32(header + 22); /* uncompressed sz */ + unsigned int fnsize = READ_16(header + 26); /* file name length */ + unsigned int extsize = READ_16(header + 28); /* extra field length */ + filename[0] = extra[0] = '\0'; + + /* Header */ + if (fwrite(header, 1, 30, fpOut) == 30) { + offset += 30; + } else { + err = Z_ERRNO; + break; + } + + /* Filename */ + if (fnsize > 0) { + if (fread(filename, 1, fnsize, fpZip) == fnsize) { + if (fwrite(filename, 1, fnsize, fpOut) == fnsize) { + offset += fnsize; + } else { + err = Z_ERRNO; + break; + } + } else { + err = Z_ERRNO; + break; + } + } else { + err = Z_STREAM_ERROR; + break; + } + + /* Extra field */ + if (extsize > 0) { + if (fread(extra, 1, extsize, fpZip) == extsize) { + if (fwrite(extra, 1, extsize, fpOut) == extsize) { + offset += extsize; + } else { + err = Z_ERRNO; + break; + } + } else { + err = Z_ERRNO; + break; + } + } + + /* Data */ + { + int dataSize = cpsize; + if (dataSize == 0) { + dataSize = uncpsize; + } + if (dataSize > 0) { + char* data = malloc(dataSize); + if (data != NULL) { + if ((int)fread(data, 1, dataSize, fpZip) == dataSize) { + if ((int)fwrite(data, 1, dataSize, fpOut) == dataSize) { + offset += dataSize; + totalBytes += dataSize; + } else { + err = Z_ERRNO; + } + } else { + err = Z_ERRNO; + } + free(data); + if (err != Z_OK) { + break; + } + } else { + err = Z_MEM_ERROR; + break; + } + } + } + + /* Central directory entry */ + { + char header[46]; + char* comment = ""; + int comsize = (int) strlen(comment); + WRITE_32(header, 0x02014b50); + WRITE_16(header + 4, version); + WRITE_16(header + 6, version); + WRITE_16(header + 8, gpflag); + WRITE_16(header + 10, method); + WRITE_16(header + 12, filetime); + WRITE_16(header + 14, filedate); + WRITE_32(header + 16, crc); + WRITE_32(header + 20, cpsize); + WRITE_32(header + 24, uncpsize); + WRITE_16(header + 28, fnsize); + WRITE_16(header + 30, extsize); + WRITE_16(header + 32, comsize); + WRITE_16(header + 34, 0); /* disk # */ + WRITE_16(header + 36, 0); /* int attrb */ + WRITE_32(header + 38, 0); /* ext attrb */ + WRITE_32(header + 42, currentOffset); + /* Header */ + if (fwrite(header, 1, 46, fpOutCD) == 46) { + offsetCD += 46; + + /* Filename */ + if (fnsize > 0) { + if (fwrite(filename, 1, fnsize, fpOutCD) == fnsize) { + offsetCD += fnsize; + } else { + err = Z_ERRNO; + break; + } + } else { + err = Z_STREAM_ERROR; + break; + } + + /* Extra field */ + if (extsize > 0) { + if (fwrite(extra, 1, extsize, fpOutCD) == extsize) { + offsetCD += extsize; + } else { + err = Z_ERRNO; + break; + } + } + + /* Comment field */ + if (comsize > 0) { + if ((int)fwrite(comment, 1, comsize, fpOutCD) == comsize) { + offsetCD += comsize; + } else { + err = Z_ERRNO; + break; + } + } + + + } else { + err = Z_ERRNO; + break; + } + } + + /* Success */ + entries++; + + } else { + break; + } + } + + /* Final central directory */ + { + int entriesZip = entries; + char header[22]; + char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools"; + int comsize = (int) strlen(comment); + if (entriesZip > 0xffff) { + entriesZip = 0xffff; + } + WRITE_32(header, 0x06054b50); + WRITE_16(header + 4, 0); /* disk # */ + WRITE_16(header + 6, 0); /* disk # */ + WRITE_16(header + 8, entriesZip); /* hack */ + WRITE_16(header + 10, entriesZip); /* hack */ + WRITE_32(header + 12, offsetCD); /* size of CD */ + WRITE_32(header + 16, offset); /* offset to CD */ + WRITE_16(header + 20, comsize); /* comment */ + + /* Header */ + if (fwrite(header, 1, 22, fpOutCD) == 22) { + + /* Comment field */ + if (comsize > 0) { + if ((int)fwrite(comment, 1, comsize, fpOutCD) != comsize) { + err = Z_ERRNO; + } + } + + } else { + err = Z_ERRNO; + } + } + + /* Final merge (file + central directory) */ + fclose(fpOutCD); + if (err == Z_OK) { + fpOutCD = fopen(fileOutTmp, "rb"); + if (fpOutCD != NULL) { + int nRead; + char buffer[8192]; + while ( (nRead = fread(buffer, 1, sizeof(buffer), fpOutCD)) > 0) { + if ((int)fwrite(buffer, 1, nRead, fpOut) != nRead) { + err = Z_ERRNO; + break; + } + } + fclose(fpOutCD); + } + } + + /* Close */ + fclose(fpZip); + fclose(fpOut); + + /* Wipe temporary file */ + (void)remove(fileOutTmp); + + /* Number of recovered entries */ + if (err == Z_OK) { + if (nRecovered != NULL) { + *nRecovered = entries; + } + if (bytesRecovered != NULL) { + *bytesRecovered = totalBytes; + } + } + } else { + err = Z_STREAM_ERROR; + } + return err; +} diff --git a/src/proxy/proxytrack.c b/src/proxy/proxytrack.c index 78775ab..195c1a5 100644 --- a/src/proxy/proxytrack.c +++ b/src/proxy/proxytrack.c @@ -1365,7 +1365,10 @@ static int proxytrack_process_HTTP_threaded(PT_Indexes indexes, T_SOC soc) { static int proxytrack_start_HTTP(PT_Indexes indexes, T_SOC soc) { while(soc != INVALID_SOCKET) { T_SOC soc_c; - if ( (soc_c = (T_SOC) accept(soc, NULL, NULL)) != INVALID_SOCKET) { + struct sockaddr clientAddr; + int clientAddrLen = sizeof(struct sockaddr); + memset(&clientAddr, 0, sizeof(clientAddr)); + if ( (soc_c = (T_SOC) accept(soc, &clientAddr, &clientAddrLen)) != INVALID_SOCKET) { if (!proxytrack_process_HTTP_threaded(indexes, soc_c)) { CRITICAL("proxytrack_start_HTTP::Can not fork a thread"); } diff --git a/src/webhttrack b/src/webhttrack index 314e070..430b026 100755 --- a/src/webhttrack +++ b/src/webhttrack @@ -4,21 +4,14 @@ # Initializes the htsserver GUI frontend and launch the default browser BROWSEREXE= -SRCHBROWSEREXE="x-www-browser www-browser iceape mozilla firefox icecat iceweasel abrowser firebird galeon konqueror opera netscape" +SRCHBROWSEREXE="x-www-browser www-browser iceape mozilla firefox firebird galeon konqueror opera netscape" if test -n "${BROWSER}"; then # sensible-browser will f up if BROWSER is not set SRCHBROWSEREXE="xdg-open sensible-browser ${SRCHBROWSEREXE}" fi -# Patch for Darwin/Mac by Ross Williams -if test "`uname -s`" == "Darwin"; then -# Darwin/Mac OS X uses a system 'open' command to find -# the default browser. The -W flag causes it to wait for -# the browser to exit -BROWSEREXE="/usr/bin/open -W" -fi -SRCHPATH="/usr/local/bin /usr/share/bin /usr/bin /usr/lib/httrack /usr/local/lib/httrack /usr/local/share/httrack /opt/local/bin /sw/bin ${HOME}/usr/bin ${HOME}/bin" +SRCHPATH="/usr/local/bin /usr/share/bin /usr/bin /usr/lib/httrack /usr/local/lib/httrack /usr/local/share/httrack /sw/bin ${HOME}/usr/bin ${HOME}/bin" SRCHPATH="$SRCHPATH "`echo $PATH | tr ":" " "` -SRCHDISTPATH="/usr/share /usr/local /usr /local /usr/local/share ${HOME}/usr ${HOME}/usr/share /opt/local/share /sw ${HOME}/usr/local ${HOME}/usr/share" +SRCHDISTPATH="/usr/share /usr/local /usr /local /usr/local/share ${HOME}/usr ${HOME}/usr/share /sw ${HOME}/usr/local ${HOME}/usr/share" ### # And now some famous cuisine @@ -40,12 +33,6 @@ echo "$1" | grep -q "firebird" [ $? -eq 0 ] && return 0 echo "$1" | grep -q "firefox" [ $? -eq 0 ] && return 0 -echo "$1" | grep -q "iceweasel" -[ $? -eq 0 ] && return 0 -echo "$1" | grep -q "abrowser" -[ $? -eq 0 ] && return 0 -echo "$1" | grep -q "icecat" -[ $? -eq 0 ] && return 0 return 1; } function mozillaloaded { @@ -54,7 +41,7 @@ if ! test -n "${user_name}"; then user_name=`id -un` fi if test -n "${user_name}"; then -ps -e -U "$user_name" | grep -E "(iceape|mozilla|netscape|firebird|firefox)" | grep -qv "grep -E" +ps -e --user "$user_name" | grep -qE "(iceape|mozilla|netscape|firebird|firefox)" else false fi -- cgit v1.2.3