static void parse_config_or_die(void)
{
+ int ret;
char *config_file;
struct audiod_cmdline_parser_params params = {
.override = 0,
config_file = make_message("%s/.paraslash/audiod.conf", home);
free(home);
}
- if (conf.config_file_given && !file_exists(config_file)) {
+ ret = file_exists(config_file);
+ if (conf.config_file_given && !ret) {
PARA_EMERG_LOG("can not read config file %s\n", config_file);
goto err;
}
- if (audiod_cmdline_parser_config_file(config_file, &conf, ¶ms)) {
- PARA_EMERG_LOG("parse error in config file\n");
- goto err;
- }
+ if (ret)
+ audiod_cmdline_parser_config_file(config_file, &conf, ¶ms);
free(config_file);
daemon_set_loglevel(conf.loglevel_arg);
return;
return filter_num;
}
-static int init_writers(void)
+static int parse_writer_args(void)
{
int i, ret, nw;
char *cmd;
struct audio_format_info *a;
- init_supported_writers();
nw = PARA_MAX(1U, conf.writer_given);
PARA_INFO_LOG("maximal number of writers: %d\n", nw);
FOR_EACH_AUDIO_FORMAT(i) {
return ret;
}
-static int init_receivers(void)
+static int parse_receiver_args(void)
{
int i, ret, receiver_num;
char *cmd = NULL;
struct audio_format_info *a;
- for (i = 0; receivers[i].name; i++) {
- PARA_INFO_LOG("initializing %s receiver\n", receivers[i].name);
- receivers[i].init(&receivers[i]);
- }
for (i = conf.receiver_given - 1; i >= 0; i--) {
char *arg = conf.receiver_arg[i];
char *recv_arg = strchr(arg, ':');
return ret;
}
-static int init_filters(void)
+static int parse_filter_args(void)
{
int i, ret, nf;
- filter_init(filters);
nf = PARA_MAX(1U, conf.filter_given);
PARA_INFO_LOG("maximal number of filters: %d\n", nf);
FOR_EACH_AUDIO_FORMAT(i) {
return ret;
}
-static int init_stream_io(void)
+static int parse_stream_args(void)
{
int ret;
- ret = init_writers();
+ ret = parse_receiver_args();
if (ret < 0)
return ret;
- ret = init_receivers();
+ ret = parse_filter_args();
if (ret < 0)
return ret;
- ret = init_filters();
+ ret = parse_writer_args();
if (ret < 0)
return ret;
return 1;
};
valid_fd_012();
- audiod_cmdline_parser_ext(argc, argv, &conf, ¶ms);
+ if (audiod_cmdline_parser_ext(argc, argv, &conf, ¶ms))
+ exit(EXIT_FAILURE);
HANDLE_VERSION_FLAG("audiod", conf);
+ /* init receivers/filters/writers early to make help work */
+ recv_init();
+ filter_init();
+ writer_init();
if (conf.help_given || conf.detailed_help_given)
print_help_and_die();
drop_privileges_or_die(conf.user_arg, conf.group_arg);
parse_config_or_die();
+ init_colors_or_die();
daemon_set_flag(DF_LOG_TIME);
daemon_set_flag(DF_LOG_HOSTNAME);
daemon_set_flag(DF_LOG_LL);
daemon_set_logfile(conf.logfile_arg);
daemon_open_log_or_die();
}
- init_colors_or_die();
- i = init_stream_io();
- if (i < 0) {
- PARA_EMERG_LOG("init stream io error: %s\n", para_strerror(-i));
+ ret = parse_stream_args();
+ if (ret < 0) {
+ PARA_EMERG_LOG("%s\n", para_strerror(-ret));
exit(EXIT_FAILURE);
}
log_welcome("para_audiod");