CCL def command, i.e. user definitions - saved as resource files.
[egate.git] / kernel / eti.c
index b0623d6..7b028d0 100644 (file)
@@ -1,8 +1,34 @@
-/* Gateway kernel
+/* Gateway Email Transport Interface
  * Europagate, 1995
  *
  * $Log: eti.c,v $
- * Revision 1.4  1995/03/28 11:42:34  adam
+ * Revision 1.12  1995/05/03 07:37:35  adam
+ * CCL commands stop/continue implemented. New functions gw_res_{int,bool}
+ * are used when possible.
+ *
+ * Revision 1.11  1995/05/01  16:26:56  adam
+ * More work on resource monitor.
+ *
+ * Revision 1.10  1995/05/01  12:43:29  adam
+ * First work on resource monitor program.
+ *
+ * Revision 1.9  1995/04/21  16:37:43  adam
+ * Parent (eti) creates BOTH FIFOs. dtbsun is more happy now.
+ *
+ * Revision 1.8  1995/04/20  15:12:24  adam
+ * Minor hacks really.
+ *
+ * Revision 1.7  1995/04/19  16:01:57  adam
+ * Some hacks to get the FIFO communication work!! Isn't reliable.
+ * Resource gw.account added - default account info.
+ *
+ * Revision 1.6  1995/04/17  09:34:27  adam
+ * Timeout (idletime) adjustable. Minor changes in kernel.
+ *
+ * Revision 1.5  1995/03/31  09:43:13  adam
+ * Removed unused variable.
+ *
+ * Revision 1.4  1995/03/28  11:42:34  adam
  * First use of string-queue utility.
  *
  * Revision 1.3  1995/03/28  08:01:23  adam
 #include <setjmp.h>
 #include <signal.h>
 
+#include <sys/file.h>
+#include <sys/stat.h>
+
 #include <gw-log.h>
 #include <gw-db.h>
 #include <gip.h>
 #include <strqueue.h>
 
 #define LINE_MAX 1024
-static char line_buf[LINE_MAX+1];
 
 static char *module = "eti";
 static jmp_buf retry_jmp;
@@ -64,6 +92,7 @@ static int email_header (struct str_queue *sq,
     return 1;
 }
 
+#if !USE_MONITOR
 static void start_kernel (int argc, char **argv, int id)
 {
     pid_t pid;
@@ -93,18 +122,18 @@ static void start_kernel (int argc, char **argv, int id)
     }
     if (!pid)
     {
-        execvp ("kernel", argv_p);
+        execv ("kernel", argv_p);
        gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, module, "execvp");
        exit (1);
     }
 }
+#endif
 
-static void deliver (struct str_queue *sq, GIP gip)
+static void deliver (struct str_queue *sq, GIP gip, const char *msg)
 {
     int index = 0;
-    char *msg;
 
-    gip_wline (gip, "mail\n");
+    gip_wline (gip, msg);
     while ((msg = str_queue_get (sq, index++)))
         gip_wline (gip, msg);
     gip_wline (gip, "\001");
@@ -115,6 +144,7 @@ int main (int argc, char **argv)
     char from_str[LINE_MAX+1];
     char subject_str[LINE_MAX+1];
     char line_str[LINE_MAX+1];
+    char msg[20];
     GW_DB user_db;
     GIP  gip;
     void *user_info;
@@ -170,21 +200,40 @@ int main (int argc, char **argv)
     else
     {
         gw_log (GW_LOG_FATAL, module, "gw_db_lookup fail");
+       exit (1);
     }
+#if USE_MONITOR
+    sprintf (fifo_server_name, "fifo.s.m");
+    sprintf (fifo_client_name, "fifo.c.m");
+#else
     sprintf (fifo_server_name, "fifo.s.%d", id);
     sprintf (fifo_client_name, "fifo.c.%d", id);
+#endif
 
     gip = gipc_initialize (fifo_client_name);
 
     signal (SIGPIPE, pipe_handle);
     setjmp (retry_jmp);
     ++pass;
+    signal (SIGPIPE, pipe_handle);
     gw_log (GW_LOG_DEBUG, module, "Pass %d", pass);
     if (pass == 1)
         r = gipc_open (gip, fifo_server_name, 0);
     else if (pass == 2)
     {
+#if USE_MONITOR
+        gw_log (GW_LOG_FATAL, module, "Cannot contact monitor");
+       exit (1);
+#else
+#if 0
         gipc_close (gip);
+        gipc_destroy (gip);
+        unlink (fifo_server_name);
+        unlink (fifo_client_name);
+        gip = gipc_initialize (fifo_client_name);
+#endif
+
+       mknod (fifo_server_name, S_IFIFO|0666, 0);
         start_kernel (argc, argv, id);
         r = gipc_open (gip, fifo_server_name, 1);
     }
@@ -192,6 +241,7 @@ int main (int argc, char **argv)
     {
         gw_log (GW_LOG_FATAL, module, "Cannot start kernel");
        exit (1);
+#endif
     }
     if (r < 0)
         if (r == -2)
@@ -211,7 +261,12 @@ int main (int argc, char **argv)
        }
     /* deliver message ... */
     gw_log (GW_LOG_DEBUG, module, "Delivering mail");
-    deliver (queue, gip);
+#if USE_MONITOR
+    sprintf (msg, "eti %d\n", id);
+#else
+    strcpy (msg, "mail\n");
+#endif
+    deliver (queue, gip, msg);
     gw_log (GW_LOG_DEBUG, module, "Closing");
     gipc_close (gip);
     gipc_destroy (gip);