Minor changes.
[idzebra-moved-to-github.git] / index / zebraapi.c
index a87ee4a..7caf21a 100644 (file)
@@ -4,7 +4,13 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: zebraapi.c,v $
- * Revision 1.3  1998-05-27 16:57:44  adam
+ * Revision 1.5  1998-06-13 00:14:08  adam
+ * Minor changes.
+ *
+ * Revision 1.4  1998/06/12 12:22:12  adam
+ * Work on Zebra API.
+ *
+ * Revision 1.3  1998/05/27 16:57:44  adam
  * Zebra returns surrogate diagnostic for single records when
  * appropriate.
  *
@@ -26,6 +32,7 @@
 #include <unistd.h>
 #endif
 
+#include <diagbib1.h>
 #include "zserver.h"
 
 static int zebra_register_lock (ZebraHandle zh)
@@ -123,7 +130,7 @@ static void zebra_register_unlock (ZebraHandle zh)
         zebra_server_unlock (zh, zh->registerState);
 }
 
-ZebraHandle zebra_open (const char *host, const char *configName)
+ZebraHandle zebra_open (const char *configName)
 {
     ZebraHandle zh = xmalloc (sizeof(*zh));
 
@@ -144,6 +151,8 @@ ZebraHandle zebra_open (const char *host, const char *configName)
     zh->records = NULL;
     zh->zebra_maps = zebra_maps_open (zh->res);
     zh->rank_classes = NULL;
+    zh->errCode = 0;
+    zh->errString = 0;
     
     zebraRankInstall (zh, rank1_class);
     return zh;
@@ -195,7 +204,8 @@ void zebra_records_retrieve (ZebraHandle zh, ODR stream,
     int i, *pos_array;
 
     zh->errCode = 0;
-    pos_array = xmalloc (sizeof(*pos_array));
+    zh->errString = NULL;
+    pos_array = xmalloc (num_recs * sizeof(*pos_array));
     for (i = 0; i<num_recs; i++)
        pos_array[i] = recs[i].position;
 
@@ -240,6 +250,7 @@ void zebra_scan (ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
                 int *is_partial)
 {
     zh->errCode = 0;
+    zh->errString = NULL;
     zebra_register_lock (zh);
     rpn_scan (zh, stream, zapt, attributeset,
              num_bases, basenames, position,
@@ -252,12 +263,34 @@ void zebra_sort (ZebraHandle zh, ODR stream,
                 char *output_setname, Z_SortKeySpecList *sort_sequence,
                 int *sort_status)
 {
+    zh->errCode = 0;
+    zh->errString = NULL;
     zebra_register_lock (zh);
     resultSetSort (zh, stream, num_input_setnames, input_setnames,
                   output_setname, sort_sequence, sort_status);
     zebra_register_unlock (zh);
 }
 
+int zebra_errCode (ZebraHandle zh)
+{
+    return zh->errCode;
+}
+
+const char *zebra_errString (ZebraHandle zh)
+{
+    return diagbib1_str (zh->errCode);
+}
+
+char *zebra_errAdd (ZebraHandle zh)
+{
+    return zh->errString;
+}
+
+int zebra_hits (ZebraHandle zh)
+{
+    return zh->hits;
+}
+
 void zebra_setDB (ZebraHandle zh, int num_bases, char **basenames)
 {