/* See LICENSE file for copyright and license details. */
#include <alsa/asoundlib.h>
+#include <err.h>
#include <fcntl.h>
#include <ifaddrs.h>
#include <limits.h>
fp = fopen(concat, "r");
if (fp == NULL) {
- fprintf(stderr, "Error opening battery file: %s: %s\n",
- concat,
- strerror(errno));
+ warn("Error opening battery file: %s", concat);
return smprintf(UNKNOWN_STR);
}
fp = fopen(concat, "r");
if (fp == NULL) {
- fprintf(stderr, "Error opening battery file: %s: %s\n",
- concat,
- strerror(errno));
+ warn("Error opening battery file: %s", concat);
return smprintf(UNKNOWN_STR);
}
FILE *fp = fopen("/proc/stat","r");
if (fp == NULL) {
- fprintf(stderr, "Error opening stat file: %s\n",
- strerror(errno));
+ warn("Error opening stat file");
return smprintf(UNKNOWN_STR);
}
fp = fopen("/proc/stat","r");
if (fp == NULL) {
- fprintf(stderr, "Error opening stat file: %s\n",
- strerror(errno));
+ warn("Error opening stat file");
return smprintf(UNKNOWN_STR);
}
struct statvfs fs;
if (statvfs(mountpoint, &fs) < 0) {
- fprintf(stderr, "Could not get filesystem info: %s\n",
- strerror(errno));
+ warn("Could not get filesystem info");
return smprintf(UNKNOWN_STR);
}
return smprintf("%f", (float)fs.f_bsize * (float)fs.f_bfree / 1024 / 1024 / 1024);
struct statvfs fs;
if (statvfs(mountpoint, &fs) < 0) {
- fprintf(stderr, "Could not get filesystem info: %s\n",
- strerror(errno));
+ warn("Could not get filesystem info");
return smprintf(UNKNOWN_STR);
}
struct statvfs fs;
if (statvfs(mountpoint, &fs) < 0) {
- fprintf(stderr, "Could not get filesystem info: %s\n",
- strerror(errno));
+ warn("Could not get filesystem info");
return smprintf(UNKNOWN_STR);
}
struct statvfs fs;
if (statvfs(mountpoint, &fs) < 0) {
- fprintf(stderr, "Could not get filesystem info: %s\n",
- strerror(errno));
+ warn("Could not get filesystem info");
return smprintf(UNKNOWN_STR);
}
FILE *fp = fopen("/proc/sys/kernel/random/entropy_avail", "r");
if (fp == NULL) {
- fprintf(stderr, "Could not open entropy file: %s\n",
- strerror(errno));
+ warn("Could not open entropy file");
return smprintf(UNKNOWN_STR);
}
FILE *fp = fopen("/proc/sys/kernel/hostname", "r");
if (fp == NULL) {
- fprintf(stderr, "Could not open hostname file: %s\n",
- strerror(errno));
+ warn("Could not open hostname file");
return smprintf(UNKNOWN_STR);
}
char host[NI_MAXHOST];
if (getifaddrs(&ifaddr) == -1) {
- fprintf(stderr, "Error getting IP address: %s\n",
- strerror(errno));
+ warn("Error getting IP address");
return smprintf(UNKNOWN_STR);
}
if ((strcmp(ifa->ifa_name, interface) == 0) && (ifa->ifa_addr->sa_family == AF_INET)) {
if (s != 0) {
- fprintf(stderr, "Error getting IP address.\n");
+ warnx("Error getting IP address.");
return smprintf(UNKNOWN_STR);
}
return smprintf("%s", host);
double avgs[3];
if (getloadavg(avgs, 3) < 0) {
- fprintf(stderr, "Error getting load avg.\n");
+ warnx("Error getting load avg.");
return smprintf(UNKNOWN_STR);
}
FILE *fp = fopen("/proc/meminfo", "r");
if (fp == NULL) {
- fprintf(stderr, "Error opening meminfo file: %s\n",
- strerror(errno));
+ warn("Error opening meminfo file");
return smprintf(UNKNOWN_STR);
}
FILE *fp = fopen("/proc/meminfo", "r");
if (fp == NULL) {
- fprintf(stderr, "Error opening meminfo file: %s\n",
- strerror(errno));
+ warn("Error opening meminfo file");
return smprintf(UNKNOWN_STR);
}
FILE *fp = fopen("/proc/meminfo", "r");
if (fp == NULL) {
- fprintf(stderr, "Error opening meminfo file: %s\n",
- strerror(errno));
+ warn("Error opening meminfo file");
return smprintf(UNKNOWN_STR);
}
FILE *fp = fopen("/proc/meminfo", "r");
if (fp == NULL) {
- fprintf(stderr, "Error opening meminfo file: %s\n",
- strerror(errno));
+ warn("Error opening meminfo file");
return smprintf(UNKNOWN_STR);
}
char buffer[64];
if (fp == NULL) {
- fprintf(stderr, "Could not get command output for: %s: %s\n",
- command, strerror(errno));
+ warn("Could not get command output for: %s", command);
return smprintf(UNKNOWN_STR);
}
FILE *fp = fopen(file, "r");
if (fp == NULL) {
- fprintf(stderr, "Could not open temperature file: %s\n",
- strerror(errno));
+ warn("Could not open temperature file");
return smprintf(UNKNOWN_STR);
}
if (pw == NULL)
return smprintf("%s", pw->pw_name);
- fprintf(stderr, "Could not get username: %s\n",
- strerror(errno));
+ warn("Could not get username");
return smprintf(UNKNOWN_STR);
}
fp = fopen(concat, "r");
if(fp == NULL) {
- fprintf(stderr, "Error opening wifi operstate file: %s\n",
- strerror(errno));
+ warn("Error opening wifi operstate file");
return smprintf(UNKNOWN_STR);
}
fp = fopen("/proc/net/wireless", "r");
if (fp == NULL) {
- fprintf(stderr, "Error opening wireless file: %s\n",
- strerror(errno));
+ warn("Error opening wireless file");
return smprintf(UNKNOWN_STR);
}
wreq.u.essid.length = IW_ESSID_MAX_SIZE+1;
sprintf(wreq.ifr_name, wificard);
if(sockfd == -1) {
- fprintf(stderr, "Cannot open socket for interface: %s: %s\n",
- wificard, strerror(errno));
+ warn("Cannot open socket for interface: %s", wificard);
return smprintf(UNKNOWN_STR);
}
wreq.u.essid.pointer = id;
if (ioctl(sockfd,SIOCGIWESSID, &wreq) == -1) {
- fprintf(stderr, "Get ESSID ioctl failed for interface %s: %s\n",
- wificard, strerror(errno));
+ warn("Get ESSID ioctl failed for interface %s", wificard);
return smprintf(UNKNOWN_STR);
}
element = smprintf(argument.format, res);
if (element == NULL) {
element = smprintf(UNKNOWN_STR);
- fprintf(stderr, "Failed to format output.\n");
+ warnx("Failed to format output.");
}
strlcat(status_string, element, sizeof(status_string));
free(res);