From dc05cd107cd158e3d8ee9256205aec20615a674f Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 25 Apr 2007 20:02:07 -0400 Subject: Pacman side code consolidation- unify callback functions to one file Some more major code reorginization here. The download progress callback function has been renamed and moved to callback.c, which is the former trans.c with the download and log callbacks added. In addition, this allows util.c to be cleaned up as fill_progress can now be static in callback.c. We've also cut two more source files out. Signed-off-by: Dan McGee --- src/pacman/util.c | 67 ------------------------------------------------------- 1 file changed, 67 deletions(-) (limited to 'src/pacman/util.c') diff --git a/src/pacman/util.c b/src/pacman/util.c index a7259e25..376582a7 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -369,71 +369,4 @@ float get_update_timediff(int first_call) return(retval); } -/* refactored from cb_trans_progress */ -void fill_progress(const int percent, const int proglen) -{ - const unsigned short chomp = alpm_option_get_chomp(); - const unsigned int hashlen = proglen - 8; - const unsigned int hash = percent * hashlen / 100; - static unsigned int lasthash = 0, mouth = 0; - unsigned int i; - - /* printf("\ndebug: proglen: %i\n", proglen); DEBUG*/ - - if(percent == 0) { - lasthash = 0; - mouth = 0; - } - - /* magic numbers, how I loathe thee */ - if(proglen > 8) { - printf(" ["); - for(i = hashlen; i > 1; --i) { - /* if special progress bar enabled */ - if(chomp) { - if(i > hashlen - hash) { - printf("-"); - } else if(i == hashlen - 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 regular progress bar */ - else if(i > hashlen - hash) { - printf("#"); - } else { - printf("-"); - } - } - printf("]"); - } - /* print percent after progress bar */ - if(proglen > 5) { - printf(" %3d%%", percent); - } - - if(percent == 100) { - printf("\n"); - } else { - printf("\r"); - } - fflush(stdout); -} - /* vim: set ts=2 sw=2 noet: */ -- cgit v1.2.3