-/* $Id: safari.c,v 1.3 2006-08-16 13:16:36 adam Exp $
- Copyright (C) 1995-2006
+/* $Id: safari.c,v 1.10 2007-10-29 16:57:53 adam Exp $
+ Copyright (C) 1995-2007
Index Data ApS
This file is part of the Zebra server.
*/
-
+#include <yaz/oid_db.h>
#include <stdio.h>
#include <assert.h>
#include <ctype.h>
{
if (fi->max <= 0)
return 0;
- fi->max = (*fi->p->readf)(fi->p->fh, fi->buf, 4096);
+ fi->max = fi->p->stream->readf(fi->p->stream, fi->buf, 4096);
fi->offset = 0;
if (fi->max <= 0)
return 0;
(*p->init)(p, &recWord);
if (!fi_gets(fi, line, sizeof(line)-1))
- return RECCTRL_EXTRACT_ERROR_GENERIC;
+ return RECCTRL_EXTRACT_EOF;
sscanf(line, "%255s", p->match_criteria);
- recWord.index_type = '0';
while (fi_gets(fi, line, sizeof(line)-1))
{
int nor = 0;
char field[40];
- char *cp;
+ const char *cp = line;
+ char type_cstr[2];
#if 0
yaz_log(YLOG_LOG, "safari line: %s", line);
#endif
+ type_cstr[1] = '\0';
+ if (*cp >= '0' && *cp <= '9')
+ type_cstr[0] = '0'; /* the default is 0 (raw) */
+ else
+ type_cstr[0] = *cp++; /* type given */
+ type_cstr[1] = '\0';
+
+ recWord.index_type = type_cstr;
if (tinfo->segments)
{
- if (sscanf(line, ZINT_FORMAT " " ZINT_FORMAT " " ZINT_FORMAT
+ if (sscanf(cp, ZINT_FORMAT " " ZINT_FORMAT " " ZINT_FORMAT
ZINT_FORMAT " %39s %n",
&recWord.record_id, &recWord.section_id,
&recWord.segment,
}
else
{
- if (sscanf(line, ZINT_FORMAT " " ZINT_FORMAT " " ZINT_FORMAT " %39s %n",
+ if (sscanf(cp, ZINT_FORMAT " " ZINT_FORMAT " " ZINT_FORMAT " %39s %n",
&recWord.record_id, &recWord.section_id, &recWord.seqno,
field, &nor) < 4)
{
return RECCTRL_EXTRACT_ERROR_GENERIC;
}
}
- for (cp = line + nor; *cp == ' '; cp++)
+ for (cp = cp + nor; *cp == ' '; cp++)
;
recWord.index_name = field;
recWord.term_buf = cp;
}
if (!make_body)
break;
- r = (*p->readf)(p->fh, filter_buf + filter_ptr, 4096);
+ r = p->stream->readf(p->stream, filter_buf + filter_ptr, 4096);
if (r <= 0)
break;
filter_ptr += r;
filter_ptr = p-filter_buf;
}
}
- p->output_format = VAL_SUTRS;
+ p->output_format = yaz_oid_recsyn_sutrs;
p->rec_buf = filter_buf;
p->rec_len = filter_ptr;
return 0;