summaryrefslogtreecommitdiffstats
path: root/src/utils.c
diff options
context:
space:
mode:
authorpancake <pancake@dazo>2008-03-06 17:58:06 +0100
committerpancake <pancake@dazo>2008-03-06 17:58:06 +0100
commit83c25d7eb267f866968c7806c4afacf00fdfead5 (patch)
tree9873f0adc0142b9131cbbf0b6d1d5070a1b1823e /src/utils.c
parent2ddb2923c68d023f9733fb82bb8d28140ea5b695 (diff)
download0xFFFF-83c25d7eb267f866968c7806c4afacf00fdfead5.tar.bz2
* 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
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c30
1 files changed, 21 insertions, 9 deletions
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, ...)