YAZ
5.34.0
|
MARC conversion. More...
#include <yaz/yconfig.h>
#include <stdio.h>
#include <yaz/wrbuf.h>
#include <yaz/nmem.h>
#include <yaz/xmltypes.h>
#include <yaz/z-opac.h>
Go to the source code of this file.
Macros | |
#define | YAZ_MARC_LINE 0 |
Output format: Line-format. More... | |
#define | YAZ_MARC_SIMPLEXML 1 |
Output format: simplexml (no longer supported) More... | |
#define | YAZ_MARC_OAIMARC 2 |
Output format: OAI-MARC (no longer supported) More... | |
#define | YAZ_MARC_MARCXML 3 |
Output format: MARCXML. More... | |
#define | YAZ_MARC_ISO2709 4 |
Output format: ISO2709. More... | |
#define | YAZ_MARC_XCHANGE 5 |
Output format: MarcXchange (ISO25577) More... | |
#define | YAZ_MARC_CHECK 6 |
Output format: check only (no marc output) More... | |
#define | YAZ_MARC_TURBOMARC 7 |
Output format: Turbo MARC Index Data format (XML based) More... | |
#define | YAZ_MARC_JSON 8 |
Output format: JSON. More... | |
#define | ISO2709_RS 035 |
MARC control char: record separator (29 Dec, 1D Hex) More... | |
#define | ISO2709_FS 036 |
MARC control char: field separator (30 Dec, 1E Hex) More... | |
#define | ISO2709_IDFS 037 |
MARC control char: identifier-field separator (31 Dec, 1F Hex) More... | |
Typedefs | |
typedef struct yaz_marc_t_ * | yaz_marc_t |
a yaz_marc_t handle (private content) More... | |
Functions | |
yaz_marc_t | yaz_marc_create (void) |
construct yaz_marc_t handle More... | |
void | yaz_marc_destroy (yaz_marc_t mt) |
destroy yaz_marc_t handle More... | |
void | yaz_marc_xml (yaz_marc_t mt, int xmlmode) |
set XML mode YAZ_MARC_LINE, YAZ_MARCXML, YAZ_MARC_ISO2709 .. More... | |
void | yaz_marc_iconv (yaz_marc_t mt, yaz_iconv_t cd) |
set iconv handle for character set conversion More... | |
yaz_iconv_t | yaz_marc_get_iconv (yaz_marc_t mt) |
supply iconv handle for character set conversion More... | |
void | yaz_marc_debug (yaz_marc_t mt, int level) |
set debug level More... | |
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 More... | |
int | yaz_marc_decode_wrbuf (yaz_marc_t mt, const char *buf, int bsize, WRBUF wrbuf) |
decodes ISO2709/MARC buffer and stores result in WRBUF More... | |
void | yaz_marc_subfield_str (yaz_marc_t mt, const char *s) |
void | yaz_marc_endline_str (yaz_marc_t mt, const char *s) |
void | yaz_marc_modify_leader (yaz_marc_t mt, size_t off, const char *str) |
modifies part of the MARC leader More... | |
int | atoi_n (const char *buf, int len) |
like atoi(3) except that it reads exactly len characters More... | |
int | atoi_n_check (const char *buf, int size, int *val) |
like atoi_n but checks for proper formatting More... | |
int | yaz_marc_read_iso2709 (yaz_marc_t mt, const char *buf, int bsize) |
read ISO2709/MARC record from buffer More... | |
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 More... | |
int | yaz_marc_read_xml (yaz_marc_t mt, const xmlNode *ptr) |
parses MARCXML/MarcXchange/TurboMARC record from xmlNode pointer More... | |
int | yaz_marc_write_line (yaz_marc_t mt, WRBUF wrbuf) |
writes record in line format More... | |
int | yaz_marc_write_marcxml (yaz_marc_t mt, WRBUF wrbuf) |
writes record in MARCXML format More... | |
int | yaz_marc_write_turbomarc (yaz_marc_t mt, WRBUF wrbuf) |
writes record in TurboMARC format More... | |
int | yaz_marc_write_marcxchange (yaz_marc_t mt, WRBUF wrbuf, const char *format, const char *type) |
writes record in MarcXchange XML (ISO25577) More... | |
int | yaz_marc_write_iso2709 (yaz_marc_t mt, WRBUF wrbuf) |
writes record in ISO2709 format More... | |
int | yaz_marc_write_mode (yaz_marc_t mt, WRBUF wrbuf) |
writes record in mode - given by yaz_marc_xml mode More... | |
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 More... | |
int | yaz_marc_write_json (yaz_marc_t mt, WRBUF w) |
writes MARC record in JSON represenation More... | |
int | yaz_marc_leader_spec (yaz_marc_t mt, const char *leader_spec) |
sets leader spec (for modifying bytes in 24 byte leader) More... | |
void | yaz_marc_set_leader (yaz_marc_t mt, const char *leader, 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 More... | |
void | yaz_marc_add_comment (yaz_marc_t mt, char *comment) |
adds MARC comment string More... | |
void | yaz_marc_cprintf (yaz_marc_t mt, const char *fmt,...) |
adds MARC annotation - printf interface More... | |
void | yaz_marc_add_subfield (yaz_marc_t mt, const char *code_data, size_t code_data_len) |
adds subfield to MARC structure More... | |
void | yaz_marc_add_controlfield (yaz_marc_t mt, const char *tag, const char *data, size_t data_len) |
adds controlfield to MARC structure More... | |
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 More... | |
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 More... | |
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 More... | |
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 More... | |
void | yaz_marc_add_datafield_xml2 (yaz_marc_t mt, char *tag_value, char *indicators) |
adds datafield to MARC structure using xml Nodes More... | |
NMEM | yaz_marc_get_nmem (yaz_marc_t mt) |
returns memory for MARC handle More... | |
void | yaz_marc_reset (yaz_marc_t mt) |
clears memory and MARC record More... | |
int | yaz_marc_get_debug (yaz_marc_t mt) |
gets debug level for MARC system More... | |
int | yaz_marc_decode_formatstr (const char *arg) |
Converts MARC format type to format type(YAZ_MARC_..) More... | |
void | yaz_marc_write_using_libxml2 (yaz_marc_t mt, int enable) |
Enables or disables writing of MARC XML records using Libxml2. More... | |
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. More... | |
void | yaz_opac_decode_wrbuf2 (yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf, yaz_iconv_t cd) |
Performs "pretty" display of OPAC record to WRBUF using marc_t. More... | |
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. More... | |
int | yaz_marc_write_trailer (yaz_marc_t mt, WRBUF wr) |
flushes records More... | |
void | yaz_marc_enable_collection (yaz_marc_t mt) |
enables record collection output More... | |
int | yaz_marc_read_json_node (yaz_marc_t mt, struct json_node *n) |
int | yaz_marc_check_marc21_coding (const char *charset, const char *marc_buf, int sz) |
check if MARC21 is UTF-8 encoded More... | |
int | yaz_opac_check_marc21_coding (const char *charset, Z_OPACRecord *r) |
size_t | yaz_marc_sizeof_char (yaz_marc_t mt, const char *buf) |
MARC conversion.
Definition in file marcdisp.h.
#define ISO2709_FS 036 |
MARC control char: field separator (30 Dec, 1E Hex)
Definition at line 148 of file marcdisp.h.
#define ISO2709_IDFS 037 |
MARC control char: identifier-field separator (31 Dec, 1F Hex)
Definition at line 150 of file marcdisp.h.
#define ISO2709_RS 035 |
MARC control char: record separator (29 Dec, 1D Hex)
Definition at line 146 of file marcdisp.h.
#define YAZ_MARC_CHECK 6 |
Output format: check only (no marc output)
Definition at line 76 of file marcdisp.h.
#define YAZ_MARC_ISO2709 4 |
Output format: ISO2709.
Definition at line 72 of file marcdisp.h.
#define YAZ_MARC_JSON 8 |
Output format: JSON.
Definition at line 80 of file marcdisp.h.
#define YAZ_MARC_LINE 0 |
Output format: Line-format.
Definition at line 64 of file marcdisp.h.
#define YAZ_MARC_MARCXML 3 |
Output format: MARCXML.
Definition at line 70 of file marcdisp.h.
#define YAZ_MARC_OAIMARC 2 |
Output format: OAI-MARC (no longer supported)
Definition at line 68 of file marcdisp.h.
#define YAZ_MARC_SIMPLEXML 1 |
Output format: simplexml (no longer supported)
Definition at line 66 of file marcdisp.h.
#define YAZ_MARC_TURBOMARC 7 |
Output format: Turbo MARC Index Data format (XML based)
Definition at line 78 of file marcdisp.h.
#define YAZ_MARC_XCHANGE 5 |
Output format: MarcXchange (ISO25577)
Definition at line 74 of file marcdisp.h.
typedef struct yaz_marc_t_* yaz_marc_t |
a yaz_marc_t handle (private content)
Definition at line 47 of file marcdisp.h.
int atoi_n | ( | const char * | buf, |
int | len | ||
) |
like atoi(3) except that it reads exactly len characters
buf | buffer to read |
len | number of bytes to consider (being digits) |
Definition at line 19 of file atoin.c.
References yaz_isdigit.
Referenced by atoi_n_check(), and yaz_marc_read_iso2709().
int atoi_n_check | ( | const char * | buf, |
int | size, | ||
int * | val | ||
) |
like atoi_n but checks for proper formatting
buf | buffer to read values from |
size | size of buffer |
val | value of decimal number (if successful) |
0 | no value found (non-digits found) |
1 | value found and *val holds value |
Definition at line 32 of file atoin.c.
References atoi_n(), and yaz_isdigit.
Referenced by convert_solrmarc(), replace_node(), yaz_marc_read_iso2709(), yaz_marc_read_line(), yaz_marc_set_leader(), yaz_marc_write_check(), yaz_marc_write_iso2709(), yaz_marc_write_json(), yaz_marc_write_line(), yaz_marc_write_marcxml_wrbuf(), yaz_marc_write_xml(), and yaz_marc_write_xml_turbo_xml().
void yaz_marc_add_comment | ( | yaz_marc_t | mt, |
char * | comment | ||
) |
adds MARC comment string
mt | handle |
comment | comment to be added) |
Definition at line 181 of file marcdisp.c.
References yaz_marc_node::comment, yaz_marc_t_::nmem, nmem_strdup(), yaz_marc_node::u, yaz_marc_node::which, yaz_marc_add_node(), and YAZ_MARC_COMMENT.
Referenced by yaz_marc_add_controlfield(), yaz_marc_add_subfield(), and yaz_marc_cprintf().
void yaz_marc_add_controlfield | ( | yaz_marc_t | mt, |
const char * | tag, | ||
const char * | data, | ||
size_t | data_len | ||
) |
adds controlfield to MARC structure
mt | handle |
tag | (e.g. "001" |
data | value for this tag |
data_len | length of data |
Definition at line 212 of file marcdisp.c.
References yaz_marc_node::controlfield, yaz_marc_controlfield::data, yaz_marc_t_::debug, yaz_marc_t_::nmem, nmem_strdup(), nmem_strdupn(), yaz_marc_controlfield::tag, yaz_marc_node::u, yaz_marc_node::which, yaz_marc_add_comment(), yaz_marc_add_node(), and YAZ_MARC_CONTROLFIELD.
Referenced by parse_field(), yaz_end_element_ns(), yaz_marc_read_iso2709(), and yaz_marc_read_line().
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
mt | handle |
ptr_tag | value of tag (TEXT xmlNode) |
ptr_data | value of data (TEXT xmlNode) |
Definition at line 160 of file marcdisp.c.
References yaz_marc_node::controlfield, yaz_marc_controlfield::data, yaz_marc_t_::nmem, nmem_text_node_cdata(), yaz_marc_controlfield::tag, yaz_marc_node::u, yaz_marc_node::which, yaz_marc_add_node(), and YAZ_MARC_CONTROLFIELD.
Referenced by yaz_marc_read_xml_fields().
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
mt | handle |
tag | string tag |
ptr_data | value of data (TEXT xmlNode) |
Definition at line 169 of file marcdisp.c.
References yaz_marc_node::controlfield, yaz_marc_controlfield::data, yaz_marc_t_::nmem, nmem_text_node_cdata(), yaz_marc_controlfield::tag, yaz_marc_node::u, yaz_marc_node::which, yaz_marc_add_node(), and YAZ_MARC_CONTROLFIELD.
Referenced by yaz_marc_read_turbo_xml_fields().
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
mt | handle |
tag | value of tag as string |
indicator | indicator string |
indicator_len | length of indicator string |
Definition at line 233 of file marcdisp.c.
References yaz_marc_node::datafield, yaz_marc_datafield::indicator, yaz_marc_t_::nmem, nmem_strdup(), nmem_strdupn(), yaz_marc_t_::subfield_pp, yaz_marc_datafield::subfields, yaz_marc_datafield::tag, yaz_marc_node::u, yaz_marc_node::which, yaz_marc_add_node(), and YAZ_MARC_DATAFIELD.
Referenced by parse_field(), yaz_marc_read_iso2709(), yaz_marc_read_line(), and yaz_start_element_ns().
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
mt | handle |
ptr_tag | value of tag (TEXT xmlNode) |
indicator | indicator string |
indicator_len | length of indicator string |
Definition at line 284 of file marcdisp.c.
References yaz_marc_node::datafield, yaz_marc_datafield::indicator, yaz_marc_t_::nmem, nmem_strdup(), nmem_text_node_cdata(), yaz_marc_t_::subfield_pp, yaz_marc_datafield::subfields, yaz_marc_datafield::tag, yaz_marc_node::u, yaz_marc_node::which, yaz_marc_add_node(), and YAZ_MARC_DATAFIELD.
Referenced by yaz_marc_read_xml_fields().
void yaz_marc_add_datafield_xml2 | ( | yaz_marc_t | mt, |
char * | tag_value, | ||
char * | indicators | ||
) |
adds datafield to MARC structure using xml Nodes
mt | handle |
tag_value | string value (pointer copied verbatim, not strdupped) |
indicators | indicator string ; pointer copied verbatim; not strdupped |
Definition at line 297 of file marcdisp.c.
References yaz_marc_node::datafield, yaz_marc_datafield::indicator, yaz_marc_t_::subfield_pp, yaz_marc_datafield::subfields, yaz_marc_datafield::tag, yaz_marc_node::u, yaz_marc_node::which, yaz_marc_add_node(), and YAZ_MARC_DATAFIELD.
Referenced by yaz_marc_read_turbo_xml_fields().
void yaz_marc_add_subfield | ( | yaz_marc_t | mt, |
const char * | code_data, | ||
size_t | code_data_len | ||
) |
adds subfield to MARC structure
mt | handle |
code_data | code data buffer |
code_data_len | length of code data |
Definition at line 316 of file marcdisp.c.
References yaz_marc_subfield::code_data, yaz_marc_t_::debug, yaz_marc_subfield::next, yaz_marc_t_::nmem, nmem_malloc(), nmem_strdupn(), yaz_marc_t_::subfield_pp, and yaz_marc_add_comment().
Referenced by parse_subfields(), yaz_end_element_ns(), yaz_marc_read_iso2709(), yaz_marc_read_line(), yaz_marc_read_turbo_xml_subfields(), and yaz_marc_read_xml_subfields().
int yaz_marc_check_marc21_coding | ( | const char * | charset, |
const char * | marc_buf, | ||
int | sz | ||
) |
check if MARC21 is UTF-8 encoded
charset | that is given by user |
marc_buf | ISO2709 buf |
sz | ISO2709 size |
1 | is probably UTF-8 |
0 | is not UTF-8 |
Definition at line 1490 of file marcdisp.c.
References yaz_matchstr().
Referenced by convert_marc(), iconv_create_charset(), and yaz_opac_check_marc21_coding().
void yaz_marc_cprintf | ( | yaz_marc_t | mt, |
const char * | fmt, | ||
... | |||
) |
adds MARC annotation - printf interface
mt | handle |
fmt | printf format string |
Definition at line 188 of file marcdisp.c.
References yaz_marc_add_comment(), and yaz_vsnprintf().
Referenced by check_ascii(), yaz_marc_read_iso2709(), yaz_marc_read_json_node(), yaz_marc_read_line(), yaz_marc_read_turbo_xml_fields(), yaz_marc_read_turbo_xml_subfields(), yaz_marc_read_xml(), yaz_marc_read_xml_fields(), yaz_marc_read_xml_leader(), yaz_marc_read_xml_subfields(), and yaz_marc_set_leader().
yaz_marc_t yaz_marc_create | ( | void | ) |
construct yaz_marc_t handle
Definition at line 102 of file marcdisp.c.
References yaz_marc_t_::debug, yaz_marc_t_::enable_collection, yaz_marc_t_::endline_str, yaz_marc_t_::iconv_cd, yaz_marc_t_::leader_spec, yaz_marc_t_::m_wr, yaz_marc_t_::nmem, nmem_create(), no_collection, yaz_marc_t_::output_format, yaz_marc_t_::subfield_str, wrbuf_alloc(), yaz_marc_t_::write_using_libxml2, xmalloc, YAZ_MARC_LINE, and yaz_marc_reset().
Referenced by convert_marc(), dummy_json_record(), dummy_xml_record(), retrieve_fetch(), return_marc_record(), return_opac_record(), and yaz_record_conv_opac_record().
void yaz_marc_debug | ( | yaz_marc_t | mt, |
int | level | ||
) |
set debug level
mt | handle |
level | level, where 0=lowest, 1 more debug, 2 even more |
Definition at line 1381 of file marcdisp.c.
References yaz_marc_t_::debug.
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
mt | marc handle |
buf | input buffer |
bsize | size of buffer or (-1 if "any size") |
result | result to be stored here |
rsize | size of result (memory "owned" by yaz_marc_mt handle) |
Decodes MARC in buf of size bsize. On success, result in *result with size *rsize. Returns -1 on error, or size of input record (>0) if OK
Definition at line 1362 of file marcdisp.c.
References yaz_marc_t_::m_wr, wrbuf_cstr(), wrbuf_len, wrbuf_rewind(), and yaz_marc_decode_wrbuf().
int yaz_marc_decode_formatstr | ( | const char * | arg | ) |
Converts MARC format type to format type(YAZ_MARC_..)
arg | string |
-1 | unknown format (bad arg) |
>= | 0 OK (one of YAZ_MARC - values) |
Definition at line 1467 of file marcdisp.c.
References YAZ_MARC_ISO2709, YAZ_MARC_JSON, YAZ_MARC_LINE, YAZ_MARC_MARCXML, YAZ_MARC_TURBOMARC, and YAZ_MARC_XCHANGE.
int yaz_marc_decode_wrbuf | ( | yaz_marc_t | mt, |
const char * | buf, | ||
int | bsize, | ||
WRBUF | wrbuf | ||
) |
decodes ISO2709/MARC buffer and stores result in WRBUF
mt | handle |
buf | input buffer |
bsize | size of buffer (-1 if "any size") |
wrbuf | WRBUF for output |
Decodes MARC in buf of size bsize. On success, result in wrbuf Returns -1 on error, or size of input record (>0) if OK
Definition at line 1351 of file marcdisp.c.
References yaz_marc_read_iso2709(), and yaz_marc_write_mode().
Referenced by dummy_json_record(), dummy_xml_record(), return_marc_record(), yaz_marc_decode_buf(), and yaz_opac_decode_wrbuf2().
void yaz_marc_destroy | ( | yaz_marc_t | mt | ) |
destroy yaz_marc_t handle
Definition at line 120 of file marcdisp.c.
References yaz_marc_t_::leader_spec, yaz_marc_t_::m_wr, yaz_marc_t_::nmem, nmem_destroy(), wrbuf_destroy(), and xfree.
Referenced by convert_marc(), dummy_json_record(), dummy_xml_record(), retrieve_fetch(), return_marc_record(), return_opac_record(), and yaz_record_conv_opac_record().
void yaz_marc_enable_collection | ( | yaz_marc_t | mt | ) |
enables record collection output
mt | handle |
Definition at line 618 of file marcdisp.c.
References collection_first, and yaz_marc_t_::enable_collection.
void yaz_marc_endline_str | ( | yaz_marc_t | mt, |
const char * | s | ||
) |
Definition at line 438 of file marcdisp.c.
References yaz_marc_t_::endline_str.
int yaz_marc_get_debug | ( | yaz_marc_t | mt | ) |
gets debug level for MARC system
mt | handle |
Definition at line 199 of file marcdisp.c.
References yaz_marc_t_::debug.
Referenced by yaz_marc_read_iso2709().
yaz_iconv_t yaz_marc_get_iconv | ( | yaz_marc_t | mt | ) |
supply iconv handle for character set conversion
Definition at line 1392 of file marcdisp.c.
References yaz_marc_t_::iconv_cd.
Referenced by yaz_opac_decode_wrbuf2().
NMEM yaz_marc_get_nmem | ( | yaz_marc_t | mt | ) |
returns memory for MARC handle
mt | handle |
NMEM | handle for MARC system |
Definition at line 130 of file marcdisp.c.
References yaz_marc_t_::nmem.
Referenced by yaz_marc_read_turbo_xml_fields(), yaz_marc_read_turbo_xml_subfields(), yaz_marc_read_xml_subfields(), and yaz_xml_to_opac_ptr().
void yaz_marc_iconv | ( | yaz_marc_t | mt, |
yaz_iconv_t | cd | ||
) |
set iconv handle for character set conversion
Definition at line 1387 of file marcdisp.c.
References yaz_marc_t_::iconv_cd.
Referenced by convert_marc(), return_marc_record(), return_opac_record(), yaz_record_conv_opac_record(), and yaz_xml_to_opac().
int yaz_marc_leader_spec | ( | yaz_marc_t | mt, |
const char * | leader_spec | ||
) |
sets leader spec (for modifying bytes in 24 byte leader)
mt | handle |
leader_spec |
0 | OK |
-1 | ERROR |
Spec takes form pos=val,pos=val,... where value is either a number (decimal char value) or a string in 'a', e.g. 9='a'
Definition at line 1410 of file marcdisp.c.
References yaz_marc_t_::leader_spec, marc_exec_leader(), xfree, and xstrdup.
Referenced by convert_marc(), and yaz_record_conv_opac_record().
void yaz_marc_modify_leader | ( | yaz_marc_t | mt, |
size_t | off, | ||
const char * | str | ||
) |
modifies part of the MARC leader
Definition at line 1397 of file marcdisp.c.
References yaz_marc_node::leader, yaz_marc_node::next, yaz_marc_t_::nodes, yaz_marc_node::u, yaz_marc_node::which, and YAZ_MARC_LEADER.
Referenced by yaz_marc_write_marcxml(), and yaz_marc_write_turbomarc().
int yaz_marc_read_iso2709 | ( | yaz_marc_t | mt, |
const char * | buf, | ||
int | bsize | ||
) |
read ISO2709/MARC record from buffer
mt | handle |
buf | ISO2709 buffer of size bsize |
bsize | size of buffer (-1 for unlimited size) |
Parses ISO2709 record from supplied buffer
-1 | ERROR |
>0 | OK (length) |
Definition at line 25 of file marc_read_iso2709.c.
References atoi_n(), atoi_n_check(), ISO2709_FS, ISO2709_IDFS, ISO2709_RS, wrbuf_alloc(), wrbuf_cstr(), wrbuf_destroy(), wrbuf_puts(), wrbuf_write_escaped(), yaz_isdigit, yaz_marc_add_controlfield(), yaz_marc_add_datafield(), yaz_marc_add_subfield(), yaz_marc_cprintf(), yaz_marc_get_debug(), yaz_marc_reset(), yaz_marc_set_leader(), and yaz_marc_sizeof_char().
Referenced by convert_marc(), and yaz_marc_decode_wrbuf().
int yaz_marc_read_json_node | ( | yaz_marc_t | mt, |
struct json_node * | n | ||
) |
Definition at line 101 of file marc_read_json.c.
References json_node_array, json_node_list, json_node_object, json_node_pair, json_node_string, json_node::link, parse_field(), json_node::string, json_node::type, json_node::u, wrbuf_alloc(), wrbuf_destroy(), yaz_marc_cprintf(), and yaz_marc_set_leader().
int yaz_marc_read_line | ( | yaz_marc_t | mt, |
int(*)(void *client_data) | getbyte, | ||
void(*)(int b, void *client_data) | ungetbyte, | ||
void * | client_data | ||
) |
read MARC lineformat from stream
mt | handle |
getbyte | get one byte handler |
ungetbyte | unget one byte handler |
client_data | opaque data for handers |
-1 | ERROR |
>0 | OK (length) |
Parses MARC line record from stream Returns > 0 for OK (same as length), -1=ERROR
Definition at line 95 of file marc_read_line.c.
References atoi_n_check(), wrbuf_alloc(), wrbuf_cstr(), wrbuf_destroy(), yaz_marc_add_controlfield(), yaz_marc_add_datafield(), yaz_marc_add_subfield(), yaz_marc_cprintf(), yaz_marc_line_gets(), yaz_marc_reset(), and yaz_marc_set_leader().
int yaz_marc_read_xml | ( | yaz_marc_t | mt, |
const xmlNode * | ptr | ||
) |
parses MARCXML/MarcXchange/TurboMARC record from xmlNode pointer
mt | handle |
ptr | is a pointer to root xml node |
0 | OK |
-1 | ERROR |
Definition at line 356 of file marc_read_xml.c.
References yaz_marc_cprintf(), YAZ_MARC_MARCXML, yaz_marc_read_turbo_xml_fields(), yaz_marc_read_xml_fields(), yaz_marc_read_xml_leader(), yaz_marc_reset(), and YAZ_MARC_TURBOMARC.
Referenced by bibliographicRecord(), and convert_marc().
void yaz_marc_reset | ( | yaz_marc_t | mt | ) |
clears memory and MARC record
mt | handle |
Definition at line 483 of file marcdisp.c.
References yaz_marc_t_::nmem, nmem_reset(), yaz_marc_t_::nodes, yaz_marc_t_::nodes_pp, and yaz_marc_t_::subfield_pp.
Referenced by yaz_marc_create(), yaz_marc_read_iso2709(), yaz_marc_read_line(), yaz_marc_read_xml(), and yaz_start_element_ns().
void yaz_marc_set_leader | ( | yaz_marc_t | mt, |
const char * | leader, | ||
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
mt | handle |
leader | of the 24 byte leader to be set |
indicator_length | indicator length (returned value) |
identifier_length | identifier length (returned value) |
base_address | base address (returned value) |
length_data_entry | length of data entry (returned value) |
length_starting | length of starting |
length_implementation | length of implementation defined data |
Definition at line 356 of file marcdisp.c.
References atoi_n_check(), check_ascii(), yaz_marc_t_::debug, yaz_marc_add_leader(), and yaz_marc_cprintf().
Referenced by yaz_end_element_ns(), yaz_marc_read_iso2709(), yaz_marc_read_json_node(), yaz_marc_read_line(), and yaz_marc_read_xml_leader().
size_t yaz_marc_sizeof_char | ( | yaz_marc_t | mt, |
const char * | buf | ||
) |
Definition at line 478 of file marcdisp.c.
References cdata_one_character().
Referenced by yaz_marc_read_iso2709().
void yaz_marc_subfield_str | ( | yaz_marc_t | mt, |
const char * | s | ||
) |
Definition at line 432 of file marcdisp.c.
References yaz_marc_t_::subfield_str.
int yaz_marc_write_iso2709 | ( | yaz_marc_t | mt, |
WRBUF | wrbuf | ||
) |
writes record in ISO2709 format
mt | handle |
wrbuf | WRBUF for output |
0 | OK |
-1 | ERROR |
Definition at line 1119 of file marcdisp.c.
References atoi_n_check(), yaz_marc_subfield::code_data, yaz_marc_node::controlfield, yaz_marc_controlfield::data, yaz_marc_node::datafield, yaz_marc_t_::iconv_cd, yaz_marc_datafield::indicator, ISO2709_FS, ISO2709_IDFS, ISO2709_RS, yaz_marc_node::leader, marc_iconv_reset(), yaz_marc_node::next, yaz_marc_subfield::next, yaz_marc_t_::nodes, yaz_marc_datafield::subfields, yaz_marc_datafield::tag, yaz_marc_controlfield::tag, yaz_marc_node::u, yaz_marc_node::which, wrbuf_alloc(), wrbuf_buf, wrbuf_destroy(), wrbuf_iconv_putchar(), wrbuf_iconv_puts(), wrbuf_len, wrbuf_printf(), wrbuf_putc, wrbuf_puts(), wrbuf_rewind(), wrbuf_write(), YAZ_MARC_COMMENT, YAZ_MARC_CONTROLFIELD, YAZ_MARC_DATAFIELD, and YAZ_MARC_LEADER.
Referenced by bibliographicRecord(), and yaz_marc_write_mode().
int yaz_marc_write_json | ( | yaz_marc_t | mt, |
WRBUF | w | ||
) |
writes MARC record in JSON represenation
mt | handle |
w | WRBUF for output |
0 | Creation successful |
-1 | ERROR |
Definition at line 1257 of file marcdisp.c.
References atoi_n_check(), cdata_one_character(), yaz_marc_subfield::code_data, yaz_marc_node::controlfield, yaz_marc_controlfield::data, yaz_marc_node::datafield, get_subfield_len(), yaz_marc_t_::iconv_cd, yaz_marc_datafield::indicator, yaz_marc_node::leader, yaz_marc_node::next, yaz_marc_subfield::next, yaz_marc_t_::nodes, yaz_marc_datafield::subfields, yaz_marc_datafield::tag, yaz_marc_controlfield::tag, yaz_marc_node::u, yaz_marc_node::which, wrbuf_iconv_json_puts(), wrbuf_iconv_json_write(), wrbuf_json_puts(), wrbuf_json_write(), wrbuf_printf(), wrbuf_puts(), YAZ_MARC_COMMENT, YAZ_MARC_CONTROLFIELD, YAZ_MARC_DATAFIELD, and YAZ_MARC_LEADER.
Referenced by yaz_marc_write_mode().
int yaz_marc_write_line | ( | yaz_marc_t | mt, |
WRBUF | wrbuf | ||
) |
writes record in line format
mt | handle |
wrbuf | WRBUF for output |
0 | OK |
-1 | ERROR |
Definition at line 537 of file marcdisp.c.
References atoi_n_check(), yaz_marc_subfield::code_data, yaz_marc_node::comment, yaz_marc_node::controlfield, yaz_marc_controlfield::data, yaz_marc_node::datafield, yaz_marc_t_::endline_str, get_subfield_len(), yaz_marc_t_::iconv_cd, yaz_marc_datafield::indicator, yaz_marc_node::leader, marc_iconv_reset(), yaz_marc_node::next, yaz_marc_subfield::next, yaz_marc_t_::nodes, yaz_marc_t_::subfield_str, yaz_marc_datafield::subfields, yaz_marc_datafield::tag, yaz_marc_controlfield::tag, yaz_marc_node::u, yaz_marc_node::which, wrbuf_iconv_puts(), wrbuf_iconv_write(), wrbuf_printf(), wrbuf_puts(), YAZ_MARC_COMMENT, YAZ_MARC_CONTROLFIELD, YAZ_MARC_DATAFIELD, and YAZ_MARC_LEADER.
Referenced by yaz_marc_write_mode().
int yaz_marc_write_marcxchange | ( | yaz_marc_t | mt, |
WRBUF | wrbuf, | ||
const char * | format, | ||
const char * | type | ||
) |
writes record in MarcXchange XML (ISO25577)
mt | handle |
wrbuf | WRBUF for output |
format | record format (e.g. "MARC21") |
type | record type (e.g. Bibliographic) |
0 | OK |
-1 | ERROR |
Definition at line 871 of file marcdisp.c.
References yaz_marc_write_marcxml_ns().
Referenced by yaz_marc_write_mode().
int yaz_marc_write_marcxml | ( | yaz_marc_t | mt, |
WRBUF | wrbuf | ||
) |
writes record in MARCXML format
mt | handle |
wrbuf | WRBUF for output |
0 | OK |
-1 | ERROR |
Sets leader[9]='a' .
Definition at line 850 of file marcdisp.c.
References yaz_marc_t_::leader_spec, yaz_marc_modify_leader(), and yaz_marc_write_marcxml_ns().
Referenced by yaz_marc_write_mode().
int yaz_marc_write_mode | ( | yaz_marc_t | mt, |
WRBUF | wrbuf | ||
) |
writes record in mode - given by yaz_marc_xml mode
mt | handle |
wrbuf | WRBUF for output |
0 | OK |
-1 | ERROR |
This function calls yaz_marc_write_iso2709, yaz_marc_write_marcxml, etc.. depending on mode given by yaz_marc_xml.
Definition at line 623 of file marcdisp.c.
References yaz_marc_t_::output_format, YAZ_MARC_CHECK, YAZ_MARC_ISO2709, YAZ_MARC_JSON, YAZ_MARC_LINE, YAZ_MARC_MARCXML, YAZ_MARC_TURBOMARC, yaz_marc_write_check(), yaz_marc_write_iso2709(), yaz_marc_write_json(), yaz_marc_write_line(), yaz_marc_write_marcxchange(), yaz_marc_write_marcxml(), yaz_marc_write_turbomarc(), and YAZ_MARC_XCHANGE.
Referenced by convert_marc(), and yaz_marc_decode_wrbuf().
int yaz_marc_write_trailer | ( | yaz_marc_t | mt, |
WRBUF | wr | ||
) |
flushes records
mt | handle |
wr | WRBUF for output |
0 | OK |
-1 | ERROR |
Definition at line 600 of file marcdisp.c.
References collection_second, yaz_marc_t_::enable_collection, yaz_marc_t_::output_format, wrbuf_printf(), YAZ_MARC_MARCXML, YAZ_MARC_TURBOMARC, and YAZ_MARC_XCHANGE.
int yaz_marc_write_turbomarc | ( | yaz_marc_t | mt, |
WRBUF | wrbuf | ||
) |
writes record in TurboMARC format
mt | handle |
wrbuf | WRBUF for output |
0 | OK |
-1 | ERROR |
Definition at line 861 of file marcdisp.c.
References yaz_marc_t_::leader_spec, yaz_marc_modify_leader(), and yaz_marc_write_marcxml_ns().
Referenced by yaz_marc_write_mode().
void yaz_marc_write_using_libxml2 | ( | yaz_marc_t | mt, |
int | enable | ||
) |
Enables or disables writing of MARC XML records using Libxml2.
mt | handle |
enable | 0=disable, 1=enable |
Definition at line 1485 of file marcdisp.c.
References yaz_marc_t_::write_using_libxml2.
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
mt | handle |
root_ptr | pointer to record node |
ns | namespace of record (such as "http://www.loc.gov/MARC21/slim") |
format | MarcXchange format (NULL for none) |
type | MarcXchange format (NULL for none) |
0 | Creation successful and *root_ptr is "record" node |
-1 | ERROR |
Definition at line 1025 of file marcdisp.c.
References atoi_n_check(), yaz_marc_subfield::code_data, yaz_marc_node::comment, yaz_marc_node::controlfield, yaz_marc_controlfield::data, yaz_marc_node::datafield, get_subfield_len(), yaz_marc_t_::iconv_cd, yaz_marc_node::leader, marc_iconv_reset(), yaz_marc_node::next, yaz_marc_subfield::next, yaz_marc_t_::nodes, yaz_marc_datafield::subfields, yaz_marc_datafield::tag, yaz_marc_controlfield::tag, type, yaz_marc_node::u, yaz_marc_node::which, wrbuf_alloc(), wrbuf_cstr(), wrbuf_destroy(), wrbuf_iconv_puts(), wrbuf_iconv_write(), wrbuf_rewind(), write_xml_indicator(), YAZ_MARC_COMMENT, YAZ_MARC_CONTROLFIELD, YAZ_MARC_DATAFIELD, and YAZ_MARC_LEADER.
Referenced by yaz_marc_write_marcxml_ns().
void yaz_marc_xml | ( | yaz_marc_t | mt, |
int | xmlmode | ||
) |
set XML mode YAZ_MARC_LINE, YAZ_MARCXML, YAZ_MARC_ISO2709 ..
mt | MARC handle |
xmlmode | mode. |
This function ONLY affects yaz_marc_write_mode, yaz_marc_write_trailer.
Definition at line 1376 of file marcdisp.c.
References yaz_marc_t_::output_format.
Referenced by convert_marc(), dummy_json_record(), dummy_xml_record(), return_marc_record(), return_opac_record(), and yaz_record_conv_opac_record().
int yaz_opac_check_marc21_coding | ( | const char * | charset, |
Z_OPACRecord * | r | ||
) |
Definition at line 194 of file opac_to_xml.c.
References Z_OPACRecord::bibliographicRecord, odr_oct::buf, odr_oct::len, Z_External::octet_aligned, Z_External::u, Z_External::which, yaz_marc_check_marc21_coding(), and Z_External_octet.
Referenced by yaz_record_conv_opac_record().
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.
mt | handle |
r | OPAC record |
wrbuf | WRBUF for resulting display string |
This function uses iconv_handle of yaz_marc_t for character set conversion of both OPAC + ISO2709 part. \
Definition at line 189 of file opac_to_xml.c.
References yaz_opac_decode_wrbuf2().
Referenced by dummy_xml_record(), return_opac_record(), and yaz_record_conv_opac_record().
void yaz_opac_decode_wrbuf2 | ( | yaz_marc_t | mt, |
Z_OPACRecord * | r, | ||
WRBUF | wrbuf, | ||
yaz_iconv_t | cd | ||
) |
Performs "pretty" display of OPAC record to WRBUF using marc_t.
mt | handle |
r | OPAC record |
wrbuf | WRBUF for resulting display string |
cd | iconv handle for OPAC content (not ISO2709 part) |
This function uses iconv handle of yaz_marc_t for character set conversion of ISO2709 part and supplied handle (cd) for OPAC part. \
Definition at line 62 of file opac_to_xml.c.
References Z_CircRecord::availableNow, Z_CircRecord::availableThru, Z_CircRecord::availablityDate, Z_OPACRecord::bibliographicRecord, odr_oct::buf, Z_HoldingsAndCircData::callNumber, Z_Volume::chronology, Z_HoldingsAndCircData::circulationData, Z_HoldingsAndCircData::completeness, Z_HoldingsAndCircData::copyNumber, Z_HoldingsAndCircData::dateOfReport, Z_HoldingsAndCircData::encodingLevel, Z_HoldingsAndCircData::enumAndChron, Z_Volume::enumAndChron, Z_CircRecord::enumAndChron, Z_Volume::enumeration, Z_HoldingsAndCircData::format, Z_HoldingsAndCircData::generalRetention, Z_HoldingsRecord::holdingsAndCirc, Z_OPACRecord::holdingsData, Z_CircRecord::itemId, odr_oct::len, Z_HoldingsAndCircData::localLocation, Z_HoldingsRecord::marcHoldingsRecord, Z_CircRecord::midspine, Z_HoldingsAndCircData::nucCode, Z_HoldingsAndCircData::num_circulationData, Z_OPACRecord::num_holdingsData, Z_HoldingsAndCircData::num_volumes, Z_External::octet_aligned, Z_CircRecord::onHold, opac_element_bool(), opac_element_str(), Z_HoldingsAndCircData::publicNote, Z_HoldingsAndCircData::receiptAcqStatus, Z_CircRecord::renewable, Z_HoldingsAndCircData::reproductionNote, Z_CircRecord::restrictions, Z_HoldingsAndCircData::shelvingData, Z_HoldingsAndCircData::shelvingLocation, Z_CircRecord::temporaryLocation, Z_HoldingsAndCircData::termsUseRepro, Z_HoldingsAndCircData::typeOfRecord, Z_External::u, Z_HoldingsRecord::u, Z_HoldingsAndCircData::volumes, Z_External::which, Z_HoldingsRecord::which, wrbuf_puts(), yaz_marc_decode_wrbuf(), yaz_marc_get_iconv(), Z_External_octet, Z_HoldingsRecord_holdingsAndCirc, and Z_HoldingsRecord_marcHoldingsRecord.
Referenced by return_opac_record(), and yaz_opac_decode_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.
mt | marc handle |
buf_in | XML buffer |
size_in | size of XML buffer |
dst | Z39.50 OPAC result - allocated by NMEM on marc handle |
cd | iconv handle for the OPAC content (not ISO2709 part) |
nmem | memory for OPACRecord (if NULL, mt NMEM memory is used) |
syntax | OID for embedded MARC (if NULL, USMARC is used) |
1 | conversion OK |
0 | conversion NOT OK \ |
Definition at line 299 of file xml_to_opac.c.
References yaz_marc_iconv(), and yaz_xml_to_opac_ptr().
Referenced by retrieve_fetch().