From: Jean-Marc Pigeon (Delson) Date: Fri, 9 Aug 2024 00:54:02 +0000 (-0400) Subject: Improving sending line to peer X-Git-Tag: tag-0.4~6 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=21a004ae12671f32d329a2e393628d957d937e0f;p=jmp%2Fmailleur Improving sending line to peer --- diff --git a/lib/lvleml.c b/lib/lvleml.c index e27996e..3f44159 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -21,6 +21,26 @@ static _Bool modopen; //module open/close status */ /********************************************************/ /* */ +/* Procedure to transmit a string to the remot peer*/ +/* */ +/********************************************************/ +static void transmit(CONTYP *contact,char *fmt,...) + +{ +va_list args; +char line[300]; + +va_start(args,fmt); +(void) vsnprintf(line,sizeof(line),fmt,args); +(void) tcp_write(contact,line,strlen(line)); +(void) tcp_write(contact,CRLF,strlen(CRLF)); +va_end(args); +} +/* +^L +*/ +/********************************************************/ +/* */ /* Procedure to proceed with peer exchange */ /* 3 return values: */ /* -1 exit with trouble. */ @@ -33,9 +53,11 @@ PUBLIC int eml_docontact(CONTYP *contact) { #define OPEP "lvleml.c:eml_docontact" int status; +_Bool proceed; status=1; -while (status>0) { +proceed=true; +while (proceed==true) { char *line; TIMESPEC attend; @@ -46,16 +68,11 @@ while (status>0) { break; //no need to go further switch (eml_getcode(line)) { case c_quit : //quit SMTP protocol - status=0; + (void) transmit(contact,"%d closing connection",QUITOK); + proceed=false; break; case c_unknown : //uknown keyword - if (line[0]!='\000') { //always - char info[300]; - - (void) snprintf(info,sizeof(info),"%d command <%s> is unknown",CMDBAD,line); - (void) tcp_write(contact,info,strlen(info)); - (void) tcp_write(contact,CRLF,strlen(CRLF)); - } + (void) transmit(contact,"%d command <%s> is unknown",CMDBAD,line); break; default : (void) rou_alert(0,"Unable to find keyword for <%s> (Bug?)",OPEP,line); diff --git a/lib/subrou.c b/lib/subrou.c index 134a4b7..9a7aacf 100644 --- a/lib/subrou.c +++ b/lib/subrou.c @@ -20,7 +20,7 @@ //version definition #define VERSION "0.3" -#define RELEASE "35" +#define RELEASE "36" //Public variables PUBLIC int debug=0; //debug level diff --git a/lib/unieml.h b/lib/unieml.h index 316f7fb..e63b16b 100644 --- a/lib/unieml.h +++ b/lib/unieml.h @@ -10,6 +10,7 @@ #define CRLF "\r\n" //EOL within SMTP protocol #define SIGNON 220 //signon information +#define QUITOK 221 //status on quit #define CMDBAD 502 //command not implemented //list of keyword