int status;
char *line;
-char *action;
_Bool empty;
+char *action;
char data[300];
int phase;
_Bool proceed;
status=false;
line=(char *)0;
-action="data";
empty=false;
+action="DATA";
(void) strcpy(data,"");
phase=0;
proceed=true;
while (proceed==true) {
- (void) rou_alert(0,"%s phase='%d'",OPEP,phase);
+ //(void) rou_alert(0,"%s JMPDBG phase='%d'",OPEP,phase);
switch (phase) {
case 0 : //Transmit "DATA" to remote
if (dooutgoing(fd->socptr,action)!=(strlen(action)+2))
int code;
code=0;
- (void) rou_alert(0,"%s JMPDBG line=<%s>",OPEP,line);
(void) sscanf(line,"%d",&code);
if (code!=DATAOK)
phase=999;
break;
case 3 : //
while (fgets(data,sizeof(data),fd->datatst)!=(char *)0) {
+ _Bool completed;
+
+ completed=true;
(void) eml_removecrlf(data);
- (void) dooutgoing(fd->socptr,data);
- if ((empty==true)&&(strcmp(data,".")==0)) {
- phase++; //Eveything is fine
- break;
+ switch (data[0]) {
+ case 'D' :
+ if ((strcmp(data+2,".")==0)&&(empty==true))
+ (void) strcat(data,".");
+ (void) dooutgoing(fd->socptr,data+2);
+ empty=(strlen(data+2)==0);
+ completed=false;
+ break;
+ case 'C' :
+ if (data[2]=='.') {
+ (void) dooutgoing(fd->socptr,"");
+ (void) dooutgoing(fd->socptr,".");
+ }
+ else
+ (void) rou_alert(0,"%s Unexpected data close <%s> (Bug?)",
+ OPEP,data);
+ break;
+ default :
+ (void) rou_alert(0,"%s Unexpected data to be send <%s> (Bug?)",
+ OPEP,data);
+ break;
+ }
+ if (completed==true) {
+ status=true;
+ break; //All data sent.
}
- empty=false;
- if (strlen(data)==0)
- empty=true;
}
break;
- case 4 : //phase reached only by data exhaustion
- phase=999; //Trouble trouble
- break;
- case 5 : //all data sent lets say it is good
- status=true;
- break;
default : //SAFE Guard
proceed=false;
break;
#====================================================
T:Sending a very Simple Email
R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
-C:ORGN 127.127.0.2
-R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
-#C:WAIT 100
#====================================================
S:HELO example.com
#R:250-mailleur.example.com, link (cleartext) ready, your IP/FQDN=[127.127.0.2/feed2.example.com]
#-------------------------------------------------------------------------
#-sending data
C:DATA
-Subject: Very Simple email contents
-From: Maitre Post <postmaster@example.com>
-To: Maitre WEB <webmaster@example.com>
-
-FIRST Line
-SECOND Line
-LAST Line
-
-this is a line with a dot
-..
-end
-.
+D:Subject: Very Simple email contents
+D:From: Maitre Post <postmaster@example.com>
+D:To: Maitre WEB <webmaster@example.com>
+D:
+D:FIRST Line
+D:SECOND Line
+D:LAST Line
+D:.
+D:this is a line with a dot
+D:
+D:.
+D:end
+D:ligne court|
+C:.
#-------------------------------------------------------------------------
R:250 3.5.3 Message accepted for delivery
S:QUIT
#-------------------------------------------------------------------------
#-sending data
C:DATA
-Subject: Second email contents
-
-SECOND FIRST Line
-SECOND SECOND Line
-SECOND LAST Line
-
-.
+D:Subject: Second email contents
+D:
+D:SECOND FIRST Line
+D:SECOND SECOND Line
+D:SECOND LAST Line
+D:
+D:
+C:.
#-------------------------------------------------------------------------
R:250 3.5.3 Message accepted for delivery
S:QUIT
#-------------------------------------------------------------------------
#-sending data
C:DATA
-Subject: Third email contents
-
-THIRD FIRST Line
-THIRD SECOND Line
-THIRD LAST Line
-
-.
+D:Subject: Third email contents
+D:
+D:THIRD FIRST Line
+D:THIRD SECOND Line
+D:THIRD LAST Line
+D:
+C:.
#-------------------------------------------------------------------------
R:250 3.5.3 Message accepted for delivery
S:QUIT
#====================================================
T:Sending a very Simple Email
R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
-C:ORGN 127.127.0.2
-R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
-#C:WAIT 100
#====================================================
S:HELO example.com
#R:250-mailleur.example.com, link (cleartext) ready, your IP/FQDN=[127.127.0.2/feed2.example.com]
#-------------------------------------------------------------------------
#-sending data
C:DATA
-Subject: Very Simple email contents
-From: Maitre Post <postmaster@example.com>
-To: Maitre WEB <webmaster@example.com>
-
-FIRST Line
-SECOND Line
-LAST Line
-
-this is a line with a dot
-..
-end
-.
+D:Subject: Very Simple email contents
+D:From: Maitre Post <postmaster@example.com>
+D:To: Maitre WEB <webmaster@example.com>
+D:
+D:FIRST Line
+D:SECOND Line
+D:LAST Line
+D:.
+D:this is a line with a dot
+D:
+D:.
+D:end
+D:ligne court|
+C:.
#-------------------------------------------------------------------------
R:250 3.5.3 Message accepted for delivery
S:QUIT
#-------------------------------------------------------------------------
#-sending data
C:DATA
-Subject: Second email contents
-
-SECOND FIRST Line
-SECOND SECOND Line
-SECOND LAST Line
-
-.
+D:Subject: Second email contents
+D:
+D:SECOND FIRST Line
+D:SECOND SECOND Line
+D:SECOND LAST Line
+D:
+D:
+C:.
#-------------------------------------------------------------------------
R:250 3.5.3 Message accepted for delivery
S:QUIT
#-------------------------------------------------------------------------
#-sending data
C:DATA
-Subject: Third email contents
-
-THIRD FIRST Line
-THIRD SECOND Line
-THIRD LAST Line
-
-.
+D:Subject: Third email contents
+D:
+D:THIRD FIRST Line
+D:THIRD SECOND Line
+D:THIRD LAST Line
+D:
+C:.
#-------------------------------------------------------------------------
R:250 3.5.3 Message accepted for delivery
S:QUIT
#define OPEP "lvleml.c:getdata,"
_Bool done;
-_Bool empty;
FILE *queue;
+_Bool empty;
+_Bool completed;
int phase;
_Bool proceed;
done=false;
-empty=false;
queue=(FILE *)0;
+empty=false;
+completed=false;
phase=0;
proceed=setdirectives(contact,"tmp");
while (proceed==true) {
- (void) rou_alert(0,"JMPDBG %s phase='%d' empty='%d'",OPEP,phase,empty);
+ //(void) rou_alert(0,"JMPDBG %s phase='%d'",OPEP,phase);
switch (phase) {
case 0 : //opening the queue email
if ((queue=eml_createqfile(contact->cursesid,""))==(FILE *)0)
DATAOK,"End data with <CR><LF>.<CR><LF>");
break;
case 3 : //get incoming line, detect 'single dot' as end
- while (proceed==true) {
- int completed;
+ while (completed==false) {
int got;
char *line;
phase=999; //trouble trouble
break; //exiting loop
}
- if ((empty==false)||(strcmp(line,".")!=0)) {
- if (strcmp(line,"..")==0)
- line[1]='\000';
- (void) fprintf(queue,"%s\n",line);
- }
- else
+ if ((empty==true)&&(strcmp(line,".")==0)) {
completed=true;
- empty=(strlen(line)==0);
+ }
+ else {
+ if (empty==true) {
+ (void) fprintf(queue,"\n");
+ if (strcmp(line,"..")==0)
+ line[1]='\000'; //removing double dot
+ }
+ empty=(strlen(line)==0);
+ if (empty==false)
+ (void) fprintf(queue,"%s\n",line);
+ }
line=rou_freestr(line);
- if (completed==true)
- break;
}
break;
- case 4 : //just display line
- empty=false;
- break;
- case 5 : //got all data
+ case 4 : //got all data
if (eml_closeqfile(queue)<0)
phase=999; //Trouble trouble
break;
- case 6 : //renameing directive
+ case 5 : //renameing directive
if (eml_renameqfile(contact->cursesid,"tmp",EXTRANS)==false)
phase=999; //Trouble trouble
break;
- case 7 : //everything fine
+ case 6 : //everything fine
(void) transmit(contact,"%d 3.5.3 %s",
CMDOK,"Message accepted for delivery");
done=true;
"condition=<%s>",str);
//(void) rou_alert(0,"%s exit status='%d'",OPEP,status);
break; //no need to go further
+
}
+ (void) rou_alert(0,"%s JMPDBG got <%s>",OPEP,line);
(void) log_fprintlog(contact->logptr,false,"%s",line);
code=eml_getcode(line);
switch (code) {