-/* $Id: extract.c,v 1.198 2005-11-09 11:51:29 adam Exp $
+/* $Id: extract.c,v 1.201 2006-02-08 13:45:44 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
}
}
+#define FILE_MATCH_BLANK "\t "
+
static char *fileMatchStr (ZebraHandle zh,
zebra_rec_keys_t reckeys,
const char *fname, const char *spec)
while (1)
{
- while (*s == ' ' || *s == '\t')
- s++;
+ for (; *s && strchr(FILE_MATCH_BLANK, *s); s++)
+ ;
if (!*s)
break;
if (*s == '(')
char attset_str[64], attname_str[64];
data1_attset *attset;
int i;
- char matchFlag[32];
int attSet = 1, attUse = 1;
int first = 1;
-
- s++;
- for (i = 0; *s && *s != ',' && *s != ')'; s++)
- if (i < 63)
+
+ for (s++; strchr(FILE_MATCH_BLANK, *s); s++)
+ ;
+ for (i = 0; *s && *s != ',' && *s != ')' &&
+ !strchr(FILE_MATCH_BLANK, *s); s++)
+ if (i+1 < sizeof(attset_str))
attset_str[i++] = *s;
attset_str[i] = '\0';
-
+
+ for (; strchr(FILE_MATCH_BLANK, *s); s++)
+ ;
if (*s == ',')
{
- s++;
- for (i = 0; *s && *s != ')'; s++)
- if (i < 63)
+ for (s++; strchr(FILE_MATCH_BLANK, *s); s++)
+ ;
+ for (i = 0; *s && *s != ')' &&
+ !strchr(FILE_MATCH_BLANK, *s); s++)
+ if (i+1 < sizeof(attname_str))
attname_str[i++] = *s;
attname_str[i] = '\0';
}
}
searchRecordKey (zh, reckeys, attSet, attUse, ws, 32);
- if (*s == ')')
- {
- for (i = 0; i<32; i++)
- matchFlag[i] = 1;
- }
- else
+ if (*s != ')')
{
yaz_log (YLOG_WARN, "Missing ) in match criteria %s in group %s",
spec, zh->m_group ? zh->m_group : "none");
s++;
for (i = 0; i<32; i++)
- if (matchFlag[i] && ws[i])
+ if (ws[i])
{
if (first)
{
char special[64];
const char *spec_src = NULL;
const char *s1 = ++s;
- while (*s1 && *s1 != ' ' && *s1 != '\t')
+ while (*s1 && !strchr(FILE_MATCH_BLANK, *s1))
s1++;
spec_len = s1 - s;
- if (spec_len > 63)
- spec_len = 63;
+ if (spec_len > sizeof(special)-1)
+ spec_len = sizeof(special)-1;
memcpy (special, s, spec_len);
special[spec_len] = '\0';
s = s1;
while (*s && *s != stopMarker)
{
- if (i < 63)
+ if (i+1 < sizeof(tmpString))
tmpString[i++] = *s++;
}
if (*s)
{
yaz_log (YLOG_LOG, "delete %s %s " PRINTF_OFF_T,
zh->m_record_type, fname, recordOffset);
- yaz_log (YLOG_WARN, "cannot delete file above, storeKeys false");
+ yaz_log (YLOG_WARN, "cannot delete file above, storeKeys false (1)");
}
else
{
}
else
{
- /* record going to be updated */
- if (zebra_rec_keys_empty(delkeys))
- {
+ /* flush new keys for sort&search etc */
+ if (zh->records_processed < zh->m_file_verbose_limit)
yaz_log (YLOG_LOG, "update %s %s " PRINTF_OFF_T,
zh->m_record_type, fname, recordOffset);
- yaz_log (YLOG_WARN, "cannot update file above, storeKeys false");
- }
- else
- {
- /* flush new keys for sort&search etc */
- if (zh->records_processed < zh->m_file_verbose_limit)
- yaz_log (YLOG_LOG, "update %s %s " PRINTF_OFF_T,
- zh->m_record_type, fname, recordOffset);
- recordAttr->staticrank = extractCtrl.staticrank;
+ recordAttr->staticrank = extractCtrl.staticrank;
#if NATTR
- extract_flushSortKeys (zh, *sysno, 1, zh->reg->sortKeys);
+ extract_flushSortKeys (zh, *sysno, 1, zh->reg->sortKeys);
#else
- extract_flushSortKeys (zh, *sysno, 1, &zh->reg->sortKeys);
+ extract_flushSortKeys (zh, *sysno, 1, &zh->reg->sortKeys);
#endif
- extract_flushRecordKeys (zh, *sysno, 1, zh->reg->keys,
+ extract_flushRecordKeys (zh, *sysno, 1, zh->reg->keys,
recordAttr->staticrank);
- zh->records_updated++;
- }
+ zh->records_updated++;
}
zebra_rec_keys_close(delkeys);
#if NATTR
int force_update,
int allow_update)
{
+ SYSNO sysno0 = 0;
RecordAttr *recordAttr;
struct recExtractCtrl extractCtrl;
int r;
yaz_log (YLOG_WARN, "extract error: no such filter");
return ZEBRA_FAIL;
}
- /* match criteria */
- matchStr = NULL;
if (extractCtrl.match_criteria[0])
match_criteria = extractCtrl.match_criteria;
- if (! *sysno) {
- char *rinfo;
+ if (!sysno) {
+
+ sysno = &sysno0;
+
if (match_criteria && *match_criteria) {
matchStr = match_criteria;
} else {
}
}
if (matchStr) {
- rinfo = dict_lookup (zh->reg->matchDict, matchStr);
+ char *rinfo = dict_lookup (zh->reg->matchDict, matchStr);
if (rinfo)
{
assert(*rinfo == sizeof(*sysno));
/* new record */
if (delete_flag)
{
- if (show_progress)
- yaz_log (YLOG_LOG, "delete %s %s %ld", recordType,
+ yaz_log (YLOG_LOG, "delete %s %s %ld", recordType,
pr_fname, (long) recordOffset);
yaz_log (YLOG_WARN, "cannot delete record above (seems new)");
return ZEBRA_FAIL;
if (!allow_update)
{
- if (show_progress)
- yaz_log (YLOG_LOG, "skipped %s %s %ld",
+ yaz_log (YLOG_LOG, "skipped %s %s %ld",
recordType, pr_fname, (long) recordOffset);
logRecord(zh);
return ZEBRA_FAIL;
/* record going to be deleted */
if (zebra_rec_keys_empty(delkeys))
{
- if (show_progress)
- {
- yaz_log (YLOG_LOG, "delete %s %s %ld", recordType,
- pr_fname, (long) recordOffset);
- yaz_log (YLOG_WARN, "cannot delete file above, "
- "storeKeys false");
- }
+ yaz_log (YLOG_LOG, "delete %s %s %ld", recordType,
+ pr_fname, (long) recordOffset);
+ yaz_log (YLOG_WARN, "cannot delete file above, "
+ "storeKeys false (3)");
}
else
{
}
else
{
- /* record going to be updated */
- if (zebra_rec_keys_empty(delkeys))
- {
- if (show_progress)
- {
- yaz_log (YLOG_LOG, "update %s %s %ld", recordType,
- pr_fname, (long) recordOffset);
- yaz_log (YLOG_WARN, "cannot update file above, storeKeys false");
- }
- }
- else
- {
- if (show_progress)
+ if (show_progress)
yaz_log (YLOG_LOG, "update %s %s %ld", recordType,
pr_fname, (long) recordOffset);
- recordAttr->staticrank = extractCtrl.staticrank;
+ recordAttr->staticrank = extractCtrl.staticrank;
#if NATTR
- extract_flushSortKeys (zh, *sysno, 1, zh->reg->sortKeys);
+ extract_flushSortKeys (zh, *sysno, 1, zh->reg->sortKeys);
#else
- extract_flushSortKeys (zh, *sysno, 1, &zh->reg->sortKeys);
+ extract_flushSortKeys (zh, *sysno, 1, &zh->reg->sortKeys);
#endif
- extract_flushRecordKeys (zh, *sysno, 1, zh->reg->keys,
+ extract_flushRecordKeys (zh, *sysno, 1, zh->reg->keys,
recordAttr->staticrank);
- zh->records_updated++;
- }
+ zh->records_updated++;
}
zebra_rec_keys_close(delkeys);
#if NATTR