summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/htsback.c60
-rw-r--r--src/htsback.h22
-rw-r--r--src/htscache.c6
-rw-r--r--src/htscatchurl.c3
-rw-r--r--src/htscore.c9
-rw-r--r--src/htslib.c39
-rw-r--r--src/htslib.h3
-rw-r--r--src/htsparse.h3
-rw-r--r--src/httrack.c2
9 files changed, 85 insertions, 62 deletions
diff --git a/src/htsback.c b/src/htsback.c
index 7c966cd..7da2cf8 100644
--- a/src/htsback.c
+++ b/src/htsback.c
@@ -446,7 +446,7 @@ int back_nsoc_overall(struct_back* sback) {
//
// fermer les paramètres de transfert,
// et notamment vérifier les fichiers compressés (décompresser), callback etc.
-int back_finalize(httrackp* opt,cache_back* cache,struct_back* sback,int p) {
+int back_finalize(httrackp* opt, cache_back* cache, struct_back* sback, const int p) {
char catbuff[CATBUFF_SIZE];
lien_back* const back = sback->lnk;
const int back_max = sback->count;
@@ -459,7 +459,7 @@ int back_finalize(httrackp* opt,cache_back* cache,struct_back* sback,int p) {
/* Don't store broken files. Note: check is done before compression.
If the file is partial, the next run will attempt to continue it with compression too.
*/
- if (back[p].r.totalsize > 0 && back[p].r.statuscode > 0
+ if (back[p].r.totalsize >= 0 && back[p].r.statuscode > 0
&& back[p].r.size != back[p].r.totalsize && ! opt->tolerant) {
if (back[p].status == STATUS_READY) {
if (opt->log!=NULL) {
@@ -626,7 +626,6 @@ int back_finalize(httrackp* opt,cache_back* cache,struct_back* sback,int p) {
}
/* EN OF REAL MEDIA HACK */
-
/* Stats */
if (cache->txt) {
char flags[32];
@@ -757,6 +756,7 @@ int back_finalize(httrackp* opt,cache_back* cache,struct_back* sback,int p) {
if (!IS_DELAYED_EXT(back[p].url_sav)) {
cache_mayadd(opt,cache,&back[p].r,back[p].url_adr,back[p].url_fil,back[p].url_sav);
} else {
+ /* error */
if (!HTTP_IS_OK(back[p].r.statuscode)) {
if ( (opt->debug>0) && (opt->log!=NULL) ) {
HTS_LOG(opt,LOG_DEBUG); fprintf(opt->log,"redirect to %s%s"LF,back[p].url_adr,back[p].url_fil);
@@ -766,7 +766,7 @@ int back_finalize(httrackp* opt,cache_back* cache,struct_back* sback,int p) {
} else {
/* Partial file, but marked as "ok" ? */
if (opt->log!=NULL) {
- HTS_LOG(opt,LOG_WARNING); fprintf(opt->log,"file not stored in cache due to bogus state (incomplete type caused by %s (%d)): %s%s"LF,back[p].r.msg,back[p].r.statuscode,back[p].url_adr,back[p].url_fil);
+ HTS_LOG(opt,LOG_WARNING); fprintf(opt->log,"file not stored in cache due to bogus state (incomplete type with %s (%d), size "LLintP"): %s%s"LF,back[p].r.msg,back[p].r.statuscode,(LLint)back[p].r.size,back[p].url_adr,back[p].url_fil);
}
}
}
@@ -787,7 +787,7 @@ int back_finalize(httrackp* opt,cache_back* cache,struct_back* sback,int p) {
}
/* try to keep the connection alive */
-int back_letlive(httrackp* opt, cache_back* cache, struct_back* sback, int p) {
+int back_letlive(httrackp* opt, cache_back* cache, struct_back* sback, const int p) {
lien_back* const back = sback->lnk;
const int back_max = sback->count;
int checkerror;
@@ -972,7 +972,7 @@ int back_unserialize_ref(httrackp* opt, const char *adr, const char *fil, lien_b
}
// clear, or leave for keep-alive
-int back_maydelete(httrackp* opt,cache_back* cache,struct_back* sback, int p) {
+int back_maydelete(httrackp* opt,cache_back* cache,struct_back* sback, const int p) {
lien_back* const back = sback->lnk;
const int back_max = sback->count;
assertf(p >= 0 && p < back_max);
@@ -1010,7 +1010,7 @@ int back_maydelete(httrackp* opt,cache_back* cache,struct_back* sback, int p) {
}
// clear, or leave for keep-alive
-void back_maydeletehttp(httrackp* opt, cache_back* cache, struct_back* sback, int p) {
+void back_maydeletehttp(httrackp* opt, cache_back* cache, struct_back* sback, const int p) {
lien_back* const back = sback->lnk;
const int back_max = sback->count;
TStamp lt = 0;
@@ -1062,7 +1062,7 @@ void back_maydeletehttp(httrackp* opt, cache_back* cache, struct_back* sback, in
/* attempt to attach a live connection to this slot */
-int back_trylive(httrackp* opt,cache_back* cache,struct_back* sback, int p) {
+int back_trylive(httrackp* opt,cache_back* cache,struct_back* sback, const int p) {
lien_back* const back = sback->lnk;
const int back_max = sback->count;
assertf(p >= 0 && p < back_max);
@@ -1138,7 +1138,7 @@ int back_search(httrackp* opt,struct_back* sback) {
return -1;
}
-void back_set_finished(struct_back* sback, int p) {
+void back_set_finished(struct_back* sback, const int p) {
lien_back* const back = sback->lnk;
const int back_max = sback->count;
assertf(p >= 0 && p < back_max);
@@ -1157,7 +1157,7 @@ void back_set_finished(struct_back* sback, int p) {
}
}
-void back_set_locked(struct_back* sback, int p) {
+void back_set_locked(struct_back* sback, const int p) {
lien_back* const back = sback->lnk;
const int back_max = sback->count;
assertf(p >= 0 && p < back_max);
@@ -1167,7 +1167,7 @@ void back_set_locked(struct_back* sback, int p) {
}
}
-void back_set_unlocked(struct_back* sback, int p) {
+void back_set_unlocked(struct_back* sback, const int p) {
lien_back* const back = sback->lnk;
const int back_max = sback->count;
assertf(p >= 0 && p < back_max);
@@ -1177,7 +1177,7 @@ void back_set_unlocked(struct_back* sback, int p) {
}
}
-int back_flush_output(httrackp* opt, cache_back* cache, struct_back* sback, int p) {
+int back_flush_output(httrackp* opt, cache_back* cache, struct_back* sback, const int p) {
lien_back* const back = sback->lnk;
const int back_max = sback->count;
assertf(p >= 0 && p < back_max);
@@ -1211,7 +1211,7 @@ int back_flush_output(httrackp* opt, cache_back* cache, struct_back* sback, int
}
// effacer entrée
-int back_delete(httrackp* opt, cache_back* cache, struct_back* sback, int p) {
+int back_delete(httrackp* opt, cache_back* cache, struct_back* sback, const int p) {
lien_back* const back = sback->lnk;
const int back_max = sback->count;
assertf(p >= 0 && p < back_max);
@@ -1252,7 +1252,7 @@ int back_delete(httrackp* opt, cache_back* cache, struct_back* sback, int p) {
}
/* ensure that the entry is not locked */
-void back_index_unlock(struct_back* sback, int p) {
+void back_index_unlock(struct_back* sback, const int p) {
lien_back* const back = sback->lnk;
if (back[p].locked) {
back[p].locked = 0; /* not locked anymore */
@@ -1378,8 +1378,8 @@ int back_add(struct_back* sback,httrackp* opt,cache_back* cache,char* adr,char*
if (back[p].r.soc!=INVALID_SOCKET) { /* we never know */
deletehttp(&back[p].r);
}
- memset(&(back[p].r), 0, sizeof(htsblk));
- back[p].r.soc=INVALID_SOCKET;
+ //memset(&(back[p].r), 0, sizeof(htsblk));
+ hts_init_htsblk(&back[p].r);
back[p].r.location=back[p].location_buffer;
// créer entrée
@@ -1615,7 +1615,9 @@ int back_add(struct_back* sback,httrackp* opt,cache_back* cache,char* adr,char*
return 0;
} else { // erreur
// effacer r
- memset(&(back[p].r), 0, sizeof(htsblk)); back[p].r.soc=INVALID_SOCKET; back[p].r.location=back[p].location_buffer;
+ hts_init_htsblk(&back[p].r);
+ //memset(&(back[p].r), 0, sizeof(htsblk));
+ back[p].r.location=back[p].location_buffer;
// et continuer (chercher le fichier)
}
@@ -1802,7 +1804,9 @@ int back_add(struct_back* sback,httrackp* opt,cache_back* cache,char* adr,char*
// ouvrir liaison, envoyer requète
// ne pas traiter ou recevoir l'en tête immédiatement
- memset(&(back[p].r), 0, sizeof(htsblk)); back[p].r.soc=INVALID_SOCKET; back[p].r.location=back[p].location_buffer;
+ hts_init_htsblk(&back[p].r);
+ //memset(&(back[p].r), 0, sizeof(htsblk));
+ back[p].r.location=back[p].location_buffer;
// recopier proxy
if ((back[p].r.req.proxy.active = opt->proxy.active)) {
if (StringBuff(opt->proxy.bindhost) != NULL)
@@ -2961,8 +2965,8 @@ void back_wait(struct_back* sback,httrackp* opt,cache_back* cache,TStamp stat_ti
back_finalize(opt,cache,sback,i);
}
- if (back[i].r.totalsize>0) { // tester totalsize
- //if ((back[i].r.totalsize>0) && (back[i].status==STATUS_WAIT_HEADERS)) { // tester totalsize
+ if (back[i].r.totalsize>=0) { // tester totalsize
+ //if ((back[i].r.totalsize>=0) && (back[i].status==STATUS_WAIT_HEADERS)) { // tester totalsize
if (back[i].r.totalsize!=back[i].r.size) { // pas la même!
if (!opt->tolerant) {
//#if HTS_CL_IS_FATAL
@@ -3008,7 +3012,7 @@ void back_wait(struct_back* sback,httrackp* opt,cache_back* cache,TStamp stat_ti
printf("[%d] chunk received and read: %s\n",(int)back[i].r.soc,chunk_data);
#endif
if (back[i].r.totalsize<0)
- back[i].r.totalsize=0; // initialiser à 0
+ back[i].r.totalsize=0; // initialiser à 0 (-1 == unknown)
if (back[i].status==STATUS_CHUNK_WAIT) { // "real" chunk
if (sscanf(chunk_data,"%x",&chunk_size) == 1) {
if (chunk_size > 0)
@@ -3115,7 +3119,7 @@ void back_wait(struct_back* sback,httrackp* opt,cache_back* cache,TStamp stat_ti
#endif
/* Tester totalsize en fin de chunk */
- if ((back[i].r.totalsize>0)) { // tester totalsize
+ if ((back[i].r.totalsize>=0)) { // tester totalsize
if (back[i].r.totalsize!=back[i].r.size) { // pas la même!
if (!opt->tolerant) {
deleteaddr(&back[i].r);
@@ -3269,7 +3273,7 @@ void back_wait(struct_back* sback,httrackp* opt,cache_back* cache,TStamp stat_ti
} else if (back[i].r.statuscode == HTTP_CONTINUE) {
back[i].status=STATUS_WAIT_HEADERS;
back[i].r.size=0;
- back[i].r.totalsize=0;
+ back[i].r.totalsize=-1;
back[i].chunk_size=0;
back[i].r.statuscode=STATUSCODE_INVALID;
back[i].r.msg[0]='\0';
@@ -3340,7 +3344,7 @@ void back_wait(struct_back* sback,httrackp* opt,cache_back* cache,TStamp stat_ti
len2=back[i].r.totalsize;
if (r.size>0)
len1=r.size;
- if (len1>0) {
+ if (len1>=0) {
if (len1 == len2) { // tailles identiques
back[i].r.statuscode=HTTP_NOT_MODIFIED; // forcer NOT MODIFIED
deletehttp(&back[i].r); back[i].r.soc=INVALID_SOCKET;
@@ -3577,7 +3581,7 @@ void back_wait(struct_back* sback,httrackp* opt,cache_back* cache,TStamp stat_ti
back[i].r.is_write=1; // écrire
back[i].r.size=sz; // déja écrit
back[i].r.statuscode=HTTP_OK; // Forcer 'OK'
- if (back[i].r.totalsize>0)
+ if (back[i].r.totalsize>=0)
back[i].r.totalsize+=sz; // plus en fait
fseek(back[i].r.out,0,SEEK_END); // à la fin
/* create a temporary reference file in case of broken mirror */
@@ -3599,11 +3603,11 @@ void back_wait(struct_back* sback,httrackp* opt,cache_back* cache,TStamp stat_ti
FILE* fp=FOPEN(fconv(catbuff,back[i].url_sav),"rb");
if (fp) {
LLint alloc_mem=sz + 1;
- if (back[i].r.totalsize>0)
+ if (back[i].r.totalsize>=0)
alloc_mem+=back[i].r.totalsize; // AJOUTER RESTANT!
if ( deleteaddr(&back[i].r) && (back[i].r.adr=(char*) malloct((size_t)alloc_mem)) ) {
back[i].r.size=sz;
- if (back[i].r.totalsize>0)
+ if (back[i].r.totalsize>=0)
back[i].r.totalsize+=sz; // plus en fait
if (( fread(back[i].r.adr,1,sz,fp)) != sz) {
back[i].status=STATUS_READY; // terminé (voir plus loin)
@@ -3675,7 +3679,7 @@ void back_wait(struct_back* sback,httrackp* opt,cache_back* cache,TStamp stat_ti
back[i].chunk_size=0;
back[i].chunk_blocksize=0;
back[i].status=STATUS_CHUNK_WAIT; // start body wait chunk
- back[i].r.totalsize=0; /* devalidate size! (rfc) */
+ back[i].r.totalsize=-1; /* devalidate size! (rfc) */
}
if (back[i].rateout>0) {
back[i].rateout_time=time_local(); // refresh pour transfer rate
diff --git a/src/htsback.h b/src/htsback.h
index 4ddd4d8..12f627c 100644
--- a/src/htsback.h
+++ b/src/htsback.h
@@ -93,7 +93,7 @@ int back_search_quick(struct_back* sback);
void back_clean(httrackp* opt,cache_back* cache,struct_back* sback);
int back_cleanup_background(httrackp* opt,cache_back* cache,struct_back* sback);
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, int p);
+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);
void back_connxfr(htsblk* src, htsblk* dst);
void back_move(lien_back* src, lien_back* dst);
@@ -102,18 +102,18 @@ int back_serialize(FILE *fp, const lien_back* src);
int back_unserialize(FILE *fp, lien_back** dst);
int back_serialize_ref(httrackp* opt, const lien_back* src);
int back_unserialize_ref(httrackp* opt, const char *adr, const char *fil, lien_back** dst);
-void back_set_finished(struct_back* sback, int p);
-void back_set_locked(struct_back* sback, int p);
-void back_set_unlocked(struct_back* sback, int p);
-int back_delete(httrackp* opt,cache_back* cache,struct_back* sback,int p);
-void back_index_unlock(struct_back* sback, int p);
+void back_set_finished(struct_back* sback, const int p);
+void back_set_locked(struct_back* sback, const int p);
+void back_set_unlocked(struct_back* sback, const int p);
+int back_delete(httrackp* opt,cache_back* cache,struct_back* sback,const int p);
+void back_index_unlock(struct_back* sback, const int p);
int back_clear_entry(lien_back* back);
-int back_flush_output(httrackp* opt, cache_back* cache, struct_back* sback, int p);
+int back_flush_output(httrackp* opt, cache_back* cache, struct_back* sback, const int p);
void back_delete_all(httrackp* opt, cache_back* cache, struct_back* sback);
-int back_maydelete(httrackp* opt, cache_back* cache, struct_back* sback, int p);
-void back_maydeletehttp(httrackp* opt, cache_back* cache, struct_back* sback, int p);
-int back_trylive(httrackp* opt,cache_back* cache,struct_back* sback, int p);
-int back_finalize(httrackp* opt,cache_back* cache,struct_back* sback,int p);
+int back_maydelete(httrackp* opt, cache_back* cache, struct_back* sback, const int p);
+void back_maydeletehttp(httrackp* opt, cache_back* cache, struct_back* sback, const int p);
+int back_trylive(httrackp* opt,cache_back* cache,struct_back* sback, const int p);
+int back_finalize(httrackp* opt,cache_back* cache,struct_back* sback,const int p);
void back_info(struct_back* sback,int i,int j,FILE* fp);
void back_infostr(struct_back* sback,int i,int j,char* s);
LLint back_transfered(LLint add,struct_back* sback);
diff --git a/src/htscache.c b/src/htscache.c
index 6680094..fc8a5b8 100644
--- a/src/htscache.c
+++ b/src/htscache.c
@@ -598,7 +598,8 @@ static htsblk cache_readex_new(httrackp* opt,cache_back* cache,const char* adr,c
intptr_t hash_pos;
int hash_pos_return;
htsblk r;
- memset(&r, 0, sizeof(htsblk)); r.soc=INVALID_SOCKET;
+ hts_init_htsblk(&r);
+ //memset(&r, 0, sizeof(htsblk)); r.soc=INVALID_SOCKET;
location_default[0] = '\0';
previous_save[0] = previous_save_[0] = '\0';
@@ -947,7 +948,8 @@ static htsblk cache_readex_old(httrackp* opt,cache_back* cache,const char* adr,c
int ok=0;
int header_only=0;
- memset(&r, 0, sizeof(htsblk)); r.soc=INVALID_SOCKET;
+ hts_init_htsblk(&r);
+ //memset(&r, 0, sizeof(htsblk)); r.soc=INVALID_SOCKET;
if (location) {
r.location = location;
} else {
diff --git a/src/htscatchurl.c b/src/htscatchurl.c
index 9579687..577ee16 100644
--- a/src/htscatchurl.c
+++ b/src/htscatchurl.c
@@ -207,7 +207,8 @@ HTSEXT_API int catch_url(T_SOC soc,char* url,char* method,char* data) {
// Traitement des en-têtes
char BIGSTK loc[HTS_URLMAXSIZE*2];
htsblk blkretour;
- memset(&blkretour, 0, sizeof(htsblk)); // effacer
+ hts_init_htsblk(&blkretour);
+ //memset(&blkretour, 0, sizeof(htsblk)); // effacer
blkretour.location=loc; // si non nul, contiendra l'adresse véritable en cas de moved xx
// Lire en têtes restants
sprintf(data,"%s %s %s\r\n",method,url_fil,protocol);
diff --git a/src/htscore.c b/src/htscore.c
index bbd0335..a67fcde 100644
--- a/src/htscore.c
+++ b/src/htscore.c
@@ -793,7 +793,8 @@ int httpmirror(char* url1, httrackp* opt) {
// Les HTMLs sont traités (si leur priorité est suffisante)
// effacer r
- memset(&r, 0, sizeof(htsblk)); r.soc=INVALID_SOCKET;
+ hts_init_htsblk(&r);
+ //memset(&r, 0, sizeof(htsblk)); r.soc=INVALID_SOCKET;
r.location=loc; // en cas d'erreur 3xx (moved)
// recopier proxy
if ((r.req.proxy.active = opt->proxy.active)) {
@@ -835,7 +836,7 @@ int httpmirror(char* url1, httrackp* opt) {
ptr++;
}
}
- if (liens[ptr]) { // on a qq chose à récupérer?
+ if (liens[ptr] != NULL) { // on a qq chose à récupérer?
if ( (opt->debug>1) && (opt->log!=NULL) ) {
HTS_LOG(opt,LOG_DEBUG); fprintf(opt->log,"Wait get: %s%s"LF,urladr,urlfil);
@@ -860,8 +861,6 @@ int httpmirror(char* url1, httrackp* opt) {
//
*/
} else { // backing, multiples sockets
-
-
/*
**************************************
Get the next link, waiting for other files, handling external callbacks
@@ -1788,7 +1787,7 @@ int httpmirror(char* url1, httrackp* opt) {
//printf("extern=%s\n",r.contenttype);
// ATTENTION C'EST ICI QU'ON SAUVE LE FICHIER!!
- if (r.adr) {
+ if (r.adr != NULL || r.size == 0) {
file_notify(opt, urladr,urlfil, savename, 1, 1, r.notmodified);
if (filesave(opt,r.adr,(int)r.size,savename,urladr,urlfil)!=0) {
int fcheck;
diff --git a/src/htslib.c b/src/htslib.c
index fbb46bf..f98adff 100644
--- a/src/htslib.c
+++ b/src/htslib.c
@@ -616,6 +616,15 @@ char* antislash(char *catbuff, const char* s) {
char cwd[MAX_PATH+1] = "";
#endif
+// Initialize a htsblk structure
+void hts_init_htsblk(htsblk* r) {
+ memset(r, 0, sizeof(htsblk)); // effacer
+ r->soc=INVALID_SOCKET;
+ r->msg[0]='\0';
+ r->statuscode=STATUSCODE_INVALID;
+ r->totalsize=-1;
+}
+
// Récupération d'un fichier http sur le net.
// Renvoie une adresse sur le bloc de mémoire, ou bien
// NULL si un retour.msgeur (buffer retour.msg) est survenue.
@@ -631,7 +640,8 @@ htsblk httpget(httrackp *opt,char* url) {
// séparer URL en adresse+chemin
if (ident_url_absolute(url,adr,fil)==-1) {
htsblk retour;
- memset(&retour, 0, sizeof(htsblk)); // effacer
+ hts_init_htsblk(&retour);
+ //memset(&retour, 0, sizeof(htsblk)); // effacer
// retour prédéfini: erreur
retour.adr=NULL;
retour.size=0;
@@ -1242,9 +1252,10 @@ void treathead(t_cookie* cookie,char* adr,char* fil,htsblk* retour,char* rcvd) {
#if HDEBUG
printf("ok, Content-length: détecté\n");
#endif
- sscanf(rcvd+p,LLintP,&(retour->totalsize));
- if (retour->totalsize == 0) {
- retour->empty = 1;
+ if (sscanf(rcvd+p,LLintP,&(retour->totalsize)) == 1) {
+ if (retour->totalsize == 0) {
+ retour->empty = 1;
+ }
}
}
else if ((p=strfield(rcvd,"Content-Disposition:"))!=0) {
@@ -1636,7 +1647,8 @@ htsblk xhttpget(httrackp *opt,char* adr,char* fil) {
T_SOC soc;
htsblk retour;
- memset(&retour, 0, sizeof(htsblk));
+ hts_init_htsblk(&retour);
+ //memset(&retour, 0, sizeof(htsblk));
soc=http_fopen(opt,adr,fil,&retour);
if (soc!=INVALID_SOCKET) {
@@ -1657,7 +1669,8 @@ htsblk http_gethead(httrackp *opt,char* adr,char* fil) {
T_SOC soc;
htsblk retour;
- memset(&retour, 0, sizeof(htsblk));
+ hts_init_htsblk(&retour);
+ //memset(&retour, 0, sizeof(htsblk));
soc=http_xfopen(opt,1,0,1,NULL,adr,fil,&retour); // HEAD, pas de traitement en-tête
if (soc!=INVALID_SOCKET) {
@@ -1760,20 +1773,21 @@ LLint http_xfread1(htsblk* r,int bufl) {
int nl=-1;
// EOF
- if (r->totalsize > 0 && r->size == r->totalsize) {
+ if (r->totalsize >= 0 && r->size == r->totalsize) {
return READ_EOF;
}
if (bufl>0) {
if (!r->is_write) { // stocker en mémoire
- if (r->totalsize>0) { // totalsize déterminé ET ALLOUE
+ if (r->totalsize>=0) { // totalsize déterminé ET ALLOUE
if (r->adr==NULL) {
r->adr = (char*) malloct((size_t) r->totalsize + 1);
r->size = 0;
}
if (r->adr != NULL) {
// lecture
- nl = hts_read(r,r->adr + ((int) r->size),(int) (r->totalsize-r->size) ); /* NO 32 bit overlow possible here (no 4GB html!) */
+ const size_t req_size = r->totalsize-r->size;
+ nl = req_size > 0 ? hts_read(r,r->adr + ((int) r->size),(int) req_size ) : 0; /* NO 32 bit overlow possible here (no 4GB html!) */
// nouvelle taille
if (nl >= 0) r->size+=nl;
@@ -1917,7 +1931,7 @@ LLint http_xfread1(htsblk* r,int bufl) {
}
}
// EOF
- if (r->totalsize > 0 && r->size == r->totalsize) {
+ if (r->totalsize >= 0 && r->size == r->totalsize) {
return READ_EOF;
} else {
return nl;
@@ -1973,7 +1987,8 @@ htsblk http_test(httrackp *opt,char* adr,char* fil,char* loc) {
tl=time_local();
loc[0]='\0';
- memset(&retour, 0, sizeof(htsblk)); // effacer
+ hts_init_htsblk(&retour);
+ //memset(&retour, 0, sizeof(htsblk)); // effacer
retour.location=loc; // si non nul, contiendra l'adresse véritable en cas de moved xx
//soc=http_fopen(adr,fil,&retour,NULL); // ouvrir, + header
@@ -4498,7 +4513,7 @@ int HTS_TOTAL_RECV_CHECK(int var) {
// >0 : data received
// == 0 : not yet data
// <0: error or no data: READ_ERROR, READ_EOF or READ_TIMEOUT
-HTS_INLINE int hts_read(htsblk* r,char* buff,int size) {
+int hts_read(htsblk* r,char* buff,int size) {
int retour;
// return read(soc,buff,size);
if (r->is_file) {
diff --git a/src/htslib.h b/src/htslib.h
index be921bc..a676af6 100644
--- a/src/htslib.h
+++ b/src/htslib.h
@@ -231,6 +231,9 @@ struct t_dnscache {
extern htsmutex dns_lock;
+// initialize an htsblk structure
+void hts_init_htsblk(htsblk* r);
+
// fonctions unix/winsock
int hts_read(htsblk* r,char* buff,int size);
//int HTS_TOTAL_RECV_CHECK(int var);
diff --git a/src/htsparse.h b/src/htsparse.h
index 9bb681c..ee797da 100644
--- a/src/htsparse.h
+++ b/src/htsparse.h
@@ -133,7 +133,7 @@ void hts_mirror_process_user_interaction(htsmoduleStruct* str, htsmoduleStructEx
int hts_mirror_wait_for_next_file(htsmoduleStruct* str, htsmoduleStructExtended* stre);
/*
- Wair for (adr, fil, save) to be started, that is,
+ Wait for (adr, fil, save) to be started, that is,
to be ready for naming, having its header MIME type
If the final URL is to be forbidden, sets 'forbidden_url' to the corresponding value
*/
@@ -143,7 +143,6 @@ int hts_wait_delayed(htsmoduleStruct* str,
char* former_adr, char* former_fil,
int* forbidden_url);
-
/* Context state */
#define ENGINE_DEFINE_CONTEXT_BASE() \
diff --git a/src/httrack.c b/src/httrack.c
index ac62ebf..cef7c89 100644
--- a/src/httrack.c
+++ b/src/httrack.c
@@ -486,7 +486,7 @@ static int __cdecl htsshow_loop(t_hts_callbackarg *carg, httrackp *opt, lien_bac
strcatbuff(StatsBuffer[index].name,s+l-MAX_LEN_INPROGRESS/2+2);
}
- if (back[i].r.totalsize>0) { // taille prédéfinie
+ if (back[i].r.totalsize>=0) { // taille prédéfinie
StatsBuffer[index].sizetot=back[i].r.totalsize;
StatsBuffer[index].size=back[i].r.size;
} else { // pas de taille prédéfinie