From: Jean-Marc Pigeon (Delson) Date: Wed, 7 May 2025 17:32:13 +0000 (-0400) Subject: Data is sent it remote server, remote accept data X-Git-Tag: tag-0.8~123 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=afd6e8f17f5519ab022ac965bc6c4d55fa85e29b;p=jmp%2Fmailleur Data is sent it remote server, remote accept data --- diff --git a/Makefile b/Makefile index 6e234f2..6dfbe0b 100644 --- a/Makefile +++ b/Makefile @@ -54,13 +54,14 @@ extfeed : debug $(DATATST)/extfeed00.tst onefeed : debug - @ bin/feeder \ + bin/feeder \ -f \ -d2 \ -c ./conf/feeder.conf.dvl \ $(TESTIP) \ $(TESTPORT) \ $(DATATST)/xxfeed.tst + # # -i 127.63.31.15 #direct test diff --git a/app/feeder.c b/app/feeder.c index 75dda15..187d32a 100644 --- a/app/feeder.c +++ b/app/feeder.c @@ -164,7 +164,7 @@ while (proceed==true) { phase=999; //Unable to send STARTTLS sequence break; case 1 : //Get STARTTLS command status - if (tcp_getline(fd->socptr,WRESP,&line)<=0) + if (tcp_getline(fd->socptr,WRESP,&line)<0) phase=999; //Didn't get signon break; case 2 : //did we received the Proper "proceed" acknoledge @@ -181,9 +181,7 @@ while (proceed==true) { case 3 : // while (fgets(data,sizeof(data),fd->datatst)!=(char *)0) { (void) eml_removecrlf(data); - (void) rou_alert(0,"JMPDBG got <%s>",data); (void) dooutgoing(fd->socptr,data); - (void) rou_alert(0,"JMPDBG sent <%s>",data); if ((empty==true)&&(strcmp(data,".")==0)) { phase++; //Eveything is fine break; @@ -634,6 +632,8 @@ while (proceed==true) { } phase++; } +if (status==true) + (void) rou_alert(0,"Scanning file <%s> complted OK",filename); return status; } /********************************************************/ diff --git a/data-tst/xxfeed.tst b/data-tst/xxfeed.tst index c3e26f3..26ffce3 100644 --- a/data-tst/xxfeed.tst +++ b/data-tst/xxfeed.tst @@ -21,6 +21,6 @@ SECOND Line LAST Line . -R:250 Message accepted for delivery +R:250 3.5.3 Message accepted for delivery S:QUIT R:221 2.0.0 Bye, closing connection... diff --git a/lib/devsoc.c b/lib/devsoc.c index 96a9a2b..fe5b112 100644 --- a/lib/devsoc.c +++ b/lib/devsoc.c @@ -331,6 +331,69 @@ while (proceed==true) { */ /********************************************************/ /* */ +/* Procedure to extract next line from the socket */ +/* incoming pile. */ +/* Return the number of character, zero if the */ +/* line is empty, -1 if now char available. */ +/* */ +/********************************************************/ +static int doextract(SOCTYP *soc,char **lineptr) + +{ +#define OPEP "devsoc.c:doextract," + +int got; +char *eol; +int phase; +_Bool proceed; + +*lineptr=(char *)0; +got=-1; +eol=(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 dat in carpile + if (soc->carin==0) + phase=999; //No char,no need to check for line + break; + case 1 : //Do we have a CRLF + eol=strstr(soc->carpile,soc->EOL); + if (eol==(char *)0) + phase=999; //No End Of Line yet + break; + case 2 : //duplicating carpile + *lineptr=calloc(soc->carin+1,sizeof(char)); + *eol='\000'; + (void) strcpy(*lineptr,soc->carpile); + got=strlen(*lineptr); + break; + case 3 : //managing carpile + soc->carin-=(got+strlen(soc->EOL)); + if (soc->carin>0) { + int delta; + + delta=got+strlen(soc->EOL); + (void) memmove(soc->carpile,soc->carpile+delta,soc->carin); + } + soc->carpile[soc->carin]='\000'; + break; + default : //SAFE guard + proceed=false; + break; + } + phase++; + } +return got; +#undef OPEP +} +/* + +*/ +/********************************************************/ +/* */ /* Procedure to wait and get a new handle */ /* */ /********************************************************/ @@ -962,6 +1025,9 @@ return status; /* */ /* Procedure to return the next available line */ /* within the socket carpile. */ +/* return the number of char within line */ +/* Return 0 if line is 'empty' */ +/* Return -1 if no characater available */ /* */ /********************************************************/ PUBLIC int soc_getnextline(SOCPTR *socptr,char **lineptr) @@ -971,48 +1037,31 @@ PUBLIC int soc_getnextline(SOCPTR *socptr,char **lineptr) int got; register SOCTYP *soc; -char *eol; int phase; _Bool proceed; *lineptr=(char *)0; -got=0; -eol=(char *)0; +got=-1; soc=(SOCTYP *)socptr; phase=0; proceed=true; while (proceed==true) { + //(void) rou_alert(0,"JMPDBG %s phase='%d'",OPEP,phase); switch (phase) { case 0 : //Do we have dat in carpile if (soc==(SOCTYP *)0) { (void) rou_alert(0,"%s, socket binding reference is NULL (Bug!?)",OPEP); phase=999; //no need to go further } - case 1 : //Do we have char available in carpile - (void) soc_receive(socptr); - if (soc->carin==0) - phase=999; //No char,no need to check for line - break; - case 2 : //Do we have a CRLF - eol=strstr(soc->carpile,soc->EOL); - if (eol==(char *)0) - phase=999; //No End Of Line yet break; - case 3 : //duplicating carpile - *lineptr=calloc(soc->carin+1,sizeof(char)); - *eol='\000'; - (void) strcpy(*lineptr,soc->carpile); - got=strlen(*lineptr); + case 1 : //Do we have char available in carpile + got=doextract(soc,lineptr); + if (got>=0) //we have line + phase=999; //no need to go further break; - case 4 : //managing carpile - soc->carin-=(got+strlen(soc->EOL)); - if (soc->carin>0) { - int delta; - - delta=got+strlen(soc->EOL); - (void) memmove(soc->carpile,soc->carpile+delta,soc->carin); - } - soc->carpile[soc->carin]='\000'; + case 2 : //lets wait for char + if (soc_receive(socptr)>0) //we have char + phase=0; //Let try to read line break; default : //SAFE guard proceed=false; diff --git a/lib/gestcp.c b/lib/gestcp.c index 5531085..6aa72f3 100644 --- a/lib/gestcp.c +++ b/lib/gestcp.c @@ -56,7 +56,7 @@ while (proceed==true) { } break; case 1 : //get nextline if ready - if ((got=soc_getnextline(socptr,lineptr))>0) + if ((got=soc_getnextline(socptr,lineptr))>=0) phase=999; //we got a line. break; case 2 : //lets wait secwait*1000 millisec for input diff --git a/lib/gestcp.h b/lib/gestcp.h index b0df057..6962c50 100644 --- a/lib/gestcp.h +++ b/lib/gestcp.h @@ -13,7 +13,7 @@ #include "devlog.h" #include "devsoc.h" -#define WAITLINE 10 //full line waiting time +#define WAITLINE 30 //full line waiting time //read a line from contact up to CRLF extern int tcp_getline(SOCPTR *socptr,u_int secwait,char **lineptr); diff --git a/lib/lvleml.c b/lib/lvleml.c index 4003f4c..3417d6a 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -192,7 +192,7 @@ got=0; phase=0; proceed=true; while (proceed==true) { - (void) rou_alert(0,"JMPDBG %s phase='%d' empty='%d'",OPEP,phase,empty); + //(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", @@ -204,7 +204,6 @@ while (proceed==true) { } 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; @@ -213,9 +212,9 @@ while (proceed==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"); + done=true; break; default : //SAFE guard proceed=false;