diff options
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/admin.c | 13 | ||||
-rw-r--r-- | mbbsd/assess.c | 6 | ||||
-rw-r--r-- | mbbsd/bbs.c | 3 | ||||
-rw-r--r-- | mbbsd/cache.c | 9 | ||||
-rw-r--r-- | mbbsd/cal.c | 6 | ||||
-rw-r--r-- | mbbsd/chat.c | 3 | ||||
-rw-r--r-- | mbbsd/chc.c | 6 | ||||
-rw-r--r-- | mbbsd/chicken.c | 8 | ||||
-rw-r--r-- | mbbsd/gomo.c | 3 | ||||
-rw-r--r-- | mbbsd/mail.c | 3 | ||||
-rw-r--r-- | mbbsd/mbbsd.c | 1 | ||||
-rw-r--r-- | mbbsd/read.c | 3 | ||||
-rw-r--r-- | mbbsd/register.c | 11 | ||||
-rw-r--r-- | mbbsd/talk.c | 18 | ||||
-rw-r--r-- | mbbsd/user.c | 11 | ||||
-rw-r--r-- | mbbsd/var.c | 1 |
16 files changed, 59 insertions, 46 deletions
diff --git a/mbbsd/admin.c b/mbbsd/admin.c index e2549d9c..70018a2f 100644 --- a/mbbsd/admin.c +++ b/mbbsd/admin.c @@ -32,17 +32,17 @@ m_loginmsg(void) int m_user(void) { - userec_t muser; int id; + userec_t xuser; + int id; char genbuf[200]; stand_title("使用者設定"); usercomplete(msg_uid, genbuf); if (*genbuf) { move(2, 0); - if ((id = getuser(genbuf))) { - memcpy(&muser, &xuser, sizeof(muser)); - user_display(&muser, 1); - uinfo_query(&muser, 1, id); + if ((id = getuser(genbuf, &xuser))) { + user_display(&xuser, 1); + uinfo_query(&xuser, 1, id); } else { outs(err_uid); clrtoeol(); @@ -1098,7 +1098,7 @@ scan_register_form(char *regfile, int automode, int neednum) *ptr = '\0'; } } - } else if ((unum = getuser(fdata[0])) == 0) { + } else if ((unum = getuser(fdata[0], &muser)) == 0) { move(2, 0); clrtobot(); outs("系統錯誤,查無此人\n\n"); @@ -1108,7 +1108,6 @@ scan_register_form(char *regfile, int automode, int neednum) neednum--; } else { neednum--; - memcpy(&muser, &xuser, sizeof(muser)); if (automode) uid = autoid; diff --git a/mbbsd/assess.c b/mbbsd/assess.c index af361a13..f79053af 100644 --- a/mbbsd/assess.c +++ b/mbbsd/assess.c @@ -17,7 +17,8 @@ inline static void inc(unsigned char *num, int n) #define modify_column(_attr) \ int inc_##_attr(char *userid, int num) \ { \ - int uid = getuser(userid);\ + userec_t xuser; \ + int uid = getuser(userid, &xuser);\ if( uid > 0 ){ \ userinfo_t *uinfo = search_ulist(uid); \ if (uinfo != NULL) \ @@ -36,7 +37,8 @@ modify_column(badsale); /* inc_badsale */ #if 0 //unused function void set_assess(char *userid, unsigned char num, int type) { - int uid = getuser(userid); + userec_t xuser; + int uid = getuser(userid, &xuser); if(uid<=0) return; switch (type){ case GOODPOST: diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index af2b2fd9..093f2854 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -1963,7 +1963,8 @@ del_post(int ent, fileheader_t * fhdr, char *direct) if (!(inc_badpost(userid, 1) % 10)){ post_violatelaw(userid, "Ptt 系統警察", "劣文累計十篇", "罰單一張"); mail_violatelaw(userid, "Ptt 系統警察", "劣文累計十篇", "罰單一張"); - xuser.userlevel |= PERM_VIOLATELAW; + // XXX xuser 未指定, 也未寫回檔案, 沒有作用 + //xuser.userlevel |= PERM_VIOLATELAW; } mail_id(userid, genbuf, newpath, cuser.userid); } diff --git a/mbbsd/cache.c b/mbbsd/cache.c index 8ad9f2e8..09116154 100644 --- a/mbbsd/cache.c +++ b/mbbsd/cache.c @@ -210,13 +210,14 @@ searchuser(char *userid) } int -getuser(char *userid) +getuser(char *userid, userec_t *xuser) { int uid; - if ((uid = searchuser(userid))) - passwd_query(uid, &xuser); - xuser.money = moneyof(uid); + if ((uid = searchuser(userid))) { + passwd_query(uid, xuser); + xuser->money = moneyof(uid); + } return uid; } diff --git a/mbbsd/cal.c b/mbbsd/cal.c index 48123958..8163c2ec 100644 --- a/mbbsd/cal.c +++ b/mbbsd/cal.c @@ -250,6 +250,7 @@ ordersong(void) static int inmailbox(int m) { + userec_t xuser; passwd_query(usernum, &xuser); cuser.exmailbox = xuser.exmailbox + m; passwd_update(usernum, &cuser); @@ -365,6 +366,9 @@ p_give(void) { int money, tax; char id[IDLEN + 1], money_buf[20]; +#ifdef PLAY_ANGEL + userec_t xuser; +#endif move(1, 0); usercomplete("這位幸運兒的id:", id); @@ -382,7 +386,7 @@ p_give(void) log_file(FN_MONEY, LOG_CREAT | LOG_VF, "%s\t給%s\t%d\t%s", cuser.userid, id, money - tax, ctime4(&now)); #ifdef PLAY_ANGEL - getuser(id); + getuser(id, &xuser); if (!strcmp(xuser.myangel, cuser.userid)){ mail_redenvelop( getkey("他是你的小主人,是否匿名?[Y/n]") == 'n' ? diff --git a/mbbsd/chat.c b/mbbsd/chat.c index cad6a09b..59cacb4b 100644 --- a/mbbsd/chat.c +++ b/mbbsd/chat.c @@ -210,10 +210,11 @@ chat_query(char *arg) { char *uid; int tuid; + userec_t xuser; printchatline(""); strtok(arg, str_space); - if ((uid = strtok(NULL, str_space)) && (tuid = getuser(uid))) { + if ((uid = strtok(NULL, str_space)) && (tuid = getuser(uid, &xuser))) { char buf[128], *ptr; FILE *fp; diff --git a/mbbsd/chc.c b/mbbsd/chc.c index 49618547..3682e217 100644 --- a/mbbsd/chc.c +++ b/mbbsd/chc.c @@ -935,6 +935,7 @@ static void chc_init_play_func(chcusr_t *user1, chcusr_t *user2, play_func_t play_func[2]) { char userid[2][IDLEN + 1]; + userec_t xuser; if (chc_mode & CHC_PERSONAL) { strlcpy(userid[0], cuser.userid, sizeof(userid[0])); @@ -954,9 +955,9 @@ chc_init_play_func(chcusr_t *user1, chcusr_t *user2, play_func_t play_func[2]) play_func[chc_my ^ 1] = hisplay; } - getuser(userid[0]); + getuser(userid[0], &xuser); chcusr_get(&xuser, user1); - getuser(userid[1]); + getuser(userid[1], &xuser); chcusr_get(&xuser, user2); } @@ -1002,6 +1003,7 @@ static int chc_init(int s, chcusr_t *user1, chcusr_t *user2, board_t board, play_func_t play_func[2]) { userinfo_t *my = currutmp; + userec_t xuser; if (chc_mode & CHC_WATCH) setutmpmode(CHESSWATCHING); diff --git a/mbbsd/chicken.c b/mbbsd/chicken.c index 7de5c848..e4928ea4 100644 --- a/mbbsd/chicken.c +++ b/mbbsd/chicken.c @@ -85,7 +85,7 @@ static const short time_change[NUM_KINDS][14] = int reload_chicken(void) { - + userec_t xuser; chicken_t *mychicken = &cuser.mychicken; passwd_query(usernum, &xuser); @@ -891,8 +891,7 @@ chickenpk(int fd) strlcpy(mateid, currutmp->mateid, sizeof(mateid)); /* 把對手的id用local buffer記住 */ - getuser(mateid); - memcpy(&ouser, &xuser, sizeof(userec_t)); + getuser(mateid, &ouser); reload_chicken(); if (!ochicken->name[0] || !mychicken->name[0]) { bell(); @@ -907,8 +906,7 @@ chickenpk(int fd) while (1) { r = random(); ch = igetch(); - getuser(mateid); - memcpy(&ouser, &xuser, sizeof(userec_t)); + getuser(mateid, &ouser); reload_chicken(); show_chicken_data(ochicken, mychicken); time_diff(mychicken); diff --git a/mbbsd/gomo.c b/mbbsd/gomo.c index c78c5e49..3d2539e6 100644 --- a/mbbsd/gomo.c +++ b/mbbsd/gomo.c @@ -350,6 +350,7 @@ gomoku(int fd) int scr_need_redraw; char ku[BRDSIZ][BRDSIZ]; char genbuf[200]; + userec_t xuser; HO_init(ku, pool); me = !(my->turn) + 1; @@ -392,7 +393,7 @@ gomoku(int fd) draw_photo = 1; } - getuser(my->mateid); + getuser(my->mateid, &xuser); if (draw_photo) { int line; FILE* fp; diff --git a/mbbsd/mail.c b/mbbsd/mail.c index dd336f6a..44ea13ce 100644 --- a/mbbsd/mail.c +++ b/mbbsd/mail.c @@ -223,12 +223,13 @@ do_send(char *userid, char *title) char receiver[IDLEN + 1]; char genbuf[200]; int internet_mail, i; + userec_t xuser; if (strchr(userid, '@')) internet_mail = 1; else { internet_mail = 0; - if (!getuser(userid)) + if (!getuser(userid, &xuser)) return -1; if (!(xuser.userlevel & PERM_READMAIL)) return -3; diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index 2bfe7173..136d5c08 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -145,7 +145,6 @@ setflags(int mask, int value) void u_exit(char *mode) { - //userec_t xuser; int diff = (time(0) - login_start_time) / 60; int dirty = currmode & MODE_DIRTY; diff --git a/mbbsd/read.c b/mbbsd/read.c index cf471688..233e70d1 100644 --- a/mbbsd/read.c +++ b/mbbsd/read.c @@ -653,8 +653,7 @@ i_read_key(const onekey_t * rcmdlist, keeploc_t * locmem, sizeof(currauthor)); stand_title("使用者設定"); move(1, 0); - if ((id = getuser(headers[locmem->crs_ln - locmem->top_ln].owner))) { - memcpy(&muser, &xuser, sizeof(muser)); + if ((id = getuser(headers[locmem->crs_ln - locmem->top_ln].owner, &muser))) { user_display(&muser, 1); uinfo_query(&muser, 1, id); } diff --git a/mbbsd/register.c b/mbbsd/register.c index f2413f39..7786c26e 100644 --- a/mbbsd/register.c +++ b/mbbsd/register.c @@ -208,6 +208,9 @@ new_register(void) more("etc/register", NA); try = 0; while (1) { + userec_t xuser; + int minute; + if (++try >= 6) { vmsg("您嘗試錯誤的輸入太多,請下次再來吧"); exit(1); @@ -218,12 +221,12 @@ new_register(void) if (bad_user_id(passbuf)) outs("無法接受這個代號,請使用英文字母,並且不要包含空格\n"); - else if ((id = getuser(passbuf)) && - (id = check_and_expire_account(id, &xuser)) >= 0) { - if (id == 999999) + else if ((id = getuser(passbuf, &xuser)) && + (minute = check_and_expire_account(id, &xuser)) >= 0) { + if (minute == 999999) // XXX magic number outs("此代號已經有人使用 是不死之身"); else { - prints("此代號已經有人使用 還有%d天才過期 \n", id / (60 * 24)); + prints("此代號已經有人使用 還有%d天才過期 \n", minute / (60 * 24)); } } else break; diff --git a/mbbsd/talk.c b/mbbsd/talk.c index 0c8004fe..b3b58e89 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -355,7 +355,8 @@ my_kick(userinfo_t * uentp) static void chicken_query(char *userid) { - if (getuser(userid)) { + userec_t xuser; + if (getuser(userid, &xuser)) { if (xuser.mychicken.name[0]) { time_diff(&(xuser.mychicken)); if (!isdeadth(&(xuser.mychicken))) { @@ -386,8 +387,7 @@ my_query(char *uident) MSG_LITTLE_BOY, MSG_LITTLE_GIRL, MSG_MAN, MSG_WOMAN, MSG_PLANT, MSG_MIME}; - if ((tuid = getuser(uident))) { - memcpy(&muser, &xuser, sizeof(muser)); + if ((tuid = getuser(uident, &muser))) { move(1, 0); clrtobot(); move(1, 0); @@ -1364,6 +1364,7 @@ my_talk(userinfo_t * uin, int fri_stat, char defact) char c; char genbuf[4]; unsigned char mode0 = currutmp->mode; + userec_t xuser; genbuf[0] = defact; ch = uin->mode; @@ -1451,7 +1452,7 @@ my_talk(userinfo_t * uin, int fri_stat, char defact) break; case 'p': reload_chicken(); - getuser(uin->userid); + getuser(uin->userid, &xuser); if (uin->lockmode == CHICKEN || currutmp->lockmode == CHICKEN) error = 1; if (!cuser.mychicken.name[0] || !xuser.mychicken.name[0]) @@ -2463,8 +2464,7 @@ userlist(void) strlcpy(currauthor, uentp->userid, sizeof(currauthor)); stand_title("使用者設定"); move(1, 0); - if ((id = getuser(uentp->userid)) > 0) { - memcpy(&muser, &xuser, sizeof(muser)); + if ((id = getuser(uentp->userid, &muser)) > 0) { user_display(&muser, 1); uinfo_query(&muser, 1, id); } @@ -2870,6 +2870,7 @@ talkreply(void) char genbuf[200]; int a, sig = currutmp->sig; int currstat0 = currstat; + userec_t xuser; uip = &SHM->uinfo[currutmp->destuip]; snprintf(page_requestor, sizeof(page_requestor), @@ -2892,7 +2893,7 @@ talkreply(void) prints(" (1) %s?先拿100銀兩來" " (2) %s?先拿1000銀兩來..\n\n", sig_des[sig], sig_des[sig]); - getuser(uip->userid); + getuser(uip->userid, &xuser); currutmp->msgs[0].pid = uip->pid; strlcpy(currutmp->msgs[0].userid, uip->userid, sizeof(currutmp->msgs[0].userid)); strlcpy(currutmp->msgs[0].last_call_in, "呼叫、呼叫,聽到請回答 (Ctrl-R)", @@ -3141,9 +3142,10 @@ static void TalkToAngel(){ userinfo_t* uent; static int AngelPermChecked = 0; + userec_t xuser; if (cuser.myangel[0] && !AngelPermChecked) { - getuser(cuser.myangel); + getuser(cuser.myangel, &xuser); // XXX if user doesn't exist if (!(xuser.userlevel & PERM_ANGEL)) cuser.myangel[0] = 0; } diff --git a/mbbsd/user.c b/mbbsd/user.c index a0a136ff..a66a21b1 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -436,9 +436,10 @@ uinfo_query(userec_t * u, int real, int unum) #ifdef PLAY_ANGEL if (real) while (1) { + userec_t xuser; getdata_str(i, 0, "小天使:", buf, IDLEN + 1, DOECHO, x.myangel); - if(buf[0] == 0 || (getuser(buf) && + if(buf[0] == 0 || (getuser(buf, &xuser) && (xuser.userlevel & PERM_ANGEL))){ strlcpy(x.myangel, buf, IDLEN + 1); ++i; @@ -618,7 +619,7 @@ uinfo_query(userec_t * u, int real, int unum) outs("\n不輸入則無法更改\n"); fail++; break; - } else if (!(uid = getuser(witness[i]))) { + } else if (!(uid = searchuser(witness[i]))) { outs("\n查無此使用者\n"); fail++; break; @@ -824,6 +825,7 @@ showplans(char *uid) if (user_query_mode) { int i = 0; FILE *fp; + userec_t xuser; sethomefile(genbuf, uid, chess_photo_name[user_query_mode - 1]); if ((fp = fopen(genbuf, "r")) != NULL) @@ -846,8 +848,7 @@ showplans(char *uid) i++; } - if (strcmp(xuser.userid, uid) != 0) - getuser(uid); // update xuser + getuser(uid, &xuser); if (user_query_mode == 1) { win = xuser.five_win; lost = xuser.five_lose; @@ -1385,7 +1386,7 @@ u_register(void) if (strcmp(inregcode, getregcode(regcode)) == 0) { int unum; - if ((unum = getuser(cuser.userid)) == 0) { + if ((unum = searchuser(cuser.userid)) == 0) { vmsg("系統錯誤,查無此人!"); u_exit("getuser error"); exit(0); diff --git a/mbbsd/var.c b/mbbsd/var.c index 95cdad2e..33c7fc0d 100644 --- a/mbbsd/var.c +++ b/mbbsd/var.c @@ -97,7 +97,6 @@ time4_t login_start_time; time4_t start_time; time4_t paste_time; userec_t cuser; /* current user structure */ -userec_t xuser; /* lookup user structure */ crosspost_t postrecord; /* anti cross post */ unsigned int currbrdattr; unsigned int currstat; |