+/** The file containing user information (public key, permissions). */
+static char *user_list_file = NULL;
+static int mmd_shm_id;
+
+
+/** The task responsible for server command handling. */
+struct server_command_task {
+ /** TCP port on which para_server listens for connections. */
+ int listen_fd;
+ /** Copied from para_server's main function. */
+ int argc;
+ /** Argument vector passed to para_server's main function. */
+ char **argv;
+ /** The command task structure for scheduling. */
+ struct task task;
+};
+
+static int want_colors(void)
+{
+ if (conf.color_arg == color_arg_no)
+ return 0;
+ if (conf.color_arg == color_arg_yes)
+ return 1;
+ if (logfile)
+ return 0;
+ return isatty(STDERR_FILENO);
+}
+
+static int get_loglevel_by_name(const char *txt, size_t n)
+{
+ if (!strncasecmp(txt, "debug", n))
+ return LL_DEBUG;
+ if (!strncasecmp(txt, "info", n))
+ return LL_INFO;
+ if (!strncasecmp(txt, "notice", n))
+ return LL_NOTICE;
+ if (!strncasecmp(txt, "warning", n))
+ return LL_WARNING;
+ if (!strncasecmp(txt, "error", n))
+ return LL_ERROR;
+ if (!strncasecmp(txt, "crit", n))
+ return LL_CRIT;
+ if (!strncasecmp(txt, "emerg", n))
+ return LL_EMERG;
+ return -1;
+}
+
+static char log_colors[NUM_LOGLEVELS][COLOR_MAXLEN];
+
+static void init_colors_or_die(void)
+{
+ int ret, i;
+ static const char *default_log_colors[NUM_LOGLEVELS] = {
+ [LL_DEBUG] = "normal",
+ [LL_INFO] = "white bold",
+ [LL_NOTICE] = "cyan bold",
+ [LL_WARNING] = "green bold",
+ [LL_ERROR] = "yellow bold",
+ [LL_CRIT] = "magenta bold",
+ [LL_EMERG] = "red bold",
+ };
+
+ for (i = 0; i < NUM_LOGLEVELS; i++) {
+ ret = color_parse(default_log_colors[i], log_colors[i]);
+ assert(ret >= 0);
+ }
+
+ for (i = 0; i < conf.log_color_given; i++) {
+ char *arg = conf.log_color_arg[i], *p = strchr(arg, ':');
+ int ll;
+ if (!p)
+ goto err;
+ ret = get_loglevel_by_name(arg, p - arg);
+ if (ret < 0)
+ goto err;
+ ll = ret;
+ p++;
+ ret = color_parse(p, log_colors[ll]);
+ if (ret < 0)
+ goto err;
+ }
+ return;
+err:
+ PARA_EMERG_LOG("color syntax error, arg %d (%s)\n", i,
+ conf.log_color_arg[i]);
+ exit(EXIT_FAILURE);
+}