diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-04-08 21:25:11 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-04-08 21:25:11 +0800 |
commit | 1ef1fe4d34d71e9488b01f2cd8f9b9d06482392b (patch) | |
tree | c5e3b73404f70a6b71d6630150008c07b3862b3a | |
parent | f09589e00925a3d9a03105ca5ff3717120acc853 (diff) | |
download | pttbbs-1ef1fe4d34d71e9488b01f2cd8f9b9d06482392b.tar pttbbs-1ef1fe4d34d71e9488b01f2cd8f9b9d06482392b.tar.gz pttbbs-1ef1fe4d34d71e9488b01f2cd8f9b9d06482392b.tar.bz2 pttbbs-1ef1fe4d34d71e9488b01f2cd8f9b9d06482392b.tar.lz pttbbs-1ef1fe4d34d71e9488b01f2cd8f9b9d06482392b.tar.xz pttbbs-1ef1fe4d34d71e9488b01f2cd8f9b9d06482392b.tar.zst pttbbs-1ef1fe4d34d71e9488b01f2cd8f9b9d06482392b.zip |
- (internal) add some Maple-3 API interface to help porting
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4099 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | include/common.h | 3 | ||||
-rw-r--r-- | include/proto.h | 17 | ||||
-rw-r--r-- | mbbsd/io.c | 33 |
3 files changed, 39 insertions, 14 deletions
diff --git a/include/common.h b/include/common.h index d448e96b..1086a796 100644 --- a/include/common.h +++ b/include/common.h @@ -15,7 +15,7 @@ #define FN_REJECT "reject" #define FN_WATER "water" #define FN_CANVOTE "can_vote" -#define FN_VISABLE "visable" +#define FN_VISABLE "visable" // 不知道是誰拼錯的,將錯就錯吧... #define FN_USIES "usies" /* BBS log */ #define FN_DIR ".DIR" #define FN_BOARD ".BRD" /* board list */ @@ -128,6 +128,7 @@ #define DOECHO 1 #define LCECHO 2 #define NUMECHO 4 +#define GCARRY 8 // (from M3) do not empty input buffer. #define YEA 1 /* Booleans (Yep, for true and false) */ #define NA 0 diff --git a/include/proto.h b/include/proto.h index 96fccf76..e68c638d 100644 --- a/include/proto.h +++ b/include/proto.h @@ -325,20 +325,23 @@ int guess_main(void); void set_converting_type(int which); /* io */ -int getdata(int line, int col, const char *prompt, char *buf, int len, int echo); int igetch(void); +int num_in_buf(void); int wait_input(float f, int bIgnoreBuf); int peek_input(float f, int c); +int input_isfull(); void drop_input(void); +void add_io(int fd, int timeout); +int getdata(int line, int col, const char *prompt, char *buf, int len, int echo); int getdata_str(int line, int col, const char *prompt, char *buf, int len, int echo, const char *defaultstr); int getdata_buf(int line, int col, const char *prompt, char *buf, int len, int echo); -void add_io(int fd, int timeout); -void oflush(void); -int oldgetdata(int line, int col, const char *prompt, char *buf, int len, int echo); -void output(const char *s, int len); -int num_in_buf(void); -int input_isfull(); int ochar(int c); +void output(const char *s, int len); +void oflush(void); +// maple 3 API +int vget(int line, int col, const char *prompt, char *buf, int len, int mode); +// int vkey(void); // P.S: in PTT system the vkey() is just alias to igetch(). +#define vkey() igetch() /* kaede */ char *Ptt_prints(char *str, size_t size, int mode); @@ -366,6 +366,14 @@ _debug_check_keyinput() static int water_which_flag = 0; +#ifndef vkey +int +vkey(void) +{ + return igetch(); +} +#endif + int igetch(void) { @@ -777,8 +785,8 @@ int getDBCSstatus(unsigned char *s, int pos) #endif #define MAXLASTCMD 12 -int -oldgetdata(int line, int col, const char *prompt, char *buf, int len, int echo) +static int +getdata_raw(int line, int col, const char *prompt, char *buf, int len, int echo) { register int ch, i; int clen, lprompt = 0; @@ -1027,23 +1035,36 @@ oldgetdata(int line, int col, const char *prompt, char *buf, int len, int echo) int getdata_buf(int line, int col, const char *prompt, char *buf, int len, int echo) { - return oldgetdata(line, col, prompt, buf, len, echo); + return getdata_raw(line, col, prompt, buf, len, echo); } int getdata_str(int line, int col, const char *prompt, char *buf, int len, int echo, const char *defaultstr) { - strlcpy(buf, defaultstr, len); + // if pointer is the same, ignore copy. + if (defaultstr != buf) + strlcpy(buf, defaultstr, len); - return oldgetdata(line, col, prompt, buf, len, echo); + return getdata_raw(line, col, prompt, buf, len, echo); } int getdata(int line, int col, const char *prompt, char *buf, int len, int echo) { buf[0] = 0; - return oldgetdata(line, col, prompt, buf, len, echo); + return getdata_raw(line, col, prompt, buf, len, echo); +} + +int +vget(int line, int col, const char *prompt, char *buf, int len, int mode) +{ + if (mode & GCARRY) + return getdata_raw(line, col, prompt, buf, len, (mode & ~GCARRY)); + else { + buf[0] = 0; + return getdata_raw(line, col, prompt, buf, len, mode); + } } /* vim:sw=4 |