| > Humm, a log callback might be interesting - anyway,
> the 'updated' callback will be included for the next
> release - and besides parsing log strings might be
> tough, too :)
Released tomorrow: new wrapper for 3.09 version
htswrap_add("transfer-status",htsdefault_xfrstatus);
With the following prototype:
int __cdecl htsdefault_xfrstatus(void* back) {
return 1; // OK (ignored)
}
This wrapper will be called each time a links is ready
(transfered, updated, in error..)
The back parameter is a pointer to a lien_back
structure, whose main members (see complete prototype
for more info) are:
* hostname, filename and output filename of the link:
char url_adr[HTS_URLMAXSIZE*2];
char url_fil[HTS_URLMAXSIZE*2];
char url_sav[HTS_URLMAXSIZE*2];
* hostname and filename of the referer link:
char referer_adr[HTS_URLMAXSIZE*2];
char referer_fil[HTS_URLMAXSIZE*2];
* location of the first target if the page has moved
(error 302,303..)
char location_buffer[HTS_URLMAXSIZE*2];
* internal htsblk structure (seel below)
htsblk r;
* the engine had a previous (older?) version and tried
to update the file
short int is_update;
The r member (htsblk structure) also has important
members:
* final HTTP status code (200=OK, 404=Not found,...)
[note: if no error encountered, the code is 200, even
when the file was updated (HTTP-304) or taken from the
cache]
int statuscode;
* the file was not modified (HTTP-304) since last
mirror
short int notmodified;
* block address if in memory (else, available in the
url_sav file)
char* adr;
* filesize/blocksize
LLint size;
* final text status message ('OK','Not found'..)
char msg[80];
* MIME type
char contenttype[64];
* content-encoding, if any
char contentencoding[64];
* last-modified header, if any
char lastmodified[64];
* etag header, if any
char etag[64];
* content-disposition header, if any
char cdispo[256]
Example:
int __cdecl my_xfrstatus(lien_back* back) {
if (back->r.statuscode == 200) {
if (back->r.notmodified)
printf("%s%s was not modified\n",back-
>url_adr,back->url_fil);
else
printf("%s%s was not modified\n",back-
>url_adr,back->url_fil);
} else
printf("%s%s : error %d\n",back->r.statuscode);
return 1; // OK (ignored)
}
| |