xref: /illumos-gate/usr/src/cmd/mail/pickFrom.c (revision d48be21240dfd051b689384ce2b23479d757f2d8)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 #include "mail.h"
26 /*
27  * pickFrom (line) - scans line, ASSUMED TO BE of the form
28  *	[>]From <fromU> <date> [remote from <fromS>]
29  * and fills fromU and fromS global strings appropriately.
30  */
31 
32 void pickFrom (lineptr)
33 register char *lineptr;
34 {
35 	register char *p;
36 	static char rf[] = "remote from ";
37 	int rfl;
38 
39 	if (*lineptr == '>')
40 		lineptr++;
41 	lineptr += 5;
42 	for (p = fromU; *lineptr; lineptr++) {
43 		if (isspace (*lineptr))
44 			break;
45 		*p++ = *lineptr;
46 	}
47 	*p = '\0';
48 	rfl = strlen (rf);
49 	while (*lineptr && strncmp (lineptr, rf, rfl))
50 		lineptr++;
51 	if (*lineptr == '\0') {
52 		fromS[0] = 0;
53 	} else {
54 		lineptr += rfl;
55 		for (p = fromS; *lineptr; lineptr++) {
56 			if (isspace (*lineptr))
57 				break;
58 			*p++ = *lineptr;
59 		}
60 		*p = '\0';
61 	}
62 }
63