From 3b9f14584e5a07fa762ed9189c72294f6b15e08c Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 28 Sep 2009 20:18:50 +0200 Subject: [PATCH] pz:recordfilter form is name[=substring]. pz:recordfilter is now of the form name[=substring]. A record is included if metadata element is present and existing (substring omitted) or includes substring (substring included). --- src/logic.c | 35 +++++++++++------------------------ test/test_http_urls | 3 ++- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/src/logic.c b/src/logic.c index e243d58..a45a8c3 100644 --- a/src/logic.c +++ b/src/logic.c @@ -1035,20 +1035,6 @@ static const char *get_mergekey(xmlDoc *doc, struct client *cl, int record_no, return mergekey_norm; } -static const char *str_tok_n(const char *s, const char *delim, - const char **res, size_t *len) -{ - *res = s; - while (*s && !strchr(delim, *s)) - s++; - *len = s - *res; - if (*len == 0) - return 0; - if (*s && strchr(delim, *s)) - s++; - return s; -} - /** \brief see if metadata for pz:recordfilter exists \param root xml root element of normalized record \param sdb session database for client @@ -1078,21 +1064,22 @@ static int check_record_filter(xmlNode *root, struct session_database *sdb) xmlChar *type = xmlGetProp(n, (xmlChar *) "type"); if (type) { - const char *s1 = s; size_t len; - const char *value; - while ((s1 = str_tok_n(s1, ",", &value, &len)) != 0) + const char *eq = strchr(s, '='); + if (eq) + len = eq - s; + else + len = strlen(s); + if (len == strlen((const char *)type) && + !memcmp((const char *) type, s, len)) { - if (len == strlen((const char *)type) && - !memcmp((const char *) type, s, len)) + xmlChar *value = xmlNodeGetContent(n); + if (value && *value) { - xmlChar *value = xmlNodeGetContent(n); - if (value && *value) - { - xmlFree(value); + if (!eq || strstr((const char *) value, eq+1)) match = 1; - } } + xmlFree(value); } xmlFree(type); } diff --git a/test/test_http_urls b/test/test_http_urls index c84e9b9..47adc23 100644 --- a/test/test_http_urls +++ b/test/test_http_urls @@ -37,6 +37,7 @@ http://localhost:9763/search.pz2?session=4&command=search&query=computer 2 http://localhost:9763/search.pz2?session=4&command=show&start=0&number=1&block=1 http://localhost:9763/search.pz2?command=init&clear=1 -http://localhost:9763/search.pz2?session=5&command=settings&pz:name[z3950.indexdata.com%2Fmarc]=marc&pz:requestsyntax[z3950.indexdata.com%2Fmarc]=usmarc&pz:nativesyntax[z3950.indexdata.com%2Fmarc]=iso2709&pz:xslt[z3950.indexdata.com%2Fmarc]=marc21.xsl&pz:recordfilter[z3950.indexdata.com%2Fmarc]=date,title +http://localhost:9763/search.pz2?session=5&command=settings&pz:name[z3950.indexdata.com%2Fmarc]=marc&pz:requestsyntax[z3950.indexdata.com%2Fmarc]=usmarc&pz:nativesyntax[z3950.indexdata.com%2Fmarc]=iso2709&pz:xslt[z3950.indexdata.com%2Fmarc]=marc21.xsl&pz:recordfilter[z3950.indexdata.com%2Fmarc]=date http://localhost:9763/search.pz2?session=5&command=search&query=computer +2 http://localhost:9763/search.pz2?session=5&command=show&start=0&number=1&block=1 -- 1.7.10.4