+// parses crit1=val1,crit2=val2|val3,...
+static struct database_criterion *create_database_criterion(NMEM m,
+ const char *buf)
+{
+ struct database_criterion *res = 0;
+ char **values;
+ int num;
+ int i;
+
+ if (!buf || !*buf)
+ return 0;
+ nmem_strsplit(m, ",", buf, &values, &num);
+ for (i = 0; i < num; i++)
+ {
+ char **subvalues;
+ int subnum;
+ int subi;
+ struct database_criterion *new = nmem_malloc(m, sizeof(*new));
+ char *eq;
+ for (eq = values[i]; *eq; eq++)
+ if (*eq == '=')
+ {
+ new->type = PAZPAR2_STRING_MATCH;
+ break;
+ }
+ else if (*eq == '~')
+ {
+ new->type = PAZPAR2_SUBSTRING_MATCH;
+ break;
+ }
+ if (!*eq)
+ {
+ yaz_log(YLOG_WARN, "Missing equal-sign/tilde in filter");
+ return 0;
+ }
+ *(eq++) = '\0';
+ new->name = values[i];
+ nmem_strsplit(m, "|", eq, &subvalues, &subnum);
+ new->values = 0;
+ for (subi = 0; subi < subnum; subi++)
+ {
+ struct database_criterion_value *newv
+ = nmem_malloc(m, sizeof(*newv));
+ newv->value = subvalues[subi];
+ newv->next = new->values;
+ new->values = newv;
+ }
+ new->next = res;
+ res = new;
+ }
+ return res;
+}
+
+static int database_match_criteria(struct setting **settings,
+ struct conf_service *service,
+ struct database_criterion *cl)