Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=b94bf7ef19f4fb9fc3190bc7d8b7cecbca9e4279
commit b94bf7ef19f4fb9fc3190bc7d8b7cecbca9e4279 Author: Michel Hermier <herm...@frugalware.org> Date: Thu Nov 28 10:11:56 2013 +0100 libpacman: Add pacman_downloadstate_avg. diff --git a/doc/libpacman-changes.txt b/doc/libpacman-changes.txt index 0fba8cd..b193a0e 100644 --- a/doc/libpacman-changes.txt +++ b/doc/libpacman-changes.txt @@ -44,13 +44,15 @@ pmconflict_t: is now public and deprecate PM_CONFLICT. pmdb_t: is now public and deprecate PM_DB. +pacman_downloadstate_avg: Access to global download rate. + pacman_downloadstate_begin: Access to download start time. pacman_downloadstate_end: Access to download end time. pacman_downloadstate_eta: Access to download eta time. -pacman_downloadstate_rate: Access to download rate time. +pacman_downloadstate_rate: Access to instant download rate. pacman_downloadstate_resume: Access to resume download size. diff --git a/lib/libpacman/pacman.c b/lib/libpacman/pacman.c index f441618..b178737 100644 --- a/lib/libpacman/pacman.c +++ b/lib/libpacman/pacman.c @@ -417,6 +417,20 @@ pmlist_t *pacman_db_getgrpcache(pmdb_t *db) * @{ */ +/** Get the average download speed (in bytes per seconds). + * @param downloadstate pointer to the download state to get the informations from. + * @param offset pointer to the value to be written. + * @return return 0 in case of success, !0 otherwise. + */ +int pacman_downloadstate_avg(const pmdownloadstate_t *downloadstate, double *avg) +{ + ASSERT(downloadstate != NULL, return -1); + ASSERT(avg != NULL, return -1); + + *avg = downloadstate->dst_avg; + return 0; +} + /** Get the download start time * @param downloadstate pointer to the download state to get the informations from. * @return return 0 in case of success, !0 otherwise. @@ -460,7 +474,7 @@ int pacman_downloadstate_eta(const pmdownloadstate_t *downloadstate, double *eta return 0; } -/** Get the current download rate (in byte per second). +/** Get the current download rate (in bytes per second). * @param downloadstate pointer to the download state to get the informations from. * @param offset pointer to the value to be written. * @return return 0 in case of success, !0 otherwise. diff --git a/lib/libpacman/pacman.h b/lib/libpacman/pacman.h index 41e9dc9..77092fe 100644 --- a/lib/libpacman/pacman.h +++ b/lib/libpacman/pacman.h @@ -172,6 +172,7 @@ pmlist_t *pacman_db_test(pmdb_t *db); * Download states */ +int pacman_downloadstate_avg(const pmdownloadstate_t *downloadstate, double *avg); int pacman_downloadstate_begin(const pmdownloadstate_t *downloadstate, struct timeval *timeval); int pacman_downloadstate_end(const pmdownloadstate_t *downloadstate, struct timeval *timeval); int pacman_downloadstate_eta(const pmdownloadstate_t *downloadstate, double *eta); diff --git a/lib/libpacman/server.h b/lib/libpacman/server.h index 175d53b..720fc91 100644 --- a/lib/libpacman/server.h +++ b/lib/libpacman/server.h @@ -46,6 +46,7 @@ struct __pmdownloadstate_t { // FIXME: change int to off_t when the download backend will permit that. struct timeval dst_begin; struct timeval dst_end; + double dst_avg; double dst_eta; double dst_rate; int dst_resume; _______________________________________________ Frugalware-git mailing list Frugalware-git@frugalware.org http://frugalware.org/mailman/listinfo/frugalware-git