* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zrpn.c,v $
- * Revision 1.18 1995-10-04 16:57:20 adam
+ * Revision 1.19 1995-10-06 10:43:56 adam
+ * Scan added. 'occurrences' in scan entries not set yet.
+ *
+ * Revision 1.18 1995/10/04 16:57:20 adam
* Key input and merge sort in one pass.
*
* Revision 1.17 1995/10/04 12:55:17 adam
attr_init (&use, zapt, 1);
use_value = attr_find (&use);
- logf (LOG_DEBUG, "use value %d", truncation_value);
+ logf (LOG_DEBUG, "use value %d", use_value);
attr_init (&truncation, zapt, 5);
truncation_value = attr_find (&truncation);
logf (LOG_DEBUG, "truncation value %d", truncation_value);
return zi->errCode;
}
+static struct scan_entry *scan_list;
+static ODR scan_odr;
+static int scan_before, scan_after;
+static int scan_prefix;
+
+static int scan_handle (Dict_char *name, const char *info, int pos)
+{
+ int idx;
+
+ if (pos > 0)
+ idx = scan_after - pos + scan_before;
+ else
+ idx = - pos - 1;
+ scan_list[idx].term = odr_malloc (scan_odr, strlen(name + scan_prefix)+1);
+ strcpy (scan_list[idx].term, name + scan_prefix);
+ scan_list[idx].occurrences = 1;
+ logf (LOG_DEBUG, "pos=%3d idx=%3d name=%s", pos, idx, name);
+ return 0;
+}
+
+int rpn_scan (ZServerInfo *zi, ODR odr, Z_AttributesPlusTerm *zapt,
+ int *position, int *num_entries, struct scan_entry **list)
+{
+ int i, j, sizez;
+ int pos = *position;
+ int num = *num_entries;
+ int before;
+ int after;
+ char termz[IT_MAX_WORD+20];
+ AttrType use;
+ int use_value;
+ Z_Term *term = zapt->term;
+
+ logf (LOG_DEBUG, "scan, position = %d, num = %d", pos, num);
+ scan_before = before = pos-1;
+ scan_after = after = 1+num-pos;
+ scan_odr = odr;
+
+ logf (LOG_DEBUG, "scan, before = %d, after = %d", before, after);
+
+ scan_list = *list = odr_malloc (odr, (before+after)*sizeof(**list));
+ attr_init (&use, zapt, 1);
+ use_value = attr_find (&use);
+ logf (LOG_DEBUG, "use value %d", use_value);
+
+ if (use_value == -1)
+ use_value = 1016;
+ scan_prefix = i = index_word_prefix (termz, 1, use_value);
+ sizez = term->u.general->len;
+ if (sizez > IT_MAX_WORD)
+ sizez = IT_MAX_WORD;
+ for (j = 0; j<sizez; j++)
+ termz[j+i] = index_char_cvt (term->u.general->buf[j]);
+ termz[j+i] = '\0';
+
+ dict_scan (zi->wordDict, termz, &before, &after, scan_handle);
+ return 0;
+}
+
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zserver.c,v $
- * Revision 1.10 1995-10-02 16:43:32 quinn
+ * Revision 1.11 1995-10-06 10:43:57 adam
+ * Scan added. 'occurrences' in scan entries not set yet.
+ *
+ * Revision 1.10 1995/10/02 16:43:32 quinn
* Set default resulting record type in fetch.
*
* Revision 1.9 1995/10/02 15:18:52 adam
#include <fcntl.h>
#include <recctrl.h>
-#include <backend.h>
#include <dmalloc.h>
#include "zserver.h"
return &r;
}
server_info.recordBuf = NULL;
+ server_info.odr = odr_createmem (ODR_ENCODE);
return &r;
}
bend_scanresult *bend_scan (void *handle, bend_scanrequest *q, int *num)
{
- static struct scan_entry list[200];
- static char buf[200][200];
static bend_scanresult r;
- int i;
+
+ odr_reset (server_info.odr);
r.term_position = q->term_position;
r.num_entries = q->num_entries;
- r.entries = list;
- for (i = 0; i < r.num_entries; i++)
- {
- list[i].term = buf[i];
- sprintf(list[i].term, "term-%d", i+1);
- list[i].occurrences = rand() % 100000;
- }
- r.errcode = 0;
+ r.errcode = rpn_scan (&server_info, server_info.odr, q->term,
+ &r.term_position,
+ &r.num_entries, &r.entries);
r.errstring = 0;
return &r;
}
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zserver.h,v $
- * Revision 1.6 1995-09-28 09:19:48 adam
+ * Revision 1.7 1995-10-06 10:43:57 adam
+ * Scan added. 'occurrences' in scan entries not set yet.
+ *
+ * Revision 1.6 1995/09/28 09:19:48 adam
* xfree/xmalloc used everywhere.
* Extract/retrieve method seems to work for text records.
*
*/
#include "index.h"
-#include <proto.h>
+#include <backend.h>
#include <rset.h>
typedef struct {
char *recordBuf;
int errCode;
char *errString;
+ ODR odr;
} ZServerInfo;
int rpn_search (ZServerInfo *zi,
Z_RPNQuery *rpn, int num_bases, char **basenames,
const char *setname, int *hits);
+int rpn_scan (ZServerInfo *zi, ODR odr, Z_AttributesPlusTerm *zapt,
+ int *position, int *num_entries, struct scan_entry **list);
+
ZServerSet *resultSetAdd (ZServerInfo *zi, const char *name,
int ov, RSET rset);
ZServerSet *resultSetGet (ZServerInfo *zi, const char *name);