2 * Copyright (c) 1995-2002, Index Data.
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
6 * $Id: d1_sumout.c,v 1.1 2002-10-22 12:53:33 adam Exp $
14 #include <yaz/proto.h>
17 static int *f_integer(data1_node *c, ODR o)
22 if (!c->child || c->child->which != DATA1N_data ||
23 c->child->u.data.len > 63)
25 r = (int *)odr_malloc(o, sizeof(*r));
26 sprintf(intbuf, "%.*s", 63, c->child->u.data.data);
31 static char *f_string(data1_node *c, ODR o)
35 if (!c->child || c->child->which != DATA1N_data)
37 r = (char *)odr_malloc(o, c->child->u.data.len+1);
38 memcpy(r, c->child->u.data.data, c->child->u.data.len);
39 r[c->child->u.data.len] = '\0';
43 Z_BriefBib *data1_nodetosummary (data1_handle dh, data1_node *n,
46 Z_BriefBib *res = (Z_BriefBib *)odr_malloc(o, sizeof(*res));
49 assert(n->which == DATA1N_root);
50 if (strcmp(n->u.root.type, "summary"))
52 yaz_log(LOG_WARN, "Attempt to convert a non-summary record");
56 res->title = "[UNKNOWN]";
60 res->bibliographicLevel = 0;
63 res->publicationPlace = 0;
64 res->publicationDate = 0;
65 res->targetSystemKey = 0;
66 res->satisfyingElement = 0;
72 for (c = n->child; c; c = c->next)
74 if (c->which != DATA1N_tag || !c->u.tag.element)
76 yaz_log(LOG_WARN, "Malformed element in Summary record");
79 if (select && !c->u.tag.node_selected)
81 switch (c->u.tag.element->tag->value.numeric)
83 case 0: res->title = f_string(c, o); break;
84 case 1: res->author = f_string(c, o); break;
85 case 2: res->callNumber = f_string(c, o); break;
86 case 3: res->recordType = f_string(c, o); break;
87 case 4: res->bibliographicLevel = f_string(c, o); break;
88 case 5: abort(); /* TODO */
89 case 10: res->publicationPlace = f_string(c, o); break;
90 case 11: res->publicationDate = f_string(c, o); break;
91 case 12: res->targetSystemKey = f_string(c, o); break;
92 case 13: res->satisfyingElement = f_string(c, o); break;
93 case 14: res->rank = f_integer(c, o); break;
94 case 15: res->documentId = f_string(c, o); break;
95 case 16: res->abstract = f_string(c, o); break;
96 case 17: abort(); /* TODO */
98 yaz_log(LOG_WARN, "Unknown element in Summary record.");