X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzebraapi.c;h=0185da1923e17e9f82291294fc20bd1646f60f7f;hb=3e8db66d56c466a5a269362eb70b4931d9579128;hp=149d40c4f7051a54e2bf364e5093f731053bea10;hpb=b5eb8cd7ae4134d915ed8b4aec25ab90c8bd0dcb;p=idzebra-moved-to-github.git diff --git a/index/zebraapi.c b/index/zebraapi.c index 149d40c..0185da1 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.125 2004-08-10 08:54:39 heikki Exp $ +/* $Id: zebraapi.c,v 1.127 2004-08-25 09:23:36 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -36,7 +36,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include "index.h" #include -#include "zebraapi.h" +#include /* simple asserts to validate the most essential input args */ #define ASSERTZH assert(zh && zh->service) @@ -766,6 +766,8 @@ int zebra_select_databases (ZebraHandle zh, int num_bases, int zebra_search_RPN (ZebraHandle zh, ODR o, Z_RPNQuery *query, const char *setname, int *hits) { + const char *max; + zint maxhits; ASSERTZH; yaz_log(LOG_API,"zebra_search_rpn"); zh->errCode=0; @@ -781,8 +783,19 @@ int zebra_search_RPN (ZebraHandle zh, ODR o, zh->num_basenames, zh->basenames, setname); zebra_end_read (zh); - if (zh->hits > INT_MAX) - *hits=INT_MAX; + max = res_get (zh->res, "maxhits"); + if (max) + maxhits=atoi(max); + else { + int i=0; + maxhits=INT_MAX; + while (maxhits>100) { maxhits/=10; i++;} + while (i--) maxhits *= 10; + } + if (zh->hits > maxhits) { /* too large for yaz to handle */ + logf(LOG_LOG,"limiting hits to "ZINT_FORMAT, maxhits); + *hits=maxhits; /* round it down to two digits, to look like rounded */ + } else *hits = zh->hits; return 0;