X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzinfo.c;h=8971d89ec2cb58fbf2deb539534df83ad66a19bf;hb=0a667d16ee52f85592f6cb73ce9a3915409f1c7b;hp=b7d4386f08f37369e882f5bf87402578684d7f60;hpb=6684933a7dbf61609c4c4a1db1ebb8d80169ad05;p=idzebra-moved-to-github.git diff --git a/index/zinfo.c b/index/zinfo.c index b7d4386..8971d89 100644 --- a/index/zinfo.c +++ b/index/zinfo.c @@ -1,4 +1,4 @@ -/* $Id: zinfo.c,v 1.67 2006-06-22 15:07:20 adam Exp $ +/* $Id: zinfo.c,v 1.74 2006-11-27 10:09:48 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -15,9 +15,9 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Zebra; see the file LICENSE.zebra. If not, write to the -Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ #include @@ -53,7 +53,7 @@ struct zebSUInfoB { typedef struct zebAccessObjectB *zebAccessObject; struct zebAccessObjectB { void *handle; - SYSNO sysno; + zint sysno; Odr_oid *oid; zebAccessObject next; }; @@ -66,7 +66,7 @@ struct zebAccessInfoB { typedef struct { struct zebSUInfoB *SUInfo; - SYSNO sysno; + zint sysno; int dirty; int readFlag; data1_node *data1_tree; @@ -79,7 +79,7 @@ struct zebDatabaseInfoB { data1_node *data1_database; zint recordCount; /* records in db */ zint recordBytes; /* size of records */ - SYSNO sysno; /* sysno of database info */ + zint sysno; /* sysno of database info */ int readFlag; /* 1: read is needed when referenced; 0 if not */ int dirty; /* 1: database is dirty: write is needed */ struct zebDatabaseInfoB *next; @@ -94,7 +94,7 @@ struct zebraExplainAttset { struct zebraCategoryListInfo { int dirty; - SYSNO sysno; + zint sysno; data1_node *data1_categoryList; }; @@ -143,7 +143,7 @@ static void zebraExplain_writeCategoryList(ZebraExplainInfo zei, int key_flush); -static Record createRecord(Records records, SYSNO *sysno) +static Record createRecord(Records records, zint *sysno) { Record rec; if (*sysno) @@ -491,7 +491,7 @@ ZebraExplainInfo zebraExplain_open( yaz_log(YLOG_DEBUG, "read runnumber=" ZINT_FORMAT, zei->runNumber); *zdip = NULL; } - rec_rm(&trec); + rec_free(&trec); } else /* create initial targetInfo */ { @@ -543,7 +543,7 @@ ZebraExplainInfo zebraExplain_open( trec->size[recInfo_storeData] = sgml_len; rec_put(records, &trec); - rec_rm(&trec); + rec_free(&trec); } zebraExplain_newDatabase(zei, "IR-Explain-1", 0); @@ -693,7 +693,7 @@ static void zebraExplain_readAttributeDetails(ZebraExplainInfo zei, } *zsuip = NULL; zad->readFlag = 0; - rec_rm (&rec); + rec_free(&rec); } static void zebraExplain_readDatabase (ZebraExplainInfo zei, @@ -738,7 +738,7 @@ static void zebraExplain_readDatabase (ZebraExplainInfo zei, np->child->u.data.len); } zdi->readFlag = 0; - rec_rm (&rec); + rec_free(&rec); } int zebraExplain_removeDatabase(ZebraExplainInfo zei, void *update_handle) @@ -762,12 +762,12 @@ int zebraExplain_removeDatabase(ZebraExplainInfo zei, void *update_handle) rec = rec_get(zei->records, zad->sysno); (*zei->updateFunc)(zei->updateHandle, rec, 0); - rec_rm(&rec); + rec_free(&rec); } /* remove database record keys and delete it */ rec = rec_get (zei->records, zdi->sysno); (*zei->updateFunc)(zei->updateHandle, rec, 0); - rec_rm(&rec); + rec_free(&rec); /* remove from list */ *zdip = zdi->next; @@ -855,8 +855,7 @@ static void zebraExplain_updateAccessInfo (ZebraExplainInfo zei, data1_node *n, if (!c) { data1_pr_tree (zei->dh, n, stdout); - exit (0); - assert (c); + zebra_exit("zebraExplain_updateAccessInfo"); } if ((p = accessInfo->attributeSetIds)) @@ -964,6 +963,8 @@ int zebraExplain_newDatabase (ZebraExplainInfo zei, const char *database, zebraExplain_initCommonInfo (zei, node_adinfo); + data1_mk_tag_data_text(zei->dh, node_adinfo, "name", database, zei->nmem); + return 0; } @@ -977,7 +978,7 @@ static void zebraExplain_writeCategoryList (ZebraExplainInfo zei, int i; Record drec; data1_node *node_ci, *node_categoryList; - SYSNO sysno = 0; + zint sysno = 0; static char *category[] = { "CategoryList", "TargetInfo", @@ -1049,6 +1050,7 @@ static void zebraExplain_writeAttributeDetails (ZebraExplainInfo zei, zad->dirty = 0; #if ZINFO_DEBUG yaz_log(YLOG_LOG, "zebraExplain_writeAttributeDetails"); + data1_pr_tree(zei->dh, zad->data1_tree, stderr); #endif drec = createRecord (zei->records, &zad->sysno); @@ -1060,9 +1062,6 @@ static void zebraExplain_writeAttributeDetails (ZebraExplainInfo zei, "/attributeDetails"); zebraExplain_updateCommonInfo (zei, node_adinfo); - data1_mk_tag_data_text (zei->dh, node_adinfo, "name", - databaseName, zei->nmem); - /* extract *searchable* keys from it. We do this here, because record count, etc. is affected */ if (key_flush) @@ -1360,10 +1359,10 @@ int zebraExplain_lookup_attr_str(ZebraExplainInfo zei, assert (zei->curDatabaseInfo); for (zsui = &zei->curDatabaseInfo->attributeDetails->SUInfo; *zsui; zsui = &(*zsui)->next) - if ((*zsui)->info.index_type == index_type - && (*zsui)->info.cat == cat - && (*zsui)->info.which == ZEB_SU_STR - && !yaz_matchstr((*zsui)->info.u.str, str)) + if ( (index_type == -1 || (*zsui)->info.index_type == index_type) + && (*zsui)->info.cat == cat + && (*zsui)->info.which == ZEB_SU_STR + && !yaz_matchstr((*zsui)->info.u.str, str)) { struct zebSUInfoB *zsui_this = *zsui; @@ -1612,6 +1611,8 @@ RecordAttr *rec_init_attr (ZebraExplainInfo zei, Record rec) if (rec->info[recInfo_attr]) return (RecordAttr *) rec->info[recInfo_attr]; recordAttr = (RecordAttr *) xmalloc (sizeof(*recordAttr)); + + memset(recordAttr, '\0', sizeof(*recordAttr)); rec->info[recInfo_attr] = (char *) recordAttr; rec->size[recInfo_attr] = sizeof(*recordAttr);