diff options
author | Xavier Roche <xroche@users.noreply.github.com> | 2014-05-23 21:33:43 +0000 |
---|---|---|
committer | Xavier Roche <xroche@users.noreply.github.com> | 2014-05-23 21:33:43 +0000 |
commit | cefcc0426613cc761373e785980c87c77f8a8cb5 (patch) | |
tree | e64653268bcb93fc50bf23d22e38799c5bb31adc | |
parent | 6ba50a2001bcfa1b467f69985a002fc064d8c807 (diff) |
"const correctness" cleanup
added the following default flags:
-Wformat
-Wformat-security
-Wmultichar
-Wwrite-strings
fixed several other warnings
-rwxr-xr-x | configure | 3 | ||||
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | man/httrack.1 | 2 | ||||
-rw-r--r-- | src/htsalias.c | 4 | ||||
-rw-r--r-- | src/htsalias.h | 2 | ||||
-rw-r--r-- | src/htsback.c | 48 | ||||
-rw-r--r-- | src/htsback.h | 18 | ||||
-rw-r--r-- | src/htsbauth.c | 52 | ||||
-rw-r--r-- | src/htsbauth.h | 24 | ||||
-rw-r--r-- | src/htscache.c | 10 | ||||
-rw-r--r-- | src/htsconcat.c | 2 | ||||
-rw-r--r-- | src/htscore.h | 8 | ||||
-rw-r--r-- | src/htsfilters.c | 10 | ||||
-rw-r--r-- | src/htsfilters.h | 6 | ||||
-rw-r--r-- | src/htsftp.c | 4 | ||||
-rw-r--r-- | src/htsftp.h | 2 | ||||
-rw-r--r-- | src/htshelp.c | 14 | ||||
-rw-r--r-- | src/htshelp.h | 8 | ||||
-rw-r--r-- | src/htsindex.c | 6 | ||||
-rw-r--r-- | src/htsjava.c | 9 | ||||
-rw-r--r-- | src/htslib.c | 44 | ||||
-rw-r--r-- | src/htslib.h | 19 | ||||
-rw-r--r-- | src/htsname.c | 2 | ||||
-rw-r--r-- | src/htsopt.h | 2 | ||||
-rw-r--r-- | src/htsparse.c | 18 | ||||
-rw-r--r-- | src/htsrobots.c | 6 | ||||
-rw-r--r-- | src/htsrobots.h | 4 | ||||
-rw-r--r-- | src/htsserver.c | 41 | ||||
-rw-r--r-- | src/htsserver.h | 10 | ||||
-rw-r--r-- | src/htstools.c | 19 | ||||
-rw-r--r-- | src/htstools.h | 2 | ||||
-rw-r--r-- | src/htsweb.c | 2 | ||||
-rw-r--r-- | src/htswizard.c | 28 | ||||
-rw-r--r-- | src/htswizard.h | 7 | ||||
-rw-r--r-- | src/httrack-library.h | 4 | ||||
-rw-r--r-- | src/proxy/proxytrack.h | 4 | ||||
-rw-r--r-- | src/proxy/store.c | 2 |
37 files changed, 230 insertions, 219 deletions
@@ -15314,7 +15314,8 @@ LT_CV_OBJDIR=$lt_cv_objdir ### Default CFLAGS -DEFAULT_CFLAGS="-Wall -Wcast-align -Wstrict-prototypes \ +DEFAULT_CFLAGS="-Wall -Wformat -Wformat-security \ +-Wmultichar -Wwrite-strings -Wcast-align -Wstrict-prototypes \ -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith \ -Wnested-externs -D_REENTRANT" diff --git a/configure.ac b/configure.ac index 9d605f4..7cc0887 100644 --- a/configure.ac +++ b/configure.ac @@ -21,7 +21,8 @@ AC_SUBST(SHLIBPATH_VAR,$shlibpath_var) AC_SUBST(LT_CV_OBJDIR,$lt_cv_objdir) ### Default CFLAGS -DEFAULT_CFLAGS="-Wall -Wcast-align -Wstrict-prototypes \ +DEFAULT_CFLAGS="-Wall -Wformat -Wformat-security \ +-Wmultichar -Wwrite-strings -Wcast-align -Wstrict-prototypes \ -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith \ -Wnested-externs -D_REENTRANT" AC_SUBST(DEFAULT_CFLAGS) diff --git a/man/httrack.1 b/man/httrack.1 index 296b2fa..3123bad 100644 --- a/man/httrack.1 +++ b/man/httrack.1 @@ -1,7 +1,7 @@ .\" Process this file with .\" groff -man -Tascii httrack.1 .\" -.TH httrack 1 "15 May 2014" "httrack website copier" +.TH httrack 1 "21 May 2014" "httrack website copier" .SH NAME httrack \- offline browser : copy websites to a local directory .SH SYNOPSIS diff --git a/src/htsalias.c b/src/htsalias.c index 19b7857..b1a7962 100644 --- a/src/htsalias.c +++ b/src/htsalias.c @@ -560,8 +560,8 @@ int optinclude_file(const char *name, int *argc, char **argv, char *x_argvblk, /* Get home directory, '.' if failed */ /* example: /home/smith */ -char *hts_gethome(void) { - char *home = getenv("HOME"); +const char *hts_gethome(void) { + const char *home = getenv("HOME"); if (home) return home; diff --git a/src/htsalias.h b/src/htsalias.h index b77885d..b09d18f 100644 --- a/src/htsalias.h +++ b/src/htsalias.h @@ -48,7 +48,7 @@ const char *optreal_value(int p); const char *optalias_value(int p); const char *opttype_value(int p); const char *opthelp_value(int p); -char *hts_gethome(void); +const char *hts_gethome(void); void expand_home(String * str); #endif diff --git a/src/htsback.c b/src/htsback.c index d5d7c10..80cfb77 100644 --- a/src/htsback.c +++ b/src/htsback.c @@ -117,7 +117,7 @@ void back_delete_all(httrackp * opt, cache_back * cache, struct_back * sback) { while((item = inthash_enum_next(&e))) { #ifndef HTS_NO_BACK_ON_DISK - char *filename = (char *) item->value.ptr; + const char *filename = (char *) item->value.ptr; if (filename != NULL) { (void) UNLINK(filename); @@ -139,19 +139,19 @@ void back_delete_all(httrackp * opt, cache_back * cache, struct_back * sback) { // --- // routines de backing -static int back_index_ready(httrackp * opt, struct_back * sback, char *adr, - char *fil, char *sav, int getIndex); -static int back_index_fetch(httrackp * opt, struct_back * sback, char *adr, - char *fil, char *sav, int getIndex); +static int back_index_ready(httrackp * opt, struct_back * sback, const char *adr, + const char *fil, const char *sav, int getIndex); +static int back_index_fetch(httrackp * opt, struct_back * sback, const char *adr, + const char *fil, const char *sav, int getIndex); // retourne l'index d'un lien dans un tableau de backing -int back_index(httrackp * opt, struct_back * sback, char *adr, char *fil, - char *sav) { +int back_index(httrackp * opt, struct_back * sback, const char *adr, const char *fil, + const char *sav) { return back_index_fetch(opt, sback, adr, fil, sav, 1); } -static int back_index_fetch(httrackp * opt, struct_back * sback, char *adr, - char *fil, char *sav, int getIndex) { +static int back_index_fetch(httrackp * opt, struct_back * sback, const char *adr, + const char *fil, const char *sav, int getIndex) { lien_back *const back = sback->lnk; const int back_max = sback->count; int index = -1; @@ -177,8 +177,8 @@ static int back_index_fetch(httrackp * opt, struct_back * sback, char *adr, } /* resurrect stored entry */ -static int back_index_ready(httrackp * opt, struct_back * sback, char *adr, - char *fil, char *sav, int getIndex) { +static int back_index_ready(httrackp * opt, struct_back * sback, const char *adr, + const char *fil, const char *sav, int getIndex) { lien_back *const back = sback->lnk; void *ptr = NULL; @@ -194,7 +194,7 @@ static int back_index_ready(httrackp * opt, struct_back * sback, char *adr, #ifndef HTS_NO_BACK_ON_DISK FILE *fp; - char *fileback = (char *) ptr; + const char *fileback = (char *) ptr; char catbuff[CATBUFF_SIZE]; if ((fp = FOPEN(fconv(catbuff, sizeof(catbuff), fileback), "rb")) != NULL) { @@ -420,8 +420,8 @@ int back_done_incache(struct_back * sback) { } // le lien a-t-il été mis en backing? -HTS_INLINE int back_exist(struct_back * sback, httrackp * opt, char *adr, - char *fil, char *sav) { +HTS_INLINE int back_exist(struct_back * sback, httrackp * opt, const char *adr, + const char *fil, const char *sav) { return (back_index_fetch(opt, sback, adr, fil, sav, /*don't fetch */ 0) >= 0); } @@ -515,7 +515,7 @@ int back_finalize(httrackp * opt, cache_back * cache, struct_back * sback, && (back[p].r.statuscode > 0) // not internal error ) { if (!back[p].testmode) { // not test mode - char *state = "unknown"; + const char *state = "unknown"; /* décompression */ #if HTS_USEZLIB @@ -980,7 +980,7 @@ int back_unserialize(FILE * fp, lien_back ** dst) { /* serialize a reference ; used to store references of files being downloaded in case of broken download */ /* Note: NOT utf-8 */ int back_serialize_ref(httrackp * opt, const lien_back * src) { - char *filename = + const char *filename = url_savename_refname_fullpath(opt, src->url_adr, src->url_fil); FILE *fp = fopen(filename, "wb"); @@ -1010,9 +1010,9 @@ int back_serialize_ref(httrackp * opt, const lien_back * src) { } /* unserialize a reference ; used to store references of files being downloaded in case of broken download */ -int back_unserialize_ref(httrackp * opt, const char *adr, const char *fil, +int back_unserialize_ref(httrackp * opt, const const char *adr, const const char *fil, lien_back ** dst) { - char *filename = url_savename_refname_fullpath(opt, adr, fil); + const char *filename = url_savename_refname_fullpath(opt, adr, fil); FILE *fp = FOPEN(filename, "rb"); if (fp != NULL) { @@ -1148,7 +1148,7 @@ int back_trylive(httrackp * opt, cache_back * cache, struct_back * sback, } /* search for a live position, or, if not possible, try to return a new one */ -int back_searchlive(httrackp * opt, struct_back * sback, char *search_addr) { +int back_searchlive(httrackp * opt, struct_back * sback, const char *search_addr) { lien_back *const back = sback->lnk; const int back_max = sback->count; int i; @@ -1400,8 +1400,8 @@ int back_stack_available(struct_back * sback) { // ajouter un lien en backing int back_add_if_not_exists(struct_back * sback, httrackp * opt, - cache_back * cache, char *adr, char *fil, char *save, - char *referer_adr, char *referer_fil, int test) { + cache_back * cache, const char *adr, const char *fil, const char *save, + const char *referer_adr, const char *referer_fil, int test) { back_clean(opt, cache, sback); /* first cleanup the backlog to ensure that we have some entry left */ if (!back_exist(sback, opt, adr, fil, save)) { return back_add(sback, opt, cache, adr, fil, save, referer_adr, referer_fil, @@ -1410,8 +1410,8 @@ int back_add_if_not_exists(struct_back * sback, httrackp * opt, return 0; } -int back_add(struct_back * sback, httrackp * opt, cache_back * cache, char *adr, - char *fil, char *save, char *referer_adr, char *referer_fil, +int back_add(struct_back * sback, httrackp * opt, cache_back * cache, const char *adr, + const char *fil, const char *save, const char *referer_adr, const char *referer_fil, int test) { lien_back *const back = sback->lnk; const int back_max = sback->count; @@ -1974,7 +1974,7 @@ int back_add(struct_back * sback, httrackp * opt, cache_back * cache, char *adr, printf("ok, dns cache ready..\n"); #endif soc = - http_xfopen(opt, 0, 0, 0, back[p].send_too, adr, fil, &(back[p].r)); + http_xfopen(opt, 0, 0, 0, back[p].send_too, adr, fil, &back[p].r); if (soc == INVALID_SOCKET) { back[p].status = STATUS_READY; // fini, erreur back_set_finished(sback, p); diff --git a/src/htsback.h b/src/htsback.h index 1da5450..776214c 100644 --- a/src/htsback.h +++ b/src/htsback.h @@ -74,21 +74,21 @@ void back_free(struct_back ** sback); // backing #define BACK_ADD_TEST "(dummy)" #define BACK_ADD_TEST2 "(dummy2)" -int back_index(httrackp * opt, struct_back * sback, char *adr, char *fil, - char *sav); +int back_index(httrackp * opt, struct_back * sback, const char *adr, const char *fil, + const char *sav); int back_available(struct_back * sback); LLint back_incache(struct_back * sback); int back_done_incache(struct_back * sback); -HTS_INLINE int back_exist(struct_back * sback, httrackp * opt, char *adr, - char *fil, char *sav); +HTS_INLINE int back_exist(struct_back * sback, httrackp * opt, const char *adr, + const char *fil, const char *sav); int back_nsoc(struct_back * sback); int back_nsoc_overall(struct_back * sback); -int back_add(struct_back * sback, httrackp * opt, cache_back * cache, char *adr, - char *fil, char *save, char *referer_adr, char *referer_fil, +int back_add(struct_back * sback, httrackp * opt, cache_back * cache, const char *adr, + const char *fil, const char *save, const char *referer_adr, const char *referer_fil, int test); int back_add_if_not_exists(struct_back * sback, httrackp * opt, - cache_back * cache, char *adr, char *fil, char *save, - char *referer_adr, char *referer_fil, int test); + cache_back * cache, const char *adr, const char *fil, const char *save, + const char *referer_adr, const char *referer_fil, int test); int back_stack_available(struct_back * sback); int back_search(httrackp * opt, struct_back * sback); int back_search_quick(struct_back * sback); @@ -99,7 +99,7 @@ void back_wait(struct_back * sback, httrackp * opt, cache_back * cache, TStamp stat_timestart); int back_letlive(httrackp * opt, cache_back * cache, struct_back * sback, const int p); -int back_searchlive(httrackp * opt, struct_back * sback, char *search_addr); +int back_searchlive(httrackp * opt, struct_back * sback, const char *search_addr); void back_connxfr(htsblk * src, htsblk * dst); void back_move(lien_back * src, lien_back * dst); void back_copy_static(const lien_back * src, lien_back * dst); diff --git a/src/htsbauth.c b/src/htsbauth.c index da0ef1d..9d9ea7c 100644 --- a/src/htsbauth.c +++ b/src/htsbauth.c @@ -44,8 +44,8 @@ Please visit our Website: http://www.httrack.com // gestion des cookie // ajoute, dans l'ordre // !=0 : erreur -int cookie_add(t_cookie * cookie, char *cook_name, char *cook_value, - char *domain, char *path) { +int cookie_add(t_cookie * cookie, const char *cook_name, const char *cook_value, + const char *domain, const char *path) { char buffer[8192]; char *a = cookie->data; char *insert; @@ -53,20 +53,20 @@ int cookie_add(t_cookie * cookie, char *cook_name, char *cook_value, // effacer éventuel cookie en double cookie_del(cookie, cook_name, domain, path); - if ((int) strlen(cook_value) > 1024) + if (strlen(cook_value) > 1024) return -1; // trop long - if ((int) strlen(cook_name) > 256) + if (strlen(cook_name) > 256) return -1; // trop long - if ((int) strlen(domain) > 256) + if (strlen(domain) > 256) return -1; // trop long - if ((int) strlen(path) > 256) + if (strlen(path) > 256) return -1; // trop long - if ((int) (strlen(cookie->data) + if (strlen(cookie->data) + strlen(cook_value) + strlen(cook_name) + strlen(domain) + strlen(path) - + 256) > cookie->max_len) + + 256 > cookie->max_len) return -1; // impossible d'ajouter insert = a; // insérer ici @@ -99,7 +99,7 @@ int cookie_add(t_cookie * cookie, char *cook_name, char *cook_value, strcatbuff(cook, "\t"); strcatbuff(cook, cook_value); strcatbuff(cook, "\n"); - if (!(((int) strlen(cookie->data) + (int) strlen(cook)) < cookie->max_len)) + if (!((strlen(cookie->data) + strlen(cook)) < cookie->max_len)) return -1; // impossible d'ajouter cookie_insert(insert, cook); #if DEBUG_COOK @@ -111,13 +111,13 @@ int cookie_add(t_cookie * cookie, char *cook_name, char *cook_value, } // effacer cookie si existe -int cookie_del(t_cookie * cookie, char *cook_name, char *domain, char *path) { +int cookie_del(t_cookie * cookie, const char *cook_name, const char *domain, const char *path) { char *a, *b; b = cookie_find(cookie->data, cook_name, domain, path); if (b) { a = cookie_nextfield(b); - cookie_delete(b, (int) (a - b)); + cookie_delete(b, a - b); #if DEBUG_COOK printf("deleted old cookie: %s %s %s\n", cook_name, domain, path); #endif @@ -128,7 +128,7 @@ int cookie_del(t_cookie * cookie, char *cook_name, char *domain, char *path) { // Matches wildcard cookie domains that start with a dot // chk_dom: the domain stored in the cookie (potentially wildcard). // domain: query domain -static int cookie_cmp_wildcard_domain(char *chk_dom, char *domain) { +static int cookie_cmp_wildcard_domain(const char *chk_dom, const char *domain) { const size_t n = strlen(chk_dom); const size_t m = strlen(domain); const size_t l = n < m ? n : m; @@ -152,7 +152,7 @@ static int cookie_cmp_wildcard_domain(char *chk_dom, char *domain) { // renvoie pointeur sur ligne, ou NULL si introuvable // path est aligné à droite et cook_name peut être vide (chercher alors tout cookie) // .doubleclick.net TRUE / FALSE 1999999999 id A -char *cookie_find(char *s, char *cook_name, char *domain, char *path) { +char *cookie_find(char *s, const char *cook_name, const char *domain, const char *path) { char buffer[8192]; char *a = s; @@ -165,15 +165,15 @@ char *cookie_find(char *s, char *cook_name, char *domain, char *path) { t = (strcmp(cookie_get(buffer, a, 5), cook_name) == 0); // tester si même nom if (t) { // même nom ou nom qualconque // - char *chk_dom = cookie_get(buffer, a, 0); // domaine concerné par le cookie + const char *chk_dom = cookie_get(buffer, a, 0); // domaine concerné par le cookie - if (((int) strlen(chk_dom) <= (int) strlen(domain) && + if ((strlen(chk_dom) <= strlen(domain) && strcmp(chk_dom, domain + strlen(domain) - strlen(chk_dom)) == 0) || !cookie_cmp_wildcard_domain(chk_dom, domain)) { // même domaine // - char *chk_path = cookie_get(buffer, a, 2); // chemin concerné par le cookie + const char *chk_path = cookie_get(buffer, a, 2); // chemin concerné par le cookie - if ((int) strlen(chk_path) <= (int) strlen(path)) { + if (strlen(chk_path) <= strlen(path)) { if (strncmp(path, chk_path, strlen(chk_path)) == 0) { // même chemin return a; } @@ -311,7 +311,7 @@ int cookie_load(t_cookie * cookie, const char *fpath, const char *name) { // écrire cookies.txt // !=0 : erreur -int cookie_save(t_cookie * cookie, char *name) { +int cookie_save(t_cookie * cookie, const char *name) { char catbuff[CATBUFF_SIZE]; if (strnotempty(cookie->data)) { @@ -337,7 +337,7 @@ int cookie_save(t_cookie * cookie, char *name) { } // insertion chaine ins avant s -void cookie_insert(char *s, char *ins) { +void cookie_insert(char *s, const char *ins) { char *buff; if (strnotempty(s) == 0) { // rien à faire, juste concat @@ -354,7 +354,7 @@ void cookie_insert(char *s, char *ins) { } // destruction chaine dans s position pos -void cookie_delete(char *s, int pos) { +void cookie_delete(char *s, size_t pos) { char *buff; if (strnotempty(s + pos) == 0) { // rien à faire, effacer @@ -371,8 +371,8 @@ void cookie_delete(char *s, int pos) { // renvoie champ param de la chaine cookie_base // ex: cookie_get("ceci est<tab>un<tab>exemple",1) renvoi "un" -char *cookie_get(char *buffer, char *cookie_base, int param) { - char *limit; +const char *cookie_get(char *buffer, const char *cookie_base, int param) { + const char *limit; while(*cookie_base == '\n') cookie_base++; @@ -393,7 +393,7 @@ char *cookie_get(char *buffer, char *cookie_base, int param) { } if (cookie_base) { if (cookie_base < limit) { - char *a = cookie_base; + const char *a = cookie_base; while((*a) && (*a != '\t') && (*a != '\n')) a++; @@ -413,7 +413,7 @@ char *cookie_get(char *buffer, char *cookie_base, int param) { // -- basic auth -- /* déclarer un répertoire comme possédant une authentification propre */ -int bauth_add(t_cookie * cookie, char *adr, char *fil, char *auth) { +int bauth_add(t_cookie * cookie, const char *adr, const char *fil, const char *auth) { char buffer[HTS_URLMAXSIZE * 2]; if (cookie) { @@ -439,7 +439,7 @@ int bauth_add(t_cookie * cookie, char *adr, char *fil, char *auth) { /* tester adr et fil, et retourner authentification si nécessaire */ /* sinon, retourne NULL */ -char *bauth_check(t_cookie * cookie, char *adr, char *fil) { +char *bauth_check(t_cookie * cookie, const char *adr, const char *fil) { char buffer[HTS_URLMAXSIZE * 2]; if (cookie) { @@ -458,7 +458,7 @@ char *bauth_check(t_cookie * cookie, char *adr, char *fil) { return NULL; } -char *bauth_prefix(char *prefix, char *adr, char *fil) { +char *bauth_prefix(char *prefix, const char *adr, const char *fil) { char *a; strcpybuff(prefix, jump_identification(adr)); diff --git a/src/htsbauth.h b/src/htsbauth.h index 248097e..dd57070 100644 --- a/src/htsbauth.h +++ b/src/htsbauth.h @@ -34,6 +34,8 @@ Please visit our Website: http://www.httrack.com #ifndef HTSBAUTH_DEFH #define HTSBAUTH_DEFH +#include <sys/types.h> + // robots wizard #ifndef HTS_DEF_FWSTRUCT_bauth_chain #define HTS_DEF_FWSTRUCT_bauth_chain @@ -60,21 +62,21 @@ struct t_cookie { #ifdef HTS_INTERNAL_BYTECODE // cookies -int cookie_add(t_cookie * cookie, char *cook_name, char *cook_value, - char *domain, char *path); -int cookie_del(t_cookie * cookie, char *cook_name, char *domain, char *path); +int cookie_add(t_cookie * cookie, const char *cook_name, const char *cook_value, + const char *domain, const char *path); +int cookie_del(t_cookie * cookie, const char *cook_name, const char *domain, const char *path); int cookie_load(t_cookie * cookie, const char *path, const char *name); -int cookie_save(t_cookie * cookie, char *name); -void cookie_insert(char *s, char *ins); -void cookie_delete(char *s, int pos); -char *cookie_get(char *buffer, char *cookie_base, int param); -char *cookie_find(char *s, char *cook_name, char *domain, char *path); +int cookie_save(t_cookie * cookie, const char *name); +void cookie_insert(char *s, const char *ins); +void cookie_delete(char *s, size_t pos); +const char *cookie_get(char *buffer, const char *cookie_base, int param); +char *cookie_find(char *s, const char *cook_name, const char *domain, const char *path); char *cookie_nextfield(char *a); // basic auth -int bauth_add(t_cookie * cookie, char *adr, char *fil, char *auth); -char *bauth_check(t_cookie * cookie, char *adr, char *fil); -char *bauth_prefix(char *buffer, char *adr, char *fil); +int bauth_add(t_cookie * cookie, const char *adr, const char *fil, const char *auth); +char *bauth_check(t_cookie * cookie, const char *adr, const char *fil); +char *bauth_prefix(char *buffer, const char *adr, const char *fil); #endif diff --git a/src/htscache.c b/src/htscache.c index 5cdcc3f..dc63221 100644 --- a/src/htscache.c +++ b/src/htscache.c @@ -2016,12 +2016,12 @@ void cache_init(cache_back * cache, httrackp * opt) { // lire un fichier.. (compatible \0) /* Note: NOT utf-8 */ -char *readfile(char *fil) { +char *readfile(const char *fil) { return readfile2(fil, NULL); } /* Note: NOT utf-8 */ -char *readfile2(char *fil, LLint * size) { +char *readfile2(const char *fil, LLint * size) { char *adr = NULL; char catbuff[CATBUFF_SIZE]; INTsys len = 0; @@ -2049,7 +2049,7 @@ char *readfile2(char *fil, LLint * size) { } /* Note: utf-8 */ -char *readfile_utf8(char *fil) { +char *readfile_utf8(const char *fil) { char *adr = NULL; char catbuff[CATBUFF_SIZE]; const off_t len = fsize_utf8(fil); @@ -2074,8 +2074,8 @@ char *readfile_utf8(char *fil) { } /* Note: NOT utf-8 */ -char *readfile_or(char *fil, char *defaultdata) { - char *realfile = fil; +char *readfile_or(const char *fil, const char *defaultdata) { + const char *realfile = fil; char *ret; char catbuff[CATBUFF_SIZE]; diff --git a/src/htsconcat.c b/src/htsconcat.c index c78513f..3553207 100644 --- a/src/htsconcat.c +++ b/src/htsconcat.c @@ -105,7 +105,7 @@ char *fslash(char *catbuff, size_t size, const char *a) { } // extension : html,gif.. -HTSEXT_API char *get_ext(char *catbuff, size_t size, const char *fil) { +HTSEXT_API const char *get_ext(char *catbuff, size_t size, const char *fil) { size_t i, last; RUNTIME_TIME_CHECK_SIZE(size); diff --git a/src/htscore.h b/src/htscore.h index f082d11..93108cd 100644 --- a/src/htscore.h +++ b/src/htscore.h @@ -329,10 +329,10 @@ int fspc(httrackp * opt, FILE * fp, const char *type); char *next_token(char *p, int flag); // -char *readfile(char *fil); -char *readfile2(char *fil, LLint * size); -char *readfile_utf8(char *fil); -char *readfile_or(char *fil, char *defaultdata); +char *readfile(const char *fil); +char *readfile2(const char *fil, LLint * size); +char *readfile_utf8(const char *fil); +char *readfile_or(const char *fil, const char *defaultdata); #if 0 void check_rate(TStamp stat_timestart, int maxrate); diff --git a/src/htsfilters.c b/src/htsfilters.c index 855cc59..ad879f4 100644 --- a/src/htsfilters.c +++ b/src/htsfilters.c @@ -54,7 +54,7 @@ Please visit our Website: http://www.httrack.com // optionnel: taille à contrôller (ou numéro, etc) en pointeur // (en de détection de *size, la taille limite est écrite par dessus *size) // exemple: +-*.gif*[<5] == supprimer GIF si <5KB -int fa_strjoker(int type, char **filters, int nfil, char *nom, LLint * size, +int fa_strjoker(int type, char **filters, int nfil, const char *nom, LLint * size, int *size_flag, int *depth) { int verdict = 0; // on sait pas int i; @@ -101,7 +101,7 @@ int fa_strjoker(int type, char **filters, int nfil, char *nom, LLint * size, // cet algo est 'un peu' récursif mais ne consomme pas trop de tm // * = toute lettre // --?-- : spécifique à HTTrack et aux ? -HTS_INLINE char *strjoker(char *chaine, char *joker, LLint * size, +HTS_INLINE const char *strjoker(const char *chaine, const char *joker, LLint * size, int *size_flag) { //int err=0; if (strnotempty(joker) == 0) { // fin de chaine joker @@ -262,7 +262,7 @@ HTS_INLINE char *strjoker(char *chaine, char *joker, LLint * size, { int i, max; - char *adr; + const char *adr; // la chaine doit se terminer exactement if (cut) { @@ -335,8 +335,8 @@ HTS_INLINE char *strjoker(char *chaine, char *joker, LLint * size, // exemple: find dans un texte de strcpybuff(*[A-Z,a-z],"*[0-9]"); va rechercher la première occurence // d'un strcpy sur une variable ayant un nom en lettres et copiant une chaine de chiffres // ATTENTION!! Eviter les jokers en début, où gare au temps machine! -char *strjokerfind(char *chaine, char *joker) { - char *adr; +const char *strjokerfind(const char *chaine, const char *joker) { + const char *adr; while(*chaine) { if ((adr = strjoker(chaine, joker, NULL, NULL))) { // ok trouvé diff --git a/src/htsfilters.h b/src/htsfilters.h index 5ed2e19..c08bd06 100644 --- a/src/htsfilters.h +++ b/src/htsfilters.h @@ -39,11 +39,11 @@ Please visit our Website: http://www.httrack.com #include "htsbase.h" -int fa_strjoker(int type, char **filters, int nfil, char *nom, LLint * size, +int fa_strjoker(int type, char **filters, int nfil, const char *nom, LLint * size, int *size_flag, int *depth); -HTS_INLINE char *strjoker(char *chaine, char *joker, LLint * size, +HTS_INLINE const char *strjoker(const char *chaine, const char *joker, LLint * size, int *size_flag); -char *strjokerfind(char *chaine, char *joker); +const char *strjokerfind(const char *chaine, const char *joker); #endif #endif diff --git a/src/htsftp.c b/src/htsftp.c index 3d26a79..ccba1bd 100644 --- a/src/htsftp.c +++ b/src/htsftp.c @@ -142,7 +142,7 @@ int run_launch_ftp(FTPDownloadStruct * pStruct) { #endif char BIGSTK adr_ip[1024]; char *adr, *real_adr; - char *ftp_filename = ""; + const char *ftp_filename = ""; int timeout = 300; // timeout int timeout_onfly = 8; // attente réponse supplémentaire int transfer_list = 0; // directory @@ -913,7 +913,7 @@ FILE *dd = NULL; // routines de réception/émission // 0 = ERROR -int send_line(T_SOC soc, char *data) { +int send_line(T_SOC soc, const char *data) { char BIGSTK line[1024]; if (_DEBUG_HEAD) { diff --git a/src/htsftp.h b/src/htsftp.h index de2a9c5..ef6fca7 100644 --- a/src/htsftp.h +++ b/src/htsftp.h @@ -68,7 +68,7 @@ int back_launch_ftp(FTPDownloadStruct * params); #endif int run_launch_ftp(FTPDownloadStruct * params); -int send_line(T_SOC soc, char *data); +int send_line(T_SOC soc, const char *data); int get_ftp_line(T_SOC soc, char *line, size_t line_size, int timeout); T_SOC get_datasocket(char *to_send, size_t to_send_size); int stop_ftp(lien_back * back); diff --git a/src/htshelp.c b/src/htshelp.c index 239e857..6cdeb12 100644 --- a/src/htshelp.c +++ b/src/htshelp.c @@ -52,7 +52,7 @@ Please visit our Website: http://www.httrack.com /* END specific definitions */ #define waitkey if (more) { char s[4]; printf("\nMORE.. q to quit\n"); linput(stdin,s,4); if (strcmp(s,"q")==0) quit=1; else printf("Page %d\n\n",++m); } -void infomsg(char *msg) { +void infomsg(const char *msg) { int l = 0; int m = 0; int more = 0; @@ -332,7 +332,7 @@ void help_wizard(httrackp * opt) { printf("\n"); // couper en morceaux - argv[0] = "winhttrack"; + argv[0] = strdup("winhttrack"); argv[1] = cmd; argc++; while(cmd[i]) { @@ -364,15 +364,15 @@ void help_wizard(httrackp * opt) { #undef str #undef argv } -int help_query(char *list, int def) { +int help_query(const char *list, int def) { char s[256]; - char *a; + const char *a; int opt; int n = 1; a = list; while(strnotempty(a)) { - char *b = strchr(a, '|'); + const char *b = strchr(a, '|'); if (b) { char str[256]; @@ -455,7 +455,7 @@ void help_catchurl(const char *dest_path) { } // Créer un index.html vide -void make_empty_index(char *str) { +void make_empty_index(const char *str) { #if 0 if (!fexist(fconcat(str, "index.html"))) { FILE *fp = fopen(fconcat(str, "index.html"), "wb"); @@ -473,7 +473,7 @@ void make_empty_index(char *str) { // mini-aide (h: help) // y -void help(char *app, int more) { +void help(const char *app, int more) { char info[2048]; infomsg(""); diff --git a/src/htshelp.h b/src/htshelp.h index 5f1b75b..7add77e 100644 --- a/src/htshelp.h +++ b/src/htshelp.h @@ -43,11 +43,11 @@ Please visit our Website: http://www.httrack.com typedef struct httrackp httrackp; #endif -void infomsg(char *msg); -void help(char *app, int more); -void make_empty_index(char *str); +void infomsg(const char *msg); +void help(const char *app, int more); +void make_empty_index(const char *str); void help_wizard(httrackp * opt); -int help_query(char *list, int def); +int help_query(const char *list, int def); void help_catchurl(const char *dest_path); #endif diff --git a/src/htsindex.c b/src/htsindex.c index 1d08012..1dca05c 100644 --- a/src/htsindex.c +++ b/src/htsindex.c @@ -103,7 +103,7 @@ Please visit our Website: http://www.httrack.com /* End of Keyword Indexer Parameters */ -int strcpos(char *adr, char c); +int strcpos(const char *adr, char c); int mystrcmp(const void *_e1, const void *_e2); // Global variables @@ -468,8 +468,8 @@ void index_finish(const char *indexpath, int mode) { /* Subroutines */ #if HTS_MAKE_KEYWORD_INDEX -int strcpos(char *adr, char c) { - char *apos = strchr(adr, c); +int strcpos(const char *adr, char c) { + const char *apos = strchr(adr, c); if (apos) return (int) (apos - adr); diff --git a/src/htsjava.c b/src/htsjava.c index 0098994..44ecbc4 100644 --- a/src/htsjava.c +++ b/src/htsjava.c @@ -493,8 +493,9 @@ static char *printname(char rname[1024], char name[1024]) { p = &name[0]; - if (*p != '[') - return ""; + if (*p != '[') { + return rname; // "" + } p += 2; //rname=(char*)calloct(strlen(name)+8,sizeof(char)); p1 = rname; @@ -504,13 +505,13 @@ static char *printname(char rname[1024], char name[1024]) { if (*p == ';') { *p1 = '\0'; strcat(rname, ".class"); - return (rname); + return rname; } else *p1 = *p; p1++; } p1 -= 3; *p1 = '\0'; - return (rname); + return rname; } diff --git a/src/htslib.c b/src/htslib.c index ab83837..0ec0148 100644 --- a/src/htslib.c +++ b/src/htslib.c @@ -609,7 +609,7 @@ void hts_init_htsblk(htsblk * r) { // ouvre une liaison http, envoie une requète GET et réceptionne le header // retour: socket -T_SOC http_fopen(httrackp * opt, char *adr, char *fil, htsblk * retour) { +T_SOC http_fopen(httrackp * opt, const char *adr, const char *fil, htsblk * retour) { // / GET, traiter en-tête return http_xfopen(opt, 0, 1, 1, NULL, adr, fil, retour); } @@ -620,10 +620,11 @@ T_SOC http_fopen(httrackp * opt, char *adr, char *fil, htsblk * retour) { // waitconnect: attendre le connect() // note: dans retour, on met les params du proxy T_SOC http_xfopen(httrackp * opt, int mode, int treat, int waitconnect, - char *xsend, char *adr, char *fil, htsblk * retour) { + const char *xsend, const char *adr, const char *fil, htsblk * retour) { //htsblk retour; //int bufl=TAILLE_BUFFER; // 8Ko de buffer T_SOC soc = INVALID_SOCKET; + char BIGSTK tempo_fil[HTS_URLMAXSIZE * 2]; //char *p,*q; @@ -699,10 +700,8 @@ T_SOC http_xfopen(httrackp * opt, int mode, int treat, int waitconnect, (fconv (OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), unescape_http(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), fil + 1)))) { - char BIGSTK tempo[HTS_URLMAXSIZE * 2]; - - strcpybuff(tempo, fil + 1); - strcpybuff(fil, tempo); + strcpybuff(tempo_fil, fil + 1); + fil = tempo_fil; } // Ouvrir retour->totalsize = fsize(fconv(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), @@ -845,15 +844,16 @@ static void print_buffer(buff_struct*const str, const char *format, ...) { } // envoi d'une requète -int http_sendhead(httrackp * opt, t_cookie * cookie, int mode, char *xsend, - char *adr, char *fil, char *referer_adr, char *referer_fil, +int http_sendhead(httrackp * opt, t_cookie * cookie, int mode, + const char *xsend, const char *adr, const char *fil, + const char *referer_adr, const char *referer_fil, htsblk * retour) { char BIGSTK buffer_head_request[8192]; buff_struct bstr = { buffer_head_request, sizeof(buffer_head_request), 0 }; //int use_11=0; // HTTP 1.1 utilisé int direct_url = 0; // ne pas analyser l'url (exemple: ftp://) - char *search_tag = NULL; + const char *search_tag = NULL; // Initialize buffer buffer_head_request[0] = '\0'; @@ -1054,7 +1054,7 @@ int http_sendhead(httrackp * opt, t_cookie * cookie, int mode, char *xsend, } { - char *real_adr = jump_identification(adr); + const char *real_adr = jump_identification(adr); // Mandatory per RFC2616 if (!direct_url) { // pas ftp:// par exemple @@ -1099,12 +1099,12 @@ int http_sendhead(httrackp * opt, t_cookie * cookie, int mode, char *xsend, /* Authentification */ { char autorisation[1100]; - char *a; + const char *a; autorisation[0] = '\0'; if (link_has_authorization(adr)) { // ohh une authentification! - char *a = jump_identification(adr); - char *astart = jump_protocol(adr); + const char *a = jump_identification(adr); + const char *astart = jump_protocol(adr); if (!direct_url) { // pas ftp:// par exemple char user_pass[256]; @@ -1184,8 +1184,8 @@ int http_sendhead(httrackp * opt, t_cookie * cookie, int mode, char *xsend, } // traiter 1ere ligne d'en tête -void treatfirstline(htsblk * retour, char *rcvd) { - char *a = rcvd; +void treatfirstline(htsblk * retour, const char *rcvd) { + const char *a = rcvd; // exemple: // HTTP/1.0 200 OK @@ -1255,7 +1255,7 @@ void treatfirstline(htsblk * retour, char *rcvd) { // traiter ligne par ligne l'en tête // gestion des cookies -void treathead(t_cookie * cookie, char *adr, char *fil, htsblk * retour, +void treathead(t_cookie * cookie, const char *adr, const char *fil, htsblk * retour, char *rcvd) { int p; @@ -1388,7 +1388,7 @@ void treathead(t_cookie * cookie, char *adr, char *fil, htsblk * retour, } } else if ((p = strfield(rcvd, "Content-Range:")) != 0) { // Content-Range: bytes 0-70870/70871 - char *a; + const char *a; for(a = rcvd + p; is_space(*a); a++) ; if (strncasecmp(a, "bytes ", 6) == 0) { @@ -2019,7 +2019,7 @@ htsblk http_location(httrackp * opt, char *adr, char *fil, char *loc) { // en cas de moved xx, dans location // abandonne désormais au bout de 30 secondes (aurevoir les sites // qui nous font poireauter 5 heures..) -> -2=timeout -htsblk http_test(httrackp * opt, char *adr, char *fil, char *loc) { +htsblk http_test(httrackp * opt, const char *adr, const char *fil, char *loc) { T_SOC soc; htsblk retour; @@ -3153,8 +3153,8 @@ void rawlinput(FILE * fp, char *s, int max) { } //cherche chaine, case insensitive -char *strstrcase(char *s, char *o) { - while((*s) && (strfield(s, o) == 0)) +char *strstrcase(char *s, const char *o) { + while(*s && strfield(s, o) == 0) s++; if (*s == '\0') return NULL; @@ -4277,7 +4277,7 @@ int may_unknown2(httrackp * opt, const char *mime, const char *filename) { // -- Utils fichiers // pretty print for i/o -void fprintfio(FILE * fp, char *buff, char *prefix) { +void fprintfio(FILE * fp, const char *buff, const char *prefix) { char nl = 1; while(*buff) { @@ -4392,7 +4392,7 @@ typedef struct { char path[1024 + 4]; int init; } hts_rootdir_strc; -HTSEXT_API char *hts_rootdir(char *file) { +HTSEXT_API const char *hts_rootdir(char *file) { static hts_rootdir_strc strc = { "", 0 }; if (file) { if (!strc.init) { diff --git a/src/htslib.h b/src/htslib.h index 615dd41..37b430d 100644 --- a/src/htslib.h +++ b/src/htslib.h @@ -249,11 +249,12 @@ LLint check_downloadable_bytes(int rate); HTSEXT_API int hts_uninit_module(void); // fonctions principales -T_SOC http_fopen(httrackp * opt, char *adr, char *fil, htsblk * retour); +T_SOC http_fopen(httrackp * opt, const char *adr, const char *fil, htsblk * retour); T_SOC http_xfopen(httrackp * opt, int mode, int treat, int waitconnect, - char *xsend, char *adr, char *fil, htsblk * retour); -int http_sendhead(httrackp * opt, t_cookie * cookie, int mode, char *xsend, - char *adr, char *fil, char *referer_adr, char *referer_fil, + const char *xsend, const char *adr, const char *fil, htsblk * retour); +int http_sendhead(httrackp * opt, t_cookie * cookie, int mode, const char *xsend, + const char *adr, const char *fil, + const char *referer_adr, const char *referer_fil, htsblk * retour); //int newhttp(char* iadr,char* err=NULL); @@ -264,12 +265,12 @@ HTS_INLINE int deleteaddr(htsblk * r); HTS_INLINE void deletesoc(T_SOC soc); HTS_INLINE void deletesoc_r(htsblk * r); htsblk http_location(httrackp * opt, char *adr, char *fil, char *loc); -htsblk http_test(httrackp * opt, char *adr, char *fil, char *loc); +htsblk http_test(httrackp * opt, const char *adr, const char *fil, char *loc); int check_readinput(htsblk * r); int check_readinput_t(T_SOC soc, int timeout); -void treathead(t_cookie * cookie, char *adr, char *fil, htsblk * retour, +void treathead(t_cookie * cookie, const char *adr, const char *fil, htsblk * retour, char *rcvd); -void treatfirstline(htsblk * retour, char *rcvd); +void treatfirstline(htsblk * retour, const char *rcvd); // sous-fonctions LLint http_xfread1(htsblk * r, int bufl); @@ -315,7 +316,7 @@ int linputsoc_t(T_SOC soc, char *s, int max, int timeout); int linput_trim(FILE * fp, char *s, int max); int linput_cpp(FILE * fp, char *s, int max); void rawlinput(FILE * fp, char *s, int max); -char *strstrcase(char *s, char *o); +char *strstrcase(char *s, const char *o); int ident_url_absolute(const char *url, char *adr, char *fil); void fil_simplifie(char *f); int is_unicode_utf8(const char *buffer, const size_t size); @@ -345,7 +346,7 @@ void hts_lowcase(char *s); void hts_replace(char *s, char from, char to); int multipleStringMatch(const char *s, const char *match); -void fprintfio(FILE * fp, char *buff, char *prefix); +void fprintfio(FILE * fp, const char *buff, const char *prefix); #ifdef _WIN32 #else diff --git a/src/htsname.c b/src/htsname.c index 8e25e2e..0ca6540 100644 --- a/src/htsname.c +++ b/src/htsname.c @@ -577,7 +577,7 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, strcpybuff(curr_fil, mov_fil); stop_looping = 1; } else if (*mov_url) { - char *methode; + const char *methode; if (!get_test_request) methode = BACK_ADD_TEST; // tester avec HEAD diff --git a/src/htsopt.h b/src/htsopt.h index 3b589f8..4a40420 100644 --- a/src/htsopt.h +++ b/src/htsopt.h @@ -374,7 +374,7 @@ struct httrackp { int maxlink; // nombre max de liens int maxfilter; // nombre max de filtres // - char *exec; // adresse du nom de l'éxecutable + const char *exec; // adresse du nom de l'éxecutable // int quiet; // poser des questions autres que wizard? int keyboard; // vérifier stdin diff --git a/src/htsparse.c b/src/htsparse.c index b3778bc..a8ee0f3 100644 --- a/src/htsparse.c +++ b/src/htsparse.c @@ -436,7 +436,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { int back_add_stats = opt->state.back_add_stats; // - char *in_media = NULL; // in other media type (real media and so..) + const char *in_media = NULL; // in other media type (real media and so..) int intag = 0; // on est dans un tag int incomment = 0; // dans un <!-- int inscript = 0; // dans un scipt pour applets javascript) @@ -456,7 +456,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { INSCRIPT_DEFAULT = 256 } INSCRIPT; INSCRIPT inscript_state_pos = INSCRIPT_START; - char *inscript_name = NULL; // script tag name + const char *inscript_name = NULL; // script tag name int inscript_tag = 0; // on est dans un <body onLoad="... terminé par > char inscript_tag_lastc = '\0'; @@ -474,9 +474,9 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { //int parseall_incomment=0; // dans un /* */ (exemple: a = /* URL */ "img.gif";) // - char *intag_start = adr; - char *intag_name = NULL; - char *intag_startattr = NULL; + const char *intag_start = adr; + const char *intag_name = NULL; + const char *intag_startattr = NULL; int intag_start_valid = 0; int intag_ctype = 0; @@ -879,7 +879,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { || check_tag(intag_start, "style") ) ) { - char *a = intag_start; // < + const char *a = intag_start; // < // ** while(is_realspace(*(--a))); if (*a == '<') { // sûr que c'est un tag? @@ -1405,7 +1405,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { foo "url" */ char expected = '='; // caractère attendu après - char *expected_end = ";"; + const char *expected_end = ";"; int can_avoid_quotes = 0; char quotes_replacement = '\0'; int ensure_not_mime = 0; @@ -2718,8 +2718,8 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { // int patch_it = 0; int add_url = 0; - char *cat_name = NULL; - char *cat_data = NULL; + const char *cat_name = NULL; + const char *cat_data = NULL; int cat_nb = 0; int cat_data_len = 0; diff --git a/src/htsrobots.c b/src/htsrobots.c index 0b70257..e7656b3 100644 --- a/src/htsrobots.c +++ b/src/htsrobots.c @@ -45,7 +45,7 @@ Please visit our Website: http://www.httrack.com // -- robots -- // fil="" : vérifier si règle déja enregistrée -int checkrobots(robots_wizard * robots, char *adr, char *fil) { +int checkrobots(robots_wizard * robots, const char *adr, const char *fil) { while(robots) { if (strfield2(robots->adr, adr)) { if (fil[0]) { @@ -60,7 +60,7 @@ int checkrobots(robots_wizard * robots, char *adr, char *fil) { return -1; // interdit } } else { // relatif - if (strstrcase(fil, line)) { + if (strstrcase((char*) fil, line)) { return -1; } } @@ -74,7 +74,7 @@ int checkrobots(robots_wizard * robots, char *adr, char *fil) { } return 0; } -int checkrobots_set(robots_wizard * robots, char *adr, char *data) { +int checkrobots_set(robots_wizard * robots, const char *adr, const char *data) { if (((int) strlen(adr)) >= sizeof(robots->adr) - 2) return 0; if (((int) strlen(data)) >= sizeof(robots->token) - 2) diff --git a/src/htsrobots.h b/src/htsrobots.h index 8fcc1c6..9160372 100644 --- a/src/htsrobots.h +++ b/src/htsrobots.h @@ -47,9 +47,9 @@ struct robots_wizard { /* Library internal definictions */ #ifdef HTS_INTERNAL_BYTECODE -int checkrobots(robots_wizard * robots, char *adr, char *fil); +int checkrobots(robots_wizard * robots, const char *adr, const char *fil); void checkrobots_free(robots_wizard * robots); -int checkrobots_set(robots_wizard * robots, char *adr, char *data); +int checkrobots_set(robots_wizard * robots, const char *adr, const char *data); #endif #endif diff --git a/src/htsserver.c b/src/htsserver.c index 30b10bc..3ac0d9d 100644 --- a/src/htsserver.c +++ b/src/htsserver.c @@ -81,7 +81,7 @@ inthash NewLangList = NULL; #include "htsserver.h" -char *gethomedir(void); +const char *gethomedir(void); int commandRunning = 0; int commandEndRequested = 0; int commandEnd = 0; @@ -97,13 +97,13 @@ extern void webhttrack_main(char *cmd); extern void webhttrack_lock(void); extern void webhttrack_release(void); -static int is_image(char *file) { +static int is_image(const char *file) { return ((strstr(file, ".gif") != NULL)); } -static int is_text(char *file) { +static int is_text(const char *file) { return ((strstr(file, ".txt") != NULL)); } -static int is_html(char *file) { +static int is_html(const char *file) { return ((strstr(file, ".htm") != NULL)); } @@ -287,12 +287,12 @@ T_SOC smallserver_init(int *port, char *adr) { // data: 32Kb typedef struct { - char *name; + const char *name; int value; } initIntElt; typedef struct { - char *name; - char *value; + const char *name; + const char *value; } initStrElt; #define SET_ERROR(err) do { \ @@ -326,10 +326,10 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) { { char pth[1024]; - char *initOn[] = { "parseall", "Cache", "ka", + const char *initOn[] = { "parseall", "Cache", "ka", "cookies", "parsejava", "testall", "updhack", "urlhack", "index", NULL }; - initIntElt initInt[] = { + const initIntElt initInt[] = { {"filter", 4}, {"travel", 2}, {"travel2", 1}, @@ -383,7 +383,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) { char line2[1024]; T_SOC soc_c; LLint length = 0; - char *error_redirect = NULL; + const char *error_redirect = NULL; line[0] = '\0'; buffer[0] = '\0'; @@ -498,7 +498,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) { strcatbuff(buffer, "&"); while(s && (e = strchr(s, '=')) && (f = strchr(s, '&'))) { - char *ua; + const char *ua; String sua = STRING_EMPTY; *e = *f = '\0'; @@ -786,7 +786,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) { if (url && *++url == '/' && (pos = strchr(url, ' ')) && !(*pos = '\0')) { char fsfile[1024]; - char *file; + const char *file; FILE *fp; char *qpos; @@ -861,10 +861,10 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) { "HTTP/1.0 302 Redirect\r\n" "Connection: close\r\n" "Server: httrack-small-server\r\n"; intptr_t adr = 0; - char *newfile = file; + const char *newfile = file; if (inthash_readptr(NewLangList, "redirect", &adr) && adr != 0) { - char *newadr = (char *) adr; + const char *newadr = (char *) adr; if (*newadr) { newfile = newadr; @@ -939,6 +939,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) { } } else if ((p = strfield(name, "do:"))) { char *pos2; + char empty[2] = ""; name += p; format = 1; @@ -948,7 +949,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) { *pos2 = '\0'; pos2++; } else { - pos2 = ""; + pos2 = empty; } if (strcmp(name, "output-mode") == 0) { if (strcmp(pos2, "html") == 0) { @@ -1063,7 +1064,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) { if (pos2 != NULL) { *pos2 = '\0'; if (inthash_readptr(NewLangList, name, &adr) || ztest) { - char *newadr = (char *) adr; + const char *newadr = (char *) adr; if (!newadr) newadr = ""; @@ -1469,7 +1470,7 @@ static int htslang_load(char *limit_to, const char *path) { /* Load master file (list of keys and internal keys) */ if (!limit_to) { - char *mname = "lang.def"; + const char *mname = "lang.def"; FILE *fp = fopen(fconcat(catbuff, sizeof(catbuff), path, mname), "rb"); if (fp) { @@ -1733,7 +1734,7 @@ static int LANG_SEARCH(const char *path, const char *iso) { return found; } -static int LANG_LIST(const char *path, char *buffer, size_t size) { +static int LANG_LIST(const char *path, char *buffer, size_t buffer_size) { char lang_str[1024]; int i = 0; int curr_lng = LANG_T(path, -1); @@ -1741,12 +1742,12 @@ static int LANG_LIST(const char *path, char *buffer, size_t size) { buffer[0] = '\0'; do { QLANG_T(i); - strlcpybuff(lang_str, "LANGUAGE_NAME", size); + strlcpybuff(lang_str, "LANGUAGE_NAME", buffer_size); htslang_load(lang_str, path); if (strlen(lang_str) > 0) { if (buffer[0]) strcatbuff(buffer, "\n"); - strcatbuff(buffer, lang_str); + strlcatbuff(buffer, lang_str, buffer_size); } i++; } while(strlen(lang_str) > 0); diff --git a/src/htsserver.h b/src/htsserver.h index 3690bce..7daeec0 100644 --- a/src/htsserver.h +++ b/src/htsserver.h @@ -100,7 +100,7 @@ int htslang_uninit(void); /* Static definitions */ -HTS_UNUSED static char *gethomedir(void); +HTS_UNUSED static const char *gethomedir(void); HTS_UNUSED static int linput_cpp(FILE * fp, char *s, int max); HTS_UNUSED static int linput_trim(FILE * fp, char *s, int max); HTS_UNUSED static int fexist(const char *s); @@ -163,8 +163,8 @@ HTS_UNUSED static int linputsoc_t(T_SOC soc, char *s, int max, int timeout) { return -1; } -static char *gethomedir(void) { - char *home = getenv("HOME"); +static const char *gethomedir(void) { + const char *home = getenv("HOME"); if (home) return home; @@ -267,11 +267,11 @@ static int ehexh(char c) { return 0; } -static int ehex(char *s) { +static int ehex(const char *s) { return 16 * ehexh(*s) + ehexh(*(s + 1)); } -HTS_UNUSED static void unescapehttp(char *s, String * tempo) { +HTS_UNUSED static void unescapehttp(const char *s, String * tempo) { size_t i; for(i = 0; s[i] != '\0'; i++) { diff --git a/src/htstools.c b/src/htstools.c index de81d57..65443ad 100644 --- a/src/htstools.c +++ b/src/htstools.c @@ -91,11 +91,11 @@ static int ehexh(char c) { return 0; } -static int ehex(char *s) { +static int ehex(const char *s) { return 16 * ehexh(*s) + ehexh(*(s + 1)); } -static void unescapehttp(char *s, String * tempo) { +static void unescapehttp(const char *s, String * tempo) { size_t i; for(i = 0; s[i] != '\0'; i++) { @@ -708,19 +708,18 @@ HTS_INLINE int rech_sampletag(const char *adr, const char *s) { } // teste si le tag contenu dans from est égal à "tag" -HTS_INLINE int check_tag(char *from, const char *tag) { - char *a = from + 1; +HTS_INLINE int check_tag(const char *from, const char *tag) { + const char *a = from + 1; int i = 0; char s[256]; while(is_space(*a)) a++; - while((isalnum((unsigned char) *a) || (*a == '/')) && (i < 250)) { - s[i++] = *a; - a++; + for( ; (isalnum((unsigned char) *a) || (*a == '/')) && i + 1 < sizeof(s) ; i++, a++) { + s[i] = *a; } - s[i++] = '\0'; - return (strfield2(s, tag)); // comparer + s[i] = '\0'; + return strfield2(s, tag); // comparer } // teste si un fichier dépasse le quota @@ -870,7 +869,7 @@ HTSEXT_API int hts_buildtopindex(httrackp * opt, const char *path, assertf(sortedElts != NULL); if (sortedElts != NULL) { int i; - char *category = ""; + const char *category = ""; /* Build array */ struct topindex_chain *chain = startchain; diff --git a/src/htstools.h b/src/htstools.h index 953a691..8db206e 100644 --- a/src/htstools.h +++ b/src/htstools.h @@ -84,7 +84,7 @@ HTS_INLINE int rech_tageq_all(const char *adr, const char *s); //HTS_INLINE int rech_tageq(const char* adr,const char* s); HTS_INLINE int rech_sampletag(const char *adr, const char *s); HTS_INLINE int rech_endtoken(const char *adr, const char **start); -HTS_INLINE int check_tag(char *from, const char *tag); +HTS_INLINE int check_tag(const char *from, const char *tag); int verif_backblue(httrackp * opt, const char *base); int verif_external(httrackp * opt, int nb, int test); diff --git a/src/htsweb.c b/src/htsweb.c index d428c5d..603d8db 100644 --- a/src/htsweb.c +++ b/src/htsweb.c @@ -238,7 +238,7 @@ static void back_launch_cmd(void *pP) { commandReturnCmdl = strdup(cmd); /* split */ - argv[0] = "webhttrack"; + argv[0] = strdup("webhttrack"); argv[1] = cmd; argc++; i = 0; diff --git a/src/htswizard.c b/src/htswizard.c index 15ca5c0..e8ea235 100644 --- a/src/htswizard.c +++ b/src/htswizard.c @@ -60,8 +60,8 @@ Please visit our Website: http://www.httrack.com } while(0) typedef struct htspair_t { - char *tag; - char *attr; + const char *tag; + const char *attr; } htspair_t; /* "embedded" */ @@ -80,8 +80,9 @@ htspair_t hts_detect_embed[] = { /* Internal */ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, - lien_url ** liens, char *adr, char *fil, char *tag, - char *attribute, int *set_prio_to, + lien_url ** liens, const char *adr, + const char *fil, const char *tag, + const char *attribute, int *set_prio_to, int *just_test_it); /* @@ -104,8 +105,10 @@ retour: -1 pas d'avis */ -int hts_acceptlink(httrackp * opt, int ptr, int lien_tot, lien_url ** liens, - char *adr, char *fil, char *tag, char *attribute, +int hts_acceptlink(httrackp * opt, int ptr, + int lien_tot, lien_url ** liens, + const char *adr, const char *fil, + const char *tag, const char *attribute, int *set_prio_to, int *just_test_it) { int forbidden_url = hts_acceptlink_(opt, ptr, lien_tot, liens, adr, fil, tag, attribute, set_prio_to, @@ -134,8 +137,9 @@ static int cmp_token(const char *tag, const char *cmp) { } static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, - lien_url ** liens, char *adr, char *fil, char *tag, - char *attribute, int *set_prio_to, + lien_url ** liens, + const char *adr, const char *fil, const char *tag, + const char *attribute, int *set_prio_to, int *just_test_it) { int forbidden_url = -1; int meme_adresse; @@ -515,7 +519,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, // filters { int jok; - char *mdepth = ""; + const char *mdepth = ""; // filters, 0=sait pas 1=ok -1=interdit { @@ -864,12 +868,12 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, } int hts_acceptmime(httrackp * opt, int ptr, int lien_tot, lien_url ** liens, - char *adr, char *fil, char *mime) { + const char *adr, const char *fil, const char *mime) { #define _FILTERS (*opt->filters.filters) #define _FILTERS_PTR (opt->filters.filptr) #define _ROBOTS ((robots_wizard*)opt->robotsptr) int forbidden_url = -1; - char *mdepth = ""; + const char *mdepth = ""; int jokDepth = 0; int jok = 0; @@ -906,7 +910,7 @@ int hts_acceptmime(httrackp * opt, int ptr, int lien_tot, lien_url ** liens, } // tester taille -int hts_testlinksize(httrackp * opt, char *adr, char *fil, LLint size) { +int hts_testlinksize(httrackp * opt, const char *adr, const char *fil, LLint size) { int jok = 0; if (size >= 0) { diff --git a/src/htswizard.h b/src/htswizard.h index 3c78884..b4d10f8 100644 --- a/src/htswizard.h +++ b/src/htswizard.h @@ -50,11 +50,12 @@ typedef struct lien_url lien_url; #endif int hts_acceptlink(httrackp * opt, int ptr, int lien_tot, lien_url ** liens, - char *adr, char *fil, char *tag, char *attribute, + const char *adr, const char *fil, + const char *tag, const char *attribute, int *set_prio_to_0, int *just_test_it); -int hts_testlinksize(httrackp * opt, char *adr, char *fil, LLint size); +int hts_testlinksize(httrackp * opt, const char *adr, const char *fil, LLint size); int hts_acceptmime(httrackp * opt, int ptr, int lien_tot, lien_url ** liens, - char *adr, char *fil, char *mime); + const char *adr, const char *fil, const char *mime); #endif #endif diff --git a/src/httrack-library.h b/src/httrack-library.h index d92e377..cfc049b 100644 --- a/src/httrack-library.h +++ b/src/httrack-library.h @@ -198,7 +198,7 @@ HTSEXT_API char *jump_normalized(const char *); HTSEXT_API char *jump_toport(const char *); HTSEXT_API char *fil_normalized(const char *source, char *dest); HTSEXT_API char *adr_normalized(const char *source, char *dest); -HTSEXT_API char *hts_rootdir(char *file); +HTSEXT_API const char *hts_rootdir(char *file); /* Escaping URLs */ HTSEXT_API void unescape_amp(char *s); @@ -239,7 +239,7 @@ HTSEXT_API void get_httptype(httrackp * opt, char *s, const char *fil, HTSEXT_API int is_knowntype(httrackp * opt, const char *fil); HTSEXT_API int is_userknowntype(httrackp * opt, const char *fil); HTSEXT_API int is_dyntype(const char *fil); -HTSEXT_API char *get_ext(char *catbuff, size_t size, const char *fil); +HTSEXT_API const char *get_ext(char *catbuff, size_t size, const char *fil); /* Ugly string tools */ HTSEXT_API char *concat(char *catbuff, size_t size, const char *a, const char *b); diff --git a/src/proxy/proxytrack.h b/src/proxy/proxytrack.h index 6936218..6e4f755 100644 --- a/src/proxy/proxytrack.h +++ b/src/proxy/proxytrack.h @@ -109,8 +109,8 @@ HTS_UNUSED static void proxytrack_print_log(const char *severity, const char *fo "<!-- _-._.--._._-._.--._._-._.--._._-._.--._._-._.--._. -->\r\n" \ "<!-- End Disable IE Friendly HTTP Error Messages -->\r\n" -HTS_UNUSED static char *gethomedir(void) { - char *home = getenv("HOME"); +HTS_UNUSED static const char *gethomedir(void) { + const char *home = getenv("HOME"); if (home) return home; diff --git a/src/proxy/store.c b/src/proxy/store.c index daa9952..76f245a 100644 --- a/src/proxy/store.c +++ b/src/proxy/store.c @@ -1253,7 +1253,7 @@ static int PT_SaveCache__New_Fun(void *arg, const char *url, PT_Element element) headersSize = 0; /* */ { - char *message; + const char *message; if (strlen(element->msg) < 32) { message = element->msg; |