/*
- * Copyright (C) 1994-1998, Index Data
+ * Copyright (C) 1994-1999, Index Data
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zsets.c,v $
- * Revision 1.18 1998-09-22 10:03:45 adam
+ * Revision 1.23 1999-05-26 07:49:13 adam
+ * C++ compilation.
+ *
+ * Revision 1.22 1999/02/02 14:51:15 adam
+ * Updated WIN32 code specific sections. Changed header.
+ *
+ * Revision 1.21 1998/11/16 16:03:46 adam
+ * Moved loggin utilities to Yaz. Was implemented in file zlogs.c.
+ *
+ * Revision 1.20 1998/11/16 10:10:53 adam
+ * Fixed problem with zebraPosSetCreate that occurred when positions were
+ * less than 1.
+ *
+ * Revision 1.19 1998/09/22 10:48:22 adam
+ * Minor changes in search API.
+ *
+ * Revision 1.18 1998/09/22 10:03:45 adam
* Changed result sets to be persistent in the sense that they can
* be re-searched if needed.
* Fixed memory leak in rsm_or.
*/
#include <stdio.h>
#include <assert.h>
-#ifdef WINDOWS
+#ifdef WIN32
#include <io.h>
#else
#include <unistd.h>
struct zset_sort_entry **entries;
};
-ZebraSet resultSetAddRPN (ZebraHandle zh, ODR stream, ODR decode,
+ZebraSet resultSetAddRPN (ZebraHandle zh, ODR input, ODR output,
Z_RPNQuery *rpn, int num_bases, char **basenames,
const char *setname)
{
ZebraSet zebraSet;
- zlog_rpn (rpn);
-
zh->errCode = 0;
zh->errString = NULL;
zh->hits = 0;
zebraSet->rpn = 0;
zebraSet->num_bases = num_bases;
zebraSet->basenames = basenames;
- zebraSet->nmem = odr_extract_mem (decode);
+ zebraSet->nmem = odr_extract_mem (input);
- zebraSet->rset = rpn_search (zh, stream->mem, rpn,
+ zebraSet->rset = rpn_search (zh, output->mem, rpn,
zebraSet->num_bases,
zebraSet->basenames, zebraSet->name,
zebraSet);
else
{
logf (LOG_DEBUG, "adding result set %s", name);
- s = xmalloc (sizeof(*s));
+ s = (ZebraSet) xmalloc (sizeof(*s));
s->next = zh->sets;
zh->sets = s;
- s->name = xmalloc (strlen(name)+1);
+ s->name = (char *) xmalloc (strlen(name)+1);
strcpy (s->name, name);
- s->sort_info = xmalloc (sizeof(*s->sort_info));
+ s->sort_info = (struct zset_sort_info *)
+ xmalloc (sizeof(*s->sort_info));
s->sort_info->max_entries = 1000;
- s->sort_info->entries =
+ s->sort_info->entries = (struct zset_sort_entry **)
xmalloc (sizeof(*s->sort_info->entries) *
s->sort_info->max_entries);
- s->sort_info->all_entries =
+ s->sort_info->all_entries = (struct zset_sort_entry *)
xmalloc (sizeof(*s->sort_info->all_entries) *
s->sort_info->max_entries);
for (i = 0; i < s->sort_info->max_entries; i++)
return NULL;
if (!(rset = sset->rset))
return NULL;
- sr = xmalloc (sizeof(*sr) * num);
+ sr = (ZebraPosSet) xmalloc (sizeof(*sr) * num);
for (i = 0; i<num; i++)
{
sr[i].sysno = 0;
for (i = 0; i<num; i++)
{
position = positions[i];
- if (position <= sort_info->num_entries)
+ if (position > 0 && position <= sort_info->num_entries)
{
logf (LOG_DEBUG, "got pos=%d (sorted)", position);
sr[i].sysno = sort_info->entries[position-1]->sysno;
void zebraRankInstall (ZebraHandle zh, struct rank_control *ctrl)
{
- ZebraRankClass p = xmalloc (sizeof(*p));
- p->control = xmalloc (sizeof(*p->control));
+ ZebraRankClass p = (ZebraRankClass) xmalloc (sizeof(*p));
+ p->control = (struct rank_control *) xmalloc (sizeof(*p->control));
memcpy (p->control, ctrl, sizeof(*p->control));
p->control->name = xstrdup (ctrl->name);
p->init_flag = 0;