X-Git-Url: http://lists.indexdata.com/cgi-bin?a=blobdiff_plain;f=src%2Flogic.c;h=8c2d070337ced82c28b7daebded0575ac631ed8a;hb=9b836e74ec3520f3c60b20515bab10940d4c6897;hp=e243d58b77687fb794504070ff096394f0234565;hpb=298428237ab753a1644549f9c9c88feeb90d5919;p=pazpar2-moved-to-github.git diff --git a/src/logic.c b/src/logic.c index e243d58..8c2d070 100644 --- a/src/logic.c +++ b/src/logic.c @@ -350,17 +350,21 @@ static int prepare_map(struct session *se, struct session_database *sdb) nmem_strsplit(se->session_nmem, ",", s, &stylesheets, &num); for (i = 0; i < num; i++) { + WRBUF fname = conf_get_fname(se->service, stylesheets[i]); + (*m) = nmem_malloc(se->session_nmem, sizeof(**m)); (*m)->next = 0; - + // XSLT if (!strcmp(&stylesheets[i][strlen(stylesheets[i])-4], ".xsl")) { (*m)->marcmap = NULL; - if (!((*m)->stylesheet = conf_load_stylesheet(se->service, stylesheets[i]))) + if (!((*m)->stylesheet = + xsltParseStylesheetFile((xmlChar *) wrbuf_cstr(fname)))) { yaz_log(YLOG_FATAL|YLOG_ERRNO, "Unable to load stylesheet: %s", stylesheets[i]); + wrbuf_destroy(fname); return -1; } } @@ -368,14 +372,15 @@ static int prepare_map(struct session *se, struct session_database *sdb) else if (!strcmp(&stylesheets[i][strlen(stylesheets[i])-5], ".mmap")) { (*m)->stylesheet = NULL; - if (!((*m)->marcmap = marcmap_load(stylesheets[i], se->session_nmem))) + if (!((*m)->marcmap = marcmap_load(wrbuf_cstr(fname), se->session_nmem))) { yaz_log(YLOG_FATAL|YLOG_ERRNO, "Unable to load marcmap: %s", stylesheets[i]); + wrbuf_destroy(fname); return -1; } } - + wrbuf_destroy(fname); m = &(*m)->next; } } @@ -566,7 +571,7 @@ enum pazpar2_error_code search(struct session *se, else { no_working++; - if (client_prep_connection(cl, se->service->z3950_connect_timeout, + if (client_prep_connection(cl, se->service->z3950_operation_timeout, se->service->z3950_session_timeout)) client_start_search(cl); } @@ -1035,20 +1040,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 +1069,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); }