~ubuntu-branches/debian/sid/httrack/sid

« back to all changes in this revision

Viewing changes to src/htsparse.c

  • Committer: Package Import Robot
  • Author(s): Xavier Roche
  • Date: 2014-04-09 21:02:08 UTC
  • mfrom: (1.4.46)
  • Revision ID: package-import@ubuntu.com-20140409210208-n2o92f7nj5g82p7k
Tags: 3.48.1-1
Updated to 3.48.1 (3.48-1)

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
/* Internal engine bytecode */
36
36
#define HTS_INTERNAL_BYTECODE
37
37
 
38
 
#ifndef  _WIN32_WCE
39
38
#include <fcntl.h>
40
 
#endif
41
39
#include <ctype.h>
42
40
 
43
41
/* File defs */
84
82
  if (ht_buff==NULL) { \
85
83
  printf("PANIC! : Not enough memory [%d]\n", __LINE__); \
86
84
  XH_uninit; \
87
 
  abortLogFmt("not enough memory for current html document in HT_ADD_CHK : realloct("LLintP") failed" _ ht_size); \
 
85
  abortLogFmt("not enough memory for current html document in HT_ADD_CHK : realloct("LLintP") failed" _ (LLint) ht_size); \
88
86
  abort(); \
89
87
  } \
90
88
} \
137
135
  if (ht_buff==NULL) { \
138
136
  printf("PANIC! : Not enough memory [%d]\n",__LINE__); \
139
137
  XH_uninit; \
140
 
  abortLogFmt("not enough memory for current html document in HT_ADD_START : malloct("LLintP") failed" _ ht_size); \
 
138
  abortLogFmt("not enough memory for current html document in HT_ADD_START : malloct("LLintP") failed" _ (LLint) ht_size); \
141
139
  abort(); \
142
140
  } \
143
141
  ht_buff[0]='\0'; \
294
292
    strcpybuff(liens[lien_tot]->fil,F); \
295
293
    strcpybuff(liens[lien_tot]->sav,S); \
296
294
    liens_record_sav_len(liens[lien_tot]); \
297
 
    hash_write(hashptr,lien_tot,opt->urlhack);  \
 
295
    hash_write(hashptr,lien_tot);  \
298
296
  } \
299
297
}
300
298
 
1701
1699
                                      || (strfield(tempo, "https:")
1702
1700
                                      )
1703
1701
#endif
1704
 
#if HTS_USEMMS
1705
 
                                      || strfield(tempo, "mms:")
1706
 
#endif
1707
1702
                                    )   // ok pas de problème
1708
1703
                                    url_ok = 1;
