static void cf_reconfigure(disorder_client *c,
char attribute((unused)) **argv) {
+ /* Re-check configuration for server */
+ if(config_read(1)) fatal(0, "cannot read configuration");
if(disorder_reconfigure(c)) exit(EXIT_FAILURE);
}
default: fatal(0, "invalid option");
}
}
- if(config_read()) fatal(0, "cannot read configuration");
+ if(config_read(0)) fatal(0, "cannot read configuration");
if(!(c = disorder_new(1))) exit(EXIT_FAILURE);
s = config_get_file("socket");
if(disorder_connect(c)) exit(EXIT_FAILURE);
assert(argc > 0);
mem_init();
debugging = 0; /* turn on for even more verbosity */
- if(config_read()) fatal(0, "config_read failed");
+ if(config_read(0)) fatal(0, "config_read failed");
tracks = &argv[1];
c = disorder_eclient_new(&callbacks, &u_value);
assert(c != 0);
/* create the event loop */
D(("create main loop"));
mainloop = g_main_loop_new(0, 0);
- if(config_read()) fatal(0, "cannot read configuration");
+ if(config_read(0)) fatal(0, "cannot read configuration");
/* create the clients */
if(!(client = gtkclient())
|| !(logclient = gtkclient()))
}
/** @brief Set post-parse defaults */
-static void config_postdefaults(struct config *c) {
+static void config_postdefaults(struct config *c,
+ int server) {
struct config_state cs;
const struct conf *whoami;
int n;
#endif
}
}
- if(c->speaker_backend == BACKEND_COMMAND && !c->speaker_command)
- fatal(0, "speaker_backend is command but speaker_command is not set");
- if(c->speaker_backend == BACKEND_NETWORK && !c->broadcast.n)
- fatal(0, "speaker_backend is network but broadcast is not set");
+ if(server) {
+ if(c->speaker_backend == BACKEND_COMMAND && !c->speaker_command)
+ fatal(0, "speaker_backend is command but speaker_command is not set");
+ if(c->speaker_backend == BACKEND_NETWORK && !c->broadcast.n)
+ fatal(0, "speaker_backend is network but broadcast is not set");
+ }
if(c->speaker_backend) {
/* Override sample format */
c->sample_format.rate = 44100;
}
}
-/** @brief (Re-)read the config file */
-int config_read() {
+/** @brief (Re-)read the config file
+ * @param server If set, do extra checking
+ */
+int config_read(int server) {
struct config *c;
char *privconf;
struct passwd *pw;
return -1;
xfree(privconf);
/* install default namepart and transform settings */
- config_postdefaults(c);
+ config_postdefaults(c, server);
/* everything is good so we shall use the new config */
config_free(config);
config = c;
extern struct config *config;
/* the current configuration */
-int config_read(void);
+int config_read(int server);
/* re-read config, return 0 on success or non-0 on error.
* Only updates @config@ if the new configuration is valid. */
cgi_parse();
if((conf = getenv("DISORDER_CONFIG"))) configfile = xstrdup(conf);
if(getenv("DISORDER_DEBUG")) debugging = 1;
- if(config_read()) exit(EXIT_FAILURE);
+ if(config_read(0)) exit(EXIT_FAILURE);
memset(&g, 0, sizeof g);
memset(&s, 0, sizeof s);
s.g = &g;
openlog(progname, LOG_PID, LOG_DAEMON);
log_default = &log_syslog;
}
- if(config_read()) fatal(0, "cannot read configuration");
+ if(config_read(0)) fatal(0, "cannot read configuration");
info("started");
trackdb_init(0);
while(getppid() != 1) {
ev = ev_new();
if(ev_child_setup(ev)) fatal(0, "ev_child_setup failed");
/* read config */
- if(config_read())
+ if(config_read(1))
fatal(0, "cannot read configuration");
/* Start the speaker process (as root! - so it can choose its nice value) */
speaker_setup(ev);
fatal(0, "specify only a dump file name");
path = argv[optind];
}
- if(config_read()) fatal(0, "cannot read configuration");
+ if(config_read(0)) fatal(0, "cannot read configuration");
trackdb_init(recover);
trackdb_open();
if(dump) {
fatal(errno, "error calling setlocale");
if(argc > 1)
fatal(0, "not intended to be invoked by users");
- if(config_read())
+ if(config_read(1))
fatal(0, "cannot read configuration");
if(!isatty(2)) {
openlog(progname, LOG_PID, LOG_DAEMON);
openlog(progname, LOG_PID, LOG_DAEMON);
log_default = &log_syslog;
}
- if(config_read()) fatal(0, "cannot read configuration");
+ if(config_read(0)) fatal(0, "cannot read configuration");
xnice(config->nice_rescan);
sa.sa_handler = signal_handler;
sa.sa_flags = SA_RESTART;
break;
case SM_RELOAD:
D(("SM_RELOAD"));
- if(config_read()) error(0, "cannot read configuration");
+ if(config_read(1)) error(0, "cannot read configuration");
info("reloaded configuration");
break;
default:
openlog(progname, LOG_PID, LOG_DAEMON);
log_default = &log_syslog;
}
- if(config_read()) fatal(0, "cannot read configuration");
+ if(config_read(1)) fatal(0, "cannot read configuration");
bpf = bytes_per_frame(&config->sample_format);
/* ignore SIGPIPE */
signal(SIGPIPE, SIG_IGN);
if(reload) {
need_another_rescan = trackdb_rescan_cancel();
trackdb_close();
- if(config_read())
+ if(config_read(1))
ret = -1;
else {
/* Tell the speaker it needs to reload its config too. */
}
if(argc - optind < 3) fatal(0, "not enough arguments");
if(argc - optind > 3) fatal(0, "too many arguments");
- if(config_read()) fatal(0, "cannot read configuration");
+ if(config_read(0)) fatal(0, "cannot read configuration");
s = trackname_part(argv[optind], argv[optind+1], argv[optind+2]);
if(!s) fatal(0, "trackname_part returned NULL");
xprintf("%s\n", nullcheck(utf82mb(s)));