From: Adam Dickmeiss Date: Mon, 2 Oct 1995 15:18:52 +0000 (+0000) Subject: New member in recRetrieveCtrl: diagnostic. X-Git-Tag: ZEBRA.1.0~732 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=2811f2e2fb2101a75e89e8b3e0358635e86ab71d;p=idzebra-moved-to-github.git New member in recRetrieveCtrl: diagnostic. --- diff --git a/index/kinput.c b/index/kinput.c index ce565a8..54f7b2f 100644 --- a/index/kinput.c +++ b/index/kinput.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: kinput.c,v $ - * Revision 1.6 1995-09-29 15:51:56 adam + * Revision 1.7 1995-10-02 15:18:52 adam + * New member in recRetrieveCtrl: diagnostic. + * + * Revision 1.6 1995/09/29 15:51:56 adam * First work on multi-way read. * * Revision 1.5 1995/09/29 14:01:43 adam @@ -161,18 +164,19 @@ void key_input (const char *dict_fname, const char *isam_fname, struct key_file { - int no; - off_t offset; - char *buf; - size_t buf_size; - size_t chunk; - size_t buf_ptr; + int no; /* file no */ + off_t offset; /* file offset */ + unsigned char *buf; /* buffer block */ + size_t buf_size; /* number of read bytes in block */ + size_t chunk; /* number of bytes allocated */ + size_t buf_ptr; /* current position in buffer */ + char *prev_name; /* last word read */ }; void key_file_chunk_read (struct key_file *f) { int nr = 0, r, fd; - char fname[256]; + char fname[256]; sprintf (fname, TEMP_FNAME, f->no); fd = open (fname, O_RDONLY); if (fd == -1) @@ -182,11 +186,9 @@ void key_file_chunk_read (struct key_file *f) } if (lseek (fd, f->offset, SEEK_SET) == -1) { - logf (LOG_FATAL|LOG_ERRNO, "lseek to %ld in file %s", - (long) f->offset, fname); + logf (LOG_FATAL|LOG_ERRNO, "cannot seek %s", fname); exit (1); } - f->buf = xmalloc (f->chunk); while (f->chunk - nr > 0) { r = read (fd, f->buf + nr, f->chunk - nr); @@ -202,10 +204,47 @@ void key_file_chunk_read (struct key_file *f) f->buf_size = nr; } -void key_file_chunk_discard (struct key_file *f) +void key_file_init (struct key_file *f) { + f->buf = xmalloc (f->chunk); + f->prev_name = xmalloc (256); + *f->prev_name = '\0'; +} +int key_file_getc (struct key_file *f) +{ + if (f->buf_ptr < f->buf_size) + return f->buf[(f->buf_ptr)++]; + if (f->buf_size < f->chunk) + return EOF; + f->offset += f->buf_size; + key_file_chunk_read (f); + if (f->buf_ptr < f->buf_size) + return f->buf[(f->buf_ptr)++]; + else + return EOF; +} +int key_file_read (struct key_file *f, char *name, char *key) +{ + int i, c; + + c = key_file_getc (f); + if (c == 0) + strcpy (name, f->prev_name); + else if (c == EOF) + return 0; + else + { + i = 0; + name[i++] = c; + while ((name[i++] = key_file_getc (f))) + ; + strcpy (f->prev_name, name); + } + for (i = 0; iterm; - size_t sizez, i; + size_t sizez, i, j; parms.key_size = sizeof(struct it_key); parms.max_rec = 100; @@ -402,8 +405,8 @@ static RSET rpn_search_APT_relevance (ZServerInfo *zi, sizez = i + term->u.general->len; if (sizez > IT_MAX_WORD) sizez = IT_MAX_WORD; - for ( ; i < sizez; i++) - termz[i] = index_char_cvt (term->u.general->buf[i]); + for (j = 0; i < sizez; i++, j++) + termz[i] = index_char_cvt (term->u.general->buf[j]); termz[i] = '\0'; isam_p_indx = 0; /* global, set by trunc_term - see below */ @@ -437,7 +440,7 @@ static RSET rpn_search_APT_word (ZServerInfo *zi, char termz[IT_MAX_WORD+1]; Z_Term *term = zapt->term; - size_t sizez, i; + size_t sizez, i, j; if (term->which != Z_Term_general) { @@ -445,11 +448,12 @@ static RSET rpn_search_APT_word (ZServerInfo *zi, return NULL; } i = index_word_prefix (termz, 1, 1016); + logf (LOG_DEBUG, "i=%d", i); sizez = i + term->u.general->len; if (sizez > IT_MAX_WORD) sizez = IT_MAX_WORD; - for ( ; i < sizez; i++) - termz[i] = index_char_cvt (term->u.general->buf[i]); + for (j = 0; i < sizez; i++, j++) + termz[i] = index_char_cvt (term->u.general->buf[j]); termz[i] = '\0'; isam_p_indx = 0; /* global, set by trunc_term - see below */ @@ -475,7 +479,7 @@ static RSET rpn_search_APT_phrase (ZServerInfo *zi, char termz[IT_MAX_WORD+1]; Z_Term *term = zapt->term; - size_t sizez, i; + size_t sizez, i, j; if (term->which != Z_Term_general) { @@ -486,8 +490,8 @@ static RSET rpn_search_APT_phrase (ZServerInfo *zi, sizez = i + term->u.general->len; if (sizez > IT_MAX_WORD) sizez = IT_MAX_WORD; - for ( ; i < sizez; i++) - termz[i] = index_char_cvt (term->u.general->buf[i]); + for (j = 0 ; i < sizez; i++, j++) + termz[i] = index_char_cvt (term->u.general->buf[j]); termz[i] = '\0'; isam_p_indx = 0; /* global, set by trunc_term - see below */ diff --git a/index/zserver.c b/index/zserver.c index 17d3016..863780a 100644 --- a/index/zserver.c +++ b/index/zserver.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zserver.c,v $ - * Revision 1.8 1995-09-28 09:19:47 adam + * Revision 1.9 1995-10-02 15:18:52 adam + * New member in recRetrieveCtrl: diagnostic. + * + * Revision 1.8 1995/09/28 09:19:47 adam * xfree/xmalloc used everywhere. * Extract/retrieve method seems to work for text records. * @@ -148,12 +151,13 @@ static int record_fetch (ZServerInfo *zi, int sysno, ODR stream, retrieveCtrl.odr = stream; retrieveCtrl.readf = record_read; retrieveCtrl.input_format = input_format; + retrieveCtrl.diagnostic = 0; (*rt->retrieve)(&retrieveCtrl); *output_format = retrieveCtrl.output_format; *rec_bufp = retrieveCtrl.rec_buf; *rec_lenp = retrieveCtrl.rec_len; close (retrieveCtrl.fd); - return 0; + return retrieveCtrl.diagnostic; } bend_fetchresult *bend_fetch (void *handle, bend_fetchrequest *q, int *num)