diff options
author | Xavier Roche <xroche@users.noreply.github.com> | 2014-06-10 20:27:13 +0000 |
---|---|---|
committer | Xavier Roche <xroche@users.noreply.github.com> | 2014-06-10 20:27:13 +0000 |
commit | 713b83f7b406858269863d92865b715470d6335c (patch) | |
tree | 79eb2733939d29388f0776f68da4b053427a61c9 | |
parent | 82e61ae9d68114bdcd6fafdb8bf823ae9ce69bef (diff) |
Added the following compiler flags:
* -Wcast-qual
* -Wmissing-parameter-type
* -Wold-style-definition
-rwxr-xr-x | configure | 110 | ||||
-rw-r--r-- | configure.ac | 8 | ||||
-rwxr-xr-x | libtest/callbacks-example-log.c | 6 | ||||
-rw-r--r-- | src/htsback.c | 4 | ||||
-rw-r--r-- | src/htsbauth.c | 2 | ||||
-rw-r--r-- | src/htscharset.c | 4 | ||||
-rw-r--r-- | src/htscore.c | 4 | ||||
-rw-r--r-- | src/htscore.h | 2 | ||||
-rw-r--r-- | src/htshash.c | 21 | ||||
-rw-r--r-- | src/htshelp.c | 2 | ||||
-rw-r--r-- | src/htsindex.c | 6 | ||||
-rw-r--r-- | src/htslib.c | 104 | ||||
-rw-r--r-- | src/htslib.h | 10 | ||||
-rw-r--r-- | src/htsmd5.c | 2 | ||||
-rw-r--r-- | src/htsname.c | 10 | ||||
-rw-r--r-- | src/htsparse.c | 101 | ||||
-rw-r--r-- | src/htsrobots.c | 2 | ||||
-rw-r--r-- | src/htstools.c | 12 | ||||
-rw-r--r-- | src/htswizard.c | 18 | ||||
-rw-r--r-- | src/httrack-library.h | 9 | ||||
-rw-r--r-- | src/minizip/ioapi.c | 3 | ||||
-rw-r--r-- | src/minizip/ioapi.c.diff | 17 | ||||
-rw-r--r-- | src/minizip/zip.c | 5 | ||||
-rw-r--r-- | src/minizip/zip.c.diff | 46 |
24 files changed, 327 insertions, 181 deletions
@@ -11778,8 +11778,9 @@ LT_CV_OBJDIR=$lt_cv_objdir ### Default CFLAGS DEFAULT_CFLAGS="-Wall -Wformat -Wformat-security \ --Wmultichar -Wwrite-strings -Wcast-align -Wstrict-prototypes \ --Wmissing-prototypes -Wmissing-declarations -Wdeclaration-after-statement \ +-Wmultichar -Wwrite-strings -Wcast-qual -Wcast-align \ +-Wstrict-prototypes -Wmissing-prototypes \ +-Wmissing-declarations -Wdeclaration-after-statement \ -Wpointer-arith -Wsequence-point -Wnested-externs \ -D_REENTRANT" @@ -11857,6 +11858,41 @@ else : fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -Waddress" >&5 +$as_echo_n "checking whether C compiler accepts -Waddress... " >&6; } +if ${ax_cv_check_cflags___Waddress+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -Waddress" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv_check_cflags___Waddress=yes +else + ax_cv_check_cflags___Waddress=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$ax_check_save_flags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___Waddress" >&5 +$as_echo "$ax_cv_check_cflags___Waddress" >&6; } +if test x"$ax_cv_check_cflags___Waddress" = xyes; then : + DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Waddress" +else + : +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -Wuninitialized" >&5 $as_echo_n "checking whether C compiler accepts -Wuninitialized... " >&6; } if ${ax_cv_check_cflags___Wuninitialized+:} false; then : @@ -11962,6 +11998,76 @@ else : fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -Wmissing-parameter-type" >&5 +$as_echo_n "checking whether C compiler accepts -Wmissing-parameter-type... " >&6; } +if ${ax_cv_check_cflags___Wmissing_parameter_type+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -Wmissing-parameter-type" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv_check_cflags___Wmissing_parameter_type=yes +else + ax_cv_check_cflags___Wmissing_parameter_type=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$ax_check_save_flags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___Wmissing_parameter_type" >&5 +$as_echo "$ax_cv_check_cflags___Wmissing_parameter_type" >&6; } +if test x"$ax_cv_check_cflags___Wmissing_parameter_type" = xyes; then : + DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wmissing-parameter-type" +else + : +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -Wold-style-definition" >&5 +$as_echo_n "checking whether C compiler accepts -Wold-style-definition... " >&6; } +if ${ax_cv_check_cflags___Wold_style_definition+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -Wold-style-definition" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv_check_cflags___Wold_style_definition=yes +else + ax_cv_check_cflags___Wold_style_definition=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$ax_check_save_flags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___Wold_style_definition" >&5 +$as_echo "$ax_cv_check_cflags___Wold_style_definition" >&6; } +if test x"$ax_cv_check_cflags___Wold_style_definition" = xyes; then : + DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wold-style-definition" +else + : +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -fstrict-aliasing -Wstrict-aliasing=2" >&5 $as_echo_n "checking whether C compiler accepts -fstrict-aliasing -Wstrict-aliasing=2... " >&6; } if ${ax_cv_check_cflags___fstrict_aliasing__Wstrict_aliasing_2+:} false; then : diff --git a/configure.ac b/configure.ac index cf28234..bedc3e1 100644 --- a/configure.ac +++ b/configure.ac @@ -52,8 +52,9 @@ AC_SUBST(VERSION_INFO) ### Default CFLAGS DEFAULT_CFLAGS="-Wall -Wformat -Wformat-security \ --Wmultichar -Wwrite-strings -Wcast-align -Wstrict-prototypes \ --Wmissing-prototypes -Wmissing-declarations -Wdeclaration-after-statement \ +-Wmultichar -Wwrite-strings -Wcast-qual -Wcast-align \ +-Wstrict-prototypes -Wmissing-prototypes \ +-Wmissing-declarations -Wdeclaration-after-statement \ -Wpointer-arith -Wsequence-point -Wnested-externs \ -D_REENTRANT" AC_SUBST(DEFAULT_CFLAGS) @@ -63,9 +64,12 @@ AC_SUBST(DEFAULT_LDFLAGS) ### Additional flags (if supported) AX_CHECK_COMPILE_FLAG([-Wparentheses], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wparentheses"]) AX_CHECK_COMPILE_FLAG([-Winit-self], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Winit-self"]) +AX_CHECK_COMPILE_FLAG([-Waddress], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Waddress"]) AX_CHECK_COMPILE_FLAG([-Wuninitialized], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wuninitialized"]) AX_CHECK_COMPILE_FLAG([-Wformat=2], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wformat=2"]) AX_CHECK_COMPILE_FLAG([-Wformat-nonliteral], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wformat-nonliteral"]) +AX_CHECK_COMPILE_FLAG([-Wmissing-parameter-type], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wmissing-parameter-type"]) +AX_CHECK_COMPILE_FLAG([-Wold-style-definition], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wold-style-definition"]) AX_CHECK_COMPILE_FLAG([-fstrict-aliasing -Wstrict-aliasing=2], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -fstrict-aliasing -Wstrict-aliasing=2"]) AX_CHECK_LINK_FLAG([-Wl,--discard-all], [DEFAULT_LDLAGS="$DEFAULT_LDLAGS -Wl,--discard-all"]) AX_CHECK_LINK_FLAG([-Wl,--no-undefined], [DEFAULT_LDLAGS="$DEFAULT_LDLAGS -Wl,--no-undefined"]) diff --git a/libtest/callbacks-example-log.c b/libtest/callbacks-example-log.c index d7d1465..94f0332 100755 --- a/libtest/callbacks-example-log.c +++ b/libtest/callbacks-example-log.c @@ -100,9 +100,9 @@ EXTERNAL_FUNCTION int hts_plug(httrackp * opt, const char *argv) { if (arg == NULL) arg = "log-wrapper-info"; hts_log(opt, arg, "* plugging functions"); - CHAIN_FUNCTION(opt, check_html, process_file, (char *) arg); - CHAIN_FUNCTION(opt, start, start_of_mirror, (char *) arg); - CHAIN_FUNCTION(opt, end, end_of_mirror, (char *) arg); + CHAIN_FUNCTION(opt, check_html, process_file, (void *) (uintptr_t) arg); + CHAIN_FUNCTION(opt, start, start_of_mirror, (void *) (uintptr_t) arg); + CHAIN_FUNCTION(opt, end, end_of_mirror, (void *) (uintptr_t) arg); hts_log(opt, arg, "* module successfully plugged"); return 1; /* success */ diff --git a/src/htsback.c b/src/htsback.c index b5a0db7..bae89eb 100644 --- a/src/htsback.c +++ b/src/htsback.c @@ -2131,7 +2131,7 @@ void back_solve(httrackp * opt, lien_back * back) { else a = back->r.req.proxy.name; assertf(a != NULL); - a = jump_protocol(a); + a = jump_protocol_const(a); if (check_hostname_dns(a)) { hts_log_print(opt, LOG_DEBUG, "resolved: %s", a); } else { @@ -3240,7 +3240,7 @@ void back_wait(struct_back * sback, httrackp * opt, cache_back * cache, fprintf(ioinfo, "[%d] response for %s%s:\r\ncode=%d\r\n", back[i].r.debugid, - jump_identification(back[i].url_adr), + jump_identification_const(back[i].url_adr), back[i].url_fil, back[i].r.statuscode); fprintfio(ioinfo, back[i].r.adr, ">>> "); fprintf(ioinfo, "\r\n"); diff --git a/src/htsbauth.c b/src/htsbauth.c index 12af086..f0d6240 100644 --- a/src/htsbauth.c +++ b/src/htsbauth.c @@ -461,7 +461,7 @@ char *bauth_check(t_cookie * cookie, const char *adr, const char *fil) { char *bauth_prefix(char *prefix, const char *adr, const char *fil) { char *a; - strcpybuff(prefix, jump_identification(adr)); + strcpybuff(prefix, jump_identification_const(adr)); strcatbuff(prefix, fil); a = strchr(prefix, '?'); if (a) diff --git a/src/htscharset.c b/src/htscharset.c index 50be2d2..48cef69 100644 --- a/src/htscharset.c +++ b/src/htscharset.c @@ -35,6 +35,8 @@ Please visit our Website: http://www.httrack.com #include "punycode.h" #include "htssafe.h" +#include <stdint.h> + int hts_isStringAscii(const char *s, size_t size) { size_t i; @@ -441,7 +443,7 @@ static char *hts_convertStringCharset(const char *s, size_t size, const iconv_t cp = iconv_open(to, from); if (cp != (iconv_t) - 1) { - char *inbuf = (char *) s; + char *inbuf = (char*) (uintptr_t) s; /* ugly iconv api, sheesh */ size_t inbytesleft = size; size_t outbufCapa = 0; char *outbuf = NULL; diff --git a/src/htscore.c b/src/htscore.c index 80f7772..5a4871d 100644 --- a/src/htscore.c +++ b/src/htscore.c @@ -609,7 +609,7 @@ int httpmirror(char *url1, httrackp * opt) { // initialiser hachage hash_init(opt, &hash, opt->urlhack); // note: we need a cast because of the const - hash.liens = (const lien_url ***) &opt->liens; + hash.liens = (const lien_url *const*const*) &opt->liens; // copier adresse(s) dans liste des adresses { @@ -2483,7 +2483,7 @@ void host_ban(httrackp * opt, int ptr, while((heap(i)->adr[l]) && (l < 1020)) l++; if ((l > 0) && (l < 1020)) { // sécurité - if (strfield2(jump_identification(heap(i)->adr), host)) { // host + if (strfield2(jump_identification_const(heap(i)->adr), host)) { // host hts_log_print(opt, LOG_DEBUG, "Cancel: %s%s", heap(i)->adr, heap(i)->fil); hts_invalidate_link(opt, i); // invalidate hashtable entry diff --git a/src/htscore.h b/src/htscore.h index 48785f7..c3572cb 100644 --- a/src/htscore.h +++ b/src/htscore.h @@ -201,7 +201,7 @@ typedef struct hash_struct hash_struct; #endif struct hash_struct { /* Links big array reference */ - const lien_url ***liens; + const lien_url *const*const*liens; /* Savename (case insensitive ; lowercased) */ inthash sav; /* Address and path */ diff --git a/src/htshash.c b/src/htshash.c index 8ce5f77..9cf4b66 100644 --- a/src/htshash.c +++ b/src/htshash.c @@ -103,11 +103,12 @@ static inthash_hashkeys key_adrfil_hashes_generic(void *arg, inthash_key_const value, const int former) { hash_struct *const hash = (hash_struct*) arg; - const lien_url*const lien = (lien_url*) value; + const lien_url*const lien = (const lien_url*) value; const char *const adr = !former ? lien->adr : lien->former_adr; const char *const fil = !former ? lien->fil : lien->former_fil; const char *const adr_norm = adr != NULL ? - ( hash->normalized ? jump_normalized(adr) : jump_identification(adr) ) + ( hash->normalized ? jump_normalized_const(adr) + : jump_identification_const(adr) ) : NULL; // copy address @@ -133,8 +134,8 @@ static int key_adrfil_equals_generic(void *arg, const int former) { hash_struct *const hash = (hash_struct*) arg; const int normalized = hash->normalized; - const lien_url*const a = (lien_url*) a_; - const lien_url*const b = (lien_url*) b_; + const lien_url*const a = (const lien_url*) a_; + const lien_url*const b = (const lien_url*) b_; const char *const a_adr = !former ? a->adr : a->former_adr; const char *const b_adr = !former ? b->adr : b->former_adr; const char *const a_fil = !former ? a->fil : a->former_fil; @@ -149,8 +150,10 @@ static int key_adrfil_equals_generic(void *arg, assertf(b_fil != NULL); // skip scheme and authentication to the domain (possibly without www.) - ja = normalized ? jump_normalized(a_adr) : jump_identification(a_adr); - jb = normalized ? jump_normalized(b_adr) : jump_identification(b_adr); + ja = normalized + ? jump_normalized_const(a_adr) : jump_identification_const(a_adr); + jb = normalized + ? jump_normalized_const(b_adr) : jump_identification_const(b_adr); assertf(ja != NULL); assertf(jb != NULL); if (strcasecmp(ja, jb) != 0) { @@ -171,7 +174,7 @@ static const char* key_adrfil_debug_print_(void *arg, inthash_key_const a_, const int former) { hash_struct *const hash = (hash_struct*) arg; - const lien_url*const a = (lien_url*) a_; + const lien_url*const a = (const lien_url*) a_; const char *const a_adr = !former ? a->adr : a->former_adr; const char *const a_fil = !former ? a->fil : a->former_fil; snprintf(hash->normfil, sizeof(hash->normfil), "%s%s", a_adr, a_fil); @@ -327,10 +330,10 @@ void hash_write(hash_struct * hash, size_t lpos) { inthash_write(hash->sav, (*hash->liens)[lpos]->sav, lpos); /* second entry: URL address and path */ - inthash_write(hash->adrfil, (char*) (*hash->liens)[lpos], lpos); + inthash_write(hash->adrfil, (*hash->liens)[lpos], lpos); /* third entry: URL address and path before redirect */ if ((*hash->liens)[lpos]->former_adr) { // former_adr existe? - inthash_write(hash->former_adrfil, (char*) (*hash->liens)[lpos], lpos); + inthash_write(hash->former_adrfil, (*hash->liens)[lpos], lpos); } } diff --git a/src/htshelp.c b/src/htshelp.c index 2416030..acd0e3c 100644 --- a/src/htshelp.c +++ b/src/htshelp.c @@ -272,7 +272,7 @@ void help_wizard(httrackp * opt) { if (strnotempty(str)) { while((a = strchr(str, ' '))) *a = ':'; // port - if (!strchr(jump_identification(str), ':')) { + if (!strchr(jump_identification_const(str), ':')) { char str2[256]; printf("\nProxy port (return=8080) :"); diff --git a/src/htsindex.c b/src/htsindex.c index 1dca05c..3c4c9da 100644 --- a/src/htsindex.c +++ b/src/htsindex.c @@ -291,7 +291,7 @@ int index_keyword(const char *html_data, LLint size, const char *mime, e++; /* 0 means "once" */ - if (strncmp((const char *) fslash(catbuff, sizeof(catbuff), (char *) indexpath), filename, strlen(indexpath)) == 0) // couper + if (strncmp((const char *) fslash(catbuff, sizeof(catbuff), (const char *) indexpath), filename, strlen(indexpath)) == 0) // couper strcpybuff(savelst, filename + strlen(indexpath)); else strcpybuff(savelst, filename); @@ -478,8 +478,8 @@ int strcpos(const char *adr, char c) { } int mystrcmp(const void *_e1, const void *_e2) { - char **e1 = (char **) _e1; - char **e2 = (char **) _e2; + const char *const*const e1 = (const char *const*) _e1; + const char *const*const e2 = (const char *const*) _e2; return strcmp(*e1, *e2); } diff --git a/src/htslib.c b/src/htslib.c index 1b29f3a..76c26fd 100644 --- a/src/htslib.c +++ b/src/htslib.c @@ -928,7 +928,7 @@ int http_sendhead(httrackp * opt, t_cookie * cookie, int mode, printf("Proxy Use: for %s%s proxy %d port %d\n", adr, fil, retour->req.proxy.name, retour->req.proxy.port); #endif - print_buffer(&bstr, "http://%s", jump_identification(adr)); + print_buffer(&bstr, "http://%s", jump_identification_const(adr)); } else { // ftp:// en proxy http #if HDEBUG printf("Proxy Use for ftp: for %s%s proxy %d port %d\n", adr, fil, @@ -971,8 +971,8 @@ int http_sendhead(httrackp * opt, t_cookie * cookie, int mode, // tester proxy authentication if (retour->req.proxy.active) { if (link_has_authorization(retour->req.proxy.name)) { // et hop, authentification proxy! - const char *a = jump_identification(retour->req.proxy.name); - const char *astart = jump_protocol(retour->req.proxy.name); + const char *a = jump_identification_const(retour->req.proxy.name); + const char *astart = jump_protocol_const(retour->req.proxy.name); char autorisation[1100]; char user_pass[256]; @@ -1000,7 +1000,7 @@ int http_sendhead(httrackp * opt, t_cookie * cookie, int mode, ) ) { // PAS file:// print_buffer(&bstr, "Referer: http://%s%s"H_CRLF, - jump_identification(referer_adr), referer_fil); + jump_identification_const(referer_adr), referer_fil); } } // HTTP field: referer @@ -1025,7 +1025,7 @@ int http_sendhead(httrackp * opt, t_cookie * cookie, int mode, int max_cookies = 8; do { - b = cookie_find(b, "", jump_identification(adr), fil); // prochain cookie satisfaisant aux conditions + b = cookie_find(b, "", jump_identification_const(adr), fil); // prochain cookie satisfaisant aux conditions if (b != NULL) { max_cookies--; if (!cook) { @@ -1054,7 +1054,7 @@ int http_sendhead(httrackp * opt, t_cookie * cookie, int mode, } { - const char *real_adr = jump_identification(adr); + const char *real_adr = jump_identification_const(adr); // Mandatory per RFC2616 if (!direct_url) { // pas ftp:// par exemple @@ -1103,8 +1103,8 @@ int http_sendhead(httrackp * opt, t_cookie * cookie, int mode, autorisation[0] = '\0'; if (link_has_authorization(adr)) { // ohh une authentification! - const char *a = jump_identification(adr); - const char *astart = jump_protocol(adr); + const char *a = jump_identification_const(adr); + const char *astart = jump_protocol_const(adr); if (!direct_url) { // pas ftp:// par exemple char user_pass[256]; @@ -1149,7 +1149,7 @@ int http_sendhead(httrackp * opt, t_cookie * cookie, int mode, if (_DEBUG_HEAD) { if (ioinfo) { fprintf(ioinfo, "[%d] request for %s%s:\r\n", retour->debugid, - jump_identification(adr), fil); + jump_identification_const(adr), fil); fprintfio(ioinfo, bstr.buffer, "<<< "); fprintf(ioinfo, "\r\n"); fflush(ioinfo); @@ -1528,7 +1528,7 @@ void treathead(t_cookie * cookie, const char *adr, const char *fil, htsblk * ret // initialiser cookie lu actuellement if (adr) - strcpybuff(domain, jump_identification(adr)); // domaine + strcpybuff(domain, jump_identification_const(adr)); // domaine strcpybuff(path, "/"); // chemin (/) strcpybuff(cook_name, ""); // nom cookie (MYCOOK) strcpybuff(cook_value, ""); // valeur (ID=toto,S=1234) @@ -2103,7 +2103,7 @@ T_SOC newhttp(httrackp * opt, const char *_iadr, htsblk * retour, int port, const char *error = "unknown error"; // tester un éventuel id:pass et virer id:pass@ si détecté - const char *const iadr = jump_identification(_iadr); + const char *const iadr = jump_identification_const(_iadr); SOCaddr_clear(server); @@ -2113,7 +2113,7 @@ T_SOC newhttp(httrackp * opt, const char *_iadr, htsblk * retour, int port, // tester un éventuel port if (port == -1) { - char *a = jump_toport(iadr); + const char *a = jump_toport_const(iadr); #if HTS_USEOPENSSL if (retour->ssl) @@ -2362,9 +2362,9 @@ int ident_url_absolute(const char *url, lien_adrfil *adrfil) { p = url + pos; // p pointe sur le début de l'adrfil->adresse, ex: www.truc.fr/sommaire/index.html - q = strchr(jump_identification(p), '/'); + q = strchr(jump_identification_const(p), '/'); if (q == 0) - q = strchr(jump_identification(p), '?'); // http://www.foo.com?bar=1 + q = strchr(jump_identification_const(p), '?'); // http://www.foo.com?bar=1 if (q == 0) q = p + strlen(p); // pointe sur \0 // q pointe sur le chemin, ex: index.html?query=recherche @@ -3123,7 +3123,7 @@ void rawlinput(FILE * fp, char *s, int max) { } //cherche chaine, case insensitive -char *strstrcase(char *s, const char *o) { +const char *strstrcase(const char *s, const char *o) { while(*s && strfield(s, o) == 0) s++; if (*s == '\0') @@ -3344,24 +3344,33 @@ int ishttperror(int err) { return 0; } +/* Declare a non-const version of FUN */ +#define DECLARE_NON_CONST_VERSION(FUN) \ +char *FUN(char *source) { \ + const char *const ret = FUN ##_const(source); \ + return ret != NULL ? source + ( ret - source ) : NULL; \ +} + // retourne le pointeur ou le pointeur + offset si il existe dans la chaine un @ signifiant // une identification -HTSEXT_API char *jump_identification(const char *source) { +HTSEXT_API const char *jump_identification_const(const char *source) { const char *a, *trytofind; if (strcmp(source, "file://") == 0) - return (char *) source; + return source; // rechercher dernier @ (car parfois email transmise dans adresse!) // mais sauter ftp:// éventuel - a = jump_protocol(source); + a = jump_protocol_const(source); trytofind = strrchr_limit(a, '@', strchr(a, '/')); - return (char *) ((trytofind != NULL) ? trytofind : a); + return trytofind != NULL ? trytofind : a; } -HTSEXT_API char *jump_normalized(const char *source) { +HTSEXT_API DECLARE_NON_CONST_VERSION(jump_identification) + +HTSEXT_API const char *jump_normalized_const(const char *source) { if (strcmp(source, "file://") == 0) - return (char *) source; - source = jump_identification(source); + return source; + source = jump_identification_const(source); if (strfield(source, "www") && source[3] != '\0') { if (source[3] == '.') { // www.foo.com -> foo.com source += 4; @@ -3375,12 +3384,14 @@ HTSEXT_API char *jump_normalized(const char *source) { } } } - return (char *) source; + return source; } +HTSEXT_API DECLARE_NON_CONST_VERSION(jump_normalized) + static int sortNormFnc(const void *a_, const void *b_) { - char **a = (char **) a_; - char **b = (char **) b_; + const char *const*const a = (const char *const*) a_; + const char *const*const b = (const char *const*) b_; return strcmp(*a + 1, *b + 1); } @@ -3457,7 +3468,7 @@ HTSEXT_API char *fil_normalized(const char *source, char *dest) { #define endwith(a) ( (len >= (sizeof(a)-1)) ? ( strncmp(dest, a+len-(sizeof(a)-1), sizeof(a)-1) == 0 ) : 0 ); HTSEXT_API char *adr_normalized(const char *source, char *dest) { /* not yet too aggressive (no com<->net<->org checkings) */ - strcpybuff(dest, jump_normalized(source)); + strcpybuff(dest, jump_normalized_const(source)); return dest; } @@ -3465,52 +3476,37 @@ HTSEXT_API char *adr_normalized(const char *source, char *dest) { // find port (:80) or NULL if not found // can handle IPV6 addresses -HTSEXT_API char *jump_toport(const char *source) { +HTSEXT_API const char *jump_toport_const(const char *source) { const char *a, *trytofind; - a = jump_identification(source); + a = jump_identification_const(source); trytofind = strrchr_limit(a, ']', strchr(source, '/')); // find last ] (http://[3ffe:b80:1234::1]:80/foo.html) a = strchr((trytofind) ? trytofind : a, ':'); - return (char *) a; + return a; } +HTSEXT_API DECLARE_NON_CONST_VERSION(jump_toport) + // strrchr, but not too far -char *strrchr_limit(const char *s, char c, const char *limit) { +const char *strrchr_limit(const char *s, char c, const char *limit) { if (limit == NULL) { const char *p = strrchr(s, c); - return (char *) (p ? (p + 1) : NULL); + return p ? (p + 1) : NULL; } else { const char *a = NULL, *p; for(;;) { p = strchr((a) ? a : s, c); if ((p >= limit) || (p == NULL)) - return (char *) a; + return a; a = p + 1; } } } -// strrchr, but not too far -char *strstr_limit(const char *s, const char *sub, const char *limit) { - if (limit == NULL) { - return strstr(s, sub); - } else { - const char *pos = strstr(s, sub); - - if (pos != NULL) { - const char *farpos = strstr(s, limit); - - if (farpos == NULL || pos < farpos) - return (char *) pos; - } - } - return NULL; -} - // retourner adr sans ftp:// -char *jump_protocol(const char *source) { +const char *jump_protocol_const(const char *source) { int p; // scheme @@ -3526,9 +3522,11 @@ char *jump_protocol(const char *source) { // net_path if (strncmp(source, "//", 2) == 0) source += 2; - return (char *) source; + return source; } +DECLARE_NON_CONST_VERSION(jump_protocol) + // codage base 64 a vers b void code64(unsigned char *a, int size_a, unsigned char *b, int crlf) { int i1 = 0, i2 = 0, i3 = 0, i4 = 0; @@ -4668,7 +4666,7 @@ static SOCaddr* hts_dns_resolve_(httrackp * opt, const char *_iadr, assertf(_iadr != NULL); assertf(addr != NULL); - strcpybuff(iadr, jump_identification(_iadr)); + strcpybuff(iadr, jump_identification_const(_iadr)); // couper éventuel : { char *a; @@ -5020,7 +5018,7 @@ HTSEXT_API void hts_set_error_callback(htsErrorCallback handler) { htsCallbackErr = handler; } -HTSEXT_API htsErrorCallback hts_get_error_callback() { +HTSEXT_API htsErrorCallback hts_get_error_callback(void) { return htsCallbackErr; } diff --git a/src/htslib.h b/src/htslib.h index 2212a0b..aec5803 100644 --- a/src/htslib.h +++ b/src/htslib.h @@ -243,7 +243,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, const char *o); +const char *strstrcase(const char *s, const char *o); int ident_url_absolute(const char *url, lien_adrfil *adrfil); void fil_simplifie(char *f); int is_unicode_utf8(const char *buffer, const size_t size); @@ -259,9 +259,9 @@ void give_mimext(char *s, const char *st); int may_bogus_multiple(httrackp * opt, const char *mime, const char *filename); int may_unknown2(httrackp * opt, const char *mime, const char *filename); -char *strrchr_limit(const char *s, char c, const char *limit); -char *strstr_limit(const char *s, const char *sub, const char *limit); -HTS_INLINE char *jump_protocol(const char *source); +const char *strrchr_limit(const char *s, char c, const char *limit); +char *jump_protocol(char *source); +const char *jump_protocol_const(const char *source); void code64(unsigned char *a, int size_a, unsigned char *b, int crlf); #define copychar(catbuff,a) concat(catbuff,(a),NULL) @@ -444,7 +444,7 @@ HTS_STATIC int strfield(const char *f, const char *s) { return 0; } -HTS_STATIC int strcmpnocase(char *a, char *b) { +HTS_STATIC int strcmpnocase(const char *a, const char *b) { while(*a) { int cmp = hichar(*a) - hichar(*b); diff --git a/src/htsmd5.c b/src/htsmd5.c index 2843738..bb2d066 100644 --- a/src/htsmd5.c +++ b/src/htsmd5.c @@ -80,7 +80,7 @@ unsigned long int md5sum32(const char *buff) { return u.hash; } -void md5selftest() { +void md5selftest(void) { static const char str1[] = "The quick brown fox jumps over the lazy dog\n"; static const char str1m[] = "37c4b87edffc5d198ff5a185cee7ee09"; static const char str2[] = "Hello"; diff --git a/src/htsname.c b/src/htsname.c index ec6a839..5224bec 100644 --- a/src/htsname.c +++ b/src/htsname.c @@ -164,11 +164,11 @@ int url_savename(lien_adrfilsave *const afs, static const char *protocol_str[] = { "http", "https", "ftp", "file", "unknown" }; int protocol = PROTOCOL_HTTP; - const char *const adr = jump_identification(adr_complete); + const char *const adr = jump_identification_const(adr_complete); // copy of fil, used for lookups (see urlhack) const char *normadr = adr; const char *normfil = fil_complete; - const char *const print_adr = jump_protocol(adr); + const char *const print_adr = jump_protocol_const(adr); const char *start_pos = NULL, *nom_pos = NULL, *dot_pos = NULL; // Position nom et point // pour changement d'extension ou de nom (content-disposition) @@ -1239,7 +1239,7 @@ int url_savename(lien_adrfilsave *const afs, // (plus la peine : masqué au début) /* { - char* a=jump_identification(afs->save); + char* a = jump_identification(afs->save); if (a!=afs->save) { char BIGSTK tempo[HTS_URLMAXSIZE*2]; char *b; @@ -1307,9 +1307,9 @@ int url_savename(lien_adrfilsave *const afs, int i = 0; while(hts_tbdev[i][0]) { - char *a = afs->save; + const char *a = afs->save; - while((a = strstrcase(a, (char *) hts_tbdev[i]))) { + while((a = strstrcase(a, hts_tbdev[i]))) { switch ((int) a[strlen(hts_tbdev[i])]) { case '\0': case '/': diff --git a/src/htsparse.c b/src/htsparse.c index 811e077..19c7577 100644 --- a/src/htsparse.c +++ b/src/htsparse.c @@ -540,9 +540,9 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { p = -1; // noter, mais sans titre else if (strfield(html, "body")) p = -1; // noter, mais sans titre - else if (((int) (html - r->adr)) >= (r->size - 1)) + else if (html - r->adr >= r->size - 1) p = -1; // noter, mais sans titre - else if ((int) (html - r->adr) >= r->size - 2) // we got to hurry + else if (html - r->adr >= r->size - 2) // we got to hurry p = -1; // xxc xxc xxc } } else @@ -617,8 +617,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { if (str->page_charset_ != NULL && *str->page_charset_ != '\0') { char *const sUtf = - hts_convertStringToUTF8(s, (int) strlen(s), - str->page_charset_); + hts_convertStringToUTF8(s, strlen(s), str->page_charset_); if (sUtf != NULL) { strcpy(s, sUtf); free(sUtf); @@ -726,7 +725,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { strcatbuff(tempo, eol); hts_template_format_str(tempo + strlen(tempo), sizeof(tempo) - strlen(tempo), StringBuff(opt->footer), - jump_identification(urladr()), urlfil(), gmttime, + jump_identification_const(urladr()), urlfil(), gmttime, HTTRACK_VERSIONID, /* EOF */ NULL); strcatbuff(tempo, eol); //fwrite(tempo,1,strlen(tempo),fp); @@ -1218,8 +1217,8 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { printf("robots.txt meta tag detected\n"); #endif if (a) { - if (((int) (a - html)) < 999) { - strncatbuff(tempo, html, (int) (a - html)); + if (a - html < 999) { + strncatbuff(tempo, html, a - html); if (strstrcase(tempo, "content")) { if (strstrcase(tempo, "robots")) { if (strstrcase(tempo, "nofollow")) { @@ -1807,11 +1806,11 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { if (ok != -1) { // continuer // découper le lien do { - if ((*(unsigned char *) eadr) < 32) { // caractère de contrôle (ou \0) + if ((unsigned char) *eadr < 32) { // caractère de contrôle (ou \0) if (!is_space(*eadr)) ok = 0; } - if ((((int) (eadr - html))) > HTS_URLMAXSIZE) // ** trop long, >HTS_URLMAXSIZE caractères (on prévoit HTS_URLMAXSIZE autres pour path) + if (eadr - html > HTS_URLMAXSIZE) // ** trop long, >HTS_URLMAXSIZE caractères (on prévoit HTS_URLMAXSIZE autres pour path) ok = -1; // ne pas traiter ce lien if (ok > 0) { @@ -1856,10 +1855,10 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } while(ok == 1); // Empty link detected - if ((((int) (eadr - html))) <= 1) { // link empty + if (eadr - html <= 1) { // link empty ok = -1; // No if (*html != '#') { // Not empty+unique # - if ((((int) (eadr - html)) == 1)) { // 1=link empty with delim (end_adr-start_adr) + if (eadr - html == 1) { // 1=link empty with delim (end_adr-start_adr) if (quote) { if ((opt->getmode & 1) && (ptr > 0)) { HT_ADD("#"); // We add this for a <href=""> @@ -1883,9 +1882,9 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { //char* p; // construire lien (découpage) - if ((((int) (eadr - html)) - 1) < HTS_URLMAXSIZE) { // pas trop long? - strncpy(lien, html, ((int) (eadr - html)) - 1); - *(lien + (((int) (eadr - html))) - 1) = '\0'; + if (eadr - html - 1 < HTS_URLMAXSIZE) { // pas trop long? + strncpy(lien, html, eadr - html - 1); + lien[eadr - html - 1] = '\0'; //printf("link: %s\n",lien); // supprimer les espaces while((lien[strlen(lien) - 1] == ' ') && (strnotempty(lien))) @@ -1941,13 +1940,13 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { if (!q) q = a + strlen(a) - 1; while((p = strstr(a, "//")) && (!done)) { // remplacer // par / - if ((int) p > (int) q) { // après le ? (toto.cgi?param=1//2.3) + if (p > q) { // après le ? (toto.cgi?param=1//2.3) done = 1; // stopper } else { char BIGSTK tempo[HTS_URLMAXSIZE * 2]; tempo[0] = '\0'; - strncatbuff(tempo, a, (int) p - (int) a); + strncatbuff(tempo, a, p - a); strcatbuff(tempo, p + 1); strcpybuff(a, tempo); // recopier } @@ -2019,7 +2018,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { // and not already UTF-8 // (note: not for the query string!) if (hasCharset && !hts_isCharsetUTF8(charset)) { - char *const s = hts_convertStringToUTF8(lien, (int) strlen(lien), charset); + char *const s = hts_convertStringToUTF8(lien, strlen(lien), charset); if (s != NULL) { hts_log_print(opt, LOG_DEBUG, "engine: save-name: '%s' charset conversion from '%s' to '%s'", @@ -2092,7 +2091,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { char *a = lien + strlen(lien) - 1; // éviter aussi index~1.html - while(((int) a > (int) lien) && (*a != '~') && (*a != '/') + while(a > lien && (*a != '~') && (*a != '/') && (*a != '.')) a--; if (*a == '~') { @@ -2151,7 +2150,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { char BIGSTK tempo[HTS_URLMAXSIZE * 2]; tempo[0] = '\0'; - strncatbuff(tempo, lien, (int) (a - lien)); + strncatbuff(tempo, lien, a - lien); strcatbuff(tempo, a + 3); // sauter :80 strcpybuff(lien, tempo); } @@ -2203,8 +2202,8 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } /* only one ending / (bug on some pages) */ - if ((int) strlen(lien) > 2) { - int len = (int) strlen(lien); + if (strlen(lien) > 2) { + size_t len = strlen(lien); while(len > 1 && lien[len - 1] == '/' && lien[len - 2] == '/') /* double // (bug) */ lien[--len] = '\0'; @@ -2296,8 +2295,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { if (strnotempty(_base)) { // considérer base if (!link_has_authority(lien)) { // non absolue if (*lien != '/') { // non absolu sur le site (/) - if (((int) strlen(_base) + (int) strlen(lien)) < - HTS_URLMAXSIZE) { + if ((strlen(_base) + strlen(lien)) < HTS_URLMAXSIZE) { // mailto: and co: do NOT add base if (ident_url_relatif (lien, urladr(), urlfil(), &afs.af) >= 0) { @@ -2323,8 +2321,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } else { lien_adrfil baseaf; if (ident_url_absolute(_base, &baseaf) >= 0) { - if (((int) strlen(baseaf.adr) + (int) strlen(lien)) < - HTS_URLMAXSIZE) { + if ((strlen(baseaf.adr) + strlen(lien)) < HTS_URLMAXSIZE) { char BIGSTK tempo[HTS_URLMAXSIZE * 2]; // base est absolue @@ -2415,8 +2412,8 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } // calculer meme_adresse meme_adresse = - strfield2(jump_identification(afs.af.adr), - jump_identification(urladr())); + strfield2(jump_identification_const(afs.af.adr), + jump_identification_const(urladr())); // Début partie sauvegarde @@ -2453,8 +2450,8 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { url_savename(&afs, &former, heap(ptr)->adr, heap(ptr)->fil, opt, sback, cache, hash, ptr, numero_passe, NULL); - if (strcmp(jump_identification(last_adr), - jump_identification(afs.af.adr)) != 0) { // a changé + if (strcmp(jump_identification_const(last_adr), + jump_identification_const(afs.af.adr)) != 0) { // a changé // 2e test si moved @@ -2559,9 +2556,9 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } if (!opt->passprivacy) { - HT_ADD_HTMLESCAPED(jump_protocol(afs.af.adr)); // Password + HT_ADD_HTMLESCAPED(jump_protocol_const(afs.af.adr)); // Password } else { - HT_ADD_HTMLESCAPED(jump_identification(afs.af.adr)); // No Password + HT_ADD_HTMLESCAPED(jump_identification_const(afs.af.adr)); // No Password } if (afs.af.fil[0] != '/') HT_ADD("/"); @@ -2582,7 +2579,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { if (!opt->passprivacy) { HT_ADD_HTMLESCAPED(afs.af.adr); // Password } else { - HT_ADD_HTMLESCAPED(jump_identification(afs.af.adr)); // No Password + HT_ADD_HTMLESCAPED(jump_identification_const(afs.af.adr)); // No Password } if (afs.af.fil[0] != '/') HT_ADD("/"); @@ -2598,9 +2595,9 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { HT_ADD(tmp); // Protocol HT_ADD("//"); if (!opt->passprivacy) { - HT_ADD_HTMLESCAPED(jump_protocol(afs.af.adr)); // Password + HT_ADD_HTMLESCAPED(jump_protocol_const(afs.af.adr)); // Password } else { - HT_ADD_HTMLESCAPED(jump_identification(afs.af.adr)); // No Password + HT_ADD_HTMLESCAPED(jump_identification_const(afs.af.adr)); // No Password } if (afs.af.fil[0] != '/') HT_ADD("/"); @@ -2635,15 +2632,15 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { default: // inconnu // asp, cgi.. if ((strfield2 - (afs.af.fil + max(0, (int) strlen(afs.af.fil) - 4), + (afs.af.fil + max(0, strlen(afs.af.fil) - 4), ".gif")) || (strfield2 - (afs.af.fil + max(0, (int) strlen(afs.af.fil) - 4), + (afs.af.fil + max(0, strlen(afs.af.fil) - 4), ".jpg")) || (strfield2 - (afs.af.fil + max(0, (int) strlen(afs.af.fil) - 4), + (afs.af.fil + max(0, strlen(afs.af.fil) - 4), ".xbm")) /*|| (ishtml(opt,fil)!=0) */ ) { @@ -2688,7 +2685,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { if (!opt->passprivacy) { HT_ADD_HTMLESCAPED(afs.af.adr); // Password } else { - HT_ADD_HTMLESCAPED(jump_identification(afs.af.adr)); // No Password + HT_ADD_HTMLESCAPED(jump_identification_const(afs.af.adr)); // No Password } if (afs.af.fil[0] != '/') HT_ADD("/"); @@ -2703,9 +2700,9 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { strncatbuff(tmp, afs.af.adr, (aut - afs.af.adr) + 2); // scheme HT_ADD(tmp); if (!opt->passprivacy) { - HT_ADD_HTMLESCAPED(jump_protocol(afs.af.adr)); // Password + HT_ADD_HTMLESCAPED(jump_protocol_const(afs.af.adr)); // Password } else { - HT_ADD_HTMLESCAPED(jump_identification(afs.af.adr)); // No Password + HT_ADD_HTMLESCAPED(jump_identification_const(afs.af.adr)); // No Password } if (afs.af.fil[0] != '/') HT_ADD("/"); @@ -2750,7 +2747,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { if (!opt->passprivacy) { HT_ADD_HTMLESCAPED(afs.af.adr); // Password } else { - HT_ADD_HTMLESCAPED(jump_identification(afs.af.adr)); // No Password + HT_ADD_HTMLESCAPED(jump_identification_const(afs.af.adr)); // No Password } if (afs.af.fil[0] != '/') HT_ADD("/"); @@ -2805,7 +2802,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { if (!opt->passprivacy) { HT_ADD_HTMLESCAPED(afs.af.adr); // Password } else { - HT_ADD_HTMLESCAPED(jump_identification(afs.af.adr)); // No Password + HT_ADD_HTMLESCAPED(jump_identification_const(afs.af.adr)); // No Password } if (*tempo_pat != '/') HT_ADD("/"); @@ -2813,8 +2810,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { HT_ADD("\" "); } - strncatbuff(tempo4, lastsaved, - (int) (p_flush - lastsaved)); + strncatbuff(tempo4, lastsaved, p_flush - lastsaved); HT_ADD(tempo4); // refresh code=" HT_ADD(tempo); } @@ -2951,7 +2947,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { char BIGSTK tempo2[HTS_URLMAXSIZE * 2]; strcpybuff(tempo2, a + 1); - strncatbuff(tempo_pat, tempo, (int) (a - tempo) + 1); // chemin + strncatbuff(tempo_pat, tempo, a - tempo + 1); // chemin strcpybuff(tempo, tempo2); // fichier } } @@ -2968,8 +2964,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { HT_ADD("\" "); } - strncatbuff(tempo4, lastsaved, - (int) (p_flush - lastsaved)); + strncatbuff(tempo4, lastsaved, p_flush - lastsaved); HT_ADD(tempo4); // refresh code=" } } @@ -3252,7 +3247,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { &&(!inscript_tag) /* Not in tag with script inside */ ) { /* Not at the end */ - if ((((int) (html - r->adr))) < r->size) { + if (html - r->adr < r->size) { /* Not on a starting tag yet */ if (*html != '<') { /* strchr does not well behave with null chrs.. */ @@ -3264,8 +3259,8 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } /* Jump to near end (index hack) */ if (!adr_next || *adr_next != '<') { - if (((int) (html - r->adr) < (r->size - 4)) - && (r->size > 4) + if (html - r->adr < r->size - 4 + && r->size > 4 ) { html = r->adr + r->size - 2; } @@ -3633,7 +3628,7 @@ int hts_mirror_check_moved(htsmoduleStruct * str, if (opt->hostcontrol) { // timeout et retry épuisés if ((opt->hostcontrol & 1) && (heap(ptr)->retry <= 0)) { hts_log_print(opt, LOG_DEBUG, "Link banned: %s%s", urladr(), urlfil()); - host_ban(opt, ptr, sback, jump_identification(urladr())); + host_ban(opt, ptr, sback, jump_identification_const(urladr())); hts_log_print(opt, LOG_DEBUG, "Info: previous log - link banned: %s%s", urladr(), urlfil()); @@ -3646,7 +3641,7 @@ int hts_mirror_check_moved(htsmoduleStruct * str, if ((opt->hostcontrol) && (heap(ptr)->retry <= 0)) { // too slow if (opt->hostcontrol & 2) { hts_log_print(opt, LOG_DEBUG, "Link banned: %s%s", urladr(), urlfil()); - host_ban(opt, ptr, sback, jump_identification(urladr())); + host_ban(opt, ptr, sback, jump_identification_const(urladr())); hts_log_print(opt, LOG_DEBUG, "Info: previous log - link banned: %s%s", urladr(), urlfil()); @@ -4611,7 +4606,7 @@ int hts_wait_delayed(htsmoduleStruct * str, lien_adrfilsave *afs, b = -1; /* Handle redirect */ - if ((int) strnotempty(mov_url)) { // location existe! + if (strnotempty(mov_url)) { // location existe! lien_adrfil moved; moved.adr[0] = moved.fil[0] = '\0'; // diff --git a/src/htsrobots.c b/src/htsrobots.c index e7656b3..dac9400 100644 --- a/src/htsrobots.c +++ b/src/htsrobots.c @@ -60,7 +60,7 @@ int checkrobots(robots_wizard * robots, const char *adr, const char *fil) { return -1; // interdit } } else { // relatif - if (strstrcase((char*) fil, line)) { + if (strstrcase(fil, line)) { return -1; } } diff --git a/src/htstools.c b/src/htstools.c index e3c587b..eb5a56b 100644 --- a/src/htstools.c +++ b/src/htstools.c @@ -194,15 +194,15 @@ int ident_url_relatif(const char *lien, const char *origin_adr, /* patch scheme if necessary */ if (strfield(lien, "http:")) { lien += 5; - strcpybuff(adrfil->adr, jump_protocol(origin_adr)); // même adresse ; protocole vide (http) + strcpybuff(adrfil->adr, jump_protocol_const(origin_adr)); // même adresse ; protocole vide (http) } else if (strfield(lien, "https:")) { lien += 6; strcpybuff(adrfil->adr, "https://"); // même adresse forcée en https - strcatbuff(adrfil->adr, jump_protocol(origin_adr)); + strcatbuff(adrfil->adr, jump_protocol_const(origin_adr)); } else if (strfield(lien, "ftp:")) { lien += 4; strcpybuff(adrfil->adr, "ftp://"); // même adresse forcée en ftp - strcatbuff(adrfil->adr, jump_protocol(origin_adr)); + strcatbuff(adrfil->adr, jump_protocol_const(origin_adr)); } else { strcpybuff(adrfil->adr, origin_adr); // même adresse ; et même éventuel protocole } @@ -395,7 +395,7 @@ int link_has_authority(const char *lien) { } int link_has_authorization(const char *lien) { - const char *adr = jump_protocol(lien); + const char *adr = jump_protocol_const(lien); const char *firstslash = strchr(adr, '/'); const char *detect = strchr(adr, '@'); @@ -748,8 +748,8 @@ int istoobig(httrackp * opt, LLint size, LLint maxhtml, LLint maxnhtml, static int sortTopIndexFnc(const void *a_, const void *b_) { int cmp; - topindex_chain **a = (topindex_chain **) a_; - topindex_chain **b = (topindex_chain **) b_; + const topindex_chain *const*const a = (const topindex_chain *const*) a_; + const topindex_chain *const*const b = (const topindex_chain *const*) b_; /* Category first, then name */ if ((cmp = (*a)->level - (*b)->level) == 0) { diff --git a/src/htswizard.c b/src/htswizard.c index af364db..fba50ad 100644 --- a/src/htswizard.c +++ b/src/htswizard.c @@ -459,7 +459,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr, question = 0; // pas de question, résolu // former URL complète du lien actuel - strcpybuff(l, jump_identification(adr)); + strcpybuff(l, jump_identification_const(adr)); if (*fil != '/') strcatbuff(l, "/"); strcatbuff(l, fil); @@ -711,7 +711,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr, forbidden_url = 1; HT_INSERT_FILTERS0; // insérer en 0 strcpybuff(_FILTERS[0], "-"); - strcatbuff(_FILTERS[0], jump_identification(adr)); + strcatbuff(_FILTERS[0], jump_identification_const(adr)); if (*fil != '/') strcatbuff(_FILTERS[0], "/"); strcatbuff(_FILTERS[0], fil); @@ -727,7 +727,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr, if (fil[i] == '/') { HT_INSERT_FILTERS0; // insérer en 0 strcpybuff(_FILTERS[0], "-"); - strcatbuff(_FILTERS[0], jump_identification(adr)); + strcatbuff(_FILTERS[0], jump_identification_const(adr)); if (*fil != '/') strcatbuff(_FILTERS[0], "/"); strncatbuff(_FILTERS[0], fil, i); @@ -744,7 +744,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr, forbidden_url = 1; HT_INSERT_FILTERS0; // insérer en 0 strcpybuff(_FILTERS[0], "-"); - strcatbuff(_FILTERS[0], jump_identification(adr)); + strcatbuff(_FILTERS[0], jump_identification_const(adr)); strcatbuff(_FILTERS[0], "*"); break; @@ -786,7 +786,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr, if (fil[i] == '/') { HT_INSERT_FILTERS0; // insérer en 0 strcpybuff(_FILTERS[0], "+"); - strcatbuff(_FILTERS[0], jump_identification(adr)); + strcatbuff(_FILTERS[0], jump_identification_const(adr)); if (*fil != '/') strcatbuff(_FILTERS[0], "/"); strncatbuff(_FILTERS[0], fil, i + 1); @@ -795,7 +795,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr, } else { // autoriser domaine alors!! HT_INSERT_FILTERS0; // insérer en 0 strcpybuff(filters[filptr],"+"); strcpybuff(_FILTERS[0], "+"); - strcatbuff(_FILTERS[0], jump_identification(adr)); + strcatbuff(_FILTERS[0], jump_identification_const(adr)); strcatbuff(_FILTERS[0], "*"); } break; @@ -803,7 +803,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr, case 6: // same domain HT_INSERT_FILTERS0; // insérer en 0 strcpybuff(filters[filptr],"+"); strcpybuff(_FILTERS[0], "+"); - strcatbuff(_FILTERS[0], jump_identification(adr)); + strcatbuff(_FILTERS[0], jump_identification_const(adr)); strcatbuff(_FILTERS[0], "*"); break; // @@ -816,7 +816,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr, if (fil[i] == '/') { HT_INSERT_FILTERS0; // insérer en 0 strcpybuff(_FILTERS[0], "+"); - strcatbuff(_FILTERS[0], jump_identification(adr)); + strcatbuff(_FILTERS[0], jump_identification_const(adr)); if (*fil != '/') strcatbuff(_FILTERS[0], "/"); strncatbuff(_FILTERS[0], fil, i + 1); @@ -915,7 +915,7 @@ int hts_testlinksize(httrackp * opt, const char *adr, const char *fil, LLint siz int size_flag = 0; // former URL complète du lien actuel - strcpybuff(l, jump_identification(adr)); + strcpybuff(l, jump_identification_const(adr)); if (*fil != '/') strcatbuff(l, "/"); strcatbuff(l, fil); diff --git a/src/httrack-library.h b/src/httrack-library.h index 9873bef..cbc7d86 100644 --- a/src/httrack-library.h +++ b/src/httrack-library.h @@ -198,9 +198,12 @@ HTSEXT_API char *int2char(strc_int2bytes2 * strc, int n); HTSEXT_API char *int2bytes(strc_int2bytes2 * strc, LLint n); HTSEXT_API char *int2bytessec(strc_int2bytes2 * strc, long int n); HTSEXT_API char **int2bytes2(strc_int2bytes2 * strc, LLint n); -HTSEXT_API char *jump_identification(const char *); -HTSEXT_API char *jump_normalized(const char *); -HTSEXT_API char *jump_toport(const char *); +HTSEXT_API char *jump_identification(char *); +HTSEXT_API const char *jump_identification_const(const char *); +HTSEXT_API char *jump_normalized(char *); +HTSEXT_API const char *jump_normalized_const(const char *); +HTSEXT_API char *jump_toport(char *); +HTSEXT_API const char *jump_toport_const(const char *); HTSEXT_API char *fil_normalized(const char *source, char *dest); HTSEXT_API char *adr_normalized(const char *source, char *dest); HTSEXT_API const char *hts_rootdir(char *file); diff --git a/src/minizip/ioapi.c b/src/minizip/ioapi.c index bbf3dd1..9e526ee 100644 --- a/src/minizip/ioapi.c +++ b/src/minizip/ioapi.c @@ -230,8 +230,7 @@ static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream) return ret; } -void fill_fopen_filefunc (pzlib_filefunc_def) - zlib_filefunc_def* pzlib_filefunc_def; +void fill_fopen_filefunc (zlib_filefunc_def* pzlib_filefunc_def) { pzlib_filefunc_def->zopen_file = fopen_file_func; pzlib_filefunc_def->zread_file = fread_file_func; diff --git a/src/minizip/ioapi.c.diff b/src/minizip/ioapi.c.diff index 05d3e4a..5040b08 100644 --- a/src/minizip/ioapi.c.diff +++ b/src/minizip/ioapi.c.diff @@ -1,5 +1,5 @@ ---- ioapi.c.orig 2012-01-21 20:58:45.000000000 +0100 -+++ ioapi.c 2014-05-24 13:27:22.516230485 +0200 +--- ioapi.c.orig 2014-06-10 18:55:32.778807408 +0200 ++++ ioapi.c 2014-06-10 20:01:51.657679218 +0200 @@ -73,6 +73,7 @@ p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file; p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file; @@ -30,7 +30,16 @@ static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream) { -@@ -229,6 +238,7 @@ +@@ -221,14 +230,14 @@ + return ret; + } + +-void fill_fopen_filefunc (pzlib_filefunc_def) +- zlib_filefunc_def* pzlib_filefunc_def; ++void fill_fopen_filefunc (zlib_filefunc_def* pzlib_filefunc_def) + { + pzlib_filefunc_def->zopen_file = fopen_file_func; + pzlib_filefunc_def->zread_file = fread_file_func; pzlib_filefunc_def->zwrite_file = fwrite_file_func; pzlib_filefunc_def->ztell_file = ftell_file_func; pzlib_filefunc_def->zseek_file = fseek_file_func; @@ -38,7 +47,7 @@ pzlib_filefunc_def->zclose_file = fclose_file_func; pzlib_filefunc_def->zerror_file = ferror_file_func; pzlib_filefunc_def->opaque = NULL; -@@ -241,6 +251,7 @@ +@@ -241,6 +250,7 @@ pzlib_filefunc_def->zwrite_file = fwrite_file_func; pzlib_filefunc_def->ztell64_file = ftell64_file_func; pzlib_filefunc_def->zseek64_file = fseek64_file_func; diff --git a/src/minizip/zip.c b/src/minizip/zip.c index b0d83e2..52d7e72 100644 --- a/src/minizip/zip.c +++ b/src/minizip/zip.c @@ -33,6 +33,7 @@ # include <stddef.h> # include <string.h> # include <stdlib.h> +# include <stdint.h> #endif #ifdef NO_ERRNO_H extern int errno; @@ -238,7 +239,7 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len) } ldi = ll->last_block; - from_copy = (unsigned char*)buf; + from_copy = (const unsigned char*)buf; while (len>0) { @@ -1450,7 +1451,7 @@ extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned in else #endif { - zi->ci.stream.next_in = (Bytef*)buf; + zi->ci.stream.next_in = (void*) (uintptr_t) buf; zi->ci.stream.avail_in = len; while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0)) diff --git a/src/minizip/zip.c.diff b/src/minizip/zip.c.diff index 204d985..1eca214 100644 --- a/src/minizip/zip.c.diff +++ b/src/minizip/zip.c.diff @@ -1,6 +1,14 @@ ---- zip.c.orig 2013-02-24 08:32:30.000000000 +0100 -+++ zip.c 2014-05-24 13:52:45.570151611 +0200 -@@ -186,7 +186,7 @@ +--- zip.c.orig 2014-06-10 18:55:32.778807408 +0200 ++++ zip.c 2014-06-10 22:24:28.372483395 +0200 +@@ -33,6 +33,7 @@ + # include <stddef.h> + # include <string.h> + # include <stdlib.h> ++# include <stdint.h> + #endif + #ifdef NO_ERRNO_H + extern int errno; +@@ -186,7 +187,7 @@ #include "crypt.h" #endif @@ -9,7 +17,16 @@ { linkedlist_datablock_internal* ldi; ldi = (linkedlist_datablock_internal*) -@@ -637,7 +637,7 @@ +@@ -238,7 +239,7 @@ + } + + ldi = ll->last_block; +- from_copy = (unsigned char*)buf; ++ from_copy = (const unsigned char*)buf; + + while (len>0) + { +@@ -637,7 +638,7 @@ return relativeOffset; } @@ -18,7 +35,7 @@ { int err=ZIP_OK; ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ -@@ -955,7 +955,7 @@ +@@ -955,7 +956,7 @@ return zipOpen3(pathname,append,NULL,NULL); } @@ -27,7 +44,16 @@ { /* write the local header */ int err; -@@ -1752,7 +1752,7 @@ +@@ -1450,7 +1451,7 @@ + else + #endif + { +- zi->ci.stream.next_in = (Bytef*)buf; ++ zi->ci.stream.next_in = (void*) (uintptr_t) buf; + zi->ci.stream.avail_in = len; + + while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0)) +@@ -1752,7 +1753,7 @@ return zipCloseFileInZipRaw (file,0,0); } @@ -36,7 +62,7 @@ { int err = ZIP_OK; ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writting_offset; -@@ -1774,7 +1774,7 @@ +@@ -1774,7 +1775,7 @@ return err; } @@ -45,7 +71,7 @@ { int err = ZIP_OK; -@@ -1813,7 +1813,8 @@ +@@ -1813,7 +1814,8 @@ } return err; } @@ -55,7 +81,7 @@ { int err = ZIP_OK; -@@ -1861,7 +1862,7 @@ +@@ -1861,7 +1863,7 @@ return err; } @@ -64,7 +90,7 @@ { int err = ZIP_OK; uInt size_global_comment = 0; -@@ -1879,6 +1880,18 @@ +@@ -1879,6 +1881,18 @@ return err; } |