From 634f115050d551e6a189452a5a36f5c0828db2a3 Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Wed, 7 May 2025 10:39:36 -0400 Subject: [PATCH] Email data start to be working (problem to read more than one line??) --- app/feeder.c | 13 ++++++++++--- data-tst/xxfeed.tst | 2 +- lib/lvleml.c | 27 ++++++++++++++++++++++++++- lib/unieml.c | 34 ++++++++++++++++++++++++++++++++++ lib/unieml.h | 3 +++ 5 files changed, 74 insertions(+), 5 deletions(-) diff --git a/app/feeder.c b/app/feeder.c index 3a2d5ef..75dda15 100644 --- a/app/feeder.c +++ b/app/feeder.c @@ -140,6 +140,8 @@ return done; static _Bool dosenddata(FEEDTYP *fd) { +#define OPEP "feeder.c:dosenddata," + int status; char *line; char *action; @@ -178,9 +180,12 @@ while (proceed==true) { break; case 3 : // while (fgets(data,sizeof(data),fd->datatst)!=(char *)0) { + (void) eml_removecrlf(data); (void) rou_alert(0,"JMPDBG got <%s>",data); - if ((empty==true)||(strcmp(data,".")==0)) { - phase++; //Eveythin is fine + (void) dooutgoing(fd->socptr,data); + (void) rou_alert(0,"JMPDBG sent <%s>",data); + if ((empty==true)&&(strcmp(data,".")==0)) { + phase++; //Eveything is fine break; } empty=false; @@ -191,7 +196,8 @@ while (proceed==true) { case 4 : //phase reached only by data exhaustion phase=999; //Trouble trouble break; - case 5 : //we have completed data transmission + case 5 : //all data sent lets say it is good + (void) rou_alert(0,"JMPDBG all data sent",data); status=true; break; default : //SAFE Guard @@ -201,6 +207,7 @@ while (proceed==true) { phase++; } return status; +#undef OPEP } /* ^L diff --git a/data-tst/xxfeed.tst b/data-tst/xxfeed.tst index 9138616..c3e26f3 100644 --- a/data-tst/xxfeed.tst +++ b/data-tst/xxfeed.tst @@ -14,7 +14,7 @@ R:250 2.6.2 Address accepted #------------------------------------------------------------------------- #-sending data C:DATA -Subject: test clmfd30 (Checking dynamic override) +Subject: Very Simple email contents FIRST Line SECOND Line diff --git a/lib/lvleml.c b/lib/lvleml.c index 1776d7a..4003f4c 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -179,19 +179,44 @@ static _Bool getdata(CONTYP *contact) #define OPEP "lvleml.c:getdata," _Bool done; +char *line; +_Bool empty; +int got; int phase; _Bool proceed; done=false; +line=(char *)0; +empty=false; +got=0; phase=0; proceed=true; while (proceed==true) { - //(void) rou_alert(0,"JMPDBG %s phase='%d'",OPEP,phase); + (void) rou_alert(0,"JMPDBG %s phase='%d' empty='%d'",OPEP,phase,empty); switch (phase) { case 0 : //Do we have a parameter (void) transmit(contact,"%d 3.5.0 %s", DATAOK,"End data with ."); break; + case 1 : //get incoming line + got=tcp_getline(contact->socptr,WAITLINE,&line); + if (got<=0) { //data timeout + } + break; + case 2 : //just display line + (void) rou_alert(0,"%s, data=<%s>",OPEP,line); + if ((empty==false)||(strcmp(line,".")!=0)) + phase=0; //Wait for next line + empty=false; + if (strlen(line)==0) + empty=true; + line=rou_freestr(line); + break; + case 3 : //got all data + (void) rou_alert(0,"JMPDBG transmit OK"); + (void) transmit(contact,"%d 3.5.3 %s", + CMDOK,"Message accepted for delivery"); + break; default : //SAFE guard proceed=false; break; diff --git a/lib/unieml.c b/lib/unieml.c index 41baffc..96ad03b 100644 --- a/lib/unieml.c +++ b/lib/unieml.c @@ -112,3 +112,37 @@ for (ptr=vocsmtp;ptr->key!=(char *)0;ptr++) { return code; #undef OPEP } + +/* +^L +*/ +/********************************************************/ +/* */ +/* Procedure to remove crlf at the end of the */ +/* return true if CRLF was removed */ +/* */ +/********************************************************/ +PUBLIC int eml_removecrlf(char *string) + +{ +_Bool done; + +done=false; +if (string!=(char *)0) { + register int taille; + register char *ptr; + + taille=strlen(string)-1; + ptr=string+taille; + while ((*ptr=='\n') || (*ptr=='\r')) { + *ptr='\000'; + taille--; + done=true; + if (taille<0) + break; + ptr--; + } + } +return done; +} + diff --git a/lib/unieml.h b/lib/unieml.h index a50656b..124e61d 100644 --- a/lib/unieml.h +++ b/lib/unieml.h @@ -41,4 +41,7 @@ extern char *eml_getcursesid(char *mainid,int numreset); //convert SMTP keyword to CODTYP extern CODTYP eml_getcode(char *keyword); +//remove CRLF from string +extern int eml_removecrlf(char *string); + #endif -- 2.47.3