New metadata facility "icurule" for normalizing metadata text PAZ-1002
[pazpar2-moved-to-github.git] / src / pazpar2_config.c
index 785293e..e23c740 100644 (file)
@@ -170,7 +170,8 @@ static struct conf_metadata* conf_service_add_metadata(
     enum conf_metadata_mergekey mt,
     const char *facetrule,
     const char *limitmap,
-    const char *limitcluster
+    const char *limitcluster,
+    const char *icurule
     )
 {
     struct conf_metadata * md = 0;
@@ -202,6 +203,7 @@ static struct conf_metadata* conf_service_add_metadata(
     md->facetrule = nmem_strdup_null(nmem, facetrule);
     md->limitmap = nmem_strdup_null(nmem, limitmap);
     md->limitcluster = nmem_strdup_null(nmem, limitcluster);
+    md->icurule = nmem_strdup_null(nmem, icurule);
     return md;
 }
 
@@ -315,6 +317,7 @@ static int parse_metadata(struct conf_service *service, xmlNode *n,
     xmlChar *xml_limitmap = 0;
     xmlChar *xml_limitcluster = 0;
     xmlChar *xml_icu_chain = 0;
+    xmlChar *xml_icurule = 0;
 
     struct _xmlAttr *attr;
 
@@ -358,6 +361,9 @@ static int parse_metadata(struct conf_service *service, xmlNode *n,
         else if (!xmlStrcmp(attr->name, BAD_CAST "limitcluster") &&
                  attr->children && attr->children->type == XML_TEXT_NODE)
             xml_limitcluster = attr->children->content;
+        else if (!xmlStrcmp(attr->name, BAD_CAST "icurule") &&
+                 attr->children && attr->children->type == XML_TEXT_NODE)
+            xml_icurule = attr->children->content;
         else
         {
             yaz_log(YLOG_FATAL, "Unknown metadata attribute '%s'", attr->name);
@@ -515,7 +521,9 @@ static int parse_metadata(struct conf_service *service, xmlNode *n,
                               mergekey_type,
                               (const char *) xml_icu_chain,
                               (const char *) xml_limitmap,
-                              (const char *) xml_limitcluster);
+                              (const char *) xml_limitcluster,
+                              (const char *) xml_icurule
+        );
     (*md_node)++;
     return 0;
 }
@@ -1276,7 +1284,7 @@ static int parse_config(struct conf_config *config, xmlNode *root)
     return 0;
 }
 
-struct conf_config *config_create(const char *fname, int verbose)
+struct conf_config *config_create(const char *fname)
 {
     xmlDoc *doc = xmlReadFile(fname,
                               NULL,
@@ -1330,16 +1338,13 @@ struct conf_config *config_create(const char *fname, int verbose)
     r = yaz_xml_include_simple(n, wrbuf_cstr(config->confdir));
     if (r == 0) /* OK */
     {
-        if (verbose)
-        {
-            yaz_log(YLOG_LOG, "Configuration %s after include processing",
-                    fname);
+        yaz_log(YLOG_LOG, "Configuration %s after include processing",
+                fname);
 #if LIBXML_VERSION >= 20600
-            xmlDocFormatDump(yaz_log_file(), doc, 0);
+        xmlDocFormatDump(yaz_log_file(), doc, 0);
 #else
-            xmlDocDump(yaz_log_file(), doc);
+        xmlDocDump(yaz_log_file(), doc);
 #endif
-        }
         r = parse_config(config, n);
     }
     xmlFreeDoc(doc);