New internal Deb package: osrting by year
[pazpar2-moved-to-github.git] / src / config.c
index 8214030..a15f5e3 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: config.c,v 1.35 2007-06-06 11:49:48 marc Exp $
+/* $Id: config.c,v 1.37 2007-06-19 10:15:44 adam Exp $
    Copyright (c) 2006-2007, Index Data.
 
 This file is part of Pazpar2.
@@ -19,7 +19,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.
  */
 
-/* $Id: config.c,v 1.35 2007-06-06 11:49:48 marc Exp $ */
+/* $Id: config.c,v 1.37 2007-06-19 10:15:44 adam Exp $ */
 
 #include <string.h>
 
@@ -35,6 +35,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 
 #include <yaz/yaz-util.h>
 #include <yaz/nmem.h>
+#include <yaz/snprintf.h>
 
 #define CONFIG_NOEXTERNS
 #include "config.h"
@@ -453,22 +454,6 @@ static struct conf_server *parse_server(xmlNode *node)
             xmlFree(host);
             xmlFree(myurl);
         }
-/*         else if (!strcmp((const char *) n->name, "zproxy")) */
-/*         { */
-/*             xmlChar *port = 0; */
-/*             xmlChar *host = 0; */
-
-/*             port = xmlGetProp(n, (xmlChar *) "port"); */
-/*             host = xmlGetProp(n, (xmlChar *) "host"); */
-
-/*             if (port) */
-/*                 server->zproxy_port = atoi((const char *) port); */
-/*             if (host) */
-/*                 server->zproxy_host = nmem_strdup(nmem, (const char *) host); */
-
-/*             xmlFree(port); */
-/*             xmlFree(host); */
-/*         } */
         else if (!strcmp((const char *) n->name, "settings"))
         {
             if (server->settings)
@@ -527,7 +512,10 @@ static struct conf_server *parse_server(xmlNode *node)
 xsltStylesheet *conf_load_stylesheet(const char *fname)
 {
     char path[256];
-    sprintf(path, "%s/%s", confdir, fname);
+    if (*fname == '/')
+        yaz_snprintf(path, sizeof(path), fname);
+    else
+        yaz_snprintf(path, sizeof(path), "%s/%s", confdir, fname);
     return xsltParseStylesheetFile((xmlChar *) path);
 }
 
@@ -626,6 +614,8 @@ int read_config(const char *fname)
     if ((p = strrchr(fname, '/')))
     {
         int len = p - fname;
+        if (len >= sizeof(confdir))
+            len = sizeof(confdir)-1;
         strncpy(confdir, fname, len);
         confdir[len] = '\0';
     }