X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fextract.c;h=a48dc38c443845219c956b205c2edb2876dd2d42;hb=8407158947485c3897c8232bf5a1f4501eb5e710;hp=6718670c6830a73f97f37a88ba50c64b73d34924;hpb=289761234a123e7fb51df77ab9baf0a2cd101dbd;p=idzebra-moved-to-github.git diff --git a/index/extract.c b/index/extract.c index 6718670..a48dc38 100644 --- a/index/extract.c +++ b/index/extract.c @@ -1,4 +1,4 @@ -/* $Id: extract.c,v 1.203 2006-02-20 18:39:43 adam Exp $ +/* $Id: extract.c,v 1.207 2006-04-05 02:11:44 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -379,13 +379,13 @@ static void init_extractCtrl(ZebraHandle zh, struct recExtractCtrl *ctrl) ctrl->flagShowRecords = !zh->m_flag_rw; } -static int file_extract_record(ZebraHandle zh, - SYSNO *sysno, const char *fname, - int deleteFlag, - struct file_read_info *fi, - int force_update, - RecType recType, - void *recTypeClientData) +static ZEBRA_RES file_extract_record(ZebraHandle zh, + SYSNO *sysno, const char *fname, + int deleteFlag, + struct file_read_info *fi, + int force_update, + RecType recType, + void *recTypeClientData) { RecordAttr *recordAttr; int r; @@ -400,7 +400,7 @@ static int file_extract_record(ZebraHandle zh, { if (zebraExplain_newDatabase (zh->reg->zei, zh->basenames[0], zh->m_explain_database)) - return 0; + return ZEBRA_FAIL; } if (fi->fd != -1) @@ -447,7 +447,7 @@ static int file_extract_record(ZebraHandle zh, yaz_log_init_prefix2 (0); if (r == RECCTRL_EXTRACT_EOF) - return 0; + return ZEBRA_FAIL; else if (r == RECCTRL_EXTRACT_ERROR_GENERIC) { /* error occured during extraction ... */ @@ -457,7 +457,7 @@ static int file_extract_record(ZebraHandle zh, yaz_log (YLOG_WARN, "fail %s %s " PRINTF_OFF_T, zh->m_record_type, fname, recordOffset); } - return 0; + return ZEBRA_FAIL; } else if (r == RECCTRL_EXTRACT_ERROR_NO_SUCH_FILTER) { @@ -469,7 +469,7 @@ static int file_extract_record(ZebraHandle zh, PRINTF_OFF_T, zh->m_record_type, fname, recordOffset); } - return 0; + return ZEBRA_FAIL; } if (extractCtrl.match_criteria[0]) matchStr = extractCtrl.match_criteria; @@ -488,7 +488,7 @@ static int file_extract_record(ZebraHandle zh, if (!matchStr) { yaz_log(YLOG_WARN, "Bad match criteria"); - return 0; + return ZEBRA_FAIL; } } if (matchStr) @@ -508,12 +508,12 @@ static int file_extract_record(ZebraHandle zh, /* the extraction process returned no information - the record is probably empty - unless flagShowRecords is in use */ if (!zh->m_flag_rw) - return 1; + return ZEBRA_OK; if (zh->records_processed < zh->m_file_verbose_limit) yaz_log (YLOG_WARN, "empty %s %s " PRINTF_OFF_T, zh->m_record_type, fname, recordOffset); - return 1; + return ZEBRA_OK; } if (! *sysno) @@ -524,7 +524,7 @@ static int file_extract_record(ZebraHandle zh, yaz_log (YLOG_LOG, "delete %s %s " PRINTF_OFF_T, zh->m_record_type, fname, recordOffset); yaz_log (YLOG_WARN, "cannot delete record above (seems new)"); - return 1; + return ZEBRA_OK; } if (zh->records_processed < zh->m_file_verbose_limit) yaz_log (YLOG_LOG, "add %s %s " PRINTF_OFF_T, zh->m_record_type, @@ -610,7 +610,7 @@ static int file_extract_record(ZebraHandle zh, } rec_rm (&rec); logRecord (zh); - return 1; + return ZEBRA_OK; } else { @@ -727,13 +727,14 @@ static int file_extract_record(ZebraHandle zh, /* commit this record */ rec_put (zh->reg->records, &rec); logRecord (zh); - return 1; + return ZEBRA_OK; } -int fileExtract (ZebraHandle zh, SYSNO *sysno, const char *fname, - int deleteFlag) +ZEBRA_RES zebra_extract_file(ZebraHandle zh, SYSNO *sysno, const char *fname, + int deleteFlag) { - int r, i, fd; + ZEBRA_RES r = ZEBRA_OK; + int i, fd; char gprefix[128]; char ext[128]; char ext_res[128]; @@ -784,7 +785,7 @@ int fileExtract (ZebraHandle zh, SYSNO *sysno, const char *fname, &recTypeClientData))) { yaz_log(YLOG_WARN, "No such record type: %s", zh->m_record_type); - return 0; + return ZEBRA_FAIL; } switch(recType->version) @@ -809,16 +810,15 @@ int fileExtract (ZebraHandle zh, SYSNO *sysno, const char *fname, else strcpy (full_rep, fname); - if ((fd = open (full_rep, O_BINARY|O_RDONLY)) == -1) { yaz_log (YLOG_WARN|YLOG_ERRNO, "open %s", full_rep); zh->m_record_type = original_record_type; - return 0; + return ZEBRA_FAIL; } } fi = file_read_start (fd); - do + while(1) { fi->file_moffset = fi->file_offset; fi->file_more = 0; /* file_end not called (yet) */ @@ -829,8 +829,15 @@ int fileExtract (ZebraHandle zh, SYSNO *sysno, const char *fname, fi->file_offset = fi->file_moffset; lseek(fi->fd, fi->file_moffset, SEEK_SET); } + if (r != ZEBRA_OK) + { + break; + } + if (sysno) + { + break; + } } - while (r && !sysno); file_read_stop (fi); if (fd != -1) close (fd); @@ -921,7 +928,7 @@ ZEBRA_RES buffer_extract_record(ZebraHandle zh, if (!recType) { - yaz_log (YLOG_WARN, "No such record type: %s", zh->m_record_type); + yaz_log (YLOG_WARN, "No such record type: %s", recordType); return ZEBRA_FAIL; } @@ -1374,8 +1381,8 @@ void extract_flushRecordKeys (ZebraHandle zh, SYSNO sysno, { if (staticrank < 0) { - yaz_log(YLOG_WARN, "staticrank = %d. Setting to 0", - staticrank); + yaz_log(YLOG_WARN, "staticrank = %ld. Setting to 0", + (long) staticrank); staticrank = 0; } *keyp++ = staticrank; @@ -1553,7 +1560,8 @@ ZEBRA_RES zebra_snippets_rec_keys(ZebraHandle zh, ord = key.mem[0]; zebraExplain_lookup_ord(zh->reg->zei, ord, &index_type, - 0/* db */, 0/* set */, 0/* use */); + 0/* db */, 0/* set */, 0/* use */, + 0 /* string_index */); assert(index_type); zebra_term_untrans_iconv(zh, nmem, index_type, &dst_term, str); @@ -1582,7 +1590,7 @@ void print_rec_keys(ZebraHandle zh, zebra_rec_keys_t reckeys) assert(key.len <= 4 && key.len > 2); zebraExplain_lookup_ord(zh->reg->zei, - key.mem[0], &index_type, &db, 0, 0); + key.mem[0], &index_type, &db, 0, 0, 0); seqno = (int) key.mem[key.len-1];