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*67689Seric static char sccsid[] = "@(#)collect.c 8.23 (Berkeley) 08/16/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 11267688Seric { 11367688Seric e->e_dfdev = stbuf.st_dev; 11467617Seric e->e_dfino = stbuf.st_ino; 11567688Seric } 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: 246*67689Seric if (c == '\n') 247*67689Seric istate = IS_BOL; 248*67689Seric else 24967599Seric { 25067599Seric ungetc(c, InChannel); 25167599Seric c = '\r'; 252*67689Seric istate = IS_NORM; 25367599Seric } 254*67689Seric goto bufferchar; 25567599Seric } 25657135Seric 257*67689Seric if (c == '\r' && !bitset(EF_CRLF_NOT_EOL, e->e_flags)) 25840965Sbostic { 25967599Seric istate = IS_CR; 26067599Seric continue; 26167599Seric } 26267599Seric else if (c == '\n' && !bitset(EF_NL_NOT_EOL, e->e_flags)) 26367599Seric istate = IS_BOL; 26467599Seric else 26567599Seric istate = IS_NORM; 26640965Sbostic 267*67689Seric bufferchar: 26867599Seric if (mstate == MS_BODY) 26967599Seric { 27067599Seric /* just put the character out */ 27167599Seric fputc(c, tf); 27267599Seric continue; 27340965Sbostic } 2741392Seric 27567599Seric /* header -- buffer up */ 27667599Seric if (bp >= &buf[buflen - 2]) 27767599Seric { 27867599Seric char *obuf; 2791392Seric 28067599Seric if (mstate != MS_HEADER) 28167599Seric break; 28240965Sbostic 28367599Seric /* out of space for header */ 28467599Seric obuf = buf; 28567599Seric if (buflen < MEMCHUNKSIZE) 28667599Seric buflen *= 2; 28767599Seric else 28867599Seric buflen += MEMCHUNKSIZE; 28967599Seric buf = xalloc(buflen); 29067599Seric bcopy(obuf, buf, bp - obuf); 29167599Seric bp = &buf[bp - obuf]; 29267599Seric if (obuf != bufbuf) 29367599Seric free(obuf); 29467599Seric } 29567599Seric *bp++ = c; 29667599Seric if (istate == IS_BOL) 29767599Seric break; 29840965Sbostic } 29967599Seric *bp = '\0'; 30040965Sbostic 30167599Seric nextstate: 30267599Seric if (tTd(30, 35)) 30367599Seric printf("nextstate, istate=%d, mstate=%d, line = \"%s\"\n", 30467599Seric istate, mstate, buf); 30567599Seric switch (mstate) 30667599Seric { 30767599Seric case MS_UFROM: 30867599Seric mstate = MS_HEADER; 30967599Seric if (strncmp(buf, "From ", 5) == 0) 31067599Seric { 31167599Seric eatfrom(buf, e); 31267599Seric continue; 31367599Seric } 31467599Seric /* fall through */ 3152900Seric 31667599Seric case MS_HEADER: 31767599Seric if (!isheader(buf)) 31867599Seric { 31967599Seric mstate = MS_BODY; 32067599Seric goto nextstate; 32167599Seric } 32257135Seric 32367599Seric /* check for possible continuation line */ 32467599Seric do 32567599Seric { 32667599Seric clearerr(InChannel); 32767599Seric errno = 0; 32867599Seric c = fgetc(InChannel); 32967599Seric } while (errno == EINTR); 33067599Seric if (c != EOF) 33167599Seric ungetc(c, InChannel); 33267599Seric if (c == ' ' || c == '\t') 33367599Seric { 33467599Seric /* yep -- defer this */ 33567599Seric continue; 33667599Seric } 33757135Seric 33867599Seric /* trim off trailing CRLF or NL */ 33967599Seric if (*--bp != '\n' || *--bp != '\r') 34067599Seric bp++; 34167599Seric *bp = '\0'; 34267599Seric if (bitset(H_EOH, chompheader(buf, FALSE, e))) 34367599Seric mstate = MS_BODY; 34467599Seric break; 3451392Seric 34667599Seric case MS_BODY: 34767599Seric if (tTd(30, 1)) 34867599Seric printf("EOH\n"); 34967599Seric if (headeronly) 35067599Seric goto readerr; 35167599Seric bp = buf; 3522900Seric 35367599Seric /* toss blank line */ 35467599Seric if ((!bitset(EF_CRLF_NOT_EOL, e->e_flags) && 35567599Seric bp[0] == '\r' && bp[1] == '\n') || 35667599Seric (!bitset(EF_NL_NOT_EOL, e->e_flags) && 35767599Seric bp[0] == '\n')) 35867599Seric { 35967599Seric break; 36067599Seric } 36167546Seric 36267599Seric /* if not a blank separator, write it out */ 36367599Seric while (*bp != '\0') 36467599Seric fputc(*bp++, tf); 3652900Seric break; 36667599Seric } 36767599Seric bp = buf; 36864718Seric } 36940965Sbostic 37067546Seric readerr: 37167546Seric if ((feof(fp) && smtpmode) || ferror(fp)) 37264718Seric { 37364916Seric if (tTd(30, 1)) 37464916Seric printf("collect: read error\n"); 37564718Seric inputerr = TRUE; 37664718Seric } 37764718Seric 37866765Seric /* reset global timer */ 37967599Seric clrevent(CollectTimeout); 38066765Seric 38167546Seric if (headeronly) 38267546Seric return; 38367546Seric 38467546Seric if (tf != NULL) 38564762Seric { 38667546Seric if (fflush(tf) != 0) 38767546Seric tferror(tf, e); 38867546Seric if (fsync(fileno(tf)) < 0 || fclose(tf) < 0) 38967546Seric { 39067546Seric tferror(tf, e); 39167546Seric finis(); 39267546Seric } 39364762Seric } 3942900Seric 39566796Seric if (CollectErrorMessage != NULL && Errors <= 0) 39616136Seric { 39766796Seric if (CollectErrno != 0) 39866796Seric { 39966796Seric errno = CollectErrno; 40066796Seric syserr(CollectErrorMessage, e->e_df); 40166796Seric finis(); 40266796Seric } 40366796Seric usrerr(CollectErrorMessage); 40466796Seric } 40566796Seric else if (inputerr && (OpMode == MD_SMTP || OpMode == MD_DAEMON)) 40666796Seric { 40766796Seric /* An EOF when running SMTP is an error */ 40858308Seric char *host; 40964718Seric char *problem; 41058082Seric 41158308Seric host = RealHostName; 41258308Seric if (host == NULL) 41358308Seric host = "localhost"; 41458308Seric 41567546Seric if (feof(fp)) 41664718Seric problem = "unexpected close"; 41767546Seric else if (ferror(fp)) 41864718Seric problem = "I/O error"; 41964718Seric else 42064718Seric problem = "read timeout"; 42136233Skarels # ifdef LOG 42267546Seric if (LogLevel > 0 && feof(fp)) 42336230Skarels syslog(LOG_NOTICE, 42466864Seric "collect: %s on connection from %s, sender=%s: %s\n", 42566864Seric problem, host, e->e_from.q_paddr, errstring(errno)); 42636233Skarels # endif 42767546Seric if (feof(fp)) 42865951Seric usrerr("451 collect: %s on connection from %s, from=%s", 42964718Seric problem, host, e->e_from.q_paddr); 43065951Seric else 43165951Seric syserr("451 collect: %s on connection from %s, from=%s", 43265951Seric problem, host, e->e_from.q_paddr); 43311145Seric 43416136Seric /* don't return an error indication */ 43555012Seric e->e_to = NULL; 43655012Seric e->e_flags &= ~EF_FATALERRS; 43764124Seric e->e_flags |= EF_CLRQUEUE; 43816136Seric 43916136Seric /* and don't try to deliver the partial message either */ 44064718Seric if (InChild) 44164718Seric ExitStat = EX_QUIT; 44216136Seric finis(); 44316136Seric } 44416136Seric 4452900Seric /* 4462900Seric ** Find out some information from the headers. 4473386Seric ** Examples are who is the from person & the date. 4482900Seric */ 4492900Seric 45058929Seric eatheader(e, !requeueflag); 4517673Seric 45264068Seric /* collect statistics */ 45364068Seric if (OpMode != MD_VERIFY) 45464068Seric markstats(e, (ADDRESS *) NULL); 45564068Seric 4567782Seric /* 4577782Seric ** Add an Apparently-To: line if we have no recipient lines. 4587782Seric */ 4594622Seric 46067546Seric if (hvalue("to", e->e_header) == NULL && 46167546Seric hvalue("cc", e->e_header) == NULL && 46267546Seric hvalue("bcc", e->e_header) == NULL && 46367546Seric hvalue("apparently-to", e->e_header) == NULL) 4647367Seric { 4657367Seric register ADDRESS *q; 4667367Seric 4677367Seric /* create an Apparently-To: field */ 4687367Seric /* that or reject the message.... */ 46955012Seric for (q = e->e_sendqueue; q != NULL; q = q->q_next) 4707367Seric { 4717389Seric if (q->q_alias != NULL) 4727389Seric continue; 4737673Seric if (tTd(30, 3)) 4747367Seric printf("Adding Apparently-To: %s\n", q->q_paddr); 47567546Seric addheader("Apparently-To", q->q_paddr, &e->e_header); 4767367Seric } 4777367Seric } 4787367Seric 47959320Seric /* check for message too large */ 48059320Seric if (MaxMessageSize > 0 && e->e_msgsize > MaxMessageSize) 48159320Seric { 48259320Seric usrerr("552 Message exceeds maximum fixed size (%ld)", 48359320Seric MaxMessageSize); 48459320Seric } 48559320Seric 48667547Seric /* check for illegal 8-bit data */ 48767547Seric if (HasEightBits) 48867547Seric { 48967547Seric e->e_flags |= EF_HAS8BIT; 49067547Seric if (bitset(MM_MIME8BIT, MimeMode)) 49167547Seric { 49267547Seric /* convert it to MIME */ 49367547Seric if (hvalue("MIME-Version", e->e_header) == NULL) 49467547Seric { 49567547Seric char mimebuf[20]; 49667547Seric 49767547Seric strcpy(mimebuf, "MIME-Version: 1.0"); 49867547Seric chompheader(mimebuf, FALSE, e); 49967547Seric } 50067547Seric if (e->e_bodytype == NULL) 50167547Seric e->e_bodytype = "8BITMIME"; 50267547Seric } 50367547Seric else if (!bitset(MM_PASS8BIT, MimeMode)) 50467547Seric usrerr("554 Eight bit data not allowed"); 50567547Seric } 50667547Seric 50755012Seric if ((e->e_dfp = fopen(e->e_df, "r")) == NULL) 50858690Seric { 50958690Seric /* we haven't acked receipt yet, so just chuck this */ 51055012Seric syserr("Cannot reopen %s", e->e_df); 51158690Seric finis(); 51258690Seric } 5131392Seric } 51440965Sbostic 51567599Seric 51667599Seric static 51767599Seric collecttimeout(timeout) 51867599Seric time_t timeout; 51940965Sbostic { 52067599Seric /* if no progress was made, die now */ 52167599Seric if (!CollectProgress) 52267599Seric longjmp(CtxCollectTimeout, 1); 52340965Sbostic 52467599Seric /* otherwise reset the timeout */ 52567599Seric CollectTimeout = setevent(timeout, collecttimeout, timeout); 52667599Seric CollectProgress = FALSE; 52740965Sbostic } 52840965Sbostic /* 52911544Seric ** TFERROR -- signal error on writing the temporary file. 53011544Seric ** 53111544Seric ** Parameters: 53211544Seric ** tf -- the file pointer for the temporary file. 53311544Seric ** 53411544Seric ** Returns: 53511544Seric ** none. 53611544Seric ** 53711544Seric ** Side Effects: 53811544Seric ** Gives an error message. 53911544Seric ** Arranges for following output to go elsewhere. 54011544Seric */ 54111544Seric 54255012Seric tferror(tf, e) 54311544Seric FILE *tf; 54455012Seric register ENVELOPE *e; 54511544Seric { 54666796Seric CollectErrno = errno; 54711544Seric if (errno == ENOSPC) 54811544Seric { 54966782Seric struct stat st; 55066782Seric long avail; 55166782Seric long bsize; 55266782Seric 55367473Seric e->e_flags |= EF_NORETURN; 55466782Seric if (fstat(fileno(tf), &st) < 0) 55566782Seric st.st_size = 0; 55655012Seric (void) freopen(e->e_df, "w", tf); 55766782Seric if (st.st_size <= 0) 55866782Seric fprintf(tf, "\n*** Mail could not be accepted"); 55966782Seric else if (sizeof st.st_size > sizeof (long)) 56066782Seric fprintf(tf, "\n*** Mail of at least %qd bytes could not be accepted\n", 56166782Seric st.st_size); 56266782Seric else 56366782Seric fprintf(tf, "\n*** Mail of at least %ld bytes could not be accepted\n", 56466782Seric st.st_size); 56566782Seric fprintf(tf, "*** at %s due to lack of disk space for temp file.\n", 56666782Seric MyHostName); 56766782Seric avail = freespace(QueueDir, &bsize); 56866782Seric if (avail > 0) 56966782Seric { 57066782Seric if (bsize > 1024) 57166782Seric avail *= bsize / 1024; 57266782Seric else if (bsize < 1024) 57366782Seric avail /= 1024 / bsize; 57466782Seric fprintf(tf, "*** Currently, %ld kilobytes are available for mail temp files.\n", 57566782Seric avail); 57666782Seric } 57766796Seric CollectErrorMessage = "452 Out of disk space for temp file"; 57811544Seric } 57911544Seric else 58066796Seric { 58166796Seric CollectErrorMessage = "cannot write message body to disk (%s)"; 58266796Seric } 58311544Seric (void) freopen("/dev/null", "w", tf); 58411544Seric } 58511544Seric /* 5862900Seric ** EATFROM -- chew up a UNIX style from line and process 5872900Seric ** 5882900Seric ** This does indeed make some assumptions about the format 5892900Seric ** of UNIX messages. 5902900Seric ** 5912900Seric ** Parameters: 5922900Seric ** fm -- the from line. 5932900Seric ** 5942900Seric ** Returns: 5952900Seric ** none. 5962900Seric ** 5972900Seric ** Side Effects: 5982900Seric ** extracts what information it can from the header, 5993386Seric ** such as the date. 6002900Seric */ 6012900Seric 6024321Seric # ifndef NOTUNIX 6034321Seric 6044203Seric char *DowList[] = 6054203Seric { 6064203Seric "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", NULL 6074203Seric }; 6084203Seric 6092900Seric char *MonthList[] = 6102900Seric { 6112900Seric "Jan", "Feb", "Mar", "Apr", "May", "Jun", 6122900Seric "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", 6132900Seric NULL 6142900Seric }; 6152900Seric 61655012Seric eatfrom(fm, e) 6172900Seric char *fm; 61855012Seric register ENVELOPE *e; 6192900Seric { 6202900Seric register char *p; 6212900Seric register char **dt; 6222900Seric 6237673Seric if (tTd(30, 2)) 6244203Seric printf("eatfrom(%s)\n", fm); 6254203Seric 6262900Seric /* find the date part */ 6272900Seric p = fm; 6282900Seric while (*p != '\0') 6292900Seric { 6302900Seric /* skip a word */ 6312900Seric while (*p != '\0' && *p != ' ') 63216896Seric p++; 6332900Seric while (*p == ' ') 63416896Seric p++; 63558050Seric if (!(isascii(*p) && isupper(*p)) || 63658050Seric p[3] != ' ' || p[13] != ':' || p[16] != ':') 6372900Seric continue; 6382900Seric 6392900Seric /* we have a possible date */ 6404203Seric for (dt = DowList; *dt != NULL; dt++) 6412900Seric if (strncmp(*dt, p, 3) == 0) 6422900Seric break; 6434203Seric if (*dt == NULL) 6444203Seric continue; 6452900Seric 6464203Seric for (dt = MonthList; *dt != NULL; dt++) 6474203Seric if (strncmp(*dt, &p[4], 3) == 0) 6484203Seric break; 6492900Seric if (*dt != NULL) 6502900Seric break; 6512900Seric } 6522900Seric 65360502Seric if (*p != '\0') 6542900Seric { 6553386Seric char *q; 6565366Seric extern char *arpadate(); 6573386Seric 6582900Seric /* we have found a date */ 6593386Seric q = xalloc(25); 66023103Seric (void) strncpy(q, p, 25); 6613386Seric q[24] = '\0'; 6625366Seric q = arpadate(q); 66355012Seric define('a', newstr(q), e); 6642900Seric } 6652900Seric } 6664321Seric 66756795Seric # endif /* NOTUNIX */ 668