static void init_colors_or_die(void)
{
- int ret, i;
+ int i;
if (!want_colors())
return;
daemon_set_default_log_colors();
daemon_set_flag(DF_COLOR_LOG);
- for (i = 0; i < conf.log_color_given; i++) {
- ret = daemon_set_log_color(conf.log_color_arg[i]);
- if (ret < 0)
- exit(EXIT_FAILURE);
- }
+ for (i = 0; i < conf.log_color_given; i++)
+ daemon_set_log_color_or_die(conf.log_color_arg[i]);
}
/**
* \param value Human-readable color spec.
* \param dst Result pointer for the escape sequence.
*
- * \return -1 on errors, 1 on success.
- *
* Format of \a value: [fg [bg]] [attr].
*/
-int color_parse(const char *value, char *dst)
+void color_parse_or_die(const char *value, char *dst)
{
const char *ptr = value;
int attr = -1;
if (!strcasecmp(value, "reset")) {
strcpy(dst, COLOR_RESET);
- return 1;
+ return;
}
/* [fg [bg]] [attr] */
*dst++ = 'm';
}
*dst = 0;
- return 1;
+ return;
bad:
- PARA_ERROR_LOG("bad color value '%s'\n", value);
- return -1;
+ PARA_EMERG_LOG("bad color value '%s'\n", value);
+ exit(EXIT_FAILURE);
}
/** Switch back to normal colors. */
#define COLOR_RESET "\033[m"
-int color_parse(const char *value, char *dst);
+void color_parse_or_die(const char *value, char *dst);
[LL_CRIT] = "magenta bold",
[LL_EMERG] = "red bold",
};
- for (i = 0; i < NUM_LOGLEVELS; i++) {
- int ret = color_parse(default_log_colors[i], me->log_colors[i]);
- assert(ret >= 0);
- }
+ for (i = 0; i < NUM_LOGLEVELS; i++)
+ color_parse_or_die(default_log_colors[i], me->log_colors[i]);
}
/**
*
* \return 1 On success, -1 on errors.
*/
-int daemon_set_log_color(char const *arg)
+void daemon_set_log_color_or_die(char const *arg)
{
char *p = strchr(arg, ':');
int ret, ll;
goto err;
ll = ret;
p++;
- ret = color_parse(p, me->log_colors[ll]);
- if (ret < 0)
- goto err;
- return 1;
+ color_parse_or_die(p, me->log_colors[ll]);
+ return;
err:
- PARA_ERROR_LOG("%s: color syntax error\n", arg);
- return -1;
-
+ PARA_EMERG_LOG("%s: color syntax error\n", arg);
+ exit(EXIT_FAILURE);
}
/**
void daemon_clear_flag(unsigned flag);
void daemon_set_loglevel(char *loglevel);
void daemon_set_default_log_colors(void);
-int daemon_set_log_color(char const *arg);
+void daemon_set_log_color_or_die(char const *arg);
/** Daemon log configuration flags. */
enum daemon_flags {
static void init_colors_or_die(void)
{
- int ret, i;
+ int i;
if (!want_colors())
return;
daemon_set_flag(DF_COLOR_LOG);
daemon_set_default_log_colors();
- for (i = 0; i < conf.log_color_given; i++) {
- ret = daemon_set_log_color(conf.log_color_arg[i]);
- if (ret < 0)
- exit(EXIT_FAILURE);
- }
+ for (i = 0; i < conf.log_color_given; i++)
+ daemon_set_log_color_or_die(conf.log_color_arg[i]);
}
/*