+#define max(a, b) ((a) > (b) ? (a) : (b))
+
+#if defined(LINUX)
+
+#define THERMAL_ZONE "/sys/class/thermal/thermal_zone%d/temp"
+
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+
+#define THERMAL_ZONE "hw.acpi.thermal.tz%d.temperature"
+#define BATT_LIFE "hw.acpi.battery.life"
+#define BATT_TIME "hw.acpi.battery.time"
+#define BATT_STATE "hw.acpi.battery.state"
+
+#endif
+
+#if defined(__FreeBSD_kernel__) && defined(__GLIBC__)
+
+#include <sys/stat.h>
+#include <sys/param.h>
+
+#endif
+
+/* 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)
+