From 1096a6b82c4110f7a15132c9a2b525899d62380c Mon Sep 17 00:00:00 2001 From: Xavier Roche Date: Mon, 19 Mar 2012 13:02:50 +0000 Subject: httrack 3.43.12 (again) --- 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, 921 insertions(+), 443 deletions(-) (limited to 'src') diff --git a/src/htsback.c b/src/htsback.c index 280dba0..723ad60 100644 --- a/src/htsback.c +++ b/src/htsback.c @@ -479,8 +479,23 @@ 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); + back[p].tmpfile=tmpnam(back[p].tmpfile_buffer); +#endif if (back[p].tmpfile != NULL && back[p].tmpfile[0] != '\0') { back[p].r.out=fopen(back[p].tmpfile,"wb"); if (back[p].r.out) { @@ -497,7 +512,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"); + strcpybuff(back[p].r.msg,"Open error when decompressing (can not create a temporary file)"); } } } @@ -2719,8 +2734,23 @@ 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[i].tmpfile_buffer); + back[i].tmpfile=tmpnam(back[p].tmpfile_buffer); +#endif 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 26f1392..d717654 100644 --- a/src/htsbasenet.h +++ b/src/htsbasenet.h @@ -47,9 +47,15 @@ Please visit our Website: http://www.httrack.com #ifndef _WIN32_WCE #undef HTS_USESCOPEID #define WIN32_LEAN_AND_MEAN -#include +// 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 #else #include #include diff --git a/src/htscatchurl.c b/src/htscatchurl.c index 74a2439..2cb10f0 100644 --- a/src/htscatchurl.c +++ b/src/htscatchurl.c @@ -160,9 +160,7 @@ HTSEXT_API int catch_url(T_SOC soc,char* url,char* method,char* data) { // connexion (accept) if (soc != INVALID_SOCKET) { T_SOC soc2; - struct sockaddr dummyaddr; - int dummylen = sizeof(struct sockaddr); - while ( (soc2 = (T_SOC) accept(soc,&dummyaddr,&dummylen)) == INVALID_SOCKET); + while ( (soc2 = (T_SOC) accept(soc, NULL, NULL)) == INVALID_SOCKET); /* #ifdef _WIN32 closesocket(soc); diff --git a/src/htscoremain.c b/src/htscoremain.c index 634bf86..bfaebaf 100644 --- a/src/htscoremain.c +++ b/src/htscoremain.c @@ -1605,11 +1605,13 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp *opt) { return 0; break; case '~': /* internal lib test */ - { - char thisIsATestYouShouldSeeAnError[12]; - strcpybuff(thisIsATestYouShouldSeeAnError, "0123456789012345678901234567890123456789"); - return 0; - } + //Disabled because choke on GCC 4.3 (toni from links2linux.de) + //{ + // char thisIsATestYouShouldSeeAnError[12]; + // const char *const bufferOverflowTest = "0123456789012345678901234567890123456789"; + // strcpybuff(thisIsATestYouShouldSeeAnError, bufferOverflowTest); + // return 0; + //} break; case 'f': opt->flush=1; break; case 'h': diff --git a/src/htsftp.c b/src/htsftp.c index e8797ca..f6df65e 100644 --- a/src/htsftp.c +++ b/src/htsftp.c @@ -653,9 +653,7 @@ int run_launch_ftp(FTPDownloadStruct *pStruct) { _CHECK_HALT_FTP; if (line[0]=='1') { //T_SOC soc_dat; - struct sockaddr dummyaddr; - int dummylen = sizeof(struct sockaddr); - if ( (soc_dat=accept(soc_servdat,&dummyaddr,&dummylen)) == INVALID_SOCKET) { + if ( (soc_dat=accept(soc_servdat, NULL, NULL)) == 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 f20f7c1..be06e5d 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-5" -#define HTTRACK_VERSIONID "3.43.5" +#define HTTRACK_VERSION "3.43-12" +#define HTTRACK_VERSIONID "3.43.12" #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'2008]" +#define HTTRACK_AFF_AUTHORS "[XR&CO'2010]" #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 4a7bd67..4ab69d0 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 (strfield2(mime,"text/html")) { + if (is_html_mime_type(mime)) { inscript=0; } // FIXME - temporary fix for image/svg+xml (svg) diff --git a/src/htslib.c b/src/htslib.c index e691902..ff41d4f 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 (strfield2(mime, "text/html")) { + if (is_html_mime_type(mime)) { 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 +// DOES NOT DECODE %25 (part of CHAR_DELIM) 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 != '%' && CHAR_DELIM(nchar) ) + int test = ( ( CHAR_RESERVED(nchar) && nchar != '+' ) /* %2B => + (not in query!) */ + || CHAR_DELIM(nchar) || CHAR_UNWISE(nchar) || CHAR_LOW(nchar) /* CHAR_SPECIAL */ || CHAR_XXAVOID(nchar) @@ -3822,9 +3822,13 @@ 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 = ( - CHAR_LOW(*s) - || CHAR_XXAVOID(*s) ); + test = + ( *s != '/' && CHAR_RESERVED(*s) ) + || CHAR_DELIM(*s) + || CHAR_UNWISE(*s) + || CHAR_SPECIAL(*s) + || CHAR_XXAVOID(*s) + ; } if (test) { @@ -4155,7 +4159,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 (strfield2(hts_mime[j][0], "text/html")) + if (is_html_mime_type(hts_mime[j][0])) return 2; else return 1; @@ -4201,7 +4205,7 @@ HTSEXT_API int is_userknowntype(httrackp *opt,const char *fil) { get_userhttptype(opt, mime, fil); if (!strnotempty(mime)) return 0; - else if (strfield2(mime,"text/html")) + else if (is_html_mime_type(mime)) return 2; else return 1; diff --git a/src/htslib.h b/src/htslib.h index 504d436..19d7adc 100644 --- a/src/htslib.h +++ b/src/htslib.h @@ -554,8 +554,14 @@ HTS_STATIC int strcmpnocase(char* a,char* b) { #else #define OPT_MMS(a) (0) #endif -#define is_hypertext_mime__(a) \ + +#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),"application/x-javascript")!=0) \ || (strfield2((a),"text/css")!=0) \ /*|| (strfield2((a),"text/vnd.wap.wml")!=0)*/ \ @@ -572,7 +578,6 @@ 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 8f7facc..07291bd 100644 --- a/src/htsmodules.c +++ b/src/htsmodules.c @@ -263,30 +263,35 @@ void htspe_init(void) { handle = LoadLibraryA((char*)"ssleay32"); #else /* We are compatible with 0.9.6/7/8/8b and potentially above */ - 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); + 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); } #endif ssl_handle = handle; - if (handle) { + if (handle != NULL) { 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 e2f955a..34ef831 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 - // XXXXXXXXXXXXXXXXX strcpybuff(lien,unescape_http(lien)); - //strcpybuff(lien,unescape_http_unharm(lien, (no_esc_utf)?0:1)); + // Bad: strcpybuff(lien,unescape_http(lien)); + // Bad: 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); - escape_spc_url(lien); + // ???? No! escape_spc_url(lien); strcatbuff(lien,query); /* restore */ } @@ -2752,6 +2752,7 @@ 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 abcd1be..855db75 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,8 +332,6 @@ 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; @@ -349,7 +347,6 @@ 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(); @@ -360,7 +357,7 @@ int smallserver(T_SOC soc,char* url,char* method,char* data, char* path) { #endif /* Accept */ - while ( (soc_c = (T_SOC) accept(soc, &dummyaddr, &dummylen)) == INVALID_SOCKET); + while ( (soc_c = (T_SOC) accept(soc, NULL, NULL)) == INVALID_SOCKET); /* Lock */ webhttrack_lock(); diff --git a/src/httrack.vcproj b/src/httrack.vcproj index 144b464..95b63ae 100755 --- a/src/httrack.vcproj +++ b/src/httrack.vcproj @@ -1,36 +1,62 @@ + RootNamespace="httrack" + TargetFrameworkVersion="131072" + > + Name="Win32" + /> + + + + ATLMinimizesCRunTimeLibraryUsage="false" + CharacterSet="2" + > + + + + + + CompileAs="0" + /> + + + Name="VCPreLinkEventTool" + /> + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + + + + + + + + + + + + + + HeaderFileName="" + /> - + Name="VCCLCompilerTool" + AdditionalOptions="/Zm200 " + Optimization="4" + InlineFunctionExpansion="2" + EnableIntrinsicFunctions="true" + FavorSizeOrSpeed="1" + OmitFramePointers="true" + AdditionalIncludeDirectories=""C:\Dev\zlib-1.2.3\";C:\Dev\openssl\include;C:\Dev\Winhttrack" + PreprocessorDefinitions="WIN32;_CONSOLE;HTS_ANALYSTE_CONSOLE" + RuntimeLibrary="2" + UsePrecompiledHeader="0" + PrecompiledHeaderFile="c:\temp\vcpp/httrack.pch" + AssemblerOutput="2" + AssemblerListingLocation="c:\temp\vcpp/" + ObjectFile="c:\temp\vcpp/" + ProgramDataBaseFileName="c:\temp\vcpp/" + BrowseInformation="1" + WarningLevel="3" + SuppressStartupBanner="true" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + CompileAs="0" + /> + Name="VCManagedResourceCompilerTool" + /> + Culture="1033" + /> + Name="VCPreLinkEventTool" + /> + Name="VCLinkerTool" + AdditionalDependencies="Ws2_32.lib libhttrack.lib" + OutputFile="O:\HTTrack\httrack\httrack.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="C:\Dev\openssl\lib,C:\Dev\zlib\dll32,C:\Dev\openssl\lib\out32dll" + GenerateDebugInformation="true" + ProgramDatabaseFile=".\Release_avec_debug/httrack.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="17" + /> + + + + + Name="VCFxCopTool" + /> + Name="VCAppVerifierTool" + /> + Name="VCPostBuildEventTool" + /> + ATLMinimizesCRunTimeLibraryUsage="false" + CharacterSet="2" + > + + + + + + CompileAs="0" + /> + + + Name="VCPreLinkEventTool" + /> + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + + + + + + + + + + + + + - + HeaderFileName="" + /> + Name="VCCLCompilerTool" + AdditionalOptions="/Zm200 " + Optimization="0" + AdditionalIncludeDirectories=""C:\Dev\zlib-1.2.3\";C:\Dev\openssl\include;C:\Dev\Winhttrack" + PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;HTS_ANALYSTE_CONSOLE;_CRT_SECURE_NO_WARNINGS" + RuntimeLibrary="3" + BufferSecurityCheck="true" + RuntimeTypeInfo="true" + PrecompiledHeaderFile="c:\temp\vcpp/httrack.pch" + AssemblerOutput="2" + AssemblerListingLocation="c:\temp\vcpp/" + ObjectFile="c:\temp\vcpp/" + ProgramDataBaseFileName="c:\temp\vcpp/" + BrowseInformation="1" + BrowseInformationFile="c:\temp\vcpp/" + WarningLevel="3" + SuppressStartupBanner="true" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + CompileAs="0" + /> + Name="VCManagedResourceCompilerTool" + /> + Culture="1033" + /> + + Name="VCLinkerTool" + AdditionalDependencies="Ws2_32.lib libhttrack.lib" + OutputFile="C:\temp\httrack64\httrack.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="C:\Dev\openssl\lib,C:\temp\zlib,C:\Dev\openssl\lib\out32dll,C:\temp\Debuglib" + GenerateDebugInformation="true" + ProgramDatabaseFile=".\Debug/httrack.pdb" + SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="17" + /> + Name="VCALinkTool" + /> + Name="VCManifestTool" + /> + Name="VCXDCMakeTool" + /> + Name="VCBscMakeTool" + /> + + + + ATLMinimizesCRunTimeLibraryUsage="false" + CharacterSet="2" + > + + + + + + SuppressStartupBanner="true" + Detect64BitPortabilityProblems="true" + CompileAs="0" + /> + Name="VCManagedResourceCompilerTool" + /> + + + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + /> + + + + + + + + + + + + + - + HeaderFileName="" + /> + Name="VCCLCompilerTool" + AdditionalOptions="/Zm200 " + Optimization="3" + InlineFunctionExpansion="2" + AdditionalIncludeDirectories=""C:\Dev\zlib-1.2.3\";C:\Dev\openssl\include;C:\Dev\Winhttrack" + PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;HTS_ANALYSTE_CONSOLE;_CRT_SECURE_NO_WARNINGS" + StringPooling="true" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile="c:\temp\vcpp/httrack.pch" + AssemblerListingLocation="c:\temp\vcpp/" + ObjectFile="c:\temp\vcpp/" + ProgramDataBaseFileName="c:\temp\vcpp/" + WarningLevel="3" + SuppressStartupBanner="true" + Detect64BitPortabilityProblems="true" + CompileAs="0" + /> + Name="VCManagedResourceCompilerTool" + /> + Culture="1033" + /> + + + + + Name="VCXDCMakeTool" + /> + Name="VCBscMakeTool" + /> + Name="VCFxCopTool" + /> + Name="VCAppVerifierTool" + /> + Name="VCPostBuildEventTool" + /> + RelativePath="httrack.c" + > + Name="Release avec debug|Win32" + > + BrowseInformation="1" + /> + Name="Release avec debug|x64" + > + + + + BrowseInformation="1" + /> + Name="Debug|x64" + > + + + + + + + PreprocessorDefinitions="" + /> + RelativePath=".\httrack.h" + > diff --git a/src/minizip/mztools.c b/src/minizip/mztools.c index 6021c49..a09bfb7 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 +/* + Additional tools for Minizip + Code: Xavier Roche '2004 + License: Same as ZLIB (www.gzip.org) +*/ + +/* Code */ +#include +#ifndef _WIN32_WCE +#include +#include +#else #include -#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; -} +#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; +} diff --git a/src/proxy/proxytrack.c b/src/proxy/proxytrack.c index 195c1a5..78775ab 100644 --- a/src/proxy/proxytrack.c +++ b/src/proxy/proxytrack.c @@ -1365,10 +1365,7 @@ 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; - 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 ( (soc_c = (T_SOC) accept(soc, NULL, NULL)) != 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 430b026..314e070 100755 --- a/src/webhttrack +++ b/src/webhttrack @@ -4,14 +4,21 @@ # Initializes the htsserver GUI frontend and launch the default browser BROWSEREXE= -SRCHBROWSEREXE="x-www-browser www-browser iceape mozilla firefox firebird galeon konqueror opera netscape" +SRCHBROWSEREXE="x-www-browser www-browser iceape mozilla firefox icecat iceweasel abrowser 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 -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" +# 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="$SRCHPATH "`echo $PATH | tr ":" " "` -SRCHDISTPATH="/usr/share /usr/local /usr /local /usr/local/share ${HOME}/usr ${HOME}/usr/share /sw ${HOME}/usr/local ${HOME}/usr/share" +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" ### # And now some famous cuisine @@ -33,6 +40,12 @@ 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 { @@ -41,7 +54,7 @@ if ! test -n "${user_name}"; then user_name=`id -un` fi if test -n "${user_name}"; then -ps -e --user "$user_name" | grep -qE "(iceape|mozilla|netscape|firebird|firefox)" +ps -e -U "$user_name" | grep -E "(iceape|mozilla|netscape|firebird|firefox)" | grep -qv "grep -E" else false fi -- cgit v1.2.3