/* open battery now file */
if (!(fp = fopen(batterynowfile, "r"))) {
fprintf(stderr, "Error opening battery file.");
- exit(1);
+ return smprintf("n/a");
}
/* read value */
/* open battery full file */
if (!(fp = fopen(batteryfullfile, "r"))) {
fprintf(stderr, "Error opening battery file.");
- exit(1);
+ return smprintf("n/a");
}
/* read value */
/* open temperature file */
if (!(fp = fopen(tempfile, "r"))) {
fprintf(stderr, "Could not open temperature file.\n");
- exit(1);
+ return smprintf("n/a");
}
/* extract temperature */
/* open stat file */
if (!(fp = fopen("/proc/stat","r"))) {
fprintf(stderr, "Error opening stat file.");
- exit(1);
+ return smprintf("n/a");
}
/* read values */
/* open stat file */
if (!(fp = fopen("/proc/stat","r"))) {
fprintf(stderr, "Error opening stat file.");
- exit(1);
+ return smprintf("n/a");
}
/* read values */
/* get time in format */
time(&tm);
if(!strftime(buf, bufsize, timeformat, localtime(&tm))) {
- fprintf(stderr, "Strftime failed.\n");
- exit(1);
+ fprintf(stderr, "Strftime failed.\n");
+ return smprintf("n/a");
}
/* return time */
/* open meminfo file */
if (!(fp = fopen("/proc/meminfo", "r"))) {
fprintf(stderr, "Error opening meminfo file.");
- exit(1);
+ return smprintf("n/a");
}
/* read the values */
/* open wifi file */
if(!(fp = fopen(path, "r"))) {
fprintf(stderr, "Error opening wifi operstate file.");
- exit(1);
+ return smprintf("n/a");
}
/* read the status */
/* check if interface down */
if(strcmp(status, "up\n") != 0){
- return "n/a";
+ return smprintf("n/a");
}
/* open wifi file */
if (!(fp = fopen("/proc/net/wireless", "r"))) {
fprintf(stderr, "Error opening wireless file.");
- exit(1);
+ return smprintf("n/a");
}
/* extract the signal strength */