+static int validate_addrport(const struct config_state attribute((unused)) *cs,
+ int nvec,
+ char attribute((unused)) **vec) {
+ switch(nvec) {
+ case 0:
+ error(0, "%s:%d: missing address",
+ cs->path, cs->line);
+ return -1;
+ case 1:
+ error(0, "%s:%d: missing port name/number",
+ cs->path, cs->line);
+ return -1;
+ case 2:
+ return 0;
+ default:
+ error(0, "%s:%d: expected ADDRESS PORT",
+ cs->path, cs->line);
+ return -1;
+ }
+}
+
+static int validate_port(const struct config_state attribute((unused)) *cs,
+ int nvec,
+ char attribute((unused)) **vec) {
+ switch(nvec) {
+ case 0:
+ error(0, "%s:%d: missing address",
+ cs->path, cs->line);
+ return -1;
+ case 1:
+ case 2:
+ return 0;
+ default:
+ error(0, "%s:%d: expected [ADDRESS] PORT",
+ cs->path, cs->line);
+ return -1;
+ }
+}
+
+static int validate_algo(const struct config_state attribute((unused)) *cs,
+ int nvec,
+ char **vec) {
+ if(nvec != 1) {
+ error(0, "%s:%d: invalid algorithm specification", cs->path, cs->line);
+ return -1;
+ }
+ if(!valid_authhash(vec[0])) {
+ error(0, "%s:%d: unsuported algorithm '%s'", cs->path, cs->line, vec[0]);
+ return -1;
+ }
+ return 0;
+}
+
+static int validate_backend(const struct config_state attribute((unused)) *cs,
+ int nvec,
+ char **vec) {
+ int n;
+ if(nvec != 1) {
+ error(0, "%s:%d: invalid sound API specification", cs->path, cs->line);
+ return -1;
+ }
+ if(!strcmp(vec[0], "network")) {
+ error(0, "'api network' is deprecated; use 'api rtp'");
+ return 0;
+ }
+ if(config_uaudio_apis) {
+ for(n = 0; config_uaudio_apis[n]; ++n)
+ if(!strcmp(vec[0], config_uaudio_apis[n]->name))
+ return 0;
+ error(0, "%s:%d: unrecognized sound API '%s'", cs->path, cs->line, vec[0]);
+ return -1;
+ }
+ /* In non-server processes we have no idea what's valid */
+ return 0;
+}
+
+static int validate_pausemode(const struct config_state attribute((unused)) *cs,
+ int nvec,
+ char **vec) {
+ if(nvec == 1 && (!strcmp(vec[0], "silence") || !strcmp(vec[0], "suspend")))
+ return 0;
+ error(0, "%s:%d: invalid pause mode", cs->path, cs->line);
+ return -1;
+}