diff --git a/src/battery.c b/src/battery.c
index 85bfc00ac373cd644be8a6ca6249c60356056d3b..2e27e60e4bcdce4b0be7452a943ce2d398636f60 100644 (file)
--- a/src/battery.c
+++ b/src/battery.c
# include <IOKit/ps/IOPSKeys.h>
#endif
-#if HAVE_IOKIT_IOKITLIB_H || HAVE_IOKIT_PS_IOPOWERSOURCES_H || KERNEL_LINUX
-# define BATTERY_HAVE_READ 1
-#else
-# define BATTERY_HAVE_READ 0
+#if !HAVE_IOKIT_IOKITLIB_H && !HAVE_IOKIT_PS_IOPOWERSOURCES_H && !KERNEL_LINUX
+# error "No applicable input method."
#endif
#define INVALID_VALUE 47841.29
-static data_source_t data_source_charge[1] =
-{
- {"value", DS_TYPE_GAUGE, 0, NAN}
-};
-
-static data_set_t charge_ds =
-{
- "charge", 1, data_source_charge
-};
-
-static data_source_t data_source_current[1] =
-{
- {"value", DS_TYPE_GAUGE, NAN, NAN}
-};
-
-static data_set_t current_ds =
-{
- "current", 1, data_source_current
-};
-
-static data_source_t data_source_voltage[1] =
-{
- {"value", DS_TYPE_GAUGE, NAN, NAN}
-};
-
-static data_set_t voltage_ds =
-{
- "voltage", 1, data_source_voltage
-};
-
-#if BATTERY_HAVE_READ
#if HAVE_IOKIT_IOKITLIB_H || HAVE_IOKIT_PS_IOPOWERSOURCES_H
/* No global variables */
/* #endif HAVE_IOKIT_IOKITLIB_H || HAVE_IOKIT_PS_IOPOWERSOURCES_H */
if ((dh = opendir ("/proc/acpi/battery")) == NULL)
{
- ERROR ("Cannot open `/proc/acpi/battery': %s", strerror (errno));
+ char errbuf[1024];
+ ERROR ("Cannot open `/proc/acpi/battery': %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
if ((fh = fopen (filename, "r")) == NULL)
{
- ERROR ("Cannot open `%s': %s", filename, strerror (errno));
+ char errbuf[1024];
+ ERROR ("Cannot open `%s': %s", filename,
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
continue;
}
return (0);
}
-#endif /* BATTERY_HAVE_READ */
void module_register (void)
{
- plugin_register_data_set (&charge_ds);
- plugin_register_data_set (¤t_ds);
- plugin_register_data_set (&voltage_ds);
-
-#if BATTERY_HAVE_READ
plugin_register_init ("battery", battery_init);
plugin_register_read ("battery", battery_read);
-#endif /* BATTERY_HAVE_READ */
-}
+} /* void module_register */