X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzebraapi.c;h=5861a23b973570814fe94db70630c222a91259a0;hb=05b9b8ed020c5bfa48a913d6a2e2b50ddf1bab8e;hp=3ede0645105c959cc59dc3d144a780b1e9028c17;hpb=5437b50633032595afe6f87dc0f989bc92a5aea8;p=idzebra-moved-to-github.git diff --git a/index/zebraapi.c b/index/zebraapi.c index 3ede064..5861a23 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.140 2004-11-19 10:27:03 heikki Exp $ +/* $Id: zebraapi.c,v 1.143 2004-12-02 17:27:03 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -847,12 +847,13 @@ int zebra_search_RPN (ZebraHandle zh, ODR o, } int zebra_records_retrieve (ZebraHandle zh, ODR stream, - const char *setname, Z_RecordComposition *comp, - oid_value input_format, int num_recs, - ZebraRetrievalRecord *recs) + const char *setname, Z_RecordComposition *comp, + oid_value input_format, int num_recs, + ZebraRetrievalRecord *recs) { - ZebraPosSet poset; - int i, *pos_array, ret = 0; + ZebraMetaRecord *poset; + int i, ret = 0; + zint *pos_array; ASSERTZH; assert(stream); assert(setname); @@ -865,7 +866,7 @@ int zebra_records_retrieve (ZebraHandle zh, ODR stream, if (!zh->res) { zh->errCode = 30; - zh->errString = odr_strdup (stream, setname); + zh->errString = odr_strdup(stream, setname); return -1; } @@ -874,10 +875,10 @@ int zebra_records_retrieve (ZebraHandle zh, ODR stream, if (zebra_begin_read (zh)) return -1; - pos_array = (int *) xmalloc (num_recs * sizeof(*pos_array)); + pos_array = (zint *) xmalloc(num_recs * sizeof(*pos_array)); for (i = 0; i 0) + { + recs[i].buf = (char*) odr_malloc(stream, len); + memcpy(recs[i].buf, buf, len); + } + else + recs[i].buf = buf; recs[i].score=poset[i].score; recs[i].sysno=poset[i].sysno; } @@ -913,14 +922,14 @@ int zebra_records_retrieve (ZebraHandle zh, ODR stream, { char num_str[20]; - sprintf (num_str, "%d", pos_array[i]); + sprintf (num_str, ZINT_FORMAT, pos_array[i]); zh->errCode = 13; zh->errString = odr_strdup (stream, num_str); ret = -1; break; } } - zebraPosSetDestroy (zh, poset, num_recs); + zebra_meta_records_destroy(zh, poset, num_recs); } zebra_end_read (zh); xfree (pos_array); @@ -1945,94 +1954,17 @@ int zebra_set_shadow_enable (ZebraHandle zh, int value) return 0; } -/* almost the same as zebra_records_retrieve ... but how did it work? - I mean for multiple records ??? CHECK ??? */ +/* Used by Perl API.. Added the record buffer dup to zebra_records_retrieve + so that it's identicical to the original api_records_retrieve */ void api_records_retrieve (ZebraHandle zh, ODR stream, const char *setname, Z_RecordComposition *comp, oid_value input_format, int num_recs, ZebraRetrievalRecord *recs) { - ZebraPosSet poset; - int i, *pos_array; - ASSERTZH; - assert(stream); - assert(setname); - assert(comp); - assert(recs); - assert(num_recs>0); - yaz_log(log_level,"api_records_retrieve s=%s n=%d",setname,num_recs); - - if (!zh->res) - { - zh->errCode = 30; - zh->errString = odr_strdup (stream, setname); - return; - } - - zh->errCode = 0; - - if (zebra_begin_read (zh)) - return; - - pos_array = (int *) xmalloc (num_recs * sizeof(*pos_array)); - for (i = 0; ierrCode = 30; - zh->errString = nmem_strdup (stream->mem, setname); - } - else - { - for (i = 0; ierrCode = 13; - zh->errString = odr_strdup (stream, num_str); - break; - } - - } - zebraPosSetDestroy (zh, poset, num_recs); - } - zebra_end_read (zh); - xfree (pos_array); + zebra_records_retrieve(zh, stream, setname, comp, input_format, + num_recs, recs); } - /* --------------------------------------------------------------------------- Record insert(=update), delete