X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzinfo.c;h=5c1b7df0b9f51b86b7ae776448820bfe2d2a99f6;hb=69da23537c6bb71ab948e079708bf8ea090de73f;hp=9e7bcd77b2fc50129efd25317b66efd27ebf494f;hpb=ef696645cc3b7e0f4027008d1dc589c0f0f90c1f;p=idzebra-moved-to-github.git diff --git a/index/zinfo.c b/index/zinfo.c index 9e7bcd7..5c1b7df 100644 --- a/index/zinfo.c +++ b/index/zinfo.c @@ -4,7 +4,14 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zinfo.c,v $ - * Revision 1.16 1999-05-26 07:49:13 adam + * 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 @@ -328,15 +335,14 @@ static Record createRecord (Records records, int *sysno) 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) { @@ -365,10 +371,18 @@ void zebraExplain_close (ZebraExplainInfo zei, int writeFlag, 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, @@ -448,15 +462,18 @@ ZebraExplainInfo zebraExplain_open ( struct zebDatabaseInfoB **zdip; time_t our_time; struct tm *tm; + NMEM nmem = nmem_create (); - logf (LOG_DEBUG, "zebraExplain_open wr=%d", writeFlag); - zei = (ZebraExplainInfo) 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; @@ -481,7 +498,12 @@ ZebraExplainInfo zebraExplain_open ( data1_node *node_tgtinfo, *node_zebra, *node_list, *np; zei->data1_target = read_sgml_rec (zei->dh, zei->nmem, trec); - + if (!zei->data1_target) + { + rec_rm (&trec); + nmem_destroy(zei->nmem); + return 0; + } #if ZINFO_DEBUG data1_pr_tree (zei->dh, zei->data1_target, stderr); #endif @@ -561,6 +583,7 @@ ZebraExplainInfo zebraExplain_open ( zei->ordinalSU = 1; zei->runNumber = 0; + *zdip = NULL; if (writeFlag) { char *sgml_buf; @@ -575,6 +598,11 @@ ZebraExplainInfo zebraExplain_open ( "Zebra\n" "\n" ); + if (!zei->data1_target) + { + nmem_destroy (zei->nmem); + return 0; + } node_tgtinfo = data1_search_tag (zei->dh, zei->data1_target->child, "targetInfo"); assert (node_tgtinfo); @@ -595,26 +623,31 @@ ZebraExplainInfo zebraExplain_open ( 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, "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; @@ -840,6 +873,8 @@ int zebraExplain_newDatabase (ZebraExplainInfo zei, const char *database, data1_read_sgml (zei->dh, zei->nmem, "DatabaseInfo\n" "\n"); + if (!zdi->data1_database) + return -2; node_dbinfo = data1_search_tag (zei->dh, zdi->data1_database->child, "databaseInfo");