]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Improving sending line to peer
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Fri, 9 Aug 2024 00:54:02 +0000 (20:54 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Fri, 9 Aug 2024 00:54:02 +0000 (20:54 -0400)
lib/lvleml.c
lib/subrou.c
lib/unieml.h

index e27996e327c40ce72fc807edf84caacbfb3cc551..3f441596aa703727df748c462d8ee9245b57b7c0 100644 (file)
@@ -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);
index 134a4b75e0f6f3c6156e10908c55b9b559b809d1..9a7aacf46b5cc78f6f70041cd913e62b64776221 100644 (file)
@@ -20,7 +20,7 @@
 
 //version definition 
 #define VERSION "0.3"
-#define RELEASE "35"
+#define RELEASE "36"
 
 //Public variables
 PUBLIC  int debug=0;            //debug level
index 316f7fb71f1b79924462668026a6e331a59ebaa4..e63b16b06c35ef09c8bf155c9fa4846e0d83b5ac 100644 (file)
@@ -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