- if (r == RECCTRL_EXTRACT_EOF)
- return 0;
- else if (r == RECCTRL_EXTRACT_ERROR_GENERIC)
- {
- /* error occured during extraction ... */
- yaz_log (LOG_WARN, "extract error: generic");
- return 0;
- }
- else if (r == RECCTRL_EXTRACT_ERROR_NO_SUCH_FILTER)
- {
- /* error occured during extraction ... */
- yaz_log (LOG_WARN, "extract error: no such filter");
- return 0;
+ extractCtrl.first_record = start_offset ? 0 : 1;
+
+ stream->endf(stream, &null_offset);;
+
+ extractCtrl.init = extract_init;
+ if (zh->reg->index_types)
+ {
+ extractCtrl.tokenAdd = extract_token_add2;
+ }
+ else
+ {
+ extractCtrl.tokenAdd = extract_token_add;
+ }
+ extractCtrl.schemaAdd = extract_schema_add;
+ extractCtrl.dh = zh->reg->dh;
+ extractCtrl.handle = zh;
+ extractCtrl.match_criteria[0] = '\0';
+ extractCtrl.staticrank = 0;
+ extractCtrl.action = action;
+
+ init_extractCtrl(zh, &extractCtrl);
+
+ extract_set_store_data_prepare(&extractCtrl);
+
+ r = (*recType->extract)(recTypeClientData, &extractCtrl);
+
+ if (action == action_update)
+ {
+ action = extractCtrl.action;
+ }
+
+ switch (r)
+ {
+ case RECCTRL_EXTRACT_EOF:
+ return ZEBRA_FAIL;
+ case RECCTRL_EXTRACT_ERROR_GENERIC:
+ /* error occured during extraction ... */
+ yaz_log(YLOG_WARN, "extract error: generic");
+ return ZEBRA_FAIL;
+ case RECCTRL_EXTRACT_ERROR_NO_SUCH_FILTER:
+ /* error occured during extraction ... */
+ yaz_log(YLOG_WARN, "extract error: no such filter");
+ return ZEBRA_FAIL;
+ case RECCTRL_EXTRACT_SKIP:
+ if (show_progress)
+ yaz_log(YLOG_LOG, "skip %s %s " ZINT_FORMAT,
+ recordType, pr_fname, (zint) start_offset);
+ *more = 1;
+
+ end_offset = stream->endf(stream, 0);
+ if (end_offset)
+ stream->seekf(stream, end_offset);
+
+ return ZEBRA_OK;
+ case RECCTRL_EXTRACT_OK:
+ break;
+ default:
+ yaz_log(YLOG_WARN, "extract error: unknown error: %d", r);
+ return ZEBRA_FAIL;
+ }
+ end_offset = stream->endf(stream, 0);
+ if (end_offset)
+ stream->seekf(stream, end_offset);
+ else
+ end_offset = stream->tellf(stream);
+
+ all_matches_add(&extractCtrl);
+
+ if (extractCtrl.match_criteria[0])
+ match_criteria = extractCtrl.match_criteria;