Numerous changes:
* Added 'ILoveCandy' support to all progress bars * Changed download callback with regards to libfetch libalpm changes * libfetch error output on failed sync * Misc others I may have forgot to name (check the diff, heh)
This commit is contained in:
parent
af2fb3324a
commit
5a8bbc99be
9 changed files with 193 additions and 145 deletions
|
@ -7,17 +7,19 @@ DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
|
|||
|
||||
AM_CFLAGS = -D_GNU_SOURCE \
|
||||
-I$(top_srcdir)/lib/libalpm \
|
||||
-I$(top_srcdir)/lib/libftp
|
||||
-I$(top_srcdir)/lib/libfetch
|
||||
|
||||
pacman_SOURCES = util.c log.c list.c package.c download.c trans.c add.c \
|
||||
remove.c upgrade.c query.c sync.c conf.c deptest.c pacman.c
|
||||
|
||||
pacman_static_SOURCES = $(pacman_SOURCES)
|
||||
|
||||
pacman_LDADD = \
|
||||
$(top_srcdir)/lib/libalpm/libalpm.la
|
||||
pacman_LDADD = -L$(top_srcdir)/lib/libalpm/.libs \
|
||||
-L$(top_srcdir)/lib/libfetch -lfetch \
|
||||
-larchive -lm -lalpm -lssl -lcrypto
|
||||
|
||||
pacman_static_LDADD = \
|
||||
$(top_srcdir)/lib/libalpm/.libs/libalpm.a $(LDFLAGS)
|
||||
pacman_static_LDADD = -L$(top_srcdir)/lib/libalpm/.libs/ \
|
||||
-L$(top_srcdir)/lib/libfetch -lfetch \
|
||||
-larchive -lm -lalpm -lssl -lcrypto
|
||||
|
||||
pacman_static_LDFLAGS = -all-static
|
||||
pacman_static_LDFLAGS = $(LDFLAGS) -all-static
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <ftplib.h>
|
||||
#include <libintl.h>
|
||||
|
||||
#include <alpm.h>
|
||||
|
@ -40,112 +39,139 @@
|
|||
#include "conf.h"
|
||||
|
||||
/* progress bar */
|
||||
char sync_fnm[PM_DLFNM_LEN+1];
|
||||
int offset;
|
||||
struct timeval t0, t;
|
||||
float rate;
|
||||
int xfered1;
|
||||
unsigned int eta_h, eta_m, eta_s;
|
||||
float rate_last;
|
||||
int xfered_last;
|
||||
struct timeval last_time;
|
||||
struct timeval initial_time;
|
||||
|
||||
/* pacman options */
|
||||
extern config_t *config;
|
||||
|
||||
extern unsigned int maxcols;
|
||||
|
||||
int log_progress(netbuf *ctl, int xfered, void *arg)
|
||||
#define FILENAME_TRIM_LEN 21
|
||||
#define UPDATE_SPEED_SEC 0.1
|
||||
|
||||
void log_progress(const char *filename, int xfered, int total)
|
||||
{
|
||||
int fsz = *(int*)arg;
|
||||
int pct = ((float)(xfered+offset) / fsz) * 100;
|
||||
static int lastpct=0;
|
||||
unsigned int i, cur;
|
||||
struct timeval t1;
|
||||
float timediff;
|
||||
/* a little hard to conceal easter eggs in open-source software, but
|
||||
* they're still fun. ;)
|
||||
*/
|
||||
int chomp;
|
||||
static unsigned short mouth;
|
||||
static unsigned int lastcur = 0;
|
||||
static int lasthash = 0, mouth = 0;
|
||||
int i, hash;
|
||||
long chomp = 0;
|
||||
char *fname, *p;
|
||||
unsigned int progresslen = maxcols - 57;
|
||||
int percent = ((float)xfered) / ((float)total) * 100;
|
||||
struct timeval current_time;
|
||||
float rate = 0.0;
|
||||
unsigned int eta_h = 0, eta_m = 0, eta_s = 0;
|
||||
float total_timediff, timediff;
|
||||
|
||||
/* we don't need that parameter */
|
||||
ctl=NULL;
|
||||
|
||||
if(config->noprogressbar || (pct == 100 && lastpct == 100)) {
|
||||
return(1);
|
||||
if(xfered == 0) {
|
||||
gettimeofday(&initial_time, NULL);
|
||||
gettimeofday(&last_time, NULL);
|
||||
xfered_last = 0;
|
||||
rate_last = 0.0;
|
||||
}
|
||||
|
||||
alpm_get_option(PM_OPT_CHOMP, (long *)&chomp);
|
||||
|
||||
gettimeofday(&t1, NULL);
|
||||
if(xfered+offset == fsz) {
|
||||
t = t0;
|
||||
}
|
||||
timediff = t1.tv_sec-t.tv_sec + (float)(t1.tv_usec-t.tv_usec) / 1000000;
|
||||
|
||||
if(xfered+offset == fsz) {
|
||||
/* average download rate */
|
||||
rate = xfered / (timediff * 1024);
|
||||
/* total download time */
|
||||
eta_s = (int)timediff;
|
||||
eta_h = eta_s / 3600;
|
||||
eta_s -= eta_h * 3600;
|
||||
eta_m = eta_s / 60;
|
||||
eta_s -= eta_m * 60;
|
||||
} else if(timediff > 1) {
|
||||
/* we avoid computing the rate & ETA on too small periods of time, so that
|
||||
results are more significant */
|
||||
rate = (xfered-xfered1) / (timediff * 1024);
|
||||
xfered1 = xfered;
|
||||
gettimeofday(&t, NULL);
|
||||
eta_s = (fsz-(xfered+offset)) / (rate * 1024);
|
||||
eta_h = eta_s / 3600;
|
||||
eta_s -= eta_h * 3600;
|
||||
eta_m = eta_s / 60;
|
||||
eta_s -= eta_m * 60;
|
||||
if(config->noprogressbar) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(rate > 1000) {
|
||||
printf("%*s %6dK %6.0fK/s %02d:%02d:%02d [", PM_DLFNM_LEN, sync_fnm, ((xfered+offset) / 1024), rate, eta_h, eta_m, eta_s);
|
||||
/* a little hard to conceal easter eggs in open-source software, but they're still fun. ;) */
|
||||
alpm_get_option(PM_OPT_CHOMP, &chomp);
|
||||
|
||||
gettimeofday(¤t_time, NULL);
|
||||
total_timediff = current_time.tv_sec-initial_time.tv_sec
|
||||
+ (float)(current_time.tv_usec-initial_time.tv_usec) / 1000000;
|
||||
timediff = current_time.tv_sec-last_time.tv_sec
|
||||
+ (float)(current_time.tv_usec-last_time.tv_usec) / 1000000;
|
||||
|
||||
if(xfered == total) {
|
||||
/* compute final values */
|
||||
rate = total / (total_timediff * 1024);
|
||||
eta_s = (int)total_timediff;
|
||||
} else if(timediff < UPDATE_SPEED_SEC) {
|
||||
/* we avoid computing the ETA on too small periods of time, so that
|
||||
results are more significant */
|
||||
return;
|
||||
} else {
|
||||
printf("%*s %6dK %6.1fK/s %02d:%02d:%02d [", PM_DLFNM_LEN, sync_fnm, ((xfered+offset) / 1024), rate, eta_h, eta_m, eta_s);
|
||||
rate = (xfered - xfered_last) / (timediff * 1024);
|
||||
rate = (rate + 2*rate_last) / 3;
|
||||
eta_s = (total - xfered) / (rate * 1024);
|
||||
}
|
||||
cur = (int)((maxcols-57)*pct/100);
|
||||
for(i = 0; i < maxcols-57; i++) {
|
||||
|
||||
rate_last = rate;
|
||||
last_time = current_time;
|
||||
xfered_last = xfered;
|
||||
|
||||
/* fix up time for display */
|
||||
eta_h = eta_s / 3600;
|
||||
eta_s -= eta_h * 3600;
|
||||
eta_m = eta_s / 60;
|
||||
eta_s -= eta_m * 60;
|
||||
|
||||
fname = strdup(filename);
|
||||
if((p = strstr(fname, PM_EXT_PKG)) || (p = strstr(fname, PM_EXT_DB))) {
|
||||
*p = '\0';
|
||||
}
|
||||
if(strlen(fname) > FILENAME_TRIM_LEN) {
|
||||
fname[FILENAME_TRIM_LEN] = '\0';
|
||||
}
|
||||
|
||||
/* hide the cursor i - prevent flicker
|
||||
printf("\033[?25l\033[?1c");
|
||||
*/
|
||||
|
||||
/*
|
||||
* DL rate cap, for printf formatting - this should be sane for a while
|
||||
* if anything we can change to MB/s if we need a higher rate
|
||||
*/
|
||||
if(rate > 9999.9) {
|
||||
rate = 9999.9;
|
||||
}
|
||||
|
||||
printf(" %-*s %6dK %#6.1fK/s %02d:%02d:%02d [", FILENAME_TRIM_LEN, fname, xfered/1024, rate, eta_h, eta_m, eta_s);
|
||||
|
||||
free(fname);
|
||||
|
||||
hash = percent*progresslen/100;
|
||||
for(i = progresslen; i > 0; --i) {
|
||||
if(chomp) {
|
||||
if(i < cur) {
|
||||
if(i > progresslen - hash) {
|
||||
printf("-");
|
||||
} else {
|
||||
if(i == cur) {
|
||||
if(lastcur == cur) {
|
||||
if(mouth) {
|
||||
printf("\033[1;33mC\033[m");
|
||||
} else {
|
||||
printf("\033[1;33mc\033[m");
|
||||
}
|
||||
} else if(i == progresslen - hash) {
|
||||
if(lasthash == hash) {
|
||||
if(mouth) {
|
||||
printf("\033[1;33mC\033[m");
|
||||
} else {
|
||||
mouth = mouth == 1 ? 0 : 1;
|
||||
if(mouth) {
|
||||
printf("\033[1;33mC\033[m");
|
||||
} else {
|
||||
printf("\033[1;33mc\033[m");
|
||||
}
|
||||
printf("\033[1;33mc\033[m");
|
||||
}
|
||||
} else {
|
||||
printf("\033[0;37m*\033[m");
|
||||
lasthash = hash;
|
||||
mouth = mouth == 1 ? 0 : 1;
|
||||
if(mouth) {
|
||||
printf("\033[1;33mC\033[m");
|
||||
} else {
|
||||
printf("\033[1;33mc\033[m");
|
||||
}
|
||||
}
|
||||
} else if(i%3 == 0) {
|
||||
printf("\033[0;37mo\033[m");
|
||||
} else {
|
||||
printf("\033[0;37m \033[m");
|
||||
}
|
||||
} else if(i > progresslen - hash) {
|
||||
printf("#");
|
||||
} else {
|
||||
(i < cur) ? printf("#") : printf(" ");
|
||||
printf("-");
|
||||
}
|
||||
}
|
||||
printf("] %3d%%\r", pct);
|
||||
if(lastpct != 100 && pct == 100) {
|
||||
printf("] %3d%%\r", percent);
|
||||
|
||||
if(percent == 100) {
|
||||
printf("\n");
|
||||
}
|
||||
lastcur = cur;
|
||||
lastpct = pct;
|
||||
fflush(stdout);
|
||||
return(1);
|
||||
return;
|
||||
}
|
||||
|
||||
/* vim: set ts=2 sw=2 noet: */
|
||||
|
|
|
@ -28,9 +28,7 @@ extern float rate;
|
|||
extern int xfered1;
|
||||
extern unsigned int eta_h, eta_m, eta_s;
|
||||
|
||||
#ifdef __FTPLIB_H
|
||||
int log_progress(netbuf *ctl, int xfered, void *arg);
|
||||
#endif
|
||||
void log_progress(const char *filename, int xfered, int total);
|
||||
|
||||
#endif /* _PM_DOWNLOAD_H */
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ void cb_log(unsigned short level, char *msg)
|
|||
break;
|
||||
}
|
||||
|
||||
#ifdef PACMAN_DEBUG
|
||||
time_t t;
|
||||
struct tm *tmp;
|
||||
char timestr[10] = {0};
|
||||
|
@ -84,6 +85,9 @@ void cb_log(unsigned short level, char *msg)
|
|||
timestr[8] = '\0';
|
||||
|
||||
MSG(NL, "[%s] %s: %s\n", timestr, str, msg);
|
||||
#else
|
||||
MSG(NL, "%s: %s\n", str, msg);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Wrapper to fprintf() that allows to choose if we want the output
|
||||
|
@ -96,7 +100,7 @@ void pm_fprintf(FILE *file, unsigned short line, char *fmt, ...)
|
|||
char str[LOG_STR_LEN];
|
||||
|
||||
if(neednl == 1 && line == NL) {
|
||||
fprintf(stdout, "\n");
|
||||
fprintf(file, "\n");
|
||||
neednl = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -88,8 +88,10 @@ void dump_pkg_full(PM_PKG *pkg, int level)
|
|||
|
||||
if(level > 1) {
|
||||
PM_LIST *i;
|
||||
long lroot;
|
||||
char *root;
|
||||
alpm_get_option(PM_OPT_ROOT, (long *)&root);
|
||||
alpm_get_option(PM_OPT_ROOT, &lroot);
|
||||
root = (void *)&root;
|
||||
fprintf(stdout, "\n");
|
||||
for(i = alpm_list_first(alpm_pkg_getinfo(pkg, PM_PKG_BACKUP)); i; i = alpm_list_next(i)) {
|
||||
struct stat buf;
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#include <mcheck.h> /* debug */
|
||||
#endif
|
||||
#include <time.h>
|
||||
#include <ftplib.h>
|
||||
|
||||
#include <alpm.h>
|
||||
/* pacman */
|
||||
|
@ -220,7 +219,11 @@ static void cleanup(int signum)
|
|||
if(neednl) {
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
/* restore the cursor
|
||||
printf("\033[?25h\033[?0c");
|
||||
fflush(stdout);
|
||||
*/
|
||||
|
||||
exit(signum);
|
||||
}
|
||||
|
@ -431,6 +434,10 @@ int main(int argc, char *argv[])
|
|||
signal(SIGTERM, cleanup);
|
||||
signal(SIGSEGV, cleanup);
|
||||
|
||||
/* hide the cursor, prevent flicker during fancy graphics
|
||||
printf("\033[?25l\033[?1c");
|
||||
*/
|
||||
|
||||
/* i18n init */
|
||||
lang=getenv("LC_ALL");
|
||||
if(lang==NULL || lang[0]=='\0')
|
||||
|
@ -533,46 +540,13 @@ int main(int argc, char *argv[])
|
|||
ERR(NL, _("failed to set option DLCB (%s)\n"), alpm_strerror(pm_errno));
|
||||
cleanup(1);
|
||||
}
|
||||
if(alpm_set_option(PM_OPT_DLFNM, (long)sync_fnm) == -1) {
|
||||
ERR(NL, _("failed to set option DLFNM (%s)\n"), alpm_strerror(pm_errno));
|
||||
cleanup(1);
|
||||
}
|
||||
if(alpm_set_option(PM_OPT_DLOFFSET, (long)&offset) == -1) {
|
||||
ERR(NL, _("failed to set option DLOFFSET (%s)\n"), alpm_strerror(pm_errno));
|
||||
cleanup(1);
|
||||
}
|
||||
if(alpm_set_option(PM_OPT_DLT0, (long)&t0) == -1) {
|
||||
ERR(NL, _("failed to set option DLT0 (%s)\n"), alpm_strerror(pm_errno));
|
||||
cleanup(1);
|
||||
}
|
||||
if(alpm_set_option(PM_OPT_DLT, (long)&t) == -1) {
|
||||
ERR(NL, _("failed to set option DLT (%s)\n"), alpm_strerror(pm_errno));
|
||||
cleanup(1);
|
||||
}
|
||||
if(alpm_set_option(PM_OPT_DLRATE, (long)&rate) == -1) {
|
||||
ERR(NL, _("failed to set option DLRATE (%s)\n"), alpm_strerror(pm_errno));
|
||||
cleanup(1);
|
||||
}
|
||||
if(alpm_set_option(PM_OPT_DLXFERED1, (long)&xfered1) == -1) {
|
||||
ERR(NL, _("failed to set option DLXFERED1 (%s)\n"), alpm_strerror(pm_errno));
|
||||
cleanup(1);
|
||||
}
|
||||
if(alpm_set_option(PM_OPT_DLETA_H, (long)&eta_h) == -1) {
|
||||
ERR(NL, _("failed to set option DLETA_H (%s)\n"), alpm_strerror(pm_errno));
|
||||
cleanup(1);
|
||||
}
|
||||
if(alpm_set_option(PM_OPT_DLETA_M, (long)&eta_m) == -1) {
|
||||
ERR(NL, _("failed to set option DLETA_M (%s)\n"), alpm_strerror(pm_errno));
|
||||
cleanup(1);
|
||||
}
|
||||
if(alpm_set_option(PM_OPT_DLETA_S, (long)&eta_s) == -1) {
|
||||
ERR(NL, _("failed to set option DLETA_S (%s)\n"), alpm_strerror(pm_errno));
|
||||
cleanup(1);
|
||||
}
|
||||
FREE(config->dbpath);
|
||||
alpm_get_option(PM_OPT_DBPATH, (long *)&config->dbpath);
|
||||
long ldbpath, lcachedir;
|
||||
alpm_get_option(PM_OPT_DBPATH, &ldbpath);
|
||||
config->dbpath = (void *)&ldbpath;
|
||||
FREE(config->cachedir);
|
||||
alpm_get_option(PM_OPT_CACHEDIR, (long *)&config->cachedir);
|
||||
alpm_get_option(PM_OPT_CACHEDIR, &lcachedir);
|
||||
config->cachedir = (void *)&lcachedir;
|
||||
|
||||
for(lp = config->op_s_ignore; lp; lp = lp->next) {
|
||||
if(alpm_set_option(PM_OPT_IGNOREPKG, (long)lp->data) == -1) {
|
||||
|
|
|
@ -46,6 +46,7 @@ static int query_fileowner(PM_DB *db, char *filename)
|
|||
int gotcha = 0;
|
||||
char rpath[PATH_MAX];
|
||||
PM_LIST *lp;
|
||||
long lroot;
|
||||
char *root;
|
||||
|
||||
if(db == NULL) {
|
||||
|
@ -61,7 +62,8 @@ static int query_fileowner(PM_DB *db, char *filename)
|
|||
return(1);
|
||||
}
|
||||
|
||||
alpm_get_option(PM_OPT_ROOT, (long *)&root);
|
||||
alpm_get_option(PM_OPT_ROOT, &lroot);
|
||||
root = (void *)&lroot;
|
||||
|
||||
for(lp = alpm_db_getpkgcache(db); lp && !gotcha; lp = alpm_list_next(lp)) {
|
||||
PM_PKG *info;
|
||||
|
@ -250,7 +252,7 @@ int pacman_query(list_t *targets)
|
|||
}
|
||||
}
|
||||
} else {
|
||||
char *pkgname, *pkgver, changelog[PATH_MAX];
|
||||
char *pkgname = NULL, *pkgver = NULL, changelog[PATH_MAX];
|
||||
|
||||
info = alpm_db_readpkg(db_local, package);
|
||||
if(info == NULL) {
|
||||
|
@ -261,8 +263,10 @@ int pacman_query(list_t *targets)
|
|||
/* find a target */
|
||||
if(config->op_q_changelog || config->op_q_info || config->op_q_list) {
|
||||
if(config->op_q_changelog) {
|
||||
long ldbpath;
|
||||
char *dbpath;
|
||||
alpm_get_option(PM_OPT_DBPATH, (long *)&dbpath);
|
||||
alpm_get_option(PM_OPT_DBPATH, &ldbpath);
|
||||
dbpath = (void *)&ldbpath;
|
||||
snprintf(changelog, PATH_MAX, "%s%s/%s/%s-%s/changelog",
|
||||
config->root, dbpath,
|
||||
(char*)alpm_db_getinfo(db_local, PM_DB_TREENAME),
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#endif
|
||||
|
||||
#include <alpm.h>
|
||||
#include <fetch.h> /* fetchLastErrString */
|
||||
/* pacman */
|
||||
#include "util.h"
|
||||
#include "log.h"
|
||||
|
@ -53,11 +54,14 @@ extern list_t *pmc_syncs;
|
|||
|
||||
static int sync_cleancache(int level)
|
||||
{
|
||||
long lroot, lcachedir;
|
||||
char *root, *cachedir;
|
||||
char dirpath[PATH_MAX];
|
||||
|
||||
alpm_get_option(PM_OPT_ROOT, (long *)&root);
|
||||
alpm_get_option(PM_OPT_CACHEDIR, (long *)&cachedir);
|
||||
alpm_get_option(PM_OPT_ROOT, &lroot);
|
||||
root = (void *)&lroot;
|
||||
alpm_get_option(PM_OPT_CACHEDIR, &lcachedir);
|
||||
cachedir = (void *)&lcachedir;
|
||||
|
||||
snprintf(dirpath, PATH_MAX, "%s%s", root, cachedir);
|
||||
|
||||
|
@ -162,14 +166,15 @@ static int sync_synctree(int level, list_t *syncs)
|
|||
sync_t *sync = (sync_t *)i->data;
|
||||
|
||||
ret = alpm_db_update((level < 2 ? 0 : 1), sync->db);
|
||||
if(ret > 0) {
|
||||
if(ret < 0) {
|
||||
if(pm_errno == PM_ERR_DB_SYNC) {
|
||||
ERR(NL, _("failed to synchronize %s\n"), sync->treename);
|
||||
/* use libfetch error */
|
||||
ERR(NL, _("failed to synchronize %s: %s\n"), sync->treename, fetchLastErrString);
|
||||
} else {
|
||||
ERR(NL, _("failed to update %s (%s)\n"), sync->treename, alpm_strerror(pm_errno));
|
||||
}
|
||||
success--;
|
||||
} else if(ret < 0) {
|
||||
} else if(ret == 1) {
|
||||
MSG(NL, _(" %s is up to date\n"), sync->treename);
|
||||
}
|
||||
}
|
||||
|
@ -350,7 +355,7 @@ int pacman_sync(list_t *targets)
|
|||
{
|
||||
int confirm = 0;
|
||||
int retval = 0;
|
||||
list_t *i;
|
||||
list_t *i = NULL;
|
||||
PM_LIST *packages, *data, *lp;
|
||||
|
||||
if(pmc_syncs == NULL || !list_count(pmc_syncs)) {
|
||||
|
@ -495,7 +500,7 @@ int pacman_sync(list_t *targets)
|
|||
/* targ not found in sync db, searching for providers... */
|
||||
PM_LIST *k = NULL;
|
||||
PM_PKG *pkg;
|
||||
char *pname;
|
||||
char *pname = NULL;
|
||||
for(j = pmc_syncs; j && !k; j = j->next) {
|
||||
sync_t *sync = j->data;
|
||||
k = alpm_db_whatprovides(sync->db, targ);
|
||||
|
|
|
@ -288,9 +288,11 @@ void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, i
|
|||
|
||||
void cb_trans_progress(unsigned char event, char *pkgname, int percent, int howmany, int remain)
|
||||
{
|
||||
static int lasthash = 0, mouth = 0;
|
||||
int i, hash;
|
||||
long chomp = 0;
|
||||
unsigned int maxpkglen, progresslen = maxcols - 57;
|
||||
char *addstr, *upgstr, *removestr, *conflictstr, *ptr;
|
||||
char *addstr, *upgstr, *removestr, *conflictstr, *ptr = NULL;
|
||||
addstr = strdup(_("installing"));
|
||||
upgstr = strdup(_("upgrading"));
|
||||
removestr = strdup(_("removing"));
|
||||
|
@ -355,14 +357,45 @@ void cb_trans_progress(unsigned char event, char *pkgname, int percent, int howm
|
|||
break;
|
||||
}
|
||||
|
||||
alpm_get_option(PM_OPT_CHOMP, &chomp);
|
||||
|
||||
/* hide the cursor, prevent flicker during fancy graphics
|
||||
printf("\033[?25l\033[?1c[");
|
||||
*/
|
||||
printf("[");
|
||||
for (i = progresslen; i > 0; i--) {
|
||||
if (i >= progresslen - hash)
|
||||
for(i = progresslen; i > 0; --i) {
|
||||
if(chomp) {
|
||||
if(i > progresslen - hash) {
|
||||
printf("-");
|
||||
} else if(i == progresslen - hash) {
|
||||
if(lasthash == hash) {
|
||||
if(mouth) {
|
||||
printf("\033[1;33mC\033[m");
|
||||
} else {
|
||||
printf("\033[1;33mc\033[m");
|
||||
}
|
||||
} else {
|
||||
lasthash = hash;
|
||||
mouth = mouth == 1 ? 0 : 1;
|
||||
if(mouth) {
|
||||
printf("\033[1;33mC\033[m");
|
||||
} else {
|
||||
printf("\033[1;33mc\033[m");
|
||||
}
|
||||
}
|
||||
} else if(i%3 == 0) {
|
||||
printf("\033[0;37mo\033[m");
|
||||
} else {
|
||||
printf("\033[0;37m \033[m");
|
||||
}
|
||||
} else if(i > progresslen - hash) {
|
||||
printf("#");
|
||||
else
|
||||
} else {
|
||||
printf("-");
|
||||
}
|
||||
}
|
||||
MSG(CL, "] %3d%%\r", percent);
|
||||
printf("] %3d%%\r", percent);
|
||||
|
||||
FREE(addstr);
|
||||
FREE(upgstr);
|
||||
FREE(removestr);
|
||||
|
|
Loading…
Add table
Reference in a new issue