home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Fish 2
/
goldfish_vol2_cd1.bin
/
files
/
comm
/
mail
/
smail
/
src
/
rcs
/
headers.c,v
< prev
next >
Wrap
Text File
|
1993-12-21
|
28KB
|
1,397 lines
head 1.14;
access;
symbols
C_1:1.14;
locks; strict;
comment @ * @;
1.14
date 93.11.13.23.13.02; author Aussem; state Exp;
branches;
next 1.13;
1.13
date 93.11.06.16.02.16; author Aussem; state Exp;
branches;
next 1.12;
1.12
date 93.11.05.22.51.53; author Aussem; state Exp;
branches;
next 1.11;
1.11
date 93.11.05.22.22.13; author Aussem; state Exp;
branches;
next 1.10;
1.10
date 93.10.28.23.14.01; author Aussem; state Exp;
branches;
next 1.9;
1.9
date 93.10.28.22.05.26; author Aussem; state Exp;
branches;
next 1.8;
1.8
date 93.10.22.00.27.53; author Aussem; state Exp;
branches;
next 1.7;
1.7
date 93.10.17.18.44.20; author Aussem; state Exp;
branches;
next 1.6;
1.6
date 93.10.10.21.05.46; author Aussem; state Exp;
branches;
next 1.5;
1.5
date 93.10.10.19.32.34; author Aussem; state Exp;
branches;
next 1.4;
1.4
date 93.09.18.20.23.05; author Aussem; state Exp;
branches;
next 1.3;
1.3
date 93.09.18.16.47.47; author Aussem; state Exp;
branches;
next 1.2;
1.2
date 93.09.11.01.42.43; author Aussem; state Exp;
branches;
next 1.1;
1.1
date 93.09.08.16.27.13; author Aussem; state Exp;
branches;
next ;
desc
@analyse and setup the header
@
1.14
log
@MAXLINE inserted
@
text
@/*
* headers.c
*
* message spooing, header and address parsing and completion
* functions for smail/rmail
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: headers.c,v $
* Revision 1.13 1993/11/06 16:02:16 Aussem
* smail does not look in rmail mode in the mailheader
*
* Revision 1.12 1993/11/05 22:51:53 Aussem
* Return-Receipt-To: recognition now works again
*
* Revision 1.11 1993/11/05 22:22:13 Aussem
* Return-Receipt-To: recognition now works
*
* Revision 1.10 1993/10/28 23:14:01 Aussem
* space on right of return-receipt headers forgotten
*
* Revision 1.9 1993/10/28 22:05:26 Aussem
* comments from return-receipt removed
*
* Revision 1.8 1993/10/22 00:27:53 Aussem
* user%site%site.do.main@@sub.do.main
* and
* sub.do.main!site.do.main%site%user
* addresses are now supported
*
* Revision 1.7 1993/10/17 18:44:20 Aussem
* -f argument is now really used
* smail does not stop on a single dot on a line anymore
*
* Revision 1.6 1993/10/10 21:05:46 Aussem
* continuation lines and whites spaces are now handled in the
* right way
*
* Revision 1.5 1993/10/10 19:32:34 Aussem
* Bcc: lines are now supported
*
* Revision 1.4 1993/09/18 20:23:05 Aussem
* the cc line can now be parsed from cmdline and from file
*
* Revision 1.3 1993/09/18 16:47:47 Aussem
* insert GNU license text in the header
*
* Revision 1.2 1993/09/11 01:42:43 Aussem
* To: lines will bei insert from mailbody AND cmdline
* EnforcerHits while generation the Cc: line removed
*
* Revision 1.1 1993/09/08 16:27:13 Aussem
* Initial revision
*
*
*/
static char *rcsid="$Id: headers.c,v 1.13 1993/11/06 16:02:16 Aussem Exp Aussem $";
# include <stdio.h>
# include <stdlib.h>
# include <sys/types.h>
# include <time.h>
# include <ctype.h>
# include "defs.h"
extern enum edebug debug; /* how verbose we are */
extern char hostname[]; /* */
extern char hostdomain[]; /* */
extern char *spoolfile; /* file name of spooled message */
extern FILE *spoolfp; /* file ptr to spooled message */
extern int spoolmaster; /* set if creator of spoolfile */
extern time_t now; /* time */
extern char nows[], arpanows[]; /* time strings */
extern struct tm *gmt, *loc; /* time structs */
extern char *from_addr; /* replacement fromaddr with -f */
extern char *subject; /* replacement subject with -s */
extern char *realname;
extern int cc_index;
extern int bcc_index;
extern int receipt;
extern FILE *mystdin;
extern int asrmail;
char return_receipt[SMLBUF]="";
static char toline[SMLBUF];
static char fromline[SMLBUF];
static char dateline[SMLBUF];
static char midline[SMLBUF];
static char subjectline[SMLBUF];
static char ccline[SMLBUF]="";
static char *ieof = "NOTNULL";
struct reqheaders {
char *name;
char *field;
char have;
};
static struct reqheaders reqtab[] = {
"Message-Id:" , midline , 'N' ,
"Date:" , dateline , 'N' ,
"From:" , fromline , 'N' ,
"To:" , toline , 'N' ,
"Cc:" , NULL , 'N' ,
"Bcc:" , NULL , 'N' ,
"Subject:" , subjectline , 'N' ,
NULL , NULL , 'N'
};
/*
**
** parse(): parse <address> into <domain, user, form>.
**
** input form
** ----- ----
** user LOCAL
** domain!user DOMAIN
** user@@domain DOMAIN
** @@domain,address LOCAL (just for sendmail)
** host!address UUCP
**
*/
enum eform
parse(address, domain, user)
char *address; /* input address */
char *domain; /* output domain */
char *user; /* output user */
{
int parts;
char *partv[MAXPATH]; /* to crack address */
/*
** If this is route address form @@domain_a,@@domain_b:user@@domain_c, ...
*/
if(*address == '@@')
#ifdef SENDMAIL
/*
** hand it to sendmail
*/
{
goto local;
}
#else
/*
** no sendmail, convert it into a bang path: domain_a!domain_b!domain_c!user
*/
{
char buf[SMLBUF], *p;
char t_dom[SMLBUF], t_user[SMLBUF];
(void) strcpy(buf, address+1); /* elide leading '@@' */
for(p=buf; *p != '\0' ; p++) { /* search for ',' or ':' */
if(*p == ':') { /* reached end of route */
break;
}
if(*p == ',') { /* elide ','s */
(void) strcpy(p, p+1);
}
if(*p == '@@') { /* convert '@@' to '!' */
*p = '!';
}
}
if(*p != ':') { /* bad syntax - punt */
goto local;
}
*p = '\0';
if(parse(p+1, t_dom, t_user) != LOCAL) {
(void) strcat(buf, "!");
(void) strcat(buf, t_dom);
}
(void) strcat(buf, "!");
(void) strcat(buf, t_user);
/* munge the address (yuk)
** it's OK to copy into 'address', because the machinations
** above don't increase the string length of the address.
*/
(void) strcpy(address, buf);
/* re-parse the address */
return(parse(address, domain, user));
}
#endif
/*
** user%site%site.do.main@@sub.do.main
** -> sub.do.main!site.do.main!site!user
**
** sub.do.main!site.do.main%site%user
** -> sub.do.main!site.do.main!site!user
*/
if(strchr(address,'%'))
{
register int i;
char *p;
parts = ssplit(address, '@@', partv);
if(parts>1)
{
strcpy(domain, partv[1]);
strncpy(user, partv[0], partv[1]-partv[0]-1);
user[partv[1]-partv[0]-1] = '\0';
strcpy(address,domain);
parts = ssplit(user, '%', partv);
for(i=0;i<parts;i++)
{
p=strchr(partv[parts-i-1],'%');
if(p) *p='\0';
strcat(address,"!");
strcat(address,partv[parts-i-1]);
}
}
else
{
for(p=address;*p!='\0';p++)
if(*p=='%')*p='!';
}
}
/*
** Try splitting at @@. If it works, this is user@@domain, form DOMAIN.
** Prefer the righthand @@ in a@@b@@c.
*/
if ((parts = ssplit(address, '@@', partv)) >= 2) {
(void) strcpy(domain, partv[parts-1]);
(void) strncpy(user, partv[0], partv[parts-1]-partv[0]-1);
user[partv[parts-1]-partv[0]-1] = '\0';
return (DOMAIN);
}
/*
** Try splitting at !. If it works, see if the piece before the ! has
** a . in it (domain!user, form DOMAIN) or not (host!user, form UUCP).
*/
if (ssplit(address, '!', partv) > 1) {
(void) strcpy(user, partv[1]);
(void) strncpy(domain, partv[0], partv[1]-partv[0]-1);
domain[partv[1]-partv[0]-1] = '\0';
if((parts = ssplit(domain, '.', partv)) < 2) {
return(UUCP);
}
if(partv[parts-1][0] == '\0') {
partv[parts-1][-1] = '\0'; /* strip trailing . */
}
return (DOMAIN);
}
/*
** Done trying. This must be just a user name, form LOCAL.
*/
local:
(void) strcpy(user, address);
(void) strcpy(domain, "");
return(LOCAL); /* user */
}
build(domain, user, form, result)
char *domain;
char *user;
enum eform form;
char *result;
{
switch((int) form) {
case LOCAL:
(void) sprintf(result, "%s", user);
break;
case UUCP:
(void) sprintf(result, "%s!%s", domain, user);
break;
case DOMAIN:
(void) sprintf(result, "%s@@%s", user, domain);
break;
}
}
/*
** ssplit(): split a line into array pointers.
**
** Each pointer wordv[i] points to the first character after the i'th
** occurence of c in buf. Note that each wordv[i] includes wordv[i+1].
**
*/
ssplit(buf, c, ptr)
register char *buf; /* line to split up */
char c; /* character to split on */
char **ptr; /* the resultant vector */
{
int count = 0;
int wasword = 0;
for(; *buf; buf++) {
if (!wasword) {
count++;
*ptr++ = buf;
}
wasword = (c != *buf);
}
if (!wasword) {
count++;
*ptr++ = buf;
}
*ptr = NULL;
return(count);
}
/*
** Determine whether an address is a local address
*/
islocal(addr, domain, user)
char *addr, *domain, *user;
{
enum eform form;
extern char hostuucp[];
/*
** parse the address
*/
form = parse(addr, domain, user);
if((form == LOCAL) /* user */
||(strcmpic(domain, hostdomain) == 0) /* user@@hostdomain */
||(strcmpic(domain, hostname) == 0) /* user@@hostname */
#ifdef DOMGATE
||(strcmpic(domain, &MYDOM[0]) == 0) /* user@@MYDOM w/ dot */
||(strcmpic(domain, &MYDOM[1]) == 0) /* user@@MYDOM no dot */
#endif
||(strcmpic(domain, hostuucp) == 0)) {/* user@@hostuucp */
return(1);
}
return(0);
}
/*
*
*/
void
checkheader(char *buf)
{
const char receipt[]="Return-Receipt-To:";
const size_t receipt_len=strlen(receipt);
if(strncmpic(buf,(char *)receipt,receipt_len)==0)
{
char *r=buf+receipt_len;
for(;*r==' ';r++);
strcpy(return_receipt,&r[0]);
r=strchr(return_receipt,' ');
if(r)
*r='\0';
r=strchr(return_receipt,'\n');
if(r)
*r='\0';
strip_comments(return_receipt);
}
}
/*
** spool - message spooling module
**
** (1) get dates for headers, etc.
** (2) if the message is on the standard input (no '-f')
** (a) create a temp file for spooling the message.
** (b) collapse the From_ headers into a path.
** (c) if the mail originated locally, then
** (i) establish default headers
** (ii) scan the message headers for required header fields
** (iii) add any required message headers that are absent
** (d) copy rest of the message to the spool file
** (e) close the spool file
** (3) open the spool file for reading
*/
void
spool(argc, argv)
int argc;
char **argv;
{
static char *tmpf = "T:"; /* temp file name */
char buf[SMLBUF];
static char splbuf[SMLBUF];
char from[SMLBUF], domain[SMLBUF], user[SMLBUF];
int flag=0;
/*
** if the mail has already been spooled by
** a previous invocation of smail don't respool.
** check the file name to prevent things like
** rmail -f /etc/passwd badguy@@dreadfuldomain
*/
if((spoolfile != NULL)
&& (strnicmp(spoolfile, tmpf, strlen(tmpf)) != 0)) {
error(EX_TEMPFAIL, "spool: bad file name '%s'\n", spoolfile);
}
/*
** set dates in local, arpa, and gmt forms
*/
setdates();
/*
** If necessary, copy mystdin to a temp file.
*/
if(spoolfile == NULL) {
spoolfile = strcpy(splbuf, tmpnam(NULL));
if((spoolfp = fopen(spoolfile, "w")) == NULL) {
error(EX_CANTCREAT, "can't create %s.\n", spoolfile);
}
spoolmaster = 1;
/*
** rline reads the standard input,
** collapsing the From_ and >From_
** lines into a single uucp path.
** first non-from_ line is in buf[];
*/
rline(from, buf);
/*
** if we are not rmail (or started as rmail)
** if the mail originated here, we parse the header
** and add any required headers that are missing.
*/
if(!asrmail && (islocal(from, domain, user) || (from_addr != NULL))) {
/*
** initialize default headers
*/
def_headers(argc, argv, from);
/*
** Return-Receipt-To: check is done in scanheaders()
*/
flag=1;
/*
** buf has first, non-from_ line
*/
scanheaders(buf);
/*
** buf has first, non-header line,
*/
compheaders();
if(buf[0] != '\n') {
(void) fputs("\n", spoolfp);
}
}
/*
** now, copy the rest of the letter into the spool file
** terminate on either EOF or '^.$'
*/
while(ieof != NULL) {
/*
** !flag while we are in the header part
*/
if(!flag && buf[0]=='\n')
flag=1;
/*
** if we are in the header and we
** should reply to Return-Receipt-To:
** Whether smail really answers the header
** is decided in deliver.c
*/
if(receipt && !flag)
checkheader(buf);
(void) fputs(buf, spoolfp);
if((fgets(buf, SMLBUF, mystdin) == NULL)
/*
** Don't know whether this right
** || (buf[0] == '.' && buf[1] == '\n')
*/
)
{
ieof = NULL;
}
}
/*
** close the spool file, and the standard input.
*/
(void) fclose(spoolfp);
(void) fclose(mystdin); /* you don't see this too often! */
}
if((spoolfp = fopen(spoolfile, "r")) == NULL) {
error(EX_TEMPFAIL, "can't open %s.\n", spoolfile);
}
}
/*
**
** rline(): collapse From_ and >From_ lines.
**
** Same idea as the old rmail, but also turns user@@domain to domain!user.
**
*/
void
rline(from, retbuf)
char *from;
char *retbuf;
{
int parts; /* for cracking From_ lines ... */
char *partv[16]; /* ... apart using ssplit() */
char user[SMLBUF]; /* for rewriting user@@host */
char domain[SMLBUF]; /* " " " */
char addr[SMLBUF]; /* " " " */
enum eform form; /* " " " */
char *c;
int nhops, i;
char buf[SMLBUF], tmp[SMLBUF], *hop[128], *e, *b;
if(spoolmaster == 0) return;
buf[0] = from[0] = addr[0] = '\0';
/*
** Read each line until we hit EOF or a line not beginning with "From "
** or ">From " (called From_ lines), accumulating the new path in from
** and stuffing the actual sending user (the user name on the last From_
** line) in addr.
*/
for(;;) {
(void) strcpy(retbuf, buf);
if(ieof == NULL) {
break;
}
if((fgets(buf, sizeof(buf), mystdin) == NULL)
/*
** Don't stop at a line with only one dot
**|| (buf[0] == '.' && buf[1] == '\n')
*/
) {
ieof = NULL;
break;
}
if (strncmp("From ", buf, 5)
&& strncmp(">From ", buf, 6)) {
break;
}
/*
** Crack the line apart using ssplit.
*/
if(c = index(buf, '\n')) {
*c = '\0';
}
parts = ssplit(buf, ' ', partv);
/*
** Tack host! onto the from argument if "remote from host" is present.
*/
if((parts > 3)
&& (strncmp("remote from ", partv[parts-3], 12) == 0)) {
(void) strcat(from, partv[parts-1]);
(void) strcat(from, "!");
}
/*
** Stuff user name into addr, overwriting the user name from previous
** From_ lines, since only the last one counts. Then rewrite user@@host
** into host!user, since @@'s don't belong in the From_ argument.
*/
if(parts < 2) {
break;
} else {
char *x = partv[1];
char *q = index(x, ' ');
if(q != NULL) {
*q = '\0';
}
(void) strcpy(addr, x);
}
(void) parse(addr, domain, user);
if(*domain == '\0') {
form = LOCAL;
} else {
form = UUCP;
}
build(domain, user, form, addr);
}
/*
** Now tack the user name onto the from argument.
*/
(void) strcat(from, addr);
/*
** If we still have no from argument, we have junk headers, but we try
** to get the user's name using /etc/passwd.
*/
if (from[0] == '\0')
{
if(!from_addr)
{
char *login;
if ((login = getloginname()) == NULL)
strcpy(from, "nobody"); /* bad news */
else
strcpy(from, login);
}
else
strcpy(from,from_addr);
}
/* split the from line on '!'s */
nhops = ssplit(from, '!', hop);
for(i = 0; i < (nhops - 1); i++) {
b = hop[i];
if(*b == '\0') {
continue;
}
e = hop[i+1];
e-- ;
*e = '\0'; /* null terminate each path segment */
e++;
#ifdef HIDDENHOSTS
/*
** Strip hidden hosts: anything.hostname.MYDOM -> hostname.MYDOM
*/
for(p = b;(p = index(p, '.')) != NULL; p++) {
if(strcmpic(hostdomain, p+1) == 0) {
(void) strcpy(b, hostdomain);
break;
}
}
#endif
/*
** Strip useless MYDOM: hostname.MYDOM -> hostname
*/
if(strcmpic(hop[i], hostdomain) == 0) {
(void) strcpy(hop[i], hostname);
}
}
/*
** Now strip out any redundant information in the From_ line
** a!b!c!c!d => a!b!c!d
*/
for(i = 0; i < (nhops - 2); i++) {
b = hop[i];
e = hop[i+1];
if(strcmpic(b, e) == 0) {
*b = '\0';
}
}
/*
** Reconstruct the From_ line
*/
tmp[0] = '\0'; /* empty the tmp buffer */
for(i = 0; i < (nhops - 1); i++) {
if((hop[i][0] == '\0') /* deleted this hop */
||((tmp[0] == '\0') /* first hop == hostname */
&&(strcmpic(hop[i], hostname) == 0))) {
continue;
}
(void) strcat(tmp, hop[i]);
(void) strcat(tmp, "!");
}
(void) strcat(tmp, hop[i]);
(void) strcpy(from, tmp);
(void) strcpy(retbuf, buf);
(void) fprintf(spoolfp, "%s\n", from);
}
/*
*
*/
void
scanheaders(buf)
char *buf;
{
int inheader = 0;
while(ieof != NULL) {
if(buf[0] == '\n') {
break; /* end of headers */
}
/*
** header lines which begin with whitespace
** are continuation lines
*/
if((inheader == 0)
|| ((buf[0] != ' ' && buf[0] != '\t'))) {
/* not a continuation line
** check for header
*/
if(isheader(buf) == 0) {
/*
** not a header
*/
break;
}
inheader = 1;
haveheaders(buf);
/*
** if we should reply to Return-Receipt-To:
** grep the address line
** Whether smail answers the header
** is decided in deliver.c
*/
if(receipt) checkheader(buf);
}
/*
** ignore continuation lines and white spaces
** their will be handled in To:,Cc: nad Bcc: lines
**
*/
if(buf[0] == ' ' || buf[0] == '\t')
buf[0]='\0';
(void) fputs(buf, spoolfp);
if((fgets(buf, SMLBUF, mystdin) == NULL)
/*
** Don't stop at a line with only one dot
**|| (buf[0] == '.' && buf[1] == '\n')
*/
) {
ieof = NULL;
}
}
if(isheader(buf)) {
buf[0] = '\0';
}
}
/*
** complete headers - add any required headers that are not in the message
*/
void
compheaders()
{
struct reqheaders *i;
/*
** look at the table of required headers and
** add those that are missing to the spooled message.
*/
for(i = reqtab; i->name != NULL; i++) {
/* for the cc-line and bcc-line the field ptr is NULL */
if(i->have != 'Y' && i->field) {
(void) fprintf(spoolfp, "%s\n", i->field);
}
}
}
/*
** look at a string and determine
** whether or not it is a valid header.
*/
isheader(s)
char *s;
{
char *p;
/*
** header field names must terminate with a colon
** and may not be null.
*/
if(((p = index(s, ':')) == NULL) || (s == p)) {
return(0);
}
/*
** header field names must consist entirely of
** printable ascii characters.
*/
while(s != p) {
if(!isprint(*s))
return(0);
/* we have ansi! if((*s < '!') || (*s > '~')) return(0); */
s++;
}
/*
** we hit the ':', so the field may be a header
*/
return(1);
}
/*
** compare the header field to those in the required header table.
** if it matches, then mark the required header as being present
** in the message.
*/
haveheaders(s)
char *s;
{
struct reqheaders *i;
for(i = reqtab; i->name != NULL; i++) {
if(strncmpic(i->name, s, strlen(i->name)) == 0) {
if((strncmpic("Subject:", s, 8) == 0)
&& (subject != NULL)) {
(void) sprintf(s, "Subject: %s\n", subject);
}
if((strncmpic("From:", s, 5) == 0)
&& (from_addr != NULL)) {
(void) sprintf(s, "From: %s\n", from_addr);
}
/* To: Cc: and Bcc: will be handled differently */
if((strncmpic("To:", s, 3) == 0) ||
(strncmpic("Bcc:", s, 4) == 0) ||
(strncmpic("Cc:", s, 3) == 0))
*s='\0';
else
i->have = 'Y';
break;
}
}
}
/*
** create default headers for the message.
*/
def_headers(argc, argv, from)
int argc;
char **argv;
char *from;
{
def_to(argc, argv); /* default To: */
def_date(); /* default Date: */
def_from(from); /* default From: */
def_mid(); /* default Message-Id: */
def_subject();
}
/*
** default Date: in arpa format
*/
def_date()
{
(void) strcpy(dateline, "Date: ");
(void) strcat(dateline, arpanows);
}
/*
** default Message-Id
** Message-Id: <yymmddhhmm.AAppppp@@hostdomain>
**
** yy year
** mm month
** dd day
** hh hour
** mm minute
** ppppp process-id
**
** date and time are set by GMT
*/
def_mid()
{
(void) sprintf(midline, "Message-Id: <%02d%02d%02d%02d%02d.AA%05d@@%s>",
gmt->tm_year,
gmt->tm_mon+1,
gmt->tm_mday,
gmt->tm_hour,
gmt->tm_min,
getpid(),
hostdomain);
}
/*
** default Subject: from cmd-line
**
*/
def_subject()
{
if (subject != NULL) {
(void) sprintf(subjectline, "Subject: %s", subject);
return;
}
}
/*
** default From:
** From: user@@hostdomain (Full Name)
*/
def_from(from)
char *from;
{
char name[SMLBUF];
name[0] = '\0';
if(!realname)
realname=getrealname(from_addr?from_addr:from);
if(realname)
strcpy(name,realname);
if (from_addr != NULL) {
if(name[0] != '\0') {
(void) sprintf(fromline,
"From: %s@@%s (%s)", from_addr, hostdomain, name);
} else {
(void) sprintf(fromline,
"From: %s@@%s", from_addr, hostdomain);
}
return;
}
if(name[0] != '\0') {
(void) sprintf(fromline,
"From: %s@@%s (%s)", from, hostdomain, name);
} else {
(void) sprintf(fromline,
"From: %s@@%s", from, hostdomain);
}
}
/*
** default To:
** To: recip1, recip2, ...
**
** lines longer than MAXLINE chars are continued on another line.
*/
def_to(argc, argv)
int argc;
char **argv;
{
int i, n;
char *bol;
/* if we have bcc-lines in argv donnot
print them in the outgoing mail */
if(bcc_index!=-1)
argc=bcc_index;
bol = toline;
(void) strcpy(bol, "To: ");
for(n = i = 0; i < argc; i++) {
/* insert the Cc: line */
if(i==cc_index)
{
bol=rindex(toline,',');
*bol = '\n';
*(bol+1) = '\0';
n = 0;
strcat(bol,"Cc: ");
}
(void) strcat(bol, argv[i]);
if((index(argv[i], '!') == NULL)
&& (index(argv[i], '@@') == NULL)) {
(void) strcat(bol, "@@");
(void) strcat(bol, hostdomain);
}
if(i+1 < argc) {
n = strlen(bol);
/* if the line is greater than MAXLINE columns */
if(n > MAXLINE) {
(void) strcat(bol, ",\n\t");
bol = bol + strlen(bol);
*bol = '\0';
n = 8;
} else {
(void) strcat(bol, ", ");
}
}
}
}
@
1.13
log
@smail does not look in rmail mode in the mailheader
@
text
@d22 3
d70 1
a70 1
static char *rcsid="$Id: headers.c,v 1.12 1993/11/05 22:51:53 Aussem Exp Aussem $";
d950 1
a950 1
** lines longer than 50 chars are continued on another line.
d985 2
a986 2
/* if the line is greater than 50 columns */
if(n > 50) {
@
1.12
log
@Return-Receipt-To: recognition now works again
@
text
@d22 3
d67 1
a67 1
static char *rcsid="$Id: headers.c,v 1.11 1993/11/05 22:22:13 Aussem Exp Aussem $";
d92 1
d447 1
d452 1
a452 1
if(islocal(from, domain, user) || (from_addr != NULL)) {
d458 4
d483 1
a483 1
** flag == 0 while we read the header
d488 1
a488 1
** if the header is active and we
d490 1
a490 1
** Whether smail answers the header
d730 7
@
1.11
log
@Return-Receipt-To: recognition now works
@
text
@d22 3
d64 1
a64 1
static char *rcsid="$Id: headers.c,v 1.10 1993/10/28 23:14:01 Aussem Exp Aussem $";
d401 1
d473 13
a485 1
if(receipt) checkheader(buf);
@
1.10
log
@space on right of return-receipt headers forgotten
@
text
@d22 3
d61 1
a61 1
static char *rcsid="$Id: headers.c,v 1.9 1993/10/28 22:05:26 Aussem Exp Aussem $";
d349 25
d469 1
d499 1
a499 1
** Same idea as the old rmail, but also turns user@@domain to domain!user.
a677 25
checkheader(char *buf)
{
const char receipt[]="Return-Receipt-To: ";
const size_t receipt_len=strlen(receipt);
if(strncmpic(buf,(char *)receipt,receipt_len)==0)
{
char *r=buf+receipt_len;
for(;*r==' ';r++);
strcpy(return_receipt,&r[0]);
r=strchr(return_receipt,' ');
if(r)
*r='\0';
r=strchr(return_receipt,'\n');
if(r)
*r='\0';
strip_comments(return_receipt);
}
}
/*
*
*/
void
a704 1
if(receipt) checkheader(buf);
@
1.9
log
@comments from return-receipt removed
@
text
@d22 3
d58 1
a58 1
static char *rcsid="$Id: headers.c,v 1.8 1993/10/22 00:27:53 Aussem Exp Aussem $";
d657 2
d660 3
@
1.8
log
@user%site%site.do.main@@sub.do.main
and
sub.do.main!site.do.main%site%user
addresses are now supported
@
text
@d22 6
d55 1
a55 1
static char *rcsid="$Id: headers.c,v 1.7 1993/10/17 18:44:20 Aussem Exp Aussem $";
d658 1
@
1.7
log
@-f argument is now really used
smail does not stop on a single dot on a line anymore
@
text
@d22 4
d49 1
a49 1
static char *rcsid="$Id: headers.c,v 1.6 1993/10/10 21:05:46 Aussem Exp Aussem $";
d129 1
d183 36
d228 2
a229 1
}
@
1.6
log
@continuation lines and whites spaces are now handled in the
right way
@
text
@d22 4
d45 1
a45 1
static char *rcsid="$Id: headers.c,v 1.5 1993/10/10 19:32:34 Aussem Exp Aussem $";
d69 1
d338 1
a338 1
** If necessary, copy stdin to a temp file.
d391 7
a397 2
if((fgets(buf, SMLBUF, stdin) == NULL)
|| (buf[0] == '.' && buf[1] == '\n')) {
d407 1
a407 1
(void) fclose(stdin); /* you don't see this too often! */
d444 1
a444 1
** and stuffing the actual sending user (the user name on the last From_
d452 6
a457 2
if((fgets(buf, sizeof(buf), stdin) == NULL)
|| (buf[0] == '.' && buf[1] == '\n')) {
d461 1
a461 1
if (strncmp("From ", buf, 5)
d482 2
a483 2
** Stuff user name into addr, overwriting the user name from previous
** From_ lines, since only the last one counts. Then rewrite user@@host
d515 13
a527 6
if (from[0] == '\0') {
char *login;
if ((login = getloginname()) == NULL) {
(void) strcpy(from, "nobody"); /* bad news */
} else {
(void) strcpy(from, login);
a528 2
}
d656 6
a661 2
if((fgets(buf, SMLBUF, stdin) == NULL)
|| (buf[0] == '.' && buf[1] == '\n')) {
@
1.5
log
@Bcc: lines are now supported
@
text
@d22 3
d41 1
a41 1
static char *rcsid="$Id: headers.c,v 1.4 1993/09/18 20:23:05 Aussem Exp Aussem $";
d627 9
@
1.4
log
@the cc line can now be parsed from cmdline and from file
@
text
@d22 3
d38 1
a38 1
static char *rcsid="$Id: headers.c,v 1.3 1993/09/18 16:47:47 Aussem Exp Aussem $";
d60 1
d85 1
d649 1
a649 1
/* for the cc-line the field ptr is NULL */
d678 1
a678 1
if((*s < '!') || (*s > '~')) {
d680 1
a680 1
}
d709 1
a709 1
/* To: will be handled differently */
d711 1
d828 5
@
1.3
log
@insert GNU license text in the header
@
text
@d22 3
d35 1
a35 1
static char *rcsid="$Id: headers.c,v 1.2 1993/09/11 01:42:43 Aussem Exp Aussem $";
d66 1
d80 1
d644 2
a645 1
if(i->have != 'Y') {
d705 2
a706 1
if(strncmpic("To:", s, 3) == 0)
@
1.2
log
@To: lines will bei insert from mailbody AND cmdline
EnforcerHits while generation the Cc: line removed
@
text
@d7 14
d22 4
d32 1
a32 1
static char *rcsid="$Id: headers.c,v 1.1 1993/09/08 16:27:13 Aussem Exp Aussem $";
@
1.1
log
@Initial revision
@
text
@d7 3
a9 1
* $Log$
d11 1
d14 1
a14 1
static char *rcsid="$Id$";
d680 5
a684 1
i->have = 'Y';
d801 1
d804 3
a806 4
bol = bol + strlen(bol)-1;
bol=rindex(bol,' ');
*(bol-1) = '\n';
*bol = '\0';
d819 1
@