Call decompress_data only for compressed data.
[elinks/elinks-j605.git] / src / network / progress.h
blob70b549b2a1d614d248874439fed267e09694561b
1 #ifndef EL__NETWORK_PROGRESS_H
2 #define EL__NETWORK_PROGRESS_H
4 #include "main/timer.h" /* timer_id_T */
5 #include "util/time.h"
7 #define CURRENT_SPD_SEC 50 /* number of seconds */
9 struct progress {
10 timeval_T elapsed;
11 timeval_T last_time;
12 timeval_T dis_b;
13 timeval_T estimated_time;
15 int average_speed; /* bytes/second */
16 int current_speed; /* bytes/second */
18 unsigned int valid:1;
19 off_t size;
20 off_t loaded, last_loaded;
21 off_t cur_loaded;
23 /* This is offset where the download was resumed possibly */
24 /* progress->start == -1 means normal session, not download
25 * == 0 means download
26 * > 0 means resume
27 * --witekfl */
28 off_t start;
29 /* This is absolute position in the stream
30 * (relative_position = pos - start) (maybe our fictional
31 * relative_position is equiv to loaded, but I'd rather not rely on it
32 * --pasky). */
33 off_t pos;
34 /* If this is non-zero, it indicates that we should seek in the
35 * stream to the value inside before the next write (and zero this
36 * counter then, obviously). */
37 off_t seek;
39 timer_id_T timer;
40 void (*timer_func)(void *);
41 void *timer_func_data;
43 int data_in_secs[CURRENT_SPD_SEC];
46 struct progress *init_progress(off_t start);
47 void done_progress(struct progress *progress);
48 void update_progress(struct progress *progress, off_t loaded, off_t size, off_t pos);
49 void start_update_progress(struct progress *progress, void (*timer_func)(void *), void *timer_func_data);
51 int has_progress(struct progress *progress);
53 #endif