summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-08-16 14:30:40 +0800
committervictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-08-16 14:30:40 +0800
commitb21c27c008abe611d03e5ab8042080b632846e5c (patch)
treeab774c72c78b4b1f457361dc796034d91411fbdb
parent46d670eedce001eb79f4ce5cc8f6ffaf2ad83b5d (diff)
downloadpttbbs-b21c27c008abe611d03e5ab8042080b632846e5c.tar
pttbbs-b21c27c008abe611d03e5ab8042080b632846e5c.tar.gz
pttbbs-b21c27c008abe611d03e5ab8042080b632846e5c.tar.bz2
pttbbs-b21c27c008abe611d03e5ab8042080b632846e5c.tar.lz
pttbbs-b21c27c008abe611d03e5ab8042080b632846e5c.tar.xz
pttbbs-b21c27c008abe611d03e5ab8042080b632846e5c.tar.zst
pttbbs-b21c27c008abe611d03e5ab8042080b632846e5c.zip
reduce memory usage by 70 bytes per user.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3047 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--include/proto.h2
-rw-r--r--mbbsd/mbbsd.c2
-rw-r--r--mbbsd/menu.c54
3 files changed, 37 insertions, 21 deletions
diff --git a/include/proto.h b/include/proto.h
index 981a7ba4..f3579619 100644
--- a/include/proto.h
+++ b/include/proto.h
@@ -379,7 +379,7 @@ int query_file_money(const fileheader_t *pfh);
/* menu */
void showtitle(const char *title, const char *mid);
void movie(int i);
-void domenu(int cmdmode, const char *cmdtitle, int cmd, const commands_t cmdtable[]);
+int main_menu(void);
int admin(void);
int Mail(void);
int Talk(void);
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index f9cd01c4..adc2dedf 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -1152,7 +1152,7 @@ start_client(void)
Signal(SIGALRM, SIG_IGN);
- domenu(MMENU, "主功\能表", (currutmp->mailalert ? 'M' : 'C'), cmdlist);
+ main_menu();
}
/* 取得 remote user name 以判定身份 */
diff --git a/mbbsd/menu.c b/mbbsd/menu.c
index a613de8d..a802713d 100644
--- a/mbbsd/menu.c
+++ b/mbbsd/menu.c
@@ -9,7 +9,6 @@ extern char *boardprefix;
extern struct utmpfile_t *utmpshm;
extern char board_hidden_status;
-
static const char *title_tail_msgs[] = {
"看板",
"文摘",
@@ -214,18 +213,30 @@ show_menu(const commands_t * p)
return n - 1;
}
-void
+
+static enum {
+ M_ADMIN = 0, M_AMUSE, M_CHC, M_JCEE, M_MAIL, M_MMENU, M_NMENU,
+ M_PMENU, M_PSALE, M_SREG, M_TMENU, M_UMENU, M_XMENU,
+};
+
+static const int mode_map[] = {
+ ADMIN, AMUSE, CHC, JCEE, MAIL, MMENU, NMENU,
+ PMENU, PSALE, SREG, TMENU, UMENU, XMENU,
+};
+
+static void
domenu(int cmdmode, const char *cmdtitle, int cmd, const commands_t cmdtable[])
{
int lastcmdptr;
int n, pos, total, i;
int err;
- // XXX do we really need this ?
- static char cmd0[MODE_MAX];
+ static char cursor_position[sizeof(mode_map) / sizeof(mode_map[0])] = { 0 };
+
+ cmdmode = mode_map[cmdmode];
- if (cmd0[cmdmode])
- cmd = cmd0[cmdmode];
+ if (cursor_position[cmdmode])
+ cmd = cursor_position[cmdmode];
setutmpmode(cmdmode);
@@ -314,7 +325,7 @@ domenu(int cmdmode, const char *cmdtitle, int cmd, const commands_t cmdtable[])
cmd = cmdtable[lastcmdptr].desc[0];
else
cmd = cmdtable[lastcmdptr].desc[1];
- cmd0[cmdmode] = cmdtable[lastcmdptr].desc[0];
+ cursor_position[cmdmode] = cmdtable[lastcmdptr].desc[0];
}
if (cmd >= 'a' && cmd <= 'z')
cmd &= ~0x20;
@@ -535,8 +546,13 @@ static const commands_t moneylist[] = {
{NULL, 0, NULL}
};
+int main_menu(void) {
+ domenu(M_MMENU, "主功\能表", (currutmp->mailalert ? 'M' : 'C'), cmdlist);
+ return 0;
+}
+
static int p_money() {
- domenu(PSALE, "Ptt量販店", '0', moneylist);
+ domenu(M_PSALE, "Ptt量販店", '0', moneylist);
return 0;
};
@@ -551,7 +567,7 @@ const static commands_t jceelist[] = {
};
static int m_jcee() {
- domenu(JCEE, "Ptt查榜系統", '0', jceelist);
+ domenu(M_JCEE, "Ptt查榜系統", '0', jceelist);
return 0;
}
#endif
@@ -594,7 +610,7 @@ static const commands_t chesslist[] = {
};
static int chessroom() {
- domenu(CHC, "Ptt棋院", '1', chesslist);
+ domenu(M_CHC, "Ptt棋院", '1', chesslist);
return 0;
}
@@ -615,7 +631,7 @@ static const commands_t plist[] = {
};
static int playground() {
- domenu(AMUSE, "Ptt遊樂場",'1',plist);
+ domenu(M_AMUSE, "Ptt遊樂場",'1',plist);
return 0;
}
@@ -628,7 +644,7 @@ static const commands_t slist[] = {
};
static int forsearch() {
- domenu(SREG, "Ptt搜尋器", '1', slist);
+ domenu(M_SREG, "Ptt搜尋器", '1', slist);
return 0;
}
@@ -637,49 +653,49 @@ static int forsearch() {
int
admin(void)
{
- domenu(ADMIN, "系統維護", 'X', adminlist);
+ domenu(M_ADMIN, "系統維護", 'X', adminlist);
return 0;
}
int
Mail(void)
{
- domenu(MAIL, "電子郵件", 'R', maillist);
+ domenu(M_MAIL, "電子郵件", 'R', maillist);
return 0;
}
int
Talk(void)
{
- domenu(TMENU, "聊天說話", 'U', talklist);
+ domenu(M_TMENU, "聊天說話", 'U', talklist);
return 0;
}
int
User(void)
{
- domenu(UMENU, "個人設定", 'I', userlist);
+ domenu(M_UMENU, "個人設定", 'I', userlist);
return 0;
}
int
Xyz(void)
{
- domenu(XMENU, "工具程式", 'M', xyzlist);
+ domenu(M_XMENU, "工具程式", 'M', xyzlist);
return 0;
}
int
Play_Play(void)
{
- domenu(PMENU, "網路遊樂場", 'A', playlist);
+ domenu(M_PMENU, "網路遊樂場", 'A', playlist);
return 0;
}
int
Name_Menu(void)
{
- domenu(NMENU, "白色恐怖", 'O', namelist);
+ domenu(M_NMENU, "白色恐怖", 'O', namelist);
return 0;
}