summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-05-27 17:13:25 +0800
committerkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-05-27 17:13:25 +0800
commit7fb50c3a816f8b243e387dd903df6fbd732735d3 (patch)
tree1d64a28cd87a251048652b27299fab8abcd6aa2c
parent47e1682c7ad6d559f46b49d525423479d7d78316 (diff)
downloadpttbbs-7fb50c3a816f8b243e387dd903df6fbd732735d3.tar
pttbbs-7fb50c3a816f8b243e387dd903df6fbd732735d3.tar.gz
pttbbs-7fb50c3a816f8b243e387dd903df6fbd732735d3.tar.bz2
pttbbs-7fb50c3a816f8b243e387dd903df6fbd732735d3.tar.lz
pttbbs-7fb50c3a816f8b243e387dd903df6fbd732735d3.tar.xz
pttbbs-7fb50c3a816f8b243e387dd903df6fbd732735d3.tar.zst
pttbbs-7fb50c3a816f8b243e387dd903df6fbd732735d3.zip
- many small revise
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4487 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--common/sys/net.c5
-rw-r--r--common/sys/string.c2
-rw-r--r--include/cmsys.h4
-rw-r--r--include/convert.h15
-rw-r--r--include/perm.h2
-rw-r--r--mbbsd/Makefile2
-rw-r--r--mbbsd/chc.c2
-rw-r--r--mbbsd/chess.c6
-rw-r--r--mbbsd/convert.c15
-rw-r--r--mbbsd/io.c16
-rw-r--r--mbbsd/record.c1
11 files changed, 49 insertions, 21 deletions
diff --git a/common/sys/net.c b/common/sys/net.c
index 80566487..ba08ff7f 100644
--- a/common/sys/net.c
+++ b/common/sys/net.c
@@ -12,10 +12,11 @@
#include "cmsys.h"
-unsigned int
+uint32_t
ipstr2int(const char *ip)
{
- unsigned int i, val = 0;
+ unsigned int i;
+ uint32_t val = 0;
char buf[32];
char *nil, *p;
diff --git a/common/sys/string.c b/common/sys/string.c
index a6a10cc9..72c80cef 100644
--- a/common/sys/string.c
+++ b/common/sys/string.c
@@ -63,7 +63,7 @@ void chomp(char *src)
/* ANSI 處理函數 */
/* ----------------------------------------------------- */
int
-strip_blank(char *cbuf, char *buf)
+strip_blank(char *cbuf, const char *buf)
{
for (; *buf; buf++)
if (*buf != ' ')
diff --git a/include/cmsys.h b/include/cmsys.h
index da03e192..2b90042c 100644
--- a/include/cmsys.h
+++ b/include/cmsys.h
@@ -75,7 +75,7 @@ extern int file_delete_record(const char *file, const char *key, int case_sensit
extern void PttLock(int fd, int start, int size, int mode);
/* net.c */
-extern unsigned int ipstr2int(const char *ip);
+extern uint32_t ipstr2int(const char *ip);
extern int tobind(const char *addr);
extern int toconnect(const char *addr);
extern int toread(int fd, void *buf, int len);
@@ -93,7 +93,7 @@ extern void trim(char *buf);
extern void chomp(char *src);
extern int strlen_noansi(const char *s);
extern int strat_ansi(int count, const char *s);
-extern int strip_blank(char *cbuf, char *buf);
+extern int strip_blank(char *cbuf, const char *buf);
extern int strip_ansi(char *buf, const char *str, enum STRIP_FLAG flag);
extern void strip_nonebig5(unsigned char *str, int maxlen);
extern int invalid_pname(const char *str);
diff --git a/include/convert.h b/include/convert.h
index a4f1b410..2800845c 100644
--- a/include/convert.h
+++ b/include/convert.h
@@ -5,13 +5,20 @@
#ifdef CONVERT
-#define CONV_NORMAL 0
-#define CONV_GB 1
-#define CONV_UTF8 2
+enum ConvertMode {
+ CONV_NORMAL,
+ CONV_GB,
+ CONV_UTF8
+};
typedef ssize_t (*read_write_type)(int, void *, size_t);
typedef ssize_t (*convert_type)(void *, ssize_t);
-// extern int bbs_convert_type;
+
+extern read_write_type write_type;
+extern read_write_type read_type;
+extern convert_type input_type;
+
+extern void init_convert();
#endif // CONVERT
#endif // _BBS_CONVERT_H
diff --git a/include/perm.h b/include/perm.h
index 3923c796..e66df594 100644
--- a/include/perm.h
+++ b/include/perm.h
@@ -55,7 +55,7 @@
#define PERM_FORWARD (PERM_LOGINOK) /* to do the forwarding */
#define PERM_INTERNET (PERM_LOGINOK) /* 身份認證過關的才能寄信到 Internet */
-#define HasUserPerm(x) (cuser.userlevel & (x))
+#define HasUserPerm(x) ((cuser.userlevel & (x)) != 0)
#define PERM_HIDE(u) (u && (u)->userlevel & PERM_SYSOPHIDE)
#define IS_BOARD(bptr) ((bptr)->brdname[0] && \
diff --git a/mbbsd/Makefile b/mbbsd/Makefile
index f6486530..f5ea4269 100644
--- a/mbbsd/Makefile
+++ b/mbbsd/Makefile
@@ -72,7 +72,7 @@ OBJS+= screen.o
#######################################################################
.if defined(DIET)
-OBJS+= random.o time.o alloc.o
+LDLIBS+= $(SRCROOT)/common/diet/libdiet.a
DIETCC:= diet -Os
.endif
diff --git a/mbbsd/chc.c b/mbbsd/chc.c
index 5c69a9bd..4df8e2d7 100644
--- a/mbbsd/chc.c
+++ b/mbbsd/chc.c
@@ -778,7 +778,7 @@ chc_select(ChessInfo* info, rc_t scrloc, ChessGameResult* result)
return 0;
}
-int round_to_int(double x)
+static int round_to_int(double x)
{
/* assume that double cast to int will drop fraction parts */
if(x>=0)
diff --git a/mbbsd/chess.c b/mbbsd/chess.c
index 3e578a20..03475926 100644
--- a/mbbsd/chess.c
+++ b/mbbsd/chess.c
@@ -48,11 +48,13 @@ static const char * const ChessHintStr[] = {
"Enter 選擇/移動"
};
-static const struct {
+struct ChessReplayMap_t {
const char* name;
int name_len;
ChessInfo* (*func)(FILE* fp);
-} ChessReplayMap[] = {
+};
+
+static const struct ChessReplayMap_t ChessReplayMap[] = {
{ "gomoku", 6, &gomoku_replay },
{ "chc", 3, &chc_replay },
{ "go", 2, &gochess_replay },
diff --git a/mbbsd/convert.c b/mbbsd/convert.c
index e5d0f07b..611e54ac 100644
--- a/mbbsd/convert.c
+++ b/mbbsd/convert.c
@@ -3,6 +3,13 @@
#ifdef CONVERT
+#ifdef CONVERT
+extern void big2gb_init(void*);
+extern void gb2big_init(void*);
+extern void big2uni_init(void*);
+extern void uni2big_init(void*);
+#endif
+
extern unsigned char *gb2big(unsigned char *, int *, int);
extern unsigned char *big2gb(unsigned char *, int *, int);
extern unsigned char *utf8_uni(unsigned char *, int *, int);
@@ -120,4 +127,12 @@ void set_converting_type(int which)
// bbs_convert_type = which;
}
+void init_convert()
+{
+ big2gb_init(NULL);
+ gb2big_init(NULL);
+ big2uni_init(NULL);
+ uni2big_init(NULL);
+}
+
#endif
diff --git a/mbbsd/io.c b/mbbsd/io.c
index c3a7f5e4..375d1a6d 100644
--- a/mbbsd/io.c
+++ b/mbbsd/io.c
@@ -31,7 +31,7 @@ static unsigned long szTotalOutput = 0, szLastOutput = 0;
extern unsigned char fakeEscape;
unsigned char fakeEscape = 0;
-unsigned char fakeEscFilter(unsigned char c)
+static unsigned char fakeEscFilter(unsigned char c)
{
if (!fakeEscape) return c;
if (c == ESC_CHR) return '*';
@@ -48,17 +48,15 @@ unsigned char fakeEscFilter(unsigned char c)
/* ----------------------------------------------------- */
#ifdef CONVERT
-extern read_write_type write_type;
-extern read_write_type read_type;
-extern convert_type input_type;
-
inline static ssize_t input_wrapper(void *buf, ssize_t count) {
/* input_wrapper is a special case.
* because we may do nothing,
* a if-branch is better than a function-pointer call.
*/
- if(input_type) return (*input_type)(buf, count);
- else return count;
+ if(input_type)
+ return (*input_type)(buf, count);
+ else
+ return count;
}
inline static int read_wrapper(int fd, void *buf, size_t count) {
@@ -745,6 +743,10 @@ drop_input(void)
icurrchar = ibufsize = 0;
}
+/*
+ * wait user input for f seconds.
+ * return 1 if control key c is available.
+ */
int
peek_input(float f, int c)
{
diff --git a/mbbsd/record.c b/mbbsd/record.c
index ec992b0b..83bafe76 100644
--- a/mbbsd/record.c
+++ b/mbbsd/record.c
@@ -322,6 +322,7 @@ safe_article_delete_range(const char *direct, int from, int to)
#endif
/* mail / post 時,依據時間建立檔案,加上郵戳 */
+/* @param[in,out] fpath input as dirname, output as filename */
int
stampfile_u(char *fpath, fileheader_t * fh)
// Ptt: stampfile_u: won't clear fileheader