-/* $Id: marcread.c,v 1.2 2006-08-14 10:40:15 adam Exp $
+/* $Id: marcread.c,v 1.5 2006-10-26 23:49:14 adam Exp $
Copyright (C) 1995-2006
Index Data ApS
char *absynName;
data1_marctab *marctab;
- if ((*p->readf)(p->fh, buf, 5) != 5)
+ if (p->stream->readf(p->stream, buf, 5) != 5)
return NULL;
while (*buf < '0' || *buf > '9')
{
for (i = 0; i<4; i++)
buf[i] = buf[i+1];
- if ((*p->readf)(p->fh, buf+4, 1) != 1)
+ if (p->stream->readf(p->stream, buf+4, 1) != 1)
return NULL;
}
record_length = atoi_n (buf, 5);
return NULL;
}
/* read remaining part - attempt to read one byte furhter... */
- read_bytes = (*p->readf)(p->fh, buf+5, record_length-4);
+ read_bytes = p->stream->readf(p->stream, buf+5, record_length-4);
if (read_bytes < record_length-5)
{
yaz_log (YLOG_WARN, "Couldn't read whole MARC record");
}
if (read_bytes == record_length - 4)
{
- off_t cur_offset = (*p->tellf)(p->fh);
+ off_t cur_offset = p->stream->tellf(p->stream);
if (cur_offset <= 27)
return NULL;
- if (p->endf)
- (*p->endf)(p->fh, cur_offset - 1);
+ if (p->stream->endf)
+ {
+ off_t end_offset = cur_offset - 1;
+ p->stream->endf(p->stream, &end_offset);
+ }
}
absynName = mi->type;
res_root = data1_mk_root (p->dh, p->mem, absynName);
else
res_top = data1_mk_tag (p->dh, p->mem, absynName, 0, res_root);
- if ((marctab = data1_absyn_getmarctab(p->dh, res_root->u.root.absyn)))
+ if ((marctab = data1_absyn_getmarctab(p->dh, res_root)))
{
memcpy(marctab->leader, buf, 24);
memcpy(marctab->implementation_codes, buf+6, 4);
static void parse_data1_tree(struct grs_read_info *p, const char *mc_stmnt,
data1_node *root)
{
- data1_marctab *marctab = data1_absyn_getmarctab(p->dh, root->u.root.absyn);
+ data1_marctab *marctab = data1_absyn_getmarctab(p->dh, root);
data1_node *top = root->child;
data1_node *field;
mc_context *c;
yaz_log(YLOG_LOG,"parse_data1_tree(): try LEADER from {%d} to {%d} positions",
pf->interval.start, pf->interval.end);
#endif
- new = data1_mk_tag_n(p->dh, p->mem, mc_stmnt, strlen(mc_stmnt), 0, top);
- data1_mk_text_n(p->dh, p->mem, marctab->leader+pf->interval.start,
- pf->interval.end-pf->interval.start+1, new);
+ if (marctab)
+ {
+ new = data1_mk_tag_n(p->dh, p->mem, mc_stmnt, strlen(mc_stmnt), 0, top);
+ data1_mk_text_n(p->dh, p->mem, marctab->leader+pf->interval.start,
+ pf->interval.end-pf->interval.start+1, new);
+ }
}
else
{
if (!root)
return 0;
- for (e = data1_absyn_getelements(p->dh, root->u.root.absyn); e; e=e->next)
+ for (e = data1_absyn_getelements(p->dh, root); e; e=e->next)
{
data1_tag *tag = e->tag;
if (!root)
return 0;
- for (e = data1_absyn_getelements(p->dh, root->u.root.absyn); e; e=e->next)
+ for (e = data1_absyn_getelements(p->dh, root); e; e=e->next)
{
data1_tag *tag = e->tag;