1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2011 Index Data
3 * See the file LICENSE for details.
7 * \brief Implements OPAC record display
17 #include <yaz/proto.h>
18 #include <yaz/marcdisp.h>
20 static void opac_element_str(WRBUF wrbuf, yaz_iconv_t cd1, yaz_iconv_t cd2,
21 int l, const char *elem,
28 wrbuf_puts(wrbuf, " ");
29 wrbuf_puts(wrbuf, "<");
30 wrbuf_puts(wrbuf, elem);
31 wrbuf_puts(wrbuf, ">");
33 pos = wrbuf->pos; /* save position */
34 if (wrbuf_iconv_write_x(wrbuf, cd1, data, strlen(data), 1) && cd2)
36 wrbuf->pos = pos; /* rewind to pos */
37 wrbuf_iconv_write_x(wrbuf, cd2, data, strlen(data), 1);
39 wrbuf_puts(wrbuf, "</");
40 wrbuf_puts(wrbuf, elem);
41 wrbuf_puts(wrbuf, ">\n");
45 static void opac_element_bool(WRBUF wrbuf, int l, const char *elem, int *data)
50 wrbuf_puts(wrbuf, " ");
51 wrbuf_puts(wrbuf, "<");
52 wrbuf_puts(wrbuf, elem);
54 wrbuf_puts(wrbuf, " value=\"1\"");
56 wrbuf_puts(wrbuf, " value=\"0\"");
57 wrbuf_puts(wrbuf, "/>\n");
61 void yaz_opac_decode_wrbuf2(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf,
65 yaz_iconv_t cd1 = yaz_marc_get_iconv(mt);
67 wrbuf_puts(wrbuf, "<opacRecord>\n");
68 if (r->bibliographicRecord)
70 Z_External *ext = r->bibliographicRecord;
72 wrbuf_puts(wrbuf, " <bibliographicRecord>\n");
73 if (ext->which == Z_External_octet)
74 yaz_marc_decode_wrbuf(mt, (const char *) ext->u.octet_aligned->buf,
75 ext->u.octet_aligned->len, wrbuf);
76 wrbuf_puts(wrbuf, " </bibliographicRecord>\n");
78 wrbuf_puts(wrbuf, "<holdings>\n");
80 for (i = 0; i < r->num_holdingsData; i++)
82 Z_HoldingsRecord *h = r->holdingsData[i];
83 wrbuf_puts(wrbuf, " <holding>\n");
85 if (h->which == Z_HoldingsRecord_marcHoldingsRecord)
87 Z_External *ext = h->u.marcHoldingsRecord;
89 wrbuf_puts(wrbuf, " <marcHoldingsRecord>\n");
90 if (ext->which == Z_External_octet)
91 yaz_marc_decode_wrbuf(mt, (const char *)
92 ext->u.octet_aligned->buf,
93 ext->u.octet_aligned->len, wrbuf);
94 wrbuf_puts(wrbuf, " </marcHoldingsRecord>\n");
96 else if (h->which == Z_HoldingsRecord_holdingsAndCirc)
100 Z_HoldingsAndCircData *d = h->u.holdingsAndCirc;
102 opac_element_str(wrbuf, cd1, cd2, 2, "typeOfRecord",
104 opac_element_str(wrbuf, cd1, cd2, 2, "encodingLevel",
106 opac_element_str(wrbuf, cd1, cd2, 2, "format",
108 opac_element_str(wrbuf, cd1, cd2, 2, "receiptAcqStatus",
109 d->receiptAcqStatus);
110 opac_element_str(wrbuf, cd1, cd2, 2, "generalRetention",
111 d->generalRetention);
112 opac_element_str(wrbuf, cd1, cd2, 2, "completeness",
114 opac_element_str(wrbuf, cd1, cd2, 2, "dateOfReport",
116 opac_element_str(wrbuf, cd1, cd2, 2, "nucCode", d->nucCode);
117 opac_element_str(wrbuf, cd1, cd2, 2, "localLocation",
119 opac_element_str(wrbuf, cd1, cd2, 2, "shelvingLocation",
120 d->shelvingLocation);
121 opac_element_str(wrbuf, cd1, cd2, 2, "callNumber",
123 opac_element_str(wrbuf, cd1, cd2, 2, "shelvingData",
125 opac_element_str(wrbuf, cd1, cd2, 2, "copyNumber",
127 opac_element_str(wrbuf, cd1, cd2, 2, "publicNote",
129 opac_element_str(wrbuf, cd1, cd2, 2, "reproductionNote",
130 d->reproductionNote);
131 opac_element_str(wrbuf, cd1, cd2, 2, "termsUseRepro",
133 opac_element_str(wrbuf, cd1, cd2, 2, "enumAndChron",
137 wrbuf_puts (wrbuf, " <volumes>\n");
138 for (j = 0; j<d->num_volumes; j++)
140 wrbuf_puts (wrbuf, " <volume>\n");
141 opac_element_str(wrbuf, cd1, cd2, 4, "enumeration",
142 d->volumes[j]->enumeration);
143 opac_element_str(wrbuf, cd1, cd2, 4, "chronology",
144 d->volumes[j]->chronology);
145 opac_element_str(wrbuf, cd1, cd2, 4, "enumAndChron",
146 d->volumes[j]->enumAndChron);
147 wrbuf_puts(wrbuf, " </volume>\n");
149 wrbuf_puts(wrbuf, " </volumes>\n");
151 if (d->num_circulationData)
153 wrbuf_puts (wrbuf, " <circulations>\n");
154 for (j = 0; j<d->num_circulationData; j++)
156 wrbuf_puts(wrbuf," <circulation>\n");
157 opac_element_bool(wrbuf, 4, "availableNow",
158 d->circulationData[j]->availableNow);
159 opac_element_str(wrbuf, cd1, cd2, 4, "availabiltyDate",
160 d->circulationData[j]->availablityDate);
161 opac_element_str(wrbuf, cd1, cd2, 4, "availableThru",
162 d->circulationData[j]->availableThru);
163 opac_element_str(wrbuf, cd1, cd2, 4, "restrictions",
164 d->circulationData[j]->restrictions);
165 opac_element_str(wrbuf, cd1, cd2, 4, "itemId",
166 d->circulationData[j]->itemId);
167 opac_element_bool(wrbuf, 4, "renewable",
168 d->circulationData[j]->renewable);
169 opac_element_bool(wrbuf, 4, "onHold",
170 d->circulationData[j]->onHold);
171 opac_element_str(wrbuf, cd1, cd2, 4, "enumAndChron",
172 d->circulationData[j]->enumAndChron);
173 opac_element_str(wrbuf, cd1, cd2, 4, "midspine",
174 d->circulationData[j]->midspine);
175 opac_element_str(wrbuf, cd1, cd2, 4, "temporaryLocation",
176 d->circulationData[j]->temporaryLocation);
177 wrbuf_puts(wrbuf, " </circulation>\n");
179 wrbuf_puts(wrbuf, " </circulations>\n");
182 wrbuf_puts(wrbuf, " </holding>\n");
184 wrbuf_puts(wrbuf, "</holdings>\n");
185 wrbuf_puts(wrbuf, "</opacRecord>\n");
188 void yaz_opac_decode_wrbuf(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf)
190 yaz_opac_decode_wrbuf2(mt, r, wrbuf, 0);
196 * c-file-style: "Stroustrup"
197 * indent-tabs-mode: nil
199 * vim: shiftwidth=4 tabstop=8 expandtab