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 cd,
22 int l, const char *elem,
28 wrbuf_puts(wrbuf, " ");
29 wrbuf_puts(wrbuf, "<");
30 wrbuf_puts(wrbuf, elem);
31 wrbuf_puts(wrbuf, ">");
32 wrbuf_iconv_puts_cdata(wrbuf, cd, data);
33 wrbuf_puts(wrbuf, "</");
34 wrbuf_puts(wrbuf, elem);
35 wrbuf_puts(wrbuf, ">\n");
39 static void opac_element_bool(WRBUF wrbuf, int l, const char *elem, int *data)
44 wrbuf_puts(wrbuf, " ");
45 wrbuf_puts(wrbuf, "<");
46 wrbuf_puts(wrbuf, elem);
48 wrbuf_puts(wrbuf, " value=\"1\"");
50 wrbuf_puts(wrbuf, " value=\"0\"");
51 wrbuf_puts(wrbuf, "/>\n");
55 void yaz_opac_decode_wrbuf2(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf,
60 wrbuf_puts(wrbuf, "<opacRecord>\n");
61 if (r->bibliographicRecord)
63 Z_External *ext = r->bibliographicRecord;
65 wrbuf_puts(wrbuf, " <bibliographicRecord>\n");
66 if (ext->which == Z_External_octet)
67 yaz_marc_decode_wrbuf(mt, (const char *) ext->u.octet_aligned->buf,
68 ext->u.octet_aligned->len, wrbuf);
69 wrbuf_puts(wrbuf, " </bibliographicRecord>\n");
71 wrbuf_puts(wrbuf, "<holdings>\n");
73 for (i = 0; i < r->num_holdingsData; i++)
75 Z_HoldingsRecord *h = r->holdingsData[i];
76 wrbuf_puts(wrbuf, " <holding>\n");
78 if (h->which == Z_HoldingsRecord_marcHoldingsRecord)
80 Z_External *ext = h->u.marcHoldingsRecord;
82 wrbuf_puts(wrbuf, " <marcHoldingsRecord>\n");
83 if (ext->which == Z_External_octet)
84 yaz_marc_decode_wrbuf(mt, (const char *)
85 ext->u.octet_aligned->buf,
86 ext->u.octet_aligned->len, wrbuf);
87 wrbuf_puts(wrbuf, " </marcHoldingsRecord>\n");
89 else if (h->which == Z_HoldingsRecord_holdingsAndCirc)
93 Z_HoldingsAndCircData *d = h->u.holdingsAndCirc;
95 opac_element_str(wrbuf, cd, 2, "typeOfRecord", d->typeOfRecord);
96 opac_element_str(wrbuf, cd, 2, "encodingLevel", d->encodingLevel);
97 opac_element_str(wrbuf, cd, 2, "format", d->format);
98 opac_element_str(wrbuf, cd, 2, "receiptAcqStatus", d->receiptAcqStatus);
99 opac_element_str(wrbuf, cd, 2, "generalRetention", d->generalRetention);
100 opac_element_str(wrbuf, cd, 2, "completeness", d->completeness);
101 opac_element_str(wrbuf, cd, 2, "dateOfReport", d->dateOfReport);
102 opac_element_str(wrbuf, cd, 2, "nucCode", d->nucCode);
103 opac_element_str(wrbuf, cd, 2, "localLocation", d->localLocation);
104 opac_element_str(wrbuf, cd, 2, "shelvingLocation", d->shelvingLocation);
105 opac_element_str(wrbuf, cd, 2, "callNumber", d->callNumber);
106 opac_element_str(wrbuf, cd, 2, "shelvingData", d->shelvingData);
108 opac_element_str(wrbuf, cd, 2, "copyNumber", d->copyNumber);
109 opac_element_str(wrbuf, cd, 2, "publicNote", d->publicNote);
110 opac_element_str(wrbuf, cd, 2, "reproductionNote", d->reproductionNote);
111 opac_element_str(wrbuf, cd, 2, "termsUseRepro", d->termsUseRepro);
112 opac_element_str(wrbuf, cd, 2, "enumAndChron", d->enumAndChron);
115 wrbuf_puts (wrbuf, " <volumes>\n");
116 for (j = 0; j<d->num_volumes; j++)
118 wrbuf_puts (wrbuf, " <volume>\n");
119 opac_element_str(wrbuf, cd, 4, "enumeration",
120 d->volumes[j]->enumeration);
121 opac_element_str(wrbuf, cd, 4, "chronology",
122 d->volumes[j]->chronology);
123 opac_element_str(wrbuf, cd, 4, "enumAndChron",
124 d->volumes[j]->enumAndChron);
125 wrbuf_puts(wrbuf, " </volume>\n");
127 wrbuf_puts(wrbuf, " </volumes>\n");
129 if (d->num_circulationData)
131 wrbuf_puts (wrbuf, " <circulations>\n");
132 for (j = 0; j<d->num_circulationData; j++)
134 wrbuf_puts(wrbuf," <circulation>\n");
135 opac_element_bool(wrbuf, 4, "availableNow",
136 d->circulationData[j]->availableNow);
137 opac_element_str(wrbuf, cd, 4, "availabiltyDate",
138 d->circulationData[j]->availablityDate);
139 opac_element_str(wrbuf, cd, 4, "availableThru",
140 d->circulationData[j]->availableThru);
141 opac_element_str(wrbuf, cd, 4, "restrictions",
142 d->circulationData[j]->restrictions);
143 opac_element_str(wrbuf, cd, 4, "itemId",
144 d->circulationData[j]->itemId);
145 opac_element_bool(wrbuf, 4, "renewable",
146 d->circulationData[j]->renewable);
147 opac_element_bool(wrbuf, 4, "onHold",
148 d->circulationData[j]->onHold);
149 opac_element_str(wrbuf, cd, 4, "enumAndChron",
150 d->circulationData[j]->enumAndChron);
151 opac_element_str(wrbuf, cd, 4, "midspine",
152 d->circulationData[j]->midspine);
153 opac_element_str(wrbuf, cd, 4, "temporaryLocation",
154 d->circulationData[j]->temporaryLocation);
155 wrbuf_puts(wrbuf, " </circulation>\n");
157 wrbuf_puts(wrbuf, " </circulations>\n");
160 wrbuf_puts(wrbuf, " </holding>\n");
162 wrbuf_puts(wrbuf, "</holdings>\n");
163 wrbuf_puts(wrbuf, "</opacRecord>\n");
166 void yaz_opac_decode_wrbuf(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf)
168 yaz_opac_decode_wrbuf2(mt, r, wrbuf, yaz_marc_get_iconv(mt));
174 * c-file-style: "Stroustrup"
175 * indent-tabs-mode: nil
177 * vim: shiftwidth=4 tabstop=8 expandtab