X-Git-Url: https://git.xandkar.net/?p=khatus.git;a=blobdiff_plain;f=x5%2Fkhatus_sensor_battery.c;fp=x5%2Fkhatus_sensor_battery.c;h=9923b34a4aca44ddd1ee8cb7e3fc511fc6948d9c;hp=e6c7fe8b1f41d8de7aa074db1009e16d39ed8da0;hb=1084633a90758b15f09bc5ec232c45470cdadc37;hpb=16e0239d76a7de132b20a564cc2c14ff2358ecf2 diff --git a/x5/khatus_sensor_battery.c b/x5/khatus_sensor_battery.c index e6c7fe8..9923b34 100644 --- a/x5/khatus_sensor_battery.c +++ b/x5/khatus_sensor_battery.c @@ -10,8 +10,8 @@ #include #include -#include "khatus_lib_log.h" -#include "khatus_lib_time.h" +#include "khlib_log.h" +#include "khlib_time.h" #define usage(...) {print_usage(); fprintf(stderr, "Error:\n " __VA_ARGS__); exit(EXIT_FAILURE);} @@ -77,12 +77,16 @@ get_capacity(char *buf, char *path) int cap; if (!(fp = fopen(path, "r"))) - fatal("Failed to open %s. errno: %d, msg: %s\n", - path, errno, strerror(errno)); + khlib_fatal( + "Failed to open %s. errno: %d, msg: %s\n", + path, + errno, + strerror(errno) + ); switch (fscanf(fp, "%d", &cap)) { - case -1: fatal("EOF\n"); - case 0: fatal("Read 0\n"); + case -1: khlib_fatal("EOF\n"); + case 0: khlib_fatal("Read 0\n"); case 1: break; default: assert(0); } @@ -101,10 +105,10 @@ main(int argc, char **argv) struct timespec ti; opt_parse(argc, argv); - ti = timespec_of_float(opt_interval); - debug("opt_battery: \"%s\"\n", opt_battery); - debug("opt_interval: %f\n", opt_interval); - debug("ti: {tv_sec = %ld, tv_nsec = %ld}\n", ti.tv_sec, ti.tv_nsec); + ti = khlib_timespec_of_float(opt_interval); + khlib_debug("opt_battery: \"%s\"\n", opt_battery); + khlib_debug("opt_interval: %f\n", opt_interval); + khlib_debug("ti: {tv_sec = %ld, tv_nsec = %ld}\n",ti.tv_sec,ti.tv_nsec); memset(path, '\0', PATH_MAX); snprintf(path, PATH_MAX, path_fmt, opt_battery); signal(SIGPIPE, SIG_IGN); @@ -113,7 +117,7 @@ main(int argc, char **argv) get_capacity(buf, path); puts(buf); fflush(stdout); - snooze(&ti); + khlib_sleep(&ti); } return EXIT_SUCCESS; }