chiark / gitweb /
Source code reorganization:
[disorder] / lib / configuration.c
index 3cf276e821d972ef321b89129082cd11cd2a1521..c66f66bf04f8c44709a69ad35585349ddd562df1 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder.
- * Copyright (C) 2004, 2005, 2006, 2007 Richard Kettlewell
+ * Copyright (C) 2004-2008 Richard Kettlewell
  * Portions copyright (C) 2007 Mark Wooding
  *
  * This program is free software; you can redistribute it and/or modify
  * @brief Configuration file support
  */
 
-#include <config.h>
-#include "types.h"
+#include "common.h"
 
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
 #include <errno.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -311,7 +307,7 @@ static int set_restrict(const struct config_state *cs,
   };
 
   for(n = 0; n < nvec; ++n) {
-    if((i = TABLE_FIND(restrictions, struct restriction, name, vec[n])) < 0) {
+    if((i = TABLE_FIND(restrictions, name, vec[n])) < 0) {
       error(0, "%s:%d: invalid restriction '%s'",
            cs->path, cs->line, vec[n]);
       return -1;
@@ -946,6 +942,9 @@ static const struct conf conf[] = {
   { C(multicast_loop),   &type_boolean,          validate_any },
   { C(multicast_ttl),    &type_integer,          validate_non_negative },
   { C(namepart),         &type_namepart,         validate_any },
+  { C(new_bias),         &type_integer,          validate_positive },
+  { C(new_bias_age),     &type_integer,          validate_positive },
+  { C(new_max),          &type_integer,          validate_positive },
   { C2(nice, nice_rescan), &type_integer,        validate_non_negative },
   { C(nice_rescan),      &type_integer,          validate_non_negative },
   { C(nice_server),      &type_integer,          validate_any },
@@ -956,7 +955,10 @@ static const struct conf conf[] = {
   { C(plugins),          &type_string_accum,     validate_isdir },
   { C(prefsync),         &type_integer,          validate_positive },
   { C(queue_pad),        &type_integer,          validate_positive },
+  { C(replay_min),       &type_integer,          validate_non_negative },
   { C(refresh),          &type_integer,          validate_positive },
+  { C(reminder_interval), &type_integer,         validate_positive },
+  { C(remote_userman),   &type_boolean,          validate_any },
   { C2(restrict, restrictions),         &type_restrict,         validate_any },
   { C(sample_format),    &type_sample_format,    validate_sample_format },
   { C(scratch),          &type_string_accum,     validate_isreg },
@@ -980,7 +982,7 @@ static const struct conf conf[] = {
 static const struct conf *find(const char *key) {
   int n;
 
-  if((n = TABLE_FIND(conf, struct conf, name, key)) < 0)
+  if((n = TABLE_FIND(conf, name, key)) < 0)
     return 0;
   return &conf[n];
 }
@@ -1176,6 +1178,7 @@ static struct config *config_default(void) {
   c->sample_format.channels = 2;
   c->sample_format.endian = ENDIAN_NATIVE;
   c->queue_pad = 10;
+  c->replay_min = 8 * 3600;
   c->api = -1;
   c->multicast_ttl = 1;
   c->multicast_loop = 1;
@@ -1188,6 +1191,10 @@ static struct config *config_default(void) {
   c->cookie_login_lifetime = 86400;
   c->cookie_key_lifetime = 86400 * 7;
   c->smtp_server = xstrdup("127.0.0.1");
+  c->new_max = 100;
+  c->reminder_interval = 600;          /* 10m */
+  c->new_bias_age = 7 * 86400;         /* 1 week */
+  c->new_bias = 9000000;               /* 100 times the base weight */
   /* Default stopwords */
   if(config_set(&cs, (int)NDEFAULT_STOPWORDS, (char **)default_stopwords))
     exit(1);
@@ -1273,17 +1280,8 @@ static void config_postdefaults(struct config *c,
       c->api = BACKEND_COMMAND;
     else if(c->broadcast.n)
       c->api = BACKEND_NETWORK;
-    else {
-#if HAVE_ALSA_ASOUNDLIB_H
-      c->api = BACKEND_ALSA;
-#elif HAVE_SYS_SOUNDCARD_H
-      c->api = BACKEND_OSS;
-#elif HAVE_COREAUDIO_AUDIOHARDWARE_H
-      c->api = BACKEND_COREAUDIO;
-#else
-      c->api = BACKEND_COMMAND;
-#endif
-    }
+    else
+      c->api = DEFAULT_BACKEND;
   }
   if(server) {
     if(c->api == BACKEND_COMMAND && !c->speaker_command)
@@ -1357,7 +1355,7 @@ int config_read(int server) {
       return -1;
     xfree(privconf);
     /* if we have a password file, read it */
-    if((privconf = config_userconf(getenv("HOME"), pw))
+    if((privconf = config_userconf(0, pw))
        && access(privconf, F_OK) == 0
        && config_include(c, privconf))
       return -1;