作者lihgong (Q.Q)
看板PttCurrent
標題Re: [請益] 鎖文的功能
時間Sun Dec 19 11:14:39 2004
我大概把實作的方法寫在這邊
有人需要可以參考看看
首先看pttstruct.h
找fileheader_t裡filemode一個空的欄位來用
在看板裡面, lock的文章要和其他文章區別
下面列出現行的pttCurrent的filemode
#define FILE_LOCAL 0x1 /* local saved */
#define FILE_READ 0x1 /* already read : mail only */
#define FILE_MARKED 0x2 /* opus: 0x8 */
#define FILE_DIGEST 0x4 /* digest */
#define FILE_HOLD 0x8 /* unused */
#define FILE_BOTTOM 0x8 /* push_bottom */
#define FILE_SOLVED 0x10 /* problem solved, sysop/BM only */
#define FILE_HIDE 0x20 /* hild */
#define FILE_BID 0x20 /* for bid */
#define FILE_BM 0x40 /* BM only */
#define FILE_MULTI 0x100 /* multi send for mail */
#define FILE_VOTE 0x40 /* for vote */
#define FILE_ANONYMOUS 0x80 /* anonymous file */
說實話... 要在上面的filemode再塞一個鎖定文章有點困難
還是可以做, 比如捨棄FILE_BID的功能, 拿這個flag來做鎖定文章
或是... (想辦法橋出來就是了 @@)
或是考慮下面比較難搞的辦法
----------
根本的解法是擴充filemode, 從char->short
我站上在擴展filemode之後, 重新分配的filemode變...
// 看板文章區
#define FILE_LOCAL 0x0001 /* local saved */
#define FILE_MARKED 0x0002 /* mark post */
#define FILE_DIGEST 0x0004 /* digest */
#define FILE_SOLVED 0x0008 /* problem solved, sysop/BM only */
#define FILE_VOTE 0x0010 /* for vote */
#define FILE_ANONYMOUS 0x0020 /* 匿名文章, 文章 money 欄位拿來存 uid */
#define FILE_BOTTOM 0x0040 /* push_bottom */
// 信件區
#define FILE_READ 0x0100 /* already read : mail only */
#define FILE_REPLYED 0x0200 /* replyed mail : mail only */
#define FILE_MULTI 0x0400 /* multi send for mail */
//閱讀權限區
#define FILE_HIDE 0x1000 /* hide & 文章加密 */
#define FILE_BM 0x2000 /* BM only */
[email protected] no.982有轉換程式的範例 (當然... 要稍微改一下)
拼一點把舊的filemode完全對應的新的filemode (看起來比較整齊乾淨)
懶一點就直接filemode (新的) = filemode (舊的)
多出來的8-bit就可以亂用
當然囉... 建議你另外跑一個PttCurrent來測試
完全ok了再對原站做轉換 (話說我當時爆了十幾次 @@)
-----------
最後列出我站上的fileheader_t給你參考
typedef struct fileheader_t {
char filename[FNLEN]; /* M.9876543210.A */
char recommend; /* important level */
char owner[IDLEN + 2]; /* uid[.] */
char date[6]; /* [02/02] or space(5) */
char title[TTLEN + 1];
/* lihgong: 下面這些flag和ptt不同, 主要原因是我把money欄位改成 short */
union {
short money;
short anon_uid;
/* lihgong: 因為我站上人數 < 65535人 */
/* different order to match alignment */
#ifdef _BIG_ENDIAN
struct {
unsigned char logins; /* money & 0xff00 */
unsigned char posts; /* money & 0xff */
} vote_limits;
struct {
unsigned short flag:1;
unsigned short ref:15;
} refer;
#else
struct {
unsigned char posts; /* money & 0xff */
unsigned char logins; /* money & 0xff00 */
} vote_limits;
struct {
unsigned short ref:15;
unsigned short flag:1;
} refer;
#endif
} multi; /* rocker: if bit16 on ==> reference */
/* XXX dirty, split into flag and money if money of each file is less than 16bit? */
unsigned short filemode; /* must be last field @ boards.c */
} fileheader_t;
note. 上面那段恐怖的union, 如果你沒用到裡頭的posts和logins
放心的把那串union註解掉, 換成short money吧
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.140.120
1F:推 frankiori:再度大感謝 163.21.254.249 12/20