回精華區
作者itoc.bbs@processor.tfcis.org (核心動力) 看板: plan
標題Re: 請問修改文章/信件檔頭
時間動力核心 (2004/02/26 Thu 23:38:50) Updated: 2006/02/23
※ 引述《Awing (山坡羊)》之銘言:
> 為了適應舊站使用者習慣,
> 我把檔頭多加上了一槓,
> ─────────────────────────────────────

: more.c:more()

int
more(fpath, footer)
  char *fpath;
  char *footer;
{
+ #define MSG_SEPERATE    "\033[36m"MSG_SEPERATOR"\033[m\n"
+ uschar *fnew;

  ...
  ...

    if (!*buf)  /* 第一次 "\n\n" 是檔頭的結尾 */
      break;
  }
  headend = foff;

+ if (header_len && footer)     /* 一般文章,在檔頭與本文之間加入分隔線 */
+ {
+   lino = strlen(MSG_SEPERATE);
+
+   if (!(fnew = malloc(fsize + lino)))
+   {
+     free(fimage);
+     return -1;
+   }
+
+   shift = foff - fimage;
+   memcpy(fnew, fimage, shift);
+   memcpy(fnew + shift, MSG_SEPERATE, lino);
+   memcpy(fnew + shift + lino, foff, fsize - shift);
+
+   free(fimage);
+   fsize += lino;
+   fimage = fnew;
+   fend = fimage + fsize;
+   headend = fimage + shift;
+ }

  /* 歸零 */
  foff = fimage;

--
  Origin:  Maple-itoc˙動力核心  processor.tfcis.org 
  Author: itoc itoc.dorm11.nctu.edu.tw 發表
精華選讀←離開[主題上]主題下(k)上篇(j)下篇S/a搜尋 G串列 TAB精華 ↑↓捲 Pg/Space翻