122697Sdist /* 234920Sbostic * Copyright (c) 1983 Eric P. Allman 362522Sbostic * Copyright (c) 1988, 1993 462522Sbostic * The Regents of the University of California. All rights reserved. 533728Sbostic * 642824Sbostic * %sccs.include.redist.c% 733728Sbostic */ 822697Sdist 922697Sdist #ifndef lint 10*67688Seric static char sccsid[] = "@(#)collect.c 8.22 (Berkeley) 08/15/94"; 1133728Sbostic #endif /* not lint */ 1222697Sdist 131439Seric # include <errno.h> 143309Seric # include "sendmail.h" 151392Seric 161392Seric /* 172969Seric ** COLLECT -- read & parse message header & make temp file. 181392Seric ** 191392Seric ** Creates a temporary file name and copies the standard 209371Seric ** input to that file. Leading UNIX-style "From" lines are 219371Seric ** stripped off (after important information is extracted). 221392Seric ** 231392Seric ** Parameters: 2467546Seric ** fp -- file to read. 2552106Seric ** smtpmode -- if set, we are running SMTP: give an RFC821 2652105Seric ** style message to say we are ready to collect 2752105Seric ** input, and never ignore a single dot to mean 2852105Seric ** end of message. 2958929Seric ** requeueflag -- this message will be requeued later, so 3058929Seric ** don't do final processing on it. 3167546Seric ** hdrp -- the location to stash the header. 3258929Seric ** e -- the current envelope. 331392Seric ** 341392Seric ** Returns: 354162Seric ** none. 361392Seric ** 371392Seric ** Side Effects: 381392Seric ** Temp file is created and filled. 394162Seric ** The from person may be set. 401392Seric */ 411392Seric 4266796Seric char *CollectErrorMessage; 4366796Seric bool CollectErrno; 4466796Seric 4567599Seric static jmp_buf CtxCollectTimeout; 4667599Seric static int collecttimeout(); 4767599Seric static bool CollectProgress; 4867599Seric static EVENT *CollectTimeout; 4967599Seric 5067599Seric /* values for input state machine */ 5167599Seric #define IS_NORM 0 /* middle of line */ 5267599Seric #define IS_BOL 1 /* beginning of line */ 5367599Seric #define IS_DOT 2 /* read a dot at beginning of line */ 5467599Seric #define IS_DOTCR 3 /* read ".\r" at beginning of line */ 5567599Seric #define IS_CR 4 /* read a carriage return */ 5667599Seric 5767599Seric /* values for message state machine */ 5867599Seric #define MS_UFROM 0 /* reading Unix from line */ 5967599Seric #define MS_HEADER 1 /* reading message header */ 6067599Seric #define MS_BODY 2 /* reading message body */ 6167599Seric 6267599Seric 6367546Seric collect(fp, smtpmode, requeueflag, hdrp, e) 6467546Seric FILE *fp; 6552105Seric bool smtpmode; 6658929Seric bool requeueflag; 6767546Seric HDR **hdrp; 6855012Seric register ENVELOPE *e; 691392Seric { 701392Seric register FILE *tf; 7152105Seric bool ignrdot = smtpmode ? FALSE : IgnrDot; 7267268Seric time_t dbto = smtpmode ? TimeOuts.to_datablock : 0; 7367599Seric register char *bp; 7467599Seric register int c; 7564718Seric bool inputerr = FALSE; 7667546Seric bool headeronly = FALSE; 7767599Seric char *buf; 7867599Seric int buflen; 7967599Seric int istate; 8067599Seric int mstate; 8167599Seric char *pbp; 8267599Seric char peekbuf[8]; 8367599Seric char bufbuf[MAXLINE]; 8467599Seric extern bool isheader(); 851392Seric 8666796Seric CollectErrorMessage = NULL; 8766796Seric CollectErrno = 0; 8867546Seric if (hdrp == NULL) 8967546Seric hdrp = &e->e_header; 9067546Seric else 9167546Seric headeronly = TRUE; 9266796Seric 931392Seric /* 941392Seric ** Create the temp file name and create the file. 951392Seric */ 961392Seric 9767546Seric if (!headeronly) 981392Seric { 9967617Seric struct stat stbuf; 10067617Seric 10167546Seric e->e_df = queuename(e, 'd'); 10267546Seric e->e_df = newstr(e->e_df); 10367546Seric if ((tf = dfopen(e->e_df, O_WRONLY|O_CREAT|O_TRUNC, FileMode)) == NULL) 10467546Seric { 10567546Seric syserr("Cannot create %s", e->e_df); 10667546Seric e->e_flags |= EF_NORETURN; 10767546Seric finis(); 10867546Seric } 10967617Seric if (fstat(fileno(tf), &stbuf) < 0) 11067617Seric e->e_dfino = -1; 11167617Seric else 112*67688Seric { 113*67688Seric e->e_dfdev = stbuf.st_dev; 11467617Seric e->e_dfino = stbuf.st_ino; 115*67688Seric } 11667546Seric HasEightBits = FALSE; 1171392Seric } 1181392Seric 1194316Seric /* 1204322Seric ** Tell ARPANET to go ahead. 1214322Seric */ 1224322Seric 12352105Seric if (smtpmode) 12458151Seric message("354 Enter mail, end with \".\" on a line by itself"); 1254322Seric 1264322Seric /* 12767599Seric ** Read the message. 12867599Seric ** 12967599Seric ** This is done using two interleaved state machines. 13067599Seric ** The input state machine is looking for things like 13167599Seric ** hidden dots; the message state machine is handling 13267599Seric ** the larger picture (e.g., header versus body). 1334316Seric */ 1344316Seric 13567599Seric buf = bp = bufbuf; 13667599Seric buflen = sizeof bufbuf; 13767599Seric pbp = peekbuf; 13867599Seric istate = IS_BOL; 13967599Seric mstate = SaveFrom ? MS_HEADER : MS_UFROM; 14067599Seric CollectProgress = FALSE; 14167599Seric 14267599Seric /* if transmitting binary, don't map NL to EOL */ 14367599Seric if (e->e_bodytype != NULL && strcasecmp(e->e_bodytype, "8BITMIME") == 0) 14467599Seric e->e_flags |= EF_NL_NOT_EOL; 14567599Seric 14667599Seric if (dbto != 0) 1472900Seric { 14867599Seric /* handle possible input timeout */ 14967599Seric if (setjmp(CtxCollectTimeout) != 0) 15067599Seric { 15167599Seric #ifdef LOG 15267599Seric syslog(LOG_NOTICE, 15367599Seric "timeout waiting for input from %s during message collect", 15467599Seric CurHostName ? CurHostName : "<local machine>"); 15567599Seric #endif 15667599Seric errno = 0; 15767599Seric usrerr("451 timeout waiting for input during message collect"); 15840965Sbostic goto readerr; 15967599Seric } 16067599Seric CollectTimeout = setevent(dbto, collecttimeout, dbto); 1612900Seric } 1622900Seric 16340965Sbostic for (;;) 1641392Seric { 16567599Seric if (tTd(30, 35)) 16667599Seric printf("top, istate=%d, mstate=%d\n", istate, mstate); 16740965Sbostic for (;;) 1681392Seric { 16967599Seric if (pbp > peekbuf) 17067599Seric c = *--pbp; 17167599Seric else 17264916Seric { 17367599Seric while (!feof(InChannel) && !ferror(InChannel)) 17467599Seric { 17567599Seric errno = 0; 17667599Seric c = fgetc(InChannel); 17767599Seric if (errno != EINTR) 17867599Seric break; 17967599Seric clearerr(InChannel); 18067599Seric } 18167599Seric CollectProgress = TRUE; 18267599Seric if (TrafficLogFile != NULL) 18367599Seric { 18467599Seric if (istate == IS_BOL) 18567599Seric fprintf(TrafficLogFile, "%05d <<< ", 18667599Seric getpid()); 18767599Seric if (c == EOF) 18867599Seric fprintf(TrafficLogFile, "[EOF]\n"); 18967599Seric else 19067599Seric fputc(c, TrafficLogFile); 19167599Seric } 19267599Seric if (c == EOF) 19367599Seric goto readerr; 19467599Seric if (SevenBitInput) 19567599Seric c &= 0x7f; 19667599Seric else 19767599Seric HasEightBits |= bitset(0x80, c); 19867599Seric e->e_msgsize++; 19967599Seric } 20067599Seric if (tTd(30, 94)) 20167599Seric printf("istate=%d, c=%c (0x%x)\n", 20267599Seric istate, c, c); 20367599Seric switch (istate) 20467599Seric { 20567599Seric case IS_BOL: 20667599Seric if (c == '.') 20767599Seric { 20867599Seric istate = IS_DOT; 20967599Seric continue; 21067599Seric } 21164916Seric break; 21240965Sbostic 21367599Seric case IS_DOT: 21467599Seric if (c == '\n' && !ignrdot && 21567599Seric !bitset(EF_NL_NOT_EOL, e->e_flags)) 21667599Seric goto readerr; 21767599Seric else if (c == '\r' && 21867599Seric !bitset(EF_CRLF_NOT_EOL, e->e_flags)) 21967599Seric { 22067599Seric istate = IS_DOTCR; 22167599Seric continue; 22267599Seric } 22367599Seric else if (c != '.' || 22467599Seric (OpMode != MD_SMTP && 22567599Seric OpMode != MD_DAEMON && 22667599Seric OpMode != MD_ARPAFTP)) 22767599Seric { 22867599Seric *pbp++ = c; 22967599Seric c = '.'; 23067599Seric } 2312900Seric break; 23240965Sbostic 23367599Seric case IS_DOTCR: 23467599Seric if (c == '\n') 23567599Seric goto readerr; 23667599Seric else 23767599Seric { 23867599Seric /* push back the ".\rx" */ 23967599Seric *pbp++ = c; 24067599Seric *pbp++ = '\r'; 24167599Seric c = '.'; 24267599Seric } 24367599Seric break; 24440965Sbostic 24567599Seric case IS_CR: 24667599Seric if (c != '\n') 24767599Seric { 24867599Seric ungetc(c, InChannel); 24967599Seric c = '\r'; 25067599Seric } 25167599Seric else if (!bitset(EF_CRLF_NOT_EOL, e->e_flags)) 25267599Seric istate = IS_BOL; 25367599Seric break; 25467599Seric } 25557135Seric 25667599Seric if (c == '\r') 25740965Sbostic { 25867599Seric istate = IS_CR; 25967599Seric continue; 26067599Seric } 26167599Seric else if (c == '\n' && !bitset(EF_NL_NOT_EOL, e->e_flags)) 26267599Seric istate = IS_BOL; 26367599Seric else 26467599Seric istate = IS_NORM; 26540965Sbostic 26667599Seric if (mstate == MS_BODY) 26767599Seric { 26867599Seric /* just put the character out */ 26967599Seric fputc(c, tf); 27067599Seric continue; 27140965Sbostic } 2721392Seric 27367599Seric /* header -- buffer up */ 27467599Seric if (bp >= &buf[buflen - 2]) 27567599Seric { 27667599Seric char *obuf; 2771392Seric 27867599Seric if (mstate != MS_HEADER) 27967599Seric break; 28040965Sbostic 28167599Seric /* out of space for header */ 28267599Seric obuf = buf; 28367599Seric if (buflen < MEMCHUNKSIZE) 28467599Seric buflen *= 2; 28567599Seric else 28667599Seric buflen += MEMCHUNKSIZE; 28767599Seric buf = xalloc(buflen); 28867599Seric bcopy(obuf, buf, bp - obuf); 28967599Seric bp = &buf[bp - obuf]; 29067599Seric if (obuf != bufbuf) 29167599Seric free(obuf); 29267599Seric } 29367599Seric *bp++ = c; 29467599Seric if (istate == IS_BOL) 29567599Seric break; 29640965Sbostic } 29767599Seric *bp = '\0'; 29840965Sbostic 29967599Seric nextstate: 30067599Seric if (tTd(30, 35)) 30167599Seric printf("nextstate, istate=%d, mstate=%d, line = \"%s\"\n", 30267599Seric istate, mstate, buf); 30367599Seric switch (mstate) 30467599Seric { 30567599Seric case MS_UFROM: 30667599Seric mstate = MS_HEADER; 30767599Seric if (strncmp(buf, "From ", 5) == 0) 30867599Seric { 30967599Seric eatfrom(buf, e); 31067599Seric continue; 31167599Seric } 31267599Seric /* fall through */ 3132900Seric 31467599Seric case MS_HEADER: 31567599Seric if (!isheader(buf)) 31667599Seric { 31767599Seric mstate = MS_BODY; 31867599Seric goto nextstate; 31967599Seric } 32057135Seric 32167599Seric /* check for possible continuation line */ 32267599Seric do 32367599Seric { 32467599Seric clearerr(InChannel); 32567599Seric errno = 0; 32667599Seric c = fgetc(InChannel); 32767599Seric } while (errno == EINTR); 32867599Seric if (c != EOF) 32967599Seric ungetc(c, InChannel); 33067599Seric if (c == ' ' || c == '\t') 33167599Seric { 33267599Seric /* yep -- defer this */ 33367599Seric continue; 33467599Seric } 33557135Seric 33667599Seric /* trim off trailing CRLF or NL */ 33767599Seric if (*--bp != '\n' || *--bp != '\r') 33867599Seric bp++; 33967599Seric *bp = '\0'; 34067599Seric if (bitset(H_EOH, chompheader(buf, FALSE, e))) 34167599Seric mstate = MS_BODY; 34267599Seric break; 3431392Seric 34467599Seric case MS_BODY: 34567599Seric if (tTd(30, 1)) 34667599Seric printf("EOH\n"); 34767599Seric if (headeronly) 34867599Seric goto readerr; 34967599Seric bp = buf; 3502900Seric 35167599Seric /* toss blank line */ 35267599Seric if ((!bitset(EF_CRLF_NOT_EOL, e->e_flags) && 35367599Seric bp[0] == '\r' && bp[1] == '\n') || 35467599Seric (!bitset(EF_NL_NOT_EOL, e->e_flags) && 35567599Seric bp[0] == '\n')) 35667599Seric { 35767599Seric break; 35867599Seric } 35967546Seric 36067599Seric /* if not a blank separator, write it out */ 36167599Seric while (*bp != '\0') 36267599Seric fputc(*bp++, tf); 3632900Seric break; 36467599Seric } 36567599Seric bp = buf; 36664718Seric } 36740965Sbostic 36867546Seric readerr: 36967546Seric if ((feof(fp) && smtpmode) || ferror(fp)) 37064718Seric { 37164916Seric if (tTd(30, 1)) 37264916Seric printf("collect: read error\n"); 37364718Seric inputerr = TRUE; 37464718Seric } 37564718Seric 37666765Seric /* reset global timer */ 37767599Seric clrevent(CollectTimeout); 37866765Seric 37967546Seric if (headeronly) 38067546Seric return; 38167546Seric 38267546Seric if (tf != NULL) 38364762Seric { 38467546Seric if (fflush(tf) != 0) 38567546Seric tferror(tf, e); 38667546Seric if (fsync(fileno(tf)) < 0 || fclose(tf) < 0) 38767546Seric { 38867546Seric tferror(tf, e); 38967546Seric finis(); 39067546Seric } 39164762Seric } 3922900Seric 39366796Seric if (CollectErrorMessage != NULL && Errors <= 0) 39416136Seric { 39566796Seric if (CollectErrno != 0) 39666796Seric { 39766796Seric errno = CollectErrno; 39866796Seric syserr(CollectErrorMessage, e->e_df); 39966796Seric finis(); 40066796Seric } 40166796Seric usrerr(CollectErrorMessage); 40266796Seric } 40366796Seric else if (inputerr && (OpMode == MD_SMTP || OpMode == MD_DAEMON)) 40466796Seric { 40566796Seric /* An EOF when running SMTP is an error */ 40658308Seric char *host; 40764718Seric char *problem; 40858082Seric 40958308Seric host = RealHostName; 41058308Seric if (host == NULL) 41158308Seric host = "localhost"; 41258308Seric 41367546Seric if (feof(fp)) 41464718Seric problem = "unexpected close"; 41567546Seric else if (ferror(fp)) 41664718Seric problem = "I/O error"; 41764718Seric else 41864718Seric problem = "read timeout"; 41936233Skarels # ifdef LOG 42067546Seric if (LogLevel > 0 && feof(fp)) 42136230Skarels syslog(LOG_NOTICE, 42266864Seric "collect: %s on connection from %s, sender=%s: %s\n", 42366864Seric problem, host, e->e_from.q_paddr, errstring(errno)); 42436233Skarels # endif 42567546Seric if (feof(fp)) 42665951Seric usrerr("451 collect: %s on connection from %s, from=%s", 42764718Seric problem, host, e->e_from.q_paddr); 42865951Seric else 42965951Seric syserr("451 collect: %s on connection from %s, from=%s", 43065951Seric problem, host, e->e_from.q_paddr); 43111145Seric 43216136Seric /* don't return an error indication */ 43355012Seric e->e_to = NULL; 43455012Seric e->e_flags &= ~EF_FATALERRS; 43564124Seric e->e_flags |= EF_CLRQUEUE; 43616136Seric 43716136Seric /* and don't try to deliver the partial message either */ 43864718Seric if (InChild) 43964718Seric ExitStat = EX_QUIT; 44016136Seric finis(); 44116136Seric } 44216136Seric 4432900Seric /* 4442900Seric ** Find out some information from the headers. 4453386Seric ** Examples are who is the from person & the date. 4462900Seric */ 4472900Seric 44858929Seric eatheader(e, !requeueflag); 4497673Seric 45064068Seric /* collect statistics */ 45164068Seric if (OpMode != MD_VERIFY) 45264068Seric markstats(e, (ADDRESS *) NULL); 45364068Seric 4547782Seric /* 4557782Seric ** Add an Apparently-To: line if we have no recipient lines. 4567782Seric */ 4574622Seric 45867546Seric if (hvalue("to", e->e_header) == NULL && 45967546Seric hvalue("cc", e->e_header) == NULL && 46067546Seric hvalue("bcc", e->e_header) == NULL && 46167546Seric hvalue("apparently-to", e->e_header) == NULL) 4627367Seric { 4637367Seric register ADDRESS *q; 4647367Seric 4657367Seric /* create an Apparently-To: field */ 4667367Seric /* that or reject the message.... */ 46755012Seric for (q = e->e_sendqueue; q != NULL; q = q->q_next) 4687367Seric { 4697389Seric if (q->q_alias != NULL) 4707389Seric continue; 4717673Seric if (tTd(30, 3)) 4727367Seric printf("Adding Apparently-To: %s\n", q->q_paddr); 47367546Seric addheader("Apparently-To", q->q_paddr, &e->e_header); 4747367Seric } 4757367Seric } 4767367Seric 47759320Seric /* check for message too large */ 47859320Seric if (MaxMessageSize > 0 && e->e_msgsize > MaxMessageSize) 47959320Seric { 48059320Seric usrerr("552 Message exceeds maximum fixed size (%ld)", 48159320Seric MaxMessageSize); 48259320Seric } 48359320Seric 48467547Seric /* check for illegal 8-bit data */ 48567547Seric if (HasEightBits) 48667547Seric { 48767547Seric e->e_flags |= EF_HAS8BIT; 48867547Seric if (bitset(MM_MIME8BIT, MimeMode)) 48967547Seric { 49067547Seric /* convert it to MIME */ 49167547Seric if (hvalue("MIME-Version", e->e_header) == NULL) 49267547Seric { 49367547Seric char mimebuf[20]; 49467547Seric 49567547Seric strcpy(mimebuf, "MIME-Version: 1.0"); 49667547Seric chompheader(mimebuf, FALSE, e); 49767547Seric } 49867547Seric if (e->e_bodytype == NULL) 49967547Seric e->e_bodytype = "8BITMIME"; 50067547Seric } 50167547Seric else if (!bitset(MM_PASS8BIT, MimeMode)) 50267547Seric usrerr("554 Eight bit data not allowed"); 50367547Seric } 50467547Seric 50555012Seric if ((e->e_dfp = fopen(e->e_df, "r")) == NULL) 50658690Seric { 50758690Seric /* we haven't acked receipt yet, so just chuck this */ 50855012Seric syserr("Cannot reopen %s", e->e_df); 50958690Seric finis(); 51058690Seric } 5111392Seric } 51240965Sbostic 51367599Seric 51467599Seric static 51567599Seric collecttimeout(timeout) 51667599Seric time_t timeout; 51740965Sbostic { 51867599Seric /* if no progress was made, die now */ 51967599Seric if (!CollectProgress) 52067599Seric longjmp(CtxCollectTimeout, 1); 52140965Sbostic 52267599Seric /* otherwise reset the timeout */ 52367599Seric CollectTimeout = setevent(timeout, collecttimeout, timeout); 52467599Seric CollectProgress = FALSE; 52540965Sbostic } 52640965Sbostic /* 52711544Seric ** TFERROR -- signal error on writing the temporary file. 52811544Seric ** 52911544Seric ** Parameters: 53011544Seric ** tf -- the file pointer for the temporary file. 53111544Seric ** 53211544Seric ** Returns: 53311544Seric ** none. 53411544Seric ** 53511544Seric ** Side Effects: 53611544Seric ** Gives an error message. 53711544Seric ** Arranges for following output to go elsewhere. 53811544Seric */ 53911544Seric 54055012Seric tferror(tf, e) 54111544Seric FILE *tf; 54255012Seric register ENVELOPE *e; 54311544Seric { 54466796Seric CollectErrno = errno; 54511544Seric if (errno == ENOSPC) 54611544Seric { 54766782Seric struct stat st; 54866782Seric long avail; 54966782Seric long bsize; 55066782Seric 55167473Seric e->e_flags |= EF_NORETURN; 55266782Seric if (fstat(fileno(tf), &st) < 0) 55366782Seric st.st_size = 0; 55455012Seric (void) freopen(e->e_df, "w", tf); 55566782Seric if (st.st_size <= 0) 55666782Seric fprintf(tf, "\n*** Mail could not be accepted"); 55766782Seric else if (sizeof st.st_size > sizeof (long)) 55866782Seric fprintf(tf, "\n*** Mail of at least %qd bytes could not be accepted\n", 55966782Seric st.st_size); 56066782Seric else 56166782Seric fprintf(tf, "\n*** Mail of at least %ld bytes could not be accepted\n", 56266782Seric st.st_size); 56366782Seric fprintf(tf, "*** at %s due to lack of disk space for temp file.\n", 56466782Seric MyHostName); 56566782Seric avail = freespace(QueueDir, &bsize); 56666782Seric if (avail > 0) 56766782Seric { 56866782Seric if (bsize > 1024) 56966782Seric avail *= bsize / 1024; 57066782Seric else if (bsize < 1024) 57166782Seric avail /= 1024 / bsize; 57266782Seric fprintf(tf, "*** Currently, %ld kilobytes are available for mail temp files.\n", 57366782Seric avail); 57466782Seric } 57566796Seric CollectErrorMessage = "452 Out of disk space for temp file"; 57611544Seric } 57711544Seric else 57866796Seric { 57966796Seric CollectErrorMessage = "cannot write message body to disk (%s)"; 58066796Seric } 58111544Seric (void) freopen("/dev/null", "w", tf); 58211544Seric } 58311544Seric /* 5842900Seric ** EATFROM -- chew up a UNIX style from line and process 5852900Seric ** 5862900Seric ** This does indeed make some assumptions about the format 5872900Seric ** of UNIX messages. 5882900Seric ** 5892900Seric ** Parameters: 5902900Seric ** fm -- the from line. 5912900Seric ** 5922900Seric ** Returns: 5932900Seric ** none. 5942900Seric ** 5952900Seric ** Side Effects: 5962900Seric ** extracts what information it can from the header, 5973386Seric ** such as the date. 5982900Seric */ 5992900Seric 6004321Seric # ifndef NOTUNIX 6014321Seric 6024203Seric char *DowList[] = 6034203Seric { 6044203Seric "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", NULL 6054203Seric }; 6064203Seric 6072900Seric char *MonthList[] = 6082900Seric { 6092900Seric "Jan", "Feb", "Mar", "Apr", "May", "Jun", 6102900Seric "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", 6112900Seric NULL 6122900Seric }; 6132900Seric 61455012Seric eatfrom(fm, e) 6152900Seric char *fm; 61655012Seric register ENVELOPE *e; 6172900Seric { 6182900Seric register char *p; 6192900Seric register char **dt; 6202900Seric 6217673Seric if (tTd(30, 2)) 6224203Seric printf("eatfrom(%s)\n", fm); 6234203Seric 6242900Seric /* find the date part */ 6252900Seric p = fm; 6262900Seric while (*p != '\0') 6272900Seric { 6282900Seric /* skip a word */ 6292900Seric while (*p != '\0' && *p != ' ') 63016896Seric p++; 6312900Seric while (*p == ' ') 63216896Seric p++; 63358050Seric if (!(isascii(*p) && isupper(*p)) || 63458050Seric p[3] != ' ' || p[13] != ':' || p[16] != ':') 6352900Seric continue; 6362900Seric 6372900Seric /* we have a possible date */ 6384203Seric for (dt = DowList; *dt != NULL; dt++) 6392900Seric if (strncmp(*dt, p, 3) == 0) 6402900Seric break; 6414203Seric if (*dt == NULL) 6424203Seric continue; 6432900Seric 6444203Seric for (dt = MonthList; *dt != NULL; dt++) 6454203Seric if (strncmp(*dt, &p[4], 3) == 0) 6464203Seric break; 6472900Seric if (*dt != NULL) 6482900Seric break; 6492900Seric } 6502900Seric 65160502Seric if (*p != '\0') 6522900Seric { 6533386Seric char *q; 6545366Seric extern char *arpadate(); 6553386Seric 6562900Seric /* we have found a date */ 6573386Seric q = xalloc(25); 65823103Seric (void) strncpy(q, p, 25); 6593386Seric q[24] = '\0'; 6605366Seric q = arpadate(q); 66155012Seric define('a', newstr(q), e); 6622900Seric } 6632900Seric } 6644321Seric 66556795Seric # endif /* NOTUNIX */ 666