summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/common.h3
-rw-r--r--include/proto.h17
-rw-r--r--mbbsd/io.c33
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);
diff --git a/mbbsd/io.c b/mbbsd/io.c
index ae78bbcd..3e1adbaa 100644
--- a/mbbsd/io.c
+++ b/mbbsd/io.c
@@ -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