diff options
author | Ingo Bürk <admin@airblader.de> | 2018-07-13 15:17:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-13 15:17:51 +0200 |
commit | fc9da67e65819cb14071db4fd5b7941ab01a1134 (patch) | |
tree | 5f6ab7b574e6fad71cdd2d8ac21c19ba0768d936 /src/print_wireless_info.c | |
parent | 9aafc38370e5f2b337643d22aa04f4d34208fb03 (diff) | |
parent | 52e9f6f63b74db2a6a1d67524851649b18794950 (diff) |
Merge pull request #297 from Stunkymonkey/percent-first
able to print percentage
Diffstat (limited to 'src/print_wireless_info.c')
-rw-r--r-- | src/print_wireless_info.c | 25 |
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: |