put true current time on SMTP greeting message; fix *(0) problems
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Mon, 18 Apr 1983 08:13:17 +0000 (00:13 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Mon, 18 Apr 1983 08:13:17 +0000 (00:13 -0800)
SCCS-mr: usr.sbin/sendmail/src/envelope.c 199, 224
SCCS-vsn: usr.sbin/sendmail/src/envelope.c 3.15

usr/src/usr.sbin/sendmail/src/envelope.c

index 773c87d..633d46f 100644 (file)
@@ -3,7 +3,7 @@
 #include "sendmail.h"
 #include <sys/stat.h>
 
 #include "sendmail.h"
 #include <sys/stat.h>
 
-SCCSID(@(#)envelope.c  3.14            %G%);
+SCCSID(@(#)envelope.c  3.15            %G%);
 
 /*
 **  NEWENVELOPE -- allocate a new envelope
 
 /*
 **  NEWENVELOPE -- allocate a new envelope
@@ -234,17 +234,11 @@ unlockqueue(e)
 
 initsys()
 {
 
 initsys()
 {
-       auto time_t now;
        static char cbuf[5];                    /* holds hop count */
        static char cbuf[5];                    /* holds hop count */
-       static char dbuf[30];                   /* holds ctime(tbuf) */
        static char pbuf[10];                   /* holds pid */
        static char pbuf[10];                   /* holds pid */
-       static char tbuf[20];                   /* holds "current" time */
        static char ybuf[10];                   /* holds tty id */
        register char *p;
        static char ybuf[10];                   /* holds tty id */
        register char *p;
-       register struct tm *tm;
        extern char *ttyname();
        extern char *ttyname();
-       extern char *arpadate();
-       extern struct tm *gmtime();
        extern char *macvalue();
        extern char Version[];
 
        extern char *macvalue();
        extern char Version[];
 
@@ -279,19 +273,7 @@ initsys()
        define('c', cbuf, CurEnv);
 
        /* time as integer, unix time, arpa time */
        define('c', cbuf, CurEnv);
 
        /* time as integer, unix time, arpa time */
-       now = curtime();
-       tm = gmtime(&now);
-       (void) sprintf(tbuf, "%02d%02d%02d%02d%02d", tm->tm_year, tm->tm_mon+1,
-                       tm->tm_mday, tm->tm_hour, tm->tm_min);
-       define('t', tbuf, CurEnv);
-       (void) strcpy(dbuf, ctime(&now));
-       *index(dbuf, '\n') = '\0';
-       if (macvalue('d', CurEnv) == NULL)
-               define('d', dbuf, CurEnv);
-       p = newstr(arpadate(dbuf));
-       if (macvalue('a', CurEnv) == NULL)
-               define('a', p, CurEnv);
-       define('b', p, CurEnv);
+       settime();
 
        /* tty name */
        if (macvalue('y', CurEnv) == NULL)
 
        /* tty name */
        if (macvalue('y', CurEnv) == NULL)
@@ -307,6 +289,44 @@ initsys()
        }
 }
 \f/*
        }
 }
 \f/*
+**  SETTIME -- set the current time.
+**
+**     Parameters:
+**             none.
+**
+**     Returns:
+**             none.
+**
+**     Side Effects:
+**             Sets the various time macros -- $a, $b, $d, $t.
+*/
+
+settime()
+{
+       register char *p;
+       auto time_t now;
+       static char tbuf[20];                   /* holds "current" time */
+       static char dbuf[30];                   /* holds ctime(tbuf) */
+       register struct tm *tm;
+       extern char *arpadate();
+       extern struct tm *gmtime();
+       extern char *macvalue();
+
+       now = curtime();
+       tm = gmtime(&now);
+       (void) sprintf(tbuf, "%02d%02d%02d%02d%02d", tm->tm_year, tm->tm_mon+1,
+                       tm->tm_mday, tm->tm_hour, tm->tm_min);
+       define('t', tbuf, CurEnv);
+       (void) strcpy(dbuf, ctime(&now));
+       *index(dbuf, '\n') = '\0';
+       if (macvalue('d', CurEnv) == NULL)
+               define('d', dbuf, CurEnv);
+       p = newstr(arpadate(dbuf));
+       if (macvalue('a', CurEnv) == NULL)
+               define('a', p, CurEnv);
+       define('b', p, CurEnv);
+}
+\f/*
 **  QUEUENAME -- build a file name in the queue directory for this envelope.
 **
 **     Assigns an id code if one does not already exist.
 **  QUEUENAME -- build a file name in the queue directory for this envelope.
 **
 **     Assigns an id code if one does not already exist.
@@ -619,7 +639,7 @@ setsender(from)
                /* if the user has given fullname already, don't redefine */
                if (FullName == NULL)
                        FullName = macvalue('x', CurEnv);
                /* if the user has given fullname already, don't redefine */
                if (FullName == NULL)
                        FullName = macvalue('x', CurEnv);
-               if (FullName[0] == '\0')
+               if (FullName != NULL && FullName[0] == '\0')
                        FullName = NULL;
 
                /* extract full name from passwd file */
                        FullName = NULL;
 
                /* extract full name from passwd file */