From 83c25d7eb267f866968c7806c4afacf00fdfead5 Mon Sep 17 00:00:00 2001 From: pancake Date: Thu, 6 Mar 2008 17:58:06 +0100 Subject: * Initial working version of the flash gui - Renamed to goxf - Needs 'sudo' to be enabled to the user without password - Identify and ban piece files while including them in the list - Support for flashing multiple piece files - progressbar and warn/error messages handled - Supports reboot mobo command * Make qmode be functional * Lot of hardcore fixups on squeue_open - Should work now everywhere fine asumid UID 1000 as allowed user - Reduce timeouts - Add push2 method --- src/utils.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'src/utils.c') diff --git a/src/utils.c b/src/utils.c index 4803a50..2f4efbb 100644 --- a/src/utils.c +++ b/src/utils.c @@ -42,16 +42,28 @@ void progressbar(unsigned long long part, unsigned long long total) int pc; int tmp, cols = 80; + /* percentage calculation */ pc = (int)(part*100/total); - (pc<0)?pc=0:(pc>100)?pc=100:0; - printf("\e[K %3d%% [", pc); - if (columns) - cols = atoi(columns); - cols-=15; - for(tmp=cols*pc/100;tmp;tmp--) printf("#"); - for(tmp=cols-(cols*pc/100);tmp;tmp--) printf("-"); - printf("]\r"); - fflush(stdout); + (pc<0)?pc=0:(pc>100)?pc=100:0; + +#if HAVE_SQUEUE + if (qmode) { + char msg[128]; + sprintf(msg, "%d%%", pc); + squeue_push2(p, "bar", msg, 0); + } else { +#endif + printf("\e[K %3d%% [", pc); + if (columns) + cols = atoi(columns); + cols-=15; + for(tmp=cols*pc/100;tmp;tmp--) printf("#"); + for(tmp=cols-(cols*pc/100);tmp;tmp--) printf("-"); + printf("]\r"); + fflush(stdout); +#if HAVE_SQUEUE + } +#endif } void eprintf(const char *format, ...) -- cgit v1.2.3