荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: jjk (UNIX+C+XML+?? 傻了?), 信区: InstallBBS
标  题: re: 我把刚做好的mail 合集贴出来吧(转寄)
发信站: 荔园晨风BBS站 (Wed Apr 17 10:22:40 2002), 转信

【 以下文字转载自 jjk 的信箱 】
【 原文由 jjksam@smth.org 所发表 】
发信人: commings.bbs@bbs.cqupt.edu.cn (死鱼一条), 信区: BBSMan_Dev
标  题: re: 我把刚做好的mail 合集贴出来吧
发信站: 幽幽黄桷兰BBS (Tue Apr 16 07:13:19 2002)
转信站: SMTH!thunews.dhs.org!news.happynet.org!CquptBBS


【 在 Altmayer.bbs@lostemple.dhs.org (alt) 的大作中提到: 】
发信人: 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;
:               ~~~~~~~~~~~~~~我觉的最好在后面多加几个空格,要是那是个破折号呢
:               strncmp(temp2,"--                    ",22)==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. 代码粗糙了点, 不过还很实用, 希望以后能多交流一下.
: 谢!
--
※ 来源:·失落的神殿 lostemple.dhs.org·[FROM: 失落的神殿]


--
勇者无畏,强者无敌!
突破极限,贴近真理。
※ 来源:·幽幽黄桷兰 bbs.cqupt.edu.cn·[FROM: thinking]
--
※ 转载:·荔园晨风BBS站 bbs.szu.edu.cn·[FROM: 192.168.0.148]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店