Change return values for yaz_retrieval_request a bit and improve
[yaz-moved-to-github.git] / src / retrieval.c
index d86b928..c433d61 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 2005-2006, Index Data ApS
  * See the file LICENSE for details.
  *
  * Copyright (C) 2005-2006, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: retrieval.c,v 1.6 2006-05-08 11:58:37 adam Exp $
+ * $Id: retrieval.c,v 1.7 2006-05-08 19:48:26 adam Exp $
  */
 /**
  * \file retrieval.c
  */
 /**
  * \file retrieval.c
@@ -242,6 +242,7 @@ int yaz_retrieval_request(yaz_retrieval_t p,
     int syntax_matches = 0;
     int schema_matches = 0;
 
     int syntax_matches = 0;
     int schema_matches = 0;
 
+    wrbuf_rewind(p->wr_error);
     if (!el)
         return 0;
     for(; el; el = el->next)
     if (!el)
         return 0;
     for(; el; el = el->next)
@@ -255,6 +256,8 @@ int yaz_retrieval_request(yaz_retrieval_t p,
             schema_ok = 1;
         if (!schema)
             schema_ok = 1;
             schema_ok = 1;
         if (!schema)
             schema_ok = 1;
+        if (schema && !el->schema)
+            schema_ok = 1;
         
         if (syntax && el->syntax && !oid_oidcmp(syntax, el->syntax))
             syntax_ok = 1;
         
         if (syntax && el->syntax && !oid_oidcmp(syntax, el->syntax))
             syntax_ok = 1;
@@ -278,13 +281,16 @@ int yaz_retrieval_request(yaz_retrieval_t p,
             return 0;
         }
     }
             return 0;
         }
     }
-    if (syntax_matches && !schema_matches)
-        return 1;
-    if (!syntax_matches && schema_matches)
+    if (!syntax_matches && syntax)
+    {
+        wrbuf_printf(p->wr_error, "%s", syntax);
         return 2;
         return 2;
-    if (!syntax_matches && !schema_matches)
-        return 3;
-    return 4;
+    }
+    if (schema)
+        wrbuf_printf(p->wr_error, "%s", schema);
+    if (!schema_matches)
+        return 1;
+    return 3;
 }
 
 const char *yaz_retrieval_get_error(yaz_retrieval_t p)
 }
 
 const char *yaz_retrieval_get_error(yaz_retrieval_t p)