From a11a1a1253d27b2d6cf8099d51aa1108817cd65d Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Sun, 22 Nov 2009 18:15:36 +0100 Subject: [PATCH] wireless_link_bar: convert to callbacks.barval --- src/core.c | 2 +- src/net_stat.c | 7 +++---- src/net_stat.h | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/core.c b/src/core.c index d3d11366..a9295b68 100644 --- a/src/core.c +++ b/src/core.c @@ -233,7 +233,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long obj->callbacks.print = &print_wireless_link_qual_perc; END OBJ(wireless_link_bar, &update_net_stats) parse_net_stat_bar_arg(obj, arg, free_at_crash); - obj->callbacks.print = &print_wireless_link_bar; + obj->callbacks.barval = &wireless_link_barval; #endif /* HAVE_IWLIB */ #endif /* __linux__ */ diff --git a/src/net_stat.c b/src/net_stat.c index 79cb6c63..094f87f7 100644 --- a/src/net_stat.c +++ b/src/net_stat.c @@ -298,15 +298,14 @@ void print_wireless_link_qual_perc(struct text_object *obj, char *p, int p_max_s spaced_print(p, p_max_size, "unk", 5); } } -void print_wireless_link_bar(struct text_object *obj, char *p, int p_max_size) +uint8_t wireless_link_barval(struct text_object *obj) { struct net_stat *ns = obj->data.opaque; if (!ns) - return; + return 0; - new_bar(obj, p, p_max_size, - ((double) ns->link_qual / ns->link_qual_max) * 255.0); + return round_to_int((double) (ns->link_qual / ns->link_qual_max) * 255.0); } #endif /* HAVE_IWLIB */ #endif /* __linux__ */ diff --git a/src/net_stat.h b/src/net_stat.h index 6929ae90..001dd84d 100644 --- a/src/net_stat.h +++ b/src/net_stat.h @@ -83,7 +83,7 @@ void print_wireless_ap(struct text_object *, char *, int); void print_wireless_link_qual(struct text_object *, char *, int); void print_wireless_link_qual_max(struct text_object *, char *, int); void print_wireless_link_qual_perc(struct text_object *, char *, int); -void print_wireless_link_bar(struct text_object *, char *, int); +uint8_t wireless_link_barval(struct text_object *); #endif /* HAVE_IWLIB */ #endif /* __linux__ */