battery: Move out struct as common code
authorAaron Marcher <me@drkhsh.at>
Fri, 18 May 2018 23:49:46 +0000 (01:49 +0200)
committerAaron Marcher <me@drkhsh.at>
Fri, 18 May 2018 23:49:46 +0000 (01:49 +0200)
components/battery.c

index 3965e8f8974d26ed9419594cf0add3b2254ea318..b086a283a654bc21925b09c778daa1eba8016a2f 100644 (file)
@@ -5,6 +5,14 @@
 
 #include "../util.h"
 
+static struct {
+       char *state;
+       char *symbol;
+} map[] = {
+       { "Charging",    "+" },
+       { "Discharging", "-" },
+};
+
 #if defined(__linux__)
        #include <limits.h>
 
        const char *
        battery_state(const char *bat)
        {
-               struct {
-                       char *state;
-                       char *symbol;
-               } map[] = {
-                       { "Charging",    "+" },
-                       { "Discharging", "-" },
-               };
                size_t i;
                char path[PATH_MAX], state[12];
 
        {
                struct apm_power_info apm_info;
                size_t i;
-               struct {
-                       unsigned int state;
-                       char *symbol;
-               } map[] = {
-                       { APM_AC_ON,      "+" },
-                       { APM_AC_OFF,     "-" },
-               };
 
                if (load_apm_power_info(&apm_info)) {
                        for (i = 0; i < LEN(map); i++) {