-/* $Id: database.c,v 1.3 2007-03-20 05:32:58 quinn Exp $ */
+/* $Id: database.c,v 1.4 2007-03-23 03:26:22 quinn Exp $ */
#include <libxml/parser.h>
#include <libxml/tree.h>
return load_database(id);
}
+// This will be generalized at some point
static int match_criterion(struct database *db, struct database_criterion *c)
{
if (!strcmp(c->name, "id"))
- return (!strcmp(c->value, db->url));
+ {
+ struct database_criterion_value *v;
+ for (v = c->values; v; v = v->next)
+ if (!strcmp(v->value, db->url))
+ return 1;
+ return 0;
+ }
else
return 0;
}
-/* $Id: pazpar2.c,v 1.51 2007-03-20 07:27:51 adam Exp $ */
+/* $Id: pazpar2.c,v 1.52 2007-03-23 03:26:22 quinn Exp $ */
#include <stdlib.h>
#include <stdio.h>
return res;
}
-// parses crit1=val1,crit2=val2,...
+// parses crit1=val1,crit2=val2|val3,...
static struct database_criterion *parse_filter(NMEM m, const char *buf)
{
struct database_criterion *res = 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 = strchr(values[i], '=');
if (!eq)
}
*(eq++) = '\0';
new->name = values[i];
- new->value = eq;
+ 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;
}
struct database *next;
};
+struct database_criterion_value {
+ char *value;
+ struct database_criterion_value *next;
+};
+
struct database_criterion {
char *name;
- char *value;
+ struct database_criterion_value *values;
struct database_criterion *next;
};