+/* Allows for the definition of a variable without opening a new scope, thus
+ * suited for usage in a macro. Idea from wmii. */
+#define with(type, var, init) \
+ for (type var = (type)-1; (var == (type)-1) && ((var=(init)) || 1); )
+
+#define CASE_SEC(name) \
+ if (BEGINS_WITH(current, name)) \
+ with(cfg_t *, sec, cfg_getsec(cfg, name)) \
+ if (sec != NULL)
+
+#define CASE_SEC_TITLE(name) \
+ if (BEGINS_WITH(current, name)) \
+ with(const char *, title, current + strlen(name) + 1) \
+ with(cfg_t *, sec, cfg_gettsec(cfg, name, title)) \
+ if (sec != NULL)
+
+
+typedef enum { CS_DISCHARGING, CS_CHARGING, CS_FULL } charging_status_t;