/*
- * Copyright (C) 1994-1997, Index Data I/S
+ * Copyright (C) 1994-1998, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: recgrs.c,v $
- * Revision 1.11 1997-10-27 14:34:00 adam
+ * Revision 1.16 1998-01-29 13:38:17 adam
+ * Fixed problem with mapping to record with unknown schema.
+ *
+ * Revision 1.15 1998/01/26 10:37:57 adam
+ * Better diagnostics.
+ *
+ * Revision 1.14 1997/11/06 11:41:01 adam
+ * Implemented "begin variant" for the sgml.regx filter.
+ *
+ * Revision 1.13 1997/10/31 12:35:44 adam
+ * Added a few log statements.
+ *
+ * Revision 1.12 1997/10/29 12:02:22 adam
+ * Using oid_ent_to_oid used instead of the non thread-safe oid_getoidbyent.
+ *
+ * Revision 1.11 1997/10/27 14:34:00 adam
* Work on generic character mapping depending on "structure" field
* in abstract syntax file.
*
static int grs_extract(struct recExtractCtrl *p)
{
data1_node *n;
- NMEM mem = nmem_create();
+ NMEM mem;
struct grs_read_info gri;
seqno = 0;
+ mem = nmem_create ();
gri.readf = p->readf;
gri.seekf = p->seekf;
gri.tellf = p->tellf;
return 26; /* fix */
}
if (espec)
+ {
+ logf (LOG_LOG, "Element: Espec-1 match");
return data1_doespec1(dh, n, espec);
+ }
else
+ {
+ logf (LOG_DEBUG, "Element: all match");
return -1;
+ }
}
static int grs_retrieve(struct recRetrieveCtrl *p)
data1_node *new;
data1_maptab *map;
int res, selected = 0;
- NMEM mem = nmem_create();
+ NMEM mem;
struct grs_read_info gri;
+ mem = nmem_create();
gri.readf = p->readf;
gri.seekf = p->seekf;
gri.tellf = p->tellf;
gri.mem = mem;
gri.dh = p->dh;
+ logf (LOG_DEBUG, "grs_retrieve");
node = read_grs_type (&gri, p->subType);
if (!node)
{
- p->diagnostic = 2;
+ p->diagnostic = 14;
+ nmem_destroy (mem);
return 0;
}
+ logf (LOG_DEBUG, "grs_retrieve: score");
if (p->score >= 0 && (new =
data1_insert_taggeddata(p->dh, node,
node, "rank",
sprintf(new->u.data.data, "%d", p->score);
new->u.data.len = strlen(new->u.data.data);
}
+ logf (LOG_DEBUG, "grs_retrieve: localControlNumber");
if ((new = data1_insert_taggeddata(p->dh, node, node,
"localControlNumber", mem)))
{
sprintf(new->u.data.data, "%d", p->localno);
new->u.data.len = strlen(new->u.data.data);
}
+ logf (LOG_DEBUG, "grs_retrieve: schemaIdentifier");
if (p->input_format == VAL_GRS1 && node->u.root.absyn &&
node->u.root.absyn->reference != VAL_NONE)
{
oident oe;
Odr_oid *oid;
+ int oidtmp[OID_SIZE];
oe.proto = PROTO_Z3950;
oe.oclass = CLASS_SCHEMA;
oe.value = node->u.root.absyn->reference;
- if ((oid = oid_getoidbyent(&oe)))
+ if ((oid = oid_ent_to_oid (&oe, oidtmp)))
{
char tmp[128];
data1_handle dh = p->dh;
}
}
+ logf (LOG_DEBUG, "grs_retrieve: schema mapping");
/*
* Does the requested format match a known schema-mapping? (this reflects
* the overlap of schema and formatting which is inherent in the MARC
if (!(node = data1_map_record(p->dh, onode, map, mem)))
{
p->diagnostic = 14;
+ nmem_destroy (mem);
return 0;
}
-
break;
}
+ logf (LOG_DEBUG, "grs_retrieve: element spec");
if (p->comp && (res = process_comp(p->dh, node, p->comp)) > 0)
{
p->diagnostic = res;
else if (p->comp && !res)
selected = 1;
+ logf (LOG_DEBUG, "grs_retrieve: transfer syntax mapping");
switch (p->output_format = (p->input_format != VAL_NONE ?
p->input_format : VAL_SUTRS))
{
dummy = 0;
if (!(p->rec_buf = data1_nodetogr(p->dh, node, selected,
p->odr, &dummy)))
- p->diagnostic = 2; /* this should be better specified */
+ p->diagnostic = 238; /* not available in requested syntax */
else
p->rec_len = -1;
break;
case VAL_EXPLAIN:
if (!(p->rec_buf = data1_nodetoexplain(p->dh, node, selected,
p->odr)))
- p->diagnostic = 2; /* this should be better specified */
+ p->diagnostic = 238;
else
p->rec_len = -1;
break;
case VAL_SUMMARY:
if (!(p->rec_buf = data1_nodetosummary(p->dh, node, selected,
p->odr)))
- p->diagnostic = 2;
+ p->diagnostic = 238;
else
p->rec_len = -1;
break;
case VAL_SUTRS:
if (!(p->rec_buf = data1_nodetobuf(p->dh, node, selected,
(int*)&p->rec_len)))
- {
- p->diagnostic = 2;
- break;
- }
+ p->diagnostic = 238;
break;
case VAL_SOIF:
if (!(p->rec_buf = data1_nodetosoif(p->dh, node, selected,
(int*)&p->rec_len)))
- {
- p->diagnostic = 2;
- break;
- }
+ p->diagnostic = 238;
break;
default:
+ if (!node->u.root.absyn)
+ {
+ p->diagnostic = 238;
+ break;
+ }
for (marctab = node->u.root.absyn->marc; marctab;
marctab = marctab->next)
if (marctab->reference == p->input_format)
break;
if (!marctab)
{
- p->diagnostic = 227;
+ p->diagnostic = 238;
break;
}
if (!(p->rec_buf = data1_nodetomarc(p->dh, marctab, node,
selected,
(int*)&p->rec_len)))
{
- p->diagnostic = 2;
+ p->diagnostic = 238;
break;
}
}