Merge branch 'master' of ssh://git.indexdata.com/home/git/pub/mp-sparql
[mp-sparql-moved-to-github.git] / src / sparql.c
index 036e137..50f41f6 100644 (file)
@@ -372,6 +372,21 @@ 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 *e;
+
+    for (e = s->conf; e; e = e->next)
+    {
+        if (!strncmp(e->pattern, "uri.", 4))
+        {
+            if (!schema || !strcmp(e->pattern + 4, schema))
+                break;
+        }
+    }
+    return e ? 1 : 0;
+}
+
 int yaz_sparql_from_uri_stream(yaz_sparql_t s,
                                WRBUF addinfo,
                                void (*pr)(const char *buf, void *client_data),
@@ -383,11 +398,9 @@ int yaz_sparql_from_uri_stream(yaz_sparql_t s,
 
     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, "uri.", 4))
         {
-            if (!strcmp(e->pattern + 4, schema))
+            if (!schema || !strcmp(e->pattern + 4, schema))
                 break;
         }
     }