X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzsets.c;h=d3fb047732d98372147043768ac307a0beaf9475;hb=47ea1fc957c7b97bb30a26698f072109cae275e4;hp=7297d02c5b8e2a5b456ead0d36576b8d2b499095;hpb=764b78fb481cf1084a5a583ffefbe8a0f32af28c;p=idzebra-moved-to-github.git diff --git a/index/zsets.c b/index/zsets.c index 7297d02..d3fb047 100644 --- a/index/zsets.c +++ b/index/zsets.c @@ -3,7 +3,7 @@ * All rights reserved. * Sebastian Hammer, Adam Dickmeiss * - * $Id: zsets.c,v 1.35 2002-04-16 22:31:42 adam Exp $ + * $Id: zsets.c,v 1.37 2002-07-25 13:06:43 adam Exp $ */ #include #include @@ -119,20 +119,56 @@ void resultSetAddTerm (ZebraHandle zh, ZebraSet s, int reg_type, } -const char *zebra_resultSetTerms (ZebraHandle zh, const char *setname, - int no, int *count, int *no_max) +int zebra_resultSetTerms (ZebraHandle zh, const char *setname, + int no, int *count, + int *type, char *out, size_t *len) { ZebraSet s = resultSetGet (zh, setname); + int no_max = 0; - *count = 0; - *no_max = 0; + if (count) + *count = 0; if (!s || !s->rset) return 0; - *no_max = s->rset->no_rset_terms; - if (no < 0 || no >= *no_max) + no_max = s->rset->no_rset_terms; + if (no < 0 || no >= no_max) return 0; - *count = s->rset->rset_terms[no]->count; - return s->rset->rset_terms[no]->name; + if (count) + *count = s->rset->rset_terms[no]->count; + if (type) + *type = s->rset->rset_terms[no]->type; + + if (out) + { + char *inbuf = s->rset->rset_terms[no]->name; + size_t inleft = strlen(inbuf); + size_t outleft = *len - 1; + int converted = 0; +#if HAVE_ICONV_H + if (zh->iconv_from_utf8 != (iconv_t)(-1)) + { + char *outbuf = out; + size_t ret; + + ret = iconv(zh->iconv_from_utf8, &inbuf, &inleft, + &outbuf, &outleft); + if (ret == (size_t)(-1)) + *len = 0; + else + *len = outbuf - out; + converted = 1; + } +#endif + if (!converted) + { + if (inleft > outleft) + inleft = outleft; + *len = inleft; + memcpy (out, inbuf, *len); + } + out[*len] = 0; + } + return no_max; } @@ -679,7 +715,6 @@ void resultSetRank (ZebraHandle zh, ZebraSet zebraSet, RSET rset) do { kno++; - yaz_log (LOG_LOG, "%d:%d", key.sysno, key.seqno); if (key.sysno != psysno) { score = (*rc->calc) (handle, psysno);