From 1872e3fc60b482771bbd1cb4b0290b8d6a9ef5d0 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 16 Apr 2007 08:44:31 +0000 Subject: [PATCH] Update for YAZ 3s new OID system --- data1/d1_absyn.c | 15 ++-- data1/d1_attset.c | 10 ++- data1/d1_doespec.c | 54 ++++++------ data1/d1_espec.c | 11 +-- data1/d1_expout.c | 28 ++---- data1/d1_map.c | 11 +-- data1/d1_marc.c | 11 ++- data1/d1_read.c | 3 +- data1/d1_tagset.c | 9 +- data1/d1_varset.c | 10 ++- include/attrfind.h | 8 +- include/d1_absyn.h | 4 +- include/idzebra/api.h | 9 +- include/idzebra/data1.h | 16 ++-- include/idzebra/recctrl.h | 11 ++- index/alvis.c | 11 +-- index/attribute.c | 19 +++-- index/index.h | 20 ++--- index/mod_dom.c | 11 +-- index/recgrs.c | 208 ++++++++++++++++++++------------------------- index/rectext.c | 5 +- index/retrieve.c | 84 +++++++++--------- index/rpnscan.c | 13 +-- index/rpnsearch.c | 52 +++++------- index/safari.c | 6 +- index/zebraapi.c | 17 ++-- index/zebrash.c | 10 +-- index/zebrasrv.c | 27 +++--- index/zinfo.c | 74 ++++++---------- index/zsets.c | 7 +- test/api/t16.c | 24 +++--- test/api/t4.c | 4 +- test/api/testlib.c | 5 +- test/api/testlib.h | 3 +- util/attrfind.c | 26 ++---- 35 files changed, 388 insertions(+), 448 deletions(-) diff --git a/data1/d1_absyn.c b/data1/d1_absyn.c index 4af2713..2f03b0c 100644 --- a/data1/d1_absyn.c +++ b/data1/d1_absyn.c @@ -1,4 +1,4 @@ -/* $Id: d1_absyn.c,v 1.34 2007-01-22 18:15:02 adam Exp $ +/* $Id: d1_absyn.c,v 1.35 2007-04-16 08:44:31 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include +#include #include #include #include @@ -250,13 +250,13 @@ data1_attset *data1_attset_search_name (data1_handle dh, const char *name) return 0; } -data1_attset *data1_attset_search_id (data1_handle dh, int id) +data1_attset *data1_attset_search_id(data1_handle dh, const int *oid) { data1_attset_cache p = *data1_attset_cache_get (dh); while (p) { - if (id == p->attset->reference) + if (p->attset->oid && !oid_oidcmp(oid, p->attset->oid)) return p->attset; p = p->next; } @@ -700,7 +700,7 @@ static data1_absyn *data1_read_absyn(data1_handle dh, const char *file, res = (data1_absyn *) nmem_malloc(data1_nmem_get(dh), sizeof(*res)); res->name = 0; - res->reference = VAL_NONE; + res->oid = 0; res->tagset = 0; res->encoding = 0; res->xpath_indexing = @@ -1022,7 +1022,10 @@ static data1_absyn *data1_read_absyn(data1_handle dh, const char *file, continue; } name = argv[1]; - if ((res->reference = oid_getvalbyname(name)) == VAL_NONE) + res->oid = yaz_string_to_oid_nmem(yaz_oid_std(), + CLASS_SCHEMA, name, + data1_nmem_get(dh)); + if (!res->oid) { yaz_log(YLOG_WARN, "%s:%d: Unknown tagset ref '%s'", file, lineno, name); diff --git a/data1/d1_attset.c b/data1/d1_attset.c index 4e2bd9e..fd0bd72 100644 --- a/data1/d1_attset.c +++ b/data1/d1_attset.c @@ -1,4 +1,4 @@ -/* $Id: d1_attset.c,v 1.13 2007-01-15 15:10:14 adam Exp $ +/* $Id: d1_attset.c,v 1.14 2007-04-16 08:44:31 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include +#include #include data1_att *data1_getattbyname(data1_handle dh, data1_attset *s, const char *name) @@ -52,7 +53,7 @@ data1_attset *data1_empty_attset(data1_handle dh) data1_attset *res = (data1_attset*) nmem_malloc(mem,sizeof(*res)); res->name = 0; - res->reference = VAL_NONE; + res->oid = 0; res->atts = 0; res->children = 0; res->next = 0; @@ -132,7 +133,10 @@ data1_attset *data1_read_attset(data1_handle dh, const char *file) continue; } name = argv[1]; - if ((res->reference = oid_getvalbyname(name)) == VAL_NONE) + + res->oid = yaz_string_to_oid_nmem(yaz_oid_std(), + CLASS_ATTSET, name, mem); + if (!res->oid) { yaz_log(YLOG_WARN, "%s:%d: Unknown reference oid '%s'", file, lineno, name); diff --git a/data1/d1_doespec.c b/data1/d1_doespec.c index 3623336..c00cc90 100644 --- a/data1/d1_doespec.c +++ b/data1/d1_doespec.c @@ -1,4 +1,4 @@ -/* $Id: d1_doespec.c,v 1.12 2007-01-15 15:10:14 adam Exp $ +/* $Id: d1_doespec.c,v 1.13 2007-04-16 08:44:31 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -20,12 +20,17 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +/** \file d1_doespec.c + * \brief handle Z39.50 variant-1 specs + * + * See http://www.loc.gov/z3950/agency/defns/variant1.html + */ #include #include #include -#include #include +#include #include static int match_children(data1_handle dh, data1_node *n, @@ -45,23 +50,18 @@ static int match_children_wildpath(data1_handle dh, data1_node *n, * set is the set to look for, universal set is the set that applies to a * triple with an unknown set. */ -static Z_Triple *find_triple(Z_Variant *var, oid_value universalset, - oid_value set, int zclass, int type) +static Z_Triple *find_triple(Z_Variant *var, const int *universal_oid, + const int *var_oid, int zclass, int type) { int i; - oident *defaultsetent = oid_getentbyoid(var->globalVariantSetId); - oid_value defaultset = defaultsetent ? defaultsetent->value : - universalset; for (i = 0; i < var->num_triples; i++) { - oident *cursetent = - oid_getentbyoid(var->triples[i]->variantSetId); - oid_value curset = cursetent ? cursetent->value : defaultset; - - if (set == curset && - *var->triples[i]->zclass == zclass && - *var->triples[i]->type == type) + const int *cur_oid = var->triples[i]->variantSetId; + if (!cur_oid) + cur_oid = var->globalVariantSetId; + if (cur_oid && var_oid + && !oid_oidcmp(var_oid, cur_oid) && *var->triples[i]->type == type) return var->triples[i]; } return 0; @@ -106,9 +106,9 @@ static void mark_subtree(data1_node *n, int make_variantlist, int no_data, } -static void match_triple (data1_handle dh, Z_Variant *vreq, - oid_value defsetval, - oid_value var1, data1_node *n) +static void match_triple(data1_handle dh, Z_Variant *vreq, + const int *def_oid, + const int *var_oid, data1_node *n) { data1_node **c; @@ -127,7 +127,7 @@ static void match_triple (data1_handle dh, Z_Variant *vreq, if ((*c)->u.variant.type->zclass->zclass == 4 && (*c)->u.variant.type->type == 1) { - if ((r = find_triple(vreq, defsetval, var1, 4, 1)) && + if ((r = find_triple(vreq, def_oid, var_oid, 4, 1)) && (r->which == Z_Triple_internationalString)) { const char *string_value = @@ -142,7 +142,7 @@ static void match_triple (data1_handle dh, Z_Variant *vreq, } else { - match_triple (dh, vreq, defsetval, var1, *c); + match_triple(dh, vreq, def_oid, var_oid, *c); c = &(*c)->next; } } @@ -282,10 +282,8 @@ static int match_children_here (data1_handle dh, data1_node *n, Z_Variant *vreq = e->elements[i]->u.simpleElement->variantRequest; - oident *defset = oid_getentbyoid(e->defaultVariantSetId); - oid_value defsetval = defset ? defset->value : VAL_NONE; - oid_value var1 = oid_getvalbyname("Variant-1"); + const int *var_oid = yaz_oid_variant1(); if (!vreq) vreq = e->defaultVariantRequest; @@ -296,21 +294,25 @@ static int match_children_here (data1_handle dh, data1_node *n, /* * 6,5: meta-data requested, variant list. */ - if (find_triple(vreq, defsetval, var1, 6, 5)) + if (find_triple(vreq, e->defaultVariantSetId, + var_oid, 6, 5)) show_variantlist = 1; /* * 9,1: Miscellaneous, no data requested. */ - if (find_triple(vreq, defsetval, var1, 9, 1)) + if (find_triple(vreq, e->defaultVariantSetId, + var_oid, 9, 1)) no_data = 1; /* howmuch */ - if ((r = find_triple(vreq, defsetval, var1, 5, 5))) + if ((r = find_triple(vreq, e->defaultVariantSetId, + var_oid, 5, 5))) if (r->which == Z_Triple_integer) get_bytes = *r->value.integer; if (!show_variantlist) - match_triple (dh, vreq, defsetval, var1, c); + match_triple(dh, vreq, e->defaultVariantSetId, + var_oid, c); } mark_subtree(c, show_variantlist, no_data, get_bytes, vreq, select_flag); diff --git a/data1/d1_espec.c b/data1/d1_espec.c index ac43e3f..4c64840 100644 --- a/data1/d1_espec.c +++ b/data1/d1_espec.c @@ -1,4 +1,4 @@ -/* $Id: d1_espec.c,v 1.13 2007-01-15 15:10:14 adam Exp $ +/* $Id: d1_espec.c,v 1.14 2007-04-16 08:44:31 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -29,20 +29,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include +#include static Z_Variant *read_variant(int argc, char **argv, NMEM nmem, const char *file, int lineno) { Z_Variant *r = (Z_Variant *)nmem_malloc(nmem, sizeof(*r)); - oident var1; int i; - int oid[OID_SIZE]; - - var1.proto = PROTO_Z3950; - var1.oclass = CLASS_VARSET; - var1.value = VAL_VAR1; - r->globalVariantSetId = odr_oiddup_nmem(nmem, oid_ent_to_oid(&var1, oid)); + r->globalVariantSetId = odr_oiddup_nmem(nmem, yaz_oid_variant1()); if (argc) r->triples = (Z_Triple **)nmem_malloc(nmem, sizeof(Z_Triple*) * argc); else diff --git a/data1/d1_expout.c b/data1/d1_expout.c index bd940d7..3757f28 100644 --- a/data1/d1_expout.c +++ b/data1/d1_expout.c @@ -1,4 +1,4 @@ -/* $Id: d1_expout.c,v 1.9 2007-01-15 15:10:14 adam Exp $ +/* $Id: d1_expout.c,v 1.10 2007-04-16 08:44:31 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -30,6 +30,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include +#include +#include #include typedef struct { @@ -113,31 +115,15 @@ static bool_t *f_bool(ExpHandle *eh, data1_node *c) static Odr_oid *f_oid(ExpHandle *eh, data1_node *c, oid_class oclass) { char oidstr[64]; - int oid_this[20]; - oid_value value_for_this; c = c->child; if (!is_data_tag (eh, c) || c->u.data.len > 63) return 0; - sprintf(oidstr, "%.*s", c->u.data.len, c->u.data.data); - value_for_this = oid_getvalbyname(oidstr); - if (value_for_this == VAL_NONE) - { - Odr_oid *oid = odr_getoidbystr(eh->o, oidstr); - assert (oid); - return oid; - } - else - { - struct oident ident; + yaz_snprintf(oidstr, sizeof(oidstr)-1, + "%.*s", c->u.data.len, c->u.data.data); - ident.oclass = oclass; - ident.proto = PROTO_Z3950; - ident.value = value_for_this; - - oid_ent_to_oid (&ident, oid_this); - } - return odr_oiddup (eh->o, oid_this); + return yaz_string_to_oid_odr(yaz_oid_std(), + CLASS_GENERAL, oidstr, eh->o); } static Z_IntUnit *f_intunit(ExpHandle *eh, data1_node *c) diff --git a/data1/d1_map.c b/data1/d1_map.c index b92ad0a..997b9cb 100644 --- a/data1/d1_map.c +++ b/data1/d1_map.c @@ -1,4 +1,4 @@ -/* $Id: d1_map.c,v 1.15 2007-01-15 15:10:14 adam Exp $ +/* $Id: d1_map.c,v 1.16 2007-04-16 08:44:31 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include +#include #include #include #include @@ -45,7 +45,7 @@ data1_maptab *data1_read_maptab (data1_handle dh, const char *file) return 0; res->name = 0; - res->target_absyn_ref = VAL_NONE; + res->oid = 0; res->map = 0; mapp = &res->map; res->next = 0; @@ -59,8 +59,9 @@ data1_maptab *data1_read_maptab (data1_handle dh, const char *file) file, lineno); continue; } - if ((res->target_absyn_ref = oid_getvalbyname(argv[1])) - == VAL_NONE) + res->oid = yaz_string_to_oid_nmem(yaz_oid_std(), + CLASS_RECSYN, argv[1], mem); + if (!res->oid) { yaz_log(YLOG_WARN, "%s:%d: Unknown reference '%s'", file, lineno, argv[1]); diff --git a/data1/d1_marc.c b/data1/d1_marc.c index a9a5ed7..05fbb76 100644 --- a/data1/d1_marc.c +++ b/data1/d1_marc.c @@ -1,4 +1,4 @@ -/* $Id: d1_marc.c,v 1.17 2007-01-15 15:10:14 adam Exp $ +/* $Id: d1_marc.c,v 1.18 2007-04-16 08:44:31 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include +#include #include #include #include @@ -47,7 +47,7 @@ data1_marctab *data1_read_marctab (data1_handle dh, const char *file) return 0; res->name = 0; - res->reference = VAL_NONE; + res->oid = 0; res->next = 0; res->length_data_entry = 4; res->length_starting = 5; @@ -81,7 +81,10 @@ data1_marctab *data1_read_marctab (data1_handle dh, const char *file) *argv); continue; } - if ((res->reference = oid_getvalbyname(argv[1])) == VAL_NONE) + res->oid = yaz_string_to_oid_nmem(yaz_oid_std(), + CLASS_TAGSET, argv[1], + mem); + if (!res->oid) { yaz_log(YLOG_WARN, "%s:%d: Unknown tagset reference '%s'", file, lineno, argv[1]); diff --git a/data1/d1_read.c b/data1/d1_read.c index 8247e62..0db4c89 100644 --- a/data1/d1_read.c +++ b/data1/d1_read.c @@ -1,4 +1,4 @@ -/* $Id: d1_read.c,v 1.24 2007-03-20 22:07:35 adam Exp $ +/* $Id: d1_read.c,v 1.25 2007-04-16 08:44:31 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -174,6 +174,7 @@ data1_node *data1_mk_root (data1_handle dh, NMEM nmem, const char *name) { data1_absyn *absyn = data1_get_absyn(dh, name, 1); data1_node *res; + if (!absyn) { yaz_log(YLOG_WARN, "Unable to acquire abstract syntax " "for '%s'", diff --git a/data1/d1_tagset.c b/data1/d1_tagset.c index 244f5df..b55dfaa 100644 --- a/data1/d1_tagset.c +++ b/data1/d1_tagset.c @@ -1,4 +1,4 @@ -/* $Id: d1_tagset.c,v 1.9 2007-01-15 15:10:14 adam Exp $ +/* $Id: d1_tagset.c,v 1.10 2007-04-16 08:44:31 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include +#include /* * We'll probably want to add some sort of hashed index to these lookup- @@ -108,7 +109,7 @@ data1_tagset *data1_empty_tagset (data1_handle dh) data1_tagset *res = (data1_tagset *) nmem_malloc(data1_nmem_get (dh), sizeof(*res)); res->name = 0; - res->reference = VAL_NONE; + res->oid = 0; res->tags = 0; res->type = 0; res->children = 0; @@ -211,7 +212,9 @@ data1_tagset *data1_read_tagset (data1_handle dh, const char *file, int type) continue; } name = argv[1]; - if ((res->reference = oid_getvalbyname(name)) == VAL_NONE) + res->oid = yaz_string_to_oid_nmem(yaz_oid_std(), + CLASS_TAGSET, name, mem); + if (!res->oid) { yaz_log(YLOG_WARN, "%s:%d: Unknown tagset ref '%s'", file, lineno, name); diff --git a/data1/d1_varset.c b/data1/d1_varset.c index bc0c8dd..f3632af 100644 --- a/data1/d1_varset.c +++ b/data1/d1_varset.c @@ -1,4 +1,4 @@ -/* $Id: d1_varset.c,v 1.10 2007-01-15 15:10:14 adam Exp $ +/* $Id: d1_varset.c,v 1.11 2007-04-16 08:44:31 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include +#include #include #include @@ -65,7 +65,7 @@ data1_varset *data1_read_varset (data1_handle dh, const char *file) char *argv[50],line[512]; res->name = 0; - res->reference = VAL_NONE; + res->oid = 0; res->classes = 0; if (!(f = data1_path_fopen(dh, file, "r"))) @@ -142,7 +142,9 @@ data1_varset *data1_read_varset (data1_handle dh, const char *file) file, lineno); continue; } - if ((res->reference = oid_getvalbyname(argv[1])) == VAL_NONE) + res->oid = yaz_string_to_oid_nmem(yaz_oid_std(), + CLASS_VARSET, argv[1], mem); + if (!res->oid) { yaz_log(YLOG_WARN, "%s:%d: Unknown reference '%s'", file, lineno, argv[1]); diff --git a/include/attrfind.h b/include/attrfind.h index 5e28e3b..daaa278 100644 --- a/include/attrfind.h +++ b/include/attrfind.h @@ -1,4 +1,4 @@ -/* $Id: attrfind.h,v 1.3 2007-01-15 20:08:24 adam Exp $ +/* $Id: attrfind.h,v 1.4 2007-04-16 08:44:31 adam Exp $ Copyright (C) 2005-2007 Index Data ApS @@ -25,7 +25,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include YAZ_BEGIN_CDECL @@ -41,10 +40,9 @@ void attr_init_APT(AttrType *src, Z_AttributesPlusTerm *zapt, int type); void attr_init_AttrList(AttrType *src, Z_AttributeList *list, int type); -int attr_find_ex(AttrType *src, oid_value *attributeSetP, +int attr_find_ex(AttrType *src, const int **attribute_set_oid, const char **string_value); -int attr_find(AttrType *src, oid_value *attributeSetP); - +int attr_find(AttrType *src, const int **attribute_set_oid); YAZ_END_CDECL diff --git a/include/d1_absyn.h b/include/d1_absyn.h index ff85ba6..f144773 100644 --- a/include/d1_absyn.h +++ b/include/d1_absyn.h @@ -1,4 +1,4 @@ -/* $Id: d1_absyn.h,v 1.11 2007-01-22 18:15:03 adam Exp $ +/* $Id: d1_absyn.h,v 1.12 2007-04-16 08:44:31 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -50,7 +50,7 @@ typedef struct data1_xpelement struct data1_absyn { char *name; - oid_value reference; + int *oid; data1_tagset *tagset; data1_varset *varset; data1_esetname *esetnames; diff --git a/include/idzebra/api.h b/include/idzebra/api.h index 8179b44..76690ae 100644 --- a/include/idzebra/api.h +++ b/include/idzebra/api.h @@ -1,4 +1,4 @@ -/* $Id: api.h,v 1.47 2007-03-14 11:48:31 adam Exp $ +/* $Id: api.h,v 1.48 2007-04-16 08:44:31 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -32,7 +32,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define IDZEBRA_API_H #include -#include #include #include #include @@ -56,7 +55,7 @@ typedef struct { int position; /* position of record in result set (1,2,..) */ char *buf; /* record buffer (void pointer really) */ int len; /* length */ - oid_value format; /* record syntax */ + const int *format; /* record syntax */ char *base; zint sysno; int score; @@ -221,7 +220,7 @@ YAZ_EXPORT ZEBRA_RES zebra_records_retrieve(ZebraHandle zh, ODR stream, const char *setname, Z_RecordComposition *comp, - oid_value input_format, + const int *input_format, int num_recs, ZebraRetrievalRecord *recs); /** \brief Deletes one or more resultsets @@ -288,7 +287,7 @@ ZEBRA_RES zebra_result_set_term_info(ZebraHandle zh, const char *setname, */ YAZ_EXPORT ZEBRA_RES zebra_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, - oid_value attributeset, + const int *attributeset, int *position, int *num_entries, ZebraScanEntry **entries, int *is_partial, diff --git a/include/idzebra/data1.h b/include/idzebra/data1.h index f41a770..b12d795 100644 --- a/include/idzebra/data1.h +++ b/include/idzebra/data1.h @@ -1,4 +1,4 @@ -/* $Id: data1.h,v 1.21 2007-01-15 20:08:24 adam Exp $ +/* $Id: data1.h,v 1.22 2007-04-16 08:44:31 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -26,7 +26,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include #include #include @@ -72,7 +71,7 @@ struct data1_attset_child { struct data1_attset { char *name; /* symbolic name */ - oid_value reference; /* external ID of attset */ + int *oid; /* attribute set OID */ data1_att *atts; /* attributes */ data1_attset_child *children; /* included attset */ data1_attset *next; /* next in cache */ @@ -112,7 +111,7 @@ typedef struct data1_mapunit typedef struct data1_maptab { char *name; - oid_value target_absyn_ref; + int *oid; /* target abstract syntax */ char *target_absyn_name; data1_mapunit *map; struct data1_maptab *next; @@ -146,7 +145,7 @@ typedef enum data1_datatype typedef struct data1_marctab { char *name; - oid_value reference; + int *oid; /* MARC OID */ char record_status[2]; char implementation_codes[5]; @@ -197,7 +196,7 @@ typedef struct data1_varclass typedef struct data1_varset { char *name; - oid_value reference; + int *oid; /* variant OID */ data1_varclass *classes; } data1_varset; @@ -230,7 +229,7 @@ struct data1_tagset { int type; /* type of tagset in current context */ char *name; /* symbolic name */ - oid_value reference; + int *oid; /* variant OID */ data1_tag *tags; /* tags defined by this set */ data1_tagset *children; /* children */ data1_tagset *next; /* sibling */ @@ -542,7 +541,8 @@ YAZ_EXPORT void data1_absyn_trav (data1_handle dh, void *handle, void (*fh)(data1_handle dh, void *h, data1_absyn *a)); -YAZ_EXPORT data1_attset *data1_attset_search_id (data1_handle dh, int id); +YAZ_EXPORT data1_attset *data1_attset_search_id (data1_handle dh, + const int *oid); YAZ_EXPORT char *data1_getNodeValue(data1_node* node, char* pTagPath); YAZ_EXPORT data1_node *data1_LookupNode(data1_node* node, char* pTagPath); diff --git a/include/idzebra/recctrl.h b/include/idzebra/recctrl.h index cd8e7a0..097af09 100644 --- a/include/idzebra/recctrl.h +++ b/include/idzebra/recctrl.h @@ -1,4 +1,4 @@ -/* $Id: recctrl.h,v 1.33 2007-03-14 14:16:14 adam Exp $ +/* $Id: recctrl.h,v 1.34 2007-04-16 08:44:31 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -25,7 +25,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include #include #include #include @@ -116,7 +115,7 @@ struct recRetrieveCtrl { /* Input parameters ... */ Res res; /* Resource pool */ ODR odr; /* ODR used to create response */ - oid_value input_format; /* Preferred record syntax */ + const int*input_format; /* Preferred record syntax OID */ Z_RecordComposition *comp; /* formatting instructions */ char *encoding; /* preferred character encoding */ zint localno; /* local id of record */ @@ -129,11 +128,11 @@ struct recRetrieveCtrl { zebra_snippets *doc_snippet; /* response */ - oid_value output_format; - void *rec_buf; + const int *output_format; /* output format OID */ + void * rec_buf; int rec_len; int diagnostic; - char *addinfo; + char * addinfo; }; typedef struct recType *RecType; diff --git a/index/alvis.c b/index/alvis.c index e168da3..77efef6 100644 --- a/index/alvis.c +++ b/index/alvis.c @@ -1,4 +1,4 @@ -/* $Id: alvis.c,v 1.15 2007-03-19 21:50:39 adam Exp $ +/* $Id: alvis.c,v 1.16 2007-04-16 08:44:31 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include +#include #include #include @@ -729,7 +730,7 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p) { p->diagnostic = YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS; } - else if (p->input_format == VAL_NONE || p->input_format == VAL_TEXT_XML) + else if (!p->input_format || !oid_oidcmp(p->input_format, yaz_oid_xml())) { xmlChar *buf_out; int len_out; @@ -740,13 +741,13 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p) else xmlDocDumpMemory(resDoc, &buf_out, &len_out); - p->output_format = VAL_TEXT_XML; + p->output_format = yaz_oid_xml(); p->rec_len = len_out; p->rec_buf = odr_malloc(p->odr, p->rec_len); memcpy(p->rec_buf, buf_out, p->rec_len); xmlFree(buf_out); } - else if (p->output_format == VAL_SUTRS) + else if (!oid_oidcmp(p->output_format, yaz_oid_sutrs())) { xmlChar *buf_out; int len_out; @@ -757,7 +758,7 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p) else xmlDocDumpMemory(resDoc, &buf_out, &len_out); - p->output_format = VAL_SUTRS; + p->output_format = yaz_oid_sutrs(); p->rec_len = len_out; p->rec_buf = odr_malloc(p->odr, p->rec_len); memcpy(p->rec_buf, buf_out, p->rec_len); diff --git a/index/attribute.c b/index/attribute.c index 2b55081..4fb5bb2 100644 --- a/index/attribute.c +++ b/index/attribute.c @@ -1,4 +1,4 @@ -/* $Id: attribute.c,v 1.28 2007-01-15 15:10:16 adam Exp $ +/* $Id: attribute.c,v 1.29 2007-04-16 08:44:31 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include "index.h" +#include static data1_att *getatt(data1_attset *p, int att) { @@ -45,7 +46,7 @@ static data1_att *getatt(data1_attset *p, int att) return 0; } -static int att_getentbyatt(ZebraHandle zi, oid_value set, int att, +static int att_getentbyatt(ZebraHandle zi, const int *set, int att, const char **name) { data1_att *r; @@ -69,7 +70,7 @@ ZEBRA_RES zebra_attr_list_get_ord(ZebraHandle zh, Z_AttributeList *attr_list, zinfo_index_category_t cat, int index_type, - oid_value curAttributeSet, + const int *curAttributeSet, int *ord) { int use_value = -1; @@ -123,7 +124,7 @@ ZEBRA_RES zebra_apt_get_ord(ZebraHandle zh, Z_AttributesPlusTerm *zapt, int index_type, const char *xpath_use, - oid_value curAttributeSet, + const int *curAttributeSet, int *ord) { ZEBRA_RES res = ZEBRA_OK; @@ -181,16 +182,18 @@ ZEBRA_RES zebra_sort_get_ord(ZebraHandle zh, { AttrType structure; int structure_value; + attr_init_AttrList(&structure, sortAttributes->list, 4); *numerical = 0; structure_value = attr_find(&structure, 0); if (structure_value == 109) *numerical = 1; - - if (zebra_attr_list_get_ord(zh, sortAttributes->list, - zinfo_index_category_sort, - -1 /* any index */, VAL_BIB1, ord)== ZEBRA_OK) + + if (zebra_attr_list_get_ord( + zh, sortAttributes->list, + zinfo_index_category_sort, + -1 /* any index */, yaz_oid_attset_bib1(), ord) == ZEBRA_OK) return ZEBRA_OK; return ZEBRA_FAIL; } diff --git a/index/index.h b/index/index.h index 32ded3e..07392a1 100644 --- a/index/index.h +++ b/index/index.h @@ -1,4 +1,4 @@ -/* $Id: index.h,v 1.196 2007-03-14 11:48:32 adam Exp $ +/* $Id: index.h,v 1.197 2007-04-16 08:44:31 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -261,7 +261,7 @@ void zebra_limit_for_rset(struct zebra_limit *zl, struct rset_key_control *zebra_key_control_create(ZebraHandle zh); ZEBRA_RES rpn_search_top(ZebraHandle zh, Z_RPNStructure *zs, - oid_value attributeSet, + const int *attributeSet, NMEM stream, NMEM rset_nmem, Z_SortKeySpecList *sort_sequence, int num_bases, char **basenames, @@ -271,7 +271,7 @@ ZEBRA_RES rpn_get_top_approx_limit(ZebraHandle zh, Z_RPNStructure *zs, zint *approx_limit); ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, - oid_value attributeset, + const int *attributeset, int num_bases, char **basenames, int *position, int *num_entries, ZebraScanEntry **list, int *is_partial, RSET limit_set); @@ -308,11 +308,11 @@ ZEBRA_RES resultSetRank(ZebraHandle zh, ZebraSet zebraSet, RSET rset, void resultSetInvalidate(ZebraHandle zh); int zebra_record_fetch(ZebraHandle zh, zint sysno, int score, - zebra_snippets *hit_snippet, ODR stream, - oid_value input_format, Z_RecordComposition *comp, - oid_value *output_format, char **rec_bufp, - int *rec_lenp, char **basenamep, - char **addinfo); + zebra_snippets *hit_snippet, ODR stream, + const int *input_format, Z_RecordComposition *comp, + const int **output_format, char **rec_bufp, + int *rec_lenp, char **basenamep, + char **addinfo); void extract_get_fname_tmp(ZebraHandle zh, char *fname, int no); @@ -379,14 +379,14 @@ ZEBRA_RES zebra_apt_get_ord(ZebraHandle zh, Z_AttributesPlusTerm *zapt, int index_type, const char *xpath_use, - oid_value curAttributeSet, + const int *curAttributeSet, int *ord); ZEBRA_RES zebra_attr_list_get_ord(ZebraHandle zh, Z_AttributeList *attr_list, zinfo_index_category_t cat, int index_type, - oid_value curAttributeSet, + const int *curAttributeSet, int *ord); ZEBRA_RES zebra_sort_get_ord(ZebraHandle zh, diff --git a/index/mod_dom.c b/index/mod_dom.c index 1832b05..ea09c31 100644 --- a/index/mod_dom.c +++ b/index/mod_dom.c @@ -1,4 +1,4 @@ -/* $Id: mod_dom.c,v 1.34 2007-04-07 22:18:46 adam Exp $ +/* $Id: mod_dom.c,v 1.35 2007-04-16 08:44:31 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -43,6 +43,7 @@ #include #include +#include /* DOM filter style indexing */ #define ZEBRA_DOM_NS "http://indexdata.com/zebra-2.0" @@ -1387,7 +1388,7 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p) { p->diagnostic = YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS; } - else if (p->input_format == VAL_NONE || p->input_format == VAL_TEXT_XML) + else if (!p->input_format || !oid_oidcmp(p->input_format, yaz_oid_xml())) { xmlChar *buf_out; int len_out; @@ -1397,13 +1398,13 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p) else xmlDocDumpMemory(doc, &buf_out, &len_out); - p->output_format = VAL_TEXT_XML; + p->output_format = yaz_oid_xml(); p->rec_len = len_out; p->rec_buf = odr_malloc(p->odr, p->rec_len); memcpy(p->rec_buf, buf_out, p->rec_len); xmlFree(buf_out); } - else if (p->output_format == VAL_SUTRS) + else if (!oid_oidcmp(p->output_format, yaz_oid_sutrs())) { xmlChar *buf_out; int len_out; @@ -1413,7 +1414,7 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p) else xmlDocDumpMemory(doc, &buf_out, &len_out); - p->output_format = VAL_SUTRS; + p->output_format = yaz_oid_sutrs(); p->rec_len = len_out; p->rec_buf = odr_malloc(p->odr, p->rec_len); memcpy(p->rec_buf, buf_out, p->rec_len); diff --git a/index/recgrs.c b/index/recgrs.c index 3137760..862a4f3 100644 --- a/index/recgrs.c +++ b/index/recgrs.c @@ -1,4 +1,4 @@ -/* $Id: recgrs.c,v 1.16 2007-03-07 21:08:36 adam Exp $ +/* $Id: recgrs.c,v 1.17 2007-04-16 08:44:32 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include +#include #include #include @@ -883,19 +883,10 @@ static int dumpkeys(data1_node *n, struct recExtractCtrl *p, RecWord *wrd) int grs_extract_tree(struct recExtractCtrl *p, data1_node *n) { - oident oe; - int oidtmp[OID_SIZE]; RecWord wrd; - oe.proto = PROTO_Z3950; - oe.oclass = CLASS_SCHEMA; - if (n->u.root.absyn) - { - oe.value = n->u.root.absyn->reference; - - if ((oid_ent_to_oid (&oe, oidtmp))) - (*p->schemaAdd)(p, oidtmp); - } + if (n->u.root.absyn && n->u.root.absyn->oid) + (*p->schemaAdd)(p, n->u.root.absyn->oid); (*p->init)(p, &wrd); /* data1_pr_tree(p->dh, n, stdout); */ @@ -909,8 +900,6 @@ static int grs_extract_sub(void *clientData, struct recExtractCtrl *p, { data1_node *n; struct grs_read_info gri; - oident oe; - int oidtmp[OID_SIZE]; RecWord wrd; gri.stream = p->stream; @@ -921,18 +910,8 @@ static int grs_extract_sub(void *clientData, struct recExtractCtrl *p, n = (*grs_read)(&gri); if (!n) return RECCTRL_EXTRACT_EOF; - oe.proto = PROTO_Z3950; - oe.oclass = CLASS_SCHEMA; -#if 0 - if (!n->u.root.absyn) - return RECCTRL_EXTRACT_ERROR; -#endif - if (n->u.root.absyn) - { - oe.value = n->u.root.absyn->reference; - if ((oid_ent_to_oid (&oe, oidtmp))) - (*p->schemaAdd)(p, oidtmp); - } + if (n->u.root.absyn && n->u.root.absyn->oid) + (*p->schemaAdd)(p, n->u.root.absyn->oid); data1_concat_text(p->dh, mem, n); /* ensure our data1 tree is UTF-8 */ @@ -1099,8 +1078,10 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, NMEM mem; struct grs_read_info gri; const char *tagname; + const int *xml_oid = yaz_oid_xml(); + const int *grs1_oid = yaz_oid_grs1(); - int requested_schema = VAL_NONE; + const int *requested_schema = 0; data1_marctab *marctab; int dummy; @@ -1162,8 +1143,14 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, dnew->u.data.len = strlen(dnew->u.data.data); } - if (p->input_format == VAL_TEXT_XML) - zebra_xml_metadata (p, top, mem); + if (!p->input_format) + { /* SUTRS is default input_format */ + p->input_format = yaz_oid_sutrs(); + } + assert(p->input_format); + + if (!oid_oidcmp(p->input_format, xml_oid)) + zebra_xml_metadata (p, top, mem); #if 0 data1_pr_tree (p->dh, node, stdout); @@ -1173,19 +1160,18 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, p->comp->u.complex->generic->which == Z_Schema_oid && p->comp->u.complex->generic->schema.oid) { - oident *oe = oid_getentbyoid (p->comp->u.complex->generic->schema.oid); - if (oe) - requested_schema = oe->value; + requested_schema = p->comp->u.complex->generic->schema.oid; } /* If schema has been specified, map if possible, then check that * we got the right one */ - if (requested_schema != VAL_NONE) + if (requested_schema) { yaz_log(YLOG_DEBUG, "grs_retrieve: schema mapping"); for (map = node->u.root.absyn->maptabs; map; map = map->next) { - if (map->target_absyn_ref == requested_schema) + // if (map->target_absyn_ref == requested_schema) + if (!oid_oidcmp(map->oid, requested_schema)) { onode = node; if (!(node = data1_map_record(p->dh, onode, map, mem))) @@ -1197,10 +1183,10 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, break; } } - if (node->u.root.absyn && - requested_schema != node->u.root.absyn->reference) + if (node->u.root.absyn + && oid_oidcmp(requested_schema, node->u.root.absyn->oid)) { - p->diagnostic = 238; + p->diagnostic = YAZ_BIB1_RECORD_NOT_AVAILABLE_IN_REQUESTED_SYNTAX; nmem_destroy (mem); return 0; } @@ -1214,7 +1200,7 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, if (node->u.root.absyn) for (map = node->u.root.absyn->maptabs; map; map = map->next) { - if (map->target_absyn_ref == p->input_format) + if (!oid_oidcmp(map->oid, p->input_format)) { onode = node; if (!(node = data1_map_record(p->dh, onode, map, mem))) @@ -1227,40 +1213,18 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, } } yaz_log(YLOG_DEBUG, "grs_retrieve: schemaIdentifier"); - if (node->u.root.absyn && - node->u.root.absyn->reference != VAL_NONE && - p->input_format == VAL_GRS1) + if (node->u.root.absyn && node->u.root.absyn->oid + && !oid_oidcmp(p->input_format, grs1_oid)) { - 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_ent_to_oid (&oe, oidtmp))) - { - char tmp[128]; - data1_handle dh = p->dh; - char *p = tmp; - int *ii; - - for (ii = oid; *ii >= 0; ii++) - { - if (p != tmp) - *(p++) = '.'; - sprintf(p, "%d", *ii); - p += strlen(p); - } - if ((dnew = data1_mk_tag_data_wd(dh, top, - "schemaIdentifier", mem))) - { - dnew->u.data.what = DATA1I_oid; - dnew->u.data.data = (char *) nmem_malloc(mem, p - tmp); - memcpy(dnew->u.data.data, tmp, p - tmp); - dnew->u.data.len = p - tmp; - } + char oid_str[OID_STR_MAX]; + char *dot_str = oid_oid_to_dotstring(node->u.root.absyn->oid, oid_str); + + if (dot_str && (dnew = data1_mk_tag_data_wd(p->dh, top, + "schemaIdentifier", mem))) + { + dnew->u.data.what = DATA1I_oid; + dnew->u.data.data = (char *) nmem_strdup(mem, dot_str); + dnew->u.data.len = strlen(dot_str); } } @@ -1279,10 +1243,12 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, data1_pr_tree (p->dh, node, stdout); #endif yaz_log(YLOG_DEBUG, "grs_retrieve: transfer syntax mapping"); - switch (p->output_format = (p->input_format != VAL_NONE ? - p->input_format : VAL_SUTRS)) + + p->output_format = p->input_format; + + assert(p->input_format); + if (!oid_oidcmp(p->input_format, yaz_oid_xml())) { - case VAL_TEXT_XML: #if 0 data1_pr_tree (p->dh, node, stdout); #endif @@ -1293,97 +1259,103 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, if (!(p->rec_buf = data1_nodetoidsgml(p->dh, node, selected, &p->rec_len))) - p->diagnostic = 238; + p->diagnostic = YAZ_BIB1_RECORD_NOT_AVAILABLE_IN_REQUESTED_SYNTAX; else { char *new_buf = (char*) odr_malloc (p->odr, p->rec_len); memcpy (new_buf, p->rec_buf, p->rec_len); p->rec_buf = new_buf; } - break; - case VAL_GRS1: + } + else if (!oid_oidcmp(p->input_format, yaz_oid_grs1())) + { data1_iconv (p->dh, mem, node, "UTF-8", data1_get_encoding(p->dh, node)); dummy = 0; if (!(p->rec_buf = data1_nodetogr(p->dh, node, selected, p->odr, &dummy))) - p->diagnostic = 238; /* not available in requested syntax */ + p->diagnostic = YAZ_BIB1_RECORD_NOT_AVAILABLE_IN_REQUESTED_SYNTAX; else p->rec_len = -1; - break; - case VAL_EXPLAIN: + } + else if (!oid_oidcmp(p->input_format, yaz_oid_explain())) + { /* ensure our data1 tree is UTF-8 */ data1_iconv (p->dh, mem, node, "UTF-8", data1_get_encoding(p->dh, node)); if (!(p->rec_buf = data1_nodetoexplain(p->dh, node, selected, p->odr))) - p->diagnostic = 238; + p->diagnostic = YAZ_BIB1_RECORD_NOT_AVAILABLE_IN_REQUESTED_SYNTAX; else p->rec_len = -1; - break; - case VAL_SUMMARY: + } + else if (!oid_oidcmp(p->input_format, yaz_oid_summary())) + { /* ensure our data1 tree is UTF-8 */ data1_iconv (p->dh, mem, node, "UTF-8", data1_get_encoding(p->dh, node)); if (!(p->rec_buf = data1_nodetosummary(p->dh, node, selected, p->odr))) - p->diagnostic = 238; + p->diagnostic = YAZ_BIB1_RECORD_NOT_AVAILABLE_IN_REQUESTED_SYNTAX; else p->rec_len = -1; - break; - case VAL_SUTRS: + } + else if (!oid_oidcmp(p->input_format, yaz_oid_sutrs())) + { if (p->encoding) data1_iconv (p->dh, mem, node, p->encoding, data1_get_encoding(p->dh, node)); if (!(p->rec_buf = data1_nodetobuf(p->dh, node, selected, &p->rec_len))) - p->diagnostic = 238; + p->diagnostic = YAZ_BIB1_RECORD_NOT_AVAILABLE_IN_REQUESTED_SYNTAX; else { char *new_buf = (char*) odr_malloc (p->odr, p->rec_len); memcpy (new_buf, p->rec_buf, p->rec_len); p->rec_buf = new_buf; } - break; - case VAL_SOIF: + } + else if (!oid_oidcmp(p->input_format, yaz_oid_soif())) + { if (p->encoding) data1_iconv (p->dh, mem, node, p->encoding, data1_get_encoding(p->dh, node)); if (!(p->rec_buf = data1_nodetosoif(p->dh, node, selected, &p->rec_len))) - p->diagnostic = 238; + p->diagnostic = YAZ_BIB1_RECORD_NOT_AVAILABLE_IN_REQUESTED_SYNTAX; else { char *new_buf = (char*) odr_malloc (p->odr, p->rec_len); memcpy (new_buf, p->rec_buf, p->rec_len); p->rec_buf = new_buf; } - break; - default: + } + else + { 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 = 238; - break; - } - if (p->encoding) - data1_iconv (p->dh, mem, node, p->encoding, - data1_get_encoding(p->dh, node)); - if (!(p->rec_buf = data1_nodetomarc(p->dh, marctab, node, - selected, &p->rec_len))) - p->diagnostic = 238; - else - { - char *new_buf = (char*) odr_malloc (p->odr, p->rec_len); - memcpy (new_buf, p->rec_buf, p->rec_len); - p->rec_buf = new_buf; - } + p->diagnostic = YAZ_BIB1_RECORD_NOT_AVAILABLE_IN_REQUESTED_SYNTAX; + else + { + for (marctab = node->u.root.absyn->marc; marctab; + marctab = marctab->next) + if (marctab->oid && !oid_oidcmp(marctab->oid, p->input_format)) + break; + if (!marctab) + p->diagnostic = YAZ_BIB1_RECORD_NOT_AVAILABLE_IN_REQUESTED_SYNTAX; + else + { + if (p->encoding) + data1_iconv (p->dh, mem, node, p->encoding, + data1_get_encoding(p->dh, node)); + if (!(p->rec_buf = data1_nodetomarc(p->dh, marctab, node, + selected, &p->rec_len))) + p->diagnostic = YAZ_BIB1_RECORD_NOT_AVAILABLE_IN_REQUESTED_SYNTAX; + else + { + char *new_buf = (char*) odr_malloc (p->odr, p->rec_len); + memcpy (new_buf, p->rec_buf, p->rec_len); + p->rec_buf = new_buf; + } + } + } } nmem_destroy(mem); return 0; diff --git a/index/rectext.c b/index/rectext.c index b33a897..39a806e 100644 --- a/index/rectext.c +++ b/index/rectext.c @@ -1,4 +1,4 @@ -/* $Id: rectext.c,v 1.4 2007-01-15 15:10:17 adam Exp $ +/* $Id: rectext.c,v 1.5 2007-04-16 08:44:32 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include +#include struct filter_info { char *sep; @@ -229,7 +230,7 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p) filter_ptr = p-filter_buf; } } - p->output_format = VAL_SUTRS; + p->output_format = yaz_oid_sutrs(); p->rec_buf = filter_buf; p->rec_len = filter_ptr; return 0; diff --git a/index/retrieve.c b/index/retrieve.c index 2627998..1d4f4ab 100644 --- a/index/retrieve.c +++ b/index/retrieve.c @@ -1,4 +1,4 @@ -/* $Id: retrieve.c,v 1.67 2007-03-19 21:50:39 adam Exp $ +/* $Id: retrieve.c,v 1.68 2007-04-16 08:44:32 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -35,7 +35,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "index.h" #include #include - +#include #define ZEBRA_XML_HEADER_STR "\n", @@ -198,9 +199,9 @@ int zebra_special_sort_fetch(ZebraHandle zh, zint sysno, ODR odr, wrbuf_printf(wrbuf, "\n"); wrbuf_printf(wrbuf, "\n"); } - else if (input_format == VAL_SUTRS) + else if (!oid_oidcmp(input_format, yaz_oid_sutrs())) { - *output_format = VAL_SUTRS; + *output_format = yaz_oid_sutrs(); wrbuf_printf(wrbuf, "%s %c %s\n", string_index, index_type, dst_buf); @@ -216,8 +217,8 @@ int zebra_special_sort_fetch(ZebraHandle zh, zint sysno, ODR odr, int zebra_special_index_fetch(ZebraHandle zh, zint sysno, ODR odr, Record rec, const char *elemsetname, - oid_value input_format, - oid_value *output_format, + const int *input_format, + const int **output_format, char **rec_bufp, int *rec_lenp) { const char *retrieval_index; @@ -231,11 +232,12 @@ int zebra_special_index_fetch(ZebraHandle zh, zint sysno, ODR odr, /* *rec_lenp = 0; */ /* only accept XML and SUTRS requests */ - if (input_format != VAL_TEXT_XML && input_format != VAL_SUTRS) + if (oid_oidcmp(input_format, yaz_oid_xml()) + && oid_oidcmp(input_format, yaz_oid_sutrs())) { yaz_log(YLOG_WARN, "unsupported format for element set zebra::%s", elemsetname); - *output_format = VAL_NONE; + *output_format = 0; return YAZ_BIB1_NO_SYNTAXES_AVAILABLE_FOR_THIS_REQUEST; } @@ -273,8 +275,7 @@ int zebra_special_index_fetch(ZebraHandle zh, zint sysno, ODR odr, if (!zebra_rec_keys_rewind(keys)) { - ret_code = - YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS; + ret_code = YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS; } else { @@ -283,16 +284,16 @@ int zebra_special_index_fetch(ZebraHandle zh, zint sysno, ODR odr, struct it_key key_in; WRBUF wrbuf = wrbuf_alloc(); - if (input_format == VAL_TEXT_XML) + if (!oid_oidcmp(input_format, yaz_oid_xml())) { - *output_format = VAL_TEXT_XML; + *output_format = input_format; wrbuf_printf(wrbuf, ZEBRA_XML_HEADER_STR " sysno=\"" ZINT_FORMAT "\"" " set=\"zebra::index%s/\">\n", sysno, elemsetname); } - else if (input_format == VAL_SUTRS) - *output_format = VAL_SUTRS; + else if (!oid_oidcmp(input_format, yaz_oid_sutrs())) + *output_format = input_format; while (zebra_rec_keys_read(keys, &str, &slen, &key_in)) { @@ -323,7 +324,8 @@ int zebra_special_index_fetch(ZebraHandle zh, zint sysno, ODR odr, zebra_term_untrans(zh, index_type, dst_buf, str); if (strlen(dst_buf)) { - if (input_format == VAL_TEXT_XML){ + if (!oid_oidcmp(input_format, yaz_oid_xml())) + { wrbuf_printf(wrbuf, " \n"); } - else if (input_format == VAL_SUTRS){ + else + { wrbuf_printf(wrbuf, "%s ", string_index); wrbuf_printf(wrbuf, "%c", index_type); @@ -343,8 +346,8 @@ int zebra_special_index_fetch(ZebraHandle zh, zint sysno, ODR odr, for (i = 1; i < key_in.len; i++) wrbuf_printf(wrbuf, " " ZINT_FORMAT, key_in.mem[i]); - - /* zebra_term_untrans(zh, index_type, dst_buf, str); */ + + /* zebra_term_untrans(zh, index_type, dst_buf, str); */ wrbuf_printf(wrbuf, " %s", dst_buf); wrbuf_printf(wrbuf, "\n"); @@ -354,7 +357,7 @@ int zebra_special_index_fetch(ZebraHandle zh, zint sysno, ODR odr, } } } - if (input_format == VAL_TEXT_XML) + if (!oid_oidcmp(input_format, yaz_oid_xml())) wrbuf_printf(wrbuf, "\n"); *rec_lenp = wrbuf_len(wrbuf); *rec_bufp = odr_malloc(odr, *rec_lenp); @@ -397,10 +400,10 @@ static void retrieve_puts_int(WRBUF wrbuf, const char *name, } int zebra_special_fetch(ZebraHandle zh, zint sysno, int score, ODR odr, - const char *elemsetname, - oid_value input_format, - oid_value *output_format, - char **rec_bufp, int *rec_lenp) + const char *elemsetname, + const int *input_format, + const int **output_format, + char **rec_bufp, int *rec_lenp) { Record rec; @@ -414,17 +417,17 @@ int zebra_special_fetch(ZebraHandle zh, zint sysno, int score, ODR odr, { int ret = 0; WRBUF wrbuf = wrbuf_alloc(); - if (input_format == VAL_SUTRS) + if (!oid_oidcmp(input_format, yaz_oid_sutrs())) { wrbuf_printf(wrbuf, ZINT_FORMAT, sysno); - *output_format = VAL_SUTRS; + *output_format = input_format; } - else if (input_format == VAL_TEXT_XML) + else if (!oid_oidcmp(input_format, yaz_oid_xml())) { wrbuf_printf(wrbuf, ZEBRA_XML_HEADER_STR " sysno=\"" ZINT_FORMAT "\"/>\n", sysno); - *output_format = VAL_TEXT_XML; + *output_format = input_format; } *rec_lenp = wrbuf_len(wrbuf); if (*rec_lenp) @@ -472,7 +475,8 @@ int zebra_special_fetch(ZebraHandle zh, zint sysno, int score, ODR odr, } /* only accept XML and SUTRS requests from now */ - if (input_format != VAL_TEXT_XML && input_format != VAL_SUTRS) + if (oid_oidcmp(input_format, yaz_oid_xml()) + && oid_oidcmp(input_format, yaz_oid_sutrs())) { yaz_log(YLOG_WARN, "unsupported format for element set zebra::%s", elemsetname); @@ -487,9 +491,9 @@ int zebra_special_fetch(ZebraHandle zh, zint sysno, int score, ODR odr, WRBUF wrbuf = wrbuf_alloc(); RecordAttr *recordAttr = rec_init_attr(zh->reg->zei, rec); - if (input_format == VAL_TEXT_XML) + if (!oid_oidcmp(input_format, yaz_oid_xml())) { - *output_format = VAL_TEXT_XML; + *output_format = input_format; wrbuf_printf(wrbuf, ZEBRA_XML_HEADER_STR " sysno=\"" ZINT_FORMAT "\"", sysno); @@ -507,9 +511,9 @@ int zebra_special_fetch(ZebraHandle zh, zint sysno, int score, ODR odr, recordAttr->recordSize, elemsetname); } - else if (input_format == VAL_SUTRS) + else if (!oid_oidcmp(input_format, yaz_oid_sutrs())) { - *output_format = VAL_SUTRS; + *output_format = input_format; wrbuf_printf(wrbuf, "sysno " ZINT_FORMAT "\n", sysno); retrieve_puts_str(wrbuf, "base", rec->info[recInfo_databaseName]); retrieve_puts_str(wrbuf, "file", rec->info[recInfo_filename]); @@ -556,8 +560,8 @@ int zebra_special_fetch(ZebraHandle zh, zint sysno, int score, ODR odr, int zebra_record_fetch(ZebraHandle zh, zint sysno, int score, zebra_snippets *hit_snippet, ODR odr, - oid_value input_format, Z_RecordComposition *comp, - oid_value *output_format, + const int *input_format, Z_RecordComposition *comp, + const int **output_format, char **rec_bufp, int *rec_lenp, char **basenamep, char **addinfo) { diff --git a/index/rpnscan.c b/index/rpnscan.c index 1e54721..be4e765 100644 --- a/index/rpnscan.c +++ b/index/rpnscan.c @@ -1,4 +1,4 @@ -/* $Id: rpnscan.c,v 1.6 2007-03-19 21:50:39 adam Exp $ +/* $Id: rpnscan.c,v 1.7 2007-04-16 08:44:32 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -37,6 +37,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include +#include #define RPN_MAX_ORDS 32 @@ -376,7 +377,7 @@ struct scan_info { }; ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, - oid_value attributeset, + const int *attributeset, int num_bases, char **basenames, int *position, int *num_entries, ZebraScanEntry **list, int *is_partial, RSET limit_set) @@ -396,8 +397,8 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, *list = 0; *is_partial = 0; - if (attributeset == VAL_NONE) - attributeset = VAL_BIB1; + if (!attributeset) + attributeset = yaz_oid_attset_bib1(); if (!limit_set) /* no limit set given already */ { @@ -426,8 +427,8 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, } } - yaz_log(YLOG_DEBUG, "position = %d, num = %d set=%d", - *position, *num_entries, attributeset); + yaz_log(YLOG_DEBUG, "position = %d, num = %d", + *position, *num_entries); if (zebra_maps_attr(zh->reg->zebra_maps, zapt, &index_type, &search_type, rank_type, &complete_flag, &sort_flag)) diff --git a/index/rpnsearch.c b/index/rpnsearch.c index aaae58a..28a6670 100644 --- a/index/rpnsearch.c +++ b/index/rpnsearch.c @@ -1,4 +1,4 @@ -/* $Id: rpnsearch.c,v 1.10 2007-03-19 21:50:39 adam Exp $ +/* $Id: rpnsearch.c,v 1.11 2007-04-16 08:44:32 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -703,7 +703,7 @@ void string_rel_add_char(char **term_p, const char *src, int *indx) */ static int string_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char **term_sub, char *term_dict, - oid_value attributeSet, + const int *attributeSet, int reg_type, int space_split, char *term_dst, int *error_code) { @@ -897,7 +897,7 @@ static int string_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt, static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char **term_sub, - oid_value attributeSet, NMEM stream, + const int *attributeSet, NMEM stream, struct grep_info *grep_info, int reg_type, int complete_flag, int num_bases, char **basenames, @@ -955,7 +955,7 @@ static ZEBRA_RES term_limits_APT(ZebraHandle zh, static ZEBRA_RES term_trunc(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char **term_sub, - oid_value attributeSet, NMEM stream, + const int *attributeSet, NMEM stream, struct grep_info *grep_info, int reg_type, int complete_flag, int num_bases, char **basenames, @@ -995,7 +995,7 @@ static ZEBRA_RES term_trunc(ZebraHandle zh, static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char **term_sub, - oid_value attributeSet, NMEM stream, + const int *attributeSet, NMEM stream, struct grep_info *grep_info, int reg_type, int complete_flag, int num_bases, char **basenames, @@ -1288,7 +1288,7 @@ static ZEBRA_RES grep_info_prepare(ZebraHandle zh, static ZEBRA_RES term_list_trunc(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char *termz, - oid_value attributeSet, + const int *attributeSet, NMEM stream, int reg_type, int complete_flag, const char *rank_type, @@ -1350,7 +1350,7 @@ static ZEBRA_RES term_list_trunc(ZebraHandle zh, static ZEBRA_RES rpn_search_APT_position(ZebraHandle zh, Z_AttributesPlusTerm *zapt, - oid_value attributeSet, + const int *attributeSet, int reg_type, int num_bases, char **basenames, NMEM rset_nmem, @@ -1442,7 +1442,7 @@ static ZEBRA_RES rpn_search_APT_position(ZebraHandle zh, static ZEBRA_RES rpn_search_APT_phrase(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char *termz_org, - oid_value attributeSet, + const int *attributeSet, NMEM stream, int reg_type, int complete_flag, const char *rank_type, @@ -1502,7 +1502,7 @@ static ZEBRA_RES rpn_search_APT_phrase(ZebraHandle zh, static ZEBRA_RES rpn_search_APT_or_list(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char *termz_org, - oid_value attributeSet, + const int *attributeSet, NMEM stream, int reg_type, int complete_flag, const char *rank_type, @@ -1569,7 +1569,7 @@ static ZEBRA_RES rpn_search_APT_or_list(ZebraHandle zh, static ZEBRA_RES rpn_search_APT_and_list(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char *termz_org, - oid_value attributeSet, + const int *attributeSet, NMEM stream, int reg_type, int complete_flag, const char *rank_type, @@ -1638,7 +1638,7 @@ static ZEBRA_RES rpn_search_APT_and_list(ZebraHandle zh, static int numeric_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char **term_sub, char *term_dict, - oid_value attributeSet, + const int *attributeSet, struct grep_info *grep_info, int *max_pos, int reg_type, @@ -1723,7 +1723,7 @@ static int numeric_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt, static ZEBRA_RES numeric_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char **term_sub, - oid_value attributeSet, NMEM stream, + const int *attributeSet, NMEM stream, struct grep_info *grep_info, int reg_type, int complete_flag, int num_bases, char **basenames, @@ -1800,7 +1800,7 @@ static ZEBRA_RES numeric_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, static ZEBRA_RES rpn_search_APT_numeric(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char *termz, - oid_value attributeSet, + const int *attributeSet, NMEM stream, int reg_type, int complete_flag, const char *rank_type, @@ -1880,7 +1880,7 @@ static ZEBRA_RES rpn_search_APT_numeric(ZebraHandle zh, static ZEBRA_RES rpn_search_APT_local(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char *termz, - oid_value attributeSet, + const int *attributeSet, NMEM stream, const char *rank_type, NMEM rset_nmem, RSET *rset, @@ -1919,7 +1919,7 @@ static ZEBRA_RES rpn_search_APT_local(ZebraHandle zh, } static ZEBRA_RES rpn_sort_spec(ZebraHandle zh, Z_AttributesPlusTerm *zapt, - oid_value attributeSet, NMEM stream, + const int *attributeSet, NMEM stream, Z_SortKeySpecList *sort_sequence, const char *rank_type, NMEM rset_nmem, @@ -1931,8 +1931,6 @@ static ZEBRA_RES rpn_sort_spec(ZebraHandle zh, Z_AttributesPlusTerm *zapt, AttrType sort_relation_type; Z_SortKeySpec *sks; Z_SortKey *sk; - int oid[OID_SIZE]; - oident oe; char termz[20]; attr_init_APT(&sort_relation_type, zapt, 7); @@ -1956,12 +1954,6 @@ static ZEBRA_RES rpn_sort_spec(ZebraHandle zh, Z_AttributesPlusTerm *zapt, i = 0; sprintf(termz, "%d", i); - oe.proto = PROTO_Z3950; - oe.oclass = CLASS_ATTSET; - oe.value = attributeSet; - if (!oid_ent_to_oid (&oe, oid)) - return ZEBRA_FAIL; - sks = (Z_SortKeySpec *) nmem_malloc(stream, sizeof(*sks)); sks->sortElement = (Z_SortElement *) nmem_malloc(stream, sizeof(*sks->sortElement)); @@ -1972,7 +1964,7 @@ static ZEBRA_RES rpn_sort_spec(ZebraHandle zh, Z_AttributesPlusTerm *zapt, sk->u.sortAttributes = (Z_SortAttributes *) nmem_malloc(stream, sizeof(*sk->u.sortAttributes)); - sk->u.sortAttributes->id = oid; + sk->u.sortAttributes->id = odr_oiddup_nmem(stream, attributeSet); sk->u.sortAttributes->list = zapt->attributes; sks->sortRelation = (int *) @@ -1997,11 +1989,11 @@ static ZEBRA_RES rpn_sort_spec(ZebraHandle zh, Z_AttributesPlusTerm *zapt, static int rpn_check_xpath(ZebraHandle zh, Z_AttributesPlusTerm *zapt, - oid_value attributeSet, + const int *attributeSet, struct xpath_location_step *xpath, int max, NMEM mem) { - oid_value curAttributeSet = attributeSet; + const int *curAttributeSet = attributeSet; AttrType use; const char *use_string = 0; @@ -2221,7 +2213,7 @@ ZEBRA_RES rpn_search_xpath(ZebraHandle zh, #define MAX_XPATH_STEPS 10 static ZEBRA_RES rpn_search_APT(ZebraHandle zh, Z_AttributesPlusTerm *zapt, - oid_value attributeSet, NMEM stream, + const int *attributeSet, NMEM stream, Z_SortKeySpecList *sort_sequence, int num_bases, char **basenames, NMEM rset_nmem, @@ -2346,7 +2338,7 @@ static ZEBRA_RES rpn_search_APT(ZebraHandle zh, Z_AttributesPlusTerm *zapt, } static ZEBRA_RES rpn_search_structure(ZebraHandle zh, Z_RPNStructure *zs, - oid_value attributeSet, + const int *attributeSet, NMEM stream, NMEM rset_nmem, Z_SortKeySpecList *sort_sequence, int num_bases, char **basenames, @@ -2386,7 +2378,7 @@ ZEBRA_RES rpn_get_top_approx_limit(ZebraHandle zh, Z_RPNStructure *zs, } ZEBRA_RES rpn_search_top(ZebraHandle zh, Z_RPNStructure *zs, - oid_value attributeSet, + const int *attributeSet, NMEM stream, NMEM rset_nmem, Z_SortKeySpecList *sort_sequence, int num_bases, char **basenames, @@ -2423,7 +2415,7 @@ ZEBRA_RES rpn_search_top(ZebraHandle zh, Z_RPNStructure *zs, } ZEBRA_RES rpn_search_structure(ZebraHandle zh, Z_RPNStructure *zs, - oid_value attributeSet, + const int *attributeSet, NMEM stream, NMEM rset_nmem, Z_SortKeySpecList *sort_sequence, int num_bases, char **basenames, diff --git a/index/safari.c b/index/safari.c index 96c2592..41cad30 100644 --- a/index/safari.c +++ b/index/safari.c @@ -1,4 +1,4 @@ -/* $Id: safari.c,v 1.5 2007-01-15 15:10:17 adam Exp $ +/* $Id: safari.c,v 1.6 2007-04-16 08:44:32 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - +#include #include #include #include @@ -262,7 +262,7 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p) filter_ptr = p-filter_buf; } } - p->output_format = VAL_SUTRS; + p->output_format = yaz_oid_sutrs(); p->rec_buf = filter_buf; p->rec_len = filter_ptr; return 0; diff --git a/index/zebraapi.c b/index/zebraapi.c index a1bb61d..825ccad 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.252 2007-03-19 21:50:39 adam Exp $ +/* $Id: zebraapi.c,v 1.253 2007-04-16 08:44:32 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -40,6 +40,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "orddict.h" #include #include +#include #define DEFAULT_APPROX_LIMIT 2000000000 @@ -1075,7 +1076,7 @@ ZEBRA_RES zebra_search_RPN(ZebraHandle zh, ODR o, Z_RPNQuery *query, ZEBRA_RES zebra_records_retrieve(ZebraHandle zh, ODR stream, const char *setname, Z_RecordComposition *comp, - oid_value input_format, int num_recs, + const int *input_format, int num_recs, ZebraRetrievalRecord *recs) { ZebraMetaRecord *poset; @@ -1119,7 +1120,7 @@ ZEBRA_RES zebra_records_retrieve(ZebraHandle zh, ODR stream, if (poset[i].term) { recs[i].errCode = 0; - recs[i].format = VAL_SUTRS; + recs[i].format = yaz_oid_sutrs(); recs[i].len = strlen(poset[i].term); recs[i].buf = poset[i].term; recs[i].base = poset[i].db; @@ -1169,7 +1170,7 @@ ZEBRA_RES zebra_records_retrieve(ZebraHandle zh, ODR stream, recs[i].buf = 0; /* no record and no error issued */ recs[i].len = 0; recs[i].errCode = 0; - recs[i].format = VAL_NONE; + recs[i].format = 0; recs[i].sysno = 0; } } @@ -1197,15 +1198,17 @@ ZEBRA_RES zebra_scan_PQF(ZebraHandle zh, ODR stream, const char *query, zh->errCode = YAZ_BIB1_SCAN_MALFORMED_SCAN; } else - res = zebra_scan(zh, stream, zapt, VAL_BIB1, + { + res = zebra_scan(zh, stream, zapt, yaz_oid_attset_bib1(), position, num_entries, entries, is_partial, setname); + } yaz_pqf_destroy (pqf_parser); return res; } ZEBRA_RES zebra_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, - oid_value attributeset, + const int *attributeset, int *position, int *num_entries, ZebraScanEntry **entries, int *is_partial, @@ -2280,7 +2283,7 @@ ZEBRA_RES zebra_search_PQF(ZebraHandle zh, const char *pqf_query, yaz_log(log_level, "zebra_search_PQF s=%s q=%s", setname, pqf_query); - query = p_query_rpn (odr, PROTO_Z3950, pqf_query); + query = p_query_rpn(odr, pqf_query); if (!query) { diff --git a/index/zebrash.c b/index/zebrash.c index 333b378..f726883 100644 --- a/index/zebrash.c +++ b/index/zebrash.c @@ -1,4 +1,4 @@ -/* $Id: zebrash.c,v 1.44 2007-03-19 21:50:39 adam Exp $ +/* $Id: zebrash.c,v 1.45 2007-04-16 08:44:32 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -45,6 +45,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include +#include #define MAX_NO_ARGS 32 #define MAX_OUT_BUFF 4096 @@ -440,17 +441,16 @@ static int cmd_show( char *args[], WRBUF outbuff) ODR odr; Z_RecordComposition *pcomp=0; int i; - oid_value format; - odr=odr_createmem(ODR_ENCODE); + odr = odr_createmem(ODR_ENCODE); recs= odr_malloc(odr,sizeof(ZebraRetrievalRecord)*nrecs); rc =z_RecordComposition(odr, &pcomp, 0,"recordComposition"); - format=oid_getvalbyname ("xml"); /*FIXME - let the user specify*/ + for (i=0;isearch_info->list[0]->which = Z_OtherInfo_externallyDefinedInfo; ext = odr_malloc (r->stream, sizeof(*ext)); r->search_info->list[0]->information.externallyDefinedInfo = ext; - ext->direct_reference = - yaz_oidval_to_z3950oid (r->stream, CLASS_USERINFO, VAL_SEARCHRES1); + ext->direct_reference = odr_oiddup(r->stream, yaz_oid_search_result_1()); ext->indirect_reference = 0; ext->descriptor = 0; ext->which = Z_External_searchResult1; @@ -314,7 +313,7 @@ int bend_search(void *handle, bend_search_rr *r) } -int bend_fetch (void *handle, bend_fetch_rr *r) +int bend_fetch(void *handle, bend_fetch_rr *r) { ZebraHandle zh = (ZebraHandle) handle; ZebraRetrievalRecord retrievalRecord; @@ -343,7 +342,7 @@ int bend_fetch (void *handle, bend_fetch_rr *r) r->basename = retrievalRecord.base; r->record = retrievalRecord.buf; r->len = retrievalRecord.len; - r->output_format = retrievalRecord.format; + r->output_format = odr_oiddup(r->stream, retrievalRecord.format); } return 0; } @@ -596,7 +595,6 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr) for (i = 0; notToKeep && i < notToKeep->num; i++) { Z_External *rec = notToKeep->elements[i]->record; - struct oident *oident = 0; Odr_oct *opaque_recid = 0; zint *sysno = 0; zint sysno_tmp; @@ -616,10 +614,14 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr) } if (rec->direct_reference) { - oident = oid_getentbyoid(rec->direct_reference); - if (oident) + char oid_name_str[OID_STR_MAX]; + const char *oid_name = + yaz_oid_to_string_buf( + rec->direct_reference, + 0, oid_name_str); + if (oid_name) yaz_log (YLOG_LOG, "record %d type %s", i, - oident->desc); + oid_name); } switch (rec->which) { @@ -643,13 +645,6 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr) rec->u.octet_aligned->len, rec->u.octet_aligned->buf); } - if (oident && oident->value != VAL_TEXT_XML - && oident->value != VAL_SUTRS) - { - rr->errcode = YAZ_BIB1_ES_IMMEDIATE_EXECUTION_FAILED; - rr->errstring = "only XML update supported"; - break; - } if (rec->which == Z_External_octet) { enum zebra_recctrl_action_t action = action_update; diff --git a/index/zinfo.c b/index/zinfo.c index 9086b6c..d678e67 100644 --- a/index/zinfo.c +++ b/index/zinfo.c @@ -1,4 +1,4 @@ -/* $Id: zinfo.c,v 1.77 2007-02-24 16:47:16 adam Exp $ +/* $Id: zinfo.c,v 1.78 2007-04-16 08:44:32 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -252,7 +252,7 @@ void zebraExplain_mergeOids (ZebraExplainInfo zei, data1_node *n, if (!ao) { ao = (zebAccessObject) nmem_malloc(zei->nmem, sizeof(*ao)); - ao->handle = NULL; + ao->handle = 0; ao->sysno = 1; ao->oid = oid; ao->next = *op; @@ -270,8 +270,8 @@ void zebraExplain_mergeAccessInfo(ZebraExplainInfo zei, data1_node *n, { *accessInfo = (zebAccessInfo) nmem_malloc(zei->nmem, sizeof(**accessInfo)); - (*accessInfo)->attributeSetIds = NULL; - (*accessInfo)->schemas = NULL; + (*accessInfo)->attributeSetIds = 0; + (*accessInfo)->schemas = 0; } else { @@ -356,20 +356,20 @@ ZebraExplainInfo zebraExplain_open( zei->updateFunc = updateFunc; zei->dirty = 0; zei->ordinalDatabase = 1; - zei->curDatabaseInfo = NULL; + zei->curDatabaseInfo = 0; zei->records = records; zei->nmem = nmem; zei->dh = dh; data1_get_absyn (zei->dh, "explain", DATA1_XPATH_INDEXING_DISABLE); - zei->attsets = NULL; + zei->attsets = 0; zei->res = res; zei->categoryList = (struct zebraCategoryListInfo *) nmem_malloc(zei->nmem, sizeof(*zei->categoryList)); zei->categoryList->sysno = 0; zei->categoryList->dirty = 0; - zei->categoryList->data1_categoryList = NULL; + zei->categoryList->data1_categoryList = 0; if ( atoi(res_get_def(res, "notimestamps", "0") )== 0) { @@ -436,9 +436,9 @@ ZebraExplainInfo zebraExplain_open( } for(; np; np = np->next) { - data1_node *node_name = NULL; - data1_node *node_id = NULL; - data1_node *node_aid = NULL; + data1_node *node_name = 0; + data1_node *node_id = 0; + data1_node *node_aid = 0; data1_node *np2; if (np->which != DATA1N_tag || strcmp(np->u.tag.tag, "database")) continue; @@ -459,7 +459,7 @@ ZebraExplainInfo zebraExplain_open( nmem_malloc(zei->nmem, sizeof(**zdip)); (*zdip)->readFlag = 1; (*zdip)->dirty = 0; - (*zdip)->data1_database = NULL; + (*zdip)->data1_database = 0; (*zdip)->recordCount = 0; (*zdip)->recordBytes = 0; zebraExplain_mergeAccessInfo (zei, 0, &(*zdip)->accessInfo); @@ -477,7 +477,7 @@ ZebraExplainInfo zebraExplain_open( node_aid->u.data.len); (*zdip)->attributeDetails->readFlag = 1; (*zdip)->attributeDetails->dirty = 0; - (*zdip)->attributeDetails->SUInfo = NULL; + (*zdip)->attributeDetails->SUInfo = 0; zdip = &(*zdip)->next; } @@ -501,7 +501,7 @@ ZebraExplainInfo zebraExplain_open( assert (np && np->which == DATA1N_data); zei->runNumber = atoi_zn(np->u.data.data, np->u.data.len); yaz_log(YLOG_DEBUG, "read runnumber=" ZINT_FORMAT, zei->runNumber); - *zdip = NULL; + *zdip = 0; } rec_free(&trec); } @@ -509,7 +509,7 @@ ZebraExplainInfo zebraExplain_open( { data1_node *node_tgtinfo; - *zdip = NULL; + *zdip = 0; if (writeFlag) { char *sgml_buf; @@ -603,12 +603,12 @@ static void zebraExplain_readAttributeDetails(ZebraExplainInfo zei, "attrlist"); for (np = node_list->child; np; np = np->next) { - data1_node *node_str = NULL; - data1_node *node_ordinal = NULL; - data1_node *node_type = NULL; - data1_node *node_cat = NULL; - data1_node *node_doc_occurrences = NULL; - data1_node *node_term_occurrences = NULL; + data1_node *node_str = 0; + data1_node *node_ordinal = 0; + data1_node *node_type = 0; + data1_node *node_cat = 0; + data1_node *node_doc_occurrences = 0; + data1_node *node_term_occurrences = 0; data1_node *np2; if (np->which != DATA1N_tag || strcmp(np->u.tag.tag, "attr")) @@ -703,7 +703,7 @@ static void zebraExplain_readAttributeDetails(ZebraExplainInfo zei, node_ordinal->u.data.len); zsuip = &(*zsuip)->next; } - *zsuip = NULL; + *zsuip = 0; zad->readFlag = 0; rec_free(&rec); } @@ -963,7 +963,7 @@ int zebraExplain_newDatabase (ZebraExplainInfo zei, const char *database, zdi->attributeDetails->readFlag = 0; zdi->attributeDetails->sysno = 0; zdi->attributeDetails->dirty = 1; - zdi->attributeDetails->SUInfo = NULL; + zdi->attributeDetails->SUInfo = 0; zdi->attributeDetails->data1_tree = data1_read_sgml (zei->dh, zei->nmem, "AttributeDetails\n" @@ -996,7 +996,7 @@ static void zebraExplain_writeCategoryList (ZebraExplainInfo zei, "TargetInfo", "DatabaseInfo", "AttributeDetails", - NULL + 0 }; assert (zcl); @@ -1235,11 +1235,10 @@ static void zebraExplain_writeAttributeSet (ZebraExplainInfo zei, Record drec; data1_node *node_root, *node_attinfo, *node_attributes, *node_atttype; data1_node *node_values; - struct oident *entp; - struct data1_attset *attset = NULL; - - if ((entp = oid_getentbyoid (o->oid))) - attset = data1_attset_search_id (zei->dh, entp->value); + struct data1_attset *attset = 0; + + if (o->oid) + attset = data1_attset_search_id (zei->dh, o->oid); #if ZINFO_DEBUG yaz_log(YLOG_LOG, "zebraExplain_writeAttributeSet %s", @@ -1522,7 +1521,7 @@ zebAccessObject zebraExplain_announceOid (ZebraExplainInfo zei, if (!ao) { ao = (zebAccessObject) nmem_malloc (zei->nmem, sizeof(*ao)); - ao->handle = NULL; + ao->handle = 0; ao->sysno = 0; ao->oid = odr_oiddup_nmem (zei->nmem, oid); ao->next = *op; @@ -1531,23 +1530,6 @@ zebAccessObject zebraExplain_announceOid (ZebraExplainInfo zei, return ao; } -void zebraExplain_addAttributeSet (ZebraExplainInfo zei, int set) -{ - oident oe; - int oid[OID_SIZE]; - - oe.proto = PROTO_Z3950; - oe.oclass = CLASS_ATTSET; - oe.value = (enum oid_value) set; - - if (oid_ent_to_oid (&oe, oid)) - { - zebraExplain_announceOid (zei, &zei->accessInfo->attributeSetIds, oid); - zebraExplain_announceOid (zei, &zei->curDatabaseInfo-> - accessInfo->attributeSetIds, oid); - } -} - struct zebSUInfoB *zebraExplain_add_sui_info(ZebraExplainInfo zei, zinfo_index_category_t cat, int index_type) diff --git a/index/zsets.c b/index/zsets.c index a81f4d8..fb997da 100644 --- a/index/zsets.c +++ b/index/zsets.c @@ -1,4 +1,4 @@ -/* $Id: zsets.c,v 1.120 2007-03-20 22:07:35 adam Exp $ +/* $Id: zsets.c,v 1.121 2007-04-16 08:44:32 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -100,7 +100,6 @@ static ZEBRA_RES resultSetSearch(ZebraHandle zh, NMEM nmem, NMEM rset_nmem, Z_RPNQuery *rpn, ZebraSet sset) { RSET rset = 0; - oident *attrset; Z_SortKeySpecList *sort_sequence; int sort_status, i; ZEBRA_RES res = ZEBRA_OK; @@ -114,11 +113,9 @@ static ZEBRA_RES resultSetSearch(ZebraHandle zh, NMEM nmem, NMEM rset_nmem, for (i = 0; inum_specs; i++) sort_sequence->specs[i] = 0; - attrset = oid_getentbyoid (rpn->attributeSetId); - rpn_get_top_approx_limit(zh, rpn->RPNStructure, &sset->approx_limit); - res = rpn_search_top(zh, rpn->RPNStructure, attrset->value, + res = rpn_search_top(zh, rpn->RPNStructure, rpn->attributeSetId, nmem, rset_nmem, sort_sequence, sset->num_bases, sset->basenames, diff --git a/test/api/t16.c b/test/api/t16.c index bf44b57..20930d5 100644 --- a/test/api/t16.c +++ b/test/api/t16.c @@ -1,4 +1,4 @@ -/* $Id: t16.c,v 1.9 2007-01-15 15:10:20 adam Exp $ +/* $Id: t16.c,v 1.10 2007-04-16 08:44:32 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -33,7 +33,7 @@ const char *myrec[] = { #define NUMBER_TO_FETCH_MAX 1000 static ZEBRA_RES fetch_first(ZebraHandle zh, const char *element_set, - oid_value format, ODR odr, + const int * format, ODR odr, const char **rec_buf, size_t *rec_len) { ZebraRetrievalRecord retrievalRecord[1]; @@ -61,7 +61,7 @@ static ZEBRA_RES fetch_first(ZebraHandle zh, const char *element_set, } static ZEBRA_RES fetch_first_compare(ZebraHandle zh, const char *element_set, - oid_value format, const char *cmp_rec) + const int *format, const char *cmp_rec) { const char *rec_buf = 0; size_t rec_len = 0; @@ -105,33 +105,33 @@ static void tst(int argc, char **argv) YAZ_CHECK_EQ(res, ZEBRA_OK); YAZ_CHECK_EQ(hits, 1); - YAZ_CHECK_EQ(fetch_first_compare(zh, "zebra::data", VAL_TEXT_XML, + YAZ_CHECK_EQ(fetch_first_compare(zh, "zebra::data", yaz_oid_xml(), "mismatch"), ZEBRA_FAIL); - YAZ_CHECK_EQ(fetch_first_compare(zh, "zebra::data", VAL_SUTRS, + YAZ_CHECK_EQ(fetch_first_compare(zh, "zebra::data", yaz_oid_sutrs(), myrec[0]), ZEBRA_OK); - YAZ_CHECK_EQ(fetch_first_compare(zh, "zebra::data", VAL_TEXT_XML, + YAZ_CHECK_EQ(fetch_first_compare(zh, "zebra::data", yaz_oid_xml(), myrec[0]), ZEBRA_OK); - YAZ_CHECK_EQ(fetch_first_compare(zh, "zebra::meta::sysno", VAL_SUTRS, + YAZ_CHECK_EQ(fetch_first_compare(zh, "zebra::meta::sysno", yaz_oid_sutrs(), "2"), ZEBRA_OK); - YAZ_CHECK_EQ(fetch_first_compare(zh, "zebra::meta::sysno", VAL_TEXT_XML, + YAZ_CHECK_EQ(fetch_first_compare(zh, "zebra::meta::sysno", yaz_oid_xml(), zebra_xml_sysno), ZEBRA_OK); - YAZ_CHECK_EQ(fetch_first_compare(zh, "zebra::meta", VAL_TEXT_XML, + YAZ_CHECK_EQ(fetch_first_compare(zh, "zebra::meta", yaz_oid_xml(), zebra_xml_meta), ZEBRA_OK); YAZ_CHECK_EQ(fetch_first_compare(zh, "zebra::index::title:p", - VAL_TEXT_XML, + yaz_oid_xml(), zebra_xml_index_title_p), ZEBRA_OK); YAZ_CHECK_EQ(fetch_first_compare(zh, "zebra::nonexistent", - VAL_TEXT_XML, ""), ZEBRA_OK); + yaz_oid_xml(), ""), ZEBRA_OK); YAZ_CHECK_EQ(fetch_first_compare(zh, "zebra::index::nonexistent", - VAL_TEXT_XML, ""), ZEBRA_OK); + yaz_oid_xml(), ""), ZEBRA_OK); YAZ_CHECK(tl_close_down(zh, zs)); } diff --git a/test/api/t4.c b/test/api/t4.c index d39a6e5..50657ba 100644 --- a/test/api/t4.c +++ b/test/api/t4.c @@ -1,4 +1,4 @@ -/* $Id: t4.c,v 1.22 2007-01-15 15:10:20 adam Exp $ +/* $Id: t4.c,v 1.23 2007-04-16 08:44:32 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -96,7 +96,7 @@ static void tst(int argc, char **argv) retrievalRecord[j].position = j+1; ret = zebra_records_retrieve(zh, odr_output, setname, 0, - VAL_TEXT_XML, number_to_fetch, + yaz_oid_xml(), number_to_fetch, retrievalRecord); if (ret != ZEBRA_OK) { diff --git a/test/api/testlib.c b/test/api/testlib.c index ad878d6..52c7ca7 100644 --- a/test/api/testlib.c +++ b/test/api/testlib.c @@ -1,4 +1,4 @@ -/* $Id: testlib.c,v 1.42 2007-01-15 15:10:20 adam Exp $ +/* $Id: testlib.c,v 1.43 2007-04-16 08:44:32 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -35,6 +35,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include +#include #include #include "testlib.h" @@ -323,7 +324,7 @@ int tl_ranking_query(ZebraHandle zh, char *query, odr_output = odr_createmem(ODR_ENCODE); rc = zebra_records_retrieve(zh, odr_output, setname, 0, - VAL_TEXT_XML, exphits, retrievalRecord); + yaz_oid_xml(), exphits, retrievalRecord); if (rc != ZEBRA_OK) ret = 0; else if (!strstr(retrievalRecord[0].buf, firstrec)) diff --git a/test/api/testlib.h b/test/api/testlib.h index cc35b20..1d3fcba 100644 --- a/test/api/testlib.h +++ b/test/api/testlib.h @@ -1,4 +1,4 @@ -/* $Id: testlib.h,v 1.24 2007-01-15 20:08:26 adam Exp $ +/* $Id: testlib.h,v 1.25 2007-04-16 08:44:32 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include +#include /** * tl_start_up : Does all the usual start functions diff --git a/util/attrfind.c b/util/attrfind.c index b7f26ab..631e35d 100644 --- a/util/attrfind.c +++ b/util/attrfind.c @@ -1,4 +1,4 @@ -/* $Id: attrfind.c,v 1.2 2007-01-15 15:10:26 adam Exp $ +/* $Id: attrfind.c,v 1.3 2007-04-16 08:44:33 adam Exp $ Copyright (C) 2005-2007 Index Data ApS @@ -42,7 +42,7 @@ void attr_init_AttrList(AttrType *src, Z_AttributeList *list, int type) src->minor = 0; } -int attr_find_ex(AttrType *src, oid_value *attributeSetP, +int attr_find_ex(AttrType *src, const int **attribute_set_oid, const char **string_value) { int num_attributes; @@ -59,25 +59,15 @@ int attr_find_ex(AttrType *src, oid_value *attributeSetP, { case Z_AttributeValue_numeric: ++(src->major); - if (element->attributeSet && attributeSetP) - { - oident *attrset; - - attrset = oid_getentbyoid(element->attributeSet); - *attributeSetP = attrset->value; - } + if (element->attributeSet && attribute_set_oid) + *attribute_set_oid = element->attributeSet; return *element->value.numeric; break; case Z_AttributeValue_complex: if (src->minor >= element->value.complex->num_list) break; - if (element->attributeSet && attributeSetP) - { - oident *attrset; - - attrset = oid_getentbyoid(element->attributeSet); - *attributeSetP = attrset->value; - } + if (element->attributeSet && attribute_set_oid) + *attribute_set_oid = element->attributeSet; if (element->value.complex->list[src->minor]->which == Z_StringOrNumeric_numeric) { @@ -106,9 +96,9 @@ int attr_find_ex(AttrType *src, oid_value *attributeSetP, return -1; } -int attr_find(AttrType *src, oid_value *attributeSetP) +int attr_find(AttrType *src, const int **attribute_set_id) { - return attr_find_ex(src, attributeSetP, 0); + return attr_find_ex(src, attribute_set_id, 0); } -- 1.7.10.4