summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Roche <xroche@users.noreply.github.com>2014-06-08 13:02:43 +0000
committerXavier Roche <xroche@users.noreply.github.com>2014-06-08 13:02:43 +0000
commit6d1544383e5c6cbf33dab7526e489a7bf58aacd3 (patch)
tree1e09d693337a6bedde4a15d6afa1f2c83e65a345
parentcd268fd39ed5c64dd1c6b16e3284f10b79bf982b (diff)
Public definitions cleanup (especially for httraqt)
htsopt.h now has the following definitions: * struct htsrequest_proxy * struct htsrequest * struct htsblk * struct lien_url * struct lien_back
-rw-r--r--src/htsbasenet.h8
-rw-r--r--src/htscore.h74
-rw-r--r--src/htsinthash.h8
-rw-r--r--src/htslib.c4
-rw-r--r--src/htslib.h80
-rw-r--r--src/htsmodules.h8
-rw-r--r--src/htsnet.h8
-rw-r--r--src/htsopt.h164
-rw-r--r--src/htssafe.h14
-rw-r--r--src/htsweb.c8
-rw-r--r--src/htswrap.h8
-rw-r--r--src/httrack-library.h3
-rw-r--r--src/httrack.c9
13 files changed, 233 insertions, 163 deletions
diff --git a/src/htsbasenet.h b/src/htsbasenet.h
index a752db5..23901d0 100644
--- a/src/htsbasenet.h
+++ b/src/htsbasenet.h
@@ -59,6 +59,10 @@ Please visit our Website: http://www.httrack.com
#define INVALID_SOCKET -1
#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#if HTS_USEOPENSSL
/*
OpensSSL crypto routines by Eric Young (eay@cryptsoft.com)
@@ -154,4 +158,8 @@ typedef enum HTTrackStatus {
STATUS_FTP_READY = 1001
} HTTrackStatus;
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/src/htscore.h b/src/htscore.h
index 8fd709b..48785f7 100644
--- a/src/htscore.h
+++ b/src/htscore.h
@@ -129,29 +129,6 @@ typedef struct filecreate_params filecreate_params;
#include "hts-indextmpl.h"
-// structure d'un lien
-#ifndef HTS_DEF_FWSTRUCT_lien_url
-#define HTS_DEF_FWSTRUCT_lien_url
-typedef struct lien_url lien_url;
-#endif
-struct lien_url {
- char *adr; // adresse
- char *fil; // nom du fichier distant
- char *sav; // nom à sauver sur disque (avec chemin éventuel)
- char *cod; // chemin codebase éventuel si classe java
- char *former_adr; // adresse initiale (avant éventuel moved), peut être nulle
- char *former_fil; // nom du fichier distant initial (avant éventuel moved), peut être nul
-
- int premier; // pointeur sur le premier lien qui a donné lieu aux autres liens du domaine
- int precedent; // pointeur sur le lien qui a donné lieu à ce lien précis
- int depth; // profondeur autorisée lien ; >0 forte 0=faible
- int pass2; // traiter après les autres, seconde passe. si == -1, lien traité en background
- char link_import; // lien importé à la suite d'un moved - ne pas appliquer les règles classiques up/down
- //int moved; // pointeur sur moved
- int retry; // nombre de retry restants
- int testmode; // mode test uniquement, envoyer juste un head!
-};
-
// adr, fil
#ifndef HTS_DEF_FWSTRUCT_lien_adrfil
#define HTS_DEF_FWSTRUCT_lien_adrfil
@@ -172,57 +149,6 @@ struct lien_adrfilsave {
char save[HTS_URLMAXSIZE * 2]; // nom à sauver sur disque (avec chemin éventuel)
};
-// chargement de fichiers en 'arrière plan'
-#ifndef HTS_DEF_FWSTRUCT_lien_back
-#define HTS_DEF_FWSTRUCT_lien_back
-typedef struct lien_back lien_back;
-#endif
-struct lien_back {
-#if DEBUG_CHECKINT
- char magic;
-#endif
- char url_adr[HTS_URLMAXSIZE * 2]; // adresse
- char url_fil[HTS_URLMAXSIZE * 2]; // nom du fichier distant
- char url_sav[HTS_URLMAXSIZE * 2]; // nom à sauver sur disque (avec chemin éventuel)
- char referer_adr[HTS_URLMAXSIZE * 2]; // adresse host page referer
- char referer_fil[HTS_URLMAXSIZE * 2]; // fichier page referer
- char location_buffer[HTS_URLMAXSIZE * 2]; // "location" en cas de "moved" (302,..)
- char *tmpfile; // nom à sauver temporairement (compressé)
- char tmpfile_buffer[HTS_URLMAXSIZE * 2]; // buffer pour le nom à sauver temporairement
- char send_too[1024]; // données à envoyer en même temps que le header
- int status; // status (-1=non utilisé, 0: prêt, >0: opération en cours)
- int locked; // locked (to be used soon)
- int testmode; // mode de test
- int timeout; // gérer des timeouts? (!=0 : nombre de secondes)
- TStamp timeout_refresh; // si oui, time refresh
- int rateout; // timeout refresh? (!=0 : taux minimum toléré en octets/s)
- TStamp rateout_time; // si oui, date de départ
- LLint maxfile_nonhtml; // taille max d'un fichier non html
- LLint maxfile_html; // idem pour un ficheir html
- htsblk r; // structure htsblk de chaque objet en background
- int is_update; // mode update
- int head_request; // requète HEAD?
- LLint range_req_size; // range utilisé
- TStamp ka_time_start; // refresh time for KA
- //
- int http11; // L'en tête doit être signé HTTP/1.1 et non HTTP/1.0
- int is_chunk; // chunk?
- char *chunk_adr; // adresse chunk en cours de chargement
- LLint chunk_size; // taille chunk en cours de chargement
- LLint chunk_blocksize; // taille data declaree par le chunk
- LLint compressed_size; // taille compressés (stats uniquement)
- //
- //int links_index; // to access liens[links_index]
- //
- char info[256]; // éventuel status pour le ftp
- int stop_ftp; // flag stop pour ftp
- int finalized; // finalized (optim memory)
- int early_add; // was added before link heap saw it
-#if DEBUG_CHECKINT
- char magic2;
-#endif
-};
-
#ifndef HTS_DEF_FWSTRUCT_struct_back
#define HTS_DEF_FWSTRUCT_struct_back
typedef struct struct_back struct_back;
diff --git a/src/htsinthash.h b/src/htsinthash.h
index f8aee07..a2689b6 100644
--- a/src/htsinthash.h
+++ b/src/htsinthash.h
@@ -173,6 +173,10 @@ struct struct_inthash_enum {
/* Library internal definictions */
#ifdef HTS_INTERNAL_BYTECODE
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* Create a new hashtable, with initial bucket size of 'size'.
* If size is 0, use the default minimal bucket size.
@@ -377,6 +381,10 @@ inthash_keys inthash_hash_value(const char *value);
void inthash_set_global_assert_handler(t_inthash_loghandler log,
t_inthash_asserthandler fatal);
+#ifdef __cplusplus
+}
+#endif
+
#endif
#endif
diff --git a/src/htslib.c b/src/htslib.c
index d57ce57..1b29f3a 100644
--- a/src/htslib.c
+++ b/src/htslib.c
@@ -5501,6 +5501,10 @@ HTSEXT_API httrackp *hts_create_opt(void) {
return opt;
}
+HTSEXT_API size_t hts_sizeof_opt(void) {
+ return sizeof(httrackp);
+}
+
HTSEXT_API void hts_free_opt(httrackp * opt) {
if (opt != NULL) {
diff --git a/src/htslib.h b/src/htslib.h
index 222cf88..2212a0b 100644
--- a/src/htslib.h
+++ b/src/htslib.h
@@ -105,86 +105,6 @@ MSVC2003INLINEBUG HTS_STATIC char *getHtsOptBuff_(httrackp * opt) {
#define OPT_GET_BUFF(OPT) ( getHtsOptBuff_(OPT) )
#define OPT_GET_BUFF_SIZE(OPT) ( sizeof(opt->state.concat.buff[0]) )
-// structure pour paramètres supplémentaires lors de la requête
-#ifndef HTS_DEF_FWSTRUCT_htsrequest_proxy
-#define HTS_DEF_FWSTRUCT_htsrequest_proxy
-typedef struct htsrequest_proxy htsrequest_proxy;
-#endif
-struct htsrequest_proxy {
- int active;
- const char* name;
- int port;
- const char* bindhost; // bind this host
-};
-
-#ifndef HTS_DEF_FWSTRUCT_htsrequest
-#define HTS_DEF_FWSTRUCT_htsrequest
-typedef struct htsrequest htsrequest;
-#endif
-struct htsrequest {
- short int user_agent_send; // user agent (ex: httrack/1.0 [sun])
- short int http11; // l'en tête peut (doit) être signé HTTP/1.1 et non HTTP/1.0
- short int nokeepalive; // pas de keep-alive
- short int range_used; // Range utilisé
- short int nocompression; // Pas de compression
- short int flush_garbage; // recycled
- const char* user_agent;
- const char* referer;
- const char* from;
- const char* lang_iso;
- const char* accept;
- const char* headers;
- htsrequest_proxy proxy; // proxy
-};
-
-// structure pour retour d'une connexion/prise d'en tête
-#ifndef HTS_DEF_FWSTRUCT_htsblk
-#define HTS_DEF_FWSTRUCT_htsblk
-typedef struct htsblk htsblk;
-#endif
-struct htsblk {
- int statuscode; // status-code, -1=erreur, 200=OK,201=..etc (cf RFC1945)
- short int notmodified; // page ou fichier NON modifié (transféré)
- short int is_write; // sortie sur disque (out) ou en mémoire (adr)
- short int is_chunk; // mode chunk
- short int compressed; // compressé?
- short int empty; // vide?
- short int keep_alive; // Keep-Alive?
- short int keep_alive_trailers; // ..with trailers extension
- int keep_alive_t; // KA timeout
- int keep_alive_max; // KA number of requests
- char *adr; // adresse du bloc de mémoire, NULL=vide
- char *headers; // adresse des en têtes si présents
- FILE *out; // écriture directe sur disque (si is_write=1)
- LLint size; // taille fichier
- char msg[80]; // message éventuel si échec ("\0"=non précisé)
- char contenttype[64]; // content-type ("text/html" par exemple)
- char charset[64]; // charset ("iso-8859-1" par exemple)
- char contentencoding[64]; // content-encoding ("gzip" par exemple)
- char *location; // on copie dedans éventuellement la véritable 'location'
- LLint totalsize; // taille totale à télécharger (-1=inconnue)
- short int is_file; // ce n'est pas une socket mais un descripteur de fichier si 1
- T_SOC soc; // ID socket
- SOCaddr address; // IP address
- int address_size; // IP address structure length (unused internally)
- FILE *fp; // fichier pour file://
-#if HTS_USEOPENSSL
- short int ssl; // is this connection a SSL one? (https)
- // BIO* ssl_soc; // SSL structure
- SSL *ssl_con; // connection structure
-#endif
- char lastmodified[64]; // Last-Modified
- char etag[256]; // Etag
- char cdispo[256]; // Content-Disposition coupé
- LLint crange; // Content-Range
- LLint crange_start; // Content-Range
- LLint crange_end; // Content-Range
- int debugid; // debug connection
- /* */
- htsrequest req; // paramètres pour la requête
- /*char digest[32+2]; // digest md5 généré par le moteur ("" si non généré) */
-};
-
/* ANCIENNE STURCTURE pour cache 1.0 */
#ifndef HTS_DEF_FWSTRUCT_OLD_t_proxy
#define HTS_DEF_FWSTRUCT_OLD_t_proxy
diff --git a/src/htsmodules.h b/src/htsmodules.h
index f38b4e2..18eef8e 100644
--- a/src/htsmodules.h
+++ b/src/htsmodules.h
@@ -115,6 +115,10 @@ struct htsmoduleStruct {
};
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* Used to wrap module initialization */
/* return 1 if init was ok */
typedef int (*t_htsWrapperInit) (char *fn, char *args);
@@ -133,4 +137,8 @@ extern int hts_parse_externals(htsmoduleStruct * str);
extern int V6_is_available;
#endif
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/src/htsnet.h b/src/htsnet.h
index 2cc7499..a393129 100644
--- a/src/htsnet.h
+++ b/src/htsnet.h
@@ -74,6 +74,10 @@ typedef unsigned long in_addr_t;
#endif
#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* Ipv4 structures */
#if HTS_INET6 != 0
typedef struct in6_addr INaddr;
@@ -253,4 +257,8 @@ static HTS_UNUSED void SOCaddr_inetntoa_(char *namebuf, size_t namebuflen,
/* Socket length type */
typedef socklen_t SOClen;
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/src/htsopt.h b/src/htsopt.h
index fc7a4cc..5c2e35e 100644
--- a/src/htsopt.h
+++ b/src/htsopt.h
@@ -35,7 +35,13 @@ Please visit our Website: http://www.httrack.com
#define HTTRACK_DEFOPT
#include <stdio.h>
+
#include "htsglobal.h"
+#include "htsnet.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
/* Forward definitions */
#ifndef HTS_DEF_FWSTRUCT_t_hts_htmlcheck_callbacks
@@ -439,4 +445,162 @@ struct hts_stat_struct {
TStamp last_request; // last request issued
};
+// structure pour paramètres supplémentaires lors de la requête
+#ifndef HTS_DEF_FWSTRUCT_htsrequest_proxy
+#define HTS_DEF_FWSTRUCT_htsrequest_proxy
+typedef struct htsrequest_proxy htsrequest_proxy;
+#endif
+struct htsrequest_proxy {
+ int active;
+ const char* name;
+ int port;
+ const char* bindhost; // bind this host
+};
+
+#ifndef HTS_DEF_FWSTRUCT_htsrequest
+#define HTS_DEF_FWSTRUCT_htsrequest
+typedef struct htsrequest htsrequest;
+#endif
+struct htsrequest {
+ short int user_agent_send; // user agent (ex: httrack/1.0 [sun])
+ short int http11; // l'en tête peut (doit) être signé HTTP/1.1 et non HTTP/1.0
+ short int nokeepalive; // pas de keep-alive
+ short int range_used; // Range utilisé
+ short int nocompression; // Pas de compression
+ short int flush_garbage; // recycled
+ const char* user_agent;
+ const char* referer;
+ const char* from;
+ const char* lang_iso;
+ const char* accept;
+ const char* headers;
+ htsrequest_proxy proxy; // proxy
+};
+
+// structure pour retour d'une connexion/prise d'en tête
+#ifndef HTS_DEF_FWSTRUCT_htsblk
+#define HTS_DEF_FWSTRUCT_htsblk
+typedef struct htsblk htsblk;
+#endif
+struct htsblk {
+ int statuscode; // status-code, -1=erreur, 200=OK,201=..etc (cf RFC1945)
+ short int notmodified; // page ou fichier NON modifié (transféré)
+ short int is_write; // sortie sur disque (out) ou en mémoire (adr)
+ short int is_chunk; // mode chunk
+ short int compressed; // compressé?
+ short int empty; // vide?
+ short int keep_alive; // Keep-Alive?
+ short int keep_alive_trailers; // ..with trailers extension
+ int keep_alive_t; // KA timeout
+ int keep_alive_max; // KA number of requests
+ char *adr; // adresse du bloc de mémoire, NULL=vide
+ char *headers; // adresse des en têtes si présents
+ FILE *out; // écriture directe sur disque (si is_write=1)
+ LLint size; // taille fichier
+ char msg[80]; // message éventuel si échec ("\0"=non précisé)
+ char contenttype[64]; // content-type ("text/html" par exemple)
+ char charset[64]; // charset ("iso-8859-1" par exemple)
+ char contentencoding[64]; // content-encoding ("gzip" par exemple)
+ char *location; // on copie dedans éventuellement la véritable 'location'
+ LLint totalsize; // taille totale à télécharger (-1=inconnue)
+ short int is_file; // ce n'est pas une socket mais un descripteur de fichier si 1
+ T_SOC soc; // ID socket
+ SOCaddr address; // IP address
+ int address_size; // IP address structure length (unused internally)
+ FILE *fp; // fichier pour file://
+#if HTS_USEOPENSSL
+ short int ssl; // is this connection a SSL one? (https)
+ // BIO* ssl_soc; // SSL structure
+ SSL *ssl_con; // connection structure
+#endif
+ char lastmodified[64]; // Last-Modified
+ char etag[256]; // Etag
+ char cdispo[256]; // Content-Disposition coupé
+ LLint crange; // Content-Range
+ LLint crange_start; // Content-Range
+ LLint crange_end; // Content-Range
+ int debugid; // debug connection
+ /* */
+ htsrequest req; // paramètres pour la requête
+ /*char digest[32+2]; // digest md5 généré par le moteur ("" si non généré) */
+};
+
+// structure d'un lien
+#ifndef HTS_DEF_FWSTRUCT_lien_url
+#define HTS_DEF_FWSTRUCT_lien_url
+typedef struct lien_url lien_url;
+#endif
+struct lien_url {
+ char *adr; // adresse
+ char *fil; // nom du fichier distant
+ char *sav; // nom à sauver sur disque (avec chemin éventuel)
+ char *cod; // chemin codebase éventuel si classe java
+ char *former_adr; // adresse initiale (avant éventuel moved), peut être nulle
+ char *former_fil; // nom du fichier distant initial (avant éventuel moved), peut être nul
+
+ int premier; // pointeur sur le premier lien qui a donné lieu aux autres liens du domaine
+ int precedent; // pointeur sur le lien qui a donné lieu à ce lien précis
+ int depth; // profondeur autorisée lien ; >0 forte 0=faible
+ int pass2; // traiter après les autres, seconde passe. si == -1, lien traité en background
+ char link_import; // lien importé à la suite d'un moved - ne pas appliquer les règles classiques up/down
+ //int moved; // pointeur sur moved
+ int retry; // nombre de retry restants
+ int testmode; // mode test uniquement, envoyer juste un head!
+};
+
+// chargement de fichiers en 'arrière plan'
+#ifndef HTS_DEF_FWSTRUCT_lien_back
+#define HTS_DEF_FWSTRUCT_lien_back
+typedef struct lien_back lien_back;
+#endif
+struct lien_back {
+#if DEBUG_CHECKINT
+ char magic;
+#endif
+ char url_adr[HTS_URLMAXSIZE * 2]; // adresse
+ char url_fil[HTS_URLMAXSIZE * 2]; // nom du fichier distant
+ char url_sav[HTS_URLMAXSIZE * 2]; // nom à sauver sur disque (avec chemin éventuel)
+ char referer_adr[HTS_URLMAXSIZE * 2]; // adresse host page referer
+ char referer_fil[HTS_URLMAXSIZE * 2]; // fichier page referer
+ char location_buffer[HTS_URLMAXSIZE * 2]; // "location" en cas de "moved" (302,..)
+ char *tmpfile; // nom à sauver temporairement (compressé)
+ char tmpfile_buffer[HTS_URLMAXSIZE * 2]; // buffer pour le nom à sauver temporairement
+ char send_too[1024]; // données à envoyer en même temps que le header
+ int status; // status (-1=non utilisé, 0: prêt, >0: opération en cours)
+ int locked; // locked (to be used soon)
+ int testmode; // mode de test
+ int timeout; // gérer des timeouts? (!=0 : nombre de secondes)
+ TStamp timeout_refresh; // si oui, time refresh
+ int rateout; // timeout refresh? (!=0 : taux minimum toléré en octets/s)
+ TStamp rateout_time; // si oui, date de départ
+ LLint maxfile_nonhtml; // taille max d'un fichier non html
+ LLint maxfile_html; // idem pour un ficheir html
+ htsblk r; // structure htsblk de chaque objet en background
+ int is_update; // mode update
+ int head_request; // requète HEAD?
+ LLint range_req_size; // range utilisé
+ TStamp ka_time_start; // refresh time for KA
+ //
+ int http11; // L'en tête doit être signé HTTP/1.1 et non HTTP/1.0
+ int is_chunk; // chunk?
+ char *chunk_adr; // adresse chunk en cours de chargement
+ LLint chunk_size; // taille chunk en cours de chargement
+ LLint chunk_blocksize; // taille data declaree par le chunk
+ LLint compressed_size; // taille compressés (stats uniquement)
+ //
+ //int links_index; // to access liens[links_index]
+ //
+ char info[256]; // éventuel status pour le ftp
+ int stop_ftp; // flag stop pour ftp
+ int finalized; // finalized (optim memory)
+ int early_add; // was added before link heap saw it
+#if DEBUG_CHECKINT
+ char magic2;
+#endif
+};
+
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/src/htssafe.h b/src/htssafe.h
index d0d6c2a..cde0ad1 100644
--- a/src/htssafe.h
+++ b/src/htssafe.h
@@ -33,10 +33,6 @@ Please visit our Website: http://www.httrack.com
#ifndef HTSSAFE_DEFH
#define HTSSAFE_DEFH
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -53,7 +49,13 @@ extern "C" {
#ifndef HTS_DEF_FWSTRUCT_htsErrorCallback
#define HTS_DEF_FWSTRUCT_htsErrorCallback
typedef void (*htsErrorCallback) (const char *msg, const char *file, int line);
+#ifdef __cplusplus
+extern "C" {
+#endif
HTSEXT_API htsErrorCallback hts_get_error_callback(void);
+#ifdef __cplusplus
+}
+#endif
#endif
#define HTSSAFE_ABORT_FUNCTION(A,B,C) do { \
@@ -207,8 +209,4 @@ static HTS_INLINE HTS_UNUSED char* strcpy_safe_(char *const dest, const size_t s
#define realloct(A,B) realloc(A, B)
#define memcpybuff(A, B, N) memcpy((A), (B), (N))
-#ifdef __cplusplus
-}
-#endif
-
#endif
diff --git a/src/htsweb.c b/src/htsweb.c
index 82f4c79..6e3f4a5 100644
--- a/src/htsweb.c
+++ b/src/htsweb.c
@@ -178,6 +178,14 @@ int main(int argc, char *argv[]) {
}
smallserver_setkey("HTTRACK_WEB", HTTRACK_WEB);
+ /* Check version compatibility */
+ if (hts_sizeof_opt() != sizeof(httrackp)) {
+ fprintf(stderr,
+ "** CRITICAL: incompatible current httrack library version %s, expected version %s",
+ hts_version(), HTTRACK_VERSIONID);
+ smallserver_setkey("HTTRACK_INCOMPATIBLE_VERSIONID", hts_version());
+ }
+
/* protected session-id */
{
char buff[1024];
diff --git a/src/htswrap.h b/src/htswrap.h
index e87ddf6..eb010d3 100644
--- a/src/htswrap.h
+++ b/src/htswrap.h
@@ -46,9 +46,17 @@ Please visit our Website: http://www.httrack.com
typedef struct httrackp httrackp;
#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
HTSEXT_API int htswrap_init(void); // LEGACY
HTSEXT_API int htswrap_free(void); // LEGACY
+#ifdef __cplusplus
+}
+#endif
+
//HTSEXT_API int htswrap_add(httrackp * opt, const char *name, void *fct);
//HTSEXT_API uintptr_t htswrap_read(httrackp * opt, const char *name);
diff --git a/src/httrack-library.h b/src/httrack-library.h
index 622fe07..9873bef 100644
--- a/src/httrack-library.h
+++ b/src/httrack-library.h
@@ -5,7 +5,7 @@ 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
-as published by the Free Software Foundation; either version 2
+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,
@@ -118,6 +118,7 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp * opt);
/* Options handling */
HTSEXT_API httrackp *hts_create_opt(void);
HTSEXT_API void hts_free_opt(httrackp * opt);
+HTSEXT_API size_t hts_sizeof_opt(void);
HTSEXT_API const hts_stat_struct* hts_get_stats(httrackp * opt);
HTSEXT_API void set_wrappers(httrackp * opt); /* LEGACY */
HTSEXT_API int plug_wrapper(httrackp * opt, const char *moduleName,
diff --git a/src/httrack.c b/src/httrack.c
index 020d4f8..e8e5cd3 100644
--- a/src/httrack.c
+++ b/src/httrack.c
@@ -223,6 +223,15 @@ int main(int argc, char **argv) {
signal_handlers();
hts_init();
+
+ // Check version compatibility
+ if (hts_sizeof_opt() != sizeof(httrackp)) {
+ fprintf(stderr,
+ "incompatible current httrack library version %s, expected version %s",
+ hts_version(), HTTRACK_VERSIONID);
+ abortLog("incompatible httrack library version, please update both httrack and its library");
+ }
+
opt = global_opt = hts_create_opt();
assert(opt->size_httrackp == sizeof(httrackp));