summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/htsbase.h225
-rw-r--r--src/htscore.c4
-rw-r--r--src/htscoremain.c10
-rw-r--r--src/htsmodules.c24
-rw-r--r--src/htsparse.c8
-rw-r--r--src/htssafe.h145
-rw-r--r--src/httrack.h159
-rw-r--r--src/proxy/proxytrack.c4
-rw-r--r--src/proxy/store.c3
9 files changed, 156 insertions, 426 deletions
diff --git a/src/htsbase.h b/src/htsbase.h
index fcda7a8..a3d7743 100644
--- a/src/htsbase.h
+++ b/src/htsbase.h
@@ -40,6 +40,7 @@ extern "C" {
#include "htsglobal.h"
#include "htsstrings.h"
+#include "htssafe.h"
#include <string.h>
#include <time.h>
@@ -106,230 +107,6 @@ extern "C" {
#define DynamicGet(handle, sym) dlsym(handle, sym)
#endif
-// emergency log
- typedef void (*t_abortLog) (char *msg, char *file, int line);
- extern HTSEXT_API t_abortLog abortLog__;
-#define abortLog(a) abortLog__(a, __FILE__, __LINE__)
-#define _ ,
-#define abortLogFmt(a) do { \
- FILE* fp = fopen("CRASH.TXT", "wb"); \
- if (!fp) fp = fopen("/tmp/CRASH.TXT", "wb"); \
- if (!fp) fp = fopen("C:\\CRASH.TXT", "wb"); \
- if (!fp) fp = fopen("\\Temp\\CRASH.TXT", "wb"); \
- if (!fp) fp = fopen("\\CRASH.TXT", "wb"); \
- if (!fp) fp = fopen("CRASH.TXT", "wb"); \
- if (fp) { \
- fprintf(fp, "HTTrack " HTTRACK_VERSIONID " closed at '" __FILE__ "', line %d\r\n", __LINE__); \
- fprintf(fp, "Reason:\r\n"); \
- fprintf(fp, a); \
- fprintf(fp, "\r\n"); \
- fflush(fp); \
- fclose(fp); \
- } \
-} while(0)
-
-#define assertf(exp) do { \
- if (! ( exp ) ) { \
- abortLog("assert failed: " #exp); \
- if (htsCallbackErr != NULL) { \
- htsCallbackErr("assert failed: " #exp, __FILE__ , __LINE__ ); \
- } \
- abort(); \
- } \
-} while(0)
-/* non-fatal assert */
-#define assertnf(exp) do { \
- if (! ( exp ) ) { \
- abortLog("assert failed: " #exp); \
- if (htsCallbackErr != NULL) { \
- htsCallbackErr("assert failed: " #exp, __FILE__ , __LINE__ ); \
- } \
- } \
-} while(0)
-
-/* regular malloc's() */
-#ifndef HTS_TRACE_MALLOC
-#define malloct(A) malloc(A)
-#define calloct(A,B) calloc((A), (B))
-#define freet(A) do { assertnf((A) != NULL); if ((A) != NULL) { free(A); (A) = NULL; } } while(0)
-#define strdupt(A) strdup(A)
-#define realloct(A,B) ( ((A) != NULL) ? realloc((A), (B)) : malloc(B) )
-#define memcpybuff(A, B, N) memcpy((A), (B), (N))
-#else
-/* debug version */
-#define malloct(A) hts_malloc(A)
-#define calloct(A,B) hts_calloc(A,B)
-#define strdupt(A) hts_strdup(A)
-#define freet(A) do { hts_free(A); (A) = NULL; } while(0)
-#define realloct(A,B) hts_realloc(A,B)
- void hts_freeall();
- void *hts_malloc(size_t);
- void *hts_calloc(size_t, size_t);
- char *hts_strdup(char *);
- void *hts_xmalloc(size_t, size_t);
- void hts_free(void *);
- void *hts_realloc(void *, size_t);
- mlink *hts_find(char *adr);
-/* protected memcpy */
-#define memcpybuff(A, B, N) do { \
- mlink* lnk = hts_find((void*)(A)); \
- if (lnk != NULL) { \
- assertf(lnk != NULL); \
- assertf( * ( (t_htsboundary*) ( ((char*) lnk->adr) - sizeof(htsboundary) ) ) == htsboundary ); \
- assertf( * ( (t_htsboundary*) ( ((char*) lnk->adr) + lnk->len ) ) == htsboundary ); \
- assertf( ( ((char*)(A)) + (N)) < (char*) (lnk->adr + lnk->len) ); \
- } \
- memcpy(A, B, N); \
-} while(0)
-
-#endif
-
- typedef void (*htsErrorCallback) (char *msg, char *file, int line);
- extern HTSEXT_API htsErrorCallback htsCallbackErr;
- extern HTSEXT_API int htsMemoryFastXfr;
-
-/*
-*/
-
-#define stringdup()
-
-#ifdef STRDEBUG
-
-/* protected strcat, strncat and strcpy - definitely useful */
-#define strcatbuff(A, B) do { \
- assertf( (A) != NULL ); \
- assertf( (B) != NULL ); \
- if (htsMemoryFastXfr) { \
- if (sizeof(A) != sizeof(char*)) { \
- (A)[sizeof(A) - 1] = '\0'; \
- } \
- strcat(A, B); \
- if (sizeof(A) != sizeof(char*)) { \
- assertf((A)[sizeof(A) - 1] == '\0'); \
- } \
- } else { \
- unsigned int sz = (unsigned int) strlen(A); \
- unsigned int szf = (unsigned int) strlen(B); \
- if (sizeof(A) != sizeof(char*)) { \
- assertf(sz + szf + 1 < sizeof(A)); \
- if (szf > 0) { \
- if (sz + szf + 1 < sizeof(A)) { \
- memcpy((A) + sz, (B), szf + 1); \
- } \
- } \
- } else if (szf > 0) { \
- memcpybuff((A) + sz, (B), szf + 1); \
- } \
- } \
-} while(0)
-#define strncatbuff(A, B, N) do { \
- assertf( (A) != NULL ); \
- assertf( (B) != NULL ); \
- if (htsMemoryFastXfr) { \
- if (sizeof(A) != sizeof(char*)) { \
- (A)[sizeof(A) - 1] = '\0'; \
- } \
- strncat(A, B, N); \
- if (sizeof(A) != sizeof(char*)) { \
- assertf((A)[sizeof(A) - 1] == '\0'); \
- } \
- } else { \
- unsigned int sz = (unsigned int) strlen(A); \
- unsigned int szf = (unsigned int) strlen(B); \
- if (szf > (unsigned int) (N)) szf = (unsigned int) (N); \
- if (sizeof(A) != sizeof(char*)) { \
- assertf(sz + szf + 1 < sizeof(A)); \
- if (szf > 0) { \
- if (sz + szf + 1 < sizeof(A)) { \
- memcpy((A) + sz, (B), szf); \
- * ( (A) + sz + szf) = '\0'; \
- } \
- } \
- } else if (szf > 0) { \
- memcpybuff((A) + sz, (B), szf); \
- * ( (A) + sz + szf) = '\0'; \
- } \
- } \
-} while(0)
-#define strcpybuff(A, B) do { \
- assertf( (A) != NULL ); \
- assertf( (const char*) (B) != NULL ); \
- if (htsMemoryFastXfr) { \
- if (sizeof(A) != sizeof(char*)) { \
- (A)[sizeof(A) - 1] = '\0'; \
- } \
- strcpy(A, B); \
- if (sizeof(A) != sizeof(char*)) { \
- assertf((A)[sizeof(A) - 1] == '\0'); \
- } \
- } else { \
- unsigned int szf = (unsigned int) strlen(B); \
- if (sizeof(A) != sizeof(char*)) { \
- assertf(szf + 1 < sizeof(A)); \
- if (szf > 0) { \
- if (szf + 1 < sizeof(A)) { \
- memcpy((A), (B), szf + 1); \
- } else { \
- * (A) = '\0'; \
- } \
- } else { \
- * (A) = '\0'; \
- } \
- } else { \
- memcpybuff((A), (B), szf + 1); \
- } \
- } \
-} while(0)
-
-#else
-
-#ifdef STRDEBUGFAST
-
-/* protected strcat, strncat and strcpy - definitely useful */
-#define strcatbuff(A, B) do { \
- assertf( (A) != NULL ); \
- assertf( (B) != NULL ); \
- if (sizeof(A) != sizeof(char*)) { \
- (A)[sizeof(A) - 1] = '\0'; \
- } \
- strcat(A, B); \
- if (sizeof(A) != sizeof(char*)) { \
- assertf((A)[sizeof(A) - 1] == '\0'); \
- } \
-} while(0)
-#define strncatbuff(A, B, N) do { \
- assertf( (A) != NULL ); \
- assertf( (B) != NULL ); \
- if (sizeof(A) != sizeof(char*)) { \
- (A)[sizeof(A) - 1] = '\0'; \
- } \
- strncat(A, B, N); \
- if (sizeof(A) != sizeof(char*)) { \
- assertf((A)[sizeof(A) - 1] == '\0'); \
- } \
-} while(0)
-#define strcpybuff(A, B) do { \
- assertf( (A) != NULL ); \
- assertf( (B) != NULL ); \
- if (sizeof(A) != sizeof(char*)) { \
- (A)[sizeof(A) - 1] = '\0'; \
- } \
- strcpy(A, B); \
- if (sizeof(A) != sizeof(char*)) { \
- assertf((A)[sizeof(A) - 1] == '\0'); \
- } \
-} while(0)
-
-#else
-
-#define strcatbuff strcat
-#define strncatbuff strncat
-#define strcpybuff strcpy
-
-#endif
-
-#endif
-
#endif
#ifdef __cplusplus
diff --git a/src/htscore.c b/src/htscore.c
index 629d3f6..65bb101 100644
--- a/src/htscore.c
+++ b/src/htscore.c
@@ -650,15 +650,11 @@ int httpmirror(char *url1, httrackp * opt) {
// Initialiser cache
{
- int backupXFR = htsMemoryFastXfr;
-
opt->state._hts_in_html_parsing = 4;
if (!RUN_CALLBACK7(opt, loop, NULL, 0, 0, 0, lien_tot, 0, NULL)) {
opt->state.exit_xh = 1; // exit requested
}
- htsMemoryFastXfr = 1; /* fast load */
cache_init(&cache, opt);
- htsMemoryFastXfr = backupXFR;
opt->state._hts_in_html_parsing = 0;
}
diff --git a/src/htscoremain.c b/src/htscoremain.c
index 82af9e0..1fd1b83 100644
--- a/src/htscoremain.c
+++ b/src/htscoremain.c
@@ -1984,7 +1984,6 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp * opt) {
char *filter = NULL;
cache_back cache;
inthash cache_hashtable = inthash_new(0);
- int backupXFR = htsMemoryFastXfr;
int sendb = 0;
if (isdigit((unsigned char) *(com + 1))) {
@@ -1998,7 +1997,6 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp * opt) {
hasFilter = 1;
filter = argv[na];
}
- htsMemoryFastXfr = 1; /* fast load */
memset(&cache, 0, sizeof(cache_back));
cache.type = 1; // cache?
@@ -2150,7 +2148,6 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp * opt) {
(hasFilter) ? " for '" : "",
(hasFilter) ? filter : "", (hasFilter) ? "'" : "");
}
- htsMemoryFastXfr = backupXFR;
return 0;
}
break;
@@ -2163,13 +2160,8 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp * opt) {
return 0;
break;
case 'X':
-#ifndef STRDEBUG
- fprintf(stderr,
- "warning: no string debugging support built, option has no effect\n");
-#endif
- htsMemoryFastXfr = 1;
+ fprintf(stderr, "warning: option has no effect\n");
if (*(com + 1) == '0') {
- htsMemoryFastXfr = 0;
com++;
}
break;
diff --git a/src/htsmodules.c b/src/htsmodules.c
index 50fa0db..656cd6a 100644
--- a/src/htsmodules.c
+++ b/src/htsmodules.c
@@ -89,30 +89,6 @@ HTSEXT_API const char *hts_get_version_info(httrackp * opt) {
return opt->state.HTbuff;
}
-/* memory checks */
-HTSEXT_API htsErrorCallback htsCallbackErr = NULL;
-HTSEXT_API int htsMemoryFastXfr = 1; /* fast xfr by default */
-void abortLog__fnc(char *msg, char *file, int line);
-void abortLog__fnc(char *msg, char *file, int line) {
- FILE *fp = fopen("CRASH.TXT", "wb");
-
- if (!fp)
- fp = fopen("/tmp/CRASH.TXT", "wb");
- if (!fp)
- fp = fopen("C:\\CRASH.TXT", "wb");
- if (!fp)
- fp = fopen("CRASH.TXT", "wb");
- if (fp) {
- fprintf(fp, "HTTrack " HTTRACK_VERSIONID " closed at '%s', line %d\r\n",
- file, line);
- fprintf(fp, "Reason:\r\n%s\r\n", msg);
- fflush(fp);
- fclose(fp);
- }
-}
-
-HTSEXT_API t_abortLog abortLog__ = abortLog__fnc; /* avoid VC++ inlining */
-
static void htspe_log(htsmoduleStruct * str, const char *msg);
int hts_parse_externals(htsmoduleStruct * str) {
diff --git a/src/htsparse.c b/src/htsparse.c
index 606ecb6..23d7dd2 100644
--- a/src/htsparse.c
+++ b/src/htsparse.c
@@ -77,12 +77,14 @@ Please visit our Website: http://www.httrack.com
// version optimisée, qui permet de ne pas toucher aux html non modifiés (update)
#define REALLOC_SIZE 8192
#define HT_ADD_CHK(A) if (((int) (A)+ht_len+1) >= ht_size) { \
+ char message[256]; \
ht_size=(A)+ht_len+REALLOC_SIZE; \
ht_buff=(char*) realloct(ht_buff,ht_size); \
if (ht_buff==NULL) { \
printf("PANIC! : Not enough memory [%d]\n", __LINE__); \
XH_uninit; \
- abortLogFmt("not enough memory for current html document in HT_ADD_CHK : realloct("LLintP") failed" _ (LLint) ht_size); \
+ snprintf(message, sizeof(message), "not enough memory for current html document in HT_ADD_CHK : realloct("LLintP") failed", (LLint) ht_size); \
+ abortLog(message); \
abort(); \
} \
} \
@@ -127,6 +129,7 @@ Please visit our Website: http://www.httrack.com
ht_buff[j_+i_]='\0'; \
} }
#define HT_ADD_START \
+ char message[256]; \
size_t ht_size=(size_t)(r->size*5)/4+REALLOC_SIZE; \
size_t ht_len=0; \
char* ht_buff=NULL; \
@@ -135,7 +138,8 @@ Please visit our Website: http://www.httrack.com
if (ht_buff==NULL) { \
printf("PANIC! : Not enough memory [%d]\n",__LINE__); \
XH_uninit; \
- abortLogFmt("not enough memory for current html document in HT_ADD_START : malloct("LLintP") failed" _ (LLint) ht_size); \
+ snprintf(message, sizeof(message), "not enough memory for current html document in HT_ADD_START : malloct("LLintP") failed", (LLint) ht_size); \
+ abortLog(message); \
abort(); \
} \
ht_buff[0]='\0'; \
diff --git a/src/htssafe.h b/src/htssafe.h
new file mode 100644
index 0000000..4768494
--- /dev/null
+++ b/src/htssafe.h
@@ -0,0 +1,145 @@
+/* ------------------------------------------------------------ */
+/*
+HTTrack Website Copier, Offline Browser for Windows and Unix
+Copyright (C) 1998-2014 Xavier Roche and other contributors
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Important notes:
+
+- We hereby ask people using this source NOT to use it in purpose of grabbing
+emails addresses, or collecting any other private information on persons.
+This would disgrace our work, and spoil the many hours we spent on it.
+
+Please visit our Website: http://www.httrack.com
+*/
+
+/* ------------------------------------------------------------ */
+/* File: htssafe.h safe strings operations, and asserts */
+/* Author: Xavier Roche */
+/* ------------------------------------------------------------ */
+
+#ifndef HTSSAFE_DEFH
+#define HTSSAFE_DEFH
+
+#include "htsglobal.h"
+
+/**
+ * Optional user-defined callback upon fatal error.
+ */
+typedef void (*htsErrorCallback) (const char *msg, const char *file, int line);
+
+/**
+ * Emergency logging.
+ */
+#ifndef HTSSAFE_ABORT_FUNCTION
+HTSEXT_API htsErrorCallback htsCallbackErr;
+#define HTSSAFE_ABORT_FUNCTION(A,B,C) do { if (htsCallbackErr != NULL) { htsCallbackErr(A,B,C); } } while(0)
+#endif
+
+/**
+ * Log an abort condition, and calls abort().
+ */
+#define abortLog(a) abortf_(a, __FILE__, __LINE__)
+
+/**
+ * Fatal assertion check.
+ */
+#define assertf__(exp, sexp, file, line) (void) ( (exp) || (abortf_(sexp, file, line), 0) )
+
+/**
+ * Fatal assertion check.
+ */
+#define assertf_(exp, file, line) assertf__(exp, #exp, __FILE__, __LINE__)
+
+/**
+ * Fatal assertion check.
+ */
+#define assertf(exp) assertf_(exp, __FILE__, __LINE__)
+
+static void log_abort_(const char *msg, const char *file, int line) {
+ fprintf(stderr, "%s failed at %s:%d\n", msg, file, line);
+ fflush(stderr);
+}
+
+static void abortf_(const char *exp, const char *file, int line) {
+ HTSSAFE_ABORT_FUNCTION(exp, file, line);
+ log_abort_(exp, file, line);
+ abort();
+}
+
+/**
+ * Append at most N characters from "B" to "A".
+ * If "A" is a char[] variable whose size is not sizeof(char*), then the size
+ * is assumed to be the capacity of this array.
+ */
+#define strncatbuff(A, B, N) \
+ ( sizeof(A) == sizeof(char*) \
+ ? strncat(A, B, N) \
+ : strncat_safe_(A, sizeof(A), B, \
+ sizeof(B) == sizeof(char*) ? (size_t) -1 : sizeof(B), N, \
+ "overflow while copying '" #B "' to '"#A"'", __FILE__, __LINE__) )
+
+/* note: "size_t is an unsigned integral type" */
+
+/**
+ * Append characters of "B" to "A".
+ * If "A" is a char[] variable whose size is not sizeof(char*), then the size
+ * is assumed to be the capacity of this array.
+ */
+#define strcatbuff(A, B) strncatbuff(A, B, (size_t) -1)
+
+/**
+ * Copy characters of "B" to "A".
+ * If "A" is a char[] variable whose size is not sizeof(char*), then the size
+ * is assumed to be the capacity of this array.
+ */
+#define strcpybuff(A, B) strcatbuff(clear_buffer_(A), B)
+
+static HTS_INLINE size_t strlen_safe_(const char *source, const size_t sizeof_source,
+ const char *file, int line) {
+ size_t size;
+ assertf_( source != NULL, file, line );
+ size = strnlen(source, sizeof_source);
+ assertf_( size < sizeof_source, file, line );
+ return size;
+}
+
+static HTS_INLINE char* clear_buffer_(char *buffer) {
+ buffer[0] = '\0';
+ return buffer;
+}
+
+static HTS_INLINE char* strncat_safe_(char *const dest, const size_t sizeof_dest,
+ const char *const source, const size_t sizeof_source,
+ const size_t n,
+ const char *exp, const char *file, int line) {
+ const size_t source_len = strlen_safe_(source, sizeof_source, file, line);
+ const size_t dest_len = strlen_safe_(dest, sizeof_dest, file, line);
+ const size_t source_copy = source_len <= n ? source_len : n;
+ const size_t dest_final_len = dest_len + source_copy;
+ assertf__(dest_final_len < sizeof_dest, exp, file, line);
+ memcpy(dest + dest_len, source, source_copy);
+ dest[dest_final_len] = '\0';
+ return dest;
+}
+
+#define malloct(A) malloc(A)
+#define calloct(A,B) calloc((A), (B))
+#define freet(A) do { if ((A) != NULL) { free(A); (A) = NULL; } } while(0)
+#define strdupt(A) strdup(A)
+#define realloct(A,B) realloc(A, B)
+#define memcpybuff(A, B, N) memcpy((A), (B), (N))
+
+#endif
diff --git a/src/httrack.h b/src/httrack.h
index 360e472..da8e0f9 100644
--- a/src/httrack.h
+++ b/src/httrack.h
@@ -35,6 +35,7 @@ Please visit our Website: http://www.httrack.com
#include "htsglobal.h"
#include "htscore.h"
+#include "htssafe.h"
#ifndef HTS_DEF_FWSTRUCT_t_StatsBuffer
#define HTS_DEF_FWSTRUCT_t_StatsBuffer
@@ -83,164 +84,6 @@ struct t_InpInfo {
int main(int argc, char **argv);
#endif
-/* */
-
-// Engine internal variables
-typedef void (*htsErrorCallback) (char *msg, char *file, int line);
-extern HTSEXT_API htsErrorCallback htsCallbackErr;
-extern HTSEXT_API int htsMemoryFastXfr;
-
-/* */
extern HTSEXT_API hts_stat_struct HTS_STAT;
extern int _DEBUG_HEAD;
extern FILE *ioinfo;
-
-// from htsbase.h
-
-/* protected strcat, strncat and strcpy - definitely useful */
-#define strcatbuff(A, B) do { \
- assertf( (A) != NULL ); \
- assertf( (B) != NULL ); \
- if (htsMemoryFastXfr) { \
- if (sizeof(A) != sizeof(char*)) { \
- (A)[sizeof(A) - 1] = '\0'; \
- } \
- strcat(A, B); \
- if (sizeof(A) != sizeof(char*)) { \
- assertf((A)[sizeof(A) - 1] == '\0'); \
- } \
- } else { \
- unsigned int sz = (unsigned int) strlen(A); \
- unsigned int szf = (unsigned int) strlen(B); \
- if (sizeof(A) != sizeof(char*)) { \
- assertf(sz + szf + 1 < sizeof(A)); \
- if (szf > 0) { \
- if (sz + szf + 1 < sizeof(A)) { \
- memcpy((A) + sz, (B), szf + 1); \
- } \
- } \
- } else if (szf > 0) { \
- memcpybuff((A) + sz, (B), szf + 1); \
- } \
- } \
-} while(0)
-#define strncatbuff(A, B, N) do { \
- assertf( (A) != NULL ); \
- assertf( (B) != NULL ); \
- if (htsMemoryFastXfr) { \
- if (sizeof(A) != sizeof(char*)) { \
- (A)[sizeof(A) - 1] = '\0'; \
- } \
- strncat(A, B, N); \
- if (sizeof(A) != sizeof(char*)) { \
- assertf((A)[sizeof(A) - 1] == '\0'); \
- } \
- } else { \
- unsigned int sz = (unsigned int) strlen(A); \
- unsigned int szf = (unsigned int) strlen(B); \
- if (szf > (unsigned int) (N)) szf = (unsigned int) (N); \
- if (sizeof(A) != sizeof(char*)) { \
- assertf(sz + szf + 1 < sizeof(A)); \
- if (szf > 0) { \
- if (sz + szf + 1 < sizeof(A)) { \
- memcpy((A) + sz, (B), szf); \
- * ( (A) + sz + szf) = '\0'; \
- } \
- } \
- } else if (szf > 0) { \
- memcpybuff((A) + sz, (B), szf); \
- * ( (A) + sz + szf) = '\0'; \
- } \
- } \
-} while(0)
-#define strcpybuff(A, B) do { \
- assertf( (A) != NULL ); \
- assertf( (const char*) (B) != NULL ); \
- if (htsMemoryFastXfr) { \
- if (sizeof(A) != sizeof(char*)) { \
- (A)[sizeof(A) - 1] = '\0'; \
- } \
- strcpy(A, B); \
- if (sizeof(A) != sizeof(char*)) { \
- assertf((A)[sizeof(A) - 1] == '\0'); \
- } \
- } else { \
- unsigned int szf = (unsigned int) strlen(B); \
- if (sizeof(A) != sizeof(char*)) { \
- assertf(szf + 1 < sizeof(A)); \
- if (szf > 0) { \
- if (szf + 1 < sizeof(A)) { \
- memcpy((A), (B), szf + 1); \
- } else { \
- * (A) = '\0'; \
- } \
- } else { \
- * (A) = '\0'; \
- } \
- } else { \
- memcpybuff((A), (B), szf + 1); \
- } \
- } \
-} while(0)
-
-// emergency log
-typedef void (*t_abortLog) (char *msg, char *file, int line);
-extern HTSEXT_API t_abortLog abortLog__;
-
-#define abortLog(a) abortLog__(a, __FILE__, __LINE__)
-#define abortLogFmt(a) do { \
- FILE* fp = fopen("CRASH.TXT", "wb"); \
- if (!fp) fp = fopen("/tmp/CRASH.TXT", "wb"); \
- if (!fp) fp = fopen("C:\\CRASH.TXT", "wb"); \
- if (fp) { \
- fprintf(fp, "HTTrack " HTTRACK_VERSIONID " closed at '" __FILE__ "', line %d\r\n", __LINE__); \
- fprintf(fp, "Reason:\r\n"); \
- fprintf(fp, a); \
- fprintf(fp, "\r\n"); \
- fflush(fp); \
- fclose(fp); \
- } \
-} while(0)
-
-#define _ ,
-#define abortLogFmt(a) do { \
- FILE* fp = fopen("CRASH.TXT", "wb"); \
- if (!fp) fp = fopen("/tmp/CRASH.TXT", "wb"); \
- if (!fp) fp = fopen("C:\\CRASH.TXT", "wb"); \
- if (fp) { \
- fprintf(fp, "HTTrack " HTTRACK_VERSIONID " closed at '" __FILE__ "', line %d\r\n", __LINE__); \
- fprintf(fp, "Reason:\r\n"); \
- fprintf(fp, a); \
- fprintf(fp, "\r\n"); \
- fflush(fp); \
- fclose(fp); \
- } \
-} while(0)
-#define assertf(exp) do { \
- if (! ( exp ) ) { \
- abortLog("assert failed: " #exp); \
- if (htsCallbackErr != NULL) { \
- htsCallbackErr("assert failed: " #exp, __FILE__ , __LINE__ ); \
- } \
- assert(exp); \
- abort(); \
- } \
-} while(0)
-/* non-fatal assert */
-#define assertnf(exp) do { \
- if (! ( exp ) ) { \
- abortLog("assert failed: " #exp); \
- if (htsCallbackErr != NULL) { \
- htsCallbackErr("assert failed: " #exp, __FILE__ , __LINE__ ); \
- } \
- } \
-} while(0)
-
-//
-
-#define malloct(A) malloc(A)
-#define calloct(A,B) calloc((A), (B))
-#define freet(A) do { assertnf((A) != NULL); if ((A) != NULL) { free(A); (A) = NULL; } } while(0)
-#define strdupt(A) strdup(A)
-#define realloct(A,B) ( ((A) != NULL) ? realloc((A), (B)) : malloc(B) )
-#define memcpybuff(A, B, N) memcpy((A), (B), (N))
diff --git a/src/proxy/proxytrack.c b/src/proxy/proxytrack.c
index e495f73..dabb761 100644
--- a/src/proxy/proxytrack.c
+++ b/src/proxy/proxytrack.c
@@ -103,6 +103,7 @@ Remark: If no cache newer than the added one is found, all entries can be added
*/
/* HTTrack definitions */
+#define HTSSAFE_ABORT_FUNCTION(A,B,C)
#include "htsbase.h"
#include "htsnet.h"
#include "htslib.h"
@@ -145,8 +146,6 @@ Remark: If no cache newer than the added one is found, all entries can be added
#endif
/* External references */
-// htsErrorCallback htsCallbackErr = NULL;
-int htsMemoryFastXfr = 1; /* fast xfr by default */
void abortLog__fnc(char *msg, char *file, int line);
void abortLog__fnc(char *msg, char *file, int line) {
FILE *fp = fopen("CRASH.TXT", "wb");
@@ -166,7 +165,6 @@ void abortLog__fnc(char *msg, char *file, int line) {
}
}
-// HTSEXT_API t_abortLog abortLog__ = abortLog__fnc; /* avoid VC++ inlining */
#define webhttrack_lock(A) do{}while(0)
/* Static definitions */
diff --git a/src/proxy/store.c b/src/proxy/store.c
index 1702bc8..9d756b7 100644
--- a/src/proxy/store.c
+++ b/src/proxy/store.c
@@ -41,6 +41,7 @@ static long int timezone = 0;
#include <pthread.h>
#endif
+#define HTSSAFE_ABORT_FUNCTION(A,B,C)
#include "htsglobal.h"
#define HTS_INTERNAL_BYTECODE
@@ -253,8 +254,6 @@ int PT_RemoveIndex(PT_Indexes index, int indexId) {
return 0;
}
-#define assertf(exp)
-
static int binput(char *buff, char *s, int max) {
int count = 0;
int destCount = 0;