/* return a NULL file pointeur if trouble. */
/* */
/********************************************************/
-PUBLIC LOGPTR *log_openlog(char *logname,_Bool inlog)
+PUBLIC LOGPTR *log_openlog(char *logname,_Bool inlog,const char *cmt)
{
#define OPEP "devlog.c:log_openlog"
(void) clock_gettime(CLOCK_REALTIME,&(log->start));
(void) fprintf(log->file,"\n#-----------------------------\n");
(void) fprintf(log->file,"#%s",ctime(&(log->start.tv_sec)));
+ if (cmt!=(const char *)0)
+ (void) fprintf(log->file,"#%s\n",cmt);
(void) fflush(log->file);
log->start.tv_sec=0;
break;
#include "geseml.h"
#include "lvleml.h"
+typedef struct {
+ SOCPTR *socptr;
+ LOGPTR *logptr;
+ MXTYP **mxs;
+ }RMTTYP;
/*
^L
*/
*/
/********************************************************/
/* */
+/* Procedure to connect to the remote SMTP server */
+/* */
+/********************************************************/
+static _Bool connect_to_mx(RMTTYP *rmt)
+
+{
+_Bool done;
+int phase;
+int proceed;
+
+
+done=false;
+phase=0;
+proceed=true;
+while (proceed==true) {
+ switch (phase) {
+ case 0 : //do ve have MX
+ break;
+ default : //SAFE Guard
+ proceed=false;
+ break;
+ }
+ phase++;
+ }
+return done;
+}
+/*
+^L
+*/
+/********************************************************/
+/* */
/* Procedure to send the whole email transaction */
/* */
/********************************************************/
#define OPEP "lvleml.c:sending_email,"
time_t isnow;
-MXTYP **mxs;
+RMTTYP rmt;
TRATYP **tosend;
int phase;
_Bool proceed;
isnow=time((time_t *)0);
-mxs=dns_getmx(domain);
+(void) memset(&rmt,'\000',sizeof(rmt));
+rmt.mxs=dns_getmx(domain);
tosend=(TRATYP **)0;
phase=0;
proceed=true;
phase=999; //all scanning done
break;
case 1 : //collecting email to be sent
+ rmt.logptr=log_closelog(rmt.logptr);
while (*tra!=(TRATYP *)0) {
if (strcmp((*tra)->sessid,sessid)!=0) {
sessid=(*tra)->sessid;
}
break;
case 2 : //Checking if we have email to be sent
+ char cmt[100];
+
+ (void) strncpy(cmt,sessid,sizeof(cmt));
+ rmt.logptr=log_openlog(sessid,false,cmt);
if (tosend==(TRATYP **)0)
phase=-1; //lets continue to see other email
break;
case 3 : //checking if connection is open
+ if (rmt.socptr!=(SOCPTR *)0) { //reset the connection
+ phase++; //NO need to open connection
+ }
break;
case 4 : //Opening connection if not open
+ if (connect_to_mx(&rmt)==false) {
+ char cmt[100];
+
+ (void) snprintf(cmt,sizeof(cmt),"Unable to contact ANY MX for domain <%s>",
+ domain);
+ (void) log_fprintlog(rmt.logptr,false,cmt);
+ phase=999; //No need to go further
+ }
break;
case 5 : //sending recipient list
break;
phase=0; //Lets see if we have other recipient
break;
default : //SAFE Guard
+ rmt.logptr=log_closelog(rmt.logptr);
proceed=false;
break;
}
phase++;
}
-mxs=dns_freemxlist(mxs);
+rmt.mxs=dns_freemxlist(rmt.mxs);
+
#undef OPEP
}
/*
}
contact->peername=soc_getaddrinfo(contact->socptr,false,true);
contact->peerip=soc_getaddrinfo(contact->socptr,false,false);
- contact->logptr=log_openlog(contact->mainsesid,true);
+ contact->logptr=log_openlog(contact->mainsesid,true,(const char *)0);
(void) rou_alert(0,"Contact from peer <%s> to port <%s> started",
contact->peerip,contact->locserv);
break;