summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2013-01-08 21:51:18 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2013-01-08 21:51:18 +0800
commit522232d92f5a8edf78f3ee57541838888fd135f8 (patch)
treee08f6747da7ddbdf3a53e1c06972591757d0b460
parentc7af1a9ba185565b8ec100c31dc1b3913a2b29f9 (diff)
downloadpttbbs-522232d92f5a8edf78f3ee57541838888fd135f8.tar
pttbbs-522232d92f5a8edf78f3ee57541838888fd135f8.tar.gz
pttbbs-522232d92f5a8edf78f3ee57541838888fd135f8.tar.bz2
pttbbs-522232d92f5a8edf78f3ee57541838888fd135f8.tar.lz
pttbbs-522232d92f5a8edf78f3ee57541838888fd135f8.tar.xz
pttbbs-522232d92f5a8edf78f3ee57541838888fd135f8.tar.zst
pttbbs-522232d92f5a8edf78f3ee57541838888fd135f8.zip
refine make system and update default conf.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5766 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--pttbbs/UPDATING8
-rw-r--r--pttbbs/mbbsd/Makefile10
-rw-r--r--pttbbs/mbbsd/testsz.c56
-rw-r--r--pttbbs/sample/pttbbs.conf18
4 files changed, 62 insertions, 30 deletions
diff --git a/pttbbs/UPDATING b/pttbbs/UPDATING
index 3025bc23..50987c7b 100644
--- a/pttbbs/UPDATING
+++ b/pttbbs/UPDATING
@@ -23,6 +23,12 @@ https://opensvn.csie.org/traccgi/pttbbs/changeset/2273
make r4871_uflag
-----------------------------------------------------------------------------
+r5748: [typecheck]
+Makefile 現在會多執行 mbbsd/testsz,並在其中確保 userec_t 等結構大小正確
+(主要是確認 time4_t 與其它自行定義的變數沒有導致data size不合)
+如果你已開的站遇到 time4_t 不合(ex, 在 64bit 系統上忘了定義 TIMET64) 請考慮
+是要砍站重開(重建所有資料)或是自己手動寫轉換程式。
+
r5734: [cleanup]
userec_t 裡很多東西以後可能要挪作它用,跑一下 upgrade/r5734 可以把資料清空。
早作早好。
@@ -91,7 +97,7 @@ r4826: [numlogindays, lastseen]
numlogins 的算法有調整,並且改名為 numlogindays;
lastlogin 也多了一個叫 lastseen (別人 talk->query 到的值)
lastlogin 只要登入就一定會更新,lastseen 則否。
-另,這個 r4826 的 upgrade 是 optional 的,不跑也不 ok,
+另,這個 r4826 的 upgrade 是 optional 的,不跑也 ok,
只是看你要不要一併調整 numlogin 的值。
r4483: [mbbsd command option]
diff --git a/pttbbs/mbbsd/Makefile b/pttbbs/mbbsd/Makefile
index 0a2ad445..d7074298 100644
--- a/pttbbs/mbbsd/Makefile
+++ b/pttbbs/mbbsd/Makefile
@@ -85,12 +85,14 @@ OBJS+= screen.o
#######################################################################
.SUFFIXES: .c .o
+.PHONY: all ctags test install clean
+
.c.o: $(SRCROOT)/include/var.h
$(CC) $(CFLAGS) -c $*.c
all: $(PROG)
-$(PROG): $(OBJS)
+$(PROG): testsz $(OBJS)
sh $(SRCROOT)/util/newvers.sh
@printf "\033[0;1;32m"
@[ -z "$(DEBUG)" ] || printf "\033[31m+DEBUG \033[32m"
@@ -101,6 +103,12 @@ $(PROG): $(OBJS)
@printf "\033[m"
$(CC) vers.c -o $(PROG) $(OBJS) $(LDFLAGS) $(LDLIBS)
+testsz: $(SRCROOT)/pttbbs.conf $(SRCROOT)/include/*.h testsz.c
+ $(CC) $(CFLAGS) testsz.c -o testsz
+ @printf "\033[0;1;33mChecking configuration data sizes...\033[m\n"
+ @./testsz
+ @printf "\033[0;1;32mData size configuration OK\033[m\n"
+
mbbsd.o: mbbsd.c $(SRCROOT)/include/var.h
$(DIETCC) $(CC) $(CFLAGS) -c $<
diff --git a/pttbbs/mbbsd/testsz.c b/pttbbs/mbbsd/testsz.c
index e5ea87be..dadb8083 100644
--- a/pttbbs/mbbsd/testsz.c
+++ b/pttbbs/mbbsd/testsz.c
@@ -2,21 +2,49 @@
#include <sys/types.h>
#include "bbs.h"
+void
+ensure(size_t sz1, size_t sz2, const char *name, const char *reason) {
+ if (sz1 == sz2) {
+ printf("sizeof(%s): %zu (OK)\n", name, sz1);
+ return;
+ }
+ printf("%s: size unmatch (expected: %zu, actual: %zu).\n",
+ name, sz1, sz2);
+ if (reason && *reason)
+ printf(" *** %s\n", reason);
+ exit(1);
+}
+
+void
+check(size_t sz, const char *name) {
+ printf("sizeof(%s): %zu\n", name, sz);
+}
+
+#define ENSURE(x, y) ensure(sizeof(x), y, #x, "")
+#define ENSURE3(x, y, reason) ensure(sizeof(x), y, #x, reason)
+#define CHECK(x) check(sizeof(x), #x)
+
int main()
{
- printf("sizeof(size_t) = %lu\n", sizeof(size_t));
- printf("sizeof(off_t) = %lu\n", sizeof(off_t));
- printf("sizeof(int) = %lu\n", sizeof(int));
- printf("sizeof(long) = %lu\n", sizeof(long));
- printf("sizeof(time_t) = %lu\n", sizeof(time_t));
- printf("sizeof(time4_t) = %lu %s\n", sizeof(time4_t), sizeof(time4_t) == 4 ? "" : "ERROR!!!!!");
- printf("sizeof(userec_t) = %lu\n", sizeof(userec_t));
- printf("sizeof(fileheader_t) = %lu\n", sizeof(fileheader_t));
- printf("sizeof(boardheader_t) = %lu\n", sizeof(boardheader_t));
- printf("sizeof(chicken_t) = %lu\n", sizeof(chicken_t));
- printf("sizeof(userinfo_t) = %lu\n", sizeof(userinfo_t));
- printf("sizeof(msgque_t) = %lu\n", sizeof(msgque_t));
- printf("sizeof(SHM_t) = %lu\n", sizeof(SHM_t));
- printf("SHMSIZE = %lu\n", SHMSIZE);
+ // System type length.
+ CHECK(size_t);
+ CHECK(size_t);
+ CHECK(off_t);
+ CHECK(int);
+ CHECK(long);
+ CHECK(time_t);
+
+ // Per-site data length
+ CHECK(userinfo_t);
+ CHECK(msgque_t);
+ CHECK(SHM_t);
+ printf("SHMSIZE = %lu\n", SHMSIZE);
+
+ // Data types that need to be checked.
+ ENSURE3(time4_t, 4, "Please define TIMET64 in your pttbbs.conf.");
+ ENSURE(userec_t, 512);
+ ENSURE(fileheader_t, 128);
+ ENSURE(boardheader_t, 256);
+ ENSURE(chicken_t, 128);
return 0;
}
diff --git a/pttbbs/sample/pttbbs.conf b/pttbbs/sample/pttbbs.conf
index 5978afd0..ebebff9f 100644
--- a/pttbbs/sample/pttbbs.conf
+++ b/pttbbs/sample/pttbbs.conf
@@ -167,7 +167,7 @@
//#define OUTTA_TIMER
/* 若定義, 則開啟 Big5 轉 UTF-8 的功能 */
-//#define CONVERT
+#define CONVERT
/* 若定義, 則在文章列表的時候不同日期會標上不同顏色 */
//#define COLORDATE
@@ -177,13 +177,10 @@
/* DBCS 相關設定 */
/* DBCS Aware: 讓游標不會跑到 DBCS trailing bytes 上 */
-//#define DBCSAWARE
-/* 因為 DBCS 要先偵測,所以可以利用指定下面的時間來判斷使用者有否偵測過
- * 請換成你真正上線的時間 (time_t) */
-//#define DBCSAWARE_UPGRADE_STARTTIME (0)
+#define DBCSAWARE
/* 若定義,guest 帳號預設不顯示一字雙色 */
-// #define GUEST_DEFAULT_DBCS_NOINTRESC
+#define GUEST_DEFAULT_DBCS_NOINTRESC
/* 使用新式的 pmore (piaip's more) 代替舊式 bug 抓不完的 more 或是簡易的 minimore */
//#define USE_PMORE
@@ -248,12 +245,6 @@
/* 若定義, 新板設定自動開記錄,不過 USE_AUTOCPLOG 還是要開才有用 */
#define DEFAULT_AUTOCPLOG
-/* 若定義,少於此數目的金錢將不開發票,也不能對獎 */
-#define VICE_MIN (100)
-
-/* 贈送信箱 */
-//#define ADD_EXMAILBOX 100
-
/* 如果 time_t 是 8 bytes的話 (如 X86_64) */
//#define TIMET64
@@ -263,9 +254,8 @@
/* 在 cacheserver 上面擋掉狂上下站的使用者 */
//#define NOFLOODING
-/* 使用 fromd, 使用外部daemon紀錄上站故鄉名稱 */
+/* 使用 daemon/fromd, 使用外部daemon紀錄上站故鄉名稱 */
//#define FROMD
-//#define FROMD_ADDR "127.0.0.1:5130"
/* 若定義, 則不允許註冊 guest */
//#define NO_GUEST_ACCOUNT_REG