回文章列表
作者hpo14.bbs@ntust.org (陌生) 看板: itoc
標題[修正] 轉錄文章至信箱: 原文章加註記錄
時間資工清流站 (2007/05/10 Thu 03:58:15)
參考這篇寫的 [修正] 轉錄文章: 原文章加註記錄 by guessi

小弟認為,除轉錄文章到看板應該在原文加註紀錄以外

若有使用者將文章轉回自己或是他人信箱的話,也應該在原文加註紀錄

目前自己使用是沒有問題。

src/maple: post_forward(xo)

int
post_forward(xo)
  XO *xo;
{
  ACCT muser;
-  //int pos;
+  int result;
  HDR *hdr;

-  pos = xo->pos;
-  hdr = (HDR *) xo_pool + (pos - xo->top);       // 上面的 pos 好像沒必要
+  hdr = (HDR *) xo_pool + (xo->pos - xo->top);

   ……

   if (acct_get("轉達信件給:", &muser) > 0)
   {
     strcpy(quote_user, hdr->owner);
     strcpy(quote_nick, hdr->nick);
     hdr_fpath(quote_file, xo->dir, hdr);
     sprintf(ve_title, "%.64s (fwd)", hdr->title);
     move(1, 0);
     clrtobot();
     prints("轉達給: %s (%s)\n標  題: %s\n",
            muser.userid, muser.username, ve_title);

-   mail_send(muser.userid);
+   result = mail_send(muser.userid);

+    if (result >= 0)
+    {
+      char fpath[64];
+      FILE *fp;
+
+      hdr_fpath(fpath, xo->dir, hdr);

       //這邊小弟不確定能否直接使用上面標黃色的變數當作 FILE的檔案路徑
       //因為 hdr_path 抓的都一樣
       //如果可以,則下面的 fpath 請改成 quote_file
+
+      if (fp = fopen(fpath, "a"))
+      {
+        char msg[32];
+
+        time_t now;
+        struct tm *ptime;
+
+        time(&now);
+        ptime = localtime(&now);
+
+        sprintf(msg, "轉錄至 %s 信箱", (muser.userid == cuser.userid) ?
+                       muser.userid : "私人");
+
+        fprintf(fp, "\033[32m# \033[1m%s\033[;32m %-*s\033[m %02d/%02d %02d:%02d\033[m\n",
+        cuser.userid, 62 - strlen(cuser.userid), msg,
+        ptime->tm_mon + 1, ptime->tm_mday, ptime->tm_hour, ptime->tm_min);
+        /* 格式自訂 盡量與推文類似 */
+
+        fclose(fp);
+
+      } /* 轉錄原文註記錄 070510 hpo14 */
+    }

    *quote_file = '\0';
  }
  return XO_HEAD;
}

--
>> 台灣科技大學 資工清流站 # ntust.org #
>> Author: 61.59.78.243
文章選讀←離開[主題上]主題下(k)上篇(j)下篇S/a搜尋 G串列 TAB精華 ↑↓捲 Pg/Space翻