1709
1704
                                  else if (tempo[strlen(tempo) - 1] == '/') {   // un slash: ok..
3198
3193
                        //
3199
3194
                        // On part de la fin et on essaye de se presser (économise temps machine)
3200
3195
                        {
3201
 
                          int i = hash_read(hash, save, "", 0, opt->urlhack);   // lecture type 0 (sav)
 
3196
                          int i = hash_read(hash, save, NULL, 0);   // lecture type 0 (sav)
3202
3197
 
3203
3198
                          if (i >= 0) {
3204
3199
                            if ((opt->debug > 1) && (opt->log != NULL)) {
3230
3225
                          if (!just_test_it) {
3231
3226
                            if ((!strfield(adr, "ftp://"))      // non ftp
3232
3227
                                && (!strfield(adr, "file://"))
3233
 
#if HTS_USEMMS
3234
 
                                && (!strfield(adr, "mms://"))
3235
 
#endif
3236
3228
                              ) {       // non file
3237
3229
                              if (opt->robots) {        // récupérer robots
3238
3230
                                if (ishtml(opt, fil) != 0) {    // pas la peine pour des fichiers isolés
3638
3630
                   liens[liens[ptr]->precedent]->adr,
3639
3631
                   liens[liens[ptr]->precedent]->fil, opt, liens, lien_tot,
3640
3632
                   sback, cache, hash, ptr, numero_passe, NULL) != -1) {
3641
 
                if (hash_read(hash, mov_sav, "", 0, 0) < 0) {   // n'existe pas déja
 
3633
                if (hash_read(hash, mov_sav, NULL, HASH_STRUCT_FILENAME) < 0) {   // n'existe pas déja
3642
3634
                  // enregistrer lien (MACRO) avec SAV IDENTIQUE
3643
3635
                  liens_record(mov_adr, mov_fil, liens[ptr]->sav, "", "");
3644
3636
                  //liens_record(mov_adr,mov_fil,mov_sav,"","");
4075
4067
        if (url_savename
4076
4068
            (add_adr, add_fil, add_sav, NULL, NULL, NULL, NULL, opt, liens,
4077
4069
             lien_tot, sback, cache, hash, ptr, numero_passe, NULL) != -1) {
4078
 
          if (hash_read(hash, add_sav, "", 0, 0) < 0) { // n'existe pas déja
 
4070
          if (hash_read(hash, add_sav, NULL, HASH_STRUCT_FILENAME) < 0) { // n'existe pas déja
4079
4071
            // enregistrer lien (MACRO)
4080
4072
            liens_record(add_adr, add_fil, add_sav, "", "");
4081
4073
            if (liens[lien_tot] != NULL) {      // OK, pas d'erreur
4625
4617
      }
4626
4618
 
4627
4619
      /* Check if the file was recorded already (necessary for redirects) */
4628
 
      if (hash_read(hash, save, "", 0, opt->urlhack) >= 0) {
 
4620
      if (hash_read(hash, save, NULL, HASH_STRUCT_FILENAME) >= 0) {
4629
4621
        if (loops == 0) {       /* Should not happend */
4630
4622
          hts_log_print(opt, LOG_ERROR,
4631
4623
                        "Duplicate entry in hts_wait_delayed() cancelled: %s%s -> %s",
4653
4645
        /* We added the link before the parser recorded it -- the background download MUST NOT clean silently this entry! (Petr Gajdusek) */
4654
4646
        back[b].early_add = 1;
4655
4647
 
4656
 
        /* Cache read failed because file does not exists (bad delayed name!)
 
4648
        /* Cache read failed because file does not exist (bad delayed name!)
4657
4649
           Just re-add with the correct name, as we know the MIME now!
4658
4650
         */
4659
4651
        if (back[b].r.statuscode == STATUSCODE_INVALID && back[b].r.adr == NULL) {
4665
4657
          back_copy_static(&back[b], &delayed_back);
4666
4658
 
4667
4659
          /* Delete entry */
4668
 
          back_delete(opt, cache, sback, b);    // cancel
 
4660
          back[b].r.statuscode = 0;  /* TEMPORARY INVESTIGATE WHY WE FETCHED A SOCKET HERE */
 
4661
          back_maydelete(opt, cache, sback, b);    // cancel
4669
4662
          b = -1;
4670
4663
 
4671
4664
          /* Recompute filename with MIME type */
4841
4834
                  }
4842
4835
 
4843
4836
                  // ftp: stop!
4844
 
                  if (strfield(mov_url, "ftp://")
4845
 
#if HTS_USEMMS
4846
 
                      || strfield(mov_url, "mms://")
4847
 
#endif
4848
 
                    ) {
 
4837
                  if (strfield(mov_url, "ftp://")) {
4849
4838
                    strcpybuff(adr, mov_adr);
4850
4839
                    strcpybuff(fil, mov_fil);
4851
4840
                    break;
4905
4894
            /* Finalize now as we have the type */
4906
4895
            if (back[b].status == STATUS_READY) {
4907
4896
              if (!back[b].finalized) {
 
4897
                hts_log_print(opt, LOG_TRACE, "finalizing as we have the type");
4908
4898
                back_finalize(opt, cache, sback, b);
4909
4899
              }
4910
4900
            }