Xinqi Bao's Git
projects
/
slstatus.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
Update README.md
[slstatus.git]
/
slstatus.c
diff --git
a/slstatus.c
b/slstatus.c
index
86d27eb
..
fe27be4
100644
(file)
--- a/
slstatus.c
+++ b/
slstatus.c
@@
-3,6
+3,7
@@
/* global libraries */
#include <alsa/asoundlib.h>
#include <fcntl.h>
/* global libraries */
#include <alsa/asoundlib.h>
#include <fcntl.h>
+#include <locale.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@@
-42,9
+43,17
@@
int
config_check()
{
struct stat fs;
config_check()
{
struct stat fs;
+
+ /* check all files in the config.h file */
CHECK_FILE(batterynowfile, fs);
CHECK_FILE(batteryfullfile, fs);
CHECK_FILE(tempfile, fs);
CHECK_FILE(batterynowfile, fs);
CHECK_FILE(batteryfullfile, fs);
CHECK_FILE(tempfile, fs);
+
+ /* check update interval */
+ if (update_interval < 1)
+ return -1;
+
+ /* exit successfully */
return 0;
}
return 0;
}
@@
-183,11
+192,14
@@
get_datetime()
/* get time in format */
time(&tm);
/* get time in format */
time(&tm);
+ setlocale(LC_TIME, "");
if(!strftime(buf, bufsize, timeformat, localtime(&tm))) {
if(!strftime(buf, bufsize, timeformat, localtime(&tm))) {
+ setlocale(LC_TIME, "C");
fprintf(stderr, "Strftime failed.\n");
return smprintf("n/a");
}
fprintf(stderr, "Strftime failed.\n");
return smprintf("n/a");
}
+ setlocale(LC_TIME, "C");
/* return time */
return smprintf("%s", buf);
}
/* return time */
return smprintf("%s", buf);
}
@@
-337,7
+349,7
@@
main()
/* check config for sanity */
if (config_check() < 0) {
/* check config for sanity */
if (config_check() < 0) {
- fprintf(stderr, "Config error, please check paths and
recompile
\n");
+ fprintf(stderr, "Config error, please check paths and
interval and recompile!
\n");
exit(1);
}
exit(1);
}