implement HELP and MRSQ -- MRSQ is a partial implementation
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Fri, 23 Oct 1981 01:14:34 +0000 (17:14 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Fri, 23 Oct 1981 01:14:34 +0000 (17:14 -0800)
of old MTP -- in particular, To: fields in MAIL commands are not yet
implemented.  The "message" routine now takes first args of the form
"999-" to specify continuation.

SCCS-vsn: usr.sbin/sendmail/src/err.c 3.12
SCCS-vsn: usr.sbin/sendmail/src/version.c 3.53
SCCS-vsn: usr.sbin/sendmail/src/srvrsmtp.c 3.4

usr/src/usr.sbin/sendmail/src/err.c
usr/src/usr.sbin/sendmail/src/srvrsmtp.c
usr/src/usr.sbin/sendmail/src/version.c

index a406b84..97a00c4 100644 (file)
@@ -3,7 +3,7 @@
 # include <syslog.h>
 # endif LOG
 
 # include <syslog.h>
 # endif LOG
 
-static char    SccsId[] = "@(#)err.c   3.11    %G%";
+static char    SccsId[] = "@(#)err.c   3.12    %G%";
 
 extern bool    HasXscrpt;
 
 
 extern bool    HasXscrpt;
 
@@ -138,7 +138,15 @@ message(num, msg, a, b, c, d, e)
 
        /* print arpa format header if needed */
        if (ArpaMode != ARPA_NONE && !HasXscrpt)
 
        /* print arpa format header if needed */
        if (ArpaMode != ARPA_NONE && !HasXscrpt)
-               fprintf(OutChannel, "%.3s ", num);
+       {
+               register char del;
+
+               if (num[3] == '-')
+                       del = '-';
+               else
+                       del = ' ';
+               fprintf(OutChannel, "%3.3s%c", num, del);
+       }
 
        if (To != NULL && To[0] != '\0')
                fprintf(OutChannel, "%s... ", To);
 
        if (To != NULL && To[0] != '\0')
                fprintf(OutChannel, "%s... ", To);
index 258c4ae..a824a4a 100644 (file)
@@ -1,6 +1,6 @@
 # include "sendmail.h"
 
 # include "sendmail.h"
 
-static char    SccsId[] =      "@(#)srvrsmtp.c 3.3     %G%";
+static char    SccsId[] =      "@(#)srvrsmtp.c 3.4     %G%";
 
 /*
 **  SMTP -- run the SMTP protocol.
 
 /*
 **  SMTP -- run the SMTP protocol.
@@ -33,6 +33,7 @@ struct cmd
 # define CMDHELP       7       /* help -- give usage info */
 # define CMDNOOP       8       /* noop -- do nothing */
 # define CMDQUIT       9       /* quit -- close connection and die */
 # define CMDHELP       7       /* help -- give usage info */
 # define CMDNOOP       8       /* noop -- do nothing */
 # define CMDQUIT       9       /* quit -- close connection and die */
+# define CMDMRSQ       10      /* mrsq -- for old mtp compat only */
 
 static struct cmd      CmdTab[] =
 {
 
 static struct cmd      CmdTab[] =
 {
@@ -45,6 +46,7 @@ static struct cmd     CmdTab[] =
        "help",         CMDHELP,
        "noop",         CMDNOOP,
        "quit",         CMDQUIT,
        "help",         CMDHELP,
        "noop",         CMDNOOP,
        "quit",         CMDQUIT,
+       "mrsq",         CMDMRSQ,
        NULL,           CMDERROR,
 };
 
        NULL,           CMDERROR,
 };
 
@@ -59,14 +61,13 @@ smtp()
        bool hasmail;                   /* mail command received */
        bool hasmrcp;                   /* has a recipient */
        bool hasdata;                   /* has mail data */
        bool hasmail;                   /* mail command received */
        bool hasmrcp;                   /* has a recipient */
        bool hasdata;                   /* has mail data */
-       int baseerrs;
 
        hasmail = hasmrcp = hasdata = FALSE;
        message("220", "%s Sendmail at your service", HostName);
        for (;;)
        {
                To = NULL;
 
        hasmail = hasmrcp = hasdata = FALSE;
        message("220", "%s Sendmail at your service", HostName);
        for (;;)
        {
                To = NULL;
-               baseerrs = Errors;
+               Errors = 0;
                if (fgets(inp, sizeof inp, InChannel) == NULL)
                {
                        /* end of file, just die */
                if (fgets(inp, sizeof inp, InChannel) == NULL)
                {
                        /* end of file, just die */
@@ -112,7 +113,7 @@ smtp()
                                break;
                        }
                        setsender(p);
                                break;
                        }
                        setsender(p);
-                       if (Errors == baseerrs)
+                       if (Errors == 0)
                        {
                                message("250", "Sender ok");
                                hasmail = TRUE;
                        {
                                message("250", "Sender ok");
                                hasmail = TRUE;
@@ -130,7 +131,7 @@ smtp()
                                break;
                        }
                        sendto(p, 1, NULL);
                                break;
                        }
                        sendto(p, 1, NULL);
-                       if (Errors == baseerrs)
+                       if (Errors == 0)
                        {
                                message("250", "Recipient ok");
                                hasmrcp = TRUE;
                        {
                                message("250", "Recipient ok");
                                hasmrcp = TRUE;
@@ -140,7 +141,7 @@ smtp()
                  case CMDDATA:         /* data -- text of mail */
                        message("354", "Enter mail, end with dot");
                        collect();
                  case CMDDATA:         /* data -- text of mail */
                        message("354", "Enter mail, end with dot");
                        collect();
-                       if (Errors == baseerrs)
+                       if (Errors == 0)
                        {
                                message("250", "Message stored");
                                hasdata = TRUE;
                        {
                                message("250", "Message stored");
                                hasdata = TRUE;
@@ -157,7 +158,7 @@ smtp()
                        else
                        {
                                sendall(FALSE);
                        else
                        {
                                sendall(FALSE);
-                               if (Errors == baseerrs)
+                               if (Errors == 0)
                                        message("250", "Sent");
                        }
                        break;
                                        message("250", "Sent");
                        }
                        break;
@@ -168,12 +169,14 @@ smtp()
 
                  case CMDVRFY:         /* vrfy -- verify address */
                        sendto(p, 1, NULL);
 
                  case CMDVRFY:         /* vrfy -- verify address */
                        sendto(p, 1, NULL);
-                       if (Errors == baseerrs)
+                       if (Errors == 0)
                                message("250", "user ok");
                        break;
 
                  case CMDHELP:         /* help -- give user info */
                                message("250", "user ok");
                        break;
 
                  case CMDHELP:         /* help -- give user info */
-                       message("502", "HELP not implemented");
+                       if (*p == '\0')
+                               p = "SMTP";
+                       help(p);
                        break;
 
                  case CMDNOOP:         /* noop -- do nothing */
                        break;
 
                  case CMDNOOP:         /* noop -- do nothing */
@@ -184,6 +187,29 @@ smtp()
                        message("221", "%s closing connection", HostName);
                        finis();
 
                        message("221", "%s closing connection", HostName);
                        finis();
 
+                 case CMDMRSQ:         /* mrsq -- negotiate protocol */
+                       if (*p == 'R' || *p == 'T')
+                       {
+                               /* recipients first or text first */
+                               message("200", "%c ok, please continue", *p);
+                       }
+                       else if (*p == '?')
+                       {
+                               /* what do I prefer?  anything, anytime */
+                               message("215", "R Recipients first is my choice");
+                       }
+                       else if (*p == '\0')
+                       {
+                               /* no meaningful scheme */
+                               message("200", "okey dokie boobie");
+                       }
+                       else
+                       {
+                               /* bad argument */
+                               message("504", "Scheme unknown");
+                       }
+                       break;
+
                  case CMDERROR:        /* unknown command */
                        message("500", "Command unrecognized");
                        break;
                  case CMDERROR:        /* unknown command */
                        message("500", "Command unrecognized");
                        break;
@@ -244,3 +270,59 @@ skipword(p, w)
 
        return (p);
 }
 
        return (p);
 }
+\f/*
+**  HELP -- implement the HELP command.
+**
+**     Parameters:
+**             topic -- the topic we want help for.
+**
+**     Returns:
+**             none.
+**
+**     Side Effects:
+**             outputs the help file to message output.
+*/
+
+help(topic)
+       char *topic;
+{
+       register FILE *hf;
+       int len;
+       char buf[MAXLINE];
+       bool noinfo;
+
+       hf = fopen("/usr/lib/sendmail.hf", "r");
+       if (hf == NULL)
+       {
+               /* no help */
+               message("502", "HELP not implemented");
+               return;
+       }
+
+       len = strlen(topic);
+       makelower(topic);
+       noinfo = TRUE;
+
+       while (fgets(buf, sizeof buf, hf) != NULL)
+       {
+               if (strncmp(buf, topic, len) == 0)
+               {
+                       register char *p;
+
+                       p = index(buf, '\t');
+                       if (p == NULL)
+                               p = buf;
+                       else
+                               p++;
+                       fixcrlf(p, TRUE);
+                       message("214-", p);
+                       noinfo = FALSE;
+               }
+       }
+
+       if (noinfo)
+               message("504", "HELP topic unknown");
+       else
+               message("214", "End of HELP info");
+       fclose(hf);
+}
index fcdfdc7..0e573ca 100644 (file)
@@ -1,3 +1,3 @@
-static char    SccsId[] = "@(#)SendMail version 3.52 of %G%";
+static char    SccsId[] = "@(#)SendMail version 3.53 of %G%";
 
 
-char   Version[] = "3.52 [%G%]";
+char   Version[] = "3.53 [%G%]";