YAZ 5.38.1
marcdisp.h
Go to the documentation of this file.
1/* This file is part of the YAZ toolkit.
2 * Copyright (C) Index Data.
3 * All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of Index Data nor the names of its contributors
13 * may be used to endorse or promote products derived from this
14 * software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
32
33#ifndef MARCDISP_H
34#define MARCDISP_H
35
36#include <yaz/yconfig.h>
37#include <stdio.h>
38#include <yaz/wrbuf.h>
39
40#include <yaz/nmem.h>
41#include <yaz/xmltypes.h>
42#include <yaz/z-opac.h>
43#include <yaz/atoi.h>
44
46
48typedef struct yaz_marc_t_ *yaz_marc_t;
49
51YAZ_EXPORT yaz_marc_t yaz_marc_create(void);
52
54YAZ_EXPORT void yaz_marc_destroy(yaz_marc_t mt);
55
62YAZ_EXPORT void yaz_marc_xml(yaz_marc_t mt, int xmlmode);
63
65#define YAZ_MARC_LINE 0
67#define YAZ_MARC_SIMPLEXML 1
69#define YAZ_MARC_OAIMARC 2
71#define YAZ_MARC_MARCXML 3
73#define YAZ_MARC_ISO2709 4
75#define YAZ_MARC_XCHANGE 5
77#define YAZ_MARC_CHECK 6
79#define YAZ_MARC_TURBOMARC 7
81#define YAZ_MARC_JSON 8
82
84YAZ_EXPORT void yaz_marc_iconv(yaz_marc_t mt, yaz_iconv_t cd);
85
88
93YAZ_EXPORT void yaz_marc_debug(yaz_marc_t mt, int level);
94
106YAZ_EXPORT int yaz_marc_decode_buf(yaz_marc_t mt, const char *buf, int bsize,
107 const char **result, size_t *rsize);
108
119YAZ_EXPORT int yaz_marc_decode_wrbuf(yaz_marc_t mt, const char *buf,
120 int bsize, WRBUF wrbuf);
121
122YAZ_EXPORT void yaz_marc_subfield_str(yaz_marc_t mt, const char *s);
123YAZ_EXPORT void yaz_marc_endline_str(yaz_marc_t mt, const char *s);
124
126YAZ_EXPORT void yaz_marc_modify_leader(yaz_marc_t mt, size_t off,
127 const char *str);
128
130#define ISO2709_RS 035
132#define ISO2709_FS 036
134#define ISO2709_IDFS 037
135
145YAZ_EXPORT int yaz_marc_read_iso2709(yaz_marc_t mt,
146 const char *buf, int bsize);
147
159YAZ_EXPORT
161 int (*getbyte)(void *client_data),
162 void (*ungetbyte)(int b, void *client_data),
163 void *client_data);
164
165#if YAZ_HAVE_XML2
172YAZ_EXPORT int yaz_marc_read_xml(yaz_marc_t mt, const xmlNode *ptr);
173#endif
174
181YAZ_EXPORT int yaz_marc_write_line(yaz_marc_t mt, WRBUF wrbuf);
182
191YAZ_EXPORT int yaz_marc_write_marcxml(yaz_marc_t mt, WRBUF wrbuf);
192
200
210 const char *format,
211 const char *type);
212
219YAZ_EXPORT int yaz_marc_write_iso2709(yaz_marc_t mt, WRBUF wrbuf);
220
230YAZ_EXPORT int yaz_marc_write_mode(yaz_marc_t mt, WRBUF wrbuf);
231
232#if YAZ_HAVE_XML2
242YAZ_EXPORT
243int yaz_marc_write_xml(yaz_marc_t mt, xmlNode **root_ptr,
244 const char *ns,
245 const char *format,
246 const char *type);
247#endif
248
255YAZ_EXPORT
257
269YAZ_EXPORT int yaz_marc_leader_spec(yaz_marc_t mt, const char *leader_spec);
270
271
282YAZ_EXPORT
283void yaz_marc_set_leader(yaz_marc_t mt, const char *leader,
284 int *indicator_length,
285 int *identifier_length,
286 int *base_address,
287 int *length_data_entry,
288 int *length_starting,
289 int *length_implementation);
290
291
296YAZ_EXPORT
297void yaz_marc_add_comment(yaz_marc_t mt, char *comment);
298
303YAZ_EXPORT
304void yaz_marc_cprintf(yaz_marc_t mt, const char *fmt, ...);
305
311YAZ_EXPORT
313 const char *code_data, size_t code_data_len);
314
315
322YAZ_EXPORT
323void yaz_marc_add_controlfield(yaz_marc_t mt, const char *tag,
324 const char *data, size_t data_len);
325
326
327#if YAZ_HAVE_XML2
333YAZ_EXPORT
334void yaz_marc_add_controlfield_xml(yaz_marc_t mt, const xmlNode *ptr_tag,
335 const xmlNode *ptr_data);
336
342YAZ_EXPORT
344 const xmlNode *ptr_data);
345#endif
346
353YAZ_EXPORT
354void yaz_marc_add_datafield(yaz_marc_t mt, const char *tag,
355 const char *indicator, size_t indicator_len);
356
357#if YAZ_HAVE_XML2
364YAZ_EXPORT
365void yaz_marc_add_datafield_xml(yaz_marc_t mt, const xmlNode *ptr_tag,
366 const char *indicator, size_t indicator_len);
367
373YAZ_EXPORT
374void yaz_marc_add_datafield_xml2(yaz_marc_t mt, char *tag_value,
375 char *indicators);
376
377#endif
378
383YAZ_EXPORT
385
389YAZ_EXPORT
391
395YAZ_EXPORT
397
403YAZ_EXPORT
404int yaz_marc_decode_formatstr(const char *arg);
405
410YAZ_EXPORT
411void yaz_marc_write_using_libxml2(yaz_marc_t mt, int enable);
412
421YAZ_EXPORT void yaz_opac_decode_wrbuf(yaz_marc_t mt, Z_OPACRecord *r,
422 WRBUF wrbuf);
423
433YAZ_EXPORT void yaz_opac_decode_wrbuf2(yaz_marc_t mt, Z_OPACRecord *r,
435
436#if YAZ_HAVE_XML2
448YAZ_EXPORT int yaz_xml_to_opac(yaz_marc_t mt,
449 const char *buf_in, size_t size_in,
450 Z_OPACRecord **dst, yaz_iconv_t cd,
451 NMEM nmem, const Odr_oid *syntax);
452#endif
453
460YAZ_EXPORT int yaz_marc_write_trailer(yaz_marc_t mt, WRBUF wr);
461
465YAZ_EXPORT void yaz_marc_enable_collection(yaz_marc_t mt);
466
467struct json_node;
468
469YAZ_EXPORT int yaz_marc_read_json_node(yaz_marc_t mt, struct json_node *n);
470
478YAZ_EXPORT
479int yaz_marc_check_marc21_coding(const char *charset,
480 const char *marc_buf, int sz);
481
482YAZ_EXPORT
483int yaz_opac_check_marc21_coding(const char *charset, Z_OPACRecord *r);
484
485
486size_t yaz_marc_sizeof_char(yaz_marc_t mt, const char *buf);
487
489
490#endif
491/*
492 * Local variables:
493 * c-basic-offset: 4
494 * c-file-style: "Stroustrup"
495 * indent-tabs-mode: nil
496 * End:
497 * vim: shiftwidth=4 tabstop=8 expandtab
498 */
499
ASCII to integer conversion.
int yaz_marc_read_iso2709(yaz_marc_t mt, const char *buf, int bsize)
read ISO2709/MARC record from buffer
int yaz_marc_read_json_node(yaz_marc_t mt, struct json_node *n)
int yaz_marc_read_line(yaz_marc_t mt, int(*getbyte)(void *client_data), void(*ungetbyte)(int b, void *client_data), void *client_data)
read MARC lineformat from stream
int yaz_marc_read_xml(yaz_marc_t mt, const xmlNode *ptr)
parses MARCXML/MarcXchange/TurboMARC record from xmlNode pointer
int yaz_marc_leader_spec(yaz_marc_t mt, const char *leader_spec)
sets leader spec (for modifying bytes in 24 byte leader)
Definition marcdisp.c:1410
int yaz_marc_write_iso2709(yaz_marc_t mt, WRBUF wr)
writes record in ISO2709 format
Definition marcdisp.c:1119
void yaz_marc_add_controlfield_xml(yaz_marc_t mt, const xmlNode *ptr_tag, const xmlNode *ptr_data)
adds controlfield to MARC structure using xml Nodes
Definition marcdisp.c:160
void yaz_marc_cprintf(yaz_marc_t mt, const char *fmt,...)
adds MARC annotation - printf interface
Definition marcdisp.c:188
int yaz_marc_check_marc21_coding(const char *charset, const char *marc_buf, int sz)
check if MARC21 is UTF-8 encoded
Definition marcdisp.c:1490
yaz_marc_t yaz_marc_create(void)
construct yaz_marc_t handle
Definition marcdisp.c:102
int yaz_marc_write_line(yaz_marc_t mt, WRBUF wr)
writes record in line format
Definition marcdisp.c:537
size_t yaz_marc_sizeof_char(yaz_marc_t mt, const char *buf)
Definition marcdisp.c:478
void yaz_marc_iconv(yaz_marc_t mt, yaz_iconv_t cd)
set iconv handle for character set conversion
Definition marcdisp.c:1387
void yaz_marc_xml(yaz_marc_t mt, int xmlmode)
set XML mode YAZ_MARC_LINE, YAZ_MARCXML, YAZ_MARC_ISO2709 ..
Definition marcdisp.c:1376
void yaz_marc_add_subfield(yaz_marc_t mt, const char *code_data, size_t code_data_len)
adds subfield to MARC structure
Definition marcdisp.c:316
void yaz_marc_add_datafield_xml(yaz_marc_t mt, const xmlNode *ptr_tag, const char *indicator, size_t indicator_len)
adds datafield to MARC structure using xml Nodes
Definition marcdisp.c:284
void yaz_marc_write_using_libxml2(yaz_marc_t mt, int enable)
Enables or disables writing of MARC XML records using Libxml2.
Definition marcdisp.c:1485
NMEM yaz_marc_get_nmem(yaz_marc_t mt)
returns memory for MARC handle
Definition marcdisp.c:130
void yaz_marc_endline_str(yaz_marc_t mt, const char *s)
Definition marcdisp.c:438
int yaz_marc_get_debug(yaz_marc_t mt)
gets debug level for MARC system
Definition marcdisp.c:199
int yaz_marc_write_turbomarc(yaz_marc_t mt, WRBUF wr)
writes record in TurboMARC format
Definition marcdisp.c:861
void yaz_marc_add_datafield(yaz_marc_t mt, const char *tag, const char *indicator, size_t indicator_len)
adds datafield to MARC structure using strings
Definition marcdisp.c:233
void yaz_marc_add_datafield_xml2(yaz_marc_t mt, char *tag_value, char *indicators)
adds datafield to MARC structure using xml Nodes
Definition marcdisp.c:297
void yaz_marc_modify_leader(yaz_marc_t mt, size_t off, const char *str)
modifies part of the MARC leader
Definition marcdisp.c:1397
int yaz_marc_write_xml(yaz_marc_t mt, xmlNode **root_ptr, const char *ns, const char *format, const char *type)
writes MARC record as libxml2 tree
Definition marcdisp.c:1025
int yaz_marc_decode_formatstr(const char *arg)
Converts MARC format type to format type(YAZ_MARC_..).
Definition marcdisp.c:1467
int yaz_marc_write_marcxml(yaz_marc_t mt, WRBUF wr)
writes record in MARCXML format
Definition marcdisp.c:850
void yaz_marc_subfield_str(yaz_marc_t mt, const char *s)
Definition marcdisp.c:432
yaz_iconv_t yaz_marc_get_iconv(yaz_marc_t mt)
supply iconv handle for character set conversion
Definition marcdisp.c:1392
void yaz_marc_destroy(yaz_marc_t mt)
destroy yaz_marc_t handle
Definition marcdisp.c:120
void yaz_marc_set_leader(yaz_marc_t mt, const char *leader_c, int *indicator_length, int *identifier_length, int *base_address, int *length_data_entry, int *length_starting, int *length_implementation)
sets leader, validates it, and returns important values
Definition marcdisp.c:356
void yaz_marc_add_controlfield_xml2(yaz_marc_t mt, char *tag, const xmlNode *ptr_data)
adds controlfield to MARC structure using xml Nodes for data
Definition marcdisp.c:169
int yaz_marc_write_mode(yaz_marc_t mt, WRBUF wr)
writes record in mode - given by yaz_marc_xml mode
Definition marcdisp.c:623
void yaz_marc_add_controlfield(yaz_marc_t mt, const char *tag, const char *data, size_t data_len)
adds controlfield to MARC structure
Definition marcdisp.c:212
void yaz_marc_add_comment(yaz_marc_t mt, char *comment)
adds MARC comment string
Definition marcdisp.c:181
void yaz_marc_reset(yaz_marc_t mt)
clears memory and MARC record
Definition marcdisp.c:483
int yaz_marc_write_marcxchange(yaz_marc_t mt, WRBUF wr, const char *format, const char *type)
writes record in MarcXchange XML (ISO25577)
Definition marcdisp.c:871
int yaz_marc_write_json(yaz_marc_t mt, WRBUF w)
writes MARC record in JSON represenation
Definition marcdisp.c:1257
void yaz_marc_enable_collection(yaz_marc_t mt)
enables record collection output
Definition marcdisp.c:618
int yaz_marc_write_trailer(yaz_marc_t mt, WRBUF wr)
flushes records
Definition marcdisp.c:600
int yaz_marc_decode_buf(yaz_marc_t mt, const char *buf, int bsize, const char **result, size_t *rsize)
decodes ISO2709 buffer using straight buffers
Definition marcdisp.c:1362
void yaz_marc_debug(yaz_marc_t mt, int level)
set debug level
Definition marcdisp.c:1381
int yaz_marc_decode_wrbuf(yaz_marc_t mt, const char *buf, int bsize, WRBUF wr)
decodes ISO2709/MARC buffer and stores result in WRBUF
Definition marcdisp.c:1351
struct yaz_marc_t_ * yaz_marc_t
a yaz_marc_t handle (private content)
Definition marcdisp.h:48
Header for Nibble Memory functions.
struct nmem_control * NMEM
NMEM handle (an opaque pointer to memory).
Definition nmem.h:44
short Odr_oid
Definition oid_util.h:42
int yaz_opac_check_marc21_coding(const char *charset, Z_OPACRecord *r)
void yaz_opac_decode_wrbuf(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf)
Performs "pretty" display of OPAC record to WRBUF using marc_t.
void yaz_opac_decode_wrbuf2(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf, yaz_iconv_t cd2)
Performs "pretty" display of OPAC record to WRBUF using marc_t.
Definition opac_to_xml.c:62
JSON node.
Definition json.h:53
string buffer
Definition wrbuf.h:43
the internals of a yaz_marc_t handle
Definition marcdisp.c:86
NMEM nmem
Definition marcdisp.c:88
char * leader_spec
Definition marcdisp.c:96
Header for WRBUF (growing buffer).
struct wrbuf * WRBUF
int yaz_xml_to_opac(yaz_marc_t mt, const char *buf_in, size_t size_in, Z_OPACRecord **dst, yaz_iconv_t cd, NMEM nmem, const Odr_oid *syntax)
Converts XML to OPAC.
Define xmlNode and xmlDocPtr if Libxml2 is present.
struct yaz_iconv_struct * yaz_iconv_t
yaz_iconv handle (similar to iconv_t)
Definition yaz-iconv.h:42
Header with fundamental macros.
#define YAZ_BEGIN_CDECL
Definition yconfig.h:56
#define YAZ_END_CDECL
Definition yconfig.h:57
ASN.1 Module RecordSyntax-opac.