- wrbuf_rewind(p->wr_error);
- wrbuf_printf(p->wr_error, "yaz_retrieval_request: not implemented");
- return -1;
+ struct yaz_retrieval_elem *el = p->list;
+
+ int syntax_matches = 0;
+ int schema_matches = 0;
+ for(; el; el = el->next)
+ {
+ int schema_ok = 0;
+ int syntax_ok = 0;
+
+ if (schema && el->schema && !strcmp(schema, el->schema))
+ schema_ok = 1;
+ if (schema && el->identifier && !strcmp(schema, el->identifier))
+ schema_ok = 1;
+ if (!schema)
+ schema_ok = 1;
+
+ if (syntax && el->syntax && !oid_oidcmp(syntax, el->syntax))
+ syntax_ok = 1;
+ if (!syntax)
+ syntax_ok = 1;
+
+ if (syntax_ok)
+ syntax_matches++;
+ if (schema_ok)
+ schema_matches++;
+ if (syntax_ok && schema_ok)
+ {
+ *match_syntax = el->syntax;
+ *match_schema = el->schema;
+ if (backend_schema)
+ *backend_schema = el->backend_schema;
+ if (backend_syntax)
+ *backend_syntax = el->backend_syntax;
+ if (rc)
+ *rc = el->record_conv;
+ return 0;
+ }
+ }
+ if (syntax_matches && !schema_matches)
+ return 1;
+ if (!syntax_matches && schema_matches)
+ return 2;
+ if (!syntax_matches && !schema_matches)
+ return 3;
+ return 4;