27 static int yaz_gets(
int (*getbyte)(
void *client_data),
28 void (*ungetbyte)(
int b,
void *client_data),
33 int ch = getbyte(client_data);
35 while (ch !=
'\0' && ch !=
'\r' && ch !=
'\n')
39 ch = getbyte(client_data);
43 ch = getbyte(client_data);
44 if (ch !=
'\n' && ch !=
'\0')
45 ungetbyte(ch, client_data);
49 ch = getbyte(client_data);
50 if (ch !=
'\r' && ch !=
'\0')
51 ungetbyte(ch, client_data);
61 void (*ungetbyte)(
int b,
void *client_data),
68 more =
yaz_gets(getbyte, ungetbyte, client_data, w);
77 int ch = getbyte(client_data);
81 ungetbyte(ch, client_data);
89 more =
yaz_gets(getbyte, ungetbyte, client_data, w);
96 int (*getbyte)(
void *client_data),
97 void (*ungetbyte)(
int b,
void *client_data),
100 int indicator_length;
101 int identifier_length;
103 int length_data_entry;
105 int length_implementation;
108 int header_created = 0;
117 size_t line_len = strlen(line);
123 else if (line[0] ==
'$')
128 else if (line[0] ==
'(')
143 &length_implementation);
146 else if (line_len > 4 && line[0] !=
' ' && line[1] !=
' '
147 && line[2] !=
' ' && line[3] ==
' ' )
151 const char *datafield_start = line+6;
155 memcpy(tag, line, 3);
159 if (*datafield_start ==
' ')
162 if (strchr(
"$_*", *datafield_start))
164 marker_ch = *datafield_start;
165 if (datafield_start[2] ==
' ')
171 const char *leader =
"01000cam 2200265 i 4500";
179 &length_implementation);
189 const char *indicator = line+4;
190 int indicator_len = 2;
191 const char *cp = datafield_start;
199 assert(cp[0] == marker_ch);
202 while ((next = strchr(next, marker_ch)))
204 if ((next[1] >=
'A' && next[1] <=
'Z')
205 ||(next[1] >=
'a' && next[1] <=
'z')
206 ||(next[1] >=
'0' && next[1] <=
'9'))
210 else if (next[2] ==
' ')
217 len = next - cp - marker_skip;
222 char *cp_blank = strchr(cp,
' ');
226 while (cp_blank != cp)
228 cp_blank[0] = cp_blank[-1];
int atoi_n_check(const char *buf, int size, int *val)
like atoi_n but checks for proper formatting
static int yaz_marc_line_gets(int(*getbyte)(void *client_data), void(*ungetbyte)(int b, void *client_data), void *client_data, WRBUF w)
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
static int yaz_gets(int(*getbyte)(void *client_data), void(*ungetbyte)(int b, void *client_data), void *client_data, WRBUF w)
void yaz_marc_cprintf(yaz_marc_t mt, const char *fmt,...)
adds MARC annotation - printf interface
void yaz_marc_add_subfield(yaz_marc_t mt, const char *code_data, size_t code_data_len)
adds subfield to MARC structure
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
the internals of a yaz_marc_t handle
void wrbuf_destroy(WRBUF b)
destroy WRBUF and its buffer
void wrbuf_rewind(WRBUF b)
empty WRBUF content (length of buffer set to 0)
WRBUF wrbuf_alloc(void)
construct WRBUF
void wrbuf_cut_right(WRBUF b, size_t no_to_remove)
cut size of WRBUF
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.