know about continuation lines in queue files: necessary for headers
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Mon, 16 Aug 1982 02:51:45 +0000 (18:51 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Mon, 16 Aug 1982 02:51:45 +0000 (18:51 -0800)
SCCS-vsn: usr.sbin/sendmail/src/util.c 3.23
SCCS-vsn: usr.sbin/sendmail/src/queue.c 3.30

usr/src/usr.sbin/sendmail/src/queue.c
usr/src/usr.sbin/sendmail/src/util.c

index 46d5a1f..8c3b811 100644 (file)
@@ -5,10 +5,10 @@
 # include <errno.h>
 
 # ifndef QUEUE
 # include <errno.h>
 
 # ifndef QUEUE
-SCCSID(@(#)queue.c     3.29            %G%     (no queueing));
+SCCSID(@(#)queue.c     3.30            %G%     (no queueing));
 # else QUEUE
 
 # else QUEUE
 
-SCCSID(@(#)queue.c     3.29            %G%);
+SCCSID(@(#)queue.c     3.30            %G%);
 
 /*
 **  QUEUEUP -- queue a message up for future transmission.
 
 /*
 **  QUEUEUP -- queue a message up for future transmission.
@@ -574,6 +574,8 @@ readqf(cf)
 {
        register FILE *f;
        char buf[MAXLINE];
 {
        register FILE *f;
        char buf[MAXLINE];
+       register char *p;
+       register int i;
        extern ADDRESS *sendto();
 
        /*
        extern ADDRESS *sendto();
 
        /*
@@ -593,9 +595,22 @@ readqf(cf)
 
        if (Verbose)
                printf("\nRunning %s\n", cf);
 
        if (Verbose)
                printf("\nRunning %s\n", cf);
-       while (fgets(buf, sizeof buf, f) != NULL)
+       p = buf;
+       while (fgets(p, sizeof buf - (p - buf), f) != NULL)
        {
        {
-               fixcrlf(buf, TRUE);
+               /*
+               **  Collect any continuation lines...
+               */
+
+               i = fgetc(f);
+               if (i != EOF)
+                       ungetc(i, f);
+               if (i == ' ' || i == '\t')
+               {
+                       p += strlen(p);
+                       continue;
+               }
+               fixcrlf(p, TRUE);
 
                switch (buf[0])
                {
 
                switch (buf[0])
                {
index ab72f53..7637330 100644 (file)
@@ -8,7 +8,7 @@
 # include "sendmail.h"
 # include "conf.h"
 
 # include "sendmail.h"
 # include "conf.h"
 
-SCCSID(@(#)util.c      3.22            %G%);
+SCCSID(@(#)util.c      3.23            %G%);
 
 /*
 **  STRIPQUOTES -- Strip quotes & quote bits from a string.
 
 /*
 **  STRIPQUOTES -- Strip quotes & quote bits from a string.
@@ -494,6 +494,9 @@ dfopen(filename, mode)
 \f/*
 **  PUTLINE -- put a line like fputs obeying SMTP conventions
 **
 \f/*
 **  PUTLINE -- put a line like fputs obeying SMTP conventions
 **
+**     This routine always guarantees outputing a newline (or CRLF,
+**     as appropriate) at the end of the string.
+**
 **     Parameters:
 **             l -- line to put.
 **             fp -- file to put it onto.
 **     Parameters:
 **             l -- line to put.
 **             fp -- file to put it onto.
@@ -506,44 +509,48 @@ dfopen(filename, mode)
 **             output of l to fp.
 */
 
 **             output of l to fp.
 */
 
-# define SMTPLINELIM   120     /* maximum line length */
+# define SMTPLINELIM   990     /* maximum line length */
 
 putline(l, fp, fullsmtp)
 
 putline(l, fp, fullsmtp)
-       char *l;
+       register char *l;
        FILE *fp;
        bool fullsmtp;
 {
        register char *p;
        FILE *fp;
        bool fullsmtp;
 {
        register char *p;
+       char svchar;
 
 
-       if (!fullsmtp)
+       do
        {
        {
-               fputs(l, fp);
-               return;
-       }
-
-       /* find the end of the line */
-       p = index(l, '\n');
-       if (p == NULL)
-               p = &l[strlen(l)];
+               /* find the end of the line */
+               p = index(l, '\n');
+               if (p == NULL)
+                       p = &l[strlen(l)];
 
 
-       /* check for line overflow */
-       while (p - l > SMTPLINELIM)
-       {
-               register char *q = &l[SMTPLINELIM - 1];
-               char svchar = *q;
+               /* check for line overflow */
+               while (fullsmtp && (p - l) > SMTPLINELIM)
+               {
+                       register char *q = &l[SMTPLINELIM - 1];
+
+                       svchar = *q;
+                       *q = '\0';
+                       fputs(l, fp);
+                       fputs("!\r\n", fp);
+                       *q = svchar;
+                       l = q;
+               }
 
 
-               *q = '\0';
+               /* output last part */
+               svchar = *p;
+               *p = '\0';
                fputs(l, fp);
                fputs(l, fp);
-               fputs("!\r\n", fp);
-               *q = svchar;
-               l = q;
-       }
-
-       /* output last part */
-       *p = '\0';
-       fputs(l, fp);
-       fputs("\r\n", fp);
-       *p = '\n';
+               if (fullsmtp)
+                       fputc('\r', fp);
+               fputc('\n', fp);
+               *p = svchar;
+               l = p;
+               if (*l == '\n')
+                       l++;
+       } while (l[0] != '\0');
 }
 \f/*
 **  XUNLINK -- unlink a file, doing logging as appropriate.
 }
 \f/*
 **  XUNLINK -- unlink a file, doing logging as appropriate.