First work on Z39.50 persistence.
[egate.git] / kernel / urp.c
index aaba374..032392c 100644 (file)
@@ -2,7 +2,10 @@
  * Europagate, 1995
  *
  * $Log: urp.c,v $
- * Revision 1.25  1995/04/17 09:34:33  adam
+ * Revision 1.26  1995/04/19 07:31:12  adam
+ * First work on Z39.50 persistence.
+ *
+ * Revision 1.25  1995/04/17  09:34:33  adam
  * Timeout (idletime) adjustable. Minor changes in kernel.
  *
  * Revision 1.24  1995/03/28  11:42:35  adam
@@ -129,7 +132,7 @@ int lgets (char *buf, int max, int fd)
     return 1;
 }
 
-static int reopen_target (void)
+int reopen_target (void)
 {
     const char *v;
     if (info.zass)
@@ -322,12 +325,16 @@ static int exec_find (struct ccl_token *list)
 {
     const struct zass_searchent *p;
     struct gw_user_set *us;
+    char setname[32];
 
     struct ccl_rpn_node *rpn;
     int error;
     const char *pos;
 
-    us = user_set_add ("Default", -1);
+    if (info.setno == -1)
+        strcpy (setname, "Default");
+    else
+        sprintf (setname, "%d", info.setno);
     rpn = ccl_find (info.bibset, list, &error, &pos);
     if (!rpn)
     {
@@ -360,9 +367,13 @@ static int exec_find (struct ccl_token *list)
     gw_log (GW_LOG_DEBUG, KERNEL_LOG, "Searching in database %s",
             info.database );
     assert (info.zass);
-    p = zass_search (info.zass, rpn, "Default", info.database );
+    fprintf (reply_fd, "Searching in database %s\n", info.database);
+    p = zass_p_search (info.zass, rpn, setname, info.database, info.sets);
     if (!p)
+    {
+        fprintf (reply_fd, "Search fail\n");
         return -1;
+    }
     if (p->errcode != -1)
     {
         display_diag_error (p->errcode, p->errstring);
@@ -370,7 +381,10 @@ static int exec_find (struct ccl_token *list)
     }
     fprintf (reply_fd, "%d %s\n", p->num,
              gw_res_get (info.kernel_res, "gw.msg.hits", "hit(s)"));
-    us->hits = p->num;
+    us = user_set_add (setname, p->num, info.database, rpn, 1);
+    fprintf (reply_fd, "Result-set %s created\n", setname);
+    if (info.setno >= 0)
+        info.setno++;
     return 0;
 }
 
@@ -442,7 +456,7 @@ static void present (const char *set, int offset, int number,
     gw_log (GW_LOG_DEBUG, KERNEL_LOG, "present in set %s", set);
     gw_log (GW_LOG_DEBUG, KERNEL_LOG, "present of %d records from offset %d",
             number, offset);
-    zp = zass_present(info.zass, (char *) set, offset, number);
+    zp = zass_p_present(info.zass, (char *) set, offset, number);
     if (zp)
     {
         int i;