/* open battery now file */
if (!(fp = fopen(batterynowfile, "r"))) {
fprintf(stderr, "Error opening battery file: %s.\n", batterynowfile);
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* read value */
/* open battery full file */
if (!(fp = fopen(batteryfullfile, "r"))) {
fprintf(stderr, "Error opening battery file.\n");
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* read value */
/* open stat file */
if (!(fp = fopen("/proc/stat","r"))) {
fprintf(stderr, "Error opening stat file.\n");
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* read values */
/* open stat file */
if (!(fp = fopen("/proc/stat","r"))) {
fprintf(stderr, "Error opening stat file.\n");
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* read values */
char *buf = malloc(bufsize);
if (buf == NULL) {
fprintf(stderr, "Failed to get date/time.\n");
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* get time in format */
setlocale(LC_TIME, "C");
free(buf);
fprintf(stderr, "Strftime failed.\n");
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
setlocale(LC_TIME, "C");
/* try to open mountpoint */
if (statvfs(mountpoint, &fs) < 0) {
fprintf(stderr, "Could not get filesystem info.\n");
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* return free */
/* try to open mountpoint */
if (statvfs(mountpoint, &fs) < 0) {
fprintf(stderr, "Could not get filesystem info.\n");
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* calculate percent */
/* try to open mountpoint */
if (statvfs(mountpoint, &fs) < 0) {
fprintf(stderr, "Could not get filesystem info.\n");
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* return total */
/* try to open mountpoint */
if (statvfs(mountpoint, &fs) < 0) {
fprintf(stderr, "Could not get filesystem info.\n");
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* return used */
/* open entropy file */
if (!(fp = fopen("/proc/sys/kernel/random/entropy_avail", "r"))) {
fprintf(stderr, "Could not open entropy file.\n");
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* extract entropy */
if ((gid = getgid()) < 0) {
fprintf(stderr, "Could no get gid.\n");
- return smprintf("n/a");
+ return smprintf(unknowntext);
} else {
return smprintf("%d", gid);
}
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* hostname */
/* open hostname file */
if (!(fp = fopen("/proc/sys/kernel/hostname", "r"))) {
fprintf(stderr, "Could not open hostname file.\n");
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* extract hostname */
/* check if getting ip address works */
if (getifaddrs(&ifaddr) == -1) {
fprintf(stderr, "Error getting IP address.\n");
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* get the ip address */
if ((strcmp(ifa->ifa_name, interface) == 0) && (ifa->ifa_addr->sa_family == AF_INET)) {
if (s != 0) {
fprintf(stderr, "Error getting IP address.\n");
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
return smprintf("%s", host);
}
/* free the address */
freeifaddrs(ifaddr);
- /* return n/a if nothing works */
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* ram free */
/* open meminfo file */
if (!(fp = fopen("/proc/meminfo", "r"))) {
fprintf(stderr, "Error opening meminfo file.\n");
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* read the values */
/* open meminfo file */
if (!(fp = fopen("/proc/meminfo", "r"))) {
fprintf(stderr, "Error opening meminfo file.\n");
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* read the values */
/* open meminfo file */
if (!(fp = fopen("/proc/meminfo", "r"))) {
fprintf(stderr, "Error opening meminfo file.\n");
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* read the values */
/* open meminfo file */
if (!(fp = fopen("/proc/meminfo", "r"))) {
fprintf(stderr, "Error opening meminfo file.\n");
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* read the values */
/* try to open the command output */
if (!(fp = popen(command, "r"))) {
fprintf(stderr, "Could not get command output for: %s.\n", command);
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* get command output text, save it to buffer */
/* open temperature file */
if (!(fp = fopen(file, "r"))) {
fprintf(stderr, "Could not open temperature file.\n");
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* extract temperature */
return smprintf("%s", pw->pw_name);
} else {
fprintf(stderr, "Could not get username.\n");
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* uid */
return smprintf("%d", uid);
} else {
fprintf(stderr, "Could not get uid.\n");
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* check */
if (vol_info == NULL || mute_info == NULL) {
fprintf(stderr, "Could not get alsa volume.\n");
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
snd_mixer_selem_id_set_name(vol_info, channel);
snd_mixer_selem_id_set_name(mute_info, channel);
/* open wifi file */
if(!(fp = fopen(path, "r"))) {
fprintf(stderr, "Error opening wifi operstate file.\n");
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* read the status */
/* check if interface down */
if(strcmp(status, "up\n") != 0) {
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* open wifi file */
if (!(fp = fopen("/proc/net/wireless", "r"))) {
fprintf(stderr, "Error opening wireless file.\n");
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* extract the signal strength */
/* check */
if((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
fprintf(stderr, "Cannot open socket for interface: %s\n", wificard);
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
wreq.u.essid.pointer = id;
if (ioctl(sockfd,SIOCGIWESSID, &wreq) == -1) {
fprintf(stderr, "Get ESSID ioctl failed for interface %s\n", wificard);
- return smprintf("n/a");
+ return smprintf(unknowntext);
}
/* return the essid */
if (strcmp((char *)wreq.u.essid.pointer, "") == 0) {
- return smprintf("n/a");
+ return smprintf(unknowntext);
} else {
return smprintf("%s", (char *)wreq.u.essid.pointer);
}
char *res = argument.func(argument.args);
char *element = smprintf(argument.format, res);
if (element == NULL) {
- element = smprintf("n/a");
+ element = smprintf(unknowntext);
fprintf(stderr, "Failed to format output.\n");
}
strcat(status_string, element);