diff options
Diffstat (limited to 'src/proxy')
-rwxr-xr-x | src/proxy/proxystrings.h | 16 | ||||
-rw-r--r-- | src/proxy/proxytrack.c | 69 | ||||
-rw-r--r-- | src/proxy/proxytrack.h | 30 | ||||
-rw-r--r-- | src/proxy/store.c | 34 |
4 files changed, 79 insertions, 70 deletions
diff --git a/src/proxy/proxystrings.h b/src/proxy/proxystrings.h index 09d0f9f..ceb0891 100755 --- a/src/proxy/proxystrings.h +++ b/src/proxy/proxystrings.h @@ -34,7 +34,7 @@ Please visit our Website: http://www.httrack.com /* Tools */ -static int ehexh(char c) { +HTS_UNUSED static int ehexh(char c) { if ((c >= '0') && (c <= '9')) return c - '0'; if ((c >= 'a') && (c <= 'f')) @@ -44,11 +44,11 @@ static int ehexh(char c) { return 0; } -static int ehex(const char *s) { +HTS_UNUSED static int ehex(const char *s) { return 16 * ehexh(*s) + ehexh(*(s + 1)); } -static void unescapehttp(const char *s, String * tempo) { +HTS_UNUSED static void unescapehttp(const char *s, String * tempo) { int i; for(i = 0; s[i] != '\0'; i++) { @@ -69,7 +69,7 @@ static void unescapehttp(const char *s, String * tempo) { } } -static void escapexml(const char *s, String * tempo) { +HTS_UNUSED static void escapexml(const char *s, String * tempo) { int i; for(i = 0; s[i] != '\0'; i++) { @@ -86,7 +86,7 @@ static void escapexml(const char *s, String * tempo) { } } -static char *concat(char *catbuff, const char *a, const char *b) { +HTS_UNUSED static char *concat(char *catbuff, const char *a, const char *b) { if (a != NULL && a[0] != '\0') { strcpy(catbuff, a); } else { @@ -98,7 +98,7 @@ static char *concat(char *catbuff, const char *a, const char *b) { return catbuff; } -static char *__fconv(char *a) { +HTS_UNUSED static char *__fconv(char *a) { #ifdef WIN32 int i; @@ -109,11 +109,11 @@ static char *__fconv(char *a) { return a; } -static char *fconcat(char *catbuff, const char *a, const char *b) { +HTS_UNUSED static char *fconcat(char *catbuff, const char *a, const char *b) { return __fconv(concat(catbuff, a, b)); } -static char *fconv(char *catbuff, const char *a) { +HTS_UNUSED static char *fconv(char *catbuff, const char *a) { return __fconv(concat(catbuff, a, "")); } diff --git a/src/proxy/proxytrack.c b/src/proxy/proxytrack.c index e78f457..bae974f 100644 --- a/src/proxy/proxytrack.c +++ b/src/proxy/proxytrack.c @@ -345,11 +345,11 @@ int proxytrack_main(char *proxyAddr, int proxyPort, char *icpAddr, int icpPort, T_SOC socICP = smallserver_init(proxyAddr, icpPort, SOCK_DGRAM); if (soc != INVALID_SOCKET && socICP != INVALID_SOCKET) { - char url[HTS_URLMAXSIZE * 2]; - char method[32]; - char data[32768]; + //char url[HTS_URLMAXSIZE * 2]; + //char method[32]; + //char data[32768]; - url[0] = method[0] = data[0] = '\0'; + //url[0] = method[0] = data[0] = '\0'; // printf("HTTP Proxy installed on %s:%d/\n", proxyAddr, proxyPort); printf("ICP Proxy installed on %s:%d/\n", icpAddr, icpPort); @@ -949,7 +949,7 @@ static void proxytrack_process_HTTP(PT_Indexes indexes, T_SOC soc_c) { char *command; char *proto; char *surl; - int directHit = 0; + //int directHit = 0; int headRequest = 0; int listRequest = 0; @@ -1094,7 +1094,7 @@ static void proxytrack_process_HTTP(PT_Indexes indexes, T_SOC soc_c) { if (strncasecmp (surl, "http://proxytrack/", sizeof("http://proxytrack/") - 1) == 0) { - directHit = 1; /* Another direct hit hack */ + //directHit = 1; /* Another direct hit hack */ } StringCopy(url, surl); } else { @@ -1115,7 +1115,7 @@ static void proxytrack_process_HTTP(PT_Indexes indexes, T_SOC soc_c) { toHit += 7; } /* Direct hit */ - directHit = 1; + //directHit = 1; StringCopy(url, ""); if (!link_has_authority(toHit)) StringCat(url, "http://"); @@ -1126,7 +1126,7 @@ static void proxytrack_process_HTTP(PT_Indexes indexes, T_SOC soc_c) { const char *toHit = surl + sizeof("/proxytrack/") - 1; /* Direct hit */ - directHit = 1; + //directHit = 1; StringCopy(url, ""); if (!link_has_authority(toHit)) StringCat(url, "http://"); @@ -1399,19 +1399,28 @@ static void proxytrack_process_HTTP(PT_Indexes indexes, T_SOC soc_c) { } /* Generic threaded function start */ + +#ifdef _WIN32 + static int startThread(void (*funct) (void *), void *param) { if (param != NULL) { -#ifdef _WIN32 if (_beginthread(funct, 0, param) == -1) { free(param); return 0; } return 1; + } else { + return 0; + } +} + #else - pthread_t handle = 0; - int retcode; - retcode = pthread_create(&handle, NULL, funct, param); +/* Generic threaded function start */ +static int startThread(void* (*funct) (void *), void *param) { + if (param != NULL) { + pthread_t handle = 0; + int retcode = pthread_create(&handle, NULL, funct, param); if (retcode != 0) { /* error */ free(param); return 0; @@ -1420,12 +1429,13 @@ static int startThread(void (*funct) (void *), void *param) { pthread_detach(handle); return 1; } -#endif } else { return 0; } } +#endif + /* Generic socket/index structure */ typedef struct proxytrack_process_th_p { T_SOC soc_c; @@ -1433,8 +1443,16 @@ typedef struct proxytrack_process_th_p { void (*process) (PT_Indexes indexes, T_SOC soc_c); } proxytrack_process_th_p; +#ifdef _WIN32 +typedef void proxytrack_process_th_return_t; +#define PROXYTRACK_PROCESS_TH_RETURN return +#else +typedef void* proxytrack_process_th_return_t; +#define PROXYTRACK_PROCESS_TH_RETURN return NULL +#endif + /* Generic socket/index function stub */ -static void proxytrack_process_th(void *param_) { +static proxytrack_process_th_return_t proxytrack_process_th(void *param_) { proxytrack_process_th_p *param = (proxytrack_process_th_p *) param_; T_SOC soc_c = param->soc_c; PT_Indexes indexes = param->indexes; @@ -1442,7 +1460,7 @@ static void proxytrack_process_th(void *param_) { free(param); process(indexes, soc_c); - return; + PROXYTRACK_PROCESS_TH_RETURN; } /* Process generic socket/index operation */ @@ -1517,7 +1535,7 @@ static int ICP_reply(struct sockaddr *clientAddr, int clientAddrLen, T_SOC soc, unsigned char *buffer; if (Message_Length == 0 && Message != NULL) /* We have to get the message size */ - Message_Length = (unsigned int) strlen(Message) + 1; /* NULL terminated */ + Message_Length = (unsigned int) strlen((char*) Message) + 1; /* NULL terminated */ BufferSize = 20 + Message_Length; buffer = malloc(BufferSize); if (buffer != NULL) { @@ -1588,9 +1606,9 @@ static int proxytrack_start_ICP(PT_Indexes indexes, T_SOC soc) { unsigned char Version = buffer[1]; unsigned short Message_Length = READ_NET16(&buffer[2]); unsigned int Request_Number = READ_NET32(&buffer[4]); /* Session ID */ - unsigned int Options = READ_NET32(&buffer[8]); - unsigned int Option_Data = READ_NET32(&buffer[12]); /* ICP_FLAG_SRC_RTT */ - unsigned int Sender_Host_Address = READ_NET32(&buffer[16]); /* ignored */ + //unsigned int Options = READ_NET32(&buffer[8]); + //unsigned int Option_Data = READ_NET32(&buffer[12]); /* ICP_FLAG_SRC_RTT */ + //unsigned int Sender_Host_Address = READ_NET32(&buffer[16]); /* ignored */ unsigned char *Payload = &buffer[20]; buffer[bufferSize] = '\0'; /* Ensure payload is NULL terminated */ @@ -1609,14 +1627,14 @@ static int proxytrack_start_ICP(PT_Indexes indexes, T_SOC soc) { ICP_reply(&clientAddr, clientAddrLen, soc, ICP_OP_DENIED, Version, 0, Request_Number, 0, 0, 0, UrlRequest); LogReply = "ICP_OP_DENIED"; - } else if (PT_LookupIndex(indexes, UrlRequest)) { + } else if (PT_LookupIndex(indexes, (char*) UrlRequest)) { ICP_reply(&clientAddr, clientAddrLen, soc, ICP_OP_HIT, Version, 0, Request_Number, 0, 0, 0, UrlRequest); LogReply = "ICP_OP_HIT"; } else { if (UrlRequestSize > 0 && UrlRequest[UrlRequestSize - 1] != '/' - && strchr(UrlRequest, '?') == NULL) { + && strchr((char*) UrlRequest, '?') == NULL) { char *UrlRedirect = malloc(UrlRequestSize + 1 + 1); if (UrlRedirect != NULL) { @@ -1681,7 +1699,7 @@ static int proxytrack_start_ICP(PT_Indexes indexes, T_SOC soc) { StringCopy(ip, "unknown"); } proxytrack_print_log(LOG, "ICP %s %s/%s %s", StringBuff(ip), LogRequest, - LogReply, (UrlRequest ? UrlRequest : "-")); + LogReply, (UrlRequest ? (char*) UrlRequest : "-")); StringFree(ip); } @@ -1698,11 +1716,14 @@ static int proxytrack_start_ICP(PT_Indexes indexes, T_SOC soc) { return 1; } +static void proxytrack_start_ICP_th(PT_Indexes indexes, T_SOC soc) { + (void) proxytrack_start_ICP(indexes, soc); +} + static int proxytrack_start(PT_Indexes indexes, T_SOC soc, T_SOC socICP) { int ret = 1; - if (proxytrack_process_generic(proxytrack_start_ICP, indexes, socICP)) { - //if (!proxytrack_process_generic(proxytrack_start_HTTP, indexes, soc)) + if (proxytrack_process_generic(proxytrack_start_ICP_th, indexes, socICP)) { if (!proxytrack_start_HTTP(indexes, soc)) { ret = 0; } diff --git a/src/proxy/proxytrack.h b/src/proxy/proxytrack.h index 6152919..ac476b0 100644 --- a/src/proxy/proxytrack.h +++ b/src/proxy/proxytrack.h @@ -65,7 +65,7 @@ int proxytrack_main(char *proxyAddr, int proxyPort, char *icpAddr, int icpPort, /* Static definitions */ -static void proxytrack_print_log(const char *severity, const char *format, ...) { +HTS_UNUSED static void proxytrack_print_log(const char *severity, const char *format, ...) { if (severity != NULL) { const int error = errno; FILE *const fp = stderr; @@ -110,7 +110,7 @@ static void proxytrack_print_log(const char *severity, const char *format, ...) "<!-- _-._.--._._-._.--._._-._.--._._-._.--._._-._.--._. -->\r\n" \ "<!-- End Disable IE Friendly HTTP Error Messages -->\r\n" -static char *gethomedir(void) { +HTS_UNUSED static char *gethomedir(void) { char *home = getenv("HOME"); if (home) @@ -119,7 +119,7 @@ static char *gethomedir(void) { return "."; } -static int linput(FILE * fp, char *s, int max) { +HTS_UNUSED static int linput(FILE * fp, char *s, int max) { int c; int j = 0; @@ -146,7 +146,7 @@ static int linput(FILE * fp, char *s, int max) { return j; } -static int link_has_authority(const char *lien) { +HTS_UNUSED static int link_has_authority(const char *lien) { const char *a = lien; if (isalpha((const unsigned char) *a)) { @@ -163,7 +163,7 @@ static int link_has_authority(const char *lien) { return 0; } -static const char *jump_protocol(const char *source) { +HTS_UNUSED static const char *jump_protocol(const char *source) { int p; // scheme @@ -184,7 +184,7 @@ static const char *jump_protocol(const char *source) { return source; } -static const char *strrchr_limit(const char *s, char c, const char *limit) { +HTS_UNUSED static const char *strrchr_limit(const char *s, char c, const char *limit) { if (limit == NULL) { char *p = strrchr(s, c); @@ -201,7 +201,7 @@ static const char *strrchr_limit(const char *s, char c, const char *limit) { } } -static const char *jump_protocol_and_auth(const char *source) { +HTS_UNUSED static const char *jump_protocol_and_auth(const char *source) { const char *a, *trytofind; if (strcmp(source, "file://") == 0) @@ -217,7 +217,7 @@ static const char *jump_protocol_and_auth(const char *source) { #ifndef max #define max(a,b) ((a)>(b)?(a):(b)) #endif -static int linput_trim(FILE * fp, char *s, int max) { +HTS_UNUSED static int linput_trim(FILE * fp, char *s, int max) { int rlen = 0; char *ls = (char *) malloc(max + 2); @@ -251,7 +251,7 @@ static int linput_trim(FILE * fp, char *s, int max) { #ifndef S_ISREG #define S_ISREG(m) ((m) & _S_IFREG) #endif -static int fexist(char *s) { +HTS_UNUSED static int fexist(char *s) { struct stat st; memset(&st, 0, sizeof(st)); @@ -264,14 +264,14 @@ static int fexist(char *s) { } /* convertir une chaine en temps */ -static void set_lowcase(char *s) { +HTS_UNUSED static void set_lowcase(char *s) { int i; for(i = 0; i < (int) strlen(s); i++) if ((s[i] >= 'A') && (s[i] <= 'Z')) s[i] += ('a' - 'A'); } -static struct tm *convert_time_rfc822(struct tm *result, const char *s) { +HTS_UNUSED static struct tm *convert_time_rfc822(struct tm *result, const char *s) { char months[] = "jan feb mar apr may jun jul aug sep oct nov dec"; char str[256]; char *a; @@ -363,7 +363,7 @@ static struct tm *convert_time_rfc822(struct tm *result, const char *s) { } return NULL; } -static struct tm PT_GetTime(time_t t) { +HTS_UNUSED static struct tm PT_GetTime(time_t t) { struct tm tmbuf; #ifdef _WIN32 @@ -378,7 +378,7 @@ static struct tm PT_GetTime(time_t t) { return tmbuf; } } -static int set_filetime(const char *file, struct tm *tm_time) { +HTS_UNUSED static int set_filetime(const char *file, struct tm *tm_time) { struct utimbuf tim; #ifndef HTS_DO_NOT_USE_FTIME @@ -394,7 +394,7 @@ static int set_filetime(const char *file, struct tm *tm_time) { #endif return utime(file, &tim); } -static int set_filetime_time_t(const char *file, time_t t) { +HTS_UNUSED static int set_filetime_time_t(const char *file, time_t t) { if (t != (time_t) 0 && t != (time_t) - 1) { struct tm tm = PT_GetTime(t); @@ -402,7 +402,7 @@ static int set_filetime_time_t(const char *file, time_t t) { } return -1; } -static int set_filetime_rfc822(const char *file, const char *date) { +HTS_UNUSED static int set_filetime_rfc822(const char *file, const char *date) { struct tm buffer; struct tm *tm_s = convert_time_rfc822(&buffer, date); diff --git a/src/proxy/store.c b/src/proxy/store.c index 2f2b92c..4ad4a0c 100644 --- a/src/proxy/store.c +++ b/src/proxy/store.c @@ -467,7 +467,7 @@ char **PT_Enumerate(PT_Indexes indexes, const char *url, int subtree) { if (isFolder) StringCat(list, "/"); StringMemcat(list, "\0", 1); /* NULL terminated strings */ - StringMemcat(listindexes, &ptr, sizeof(ptr)); + StringMemcat(listindexes, (char*) &ptr, sizeof(ptr)); listCount++; inthash_write(hdupes, StringBuff(subitem), 0); } @@ -488,7 +488,7 @@ char **PT_Enumerate(PT_Indexes indexes, const char *url, int subtree) { char *startStrings; /* NULL terminated index */ - StringMemcat(listindexes, &nullPointer, sizeof(nullPointer)); + StringMemcat(listindexes, (char*) &nullPointer, sizeof(nullPointer)); /* start of all strings (index) */ startStrings = nullPointer + StringLength(listindexes); /* copy list of URLs after indexes */ @@ -1030,7 +1030,7 @@ static PT_Element PT_ReadCache__New_u(PT_Index index_, const char *url, if (unzOpenCurrentFile(index->zFile) == Z_OK) { char headerBuff[8192 + 2]; int readSizeHeader; - int totalHeader = 0; + //int totalHeader = 0; int dataincache = 0; /* For BIG comments */ @@ -1086,7 +1086,7 @@ static PT_Element PT_ReadCache__New_u(PT_Index index_, const char *url, } } } while(offset < readSizeHeader && !lineEof); - totalHeader = offset; + //totalHeader = offset; /* Previous entry */ if (previous_save_[0] != '\0') { @@ -1257,7 +1257,7 @@ static int PT_SaveCache__New_Fun(void *arg, const char *url, PT_Element element) } /* 64 characters MAX for first line */ sprintf(headers + headersSize, "HTTP/1.%c %d %s\r\n", '1', - element->statuscode, element->msg); + element->statuscode, message); } headersSize += (int) strlen(headers + headersSize); @@ -1300,9 +1300,7 @@ static int PT_SaveCache__New_Fun(void *arg, const char *url, PT_Element element) */ headers, (uInt) strlen(headers), NULL, 0, NULL, /* comment */ Z_DEFLATED, Z_DEFAULT_COMPRESSION)) != Z_OK) { - int zip_zipOpenNewFileInZip_failed = 0; - - assertf(zip_zipOpenNewFileInZip_failed); + assertf(! "zip_zipOpenNewFileInZip_failed"); } /* Write data in cache */ @@ -1310,24 +1308,18 @@ static int PT_SaveCache__New_Fun(void *arg, const char *url, PT_Element element) if ((zErr = zipWriteInFileInZip(zFileOut, element->adr, (int) element->size)) != Z_OK) { - int zip_zipWriteInFileInZip_failed = 0; - - assertf(zip_zipWriteInFileInZip_failed); + assertf(! "zip_zipWriteInFileInZip_failed"); } } /* Close */ if ((zErr = zipCloseFileInZip(zFileOut)) != Z_OK) { - int zip_zipCloseFileInZip_failed = 0; - - assertf(zip_zipCloseFileInZip_failed); + assertf(! "zip_zipCloseFileInZip_failed"); } /* Flush */ if ((zErr = zipFlush(zFileOut)) != 0) { - int zip_zipFlush_failed = 0; - - assertf(zip_zipFlush_failed); + assertf(! "zip_zipFlush_failed"); } return 0; @@ -1379,9 +1371,7 @@ static void cache_rstr(FILE * fp, char *s) { i = 0; if (i > 0) { if ((int) fread(s, 1, i, fp) != i) { - int fread_cache_failed = 0; - - assertf(fread_cache_failed); + assertf(! "fread_cache_failed"); } } *(s + i) = '\0'; @@ -1400,9 +1390,7 @@ static char *cache_rstr_addr(FILE * fp) { addr = malloc(i + 1); if (addr != NULL) { if ((int) fread(addr, 1, i, fp) != i) { - int fread_cache_failed = 0; - - assertf(fread_cache_failed); + assertf(! "fread_cache_failed"); } *(addr + i) = '\0'; } |