projects
/
mp-sparql-moved-to-github.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
16b2af1
)
DRY the schema lookup
author
Adam Dickmeiss
<adam@indexdata.dk>
Thu, 30 Apr 2015 08:44:08 +0000
(10:44 +0200)
committer
Adam Dickmeiss
<adam@indexdata.dk>
Thu, 30 Apr 2015 08:44:08 +0000
(10:44 +0200)
src/sparql.c
patch
|
blob
|
history
diff --git
a/src/sparql.c
b/src/sparql.c
index
50f41f6
..
0ce6c40
100644
(file)
--- a/
src/sparql.c
+++ b/
src/sparql.c
@@
-372,7
+372,7
@@
static int emit_prefixes(yaz_sparql_t s,
return errors;
}
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;
{
struct sparql_entry *e;
@@
-384,7
+384,12
@@
int yaz_sparql_lookup_schema(yaz_sparql_t s, const char *schema)
break;
}
}
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,
}
int yaz_sparql_from_uri_stream(yaz_sparql_t s,
@@
-394,16
+399,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);
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 (!strncmp(e->pattern, "uri.", 4))
- {
- if (!schema || !strcmp(e->pattern + 4, schema))
- break;
- }
- }
+ struct sparql_entry *e = lookup_schema(s, schema);
if (!e)
errors++;
if (!errors)
if (!e)
errors++;
if (!errors)