From 95fbecc3858c53a20ea7e250f651896ab609981d Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Mon, 23 Nov 2009 23:26:11 +0100 Subject: [PATCH] merge entropy_bar to callbacks.barval --- src/core.c | 2 +- src/entropy.c | 8 ++------ src/entropy.h | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/core.c b/src/core.c index 4b77a829..b00863c8 100644 --- a/src/core.c +++ b/src/core.c @@ -1375,7 +1375,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long obj->callbacks.print = &print_entropy_poolsize; END OBJ(entropy_bar, &update_entropy) scan_bar(obj, arg); - obj->callbacks.print = &print_entropy_bar; + obj->callbacks.barval = &entropy_barval; END OBJ_ARG(include, 0, "include needs a argument") struct conftree *leaf = conftree_add(currentconffile, arg); if(leaf) { diff --git a/src/entropy.c b/src/entropy.c index c18d3a28..b1f5fe85 100644 --- a/src/entropy.c +++ b/src/entropy.c @@ -74,13 +74,9 @@ void print_entropy_poolsize(struct text_object *obj, char *p, int p_max_size) snprintf(p, p_max_size, "%u", entropy.poolsize); } -void print_entropy_bar(struct text_object *obj, char *p, int p_max_size) +uint8_t entropy_barval(struct text_object *obj) { - double ratio; - (void)obj; - ratio = (double) entropy.avail / - (double) entropy.poolsize; - new_bar(obj, p, p_max_size, (int) (ratio * 255.0f)); + return round_to_int((double) entropy.avail * 255.0f / (double) entropy.poolsize); } diff --git a/src/entropy.h b/src/entropy.h index 5cc90efb..d93d472e 100644 --- a/src/entropy.h +++ b/src/entropy.h @@ -36,6 +36,6 @@ void update_entropy(void); void print_entropy_avail(struct text_object *, char *, int); void print_entropy_perc(struct text_object *, char *, int); void print_entropy_poolsize(struct text_object *, char *, int); -void print_entropy_bar(struct text_object *, char *, int); +uint8_t entropy_barval(struct text_object *); #endif /* _ENTROPY_H */