Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=2d8df4e7311e9ae6539b08702e7c770f4bb2d7a7
commit 2d8df4e7311e9ae6539b08702e7c770f4bb2d7a7 Author: Michel Hermier <herm...@frugalware.org> Date: Thu Nov 28 11:34:09 2013 +0100 libpacman: Rename pmdownloadstate_t to pmdownload_t. diff --git a/doc/libpacman-changes.txt b/doc/libpacman-changes.txt index b193a0e..618cf99 100644 --- a/doc/libpacman-changes.txt +++ b/doc/libpacman-changes.txt @@ -20,8 +20,6 @@ None. pacman_cb_log: Make 'message' argument a constant. -pacman_downloadstate_resume, pacman_downloadstate_size: Access to the various pmdownloadstate_t data. - pacman_logaction: Now returns a void instead of a int to reflect success. Logging should allways success and not be intrusive. pacman_parse_config: Make 'file' argument a constant. Remove 'this_section' argument, it is internal and should not have been exposed publicly. @@ -30,9 +28,9 @@ pacman_reg_match: Make arguments constants. pacman_trans_cb_download: -* Changed the not usable PM_NETBUF *ctl to a const pmdownloadstate_t *downloadstates (thougt only one supported for now). +* Changed the not usable PM_NETBUF *ctl to a const pmdownload_t *downloads (thougt only one supported for now). -* Removed the 'xfered' parameter in favor of pacman_downloadstate_xfered. +* Removed the 'xfered' parameter in favor of pacman_download_xfered. * Removed the old abused 'arg' parameter. @@ -44,23 +42,23 @@ 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_download_avg: Access to global download rate. -pacman_downloadstate_begin: Access to download start time. +pacman_download_begin: Access to download start time. -pacman_downloadstate_end: Access to download end time. +pacman_download_end: Access to download end time. -pacman_downloadstate_eta: Access to download eta time. +pacman_download_eta: Access to download eta time. -pacman_downloadstate_rate: Access to instant download rate. +pacman_download_rate: Access to instant download rate. -pacman_downloadstate_resume: Access to resume download size. +pacman_download_resume: Access to resume download size. -pacman_downloadstate_size: Access to final download size. +pacman_download_size: Access to final download size. -pacman_downloadstate_tell: Access to current download size. +pacman_download_tell: Access to current download size. -pacman_downloadstate_xfered: Access to a xfered download size. +pacman_download_xfered: Access to a xfered download size. pmdepmissing_t: is now public and deprecate PM_DEPMISS. diff --git a/lib/libpacman/pacman.c b/lib/libpacman/pacman.c index b178737..e3c5e59 100644 --- a/lib/libpacman/pacman.c +++ b/lib/libpacman/pacman.c @@ -412,135 +412,135 @@ pmlist_t *pacman_db_getgrpcache(pmdb_t *db) /** @} */ -/** @defgroup pacman_downloadstate Download States Functions +/** @defgroup pacman_download Download States Functions * @brief Functions to informations from libpacman downloads * @{ */ /** Get the average download speed (in bytes per seconds). - * @param downloadstate pointer to the download state to get the informations from. + * @param download 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) +int pacman_download_avg(const pmdownload_t *download, double *avg) { - ASSERT(downloadstate != NULL, return -1); + ASSERT(download != NULL, return -1); ASSERT(avg != NULL, return -1); - *avg = downloadstate->dst_avg; + *avg = download->dst_avg; return 0; } /** Get the download start time - * @param downloadstate pointer to the download state to get the informations from. + * @param download pointer to the download state to get the informations from. * @return return 0 in case of success, !0 otherwise. */ -int pacman_downloadstate_begin(const pmdownloadstate_t *downloadstate, struct timeval *timeval) +int pacman_download_begin(const pmdownload_t *download, struct timeval *timeval) { - ASSERT(downloadstate != NULL, return -1); + ASSERT(download != NULL, return -1); ASSERT(timeval != NULL, return -1); - *timeval = downloadstate->dst_begin; + *timeval = download->dst_begin; return 0; } /** Get the download end time. - * Calling this method before pacman_downloadstate_tell give the same value as pacman_downloadstate_size + * Calling this method before pacman_download_tell give the same value as pacman_download_size * has no meaning and can give any value. - * @param downloadstate pointer to the download state to get the informations from. + * @param download 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_end(const pmdownloadstate_t *downloadstate, struct timeval *timeval) +int pacman_download_end(const pmdownload_t *download, struct timeval *timeval) { - ASSERT(downloadstate != NULL, return -1); + ASSERT(download != NULL, return -1); ASSERT(timeval != NULL, return -1); - *timeval = downloadstate->dst_end; + *timeval = download->dst_end; return 0; } /** Get the estimate time to arrival of the download (in seconds). - * @param downloadstate pointer to the download state to get the informations from. + * @param download 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_eta(const pmdownloadstate_t *downloadstate, double *eta) +int pacman_download_eta(const pmdownload_t *download, double *eta) { - ASSERT(downloadstate != NULL, return -1); + ASSERT(download != NULL, return -1); ASSERT(eta != NULL, return -1); - *eta = downloadstate->dst_eta; + *eta = download->dst_eta; return 0; } /** Get the current download rate (in bytes per second). - * @param downloadstate pointer to the download state to get the informations from. + * @param download 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_rate(const pmdownloadstate_t *downloadstate, double *rate) +int pacman_download_rate(const pmdownload_t *download, double *rate) { - ASSERT(downloadstate != NULL, return -1); + ASSERT(download != NULL, return -1); ASSERT(rate != NULL, return -1); - *rate = downloadstate->dst_rate; + *rate = download->dst_rate; 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 download 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_resume(const pmdownloadstate_t *downloadstate, off_t *offset) +int pacman_download_resume(const pmdownload_t *download, off_t *offset) { - ASSERT(downloadstate != NULL, return -1); + ASSERT(download != NULL, return -1); ASSERT(offset != NULL, return -1); - *offset = downloadstate->dst_resume; + *offset = download->dst_resume; return 0; } /** Get the final size of the download - * @param downloadstate pointer to the download state to get the informations from. + * @param download 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_size(const pmdownloadstate_t *downloadstate, off_t *offset) +int pacman_download_size(const pmdownload_t *download, off_t *offset) { - ASSERT(downloadstate != NULL, return -1); + ASSERT(download != NULL, return -1); ASSERT(offset != NULL, return -1); - *offset = downloadstate->dst_size; + *offset = download->dst_size; return 0; } /** Get the current size of the download - * @param downloadstate pointer to the download state to get the informations from. + * @param download 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_tell(const pmdownloadstate_t *downloadstate, off_t *offset) +int pacman_download_tell(const pmdownload_t *download, off_t *offset) { - ASSERT(downloadstate != NULL, return -1); + ASSERT(download != NULL, return -1); ASSERT(offset != NULL, return -1); - *offset = downloadstate->dst_tell; + *offset = download->dst_tell; return 0; } /** Get the xfered size of the download - * @param downloadstate pointer to the download state to get the informations from. + * @param download 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_xfered(const pmdownloadstate_t *downloadstate, off_t *offset) +int pacman_download_xfered(const pmdownload_t *download, off_t *offset) { - ASSERT(downloadstate != NULL, return -1); + ASSERT(download != NULL, return -1); ASSERT(offset != NULL, return -1); - *offset = downloadstate->dst_tell - downloadstate->dst_resume; + *offset = download->dst_tell - download->dst_resume; return 0; } diff --git a/lib/libpacman/pacman.h b/lib/libpacman/pacman.h index 77092fe..1534a69 100644 --- a/lib/libpacman/pacman.h +++ b/lib/libpacman/pacman.h @@ -51,7 +51,7 @@ extern "C" { typedef struct __pmconflict_t pmconflict_t; typedef struct __pmdb_t pmdb_t; typedef struct __pmdepmissing_t pmdepmissing_t; -typedef struct __pmdownloadstate_t pmdownloadstate_t; +typedef struct __pmdownload_t pmdownload_t; typedef struct __pmgrp_t pmgrp_t; typedef struct __pmlist_t pmlist_t; typedef struct __pmpkg_t pmpkg_t; @@ -169,18 +169,18 @@ pmlist_t *pacman_db_search(pmdb_t *db); pmlist_t *pacman_db_test(pmdb_t *db); /* - * Download states + * Downloads */ -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); -int pacman_downloadstate_rate(const pmdownloadstate_t *downloadstate, double *rate); -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); -int pacman_downloadstate_xfered(const pmdownloadstate_t *downloadstate, off_t *offset); +int pacman_download_avg(const pmdownload_t *download, double *avg); +int pacman_download_begin(const pmdownload_t *download, struct timeval *timeval); +int pacman_download_end(const pmdownload_t *download, struct timeval *timeval); +int pacman_download_eta(const pmdownload_t *download, double *eta); +int pacman_download_rate(const pmdownload_t *download, double *rate); +int pacman_download_resume(const pmdownload_t *download, off_t *offset); +int pacman_download_size(const pmdownload_t *download, off_t *offset); +int pacman_download_tell(const pmdownload_t *download, off_t *offset); +int pacman_download_xfered(const pmdownload_t *download, off_t *offset); /* * Packages @@ -363,7 +363,7 @@ typedef void (*pacman_trans_cb_conv)(unsigned char, void *, void *, void *, int typedef void (*pacman_trans_cb_progress)(unsigned char, const char *, int, int, int); /* Download Progress callback */ -typedef int (*pacman_trans_cb_download)(const pmdownloadstate_t *downloadstates); +typedef int (*pacman_trans_cb_download)(const pmdownload_t *downloads); /* Info parameters */ enum { diff --git a/lib/libpacman/server.c b/lib/libpacman/server.c index 8a16bd1..50e5c2d 100644 --- a/lib/libpacman/server.c +++ b/lib/libpacman/server.c @@ -130,7 +130,9 @@ typedef enum __pmdownloadsuccess_t pmdownloadsuccess_t; struct __pmcurldownloader_t { CURL *curl; - pmdownloadstate_t downloadstate; + struct timeval previous_update; + size_t previous_update_dltotal; + pmdownload_t download; }; enum __pmdownloadsuccess_t { @@ -219,9 +221,9 @@ pmdownloadsuccess_t _pacman_curl_download(pmcurldownloader_t *curldownloader, co pmdownloadsuccess_t ret = PM_DOWNLOAD_OK; /* ETA setup */ - gettimeofday(&curldownloader->downloadstate.dst_begin, NULL); + gettimeofday(&curldownloader->download.dst_begin, NULL); if(pm_dlt && pm_dlrate && pm_dlxfered1 && pm_dleta_h && pm_dleta_m && pm_dleta_s) { - *pm_dlt = curldownloader->downloadstate.dst_begin; + *pm_dlt = curldownloader->download.dst_begin; *pm_dlrate = 0; *pm_dlxfered1 = 0; *pm_dleta_h = 0; @@ -240,8 +242,8 @@ pmdownloadsuccess_t _pacman_curl_download(pmcurldownloader_t *curldownloader, co curl_easy_setopt(curlHandle, CURLOPT_FILETIME, 0); curl_easy_setopt(curlHandle, CURLOPT_TIMECONDITION, CURL_TIMECOND_NONE); if(!stat(output, &st)) { - curldownloader->downloadstate.dst_resume = st.st_size; - curl_easy_setopt(curlHandle, CURLOPT_RESUME_FROM, curldownloader->downloadstate.dst_resume); + curldownloader->download.dst_resume = st.st_size; + curl_easy_setopt(curlHandle, CURLOPT_RESUME_FROM, curldownloader->download.dst_resume); outputFile = fopen(output,"ab"); } else { curl_easy_setopt(curlHandle, CURLOPT_RESUME_FROM, 0); @@ -505,7 +507,7 @@ int _pacman_downloadfiles_forreal(pmlist_t *servers, const char *localpath, if(!strcmp(server->protocol, "file")) { EVENT(handle->trans, PM_TRANS_EVT_RETRIEVE_LOCAL, pm_dlfnm, server->path); } else if(pm_dlcb) { - pm_dlcb(&curldownloader.downloadstate); + pm_dlcb(&curldownloader.download); } complete = _pacman_list_add(complete, fn); /* rename "output.part" file to "output" file */ diff --git a/lib/libpacman/server.h b/lib/libpacman/server.h index 720fc91..8fc8d31 100644 --- a/lib/libpacman/server.h +++ b/lib/libpacman/server.h @@ -42,7 +42,7 @@ typedef struct __pmserver_t { char *path; } pmserver_t; -struct __pmdownloadstate_t { +struct __pmdownload_t { // FIXME: change int to off_t when the download backend will permit that. struct timeval dst_begin; struct timeval dst_end; diff --git a/src/pacman-g2/download.c b/src/pacman-g2/download.c index b595b4d..1985238 100644 --- a/src/pacman-g2/download.c +++ b/src/pacman-g2/download.c @@ -69,9 +69,9 @@ int log_progress(const pmdownloadstate_t *downloadstate) unsigned int maxpkglen; static char prev_fnm[DLFNM_PROGRESS_LEN+1]=""; - pacman_downloadstate_resume(downloadstate, &offset); - pacman_downloadstate_size(downloadstate, &fsz); - pacman_downloadstate_xfered(downloadstate, &xfered); + pacman_download_resume(download, &offset); + pacman_download_size(download, &fsz); + pacman_download_xfered(download, &xfered); pct = ((float)(xfered+offset) / fsz) * 100; @@ -92,7 +92,7 @@ int log_progress(const pmdownloadstate_t *downloadstate) gettimeofday(&t1, NULL); if(xfered+offset == fsz) { - pacman_downloadstate_begin(downloadstate, &t); + pacman_download_begin(download, &t); } timediff = t1.tv_sec-t.tv_sec + (float)(t1.tv_usec-t.tv_usec) / 1000000; diff --git a/src/pacman-g2/download.h b/src/pacman-g2/download.h index 49b3242..dec01ff 100644 --- a/src/pacman-g2/download.h +++ b/src/pacman-g2/download.h @@ -32,7 +32,7 @@ extern float rate; extern int xfered1; extern unsigned int eta_h, eta_m, eta_s, remain, howmany; -int log_progress(const pmdownloadstate_t *downloadstate); +int log_progress(const pmdownload_t *download); #endif /* _PM_DOWNLOAD_H */ _______________________________________________ Frugalware-git mailing list Frugalware-git@frugalware.org http://frugalware.org/mailman/listinfo/frugalware-git