X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=x5%2Fkhatus.c;h=ee96d60619c2af06a7d85f22ee5b2ee4a66827fe;hb=a6b13fa2d61136a971b2ebbf6eadb943002fa9d5;hp=3d81cad810e65dc9318e6f059089b249d2f5e5b0;hpb=4c438cef6b69db82d2835d2c32d41fae12c93016;p=khatus.git diff --git a/x5/khatus.c b/x5/khatus.c index 3d81cad..ee96d60 100644 --- a/x5/khatus.c +++ b/x5/khatus.c @@ -69,24 +69,23 @@ struct Config { void fifo_print_one(Fifo *f, Config *cfg) { - info( - "Fifo " - "{" - " name = %s," - " fd = %d," - " width = %d," - " last_read = %d," - " ttl = %d," - " pos = %d," - " next = %p," - " }\n", - f->name, - f->fd, - f->width, - f->last_read, - f->ttl, - f->pos, - f->next + info("Fifo " + "{" + " name = %s," + " fd = %d," + " width = %d," + " last_read = %d," + " ttl = %d," + " pos = %d," + " next = %p," + " }\n", + f->name, + f->fd, + f->width, + f->last_read, + f->ttl, + f->pos, + f->next ); } @@ -102,20 +101,20 @@ void config_print(Config *cfg) { info( - "Config " - "{" - " interval = %d," - " separator = %s," - " fifo_count = %d," - " total_width = %d," - " log_level = %d," - " fifos = ..." - " }\n", - cfg->interval, - cfg->separator, - cfg->fifo_count, - cfg->total_width, - cfg->log_level + "Config " + "{" + " interval = %d," + " separator = %s," + " fifo_count = %d," + " total_width = %d," + " log_level = %d," + " fifos = ..." + " }\n", + cfg->interval, + cfg->separator, + cfg->fifo_count, + cfg->total_width, + cfg->log_level ); fifo_print_all(cfg->fifos, cfg); } @@ -134,31 +133,31 @@ print_usage() { assert(argv0); fprintf( - stderr, - "\n" - "Usage: %s [OPTION ...] SPEC [SPEC ...]\n" - "\n" - " SPEC = FILE_PATH DATA_WIDTH DATA_TTL\n" - " FILE_PATH = string\n" - " DATA_WIDTH = int (* (positive) number of characters *)\n" - " DATA_TTL = int (* (positive) number of seconds *)\n" - " OPTION = -i INTERVAL\n" - " | -s SEPARATOR\n" - " | -x (* Output to X root window *)\n" - " | -l LOG_LEVEL\n" - " SEPARATOR = string\n" - " INTERVAL = int (* (positive) number of seconds *)\n" - " LOG_LEVEL = int (* %d through %d *)\n" - "\n", - argv0, - Nothing, - Debug + stderr, + "\n" + "Usage: %s [OPTION ...] SPEC [SPEC ...]\n" + "\n" + " SPEC = FILE_PATH DATA_WIDTH DATA_TTL\n" + " FILE_PATH = string\n" + " DATA_WIDTH = int (* (positive) number of characters *)\n" + " DATA_TTL = int (* (positive) number of seconds *)\n" + " OPTION = -i INTERVAL\n" + " | -s SEPARATOR\n" + " | -x (* Output to X root window *)\n" + " | -l LOG_LEVEL\n" + " SEPARATOR = string\n" + " INTERVAL = int (* (positive) number of seconds *)\n" + " LOG_LEVEL = int (* %d through %d *)\n" + "\n", + argv0, + Nothing, + Debug ); fprintf( - stderr, - "Example: %s -i 1 /dev/shm/khatus/khatus_sensor_x 4 10\n" - "\n", - argv0 + stderr, + "Example: %s -i 1 /dev/shm/khatus/khatus_sensor_x 4 10\n" + "\n", + argv0 ); } @@ -210,24 +209,24 @@ void parse_opts_opt(Config *cfg, int argc, char *argv[], int i) { switch (argv[i][1]) { - case 'i': - /* TODO: Generic set_int */ - parse_opts_opt_i(cfg, argc, argv, ++i); - break; - case 's': - /* TODO: Generic set_str */ - parse_opts_opt_s(cfg, argc, argv, ++i); - break; - case 'x': - cfg->output_to_x_root_window = 1; - opts_parse_any(cfg, argc, argv, ++i); - break; - case 'l': - /* TODO: Generic set_int */ - parse_opts_opt_l(cfg, argc, argv, ++i); - break; - default : - usage("Option \"%s\" is invalid\n", argv[i]); + case 'i': + /* TODO: Generic set_int */ + parse_opts_opt_i(cfg, argc, argv, ++i); + break; + case 's': + /* TODO: Generic set_str */ + parse_opts_opt_s(cfg, argc, argv, ++i); + break; + case 'x': + cfg->output_to_x_root_window = 1; + opts_parse_any(cfg, argc, argv, ++i); + break; + case 'l': + /* TODO: Generic set_int */ + parse_opts_opt_l(cfg, argc, argv, ++i); + break; + default : + usage("Option \"%s\" is invalid\n", argv[i]); } } @@ -269,11 +268,11 @@ opts_parse_any(Config *cfg, int argc, char *argv[], int i) { if (i < argc) { switch (argv[i][0]) { - case '-': - parse_opts_opt(cfg, argc, argv, i); - break; - default : - parse_opts_spec(cfg, argc, argv, i); + case '-': + parse_opts_opt(cfg, argc, argv, i); + break; + default : + parse_opts_spec(cfg, argc, argv, i); } } } @@ -393,9 +392,9 @@ snooze(struct timespec *t, Config *cfg) if (result < 0) { if (errno == EINTR) { info( - "nanosleep interrupted. Remainder: " - "{ tv_sec = %ld, tv_nsec = %ld }", - remainder.tv_sec, remainder.tv_nsec); + "nanosleep interrupted. Remainder: " + "{ tv_sec = %ld, tv_nsec = %ld }", + remainder.tv_sec, remainder.tv_nsec); /* No big deal if we occasionally sleep less, * so not attempting to correct after an interruption. */