CCL commands stop/continue implemented. New functions gw_res_{int,bool}
[egate.git] / kernel / main.c
index 63d6a4f..8a5971c 100644 (file)
@@ -2,7 +2,11 @@
  * Europagate, 1995
  *
  * $Log: main.c,v $
- * Revision 1.21  1995/05/01 16:26:56  adam
+ * Revision 1.22  1995/05/03 07:37:39  adam
+ * CCL commands stop/continue implemented. New functions gw_res_{int,bool}
+ * are used when possible.
+ *
+ * Revision 1.21  1995/05/01  16:26:56  adam
  * More work on resource monitor.
  *
  * Revision 1.20  1995/05/01  12:43:32  adam
@@ -104,8 +108,10 @@ static void kernel_events (struct str_queue *queue, int userid)
     int timeout;
     int continuation = 0;
     int extra_fd;
+    int persist_flag;
 
-    timeout = atoi(gw_res_get (info.kernel_res, "gw.timeout", "600"));
+    persist_flag = gw_res_bool (info.kernel_res, "gw.persist", 0);
+    timeout = gw_res_int (info.kernel_res, "gw.timeout", 600);
     gw_log (GW_LOG_DEBUG, KERNEL_LOG, "event loop");
 
     sprintf (fifo_client_name, "fifo.c.%d", userid);
@@ -134,7 +140,7 @@ 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)
+           if (info.zass && persist_flag)
                save_p_state (userid);
            break;
        }
@@ -156,9 +162,11 @@ 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)
+                if (persist_flag && !continuation)
                    load_p_state (userid);      
-               urp_command (queue);
+               r = urp_command (queue);
+               if (persist_flag && r == 1)
+                   del_p_state (userid);
                urp_end ();
                 while (str_queue_deq (queue, 0, 0))
                     ;
@@ -515,8 +523,7 @@ void read_kernel_res (void)
         else
         {
             strcpy (info.hostname, info.target);
-            info.port = atoi (gw_res_get
-                              (info.kernel_res, "gw.portno", "210"));
+            info.port = gw_res_int (info.kernel_res, "gw.portno", 210);
         }
     }
     else
@@ -524,8 +531,7 @@ void read_kernel_res (void)
         strncpy (info.hostname, gw_res_get (info.kernel_res,
                                             "gw.hostname", "localhost"),
                  sizeof(info.hostname)-1);
-        info.port = atoi (gw_res_get (info.kernel_res,
-                                      "gw.portno", "210"));
+        info.port = gw_res_int (info.kernel_res, "gw.portno", 210);
         strcpy (info.account, gw_res_get (info.kernel_res, "gw.account", ""));
     }
     if (info.databases)
@@ -559,8 +565,10 @@ 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 (gw_res_bool (info.kernel_res, "gw.result.set", 1))
+        info.setno = 0;
+    else
+        info.setno = -1;
 #if USE_FML
     if (!info.fml)
     {