X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzsets.c;h=d0ce024f00044eccc0c98ed7a50de4600d32dad4;hb=43506dd0ff92373604bb7288e2dcc943b2c1d524;hp=ed5e1a6834d928ceeed1f25a8cd0dc1b572e21c5;hpb=4c1c4df443dc34e0a183de4760a2890396409bb8;p=idzebra-moved-to-github.git diff --git a/index/zsets.c b/index/zsets.c index ed5e1a6..d0ce024 100644 --- a/index/zsets.c +++ b/index/zsets.c @@ -1,10 +1,22 @@ /* - * 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.20 1998-11-16 10:10:53 adam + * Revision 1.24 1999-11-04 15:00:45 adam + * Implemented delete result set(s). + * + * 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. * @@ -79,7 +91,7 @@ */ #include #include -#ifdef WINDOWS +#ifdef WIN32 #include #else #include @@ -122,8 +134,6 @@ ZebraSet resultSetAddRPN (ZebraHandle zh, ODR input, ODR output, { ZebraSet zebraSet; - zlog_rpn (rpn); - zh->errCode = 0; zh->errString = NULL; zh->hits = 0; @@ -167,18 +177,19 @@ ZebraSet resultSetAdd (ZebraHandle zh, const char *name, int ov) 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++) @@ -210,26 +221,48 @@ ZebraSet resultSetGet (ZebraHandle zh, const char *name) return NULL; } - -void resultSetDestroy (ZebraHandle zh) +void resultSetDestroy (ZebraHandle zh, int num, char **names,int *statuses) { - ZebraSet s, s1; - - for (s = zh->sets; s; s = s1) + ZebraSet *ss = &zh->sets; + int i; + + if (statuses) + for (i = 0; ierrCode = 0; + zh->errString = NULL; + while (*ss) { - s1 = s->next; - - xfree (s->sort_info->all_entries); - xfree (s->sort_info->entries); - xfree (s->sort_info); - - if (s->nmem) - nmem_destroy (s->nmem); - rset_delete (s->rset); - xfree (s->name); - xfree (s); + int i = -1; + ZebraSet s = *ss; + if (num >= 0) + { + for (i = 0; iname, names[i])) + { + if (statuses) + statuses[i] = Z_DeleteStatus_success; + i = -1; + break; + } + } + if (i < 0) + { + *ss = s->next; + + xfree (s->sort_info->all_entries); + xfree (s->sort_info->entries); + xfree (s->sort_info); + + if (s->nmem) + nmem_destroy (s->nmem); + rset_delete (s->rset); + xfree (s->name); + xfree (s); + } + else + ss = &s->next; } - zh->sets = NULL; } ZebraPosSet zebraPosSetCreate (ZebraHandle zh, const char *name, @@ -245,7 +278,7 @@ ZebraPosSet zebraPosSetCreate (ZebraHandle zh, const char *name, return NULL; if (!(rset = sset->rset)) return NULL; - sr = xmalloc (sizeof(*sr) * num); + sr = (ZebraPosSet) xmalloc (sizeof(*sr) * num); for (i = 0; icontrol = 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;