Some hacks to get the FIFO communication work!! Isn't reliable.
[egate.git] / kernel / main.c
index 9398e2b..374ca49 100644 (file)
@@ -2,7 +2,20 @@
  * Europagate, 1995
  *
  * $Log: main.c,v $
- * Revision 1.15  1995/04/17 09:34:30  adam
+ * Revision 1.19  1995/04/19 16:01:58  adam
+ * Some hacks to get the FIFO communication work!! Isn't reliable.
+ * Resource gw.account added - default account info.
+ *
+ * Revision 1.18  1995/04/19  13:19:09  adam
+ * New command: account - for authentication.
+ *
+ * Revision 1.17  1995/04/19  10:46:18  adam
+ * Persistency works much better now. New command: status - history-like
+ *
+ * Revision 1.16  1995/04/19  07:31:07  adam
+ * First work on Z39.50 persistence.
+ *
+ * Revision 1.15  1995/04/17  09:34:30  adam
  * Timeout (idletime) adjustable. Minor changes in kernel.
  *
  * Revision 1.14  1995/03/28  11:42:34  adam
@@ -94,6 +107,7 @@ static void kernel_events (struct str_queue *queue, int userid)
     gip = gips_initialize (fifo_server_name);
     gips_open (gip, fifo_client_name);
     gip_fd = gip_infileno (gip);
+    open (fifo_server_name, O_WRONLY);
 
     while (1)
     {
@@ -113,6 +127,8 @@ static void kernel_events (struct str_queue *queue, int userid)
        {
            gw_log (GW_LOG_STAT, KERNEL_LOG, "Timeout after %d seconds", 
                    timeout);
+           if (info.zass)
+               save_p_state (userid);
            break;
        }
        if (FD_ISSET (gip_fd, &set_r))
@@ -133,6 +149,8 @@ static void kernel_events (struct str_queue *queue, int userid)
                 while (lgets (line_buf, sizeof(line_buf)-1, gip_fd))
                     str_queue_enq (queue, line_buf);
                urp_start (continuation, queue);
+                if (!continuation)
+                   load_p_state (userid);      
                urp_command (queue);
                urp_end ();
                 while (str_queue_deq (queue, 0, 0))
@@ -165,6 +183,7 @@ int main (int argc, char **argv)
     info.default_res = "default.res";
     info.override_res = NULL;
     *info.target = 0;
+    *info.account = 0;
     info.lang = NULL;
     info.bibset = NULL;
     info.zass = NULL;
@@ -172,6 +191,7 @@ int main (int argc, char **argv)
     info.override_hostname = NULL;
     info.databases = NULL;
     info.database = NULL;
+    info.setno = -1;
 #if USE_FML
     info.fml = NULL;
 #endif
@@ -200,6 +220,9 @@ int main (int argc, char **argv)
                 fprintf (stderr, " -i id        Set IPC userid\n");
                 exit (1);
             case 'd':
+                gw_log_level (GW_LOG_ALL & ~RES_DEBUG);
+                break;
+            case 'D':
                 gw_log_level (GW_LOG_ALL);
                 break;
             case 't':
@@ -308,17 +331,20 @@ int main (int argc, char **argv)
         else
             info.default_res = *argv;
     }
-    read_kernel_res ();
     if (!(queue = str_queue_mk ()))
     {
         gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, KERNEL_LOG, "str_queue_mk");
         exit (1);
     }
     if (userid != -1)
+    {
+       read_kernel_res ();
         kernel_events (queue, userid);
+    }
     else
     {
         char line_buf[512];
+        read_kernel_res ();
         while (lgets (line_buf, sizeof(line_buf)-1, 0))
             str_queue_enq (queue, line_buf);
        urp_start (0, queue);
@@ -328,7 +354,11 @@ int main (int argc, char **argv)
     return 0;
 }
 
-struct gw_user_set *user_set_add (const char *name, int hits)
+struct gw_user_set *user_set_add (const char *name, int hits, 
+                                 const char *database, 
+                                 struct ccl_rpn_node *rpn,
+                                 int present_flag,
+                                  const char *search_str)
 {
     struct gw_user_set *s;
 
@@ -337,6 +367,10 @@ struct gw_user_set *user_set_add (const char *name, int hits)
 
     s->name = gw_strdup (name);
     s->hits = hits;
+    s->database = gw_strdup (database);
+    s->rpn = rpn;
+    s->present_flag = present_flag;
+    s->search_str = gw_strdup (search_str);
     s->prev = info.sets;
     info.sets = s;
     return s;
@@ -349,6 +383,8 @@ void user_set_init (void)
     for (s = info.sets; s; s = s1)
     {
         free (s->name);
+       free (s->database);
+       ccl_rpn_delete (s->rpn);
         s1 = s->prev;
         free (s);
     }
@@ -460,16 +496,20 @@ void read_kernel_res (void)
     if (*info.target && ! gw_res_get (info.kernel_res, resource_name, NULL))
     {
         /* target is there, and there is no sub-resource for it... */
-        char *split;
+        const char *split;
 
         if ((split = strchr (info.target, ':')))
-            *split++ = '\0';
-        strncpy (info.hostname, info.target, sizeof(info.hostname)-1);
-        if (split)
-            info.port = atoi (split);
+        {
+            memcpy (info.hostname, info.target, split-info.target);
+            info.hostname[split-info.target] = '\0';
+            info.port = atoi (split+1);
+        }
         else
+        {
+            strcpy (info.hostname, info.target);
             info.port = atoi (gw_res_get
                               (info.kernel_res, "gw.portno", "210"));
+        }
     }
     else
     {
@@ -478,6 +518,7 @@ void read_kernel_res (void)
                  sizeof(info.hostname)-1);
         info.port = atoi (gw_res_get (info.kernel_res,
                                       "gw.portno", "210"));
+        strcpy (info.account, gw_res_get (info.kernel_res, "gw.account", ""));
     }
     if (info.databases)
         free (info.databases);
@@ -510,6 +551,8 @@ void read_kernel_res (void)
     if (info.override_hostname)
         strncpy (info.hostname, info.override_hostname,
                  sizeof(info.hostname)-1);
+    v = gw_res_get (info.kernel_res, "gw.result.set", NULL);
+    info.setno = v ? -1 : 0;
 #if USE_FML
     if (!info.fml)
     {