summaryrefslogtreecommitdiff
path: root/src/htswizard.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/htswizard.c')
-rw-r--r--src/htswizard.c85
1 files changed, 39 insertions, 46 deletions
diff --git a/src/htswizard.c b/src/htswizard.c
index e8ea235..7273ce1 100644
--- a/src/htswizard.c
+++ b/src/htswizard.c
@@ -42,10 +42,6 @@ Please visit our Website: http://www.httrack.com
#include <ctype.h>
/* END specific definitions */
-// pour alléger la syntaxe, des raccourcis sont créés
-#define urladr (liens[ptr]->adr)
-#define urlfil (liens[ptr]->fil)
-
// libérer filters[0] pour insérer un élément dans filters[0]
#define HT_INSERT_FILTERS0 do {\
int i;\
@@ -191,8 +187,8 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot,
/* Niveau 1: ne pas parser suivant! */
if (ptr > 0) {
- if ((liens[ptr]->depth <= 0)
- || (liens[ptr]->depth <= 1 && !embedded_triggered)) {
+ if ((heap(ptr)->depth <= 0)
+ || (heap(ptr)->depth <= 1 && !embedded_triggered)) {
forbidden_url = 1; // interdire récupération du lien
hts_log_print(opt, LOG_DEBUG,
"file from too far level ignored at %s : %s", adr, fil);
@@ -207,11 +203,11 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot,
// ------------------------------------------------------
// doit-on traiter ce lien?.. vérifier droits de déplacement
- meme_adresse = strfield2(adr, urladr);
+ meme_adresse = strfield2(adr, urladr());
if (meme_adresse)
- hts_log_print(opt, LOG_DEBUG, "Compare addresses: %s=%s", adr, urladr);
+ hts_log_print(opt, LOG_DEBUG, "Compare addresses: %s=%s", adr, urladr());
else
- hts_log_print(opt, LOG_DEBUG, "Compare addresses: %s!=%s", adr, urladr);
+ hts_log_print(opt, LOG_DEBUG, "Compare addresses: %s!=%s", adr, urladr());
if (meme_adresse) { // même adresse
{ // tester interdiction de descendre
// MODIFIE : en cas de remontée puis de redescente, il se pouvait qu'on ne puisse pas atteindre certains fichiers
@@ -224,15 +220,15 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot,
// note (up/down): on calcule à partir du lien primaire, ET du lien précédent.
// ex: si on descend 2 fois on peut remonter 1 fois
- if (lienrelatif(tempo, fil, liens[liens[ptr]->premier]->fil) == 0) {
- if (lienrelatif(tempo2, fil, liens[ptr]->fil) == 0) {
+ if (lienrelatif(tempo, fil, heap(heap(ptr)->premier)->fil) == 0) {
+ if (lienrelatif(tempo2, fil, heap(ptr)->fil) == 0) {
hts_log_print(opt, LOG_DEBUG,
"build relative links to test: %s %s (with %s and %s)",
- tempo, tempo2, liens[liens[ptr]->premier]->fil,
- liens[ptr]->fil);
+ tempo, tempo2, heap(heap(ptr)->premier)->fil,
+ heap(ptr)->fil);
// si vient de primary, ne pas tester lienrelatif avec (car host "différent")
- /*if (liens[liens[ptr]->premier] == 0) { // vient de primary
+ /*if (heap(heap(ptr)->premier) == 0) { // vient de primary
}
*/
@@ -246,7 +242,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot,
|| (tempo2[0] != '\0' && tempo2[1] != '\0'
&& strchr(tempo2 + 1, '/') == 0)
) {
- if (!liens[ptr]->link_import) { // ne résulte pas d'un 'moved'
+ if (!heap(ptr)->link_import) { // ne résulte pas d'un 'moved'
forbidden_url = 0;
hts_log_print(opt, LOG_DEBUG, "same level link authorized: %s%s",
adr, fil);
@@ -271,7 +267,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot,
hts_log_print(opt, LOG_DEBUG, "lower link canceled: %s%s", adr,
fil);
} else { // autorisé à priori - NEW
- if (!liens[ptr]->link_import) { // ne résulte pas d'un 'moved'
+ if (!heap(ptr)->link_import) { // ne résulte pas d'un 'moved'
forbidden_url = 0;
hts_log_print(opt, LOG_DEBUG, "lower link authorized: %s%s",
adr, fil);
@@ -279,7 +275,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot,
}
} else if ((test1) || (test2)) { // on peut descendre pour accéder au lien
if ((opt->seeker & 1) != 0) { // on peut descendre - NEW
- if (!liens[ptr]->link_import) { // ne résulte pas d'un 'moved'
+ if (!heap(ptr)->link_import) { // ne résulte pas d'un 'moved'
forbidden_url = 0;
hts_log_print(opt, LOG_DEBUG, "lower link authorized: %s%s",
adr, fil);
@@ -295,7 +291,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot,
hts_log_print(opt, LOG_DEBUG, "upper link canceled: %s%s", adr,
fil);
} else { // autorisé à monter - NEW
- if (!liens[ptr]->link_import) { // ne résulte pas d'un 'moved'
+ if (!heap(ptr)->link_import) { // ne résulte pas d'un 'moved'
forbidden_url = 0;
hts_log_print(opt, LOG_DEBUG, "upper link authorized: %s%s",
adr, fil);
@@ -303,7 +299,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot,
}
} else if ((!strncmp(tempo, "../", 3)) || (!strncmp(tempo2, "../", 3))) { // Possible en montant
if ((opt->seeker & 2) != 0) { // autorisé à monter - NEW
- if (!liens[ptr]->link_import) { // ne résulte pas d'un 'moved'
+ if (!heap(ptr)->link_import) { // ne résulte pas d'un 'moved'
forbidden_url = 0;
hts_log_print(opt, LOG_DEBUG, "upper link authorized: %s%s",
adr, fil);
@@ -314,11 +310,11 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot,
} else {
hts_log_print(opt, LOG_ERROR,
"Error building relative link %s and %s", fil,
- liens[ptr]->fil);
+ heap(ptr)->fil);
}
} else {
hts_log_print(opt, LOG_ERROR, "Error building relative link %s and %s",
- fil, liens[liens[ptr]->premier]->fil);
+ fil, heap(heap(ptr)->premier)->fil);
}
} // tester interdiction de descendre?
@@ -327,16 +323,16 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot,
char BIGSTK tempo[HTS_URLMAXSIZE * 2];
char BIGSTK tempo2[HTS_URLMAXSIZE * 2];
- if (lienrelatif(tempo, fil, liens[liens[ptr]->premier]->fil) == 0) {
- if (lienrelatif(tempo2, fil, liens[ptr]->fil) == 0) {
+ if (lienrelatif(tempo, fil, heap(heap(ptr)->premier)->fil) == 0) {
+ if (lienrelatif(tempo2, fil, heap(ptr)->fil) == 0) {
} else {
hts_log_print(opt, LOG_ERROR,
"Error building relative link %s and %s", fil,
- liens[ptr]->fil);
+ heap(ptr)->fil);
}
} else {
hts_log_print(opt, LOG_ERROR, "Error building relative link %s and %s",
- fil, liens[liens[ptr]->premier]->fil);
+ fil, heap(heap(ptr)->premier)->fil);
}
} // fin tester interdiction de monter
@@ -352,24 +348,24 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot,
break; // interdicton de sortir au dela de l'adresse
case 1:{ // sortie sur le même dom.xxx
size_t i = strlen(adr) - 1;
- size_t j = strlen(urladr) - 1;
+ size_t j = strlen(urladr()) - 1;
if ((i > 0) && (j > 0)) {
while((i > 0) && (adr[i] != '.'))
i--;
- while((j > 0) && (urladr[j] != '.'))
+ while((j > 0) && (urladr()[j] != '.'))
j--;
if ((i > 0) && (j > 0)) {
i--;
j--;
while((i > 0) && (adr[i] != '.'))
i--;
- while((j > 0) && (urladr[j] != '.'))
+ while((j > 0) && (urladr()[j] != '.'))
j--;
}
}
if ((i > 0) && (j > 0)) {
- if (!strfield2(adr + i, urladr + j)) { // !=
+ if (!strfield2(adr + i, urladr() + j)) { // !=
if (!opt->wizard) { // mode non wizard
//printf("refused: %s\n",adr);
forbidden_url = 1; // pas même domaine
@@ -391,14 +387,14 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot,
break;
case 2:{ // sortie sur le même .xxx
size_t i = strlen(adr) - 1;
- size_t j = strlen(urladr) - 1;
+ size_t j = strlen(urladr()) - 1;
while((i > 0) && (adr[i] != '.'))
i--;
- while((j > 0) && (urladr[j] != '.'))
+ while((j > 0) && (urladr()[j] != '.'))
j--;
if ((i > 0) && (j > 0)) {
- if (!strfield2(adr + i, urladr + j)) { // !-
+ if (!strfield2(adr + i, urladr() + j)) { // !-
if (!opt->wizard) { // mode non wizard
//printf("refused: %s\n",adr);
forbidden_url = 1; // pas même .xx
@@ -497,7 +493,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot,
// there is no way yet to tag "external" links, and therefore links that are
// "weak" (authorized depth < external depth) are just not considered for external
// hack
- if (liens[ptr]->depth > opt->extdepth) {
+ if (heap(ptr)->depth > opt->extdepth) {
// *set_prio_to = opt->extdepth + 1;
*set_prio_to = 1 + (opt->extdepth);
may_set_prio_to = 0; // clear may-set flag
@@ -506,11 +502,11 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot,
if (question) {
hts_log_print(opt, LOG_DEBUG,
"(wizard) ambiguous link accepted (external depth): link %s at %s%s",
- l, urladr, urlfil);
+ l, urladr(), urlfil());
} else {
hts_log_print(opt, LOG_DEBUG,
"(wizard) forced to accept link (external depth): link %s at %s%s",
- l, urladr, urlfil);
+ l, urladr(), urlfil());
}
}
@@ -554,14 +550,14 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot,
may_set_prio_to = 0; // clear may-set flag
hts_log_print(opt, LOG_DEBUG,
"(wizard) explicit authorized (%s) link: link %s at %s%s",
- mdepth, l, urladr, urlfil);
+ mdepth, l, urladr(), urlfil());
} else if (jok == -1) { // forbidden
filters_answer = 1; // décision prise par les filtres
question = 0; // ne pas poser de question:
forbidden_url = 1; // URL interdite
hts_log_print(opt, LOG_DEBUG,
"(wizard) explicit forbidden (%s) link: link %s at %s%s",
- mdepth, l, urladr, urlfil);
+ mdepth, l, urladr(), urlfil());
} // sinon on touche à rien
}
}
@@ -569,14 +565,14 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot,
// vérifier mode mirror links
if (question) {
if (opt->mirror_first_page) { // mode mirror links
- if (liens[ptr]->precedent == 0) { // parent=primary!
+ if (heap(ptr)->precedent == 0) { // parent=primary!
forbidden_url = 0; // autorisé
may_set_prio_to = 0; // clear may-set flag
question = 1; // résolution auto
force_mirror = 5; // mirror (5)
hts_log_print(opt, LOG_DEBUG,
"(wizard) explicit mirror link: link %s at %s%s", l,
- urladr, urlfil);
+ urladr(), urlfil());
}
}
}
@@ -588,7 +584,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot,
forbidden_url = 1;
hts_log_print(opt, LOG_DEBUG,
"(wizard) ambiguous forbidden link: link %s at %s%s", l,
- urladr, urlfil);
+ urladr(), urlfil());
}
}
// vérifier robots.txt
@@ -623,14 +619,14 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot,
if (!forbidden_url) {
hts_log_print(opt, LOG_DEBUG,
"(wizard) shared foreign domain link: link %s at %s%s", l,
- urladr, urlfil);
+ urladr(), urlfil());
} else {
hts_log_print(opt, LOG_DEBUG,
"(wizard) cancelled foreign domain link: link %s at %s%s",
- l, urladr, urlfil);
+ l, urladr(), urlfil());
}
#if BDEBUG==3
- printf("at %s in %s, wizard says: url %s ", urladr, urlfil, l);
+ printf("at %s in %s, wizard says: url %s ", urladr(), urlfil(), l);
if (forbidden_url)
printf("cancelled");
else
@@ -988,7 +984,4 @@ int hts_testlinksize(httrackp * opt, const char *adr, const char *fil, LLint siz
return jok;
}
-#undef urladr
-#undef urlfil
-
#undef HT_INSERT_FILTERS0