30 int identifier_length;
33 int length_data_entry;
35 int length_implementation;
44 if (record_length < 25)
50 if (bsize != -1 && record_length > bsize)
53 record_length, bsize);
65 &length_implementation);
68 for (entry_p = 24; buf[entry_p] !=
ISO2709_FS; )
71 int l = 3 + length_data_entry + length_starting;
72 if (entry_p + l >= record_length)
75 " Missing FS char", entry_p);
103 length_data_entry + length_starting + 3);
105 " length and/or length starting (%s)", entry_p,
110 entry_p += 3 + length_data_entry + length_starting;
112 end_of_directory = entry_p;
113 if (base_address != entry_p+1)
116 " base %d, end %d", base_address, entry_p+1);
120 for (entry_p = 24; entry_p != end_of_directory; )
127 int identifier_flag = 0;
128 int entry_p0 = entry_p;
130 memcpy (tag, buf+entry_p, 3);
133 data_length =
atoi_n(buf+entry_p, length_data_entry);
134 entry_p += length_data_entry;
135 data_offset =
atoi_n(buf+entry_p, length_starting);
136 entry_p += length_starting;
137 i = data_offset + base_address;
138 end_offset = i+data_length-1;
140 if (data_length <= 0 || data_offset < 0)
147 tag, entry_p0, data_length, data_offset);
149 if (end_offset >= record_length)
152 entry_p0, end_offset, record_length);
156 if (memcmp (tag,
"00", 2))
158 else if (indicator_length < 4 && indicator_length > 0)
170 i += identifier_flag-1;
171 if (indicator_length)
174 for (j = 0; j < indicator_length; j++)
179 while (i < end_offset &&
182 int code_offset = i+1;
185 while (i < end_offset &&
197 while (i < end_offset &&
213 return record_length;
int atoi_n_check(const char *buf, int size, int *val)
like atoi_n but checks for proper formatting
int atoi_n(const char *buf, int len)
like atoi(3) except that it reads exactly len characters
int yaz_marc_read_iso2709(yaz_marc_t mt, const char *buf, int bsize)
read ISO2709/MARC record from buffer
void yaz_marc_cprintf(yaz_marc_t mt, const char *fmt,...)
adds MARC annotation - printf interface
size_t yaz_marc_sizeof_char(yaz_marc_t mt, const char *buf)
void yaz_marc_add_subfield(yaz_marc_t mt, const char *code_data, size_t code_data_len)
adds subfield to MARC structure
int yaz_marc_get_debug(yaz_marc_t mt)
gets debug level for MARC system
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
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
void yaz_marc_add_controlfield(yaz_marc_t mt, const char *tag, const char *data, size_t data_len)
adds controlfield to MARC structure
void yaz_marc_reset(yaz_marc_t mt)
clears memory and MARC record
#define ISO2709_FS
MARC control char: field separator (30 Dec, 1E Hex)
#define ISO2709_IDFS
MARC control char: identifier-field separator (31 Dec, 1F Hex)
#define ISO2709_RS
MARC control char: record separator (29 Dec, 1D Hex)
the internals of a yaz_marc_t handle
void wrbuf_destroy(WRBUF b)
destroy WRBUF and its buffer
WRBUF wrbuf_alloc(void)
construct WRBUF
void wrbuf_write_escaped(WRBUF b, const char *str, size_t len)
writes buffer to WRBUF and escape non-ASCII characters
const char * wrbuf_cstr(WRBUF b)
returns WRBUF content as C-string
void wrbuf_puts(WRBUF b, const char *buf)
appends C-string to WRBUF
Header for WRBUF (growing buffer)
Header for common YAZ utilities.