qmail-local代码分析[4]

[入库:2005年9月21日] [更新:2007年3月24日]

本文简介:

unsigned long mailforward_qp = 0;
//转发邮件,地址在recips中
void mailforward(recips)
char **recips;
{//struct qmail {
 // int flagerr;
 // unsigned long pid;
 // int fdm;
 // int fde;
 // substdio ss;
 // char buf[1024];
 // } ;
 struct qmail qqt;
 char *qqx;
 substdio ss;
 int match;

 if (seek_begin(0) == -1) temp_rewind();
 substdio_fdbuf(&ss,read,0,buf,sizeof(buf));

 if (qmail_open(&qqt) == -1) temp_fork();
 mailforward_qp = qmail_qp(&qqt);
 qmail_put(&qqt,dtline.s,dtline.len);
 do
  {
   if (getln(&ss,&messline,&match,'\n') != 0) { qmail_fail(&qqt); break; }
   qmail_put(&qqt,messline.s,messline.len);
  }
 while (match);
 qmail_from(&qqt,ueo.s);
 while (*recips) qmail_to(&qqt,*recips++);
 qqx = qmail_close(&qqt);
 if (!*qqx) return;
 strerr_die3x(*qqx == 'D' ? 100 :; 111,"Unable to forward message:; ",qqx + 1,".");
}

void bouncexf()
{
 int match;
 substdio ss;
//#define seek_begin(fd) (seek_set((fd),(seek_pos) 0))
//typedef unsigned long seek_pos
//将文件0的指针移到开始位置。
 if (seek_begin(0) == -1) temp_rewind();
//给ss附值,ss->x=buf,s->fd = 0;s->op = read;s->p = 0(字节数);s->n = sizeof(buf)(还有的空间) 
 substdio_fdbuf(&ss,read,0,buf,sizeof(buf));
 for (;;)
  {
   if (getln(&ss,&messline,&match,'\n') != 0) temp_read();
   if (!match) break;
//判断文件是否结束
   if (messline.len <= 1)
     break;
   if (messline.len == dtline.len)
     if (!str_diffn(messline.s,dtline.s,dtline.len))
       strerr_die1x(100,"This message is looping:; it already has my Delivered-To line. (#5.4.6)");
  }
}

void checkhome()
{
 struct stat st;

 if (stat(".",&st) == -1)
   strerr_die3x(111,"Unable to stat home directory:; ",error_str(errno),". (#4.3.0)");
 if (st.st_mode & auto_patrn)
   strerr_die1x(111,"Uh-oh:; home directory is writable. (#4.7.0)");
 if (st.st_mode & 01000)
   if (flagdoit)
     strerr_die1x(111,"Home directory is sticky:; user is editing his .qmail file. (#4.2.1)");
   else
     strerr_warn1("Warning:; home directory is sticky.",0);
}
//得到文件".qmail"+dash+safeext+dashowner的权限,正确返回0,错误为-1
int qmeox(dashowner)
char *dashowner;
{
 struct stat st;

 if (!stralloc_copys(&qme,".qmail")) temp_nomem();
 if (!stralloc_cats(&qme,dash)) temp_nomem();
 if (!stralloc_cat(&qme,&safeext)) temp_nomem();
 if (!stralloc_cats(&qme,dashowner)) temp_nomem();
 if (!stralloc_0(&qme)) temp_nomem();
 if (stat(qme.s,&st) == -1)
  {
   if (error_temp(errno)) temp_qmail(qme.s);

本文关键:qmail-local代码分析
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top