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
18 #include <yaz/proto.h>
19 #include <yaz/marcdisp.h>
21 static void opac_element_str(WRBUF wrbuf, yaz_iconv_t cd1, yaz_iconv_t cd2,
22 int l, const char *elem,
29 wrbuf_puts(wrbuf, " ");
30 wrbuf_puts(wrbuf, "<");
31 wrbuf_puts(wrbuf, elem);
32 wrbuf_puts(wrbuf, ">");
34 pos = wrbuf->pos; /* save position */
35 if (wrbuf_iconv_write_x(wrbuf, cd1, data, strlen(data), 1) && cd2)
37 wrbuf->pos = pos; /* rewind to pos */
38 wrbuf_iconv_write_x(wrbuf, cd2, data, strlen(data), 1);
40 wrbuf_puts(wrbuf, "</");
41 wrbuf_puts(wrbuf, elem);
42 wrbuf_puts(wrbuf, ">\n");
46 static void opac_element_bool(WRBUF wrbuf, int l, const char *elem, int *data)
51 wrbuf_puts(wrbuf, " ");
52 wrbuf_puts(wrbuf, "<");
53 wrbuf_puts(wrbuf, elem);
55 wrbuf_puts(wrbuf, " value=\"1\"");
57 wrbuf_puts(wrbuf, " value=\"0\"");
58 wrbuf_puts(wrbuf, "/>\n");
62 void yaz_opac_decode_wrbuf2(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf,
66 yaz_iconv_t cd1 = yaz_marc_get_iconv(mt);
68 wrbuf_puts(wrbuf, "<opacRecord>\n");
69 if (r->bibliographicRecord)
71 Z_External *ext = r->bibliographicRecord;
73 wrbuf_puts(wrbuf, " <bibliographicRecord>\n");
74 if (ext->which == Z_External_octet)
75 yaz_marc_decode_wrbuf(mt, (const char *) ext->u.octet_aligned->buf,
76 ext->u.octet_aligned->len, wrbuf);
77 wrbuf_puts(wrbuf, " </bibliographicRecord>\n");
79 wrbuf_puts(wrbuf, "<holdings>\n");
81 for (i = 0; i < r->num_holdingsData; i++)
83 Z_HoldingsRecord *h = r->holdingsData[i];
84 wrbuf_puts(wrbuf, " <holding>\n");
86 if (h->which == Z_HoldingsRecord_marcHoldingsRecord)
88 Z_External *ext = h->u.marcHoldingsRecord;
90 wrbuf_puts(wrbuf, " <marcHoldingsRecord>\n");
91 if (ext->which == Z_External_octet)
92 yaz_marc_decode_wrbuf(mt, (const char *)
93 ext->u.octet_aligned->buf,
94 ext->u.octet_aligned->len, wrbuf);
95 wrbuf_puts(wrbuf, " </marcHoldingsRecord>\n");
97 else if (h->which == Z_HoldingsRecord_holdingsAndCirc)
101 Z_HoldingsAndCircData *d = h->u.holdingsAndCirc;
103 opac_element_str(wrbuf, cd1, cd2, 2, "typeOfRecord",
105 opac_element_str(wrbuf, cd1, cd2, 2, "encodingLevel",
107 opac_element_str(wrbuf, cd1, cd2, 2, "format",
109 opac_element_str(wrbuf, cd1, cd2, 2, "receiptAcqStatus",
110 d->receiptAcqStatus);
111 opac_element_str(wrbuf, cd1, cd2, 2, "generalRetention",
112 d->generalRetention);
113 opac_element_str(wrbuf, cd1, cd2, 2, "completeness",
115 opac_element_str(wrbuf, cd1, cd2, 2, "dateOfReport",
117 opac_element_str(wrbuf, cd1, cd2, 2, "nucCode", d->nucCode);
118 opac_element_str(wrbuf, cd1, cd2, 2, "localLocation",
120 opac_element_str(wrbuf, cd1, cd2, 2, "shelvingLocation",
121 d->shelvingLocation);
122 opac_element_str(wrbuf, cd1, cd2, 2, "callNumber",
124 opac_element_str(wrbuf, cd1, cd2, 2, "shelvingData",
126 opac_element_str(wrbuf, cd1, cd2, 2, "copyNumber",
128 opac_element_str(wrbuf, cd1, cd2, 2, "publicNote",
130 opac_element_str(wrbuf, cd1, cd2, 2, "reproductionNote",
131 d->reproductionNote);
132 opac_element_str(wrbuf, cd1, cd2, 2, "termsUseRepro",
134 opac_element_str(wrbuf, cd1, cd2, 2, "enumAndChron",
138 wrbuf_puts (wrbuf, " <volumes>\n");
139 for (j = 0; j<d->num_volumes; j++)
141 wrbuf_puts (wrbuf, " <volume>\n");
142 opac_element_str(wrbuf, cd1, cd2, 4, "enumeration",
143 d->volumes[j]->enumeration);
144 opac_element_str(wrbuf, cd1, cd2, 4, "chronology",
145 d->volumes[j]->chronology);
146 opac_element_str(wrbuf, cd1, cd2, 4, "enumAndChron",
147 d->volumes[j]->enumAndChron);
148 wrbuf_puts(wrbuf, " </volume>\n");
150 wrbuf_puts(wrbuf, " </volumes>\n");
152 if (d->num_circulationData)
154 wrbuf_puts (wrbuf, " <circulations>\n");
155 for (j = 0; j<d->num_circulationData; j++)
157 wrbuf_puts(wrbuf," <circulation>\n");
158 opac_element_bool(wrbuf, 4, "availableNow",
159 d->circulationData[j]->availableNow);
160 opac_element_str(wrbuf, cd1, cd2, 4, "availabiltyDate",
161 d->circulationData[j]->availablityDate);
162 opac_element_str(wrbuf, cd1, cd2, 4, "availableThru",
163 d->circulationData[j]->availableThru);
164 opac_element_str(wrbuf, cd1, cd2, 4, "restrictions",
165 d->circulationData[j]->restrictions);
166 opac_element_str(wrbuf, cd1, cd2, 4, "itemId",
167 d->circulationData[j]->itemId);
168 opac_element_bool(wrbuf, 4, "renewable",
169 d->circulationData[j]->renewable);
170 opac_element_bool(wrbuf, 4, "onHold",
171 d->circulationData[j]->onHold);
172 opac_element_str(wrbuf, cd1, cd2, 4, "enumAndChron",
173 d->circulationData[j]->enumAndChron);
174 opac_element_str(wrbuf, cd1, cd2, 4, "midspine",
175 d->circulationData[j]->midspine);
176 opac_element_str(wrbuf, cd1, cd2, 4, "temporaryLocation",
177 d->circulationData[j]->temporaryLocation);
178 wrbuf_puts(wrbuf, " </circulation>\n");
180 wrbuf_puts(wrbuf, " </circulations>\n");
183 wrbuf_puts(wrbuf, " </holding>\n");
185 wrbuf_puts(wrbuf, "</holdings>\n");
186 wrbuf_puts(wrbuf, "</opacRecord>\n");
189 void yaz_opac_decode_wrbuf(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf)
191 yaz_opac_decode_wrbuf2(mt, r, wrbuf, 0);
197 * c-file-style: "Stroustrup"
198 * indent-tabs-mode: nil
200 * vim: shiftwidth=4 tabstop=8 expandtab