summaryrefslogtreecommitdiff
path: root/src/print_wireless_info.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/print_wireless_info.c')
-rw-r--r--src/print_wireless_info.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/print_wireless_info.c b/src/print_wireless_info.c
index dcfde52..d495b47 100644
--- a/src/print_wireless_info.c
+++ b/src/print_wireless_info.c
@@ -534,10 +534,8 @@ void print_wireless_info(yajl_gen json_gen, char *buffer, const char *interface,
for (; *walk != '\0'; walk++) {
if (*walk != '%') {
*(outwalk++) = *walk;
- continue;
- }
- if (BEGINS_WITH(walk + 1, "quality")) {
+ } else if (BEGINS_WITH(walk + 1, "quality")) {
if (info.flags & WIRELESS_INFO_FLAG_HAS_QUALITY) {
if (info.quality_max)
outwalk += sprintf(outwalk, format_quality, PERCENT_VALUE(info.quality, info.quality_max), pct_mark);
@@ -547,9 +545,8 @@ void print_wireless_info(yajl_gen json_gen, char *buffer, const char *interface,
*(outwalk++) = '?';
}
walk += strlen("quality");
- }
- if (BEGINS_WITH(walk + 1, "signal")) {
+ } else if (BEGINS_WITH(walk + 1, "signal")) {
if (info.flags & WIRELESS_INFO_FLAG_HAS_SIGNAL) {
if (info.signal_level_max)
outwalk += sprintf(outwalk, "%3d%s", PERCENT_VALUE(info.signal_level, info.signal_level_max), pct_mark);
@@ -559,9 +556,8 @@ void print_wireless_info(yajl_gen json_gen, char *buffer, const char *interface,
*(outwalk++) = '?';
}
walk += strlen("signal");
- }
- if (BEGINS_WITH(walk + 1, "noise")) {
+ } else if (BEGINS_WITH(walk + 1, "noise")) {
if (info.flags & WIRELESS_INFO_FLAG_HAS_NOISE) {
if (info.noise_level_max)
outwalk += sprintf(outwalk, "%3d%s", PERCENT_VALUE(info.noise_level, info.noise_level_max), pct_mark);
@@ -571,9 +567,8 @@ void print_wireless_info(yajl_gen json_gen, char *buffer, const char *interface,
*(outwalk++) = '?';
}
walk += strlen("noise");
- }
- if (BEGINS_WITH(walk + 1, "essid")) {
+ } else if (BEGINS_WITH(walk + 1, "essid")) {
#ifdef IW_ESSID_MAX_SIZE
if (info.flags & WIRELESS_INFO_FLAG_HAS_ESSID)
maybe_escape_markup(info.essid, &outwalk);
@@ -581,23 +576,20 @@ void print_wireless_info(yajl_gen json_gen, char *buffer, const char *interface,
#endif
*(outwalk++) = '?';
walk += strlen("essid");
- }
- if (BEGINS_WITH(walk + 1, "frequency")) {
+ } else if (BEGINS_WITH(walk + 1, "frequency")) {
if (info.flags & WIRELESS_INFO_FLAG_HAS_FREQUENCY)
outwalk += sprintf(outwalk, "%1.1f GHz", info.frequency / 1e9);
else
*(outwalk++) = '?';
walk += strlen("frequency");
- }
- if (BEGINS_WITH(walk + 1, "ip")) {
+ } else if (BEGINS_WITH(walk + 1, "ip")) {
outwalk += sprintf(outwalk, "%s", ip_address);
walk += strlen("ip");
}
-
#ifdef LINUX
- if (BEGINS_WITH(walk + 1, "bitrate")) {
+ else if (BEGINS_WITH(walk + 1, "bitrate")) {
char br_buffer[128];
print_bitrate(br_buffer, sizeof(br_buffer), info.bitrate);
@@ -606,6 +598,9 @@ void print_wireless_info(yajl_gen json_gen, char *buffer, const char *interface,
walk += strlen("bitrate");
}
#endif
+ else {
+ *(outwalk++) = '%';
+ }
}
out: