Esempio n. 1
0
/*
 * Split a headline into its useful components.
 * Copy the line into dynamic string space, then set
 * pointers into the copied line in the passed headline
 * structure.  Actually, it scans.
 */
void
parse(char line[], struct headline *hl, char pbuf[])
{
	char *cp, *sp;
	char word[LINESIZE];

	hl->l_from = NULL;
	hl->l_tty = NULL;
	hl->l_date = NULL;
	cp = line;
	sp = pbuf;
	/*
	 * Skip over "From" first.
	 */
	cp = nextword(cp, word);
	/*
	 * Check for missing return-path.
	 */
	if (isdate(cp)) {
		hl->l_date = copyin(cp, &sp);
		return;
	}
	cp = nextword(cp, word);
	if (strlen(word) > 0)
		hl->l_from = copyin(word, &sp);
	if (cp != NULL && strncmp(cp, "tty", 3) == 0) {
		cp = nextword(cp, word);
		hl->l_tty = copyin(word, &sp);
	}
	if (cp != NULL)
		hl->l_date = copyin(cp, &sp);
}
Esempio n. 2
0
/*
 * See if the passed line buffer is a mail header.
 * Return true if yes.  Note the extreme pains to
 * accommodate all funny formats.
 */
int
ishead(char *linebuf)
{
	char *cp;
	struct headline hl;
	char parbuf[BUFSIZ];

	cp = linebuf;
	if (*cp++ != 'F' || *cp++ != 'r' || *cp++ != 'o' || *cp++ != 'm' ||
	    *cp++ != ' ')
		return(0);
	parse(linebuf, &hl, parbuf);
	if (hl.l_from == NULL || hl.l_date == NULL) {
		fail(linebuf, "No from or date field");
		return(0);
	}
        /* be very tolerant about the date */
#ifndef DEBIAN
	if (!isdate(hl.l_date)) {
		fail(linebuf, "Date field not legal date");
		return(0);
	}
#endif
	/*
	 * I guess we got it!
	 */
	return(1);
}
Esempio n. 3
0
/*
 * See if the passed line buffer is a mail header.
 * Return true if yes.  Note the extreme pains to
 * accommodate all funny formats.
 */
int
ishead(char linebuf[])
{
	struct headline hl;
	char parbuf[BUFSIZ];

	if (strncmp(linebuf, "From ", 5) != 0)
		return (0);
	parse(linebuf, &hl, parbuf);
	if (hl.l_date == NULL) {
		fail(linebuf, "No date field");
		return (0);
	}
	if (!isdate(hl.l_date)) {
		fail(linebuf, "Date field not legal date");
		return (0);
	}
	/*
	 * I guess we got it!
	 */
	return (1);
}