unsigned long count_file = 0;
unsigned long count_forward = 0;
unsigned long count_program = 0;
char count_buf[FMT_ULONG];
void count_print()
{
substdio_puts(subfdoutsmall,"did ");
substdio_put(subfdoutsmall,count_buf,fmt_ulong(count_buf,count_file));
substdio_puts(subfdoutsmall,"+");
substdio_put(subfdoutsmall,count_buf,fmt_ulong(count_buf,count_forward));
substdio_puts(subfdoutsmall,"+");
substdio_put(subfdoutsmall,count_buf,fmt_ulong(count_buf,count_program));
substdio_puts(subfdoutsmall,"\n");
if (mailforward_qp)
{
substdio_puts(subfdoutsmall,"qp ");
substdio_put(subfdoutsmall,count_buf,fmt_ulong(count_buf,mailforward_qp));
substdio_puts(subfdoutsmall,"\n");
}
substdio_flush(subfdoutsmall);
}
void sayit(type,cmd,len)
char *type;
char *cmd;
int len;
{
substdio_puts(subfdoutsmall,type);
substdio_put(subfdoutsmall,cmd,len);
substdio_putsflush(subfdoutsmall,"\n");
}
void main(argc,argv)
int argc;
char **argv;
{
int opt;
int i;
int j;
int k;
int fd;
int numforward;
char **recips;
datetime_sec starttime;
int flagforwardonly;
char *x;
umask(077);//将系统umask值设为077&0777的值。open函数的真正权限为mode&-umask
sig_pipeignore();//忽略信号
//将environ空间扩大(加10个字符串位置)错误返回0
if (!env_init()) temp_nomem();
//-n Instead of reading and delivering the message, print a description of
// the delivery instructions. (man page)
//-N 是默认值
flagdoit = 1;
while ((opt = getopt(argc,argv,"nN")) != opteof)
switch(opt)
{
case 'n':; flagdoit = 0; break;
case 'N':; flagdoit = 1; break;
default:;
usage();
}
argc -= optind;
argv += optind;
//将参数拷到相应的变量中。
if (!(user = *argv++)) usage();
if (!(homedir = *argv++)) usage();
if (!(local = *argv++)) usage();
if (!(dash = *argv++)) usage();
if (!(ext = *argv++)) usage();
if (!(host = *argv++)) usage();
if (!(sender = *argv++)) usage();
if (!(aliasempty = *argv++)) usage();
if (*argv) usage();
//目录是以'/'开头的
if (homedir[0] != '/') usage();
if (chdir(homedir) == -1)
strerr_die5x(111,"Unable to switch to ",homedir,":; ",error_str(errno),". (#4.3.0)");
checkhome();
//将"HOST"和host结合为"HOST="+host,加到environ后面。下同
if (!env_put2("HOST",host)) temp_nomem();//接收地址的域名部分
if (!env_put2("HOME",homedir)) temp_nomem();//用户的主目录
if (!env_put2("USER",user)) temp_nomem();//当前的用户
if (!env_put2("LOCAL",local)) temp_nomem();//接收地址的local部分
//将本地的地址扩展。如local为"dingwenbin",host为pact518.hit.edu.cn,则envrecip为"dingwenbin@pact518.hit.edu.cn"
if (!stralloc_copys(&envrecip,local)) temp_nomem();