* Sebastian Hammer, Adam Dickmeiss
*
* $Log: extract.c,v $
- * Revision 1.82 1998-05-20 10:12:15 adam
+ * Revision 1.84 1998-06-11 15:42:22 adam
+ * Changed the way use attributes are specified in the recordId
+ * specification.
+ *
+ * Revision 1.83 1998/06/08 14:43:10 adam
+ * Added suport for EXPLAIN Proxy servers - added settings databasePath
+ * and explainDatabase to facilitate this. Increased maximum number
+ * of databases and attributes in one register.
+ *
+ * Revision 1.82 1998/05/20 10:12:15 adam
* Implemented automatic EXPLAIN database maintenance.
* Modified Zebra to work with ASN.1 compiled version of YAZ.
*
if (ch < 0)
ch = zebraExplain_addSU (zti, attrSet, attrUse);
assert (ch > 0);
- ((char*) key_buf) [key_buf_used++] = ch;
+ key_buf_used += key_SU_code (ch, ((char*)key_buf) + key_buf_used);
+
while (*src)
((char*)key_buf) [key_buf_used++] = *src++;
src++;
p->file_moffset = offset;
}
-static int atois (const char **s)
-{
- int val = 0, c;
- while ( (c=**s) >= '0' && c <= '9')
- {
- val = val*10 + c - '0';
- ++(*s);
- }
- return val;
-}
-
static char *fileMatchStr (struct recKeys *reckeys, struct recordGroup *rGroup,
- const char *fname,
- const char *spec)
+ const char *fname, const char *spec)
{
static char dstBuf[2048];
char *dst = dstBuf;
const char *s = spec;
static const char **w;
- int i;
while (1)
{
break;
if (*s == '(')
{
+ char attset_str[64], attname_str[64];
+ data1_attset *attset;
+ int i;
char matchFlag[32];
- int attrSet, attrUse;
+ int attSet = 1, attUse = 1;
int first = 1;
s++;
- attrSet = atois (&s);
- if (*s != ',')
- {
- logf (LOG_WARN, "Missing , in match criteria %s in group %s",
- spec, rGroup->groupName ? rGroup->groupName : "none");
- return NULL;
- }
- s++;
- attrUse = atois (&s);
- w = searchRecordKey (reckeys, attrSet, attrUse);
+ for (i = 0; *s && *s != ',' && *s != ')'; s++)
+ if (i < 63)
+ attset_str[i++] = *s;
+ attset_str[i] = '\0';
+
+ if (*s == ',')
+ {
+ s++;
+ for (i = 0; *s && *s != ')'; s++)
+ if (i < 63)
+ attname_str[i++] = *s;
+ attname_str[i] = '\0';
+ }
+
+ if ((attset = data1_get_attset (rGroup->dh, attset_str)))
+ {
+ data1_att *att;
+ attSet = attset->reference;
+ att = data1_getattbyname(rGroup->dh, attset, attname_str);
+ if (att)
+ attUse = att->value;
+ else
+ attUse = atoi (attname_str);
+ }
+ w = searchRecordKey (reckeys, attSet, attUse);
assert (w);
if (*s == ')')
if (first)
{
logf (LOG_WARN, "Record didn't contain match"
- " fields in (%d,%d)", attrSet, attrUse);
+ " fields in (%s,%s)", attset_str, attname_str);
return NULL;
}
}
logf (LOG_DEBUG, "fileExtract %s", fname);
/* determine file extension */
+ *ext = '\0';
for (i = strlen(fname); --i >= 0; )
if (fname[i] == '/')
- {
- strcpy (ext, "");
break;
- }
else if (fname[i] == '.')
{
strcpy (ext, fname+i+1);
if (!(rGroup->recordType = res_get (common_resource, ext_res)))
{
sprintf (ext_res, "%srecordType", gprefix);
- if (!(rGroup->recordType = res_get (common_resource, ext_res)))
- {
- if (records_processed < rGroup->fileVerboseLimit)
- logf (LOG_LOG, "? %s", fname);
- return 0;
- }
+ rGroup->recordType = res_get (common_resource, ext_res);
}
}
if (!rGroup->recordType)
{
if (records_processed < rGroup->fileVerboseLimit)
- logf (LOG_LOG, "? record %s", fname);
+ logf (LOG_LOG, "? %s", fname);
return 0;
}
+ if (!*rGroup->recordType)
+ return 0;
if (!(recType = recType_byName (rGroup->recordType, subType)))
{
logf (LOG_WARN, "No such record type: %s", rGroup->recordType);
if (!rGroup->databaseName)
rGroup->databaseName = "Default";
+ /* determine if explain database */
+
+ sprintf (ext_res, "%sexplainDatabase", gprefix);
+ rGroup->explainDatabase =
+ atoi (res_get_def (common_resource, ext_res, "0"));
+
+ /* announce database */
if (zebraExplain_curDatabase (zti, rGroup->databaseName))
{
- if (zebraExplain_newDatabase (zti, rGroup->databaseName))
+ if (zebraExplain_newDatabase (zti, rGroup->databaseName,
+ rGroup->explainDatabase))
abort ();
}
if (zebraExplain_curDatabase (zti, rec->info[recInfo_databaseName]))
{
- if (zebraExplain_newDatabase (zti, rec->info[recInfo_databaseName]))
+ if (zebraExplain_newDatabase (zti, rec->info[recInfo_databaseName], 0))
abort ();
}