This update completes the factoring out of database management into database.c,
[pazpar2-moved-to-github.git] / src / config.c
index 3ceb427..0630185 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: config.c,v 1.13 2007-01-15 16:56:51 quinn Exp $ */
+/* $Id: config.c,v 1.15 2007-03-15 16:50:56 quinn Exp $ */
 
 #include <string.h>
 
@@ -191,6 +191,7 @@ static struct conf_server *parse_server(xmlNode *node)
     r->port = 0;
     r->proxy_host = 0;
     r->proxy_port = 0;
+    r->myurl = 0;
     r->service = 0;
     r->next = 0;
 
@@ -213,12 +214,21 @@ static struct conf_server *parse_server(xmlNode *node)
         {
             xmlChar *port = xmlGetProp(n, "port");
             xmlChar *host = xmlGetProp(n, "host");
+            xmlChar *myurl = xmlGetProp(n, "myurl");
             if (port)
                 r->proxy_port = atoi(port);
             if (host)
                 r->proxy_host = nmem_strdup(nmem, host);
+            if (myurl)
+                r->myurl = nmem_strdup(nmem, myurl);
+            else
+            {
+                yaz_log(YLOG_FATAL, "Must specify @myurl for proxy");
+                return 0;
+            }
             xmlFree(port);
             xmlFree(host);
+            xmlFree(myurl);
         }
         else if (!strcmp(n->name, "service"))
         {
@@ -381,6 +391,41 @@ static struct conf_retrievalprofile *parse_retrievalprofile(xmlNode *node)
     return r;
 }
 
+static struct conf_targetprofiles *parse_targetprofiles(xmlNode *node)
+{
+    struct conf_targetprofiles *r = nmem_malloc(nmem, sizeof(*r));
+    memset(r, 0, sizeof(*r));
+    xmlChar *type = xmlGetProp(node, "type");
+    xmlChar *src = xmlGetProp(node, "src");
+
+    if (type)
+    {
+        if (!strcmp(type, "local"))
+            r->type = Targetprofiles_local;
+        else
+        {
+            yaz_log(YLOG_FATAL, "Unknown targetprofile type");
+            return 0;
+        }
+    }
+    else
+    {
+        yaz_log(YLOG_FATAL, "Must specify type for targetprofile");
+        return 0;
+    }
+
+    if (src)
+        r->src = nmem_strdup(nmem, src);
+    else
+    {
+        yaz_log(YLOG_FATAL, "Must specify src in targetprofile");
+        return 0;
+    }
+    xmlFree(type);
+    xmlFree(src);
+    return r;
+}
+
 static struct conf_config *parse_config(xmlNode *root)
 {
     xmlNode *n;
@@ -390,6 +435,7 @@ static struct conf_config *parse_config(xmlNode *root)
     r->servers = 0;
     r->queryprofiles = 0;
     r->retrievalprofiles = 0;
+    r->targetprofiles = 0;
 
     for (n = root->children; n; n = n->next)
     {
@@ -412,6 +458,17 @@ static struct conf_config *parse_config(xmlNode *root)
                 return 0;
             rp = &(*rp)->next;
         }
+        else if (!strcmp(n->name, "targetprofiles"))
+        {
+            // It would be fun to be able to fix this sometime
+            if (r->targetprofiles)
+            {
+                yaz_log(YLOG_FATAL, "Can't repeat targetprofiles");
+                return 0;
+            }
+            if (!(r->targetprofiles = parse_targetprofiles(n)))
+                return 0;
+        }
         else
         {
             yaz_log(YLOG_FATAL, "Bad element: %s", n->name);