Start work on ICU based regexp searches
[idzebra-moved-to-github.git] / data1 / d1_marc.c
index 8cd728b..a332b2a 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of the Zebra server.
-   Copyright (C) 1995-2008 Index Data
+   Copyright (C) 1994-2011 Index Data
 
 Zebra 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
@@ -19,6 +19,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 /* converts data1 tree to ISO2709/MARC record */
 
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
@@ -148,6 +151,21 @@ data1_marctab *data1_read_marctab (data1_handle dh, const char *file)
            }
            res->force_identifier_length = atoi(argv[1]);
        }
+       else if (!strcmp(*argv, "implementation-codes"))
+       {
+           if (argc != 2)
+           {
+               yaz_log(YLOG_WARN, "%s:%d: Missing arg for %s", file, lineno,
+                       *argv);
+               continue;
+           }
+            /* up to 4 characters .. space pad */
+            if (strlen(argv[1]) > 4)
+               yaz_log(YLOG_WARN, "%s:%d: Max 4 characters for "
+                                   "implementation-codes", file, lineno);
+            else
+                memcpy(res->implementation_codes, argv[1], strlen(argv[1]));
+       }
        else
            yaz_log(YLOG_WARN, "%s:%d: Unknown directive '%s'", file, lineno,
                    *argv);
@@ -174,7 +192,7 @@ static void get_data2(data1_node *n, int *len, char *dst, size_t max)
             }
             *len += n->u.data.len;
         }
-        if (n->which == DATA1N_tag)
+        if (n->which == DATA1N_tag && *len == 0)
             n = n->child;
        else if (n->which == DATA1N_data)
             n = n->next;
@@ -462,6 +480,7 @@ char *data1_nodetomarc(data1_handle dh, data1_marctab *p, data1_node *n,
 /*
  * Local variables:
  * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
  * indent-tabs-mode: nil
  * End:
  * vim: shiftwidth=4 tabstop=8 expandtab