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