Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=8fda2674ac3ec0fc681acf569eb267cda0efb9a9
commit 8fda2674ac3ec0fc681acf569eb267cda0efb9a9 Author: Michel Hermier <herm...@frugalware.org> Date: Sat Nov 16 12:09:00 2013 +0100 libpacman: Add pacman_downloadstate_end. diff --git a/doc/libpacman-changes.txt b/doc/libpacman-changes.txt index 6da6bec..2b4505c 100644 --- a/doc/libpacman-changes.txt +++ b/doc/libpacman-changes.txt @@ -46,6 +46,8 @@ pmdb_t: is now public and deprecate PM_DB. pacman_downloadstate_begin: Access to download start time. +pacman_downloadstate_end: Access to download end time. + pacman_downloadstate_resume: Access to resume download size. pacman_downloadstate_size: Access to final download size. diff --git a/lib/libpacman/pacman.c b/lib/libpacman/pacman.c index 4f833ec..01baba2 100644 --- a/lib/libpacman/pacman.c +++ b/lib/libpacman/pacman.c @@ -419,7 +419,7 @@ pmlist_t *pacman_db_getgrpcache(pmdb_t *db) /** Get the download start time * @param downloadstate pointer to the download state to get the informations from. - * @return the size of the file at the start of download resume of the file or ((off_t) -1) in case of error. + * @return return 0 in case of success, !0 otherwise. */ int pacman_downloadstate_begin(const pmdownloadstate_t *downloadstate, struct timeval *timeval) { @@ -430,10 +430,25 @@ int pacman_downloadstate_begin(const pmdownloadstate_t *downloadstate, struct ti return 0; } +/** Get the download end time. + * Calling this method before pacman_downloadstate_tell give the same value as pacman_downloadstate_size + * has no meaning and can give any value. + * @param downloadstate pointer to the download state to get the informations from. + * @return return 0 in case of success, !0 otherwise. + */ +int pacman_downloadstate_end(const pmdownloadstate_t *downloadstate, struct timeval *timeval) +{ + ASSERT(downloadstate != NULL, return -1); + ASSERT(timeval != NULL, return -1); + + *timeval = downloadstate->dst_end; + return 0; +} + /** Get the size at the start of the download resume * @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, not 0 otherwise. + * @return return 0 in case of success, !0 otherwise. */ int pacman_downloadstate_resume(const pmdownloadstate_t *downloadstate, off_t *offset) { @@ -447,7 +462,7 @@ int pacman_downloadstate_resume(const pmdownloadstate_t *downloadstate, off_t *o /** Get the final size of the download * @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, not 0 otherwise. + * @return return 0 in case of success, !0 otherwise. */ int pacman_downloadstate_size(const pmdownloadstate_t *downloadstate, off_t *offset) { @@ -461,7 +476,7 @@ int pacman_downloadstate_size(const pmdownloadstate_t *downloadstate, off_t *off /** Get the current size of the download * @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, not 0 otherwise. + * @return return 0 in case of success, !0 otherwise. */ int pacman_downloadstate_tell(const pmdownloadstate_t *downloadstate, off_t *offset) { @@ -475,7 +490,7 @@ int pacman_downloadstate_tell(const pmdownloadstate_t *downloadstate, off_t *off /** Get the xfered size of the download * @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, not 0 otherwise. + * @return return 0 in case of success, !0 otherwise. */ int pacman_downloadstate_xfered(const pmdownloadstate_t *downloadstate, off_t *offset) { diff --git a/lib/libpacman/pacman.h b/lib/libpacman/pacman.h index ed16fe5..bbd5c46 100644 --- a/lib/libpacman/pacman.h +++ b/lib/libpacman/pacman.h @@ -173,6 +173,7 @@ pmlist_t *pacman_db_test(pmdb_t *db); */ 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_resume(const pmdownloadstate_t *downloadstate, off_t *offset); int pacman_downloadstate_size(const pmdownloadstate_t *downloadstate, off_t *offset); int pacman_downloadstate_tell(const pmdownloadstate_t *downloadstate, off_t *offset); diff --git a/lib/libpacman/server.h b/lib/libpacman/server.h index f56b533..9cf6f19 100644 --- a/lib/libpacman/server.h +++ b/lib/libpacman/server.h @@ -46,6 +46,7 @@ typedef struct __pmserver_t { struct __pmdownloadstate_t { // FIXME: change int to off_t when the download backend will permit that. struct timeval dst_begin; + struct timeval dst_end; int dst_resume; int dst_size; int dst_tell; _______________________________________________ Frugalware-git mailing list Frugalware-git@frugalware.org http://frugalware.org/mailman/listinfo/frugalware-git