Removed 'user' from settings structure and code..
[pazpar2-moved-to-github.git] / src / settings.c
index ea84e06..4e0624f 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: settings.c,v 1.11 2007-04-11 02:14:15 quinn Exp $
+/* $Id: settings.c,v 1.14 2007-04-11 19:55:57 quinn Exp $
    Copyright (c) 2006-2007, Index Data.
 
 This file is part of Pazpar2.
@@ -56,6 +56,7 @@ static char *hard_settings[] = {
     "pz:allow",
     "pz:maxrecs",
     "pz:id",
+    "pz:name",
     0
 };
 
@@ -162,7 +163,6 @@ static void read_settings_file(const char *path,
                 struct setting set;
                 char nameb[1024];
                 char targetb[1024];
-                char userb[1024];
                 char valueb[1024];
 
                 // Copy everything into a temporary buffer -- we decide
@@ -173,13 +173,6 @@ static void read_settings_file(const char *path,
                     set.precedence = atoi((char *) precedencea);
                 else
                     set.precedence = 0;
-                set.user = userb;
-                if (user)
-                    strcpy(userb, user);
-                else if (usera)
-                    strcpy(userb, (const char *) usera);
-                else
-                    set.user = "";
                 if (target)
                     strcpy(targetb, target);
                 else
@@ -215,6 +208,8 @@ static void read_settings_file(const char *path,
     xmlFree(valuea);
     xmlFree(usera);
     xmlFree(targeta);
+
+    xmlFreeDoc(doc);
 }
  
 // Recursively read files in a directory structure, calling 
@@ -250,16 +245,23 @@ static void read_settings(const char *path,
 
 // Callback. Adds a new entry to the dictionary if necessary
 // This is used in pass 1 to determine layout of dictionary
+// and to load any databases mentioned
 static void prepare_dictionary(struct setting *set)
 {
     int i;
     char *p;
 
+    // If target address is not wildcard, add the database
+    if (*set->target && set->target[strlen(set->target) - 1] != '*')
+        find_database(set->target, 0);
+
+    // Determine if we already have a dictionary entry
     if (!strncmp(set->name, "pz:", 3) && (p = strchr(set->name + 3, ':')))
         *(p + 1) = '\0';
     for (i = 0; i < dictionary->num; i++)
         if (!strcmp(dictionary->dict[i], set->name))
             return;
+
     if (!strncmp(set->name, "pz:", 3)) // Probably a typo in config fle
     {
         yaz_log(YLOG_FATAL, "Unknown pz: setting '%s'", set->name);
@@ -302,7 +304,6 @@ static void update_database(void *context, struct database *db)
         id->precedence = 0;
         id->name = "pz:id";
         id->target = id->value = db->url;
-        id->user = "";
         id->next = 0;
         db->settings[PZ_ID] = id;
     }
@@ -313,7 +314,7 @@ static void update_database(void *context, struct database *db)
     // with the same name.
     for (s = db->settings[offset], sp = &db->settings[offset]; s;
             sp = &s->next, s = s->next)
-        if (!strcmp(s->user, set->user) && !strcmp(s->name, set->name))
+        if (!strcmp(s->name, set->name))
         {
             if (s->precedence < set->precedence)
                 // We discard the value (nmem keeps track of the space)
@@ -337,7 +338,6 @@ static void update_database(void *context, struct database *db)
         new->target = nmem_strdup(nmem, set->target);
         new->name = nmem_strdup(nmem, set->name);
         new->value = nmem_strdup(nmem, set->value);
-        new->user = nmem_strdup(nmem, set->user);
         new->next = db->settings[offset];
         db->settings[offset] = new;
     }