X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fsparql.c;h=c738e5df87c7bfc7d1969aab3948e3a1ccbc2b68;hb=a0884c6c35bc62160b6ce6100a4e8ad2d15ab937;hp=e9987a148cd13f7398f37b3155f0c5453ecf679b;hpb=c15f541624500e98bcea49b8a77c24d28d4c434d;p=mp-sparql-moved-to-github.git diff --git a/src/sparql.c b/src/sparql.c index e9987a1..c738e5d 100644 --- a/src/sparql.c +++ b/src/sparql.c @@ -37,6 +37,13 @@ void yaz_sparql_destroy(yaz_sparql_t s) nmem_destroy(s->nmem); } +void yaz_sparql_include(yaz_sparql_t s, yaz_sparql_t u) +{ + struct sparql_entry *e = u->conf; + for (; e; e = e->next) + yaz_sparql_add_pattern(s, e->pattern, e->value); +} + int yaz_sparql_add_pattern(yaz_sparql_t s, const char *pattern, const char *value) { @@ -359,6 +366,10 @@ static int emit_prefixes(yaz_sparql_t s, { ; } + else if (!strncmp(e->pattern, "present", 7)) + { + ; + } else if (!strncmp(e->pattern, "uri", 3)) { ; @@ -372,21 +383,29 @@ static int emit_prefixes(yaz_sparql_t s, return errors; } -int yaz_sparql_lookup_schema(yaz_sparql_t s, const char *schema) +struct sparql_entry *lookup_schema(yaz_sparql_t s, const char *schema) { struct sparql_entry *e; for (e = s->conf; e; e = e->next) { - if (!schema && !strcmp(e->pattern, "uri")) - break; - else if (schema && !strncmp(e->pattern, "uri.", 4)) + if (!strncmp(e->pattern, "present.", 8)) { - if (!strcmp(e->pattern + 4, schema)) + if (!schema || !strcmp(e->pattern + 8, schema)) + break; + } + if (!strncmp(e->pattern, "uri.", 4)) + { + if (!schema || !strcmp(e->pattern + 4, schema)) break; } } - return e ? 1 : 0; + return e; +} + +int yaz_sparql_lookup_schema(yaz_sparql_t s, const char *schema) +{ + return lookup_schema(s, schema) ? 1 : 0; } int yaz_sparql_from_uri_stream(yaz_sparql_t s, @@ -396,18 +415,7 @@ int yaz_sparql_from_uri_stream(yaz_sparql_t s, const char *uri, const char *schema) { int r = 0, errors = emit_prefixes(s, addinfo, pr, client_data); - struct sparql_entry *e; - - for (e = s->conf; e; e = e->next) - { - if (!schema && !strcmp(e->pattern, "uri")) - break; - else if (schema && !strncmp(e->pattern, "uri.", 4)) - { - if (!strcmp(e->pattern + 4, schema)) - break; - } - } + struct sparql_entry *e = lookup_schema(s, schema); if (!e) errors++; if (!errors)