]> git.sur5r.net Git - i3/i3status/blobdiff - src/print_wireless_info.c
Move full_design and full_last into struct battery_info.
[i3/i3status] / src / print_wireless_info.c
index a3ab6701eb89c8d113310a0f81beb5aafa77957b..14879ebf7cbccb5b077e040c52afb5b309f765e4 100644 (file)
 #define IW_ESSID_MAX_SIZE 32
 #endif
 
+#ifdef __APPLE__
+#define IW_ESSID_MAX_SIZE 32
+#endif
+
 #ifdef __FreeBSD__
 #include <sys/param.h>
 #include <sys/ioctl.h>
 #include <netinet/if_ether.h>
 #include <net80211/ieee80211.h>
 #include <net80211/ieee80211_ioctl.h>
+#define IW_ESSID_MAX_SIZE IEEE80211_NWID_LEN
+#endif
+
+#ifdef __NetBSD__
+#include <sys/types.h>
+#include <net80211/ieee80211.h>
+#define IW_ESSID_MAX_SIZE IEEE80211_NWID_LEN
 #endif
 
 #include "i3status.h"
@@ -104,7 +115,7 @@ static void print_bitrate(char *buffer, int buflen, int bitrate) {
 }
 
 // Based on NetworkManager/src/platform/wifi/wifi-utils-nl80211.c
-static uint32_t nl80211_xbm_to_percent(int32_t xbm, uint32_t divisor) {
+static uint32_t nl80211_xbm_to_percent(int32_t xbm, int32_t divisor) {
 #define NOISE_FLOOR_DBM -90
 #define SIGNAL_MAX_DBM -20
 
@@ -419,7 +430,7 @@ error1:
         else
             len = IEEE80211_NWID_LEN + 1;
 
-        strncpy(&info->essid[0], nwid.i_nwid, len);
+        strncpy(&info->essid[0], (char *)nwid.i_nwid, len);
         info->essid[IW_ESSID_MAX_SIZE] = '\0';
         info->flags |= WIRELESS_INFO_FLAG_HAS_ESSID;
     }
@@ -519,7 +530,7 @@ void print_wireless_info(yajl_gen json_gen, char *buffer, const char *interface,
 
         if (BEGINS_WITH(walk + 1, "essid")) {
             if (info.flags & WIRELESS_INFO_FLAG_HAS_ESSID)
-                outwalk += sprintf(outwalk, "%s", info.essid);
+                maybe_escape_markup(info.essid, &outwalk);
             else
                 *(outwalk++) = '?';
             walk += strlen("essid");