GPLv2. Added appendix with full license. Added refernece to that from
[pazpar2-moved-to-github.git] / src / settings.c
index 391a32b..a82400a 100644 (file)
@@ -1,4 +1,25 @@
-// $Id: settings.c,v 1.4 2007-03-30 02:45:07 quinn Exp $
+/* $Id: settings.c,v 1.10 2007-04-10 08:48:56 adam Exp $
+   Copyright (c) 2006-2007, Index Data.
+
+This file is part of Pazpar2.
+
+Pazpar2 is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Pazpar2; see the file LICENSE.  If not, write to the
+Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
+ */
+
+
 // This module implements a generic system of settings (attribute-value) that can 
 // be associated with search targets. The system supports both default values,
 // per-target overrides, and per-user settings.
@@ -26,8 +47,14 @@ static NMEM nmem = 0;
 static char *hard_settings[] = {
     "pz:piggyback",
     "pz:elements",
-    "pz:syntax",
+    "pz:requestsyntax",
     "pz:cclmap:",
+    "pz:encoding",
+    "pz:xslt",
+    "pz:nativesyntax",
+    "pz:authentication",
+    "pz:allow",
+    "pz:maxrecs",
     0
 };
 
@@ -44,6 +71,8 @@ int settings_offset(const char *name)
 {
     int i;
 
+    if (!name)
+        name = "";
     for (i = 0; i < dictionary->num; i++)
         if (!strcmp(name, dictionary->dict[i]))
             return i;
@@ -106,15 +135,15 @@ static void read_settings_file(const char *path,
     {
         if (n->type != XML_ELEMENT_NODE)
             continue;
-        if (!strcmp(n->name, (xmlChar *) "set"))
+        if (!strcmp((const char *) n->name, "set"))
         {
             char *name, *target, *value, *user, *precedence;
 
-            name = xmlGetProp(n, (xmlChar *) "name");
-            target = xmlGetProp(n, (xmlChar *) "target");
-            value = xmlGetProp(n, (xmlChar *) "value");
-            user = xmlGetProp(n, (xmlChar *) "user");
-            precedence = xmlGetProp(n, (xmlChar *) "precedence");
+            name = (char *) xmlGetProp(n, (xmlChar *) "name");
+            target = (char *) xmlGetProp(n, (xmlChar *) "target");
+            value = (char *) xmlGetProp(n, (xmlChar *) "value");
+            user = (char *) xmlGetProp(n, (xmlChar *) "user");
+            precedence = (char *) xmlGetProp(n, (xmlChar *) "precedence");
 
             if ((!name && !namea) || (!value && !valuea) || (!target && !targeta))
             {
@@ -141,23 +170,23 @@ static void read_settings_file(const char *path,
                 if (user)
                     strcpy(userb, user);
                 else if (usera)
-                    strcpy(userb, usera);
+                    strcpy(userb, (const char *) usera);
                 else
                     set.user = "";
                 if (target)
                     strcpy(targetb, target);
                 else
-                    strcpy(targetb, targeta);
+                    strcpy(targetb, (const char *) targeta);
                 set.target = targetb;
                 if (name)
                     strcpy(nameb, name);
                 else
-                    strcpy(nameb, namea);
+                    strcpy(nameb, (const char *) namea);
                 set.name = nameb;
                 if (value)
                     strcpy(valueb, value);
                 else
-                    strcpy(valueb, valuea);
+                    strcpy(valueb, (const char *) valuea);
                 set.value = valueb;
                 set.next = 0;
                 (*fun)(&set);
@@ -224,6 +253,11 @@ static void prepare_dictionary(struct setting *set)
     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);
+        exit(1);
+    }
     // Create a new dictionary entry
     // Grow dictionary if necessary
     if (!dictionary->size)