- opts_parse(cfg, argc, argv);
- debug("argv0 = %s\n", argv0);
- config_print(cfg);
- if (cfg->fifos == NULL)
- usage("No fifo specs were given!\n");
-
- width = cfg->total_width;
- seplen = strlen(cfg->separator);
-
- /* 1st pass to make space for separators */
- for (Fifo *f = cfg->fifos; f; f = f->next) {
- f->pos += prefix;
+ opts_parse(&cfg, argc, argv);
+ khlib_debug("argv0 = %s\n", argv0);
+ config_print(&cfg);
+
+ ti = khlib_timespec_of_float(cfg.interval);
+
+ if (cfg.slots == NULL)
+ usage("No slot specs were given!\n");
+
+ /* 1st pass to check file existence and type */
+ for (Slot *s = cfg.slots; s; s = s->next) {
+ if (lstat(s->in_fifo, &st) < 0) {
+ khlib_error(
+ "Cannot stat \"%s\". Error: %s\n",
+ s->in_fifo,
+ strerror(errno)
+ );
+ errors++;
+ continue;
+ }
+ if (!(st.st_mode & S_IFIFO)) {
+ khlib_error("\"%s\" is not a FIFO\n", s->in_fifo);
+ errors++;
+ continue;
+ }
+ }
+ if (errors)
+ khlib_fatal(
+ "Encountered errors with given file paths. See log.\n"
+ );
+
+ width = cfg.total_width;
+ seplen = strlen(cfg.separator);
+
+ /* 2nd pass to make space for separators */
+ for (Slot *s = cfg.slots; s; s = s->next) {
+ s->out_pos_lo += prefix;
+ s->out_pos_hi += prefix;
+ s->out_pos_cur = s->out_pos_lo;