* 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
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)
}
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);
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; i<KEY_SIZE; i++)
+ key[i++] = key_file_getc (f);
+ return 1;
}
int inp2 (Dict dict, ISAM isam, const char *name)
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zrpn.c,v $
- * Revision 1.14 1995-09-28 12:10:32 adam
+ * Revision 1.15 1995-10-02 15:18:52 adam
+ * New member in recRetrieveCtrl: diagnostic.
+ *
+ * Revision 1.14 1995/09/28 12:10:32 adam
* Bug fixes. Field prefix used in queries.
*
* Revision 1.13 1995/09/18 14:17:50 adam
char term_sub[IT_MAX_WORD+1];
char *p0 = termz, *p1 = NULL;
Z_Term *term = zapt->term;
- size_t sizez, i;
+ size_t sizez, i, j;
parms.key_size = sizeof(struct it_key);
parms.max_rec = 100;
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 */
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)
{
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 */
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)
{
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 */
* 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.
*
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)