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*67704Seric static char sccsid[] = "@(#)collect.c 8.24 (Berkeley) 08/18/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: 24667689Seric if (c == '\n') 24767689Seric istate = IS_BOL; 24867689Seric else 24967599Seric { 25067599Seric ungetc(c, InChannel); 25167599Seric c = '\r'; 25267689Seric istate = IS_NORM; 25367599Seric } 25467689Seric goto bufferchar; 25567599Seric } 25657135Seric 25767689Seric 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 26767689Seric 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 { 311*67704Seric bp = buf; 31267599Seric eatfrom(buf, e); 31367599Seric continue; 31467599Seric } 31567599Seric /* fall through */ 3162900Seric 31767599Seric case MS_HEADER: 31867599Seric if (!isheader(buf)) 31967599Seric { 32067599Seric mstate = MS_BODY; 32167599Seric goto nextstate; 32267599Seric } 32357135Seric 32467599Seric /* check for possible continuation line */ 32567599Seric do 32667599Seric { 32767599Seric clearerr(InChannel); 32867599Seric errno = 0; 32967599Seric c = fgetc(InChannel); 33067599Seric } while (errno == EINTR); 33167599Seric if (c != EOF) 33267599Seric ungetc(c, InChannel); 33367599Seric if (c == ' ' || c == '\t') 33467599Seric { 33567599Seric /* yep -- defer this */ 33667599Seric continue; 33767599Seric } 33857135Seric 33967599Seric /* trim off trailing CRLF or NL */ 34067599Seric if (*--bp != '\n' || *--bp != '\r') 34167599Seric bp++; 34267599Seric *bp = '\0'; 34367599Seric if (bitset(H_EOH, chompheader(buf, FALSE, e))) 34467599Seric mstate = MS_BODY; 34567599Seric break; 3461392Seric 34767599Seric case MS_BODY: 34867599Seric if (tTd(30, 1)) 34967599Seric printf("EOH\n"); 35067599Seric if (headeronly) 35167599Seric goto readerr; 35267599Seric bp = buf; 3532900Seric 35467599Seric /* toss blank line */ 35567599Seric if ((!bitset(EF_CRLF_NOT_EOL, e->e_flags) && 35667599Seric bp[0] == '\r' && bp[1] == '\n') || 35767599Seric (!bitset(EF_NL_NOT_EOL, e->e_flags) && 35867599Seric bp[0] == '\n')) 35967599Seric { 36067599Seric break; 36167599Seric } 36267546Seric 36367599Seric /* if not a blank separator, write it out */ 36467599Seric while (*bp != '\0') 36567599Seric fputc(*bp++, tf); 3662900Seric break; 36767599Seric } 36867599Seric bp = buf; 36964718Seric } 37040965Sbostic 37167546Seric readerr: 37267546Seric if ((feof(fp) && smtpmode) || ferror(fp)) 37364718Seric { 37464916Seric if (tTd(30, 1)) 37564916Seric printf("collect: read error\n"); 37664718Seric inputerr = TRUE; 37764718Seric } 37864718Seric 37966765Seric /* reset global timer */ 38067599Seric clrevent(CollectTimeout); 38166765Seric 38267546Seric if (headeronly) 38367546Seric return; 38467546Seric 38567546Seric if (tf != NULL) 38664762Seric { 38767546Seric if (fflush(tf) != 0) 38867546Seric tferror(tf, e); 38967546Seric if (fsync(fileno(tf)) < 0 || fclose(tf) < 0) 39067546Seric { 39167546Seric tferror(tf, e); 39267546Seric finis(); 39367546Seric } 39464762Seric } 3952900Seric 39666796Seric if (CollectErrorMessage != NULL && Errors <= 0) 39716136Seric { 39866796Seric if (CollectErrno != 0) 39966796Seric { 40066796Seric errno = CollectErrno; 40166796Seric syserr(CollectErrorMessage, e->e_df); 40266796Seric finis(); 40366796Seric } 40466796Seric usrerr(CollectErrorMessage); 40566796Seric } 40666796Seric else if (inputerr && (OpMode == MD_SMTP || OpMode == MD_DAEMON)) 40766796Seric { 40866796Seric /* An EOF when running SMTP is an error */ 40958308Seric char *host; 41064718Seric char *problem; 41158082Seric 41258308Seric host = RealHostName; 41358308Seric if (host == NULL) 41458308Seric host = "localhost"; 41558308Seric 41667546Seric if (feof(fp)) 41764718Seric problem = "unexpected close"; 41867546Seric else if (ferror(fp)) 41964718Seric problem = "I/O error"; 42064718Seric else 42164718Seric problem = "read timeout"; 42236233Skarels # ifdef LOG 42367546Seric if (LogLevel > 0 && feof(fp)) 42436230Skarels syslog(LOG_NOTICE, 42566864Seric "collect: %s on connection from %s, sender=%s: %s\n", 42666864Seric problem, host, e->e_from.q_paddr, errstring(errno)); 42736233Skarels # endif 42867546Seric if (feof(fp)) 42965951Seric usrerr("451 collect: %s on connection from %s, from=%s", 43064718Seric problem, host, e->e_from.q_paddr); 43165951Seric else 43265951Seric syserr("451 collect: %s on connection from %s, from=%s", 43365951Seric problem, host, e->e_from.q_paddr); 43411145Seric 43516136Seric /* don't return an error indication */ 43655012Seric e->e_to = NULL; 43755012Seric e->e_flags &= ~EF_FATALERRS; 43864124Seric e->e_flags |= EF_CLRQUEUE; 43916136Seric 44016136Seric /* and don't try to deliver the partial message either */ 44164718Seric if (InChild) 44264718Seric ExitStat = EX_QUIT; 44316136Seric finis(); 44416136Seric } 44516136Seric 4462900Seric /* 4472900Seric ** Find out some information from the headers. 4483386Seric ** Examples are who is the from person & the date. 4492900Seric */ 4502900Seric 45158929Seric eatheader(e, !requeueflag); 4527673Seric 45364068Seric /* collect statistics */ 45464068Seric if (OpMode != MD_VERIFY) 45564068Seric markstats(e, (ADDRESS *) NULL); 45664068Seric 4577782Seric /* 4587782Seric ** Add an Apparently-To: line if we have no recipient lines. 4597782Seric */ 4604622Seric 46167546Seric if (hvalue("to", e->e_header) == NULL && 46267546Seric hvalue("cc", e->e_header) == NULL && 46367546Seric hvalue("bcc", e->e_header) == NULL && 46467546Seric hvalue("apparently-to", e->e_header) == NULL) 4657367Seric { 4667367Seric register ADDRESS *q; 4677367Seric 4687367Seric /* create an Apparently-To: field */ 4697367Seric /* that or reject the message.... */ 47055012Seric for (q = e->e_sendqueue; q != NULL; q = q->q_next) 4717367Seric { 4727389Seric if (q->q_alias != NULL) 4737389Seric continue; 4747673Seric if (tTd(30, 3)) 4757367Seric printf("Adding Apparently-To: %s\n", q->q_paddr); 47667546Seric addheader("Apparently-To", q->q_paddr, &e->e_header); 4777367Seric } 4787367Seric } 4797367Seric 48059320Seric /* check for message too large */ 48159320Seric if (MaxMessageSize > 0 && e->e_msgsize > MaxMessageSize) 48259320Seric { 48359320Seric usrerr("552 Message exceeds maximum fixed size (%ld)", 48459320Seric MaxMessageSize); 48559320Seric } 48659320Seric 48767547Seric /* check for illegal 8-bit data */ 48867547Seric if (HasEightBits) 48967547Seric { 49067547Seric e->e_flags |= EF_HAS8BIT; 49167547Seric if (bitset(MM_MIME8BIT, MimeMode)) 49267547Seric { 49367547Seric /* convert it to MIME */ 49467547Seric if (hvalue("MIME-Version", e->e_header) == NULL) 49567547Seric { 49667547Seric char mimebuf[20]; 49767547Seric 49867547Seric strcpy(mimebuf, "MIME-Version: 1.0"); 49967547Seric chompheader(mimebuf, FALSE, e); 50067547Seric } 50167547Seric if (e->e_bodytype == NULL) 50267547Seric e->e_bodytype = "8BITMIME"; 50367547Seric } 50467547Seric else if (!bitset(MM_PASS8BIT, MimeMode)) 50567547Seric usrerr("554 Eight bit data not allowed"); 50667547Seric } 50767547Seric 50855012Seric if ((e->e_dfp = fopen(e->e_df, "r")) == NULL) 50958690Seric { 51058690Seric /* we haven't acked receipt yet, so just chuck this */ 51155012Seric syserr("Cannot reopen %s", e->e_df); 51258690Seric finis(); 51358690Seric } 5141392Seric } 51540965Sbostic 51667599Seric 51767599Seric static 51867599Seric collecttimeout(timeout) 51967599Seric time_t timeout; 52040965Sbostic { 52167599Seric /* if no progress was made, die now */ 52267599Seric if (!CollectProgress) 52367599Seric longjmp(CtxCollectTimeout, 1); 52440965Sbostic 52567599Seric /* otherwise reset the timeout */ 52667599Seric CollectTimeout = setevent(timeout, collecttimeout, timeout); 52767599Seric CollectProgress = FALSE; 52840965Sbostic } 52940965Sbostic /* 53011544Seric ** TFERROR -- signal error on writing the temporary file. 53111544Seric ** 53211544Seric ** Parameters: 53311544Seric ** tf -- the file pointer for the temporary file. 53411544Seric ** 53511544Seric ** Returns: 53611544Seric ** none. 53711544Seric ** 53811544Seric ** Side Effects: 53911544Seric ** Gives an error message. 54011544Seric ** Arranges for following output to go elsewhere. 54111544Seric */ 54211544Seric 54355012Seric tferror(tf, e) 54411544Seric FILE *tf; 54555012Seric register ENVELOPE *e; 54611544Seric { 54766796Seric CollectErrno = errno; 54811544Seric if (errno == ENOSPC) 54911544Seric { 55066782Seric struct stat st; 55166782Seric long avail; 55266782Seric long bsize; 55366782Seric 55467473Seric e->e_flags |= EF_NORETURN; 55566782Seric if (fstat(fileno(tf), &st) < 0) 55666782Seric st.st_size = 0; 55755012Seric (void) freopen(e->e_df, "w", tf); 55866782Seric if (st.st_size <= 0) 55966782Seric fprintf(tf, "\n*** Mail could not be accepted"); 56066782Seric else if (sizeof st.st_size > sizeof (long)) 56166782Seric fprintf(tf, "\n*** Mail of at least %qd bytes could not be accepted\n", 56266782Seric st.st_size); 56366782Seric else 56466782Seric fprintf(tf, "\n*** Mail of at least %ld bytes could not be accepted\n", 56566782Seric st.st_size); 56666782Seric fprintf(tf, "*** at %s due to lack of disk space for temp file.\n", 56766782Seric MyHostName); 56866782Seric avail = freespace(QueueDir, &bsize); 56966782Seric if (avail > 0) 57066782Seric { 57166782Seric if (bsize > 1024) 57266782Seric avail *= bsize / 1024; 57366782Seric else if (bsize < 1024) 57466782Seric avail /= 1024 / bsize; 57566782Seric fprintf(tf, "*** Currently, %ld kilobytes are available for mail temp files.\n", 57666782Seric avail); 57766782Seric } 57866796Seric CollectErrorMessage = "452 Out of disk space for temp file"; 57911544Seric } 58011544Seric else 58166796Seric { 58266796Seric CollectErrorMessage = "cannot write message body to disk (%s)"; 58366796Seric } 58411544Seric (void) freopen("/dev/null", "w", tf); 58511544Seric } 58611544Seric /* 5872900Seric ** EATFROM -- chew up a UNIX style from line and process 5882900Seric ** 5892900Seric ** This does indeed make some assumptions about the format 5902900Seric ** of UNIX messages. 5912900Seric ** 5922900Seric ** Parameters: 5932900Seric ** fm -- the from line. 5942900Seric ** 5952900Seric ** Returns: 5962900Seric ** none. 5972900Seric ** 5982900Seric ** Side Effects: 5992900Seric ** extracts what information it can from the header, 6003386Seric ** such as the date. 6012900Seric */ 6022900Seric 6034321Seric # ifndef NOTUNIX 6044321Seric 6054203Seric char *DowList[] = 6064203Seric { 6074203Seric "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", NULL 6084203Seric }; 6094203Seric 6102900Seric char *MonthList[] = 6112900Seric { 6122900Seric "Jan", "Feb", "Mar", "Apr", "May", "Jun", 6132900Seric "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", 6142900Seric NULL 6152900Seric }; 6162900Seric 61755012Seric eatfrom(fm, e) 6182900Seric char *fm; 61955012Seric register ENVELOPE *e; 6202900Seric { 6212900Seric register char *p; 6222900Seric register char **dt; 6232900Seric 6247673Seric if (tTd(30, 2)) 6254203Seric printf("eatfrom(%s)\n", fm); 6264203Seric 6272900Seric /* find the date part */ 6282900Seric p = fm; 6292900Seric while (*p != '\0') 6302900Seric { 6312900Seric /* skip a word */ 6322900Seric while (*p != '\0' && *p != ' ') 63316896Seric p++; 6342900Seric while (*p == ' ') 63516896Seric p++; 63658050Seric if (!(isascii(*p) && isupper(*p)) || 63758050Seric p[3] != ' ' || p[13] != ':' || p[16] != ':') 6382900Seric continue; 6392900Seric 6402900Seric /* we have a possible date */ 6414203Seric for (dt = DowList; *dt != NULL; dt++) 6422900Seric if (strncmp(*dt, p, 3) == 0) 6432900Seric break; 6444203Seric if (*dt == NULL) 6454203Seric continue; 6462900Seric 6474203Seric for (dt = MonthList; *dt != NULL; dt++) 6484203Seric if (strncmp(*dt, &p[4], 3) == 0) 6494203Seric break; 6502900Seric if (*dt != NULL) 6512900Seric break; 6522900Seric } 6532900Seric 65460502Seric if (*p != '\0') 6552900Seric { 6563386Seric char *q; 6575366Seric extern char *arpadate(); 6583386Seric 6592900Seric /* we have found a date */ 6603386Seric q = xalloc(25); 66123103Seric (void) strncpy(q, p, 25); 6623386Seric q[24] = '\0'; 6635366Seric q = arpadate(q); 66455012Seric define('a', newstr(q), e); 6652900Seric } 6662900Seric } 6674321Seric 66856795Seric # endif /* NOTUNIX */ 669