Linux 版 (精华区)

发信人: cucme (说你说我), 信区: Linux
标  题: [innbbsd patch] early cancel
发信站: 紫 丁 香 (Sun Aug 22 21:53:33 1999), 转信

发信人  Leeym.bbs@bbs.civil.ncku.edu.tw (Phantom)            信区  installbbs
 标  题  [innbbsd patch] early cancel
 发信站  成大土木大地雕塑家 (99/03/10 19:45:01)
 转信站  TKU-BBS!news.tku!news!MOECC-INN2!ctu-peer!ctu-gate!news.nctu!netnews.c
 Origin  (null)

        本来说不摸程式了 不过吃饭时间改改程式当消遣.. :p

        如果 cancel message 比本文先到, stevel 称这情形叫 early cancel.

        原先 innbbsd 对 early cancel 没有任何措施.
cancel_article_front(msgid)
  char *msgid;
{
        :
  char *ptr = (char *) DBfetch(msgid);
  if (ptr == NULL)
  {
    return 0;   /* 直接放弃整个 cancel article 的动作 */
  }
        :
}

        patch 大概的想法是, 收到 early cancel 先丢到 control 版
        storeDB 存下要被砍的文章的 MSGID.

        而在 receive_article 前面 DBfetch 检查是否已经有此文章.

int
early_cancel(msgid)
{
  char *boardhome, *fname;
  char firstpath[MAXPATHLEN], *firstpathbase;
  char **splitptr, *ngptr;
  newsfeeds_t *nf;

  boardhome = (char *) fileglue("%s/boards/control", BBSHOME);
  testandmkdir(boardhome);
  *firstpath = '\0';
  if (isdir(boardhome))
  {
    splitptr = (char **) BNGsplit(GROUPS);
    for (ngptr = *splitptr; ngptr != NULL; ngptr = *(++splitptr))
    {
      if (*ngptr == '\0')
        continue;
      nf = (newsfeeds_t *) search_group(ngptr);
      if (nf == NULL)
        continue;
      if (nf->board == NULL)
        continue;
      if (nf->path == NULL)
        continue;
      fname = (char *) post_article(boardhome, FROM, "control",
        bbspost_write_control, NULL, firstpath);
      if (fname != NULL)
      {
        if (firstpath[0] == '\0')
          sprintf(firstpath, "%s/boards/control/%s", BBSHOME, fname);
        bbsfeedslog(fileglue("control/%s", fname), 'C');
        firstpathbase = firstpath + strlen(BBSHOME) + strlen("/boards/");
        feedfplog(nf, firstpathbase, 'C');
        if (storeDB(msgid, (char *) fileglue("control/%s", fname)) < 0)
          bbslog("fail to storeDB early cancel %s, %s\n", msgid, fname);
        else
          bbslog("early cancel %s\n", msgid);
        return 0;
      }
    }
  }
  return 0;
}


receive_article()
{
        :
+  char *ptr = (char *) DBfetch(MSGID);

+  if (ptr != NULL)
+  {
+    bbslog("receive_article early cancelled %s\n", MSGID);
+    return 0;
+  }
        :
}


cancel_article_front(msgid)
  char *msgid;
{
        :
  char *ptr = (char *) DBfetch(msgid);
  if (ptr == NULL)
  {
!    return early_cancel(msgid);
  }
        :
}

cancel_article()
{
        :
    if (strcmp(file, header.filename) == 0)
    {
       if ((header.filemode & FILE_MARKED)
           || (header.filemode & FILE_DIGEST) || (header.owner[0] == '-'))
          break;
       delete_record(dirname, sizeof(fileheader), lseek(fd, (off_t)0, SEEK_CUR)
+       if (strcmp(board, "control"))
+       else
+       {
+         char fpath[80];
+         sprintf(fpath, BBSHOME "/boards/%s/%s", board, header.filename);
+         unlink(fpath);
+       }
       break;
    }
        :
}


--
※ 来源:.紫 丁 香 bbs.hit.edu.cn.[FROM: 202.118.243.5]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:4.361毫秒