/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
+ * vim: ts=4 sw=4 noet ai cindent syntax=c
*
* apcupsd.c: conky module for APC UPS daemon monitoring
*
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA.
*
- * vim: ts=4 sw=4 noet ai cindent syntax=c
- *
*/
#include "conky.h"
//
// Conky update function for apcupsd data
//
-void update_apcupsd(void) {
+int update_apcupsd(void) {
int i;
APCUPSD_S apc;
break;
}
#ifdef HAVE_GETHOSTBYNAME_R
- if (gethostbyname_r(info.apcupsd.host, &he_mem, hostbuff, sizeof(hostbuff), &he, &he_errno)) {
- ERR("APCUPSD gethostbyname_r: %s", hstrerror(h_errno));
+ if (gethostbyname_r(info.apcupsd.host, &he_mem, hostbuff, sizeof(hostbuff), &he, &he_errno) || !he ) {
+ NORM_ERR("APCUPSD gethostbyname_r: %s", hstrerror(h_errno));
break;
}
#else /* HAVE_GETHOSTBYNAME_R */
// "atomically" copy the data into working set
//
memcpy(info.apcupsd.items, apc.items, sizeof(info.apcupsd.items));
- return;
-}
-
-//
-// fills in the N/A strings and default host:port
-//
-void init_apcupsd(void) {
-
- int i;
- for (i = 0; i < _APCUPSD_COUNT; ++i)
- memcpy(info.apcupsd.items[i], "N/A", 4); // including \0
- memcpy(info.apcupsd.host, "localhost", 10);
- info.apcupsd.port = htons(3551);
+ return 0;
}