-struct _curl_cb_data {
- opkg_progress_callback_t cb;
- opkg_progress_data_t *progress_data;
- void *user_data;
- int start_range;
- int finish_range;
-};
-
-int
-curl_progress_cb(struct _curl_cb_data *cb_data, double t, /* dltotal */
- double d, /* dlnow */
- double ultotal, double ulnow)
-{
- int p = (t) ? d * 100 / t : 0;
- static int prev = -1;
- int progress = 0;
-
- /* prevent the same value being sent twice (can occur due to rounding) */
- if (p == prev)
- return 0;
- prev = p;
-
- if (t < 1)
- return 0;
-
- progress = cb_data->start_range +
- (d / t * ((cb_data->finish_range - cb_data->start_range)));
- cb_data->progress_data->percentage = progress;
-
- (cb_data->cb) (cb_data->progress_data, cb_data->user_data);
-
- return 0;
-}
-
-