/*
- * Copyright (C) 1994-1999, Index Data
+ * Copyright (C) 1994-2000, Index Data
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zinfo.c,v $
- * Revision 1.15 1999-01-25 13:47:54 adam
+ * Revision 1.21 2000-12-05 10:01:44 adam
+ * Fixed bug regarding user-defined attribute sets.
+ *
+ * Revision 1.20 2000/11/29 14:24:01 adam
+ * Script configure uses yaz pthreads options. Added locking for
+ * zebra_register_{lock,unlock}.
+ *
+ * Revision 1.19 2000/07/07 12:49:20 adam
+ * Optimized resultSetInsert{Rank,Sort}.
+ *
+ * Revision 1.18 2000/03/20 19:08:36 adam
+ * Added remote record import using Z39.50 extended services and Segment
+ * Requests.
+ *
+ * Revision 1.17 1999/07/14 10:53:51 adam
+ * Updated various routines to handle missing explain schema.
+ *
+ * Revision 1.16 1999/05/26 07:49:13 adam
+ * C++ compilation.
+ *
+ * Revision 1.15 1999/01/25 13:47:54 adam
* Fixed bug.
*
* Revision 1.14 1998/11/04 16:31:32 adam
const char *tag, NMEM nmem)
{
data1_node *partag = get_parent_tag(dh, at);
- data1_node *res = data1_mk_node (dh, nmem);
+ data1_node *res = data1_mk_node_type (dh, nmem, DATA1N_tag);
data1_element *e = NULL;
res->parent = at;
- res->which = DATA1N_tag;
res->u.tag.tag = data1_insert_string (dh, res, nmem, tag);
- res->u.tag.node_selected = 0;
- res->u.tag.make_variantlist = 0;
- res->u.tag.no_data_requested = 0;
- res->u.tag.get_bytes = -1;
if (partag)
e = partag->u.tag.element;
return rec;
}
-void zebraExplain_close (ZebraExplainInfo zei, int writeFlag,
- int (*updateH)(Record drec, data1_node *n))
+void zebraExplain_flush (ZebraExplainInfo zei, int writeFlag, void *handle)
{
- struct zebDatabaseInfoB *zdi;
-
- logf (LOG_DEBUG, "zebraExplain_close wr=%d", writeFlag);
+ zei->updateHandle = handle;
if (writeFlag)
{
+ struct zebDatabaseInfoB *zdi;
zebAccessObject o;
+
/* write each database info record */
for (zdi = zei->databaseInfo; zdi; zdi = zdi->next)
{
zdi->databaseName, 0);
}
zebraExplain_writeTarget (zei, 0);
-
}
+}
+
+void zebraExplain_close (ZebraExplainInfo zei, int writeFlag)
+{
+#if ZINFO_DEBUG
+ logf (LOG_LOG, "zebraExplain_close wr=%d", writeFlag);
+#endif
+ if (!zei)
+ return;
+ zebraExplain_flush (zei, writeFlag, zei->updateHandle);
nmem_destroy (zei->nmem);
- xfree (zei);
}
void zebraExplain_mergeOids (ZebraExplainInfo zei, data1_node *n,
}
if (!ao)
{
- ao = nmem_malloc (zei->nmem, sizeof(*ao));
+ ao = (zebAccessObject) nmem_malloc (zei->nmem, sizeof(*ao));
ao->handle = NULL;
ao->sysno = 1;
ao->oid = oid;
if (!n)
{
- *accessInfo = nmem_malloc (zei->nmem, sizeof(**accessInfo));
+ *accessInfo = (zebAccessInfo)
+ nmem_malloc (zei->nmem, sizeof(**accessInfo));
(*accessInfo)->attributeSetIds = NULL;
(*accessInfo)->schemas = NULL;
}
struct zebDatabaseInfoB **zdip;
time_t our_time;
struct tm *tm;
+ NMEM nmem = nmem_create ();
- logf (LOG_DEBUG, "zebraExplain_open wr=%d", writeFlag);
- zei = xmalloc (sizeof(*zei));
+#if ZINFO_DEBUG
+ logf (LOG_LOG, "zebraExplain_open wr=%d", writeFlag);
+#endif
+ zei = (ZebraExplainInfo) nmem_malloc (nmem, sizeof(*zei));
zei->updateHandle = updateHandle;
zei->updateFunc = updateFunc;
zei->dirty = 0;
zei->curDatabaseInfo = NULL;
zei->records = records;
- zei->nmem = nmem_create ();
+ zei->nmem = nmem;
zei->dh = dh;
zei->attsets = NULL;
zei->res = res;
- zei->categoryList = nmem_malloc (zei->nmem,
- sizeof(*zei->categoryList));
+ zei->categoryList = (struct zebraCategoryListInfo *)
+ nmem_malloc (zei->nmem, sizeof(*zei->categoryList));
zei->categoryList->sysno = 0;
zei->categoryList->dirty = 0;
zei->categoryList->data1_categoryList = NULL;
zdip = &zei->databaseInfo;
trec = rec_get (records, 1); /* get "root" record */
+ zei->ordinalSU = 1;
+ zei->runNumber = 0;
+
zebraExplain_mergeAccessInfo (zei, 0, &zei->accessInfo);
if (trec) /* targetInfo already exists ... */
{
data1_node *node_tgtinfo, *node_zebra, *node_list, *np;
zei->data1_target = read_sgml_rec (zei->dh, zei->nmem, trec);
-
+ if (!zei->data1_target || !zei->data1_target->u.root.absyn)
+ {
+ logf (LOG_FATAL, "Explain schema missing. Check profilePath");
+ nmem_destroy (zei->nmem);
+ return 0;
+ }
#if ZINFO_DEBUG
data1_pr_tree (zei->dh, zei->data1_target, stderr);
#endif
node_zebra = data1_search_tag (zei->dh, node_tgtinfo->child,
"zebraInfo");
- node_list = data1_search_tag (zei->dh, node_zebra->child,
- "databaseList");
- for (np = node_list->child; np; np = np->next)
+ np = 0;
+ if (node_zebra)
+ {
+ node_list = data1_search_tag (zei->dh, node_zebra->child,
+ "databaseList");
+ if (node_list)
+ np = node_list->child;
+ }
+ for (; np; np = np->next)
{
data1_node *node_name = NULL;
data1_node *node_id = NULL;
}
assert (node_id && node_name && node_aid);
- *zdip = nmem_malloc (zei->nmem, sizeof(**zdip));
-
+ *zdip = (struct zebDatabaseInfoB *)
+ nmem_malloc (zei->nmem, sizeof(**zdip));
(*zdip)->readFlag = 1;
(*zdip)->dirty = 0;
(*zdip)->data1_database = NULL;
(*zdip)->recordBytes = 0;
zebraExplain_mergeAccessInfo (zei, 0, &(*zdip)->accessInfo);
- (*zdip)->databaseName = nmem_malloc (zei->nmem,
- 1+node_name->u.data.len);
+ (*zdip)->databaseName = (char *)
+ nmem_malloc (zei->nmem, 1+node_name->u.data.len);
memcpy ((*zdip)->databaseName, node_name->u.data.data,
node_name->u.data.len);
(*zdip)->databaseName[node_name->u.data.len] = '\0';
(*zdip)->sysno = atoi_n (node_id->u.data.data,
node_id->u.data.len);
- (*zdip)->attributeDetails =
+ (*zdip)->attributeDetails = (zebAttributeDetails)
nmem_malloc (zei->nmem, sizeof(*(*zdip)->attributeDetails));
(*zdip)->attributeDetails->sysno = atoi_n (node_aid->u.data.data,
node_aid->u.data.len);
zdip = &(*zdip)->next;
}
- np = data1_search_tag (zei->dh, node_zebra->child,
- "ordinalSU");
- np = np->child;
- assert (np && np->which == DATA1N_data);
- zei->ordinalSU = atoi_n (np->u.data.data, np->u.data.len);
-
- np = data1_search_tag (zei->dh, node_zebra->child,
- "runNumber");
- np = np->child;
- assert (np && np->which == DATA1N_data);
- zei->runNumber = atoi_n (np->u.data.data, np->u.data.len);
- *zdip = NULL;
+ if (node_zebra)
+ {
+ np = data1_search_tag (zei->dh, node_zebra->child,
+ "ordinalSU");
+ np = np->child;
+ assert (np && np->which == DATA1N_data);
+ zei->ordinalSU = atoi_n (np->u.data.data, np->u.data.len);
+
+ np = data1_search_tag (zei->dh, node_zebra->child,
+ "runNumber");
+ np = np->child;
+ assert (np && np->which == DATA1N_data);
+ zei->runNumber = atoi_n (np->u.data.data, np->u.data.len);
+ *zdip = NULL;
+ }
rec_rm (&trec);
}
else /* create initial targetInfo */
{
data1_node *node_tgtinfo;
- zei->ordinalSU = 1;
- zei->runNumber = 0;
+ *zdip = NULL;
if (writeFlag)
{
char *sgml_buf;
"<multipleDBSearch>1</>\n"
"<nicknames><name>Zebra</></>\n"
"</></>\n" );
-
+ if (!zei->data1_target || !zei->data1_target->u.root.absyn)
+ {
+ logf (LOG_FATAL, "Explain schema missing. Check profilePath");
+ nmem_destroy (zei->nmem);
+ return 0;
+ }
node_tgtinfo = data1_search_tag (zei->dh, zei->data1_target->child,
"targetInfo");
assert (node_tgtinfo);
rec_strdup ("IR-Explain-1", &trec->size[recInfo_databaseName]);
sgml_buf = data1_nodetoidsgml(dh, zei->data1_target, 0, &sgml_len);
- trec->info[recInfo_storeData] = xmalloc (sgml_len);
+ trec->info[recInfo_storeData] = (char *) xmalloc (sgml_len);
memcpy (trec->info[recInfo_storeData], sgml_buf, sgml_len);
trec->size[recInfo_storeData] = sgml_len;
rec_put (records, &trec);
+ rec_rm (&trec);
+
}
- *zdip = NULL;
- rec_rm (&trec);
zebraExplain_newDatabase (zei, "IR-Explain-1", 0);
-
+
if (!zei->categoryList->dirty)
{
struct zebraCategoryListInfo *zcl = zei->categoryList;
data1_node *node_cl;
-
+
zcl->dirty = 1;
zcl->data1_categoryList =
data1_read_sgml (zei->dh, zei->nmem,
"<explain><categoryList>CategoryList\n"
- "/></>\n");
- node_cl = data1_search_tag (zei->dh,
- zcl->data1_categoryList->child,
- "categoryList");
- assert (node_cl);
- zebraExplain_initCommonInfo (zei, node_cl);
+ "</></>\n");
+
+ if (zcl->data1_categoryList)
+ {
+ assert (zcl->data1_categoryList->child);
+ node_cl = data1_search_tag (zei->dh,
+ zcl->data1_categoryList->child,
+ "categoryList");
+ assert (node_cl);
+ zebraExplain_initCommonInfo (zei, node_cl);
+ }
}
}
return zei;
assert (node_set && node_use && node_ordinal);
oid_str_len = node_set->u.data.len;
- if (oid_str_len >= sizeof(oid_str))
+ if (oid_str_len >= (int) sizeof(oid_str))
oid_str_len = sizeof(oid_str)-1;
memcpy (oid_str, node_set->u.data.data, oid_str_len);
oid_str[oid_str_len] = '\0';
-
- *zsuip = nmem_malloc (zei->nmem, sizeof(**zsuip));
+
+ *zsuip = (struct zebSUInfoB *)
+ nmem_malloc (zei->nmem, sizeof(**zsuip));
(*zsuip)->info.set = oid_getvalbyname (oid_str);
(*zsuip)->info.use = atoi_n (node_use->u.data.data,
{
zdi->recordCount = atoi_n (np->child->u.data.data,
np->child->u.data.len);
- }
+ }
zdi->readFlag = 0;
rec_rm (&rec);
}
if (zdi)
return -1;
/* it's new really. make it */
- zdi = nmem_malloc (zei->nmem, sizeof(*zdi));
+ zdi = (struct zebDatabaseInfoB *) nmem_malloc (zei->nmem, sizeof(*zdi));
zdi->next = zei->databaseInfo;
zei->databaseInfo = zdi;
zdi->sysno = 0;
data1_read_sgml (zei->dh, zei->nmem,
"<explain><databaseInfo>DatabaseInfo\n"
"</></>\n");
+ if (!zdi->data1_database)
+ return -2;
node_dbinfo = data1_search_tag (zei->dh, zdi->data1_database->child,
"databaseInfo");
zei->dirty = 1;
zei->curDatabaseInfo = zdi;
- zdi->attributeDetails =
+ zdi->attributeDetails = (zebAttributeDetails)
nmem_malloc (zei->nmem, sizeof(*zdi->attributeDetails));
zdi->attributeDetails->readFlag = 0;
zdi->attributeDetails->sysno = 0;
#if ZINFO_DEBUG
data1_pr_tree (zei->dh, node_categoryList, stderr);
#endif
- sgml_buf = data1_nodetoidsgml(zei->dh, node_categoryList,
- 0, &sgml_len);
- drec->info[recInfo_storeData] = xmalloc (sgml_len);
+ sgml_buf = data1_nodetoidsgml(zei->dh, node_categoryList, 0, &sgml_len);
+ drec->info[recInfo_storeData] = (char *) xmalloc (sgml_len);
memcpy (drec->info[recInfo_storeData], sgml_buf, sgml_len);
drec->size[recInfo_storeData] = sgml_len;
oe.proto = PROTO_Z3950;
oe.oclass = CLASS_ATTSET;
- oe.value = set_ordinal;
+ oe.value = (enum oid_value) set_ordinal;
if (oid_ent_to_oid (&oe, oid))
{
oident.proto = PROTO_Z3950;
oident.oclass = CLASS_ATTSET;
- oident.value = zsui->info.set;
+ oident.value = (enum oid_value) zsui->info.set;
oid_ent_to_oid (&oident, oid);
data1_add_tagdata_text (zei->dh, node_attr, "set",
#endif
sgml_buf = data1_nodetoidsgml(zei->dh, zad->data1_tree,
0, &sgml_len);
- drec->info[recInfo_storeData] = xmalloc (sgml_len);
+ drec->info[recInfo_storeData] = (char *) xmalloc (sgml_len);
memcpy (drec->info[recInfo_storeData], sgml_buf, sgml_len);
drec->size[recInfo_storeData] = sgml_len;
#endif
sgml_buf = data1_nodetoidsgml(zei->dh, zdi->data1_database,
0, &sgml_len);
- drec->info[recInfo_storeData] = xmalloc (sgml_len);
+ drec->info[recInfo_storeData] = (char *) xmalloc (sgml_len);
memcpy (drec->info[recInfo_storeData], sgml_buf, sgml_len);
drec->size[recInfo_storeData] = sgml_len;
data1_pr_tree (zei->dh, node_root, stderr);
#endif
sgml_buf = data1_nodetoidsgml(zei->dh, node_root, 0, &sgml_len);
- drec->info[recInfo_storeData] = xmalloc (sgml_len);
+ drec->info[recInfo_storeData] = (char *) xmalloc (sgml_len);
memcpy (drec->info[recInfo_storeData], sgml_buf, sgml_len);
drec->size[recInfo_storeData] = sgml_len;
#endif
sgml_buf = data1_nodetoidsgml(zei->dh, zei->data1_target,
0, &sgml_len);
- trec->info[recInfo_storeData] = xmalloc (sgml_len);
+ trec->info[recInfo_storeData] = (char *) xmalloc (sgml_len);
memcpy (trec->info[recInfo_storeData], sgml_buf, sgml_len);
trec->size[recInfo_storeData] = sgml_len;
break;
if (!ao)
{
- ao = nmem_malloc (zei->nmem, sizeof(*ao));
+ ao = (zebAccessObject) nmem_malloc (zei->nmem, sizeof(*ao));
ao->handle = NULL;
ao->sysno = 0;
ao->oid = odr_oiddup_nmem (zei->nmem, oid);
oe.proto = PROTO_Z3950;
oe.oclass = CLASS_ATTSET;
- oe.value = set;
+ oe.value = (enum oid_value) set;
if (oid_ent_to_oid (&oe, oid))
{
if (zsui->info.use == use && zsui->info.set == set)
return -1;
zebraExplain_addAttributeSet (zei, set);
- zsui = nmem_malloc (zei->nmem, sizeof(*zsui));
+ zsui = (struct zebSUInfoB *) nmem_malloc (zei->nmem, sizeof(*zsui));
zsui->next = zei->curDatabaseInfo->attributeDetails->SUInfo;
zei->curDatabaseInfo->attributeDetails->SUInfo = zsui;
zei->curDatabaseInfo->attributeDetails->dirty = 1;
if (rec->info[recInfo_attr])
return (RecordAttr *) rec->info[recInfo_attr];
- recordAttr = xmalloc (sizeof(*recordAttr));
+ recordAttr = (RecordAttr *) xmalloc (sizeof(*recordAttr));
rec->info[recInfo_attr] = (char *) recordAttr;
rec->size[recInfo_attr] = sizeof(*recordAttr);
static void att_loadset(void *p, const char *n, const char *name)
{
- data1_handle dh = p;
+ data1_handle dh = (data1_handle) p;
if (!data1_get_attset (dh, name))
logf (LOG_WARN, "Couldn't load attribute set %s", name);
}