]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Stating to implemented email queing process
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 7 May 2025 22:38:26 +0000 (18:38 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 7 May 2025 22:38:26 +0000 (18:38 -0400)
Makefile
lib/subrou.h
lib/unieml.c
lib/unieml.h

index cdc7548fc38fb6ec6d4354430242cc672ae7003f..c31db87f3c8004acb3bef1f3162817e72193ce77 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -229,6 +229,7 @@ DATA        =  chkaddr.spf.example.com 127.0.1.255
 newtest        :  deltest
           @ mkdir -p $(TESTDIR)/var/run
           @ mkdir -p $(TESTDIR)/var/spool/$(APPNAME)/{in,out}-logs
+          @ mkdir -p $(TESTDIR)/var/spool/$(APPNAME)/queue
           @ mkdir -p $(TESTDIR)/usr
           @ cp -a                                      \
                bin                                     \
index a647e8fdbf5cba00ce02893723c85c051e14987b..81b2d4fccff8d6e9eb6067109918be86d6ce3301 100644 (file)
@@ -77,6 +77,9 @@ extern char *rou_setappname(const char *newname);
 //to compute an application path with the root directory
 extern char *rou_apppath(const char *path);
 
+//to compute an application path with the root directory
+extern char *rou_apppath(const char *path);
+
 //to display message on console (verbose mode) or
 //via syslog (LOG_INFO) using variable argument list macros
 void rou_valert(const int dlevel,const char *fmt,va_list ap);
index 96ad03b2f2f8d4b48b7b00bb9bb5b293fa913b98..68d5868657bfd19fb1525b3564ce29f480254320 100644 (file)
@@ -5,14 +5,18 @@
 /*     exchange.                                       */
 /*                                                     */
 /********************************************************/
+#include        <errno.h>
 #include        <stdbool.h>
 #include        <stdio.h>
+#include        <stdlib.h>
 #include        <string.h>
 #include        <unistd.h>
 
 #include       "subrou.h"
 #include       "unieml.h"
 
+#define QDIR    "/var/spool/"APPNAME"/queue"
+
 typedef struct  {
         CODTYP code;            //keyword code
         const char *key;        //keyword itself
@@ -112,7 +116,6 @@ for (ptr=vocsmtp;ptr->key!=(char *)0;ptr++) {
 return code;
 #undef  OPEP
 }
-
 /*
 ^L
 */
@@ -145,4 +148,52 @@ if (string!=(char *)0) {
   }
 return done;
 }
+/*
+^L
+*/
+/********************************************************/
+/*                                                      */
+/*     Procedure to open a file to store the email in  */
+/*      within the spool queue.                         */
+/*                                                      */
+/********************************************************/
+PUBLIC FILE *eml_opennewqueue(char *sessionid)
 
+{
+#define OPEP    "unieml.c:eml_opennewqueue,"
+
+FILE *fichier;
+char *filename;
+int phase;
+int proceed;
+
+fichier=(FILE *)0;
+filename=(char *)0;
+phase=0;
+proceed=true;
+while (proceed==true) {
+  //(void) rou_alert(0,"JMPDBG %s phase='%d'",OPEP,phase);
+  switch (phase) {
+    case 0      :       //Do we have a session ID
+      if ((sessionid=(char *)0)||(strlen(sessionid)==0)) {
+        (void) rou_core_dump("%s sessionID is not set (bug?)",OPEP);
+        phase=999;      //never reached
+        }
+      break;
+    case 1      :       //"Computing" the file new queue filename
+      filename=rou_apppath(QDIR);
+      filename=(char *)realloc(filename,strlen(filename)+strlen(sessionid)+10);
+      if ((fichier=fopen(filename,"w"))==(FILE *)0) {
+        (void) rou_alert(0,"%s Unable to open file <%s> (error=<%s>)",
+                           OPEP,filename,strerror(errno));
+        }
+      filename=rou_freestr(filename);
+      break;
+    default     :       //SAFE guard
+      proceed=false;
+      break;
+    }
+  phase++;
+  }
+return fichier;
+}
index 124e61dfc25be6bdac29036a3a7658cd0cec9735..29d20e4be0811c12aad7fd7875a262cb811cd58c 100644 (file)
@@ -8,6 +8,8 @@
 #ifndef        UNIEML
 #define UNIEML
 
+#include        <stdio.h>
+
 #define MXMSIZE 52428800        //52 Megabytes
 #define CRLF    "\r\n"          //EOL within SMTP protocol
 #define        SIGNON  220             //signon information
@@ -44,4 +46,10 @@ extern CODTYP eml_getcode(char *keyword);
 //remove CRLF from string
 extern int eml_removecrlf(char *string);
 
+//procedure to open a queue file
+extern FILE *eml_opennewqueue(char *sessid);
+
+//procedure to open a queue file
+extern int eml_closenewqueue(FILE *queue);
+
 #endif