发信人: Altmayer (alt), 信区: bbsdev
标 题: mail 增加了合集功能
发信站: 失落的神殿 (2002年04月11日04:41:16 星期四), 站内信件
读 mail 时, 按 b ,同主题合集. 做的不是很细致, 以后慢慢完善!
1. 在 mail.c 里增加 'b' 对应函数 Mail_combine()
2. 在 read.c 增加函数 Mail_combine()
int Mail_combine (int ent, struct fileheader *fileinfo, char *direct)
{
int result = 0;
char buf[STRLEN];
saveline(t_lines - 1, 0);
move(t_lines - 1, 0);
if (askyn("确定要执行相同主题合集吗?", YEA, NA) == 0){
saveline(t_lines - 1, 1);
return DONOTHING;
}
strcpy(keyword, fileinfo->title);
sprintf(buf, "tmp/%s.combine", currentuser.userid);
if(dashf(buf)) unlink(buf);
move(t_lines - 1, 0);
sprintf(buf, "是否从此主题第一篇开始合集 (Y)第一篇 (N)目前这一篇");
if(askyn(buf, YEA, NA) == YEA) {
result = locate_the_post(fileinfo, keyword, 5, 0, 0);
} else {
memcpy(&SR_fptr, fileinfo, sizeof(SR_fptr));
}
if( result == -1 ){
saveline(t_lines - 1, 1);
return DONOTHING;
}
while(1){
FILE *fp;
char temp2[1024];
char buf[STRLEN];
sprintf(buf, "tmp/%s.combine", currentuser.userid);
fp=fopen(buf,"at");
fprintf(fp,"^[[1;35m☆─────────────────────────
─────────────☆^[[m\n");
{
FILE *fp1;
char *s_ptr,*e_ptr;
int blankline=0;
char filename[80];
struct fileheader *fileinfo;
fileinfo = &SR_fptr;
sprintf(filename, "mail/%c/%s/%s", toupper(currentuser.userid[0]), cur
rentuser.userid, fileinfo->filename);
fp1=fopen(filename,"rt");
if (fgets(temp2, 256, fp1)!=NULL) {
if(!strstr(temp2,"寄信人")) fputs(temp2,fp);
else{
e_ptr=strchr(temp2,'\n');
if (e_ptr!=NULL) *(e_ptr)='\0';
s_ptr=&temp2[7];
fprintf(fp, " ^[[0;1;33m%s ^[[m",s_ptr);
fgets(temp2, 256, fp1);
if (fgets(temp2, 256, fp1)!=NULL) {
e_ptr=strchr(temp2,')');
if (e_ptr!=NULL) {
*(e_ptr)='\0';
s_ptr=strchr(temp2,'(');
if (s_ptr==NULL) s_ptr=temp2;
else s_ptr++;
fprintf(fp, "于 ^[[1;34m%s^[[m 提到:\n",s_ptr);
}
}
}
}
fgets(temp2, 256, fp1);
while (!feof(fp1)) {
fgets(temp2, 256, fp1);
if ((unsigned)*temp2<'\x1b'){
if (blankline) continue; else blankline=1;
}
else blankline=0;
// if ((strstr(temp2, "【"))|| + (*temp2==':')) continue;
if (strncmp(temp2,"--",2)==0) break;
fputs(temp2, fp);
}
fclose(fp1);
}
fprintf(fp,"\n" );
fclose(fp);
result = locate_the_post(fileinfo, keyword,1,0,0);
if(result == -1) break;
}
if( !strncmp(keyword, "Re: ", 4)||!strncmp(keyword,"RE: ",4) )
sprintf(buf, "【合集】%s", keyword + 4);
else sprintf(buf, "【合集】%s", keyword);
strcpy(keyword, buf);
sprintf(buf, "tmp/%s.combine", currentuser.userid);
mail_file(buf,currentuser.userid,keyword);
unlink(buf);
return DIRCHANGED;
}
【 在 Altmayer (alt) 的大作中提到: 】
: for fb2k. 代码粗糙了点, 不过还很实用, 希望以后能多交流一下.
: 谢!
--