}
if (!settings[offset])
return 0;
- for (v = c->values; v; v = v->next)
- {
- if (offset == PZ_ID)
+ if (c->type == PAZPAR2_STRING_MATCH)
+ for (v = c->values; v; v = v->next)
{
- if (match_zurl(settings[offset]->value, v->value))
- break;
+ if (offset == PZ_ID)
+ {
+ if (match_zurl(settings[offset]->value, v->value))
+ break;
+ }
+ else
+ {
+ if (!strcmp(settings[offset]->value, v->value))
+ break;
+ }
}
- else
+ else if (c->type == PAZPAR2_SUBSTRING_MATCH)
+ for (v = c->values; v; v = v->next)
{
- if (!strcmp(settings[offset]->value, v->value))
- break;
+ if (offset == PZ_ID)
+ {
+ if (match_zurl(settings[offset]->value, v->value))
+ break;
+ }
+ else
+ {
+ if (strstr(settings[offset]->value, v->value))
+ break;
+ }
}
- }
if (v)
return 1;
else
int subnum;
int subi;
struct database_criterion *new = nmem_malloc(m, sizeof(*new));
- char *eq = strchr(values[i], '=');
+ char *eq;
+ if (eq = strchr(values[i], '='))
+ new->type = PAZPAR2_STRING_MATCH;
+ if (eq = strchr(values[i], '~'))
+ new->type = PAZPAR2_SUBSTRING_MATCH;
if (!eq)
{
- yaz_log(YLOG_WARN, "Missing equal-sign in filter");
+ yaz_log(YLOG_WARN, "Missing equal-signi/tilde in filter");
return 0;
}
*(eq++) = '\0';
PAZPAR2_LAST_ERROR
};
+enum pazpar2_database_criterion_type {
+ PAZPAR2_STRING_MATCH,
+ PAZPAR2_SUBSTRING_MATCH
+};
+
// Represents a (virtual) database on a host
struct database {
struct host *host;
struct database_criterion {
char *name;
+ enum pazpar2_database_criterion_type type;
struct database_criterion_value *values;
struct database_criterion *next;
};