2 * Copyright (c) 1995-1999, Index Data.
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
6 * $Log: d1_sumout.c,v $
7 * Revision 1.4 1999-08-27 09:40:32 adam
8 * Renamed logf function to yaz_log. Removed VC++ project files.
10 * Revision 1.3 1998/02/11 11:53:35 adam
11 * Changed code so that it compiles as C++.
13 * Revision 1.2 1997/09/17 12:10:38 adam
16 * Revision 1.1 1996/06/10 08:56:03 quinn
30 static int *f_integer(data1_node *c, ODR o)
35 if (!c->child || c->child->which != DATA1N_data ||
36 c->child->u.data.len > 63)
38 r = (int *)odr_malloc(o, sizeof(*r));
39 sprintf(intbuf, "%.*s", 63, c->child->u.data.data);
44 static char *f_string(data1_node *c, ODR o)
48 if (!c->child || c->child->which != DATA1N_data)
50 r = (char *)odr_malloc(o, c->child->u.data.len+1);
51 memcpy(r, c->child->u.data.data, c->child->u.data.len);
52 r[c->child->u.data.len] = '\0';
56 Z_BriefBib *data1_nodetosummary (data1_handle dh, data1_node *n,
59 Z_BriefBib *res = (Z_BriefBib *)odr_malloc(o, sizeof(*res));
62 assert(n->which == DATA1N_root);
63 if (strcmp(n->u.root.type, "summary"))
65 yaz_log(LOG_WARN, "Attempt to convert a non-summary record");
69 res->title = "[UNKNOWN]";
73 res->bibliographicLevel = 0;
76 res->publicationPlace = 0;
77 res->publicationDate = 0;
78 res->targetSystemKey = 0;
79 res->satisfyingElement = 0;
85 for (c = n->child; c; c = c->next)
87 if (c->which != DATA1N_tag || !c->u.tag.element)
89 yaz_log(LOG_WARN, "Malformed element in Summary record");
92 if (select && !c->u.tag.node_selected)
94 switch (c->u.tag.element->tag->value.numeric)
96 case 0: res->title = f_string(c, o); break;
97 case 1: res->author = f_string(c, o); break;
98 case 2: res->callNumber = f_string(c, o); break;
99 case 3: res->recordType = f_string(c, o); break;
100 case 4: res->bibliographicLevel = f_string(c, o); break;
101 case 5: abort(); /* TODO */
102 case 10: res->publicationPlace = f_string(c, o); break;
103 case 11: res->publicationDate = f_string(c, o); break;
104 case 12: res->targetSystemKey = f_string(c, o); break;
105 case 13: res->satisfyingElement = f_string(c, o); break;
106 case 14: res->rank = f_integer(c, o); break;
107 case 15: res->documentId = f_string(c, o); break;
108 case 16: res->abstract = f_string(c, o); break;
109 case 17: abort(); /* TODO */
111 yaz_log(LOG_WARN, "Unknown element in Summary record.");