projects
/
idzebra-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Read-only sets uses common no write handler
[idzebra-moved-to-github.git]
/
data1
/
d1_marc.c
diff --git
a/data1/d1_marc.c
b/data1/d1_marc.c
index
e9fb614
..
3d61c8a
100644
(file)
--- a/
data1/d1_marc.c
+++ b/
data1/d1_marc.c
@@
-1,5
+1,5
@@
/* This file is part of the Zebra server.
/* This file is part of the Zebra server.
- Copyright (C) 1994-2009 Index Data
+ Copyright (C) 2004-2013 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
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 */
/* converts data1 tree to ISO2709/MARC record */
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
@@
-39,7
+42,7
@@
data1_marctab *data1_read_marctab (data1_handle dh, const char *file)
char line[512], *argv[50];
int lineno = 0;
int argc;
char line[512], *argv[50];
int lineno = 0;
int argc;
-
+
if (!(f = data1_path_fopen(dh, file, "r")))
return 0;
if (!(f = data1_path_fopen(dh, file, "r")))
return 0;
@@
-58,7
+61,7
@@
data1_marctab *data1_read_marctab (data1_handle dh, const char *file)
res->force_indicator_length = -1;
res->force_identifier_length = -1;
strcpy(res->user_systems, "z ");
res->force_indicator_length = -1;
res->force_identifier_length = -1;
strcpy(res->user_systems, "z ");
-
+
while ((argc = readconf_line(f, &lineno, line, 512, argv, 50)))
if (!strcmp(*argv, "name"))
{
while ((argc = readconf_line(f, &lineno, line, 512, argv, 50)))
if (!strcmp(*argv, "name"))
{
@@
-79,7
+82,7
@@
data1_marctab *data1_read_marctab (data1_handle dh, const char *file)
continue;
}
res->oid = yaz_string_to_oid_nmem(yaz_oid_std(),
continue;
}
res->oid = yaz_string_to_oid_nmem(yaz_oid_std(),
- CLASS_TAGSET, argv[1],
+ CLASS_TAGSET, argv[1],
mem);
if (!res->oid)
{
mem);
if (!res->oid)
{
@@
-189,12
+192,12
@@
static void get_data2(data1_node *n, int *len, char *dst, size_t max)
}
*len += n->u.data.len;
}
}
*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;
else
n = n->child;
else if (n->which == DATA1N_data)
n = n->next;
else
- break;
+ break;
}
}
}
}
@@
-257,11
+260,11
@@
static int nodetomarc(data1_handle dh,
continue;
if (selected && !field->u.tag.node_selected)
continue;
continue;
if (selected && !field->u.tag.node_selected)
continue;
-
+
subf = field->child;
if (!subf)
continue;
subf = field->child;
if (!subf)
continue;
-
+
if (!yaz_matchstr(field->u.tag.tag, "mc?"))
continue;
else if (!strcmp(field->u.tag.tag, "leader"))
if (!yaz_matchstr(field->u.tag.tag, "mc?"))
continue;
else if (!strcmp(field->u.tag.tag, "leader"))
@@
-297,13
+300,13
@@
static int nodetomarc(data1_handle dh,
+ p->length_implementation;
if (!control_field)
+ p->length_implementation;
if (!control_field)
- len += p->indicator_length;
+ len += p->indicator_length;
/* we'll allow no indicator if length is not 2 */
/* select when old XML format, since indicator is an element */
if (marc_xml == 0 && is_indicator (p, subf))
subf = subf->child;
/* we'll allow no indicator if length is not 2 */
/* select when old XML format, since indicator is an element */
if (marc_xml == 0 && is_indicator (p, subf))
subf = subf->child;
-
+
for (; subf; subf = subf->next)
{
if (!control_field)
for (; subf; subf = subf->next)
{
if (!control_field)
@@
-321,7
+324,7
@@
static int nodetomarc(data1_handle dh,
*buf = (char *)xmalloc(*size = len);
else if (*size <= len)
*buf = (char *)xrealloc(*buf, *size = len);
*buf = (char *)xmalloc(*size = len);
else if (*size <= len)
*buf = (char *)xrealloc(*buf, *size = len);
-
+
op = *buf;
/* we know the base address now */
op = *buf;
/* we know the base address now */
@@
-330,7
+333,7
@@
static int nodetomarc(data1_handle dh,
/* copy temp leader to real output buf op */
memcpy (op, leader, 24);
memint (op, len, 5);
/* copy temp leader to real output buf op */
memcpy (op, leader, 24);
memint (op, len, 5);
-
+
entry_p = 24;
data_p = base_address;
entry_p = 24;
data_p = base_address;
@@
-355,7
+358,7
@@
static int nodetomarc(data1_handle dh,
subf = field->child;
if (!subf)
continue;
subf = field->child;
if (!subf)
continue;
-
+
if (!yaz_matchstr(field->u.tag.tag, "mc?"))
continue;
else if (!strcmp(field->u.tag.tag, "leader"))
if (!yaz_matchstr(field->u.tag.tag, "mc?"))
continue;
else if (!strcmp(field->u.tag.tag, "leader"))
@@
-416,7
+419,7
@@
static int nodetomarc(data1_handle dh,
if (strcmp(subf->u.tag.tag, "subfield"))
yaz_log(YLOG_WARN, "Unhandled tag %s",
subf->u.tag.tag);
if (strcmp(subf->u.tag.tag, "subfield"))
yaz_log(YLOG_WARN, "Unhandled tag %s",
subf->u.tag.tag);
-
+
for (xa = subf->u.tag.attributes; xa; xa = xa->next)
if (!strcmp(xa->name, "code"))
identifier = xa->value;
for (xa = subf->u.tag.attributes; xa; xa = xa->next)
if (!strcmp(xa->name, "code"))
identifier = xa->value;
@@
-447,7
+450,7
@@
static int nodetomarc(data1_handle dh,
if (!tag || strlen(tag) != 3)
tag = "000";
memcpy (op + entry_p, tag, 3);
if (!tag || strlen(tag) != 3)
tag = "000";
memcpy (op + entry_p, tag, 3);
-
+
entry_p += 3;
memint (op + entry_p, data_p - data_0, p->length_data_entry);
entry_p += p->length_data_entry;
entry_p += 3;
memint (op + entry_p, data_p - data_0, p->length_data_entry);
entry_p += p->length_data_entry;
@@
-477,6
+480,7
@@
char *data1_nodetomarc(data1_handle dh, data1_marctab *p, data1_node *n,
/*
* Local variables:
* c-basic-offset: 4
/*
* Local variables:
* c-basic-offset: 4
+ * c-file-style: "Stroustrup"
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab