summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/admin.c14
-rw-r--r--mbbsd/announce.c16
-rw-r--r--mbbsd/bbs.c116
-rw-r--r--mbbsd/board.c26
-rw-r--r--mbbsd/cache.c6
-rw-r--r--mbbsd/cal.c63
-rw-r--r--mbbsd/calendar.c4
-rw-r--r--mbbsd/card.c16
-rw-r--r--mbbsd/chat.c10
-rw-r--r--mbbsd/chc.c12
-rw-r--r--mbbsd/chicken.c34
-rw-r--r--mbbsd/dice.c18
-rw-r--r--mbbsd/edit.c34
-rw-r--r--mbbsd/fav.c2
-rw-r--r--mbbsd/friend.c4
-rw-r--r--mbbsd/gamble.c6
-rw-r--r--mbbsd/gomo.c69
-rw-r--r--mbbsd/guess.c26
-rw-r--r--mbbsd/indict.c2
-rw-r--r--mbbsd/kaede.c12
-rw-r--r--mbbsd/lovepaper.c6
-rw-r--r--mbbsd/mail.c106
-rw-r--r--mbbsd/mbbsd.c173
-rw-r--r--mbbsd/menu.c9
-rw-r--r--mbbsd/othello.c16
-rw-r--r--mbbsd/page.c4
-rw-r--r--mbbsd/passwd.c30
-rw-r--r--mbbsd/read.c4
-rw-r--r--mbbsd/register.c34
-rw-r--r--mbbsd/stuff.c7
-rw-r--r--mbbsd/syspost.c14
-rw-r--r--mbbsd/talk.c70
-rw-r--r--mbbsd/user.c167
-rw-r--r--mbbsd/var.c2
-rw-r--r--mbbsd/vote.c4
-rw-r--r--mbbsd/voteboard.c22
-rw-r--r--mbbsd/xyz.c12
37 files changed, 585 insertions, 585 deletions
diff --git a/mbbsd/admin.c b/mbbsd/admin.c
index 8960d322..7af794c7 100644
--- a/mbbsd/admin.c
+++ b/mbbsd/admin.c
@@ -24,7 +24,7 @@ m_loginmsg()
{
SHM->loginmsg.pid=currutmp->pid; /*站長不多 就不管race condition */
strcpy(SHM->loginmsg.last_call_in, msg);
- strcpy(SHM->loginmsg.userid, cuser.userid);
+ strcpy(SHM->loginmsg.userid, cuser->userid);
}
return 0;
}
@@ -354,7 +354,7 @@ m_mod_board(char *bname)
system(genbuf);
memset(&bh, 0, sizeof(bh));
snprintf(bh.title, sizeof(bh.title),
- "%s 看板 %s 刪除", bname, cuser.userid);
+ "%s 看板 %s 刪除", bname, cuser->userid);
post_msg("Security", bh.title, "請注意刪除的合法性", "[系統安全局]");
substitute_record(fn_board, &bh, sizeof(bh), bid);
reset_board(bid);
@@ -884,7 +884,7 @@ scan_register_form(char *regfile, int automode, int neednum)
int n = 0, unum = 0;
int nSelf = 0, nAuto = 0;
- uid = cuser.userid;
+ uid = cuser->userid;
snprintf(fname, sizeof(fname), "%s.tmp", regfile);
move(2, 0);
if (dashf(fname)) {
@@ -933,7 +933,7 @@ scan_register_form(char *regfile, int automode, int neednum)
uid = autoid;
if ((!automode || !auto_scan(fdata, ans))) {
- uid = cuser.userid;
+ uid = cuser->userid;
move(1, 0);
prints("帳號位置 :%d\n", unum);
@@ -1016,7 +1016,7 @@ scan_register_form(char *regfile, int automode, int neednum)
sethomepath(buf1, muser.userid);
stampfile(buf1, &mhdr);
- strlcpy(mhdr.owner, cuser.userid, sizeof(mhdr.owner));
+ strlcpy(mhdr.owner, cuser->userid, sizeof(mhdr.owner));
strlcpy(mhdr.title, "[註冊失敗]", TTLEN);
mhdr.filemode = 0;
sethomedir(title, muser.userid);
@@ -1104,10 +1104,10 @@ scan_register_form(char *regfile, int automode, int neednum)
* &xfile); strcpy(xfile.owner, "系統"); strcpy(xfile.title, "[報告]
* 審核記錄"); xptr = fopen(xfpath, "w"); fprintf(xptr, "\n時間:%s %s
* 審了 %d 份註冊單\n AutoScan 審了 %d 份註冊單\n 共計 %d 份。", buf,
- * cuser.userid, nSelf, nAuto, nSelf+nAuto); fclose(xptr); setbdir(fname,
+ * cuser->userid, nSelf, nAuto, nSelf+nAuto); fclose(xptr); setbdir(fname,
* xboard); append_record(fname, &xfile, sizeof(xfile));
* outgo_post(&xfile, xboard); touchbtotal(getbnum(xboard));
- * cuser.numposts++;
+ * cuser->numposts++;
*/
/*********************************************/
pressanykey();
diff --git a/mbbsd/announce.c b/mbbsd/announce.c
index 3bb1aad5..a7cd016f 100644
--- a/mbbsd/announce.c
+++ b/mbbsd/announce.c
@@ -299,7 +299,7 @@ a_newitem(menu_t * pm, int mode)
break;
}
- strlcpy(item.owner, cuser.userid, sizeof(item.owner));
+ strlcpy(item.owner, cuser->userid, sizeof(item.owner));
a_additem(pm, &item);
}
@@ -364,7 +364,7 @@ a_pasteitem(menu_t * pm, int mode)
igetch();
return;
}
- strlcpy(item.owner, *copyowner ? copyowner : cuser.userid,
+ strlcpy(item.owner, *copyowner ? copyowner : cuser->userid,
sizeof(item.owner));
strlcpy(item.title, copytitle, sizeof(item.title));
a_additem(pm, &item);
@@ -441,7 +441,7 @@ a_pastetagpost(menu_t * pm, int mode)
char dirname[200], buf[200];
if (TagBoard == 0){
- sethomedir(dirname, cuser.userid);
+ sethomedir(dirname, cuser->userid);
}
else{
bh = getbcache(TagBoard);
@@ -455,7 +455,7 @@ a_pastetagpost(menu_t * pm, int mode)
while (tagnum--) {
EnumTagFhdr(&fhdr, dirname, ent++);
if (TagBoard == 0)
- sethomefile(buf, cuser.userid, fhdr.filename);
+ sethomefile(buf, cuser->userid, fhdr.filename);
else
setbfile(buf, bh->brdname, fhdr.filename);
@@ -565,7 +565,7 @@ a_delete(menu_t * pm)
setbpath(buf, "deleted");
stampfile(buf, &backup);
- strlcpy(backup.owner, cuser.userid, sizeof(backup.owner));
+ strlcpy(backup.owner, cuser->userid, sizeof(backup.owner));
strlcpy(backup.title,
pm->header[pm->now - pm->page].title + 2,
sizeof(backup.title));
@@ -590,7 +590,7 @@ a_delete(menu_t * pm)
"rm -rf %s;/bin/mv -f %s %s", buf, fpath, buf);
system(cmd);
- strlcpy(backup.owner, cuser.userid, sizeof(backup.owner));
+ strlcpy(backup.owner, cuser->userid, sizeof(backup.owner));
strlcpy(backup.title,
pm->header[pm->now - pm->page].title + 2,
sizeof(backup.title));
@@ -846,7 +846,7 @@ a_menu(char *maintitle, char *path, int lastlevel)
fhdr.filename,
sizeof(me.header[me.now - me.page].filename));
strlcpy(me.header[me.now - me.page].owner,
- cuser.userid,
+ cuser->userid,
sizeof(me.header[me.now - me.page].owner));
setadir(fpath, path);
substitute_record(fpath, me.header + me.now - me.page,
@@ -1191,7 +1191,7 @@ void BlogMain(int num)
sprintf(fpath, "man/boards/%c/%s", currboard[0], currboard);
stampdir(fpath, &item);
strlcpy(item.title, "◆ Blog", sizeof(item.title));
- strlcpy(item.owner, cuser.userid, sizeof(item.owner));
+ strlcpy(item.owner, cuser->userid, sizeof(item.owner));
sprintf(adir, "man/boards/%c/%s/.DIR", currboard[0], currboard);
append_record(adir, &item, FHSZ);
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index 1a455c75..1c75e1a6 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -14,16 +14,14 @@ mail_by_link(char *owner, char *title, char *path)
{
char genbuf[200];
fileheader_t mymail;
-
- snprintf(genbuf, sizeof(genbuf),
- BBSHOME "/home/%c/%s", cuser.userid[0], cuser.userid);
+
+ sethomepath(genbuf, cuser->userid);
stampfile(genbuf, &mymail);
strlcpy(mymail.owner, owner, sizeof(mymail.owner));
snprintf(mymail.title, sizeof(mymail.title), title);
unlink(genbuf);
Link(path, genbuf);
- snprintf(genbuf, sizeof(genbuf),
- BBSHOME "/home/%c/%s/.DIR", cuser.userid[0], cuser.userid);
+ sethomedir(genbuf, cuser->userid);
append_record(genbuf, &mymail, sizeof(mymail));
}
@@ -36,15 +34,16 @@ anticrosspost()
snprintf(buf, sizeof(buf),
"\033[1;33;46m%s \033[37;45mcross post 文章 \033[37m %s\033[m\n",
- cuser.userid, ctime(&now));
+ cuser->userid, ctime(&now));
log_file("etc/illegal_money", buf, 1);
- post_violatelaw(cuser.userid, "Ptt系統警察", "Cross-post", "罰單處份");
- cuser.userlevel |= PERM_VIOLATELAW;
- cuser.vl_count++;
+ post_violatelaw(cuser->userid, "Ptt系統警察", "Cross-post", "罰單處份");
+ cuser->userlevel |= PERM_VIOLATELAW;
+ cuser->vl_count++;
mail_by_link("Ptt警察部隊", "Cross-Post罰單",
BBSHOME "/etc/crosspost.txt");
- passwd_update(usernum, &cuser);
+ //passwd_update(usernum, &cuser);
+ u_exit("Cross Post");
exit(0);
}
@@ -58,16 +57,16 @@ save_violatelaw()
clear();
stand_title("繳罰單中心");
- if (!(cuser.userlevel & PERM_VIOLATELAW)) {
+ if (!(cuser->userlevel & PERM_VIOLATELAW)) {
mprints(22, 0, "\033[1;31m你無聊啊? 你又沒有被開罰單~~\033[m");
pressanykey();
return 0;
}
reload_money();
- if (cuser.money < (int)cuser.vl_count * 1000) {
+ if (cuser->money < (int)cuser->vl_count * 1000) {
snprintf(buf, sizeof(buf), "\033[1;31m這是你第 %d 次違反本站法規"
"必須繳出 %d $Ptt ,你只有 %d 元, 錢不夠啦!!\033[m",
- (int)cuser.vl_count, (int)cuser.vl_count * 1000, cuser.money);
+ (int)cuser->vl_count, (int)cuser->vl_count * 1000, cuser->money);
mprints(22, 0, buf);
pressanykey();
return 0;
@@ -85,7 +84,7 @@ save_violatelaw()
return 0;
}
snprintf(buf, sizeof(buf), "這是你第 %d 次違法 必須繳出 %d $Ptt",
- cuser.vl_count, cuser.vl_count * 1000);
+ cuser->vl_count, cuser->vl_count * 1000);
mprints(11, 0, buf);
if (!getdata(10, 0, "要付錢[y/n]:", ok, sizeof(ok), LCECHO) ||
@@ -95,9 +94,9 @@ save_violatelaw()
pressanykey();
return 0;
}
- demoney(-1000 * cuser.vl_count);
- cuser.userlevel &= (~PERM_VIOLATELAW);
- passwd_update(usernum, &cuser);
+ demoney(-1000 * cuser->vl_count);
+ cuser->userlevel &= (~PERM_VIOLATELAW);
+// passwd_update(usernum, &cuser);
return 0;
}
@@ -341,7 +340,7 @@ outgo_post(fileheader_t * fh, char *board)
if ((foo = fopen("innd/out.bntp", "a"))) {
fprintf(foo, "%s\t%s\t%s\t%s\t%s\n", board,
- fh->filename, cuser.userid, cuser.username, fh->title);
+ fh->filename, cuser->userid, cuser->username, fh->title);
fclose(foo);
}
}
@@ -377,7 +376,7 @@ cancelpost(fileheader_t * fh, int by_BM, char *newpath)
if ((fout = fopen("innd/cancel.bntp", "a"))) {
fprintf(fout, "%s\t%s\t%s\t%s\t%s\n", currboard, fh->filename,
- cuser.userid, nick, fh->title);
+ cuser->userid, nick, fh->title);
fclose(fout);
}
fclose(fin);
@@ -420,7 +419,7 @@ do_unanonymous_post(char *fpath)
stampfile(genbuf, &mhdr);
unlink(genbuf);
Link(fpath, genbuf);
- strlcpy(mhdr.owner, cuser.userid, sizeof(mhdr.owner));
+ strlcpy(mhdr.owner, cuser->userid, sizeof(mhdr.owner));
strlcpy(mhdr.title, save_title, sizeof(mhdr.title));
mhdr.filemode = 0;
setbdir(title, "UnAnonymous");
@@ -529,7 +528,7 @@ do_general(int isbid)
if (!(currmode & MODE_POST)
#ifdef FOREIGN_REG
// 不是外籍使用者在 PttForeign 板
- && !((cuser.uflag2 & FOREIGN) && strcmp(bp->brdname, "PttForeign") == 0)
+ && !((cuser->uflag2 & FOREIGN) && strcmp(bp->brdname, "PttForeign") == 0)
#endif
) {
move(5, 10);
@@ -656,9 +655,9 @@ do_general(int isbid)
owner = real_name;
ifuseanony = 1;
} else
- owner = cuser.userid;
+ owner = cuser->userid;
#else
- owner = cuser.userid;
+ owner = cuser->userid;
#endif
/* 錢 */
aborted = (aborted > MAX_POST_MONEY * 2) ? MAX_POST_MONEY : aborted / 2;
@@ -701,7 +700,7 @@ do_general(int isbid)
aborted = (aborted > MAX_POST_MONEY) ? MAX_POST_MONEY : aborted;
#endif
if (strcmp(currboard, "Test") && !ifuseanony) {
- prints("這是您的第 %d 篇文章。",++cuser.numposts);
+ prints("這是您的第 %d 篇文章。",++cuser->numposts);
if(postfile.filemode&FILE_BID)
prints("招標文章沒有稿酬。");
else if(currbrdattr&BRD_BAD)
@@ -711,7 +710,7 @@ do_general(int isbid)
prints(" 稿酬 %d 銀。",aborted);
demoney(aborted);
}
- passwd_update(usernum, &cuser); /* post 數 */
+ // passwd_update(usernum, &cuser); /* post 數 */
} else
outs("測試信件不列入紀錄,敬請包涵。");
@@ -735,7 +734,7 @@ do_general(int isbid)
unlink(genbuf);
Link(fpath, genbuf);
- strlcpy(postfile.owner, cuser.userid, sizeof(postfile.owner));
+ strlcpy(postfile.owner, cuser->userid, sizeof(postfile.owner));
strlcpy(postfile.title, save_title, sizeof(postfile.title));
sethomedir(genbuf, quote_user);
if (append_record(genbuf, &postfile, sizeof(postfile)) == -1)
@@ -942,7 +941,7 @@ edit_post(int ent, fileheader_t * fhdr, char *direct)
return DONOTHING;
if( !HAS_PERM(PERM_SYSOP) &&
- (!(currmode & MODE_POST) || strcmp(fhdr->owner, cuser.userid) != 0) )
+ (!(currmode & MODE_POST) || strcmp(fhdr->owner, cuser->userid) != 0) )
return DONOTHING;
if( currmode & MODE_SELECT )
@@ -1052,7 +1051,7 @@ cross_post(int ent, fileheader_t * fhdr, char *direct)
}
ent = 1;
- if (HAS_PERM(PERM_SYSOP) || !strcmp(fhdr->owner, cuser.userid)) {
+ if (HAS_PERM(PERM_SYSOP) || !strcmp(fhdr->owner, cuser->userid)) {
getdata(2, 0, "(1)原文轉載 (2)舊轉錄格式?[1] ",
genbuf, 3, DOECHO);
if (genbuf[0] != '2') {
@@ -1083,7 +1082,7 @@ cross_post(int ent, fileheader_t * fhdr, char *direct)
if (author)
strlcpy(xfile.owner, fhdr->owner, sizeof(xfile.owner));
else
- strlcpy(xfile.owner, cuser.userid, sizeof(xfile.owner));
+ strlcpy(xfile.owner, cuser->userid, sizeof(xfile.owner));
strlcpy(xfile.title, xtitle, sizeof(xfile.title));
if (genbuf[0] == 'l') {
xfile.filemode = FILE_LOCAL;
@@ -1111,7 +1110,7 @@ cross_post(int ent, fileheader_t * fhdr, char *direct)
if (!xfile.filemode && !(bp->brdattr & BRD_NOTRAN))
outgo_post(&xfile, xboard);
setbtotal(getbnum(xboard));
- cuser.numposts++;
+ cuser->numposts++;
UPDATE_USEREC;
outs("文章轉錄完成");
pressanykey();
@@ -1371,7 +1370,7 @@ hold_gamble(int ent, fileheader_t * fhdr, char *direct)
move(8 + i, 0);
prints("賭盤設定完成");
snprintf(genbuf, sizeof(genbuf), "[公告] %s 板 開始賭博!", currboard);
- post_msg(currboard, genbuf, msg, cuser.userid);
+ post_msg(currboard, genbuf, msg, cuser->userid);
post_msg("Record", genbuf + 7, msg, "[馬路探子]");
/* Tim 控制CS, 以免正在玩的user把資料已經寫進來 */
rename(fn_ticket_end, fn_ticket);
@@ -1403,7 +1402,7 @@ edit_title(int ent, fileheader_t * fhdr, char *direct)
fileheader_t tmpfhdr = *fhdr;
int dirty = 0;
- if (currmode & MODE_BOARD || !strcmp(cuser.userid, fhdr->owner)) {
+ if (currmode & MODE_BOARD || !strcmp(cuser->userid, fhdr->owner)) {
if (getdata(b_lines - 1, 0, "標題:", genbuf, TTLEN, DOECHO)) {
strlcpy(tmpfhdr.title, genbuf, sizeof(tmpfhdr.title));
dirty++;
@@ -1419,7 +1418,7 @@ edit_title(int ent, fileheader_t * fhdr, char *direct)
dirty++;
}
}
- if (currmode & MODE_BOARD || !strcmp(cuser.userid, fhdr->owner)) {
+ if (currmode & MODE_BOARD || !strcmp(cuser->userid, fhdr->owner)) {
getdata(b_lines - 1, 0, "確定(Y/N)?[n] ", genbuf, 3, DOECHO);
if ((genbuf[0] == 'y' || genbuf[0] == 'Y') && dirty) {
*fhdr = tmpfhdr;
@@ -1563,13 +1562,13 @@ do_bid(int ent, fileheader_t * fhdr, boardheader_t *bp, char *direct, struct t
prints("起標價: %d", bidinfo.high);
next=bidinfo.high;
}
- if(!strcmp(cuser.userid,bidinfo.userid))
+ if(!strcmp(cuser->userid,bidinfo.userid))
{
prints("你是最高得標者!");
pressanykey();
return FULLUPDATE;
}
- if (strcmp(cuser.userid, fhdr->owner) == 0){
+ if (strcmp(cuser->userid, fhdr->owner) == 0){
vmsg("警告! 本人不能出價!");
return FULLUPDATE;
}
@@ -1592,7 +1591,7 @@ do_bid(int ent, fileheader_t * fhdr, boardheader_t *bp, char *direct, struct t
next=bidinfo.high + bidinfo.increment;
- if(mymax< next || (bidinfo.payby==0 && cuser.money<mymax ))
+ if(mymax< next || (bidinfo.payby==0 && cuser->money<mymax ))
{
vmsg("取消下標或標金不足搶標");
return FULLUPDATE;
@@ -1600,8 +1599,8 @@ do_bid(int ent, fileheader_t * fhdr, boardheader_t *bp, char *direct, struct t
snprintf(genbuf, sizeof(genbuf),
"\033[1;31m→ \033[33m%s\033[m\033[33m:%s\033[m%*s %s%-15d標%15s %02d/%02d\n",
- cuser.userid,say,
- 31 - strlen(cuser.userid) - strlen(say), " ",
+ cuser->userid,say,
+ 31 - strlen(cuser->userid) - strlen(say), " ",
money,
next, fromhost,
ptime->tm_mon + 1, ptime->tm_mday);
@@ -1610,19 +1609,19 @@ do_bid(int ent, fileheader_t * fhdr, boardheader_t *bp, char *direct, struct t
{
bidinfo.usermax=mymax;
bidinfo.high=next;
- strcpy(bidinfo.userid,cuser.userid);
+ strcpy(bidinfo.userid,cuser->userid);
}
else if(mymax>bidinfo.usermax)
{
bidinfo.high=bidinfo.usermax+bidinfo.increment;
if(bidinfo.high>mymax) bidinfo.high=mymax;
bidinfo.usermax=mymax;
- strcpy(bidinfo.userid,cuser.userid);
+ strcpy(bidinfo.userid,cuser->userid);
snprintf(genbuf, sizeof(genbuf),
"\033[1;31m→ \033[33m自動競標%s勝出\033[m\033[33m\033[m%*s%s%-15d標 %02d/%02d\n",
- cuser.userid,
- 20 - strlen(cuser.userid) , " ",money,
+ cuser->userid,
+ 20 - strlen(cuser->userid) , " ",money,
bidinfo.high,
ptime->tm_mon + 1, ptime->tm_mday);
do_add_recommend(direct, fhdr, ent, genbuf);
@@ -1675,12 +1674,12 @@ recommend(int ent, fileheader_t * fhdr, char *direct)
}
setdirpath(path, direct, fhdr->filename);
- if (fhdr->recommend == 0 && strcmp(cuser.userid, fhdr->owner) == 0){
+ if (fhdr->recommend == 0 && strcmp(cuser->userid, fhdr->owner) == 0){
vmsg("警告! 本人不能推薦第一次!");
return FULLUPDATE;
}
#ifndef DEBUG
- if (!(currmode & MODE_BOARD) && getuser(cuser.userid) &&
+ if (!(currmode & MODE_BOARD) && getuser(cuser->userid) &&
now - lastrecommend < 40) {
move(b_lines - 1, 0);
prints("離上次推薦時間太近囉, 請多花點時間仔細閱\讀文章!");
@@ -1699,8 +1698,8 @@ recommend(int ent, fileheader_t * fhdr, char *direct)
snprintf(buf, sizeof(buf),
"\033[1;31m→ \033[33m%s\033[m\033[33m:%s\033[m%*s推%15s %02d/%02d\n",
- cuser.userid, path,
- 51 - strlen(cuser.userid) - strlen(path), " ", fromhost,
+ cuser->userid, path,
+ 51 - strlen(cuser->userid) - strlen(path), " ", fromhost,
ptime->tm_mon + 1, ptime->tm_mday);
do_add_recommend(direct, fhdr, ent, buf);
#ifdef ASSESS
@@ -1796,7 +1795,7 @@ del_range(int ent, fileheader_t *fhdr, char *direct)
fileheader_t rsfh;
int i = inum1, now;
if (currstat == RMAIL)
- sethomedir(genbuf, cuser.userid);
+ sethomedir(genbuf, cuser->userid);
else
setbdir(genbuf, currboard);
if ((fd = (open(direct, O_RDONLY, 0))) != -1) {
@@ -1849,10 +1848,10 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
(fhdr->owner[0] == '-'))
return DONOTHING;
- not_owned = strcmp(fhdr->owner, cuser.userid);
+ not_owned = strcmp(fhdr->owner, cuser->userid);
if ((!(currmode & MODE_BOARD) && not_owned) ||
((bp->brdattr & BRD_VOTEBOARD) && !HAS_PERM(PERM_SYSOP)) ||
- !strcmp(cuser.userid, STR_GUEST))
+ !strcmp(cuser->userid, STR_GUEST))
return DONOTHING;
getdata(1, 0, msg_del_ny, genbuf, 3, LCECHO);
@@ -1917,7 +1916,7 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
xuser.userlevel |= PERM_VIOLATELAW;
}
sprintf(genbuf,"劣文退回(%s):%-40.40s", reason, fhdr->title);
- mail_id(xuser.userid, genbuf, newpath, cuser.userid);
+ mail_id(xuser.userid, genbuf, newpath, cuser->userid);
}
}
#undef SIZE
@@ -1930,16 +1929,15 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
deumoney(num, -fhdr->money);
}
if (!not_owned && strcmp(currboard, "Test")) {
- if (cuser.numposts)
- cuser.numposts--;
- /* XXX: is_BM(cuser.userid) is always true @_@ */
+ if (cuser->numposts)
+ cuser->numposts--;
if (!(currmode & MODE_DIGEST && currmode & MODE_BOARD)){
move(b_lines - 1, 0);
clrtoeol();
demoney(-fhdr->money);
- passwd_update(usernum, &cuser); /* post 數 */
+ // passwd_update(usernum, &cuser); /* post 數 */
prints("%s,您的文章減為 %d 篇,支付清潔費 %d 銀", msg_del_ok,
- cuser.numposts, fhdr->money);
+ cuser->numposts, fhdr->money);
refresh();
pressanykey();
}
@@ -2015,7 +2013,7 @@ tar_addqueue(int ent, fileheader_t * fhdr, char *direct)
return FULLUPDATE;
}
fp = fopen(qfn, "w");
- fprintf(fp, "%s\n", cuser.userid);
+ fprintf(fp, "%s\n", cuser->userid);
fprintf(fp, "%s\n", email);
fprintf(fp, "%d,%d\n", bakboard, bakman);
fclose(fp);
@@ -2257,11 +2255,11 @@ board_select()
char genbuf[100];
currmode &= ~MODE_SELECT;
- snprintf(fpath, sizeof(fpath), "SR.%s", cuser.userid);
+ snprintf(fpath, sizeof(fpath), "SR.%s", cuser->userid);
setbfile(genbuf, currboard, fpath);
unlink(genbuf);
if (currstat == RMAIL)
- sethomedir(currdirect, cuser.userid);
+ sethomedir(currdirect, cuser->userid);
else
setbdir(currdirect, currboard);
return NEWDIRECT;
@@ -2673,7 +2671,7 @@ log_board(char *mode, time_t usetime)
if (usetime > 30) {
snprintf(buf, sizeof(buf), "USE %-20.20s Stay: %5ld (%s) %s\n",
- mode, usetime, cuser.userid, ctime(&now));
+ mode, usetime, cuser->userid, ctime(&now));
log_file(FN_USEBOARD, buf, 1);
}
}
diff --git a/mbbsd/board.c b/mbbsd/board.c
index 525cc020..dff9d9b0 100644
--- a/mbbsd/board.c
+++ b/mbbsd/board.c
@@ -129,7 +129,7 @@ brc_insert_record(const char* board, int num, int* list)
void
brc_update(){
- if (brc_changed && cuser.userlevel && brc_num > 0)
+ if (brc_changed && cuser->userlevel && brc_num > 0)
brc_insert_record(currboard, brc_num, brc_list);
}
@@ -223,7 +223,7 @@ brc_addlist(const char *fname)
{
int ftime, n, i;
- if (!cuser.userlevel)
+ if (!cuser->userlevel)
return;
ftime = atoi(&fname[2]);
@@ -506,7 +506,7 @@ static void
load_boards(char *key)
{
boardheader_t *bptr = NULL;
- int type = cuser.uflag & BRDSORT_FLAG ? 1 : 0;
+ int type = cuser->uflag & BRDSORT_FLAG ? 1 : 0;
int i, n;
int state;
char byMALLOC = 0, needREALLOC = 0;
@@ -800,12 +800,12 @@ show_brdlist(int head, int clsflag, int newflag)
prints("%5d %c %sMyFavFolder\033[m 目錄 □%-34s\033[m",
head,
ptr->myattr & NBRD_TAG ? 'D' : ' ',
- !(cuser.uflag2 & FAVNOHILIGHT) ? "\033[1;36m" : "",
+ !(cuser->uflag2 & FAVNOHILIGHT) ? "\033[1;36m" : "",
title);
else
prints("%6d %sMyFavFolder\033[m 目錄 □%-34s\033[m",
get_data_number(get_fav_folder(getfolder(ptr->bid))),
- !(cuser.uflag2 & FAVNOHILIGHT) ? "\033[1;36m" : "",
+ !(cuser->uflag2 & FAVNOHILIGHT) ? "\033[1;36m" : "",
title);
continue;
}
@@ -833,7 +833,7 @@ show_brdlist(int head, int clsflag, int newflag)
else {
prints("%s%-13s\033[m%s%5.5s\033[0;37m%2.2s\033[m"
"%-34.34s",
- ((!(cuser.uflag2 & FAVNOHILIGHT) &&
+ ((!(cuser->uflag2 & FAVNOHILIGHT) &&
getboard(ptr->bid) != NULL))? "\033[1;36m" : "",
B_BH(ptr)->brdname,
color[(unsigned int)
@@ -901,7 +901,7 @@ set_menu_BM(char *BM)
{
if (HAS_PERM(PERM_ALLBOARD) || is_BM(BM)) {
currmode |= MODE_GROUPOP;
- cuser.userlevel |= PERM_SYSSUBOP;
+ cuser->userlevel |= PERM_SYSSUBOP;
}
}
@@ -924,7 +924,7 @@ choose_board(int newflag)
load_brdbuf();
++choose_board_depth;
brdnum = 0;
- if (!cuser.userlevel) /* guest yank all boards */
+ if (!cuser->userlevel) /* guest yank all boards */
yank_flag = 2;
do {
@@ -1073,7 +1073,7 @@ choose_board(int newflag)
case 'F':
case 'f':
if (class_bid>0 && HAS_PERM(PERM_SYSOP)) {
- bcache[class_bid - 1].firstchild[cuser.uflag & BRDSORT_FLAG ? 1 : 0]
+ bcache[class_bid - 1].firstchild[cuser->uflag & BRDSORT_FLAG ? 1 : 0]
= NULL;
brdnum = -1;
}
@@ -1099,7 +1099,7 @@ choose_board(int newflag)
fav_sort_by_class();
}
else
- cuser.uflag ^= BRDSORT_FLAG;
+ cuser->uflag ^= BRDSORT_FLAG;
brdnum = -1;
break;
case 'y':
@@ -1291,12 +1291,12 @@ choose_board(int newflag)
case 'Z':
if (HAS_PERM(PERM_LOGINOK)) {
char genbuf[256];
- sprintf(genbuf, "確定要 %s訂閱\ 新看板? [N/y] ", cuser.uflag2 & FAVNEW_FLAG ? "取消" : "");
+ sprintf(genbuf, "確定要 %s訂閱\ 新看板? [N/y] ", cuser->uflag2 & FAVNEW_FLAG ? "取消" : "");
if (getans(genbuf) != 'y')
break;
- cuser.uflag2 ^= FAVNEW_FLAG;
- if (cuser.uflag2 & FAVNEW_FLAG) {
+ cuser->uflag2 ^= FAVNEW_FLAG;
+ if (cuser->uflag2 & FAVNEW_FLAG) {
subscribe_newfav();
vmsg("切換為訂閱\新看板模式");
}
diff --git a/mbbsd/cache.c b/mbbsd/cache.c
index ff409191..bac961cb 100644
--- a/mbbsd/cache.c
+++ b/mbbsd/cache.c
@@ -492,7 +492,7 @@ setutmpmode(unsigned int mode)
if (HAS_PERM(PERM_LOGUSER)) {
char msg[200];
snprintf(msg, sizeof(msg), "%s setutmpmode to %s(%d) at %s",
- cuser.userid, modestring(currutmp, 0), mode, Cdate(&COMMON_TIME));
+ cuser->userid, modestring(currutmp, 0), mode, Cdate(&COMMON_TIME));
log_user(msg);
}
}
@@ -761,7 +761,7 @@ haspostperm(char *bname)
char buf[200];
setbfile(buf, bname, fn_water);
- if (belong(buf, cuser.userid))
+ if (belong(buf, cuser->userid))
return 0;
if (!strcasecmp(bname, DEFAULT_BOARD))
@@ -817,7 +817,7 @@ int is_BM_cache(int bid) /* bid starts from 1 */
currutmp->uid == SHM->BMcache[bid][1] ||
currutmp->uid == SHM->BMcache[bid][2] ||
currutmp->uid == SHM->BMcache[bid][3] ){
- cuser.userlevel |= PERM_BM;
+ cuser->userlevel |= PERM_BM;
return 1;
}
return 0;
diff --git a/mbbsd/cal.c b/mbbsd/cal.c
index d2cec676..29cacc98 100644
--- a/mbbsd/cal.c
+++ b/mbbsd/cal.c
@@ -59,21 +59,16 @@ unlockutmpmode()
int
vice(int money, char *item)
{
- char buf[128];
- unsigned int viceserial = (currutmp->lastact % 1000000) * 100 + rand() % 100;
- FILE *fp;
+ char buf[128], vice[12];
+ unsigned int viceserial = (currutmp->lastact % 1000000) * 100 + rand() % 100;
+
demoney(-money);
- snprintf(buf, sizeof(buf), BBSHOME "/home/%c/%s/%s",
- cuser.userid[0], cuser.userid, VICE_NEW);
- fp = fopen(buf, "a");
- if (!fp) {
- return 0;
- }
- fprintf(fp, "%08d\n", viceserial);
- fclose(fp);
+ setuserfile(buf, VICE_NEW);
+ sprintf(vice,"%8.8d\n", viceserial);
+ log_file(buf, vice, 1);
snprintf(buf, sizeof(buf),
"%s 花了%d$ 編號[%08d]", item, money, viceserial);
- mail_id(cuser.userid, buf, "etc/vice.txt", "Ptt經濟部");
+ mail_id(cuser->userid, buf, "etc/vice.txt", "Ptt經濟部");
return 0;
}
@@ -99,7 +94,7 @@ osong(char *defaultid)
lockreturn0(OSONG, LOCK_MULTI);
/* Jaky 一人一天點一首 */
- if (!strcmp(buf, Cdatedate(&cuser.lastsong)) && !HAS_PERM(PERM_SYSOP)) {
+ if (!strcmp(buf, Cdatedate(&cuser->lastsong)) && !HAS_PERM(PERM_SYSOP)) {
move(22, 0);
outs("你今天已經點過囉,明天再點吧....");
refresh();
@@ -108,7 +103,7 @@ osong(char *defaultid)
unlockutmpmode();
return 0;
}
- if (cuser.money < 200) {
+ if (cuser->money < 200) {
move(22, 0);
outs("點歌要200銀唷!....");
refresh();
@@ -118,7 +113,7 @@ osong(char *defaultid)
}
move(12, 0);
clrtobot();
- prints("親愛的 %s 歡迎來到歐桑自動點歌系統\n", cuser.userid);
+ prints("親愛的 %s 歡迎來到歐桑自動點歌系統\n", cuser->userid);
trans_buffer[0] = 0;
if (!defaultid) {
getdata(13, 0, "要點給誰呢:[可直接按 Enter 先選歌]",
@@ -142,7 +137,7 @@ osong(char *defaultid)
getdata_str(14, 0, "想要要對他(她)說..:", say,
sizeof(say), DOECHO, "我愛妳..");
snprintf(save_title, sizeof(save_title),
- "%s:%s", (ano[0] == 'y') ? "匿名者" : cuser.userid, say);
+ "%s:%s", (ano[0] == 'y') ? "匿名者" : cuser->userid, say);
getdata_str(16, 0, "寄到誰的信箱(可用E-mail)?",
receiver, sizeof(receiver), LCECHO, destid);
@@ -170,7 +165,7 @@ osong(char *defaultid)
strlcpy(mail.owner, "點歌機", sizeof(mail.owner));
snprintf(mail.title, sizeof(mail.title),
"◇ %s 點給 %s ",
- (ano[0] == 'y') ? "匿名者" : cuser.userid, destid);
+ (ano[0] == 'y') ? "匿名者" : cuser->userid, destid);
while (fgets(buf, sizeof(buf), fp)) {
char *po;
@@ -188,7 +183,7 @@ osong(char *defaultid)
po[0] = 0;
snprintf(genbuf, sizeof(genbuf),
"%s%s%s", buf,
- (ano[0] == 'y') ? "匿名者" : cuser.userid, po + 7);
+ (ano[0] == 'y') ? "匿名者" : cuser->userid, po + 7);
strlcpy(buf, genbuf, sizeof(buf));
}
while ((po = strstr(buf, "<~Des~>"))) {
@@ -208,7 +203,7 @@ osong(char *defaultid)
if (append_record(OSONGPATH "/.DIR", &mail, sizeof(mail)) != -1) {
- cuser.lastsong = now;
+ cuser->lastsong = now;
/* Jaky 超過 500 首歌就開始砍 */
nsongs = get_num_records(OSONGPATH "/.DIR", sizeof(mail));
if (nsongs > 500) {
@@ -218,7 +213,7 @@ osong(char *defaultid)
vice(200, "點歌");
}
snprintf(save_title, sizeof(save_title),
- "%s:%s", (ano[0] == 'y') ? "匿名者" : cuser.userid, say);
+ "%s:%s", (ano[0] == 'y') ? "匿名者" : cuser->userid, say);
hold_mail(filename, destid);
if (receiver[0]) {
@@ -256,9 +251,9 @@ static int
inmailbox(int m)
{
passwd_query(usernum, &xuser);
- cuser.exmailbox = xuser.exmailbox + m;
- passwd_update(usernum, &cuser);
- return cuser.exmailbox;
+ cuser->exmailbox = xuser.exmailbox + m;
+// passwd_update(usernum, &cuser);
+ return cuser->exmailbox;
}
@@ -273,7 +268,7 @@ p_cloak()
buf, sizeof(buf), LCECHO);
if (buf[0] != 'y')
return 0;
- if (cuser.money >= 19) {
+ if (cuser->money >= 19) {
vice(19, "cloak");
currutmp->invisible %= 2;
outs((currutmp->invisible ^= 1) ? MSG_CLOAKED : MSG_UNCLOAK);
@@ -293,7 +288,7 @@ p_from()
if (ans[0] != 'y')
return 0;
reload_money();
- if (cuser.money < 49)
+ if (cuser->money < 49)
return 0;
if (getdata_buf(b_lines - 1, 0, "請輸入新故鄉:",
currutmp->from, sizeof(currutmp->from), DOECHO)) {
@@ -309,13 +304,13 @@ p_exmail()
char ans[4], buf[200];
int n;
- if (cuser.exmailbox >= MAX_EXKEEPMAIL) {
+ if (cuser->exmailbox >= MAX_EXKEEPMAIL) {
prints("容量最多增加 %d 封,不能再買了。", MAX_EXKEEPMAIL);
refresh();
return 0;
}
snprintf(buf, sizeof(buf),
- "您曾增購 %d 封容量,還要再買多少?", cuser.exmailbox);
+ "您曾增購 %d 封容量,還要再買多少?", cuser->exmailbox);
getdata_str(b_lines - 2, 0, buf, ans, sizeof(ans), LCECHO, "10");
@@ -324,10 +319,10 @@ p_exmail()
return 0;
if (n < 0)
n = 100;
- if (n + cuser.exmailbox > MAX_EXKEEPMAIL)
- n = MAX_EXKEEPMAIL - cuser.exmailbox;
+ if (n + cuser->exmailbox > MAX_EXKEEPMAIL)
+ n = MAX_EXKEEPMAIL - cuser->exmailbox;
reload_money();
- if (cuser.money < n * 1000)
+ if (cuser->money < n * 1000)
return 0;
vice(n * 1000, "mail");
inmailbox(n);
@@ -384,23 +379,23 @@ p_give()
move(1, 0);
usercomplete("這位幸運兒的id:", id);
- if (!id[0] || !strcmp(cuser.userid, id) ||
+ if (!id[0] || !strcmp(cuser->userid, id) ||
!getdata(2, 0, "要給多少錢:", genbuf, 7, LCECHO))
return 0;
money = atoi(genbuf);
reload_money();
- if (money > 0 && cuser.money >= money) {
+ if (money > 0 && cuser->money >= money) {
tax = give_tax(money);
if (money - tax <= 0)
return 0; /* 繳完稅就沒錢給了 */
deumoney(searchuser(id), money - tax);
demoney(-money);
snprintf(genbuf, sizeof(genbuf), "%s\t給%s\t%d\t%s\n",
- cuser.userid, id, money - tax, ctime(&now));
+ cuser->userid, id, money - tax, ctime(&now));
log_file(FN_MONEY, genbuf, 1);
genbuf[0] = 'n';
getdata(3, 0, "要自行書寫紅包袋嗎?[y/N]", genbuf, 2, LCECHO);
- mail_redenvelop(cuser.userid, id, money - tax, genbuf[0]);
+ mail_redenvelop(cuser->userid, id, money - tax, genbuf[0]);
}
return 0;
}
diff --git a/mbbsd/calendar.c b/mbbsd/calendar.c
index 67524a91..d5c1fe61 100644
--- a/mbbsd/calendar.c
+++ b/mbbsd/calendar.c
@@ -1,4 +1,4 @@
-/* $Id: calendar.c,v 1.8 2003/01/16 11:58:04 kcwu Exp $ */
+/* $Id$ */
#include "bbs.h"
typedef struct event_t {
@@ -129,7 +129,7 @@ ReadEvent(int today)
static event_t head;
head.next = NULL;
- setcalfile(buf, cuser.userid);
+ setcalfile(buf, cuser->userid);
fp = fopen(buf, "r");
if (fp) {
while (fgets(buf, sizeof(buf), fp)) {
diff --git a/mbbsd/card.c b/mbbsd/card.c
index 55102df5..806c5429 100644
--- a/mbbsd/card.c
+++ b/mbbsd/card.c
@@ -1,4 +1,4 @@
-/* $Id: card.c,v 1.6 2002/07/22 19:02:00 in2 Exp $ */
+/* $Id$ */
#include "bbs.h"
static int
@@ -353,14 +353,14 @@ game_log(int type, int money)
fp = fopen(BBSHOME "/etc/card/jack.log", "a");
if (!fp)
return 0;
- fprintf(fp, "%s win:%d\n", cuser.userid, money);
+ fprintf(fp, "%s win:%d\n", cuser->userid, money);
fclose(fp);
break;
case TEN_HALF:
fp = fopen(BBSHOME "/etc/card/tenhalf.log", "a");
if (!fp)
return 0;
- fprintf(fp, "%s win:%d\n", cuser.userid, money);
+ fprintf(fp, "%s win:%d\n", cuser->userid, money);
fclose(fp);
break;
}
@@ -374,9 +374,9 @@ card_double_ask()
snprintf(buf, sizeof(buf),
"[ %s ]您現在共有 %d P幣, 現在要分組(加收 %d 元)嗎? [y/N]",
- cuser.userid, cuser.money, JACK);
+ cuser->userid, cuser->money, JACK);
reload_money();
- if (cuser.money < JACK)
+ if (cuser->money < JACK)
return 0;
getdata(20, 0, buf, buf2, sizeof(buf2), LCECHO);
if (buf2[0] == 'y' || buf2[0] == 'Y')
@@ -390,7 +390,7 @@ card_ask()
char buf[100], buf2[3];
snprintf(buf, sizeof(buf), "[ %s ]您現在共有 %d P幣, 還要加牌嗎? [y/N]",
- cuser.userid, cuser.money);
+ cuser->userid, cuser->money);
getdata(20, 0, buf, buf2, sizeof(buf2), LCECHO);
if (buf2[0] == 'y' || buf2[0] == 'Y')
return 1;
@@ -541,7 +541,7 @@ g_card_jack()
setutmpmode(JACK_CARD);
while (1) {
reload_money();
- if (cuser.money < JACK) {
+ if (cuser->money < JACK) {
outs("您的錢不夠唷!去多發表些有意義的文章再來~~~");
return 0;
}
@@ -642,7 +642,7 @@ g_ten_helf()
setutmpmode(TENHALF);
while (1) {
reload_money();
- if (cuser.money < TEN_HALF) {
+ if (cuser->money < TEN_HALF) {
outs("您的錢不夠唷!去多發表些有意義的文章再來~~~");
return 0;
}
diff --git a/mbbsd/chat.c b/mbbsd/chat.c
index 28b488f9..744efa7d 100644
--- a/mbbsd/chat.c
+++ b/mbbsd/chat.c
@@ -332,13 +332,13 @@ t_chat()
while (1) {
getdata(b_lines - 1, 0, "請輸入聊天代號:", chatid, 9, DOECHO);
if(!chatid[0])
- strlcpy(chatid, cuser.userid, sizeof(chatid));
+ strlcpy(chatid, cuser->userid, sizeof(chatid));
chatid[8] = '\0';
/*
* 新格式: /! UserID ChatID Password
*/
snprintf(inbuf, sizeof(inbuf), "/! %s %s %s",
- cuser.userid, chatid, cuser.passwd);
+ cuser->userid, chatid, cuser->passwd);
chat_send(cfd, inbuf);
if (recv(cfd, inbuf, 3, 0) != 3) {
close(cfd);
@@ -381,7 +381,7 @@ t_chat()
print_chatid(chatid);
memset(inbuf, 0, sizeof(inbuf));
- sethomepath(fpath, cuser.userid);
+ sethomepath(fpath, cuser->userid);
strlcpy(fpath, tempnam(fpath, "chat_"), sizeof(fpath));
flog = fopen(fpath, "w");
@@ -521,12 +521,12 @@ t_chat()
char title[128];
char genbuf[200];
- sethomepath(genbuf, cuser.userid);
+ sethomepath(genbuf, cuser->userid);
stampfile(genbuf, &mymail);
mymail.filemode = FILE_READ ;
strlcpy(mymail.owner, "[備.忘.錄]", sizeof(mymail.owner));
strlcpy(mymail.title, "會議\033[1;33m記錄\033[m", sizeof(mymail.title));
- sethomedir(title, cuser.userid);
+ sethomedir(title, cuser->userid);
append_record(title, &mymail, sizeof(mymail));
Rename(fpath, genbuf);
} else
diff --git a/mbbsd/chc.c b/mbbsd/chc.c
index e6436d0c..6779f456 100644
--- a/mbbsd/chc.c
+++ b/mbbsd/chc.c
@@ -775,8 +775,8 @@ mainloop(int s, chcusr_t *user1, chcusr_t *user2, board_t board, play_func_t pla
currutmp->chc_tie++;
}
user1->lose--;
- chcusr_put(&cuser, user1);
- passwd_update(usernum, &cuser);
+ chcusr_put(cuser, user1);
+// passwd_update(usernum, &cuser);
}
else if (chc_mode & CHC_WATCH) {
strlcpy(chc_warnmsg, "結束觀棋", sizeof(chc_warnmsg));
@@ -804,8 +804,8 @@ chc_init_play_func(chcusr_t *user1, chcusr_t *user2, play_func_t play_func[2])
char userid[2][IDLEN + 1];
if (chc_mode & CHC_PERSONAL) {
- strlcpy(userid[0], cuser.userid, sizeof(userid[0]));
- strlcpy(userid[1], cuser.userid, sizeof(userid[1]));
+ strlcpy(userid[0], cuser->userid, sizeof(userid[0]));
+ strlcpy(userid[1], cuser->userid, sizeof(userid[1]));
play_func[0] = play_func[1] = myplay;
}
else if (chc_mode & CHC_WATCH) {
@@ -815,7 +815,7 @@ chc_init_play_func(chcusr_t *user1, chcusr_t *user2, play_func_t play_func[2])
play_func[0] = play_func[1] = hisplay;
}
else {
- strlcpy(userid[0], cuser.userid, sizeof(userid[0]));
+ strlcpy(userid[0], cuser->userid, sizeof(userid[0]));
strlcpy(userid[1], currutmp->mateid, sizeof(userid[1]));
play_func[chc_my] = myplay;
play_func[chc_my ^ 1] = hisplay;
@@ -954,7 +954,7 @@ chc(int s, int mode)
chc_log("\n--\n\n");
chc_log_poem();
chc_log_close();
- mail_id(cuser.userid, title, file, "[楚河漢界]");
+ mail_id(cuser->userid, title, file, "[楚河漢界]");
}
else
chc_log_close();
diff --git a/mbbsd/chicken.c b/mbbsd/chicken.c
index 7bb7e5ee..ce876c84 100644
--- a/mbbsd/chicken.c
+++ b/mbbsd/chicken.c
@@ -45,7 +45,7 @@ enum {
TEMPERAMENT, TIREDSTRONG, SICK, HP_MAX, MM_MAX
};
-static chicken_t *mychicken = &cuser.mychicken;
+static chicken_t *mychicken;
static int age;
static const short time_change[NUM_KINDS][14] =
@@ -123,7 +123,7 @@ new_chicken()
reload_money();
price = egg_price[(int)mychicken->type];
- if (cuser.money < price) {
+ if (cuser->money < price) {
prints("\n 錢不夠買蛋蛋,蛋蛋要 %d 元", price);
refresh();
return 0;
@@ -135,7 +135,7 @@ new_chicken()
snprintf(buf, sizeof(buf),
"\033[31m%s \033[m養了一隻叫\033[33m %s \033[m的 "
- "\033[32m%s\033[m 於 %s\n", cuser.userid,
+ "\033[32m%s\033[m 於 %s\n", cuser->userid,
mychicken->name, chicken_type[(int)mychicken->type], ctime(&now));
log_file(CHICKENLOG, buf, 1);
mychicken->lastvisit = mychicken->birthday = mychicken->cbirth = now;
@@ -326,7 +326,7 @@ ch_guess()
win = (int)(3.0 * rand() / (RAND_MAX + 1.0)) - 1;
ch = (me + win + 3) % 3;
prints("%s:%s ! %s:%s !.....%s",
- cuser.userid, guess[(int)me], mychicken->name, guess[(int)ch],
+ cuser->userid, guess[(int)me], mychicken->name, guess[(int)ch],
win == 0 ? "平手" : win < 0 ? "耶..贏了 :D!!" : "嗚..我輸了 :~");
pressanykey();
}
@@ -384,7 +384,7 @@ ch_buyitem(int money, char *picture, int *item, int haveticket)
if (num < 1)
return;
reload_money();
- if (cuser.money > money * num) {
+ if (cuser->money > money * num) {
*item += num;
if( haveticket )
vice(money * num, "購買寵物,賭盤項目");
@@ -442,7 +442,7 @@ ch_kill()
more(CHICKEN_PIC "/deadth", YEA);
snprintf(buf, sizeof(buf),
"\033[31m%s \033[m把 \033[33m%s\033[m\033[32m %s "
- "\033[m宰了 於 %s\n", cuser.userid, mychicken->name,
+ "\033[m宰了 於 %s\n", cuser->userid, mychicken->name,
chicken_type[(int)mychicken->type], ctime(&now));
log_file(CHICKENLOG, buf, 1);
mychicken->name[0] = 0;
@@ -501,11 +501,11 @@ ch_sell()
if (ans[0] == 'y') {
snprintf(buf, sizeof(buf), "\033[31m%s\033[m 把 \033[33m%s\033[m "
"\033[32m%s\033[m 用 \033[36m%d\033[m 賣了 於 %s\n",
- cuser.userid, mychicken->name,
+ cuser->userid, mychicken->name,
chicken_type[(int)mychicken->type], money, ctime(&now));
log_file(CHICKENLOG, buf, 1);
mychicken->lastvisit = mychicken->name[0] = 0;
- passwd_update(usernum, &cuser);
+// passwd_update(usernum, &cuser);
more(CHICKEN_PIC "/sell", YEA);
demoney(money);
return 1;
@@ -658,12 +658,12 @@ deadtype(chicken_t * thechicken)
snprintf(buf, sizeof(buf),
"\033[31m%s\033[m 所疼愛的\033[33m %s\033[32m %s "
"\033[m掛了 於 %s\n",
- cuser.userid, thechicken->name,
+ cuser->userid, thechicken->name,
chicken_type[(int)thechicken->type],
ctime(&now));
log_file(CHICKENLOG, buf, 1);
mychicken->name[0] = 0;
- passwd_update(usernum, &cuser);
+// passwd_update(usernum, &cuser);
}
return i;
}
@@ -716,7 +716,7 @@ ch_changename()
snprintf(buf, sizeof(buf),
"\033[31m%s\033[m 把疼愛的\033[33m %s\033[32m %s "
"\033[m改名為\033[33m %s\033[m 於 %s\n",
- cuser.userid, mychicken->name,
+ cuser->userid, mychicken->name,
chicken_type[(int)mychicken->type],
newname, ctime(&now));
strlcpy(mychicken->name, newname, sizeof(mychicken->name));
@@ -741,7 +741,7 @@ select_menu()
"(\033[37mm\033[33m)買藥$10 (\033[37mk\033[33m)棄養 "
"(\033[37ms\033[33m)賣掉 (\033[37mn\033[33m)改名 "
"(\033[37mq\033[33m)離開:\033[m",
- cuser.money,
+ cuser->money,
/*
* chicken_food[(int)mychicken->type],
* chicken_type[(int)mychicken->type],
@@ -835,7 +835,7 @@ recover_chicken(chicken_t * thechicken)
getdata_str(21, 0, " 選擇:(N:坑人嘛/y:請幫幫我)", buf, 3, LCECHO, "N");
if (buf[0] == 'y' || buf[0] == 'Y') {
reload_money();
- if (cuser.money < price * 2) {
+ if (cuser->money < price * 2) {
outmsg("\033[33;44m★靈界守衛\033[37;45m 什麼 錢沒帶夠 "
"沒錢的小鬼 快去籌錢吧 \033[m");
bell();
@@ -860,7 +860,7 @@ recover_chicken(chicken_t * thechicken)
bell();
igetch();
thechicken->lastvisit = 0;
- passwd_update(usernum, &cuser);
+ // passwd_update(usernum, &cuser);
return 0;
}
@@ -870,7 +870,7 @@ int
chicken_main()
{
lockreturn0(CHICKEN, LOCK_MULTI);
-
+ mychicken = &(cuser->mychicken);
reload_chicken();
age = ((now - mychicken->cbirth) / (60 * 60 * 24));
if (!mychicken->name[0] && !recover_chicken(mychicken) && !new_chicken()) {
@@ -884,7 +884,7 @@ chicken_main()
show_chicken_data(mychicken, NULL);
} while (select_menu());
reload_money();
- passwd_update(usernum, &cuser);
+// passwd_update(usernum, &cuser);
unlockutmpmode();
return 0;
}
@@ -1016,7 +1016,7 @@ chickenpk(int fd)
outs(data + 1);
i = strlen(data) + 1;
passwd_update(duid, &ouser);
- passwd_update(usernum, &cuser);
+// passwd_update(usernum, &cuser);
send(fd, data, i, 0);
if (data[0] == 'q' || data[0] == 'd')
break;
diff --git a/mbbsd/dice.c b/mbbsd/dice.c
index b6336d93..994bc000 100644
--- a/mbbsd/dice.c
+++ b/mbbsd/dice.c
@@ -209,7 +209,7 @@ del(int value[100],int total, dicedata_t * table)
demoney(money);
move(19, 0);
clrtoeol();
- prints("你現在有 %u Ptt$歐", cuser.money);
+ prints("你現在有 %u Ptt$歐", cuser->money);
table[i].mymoney -= money;
show_count(value, index, -money);
break;
@@ -336,7 +336,7 @@ dice_main(void)
more(DICE_TXT, NA);
reload_money();
- if (cuser.money < 10) {
+ if (cuser->money < 10) {
move(19, 0);
prints("\033[1;37m超過十元再來玩吧~~\033[m");
pressanykey();
@@ -362,11 +362,11 @@ dice_main(void)
while (1) {
move(19, 0);
prints("\033[1;32m你現在有\033[1;31m %u \033[1;32mPtt$歐\033[m",
- cuser.money);
+ cuser->money);
getdata(20, 0, "\033[1;37m數字:加選 d:退選 s:開始或離開\033[m: ",
input, 5, LCECHO);
reload_money();
- if (input[0] != 's' && input[0] != 'd' && cuser.money < 10) {
+ if (input[0] != 's' && input[0] != 'd' && cuser->money < 10) {
move(21, 0);
clrtoeol();
prints("\033[1;37m超過十元才能賭~\033[m");
@@ -387,14 +387,14 @@ dice_main(void)
continue;
/* 輸入錢的loop */
while (1) {
- if (cuser.money < 10)
+ if (cuser->money < 10)
break;
getdata(21, 0, "\033[1;32m賭多少錢呢\033[1;37m(大於10 小於500)"
"\033[m: ", input, sizeof(input), LCECHO);
if (!(money = IsLegal(input)) || input[0] == '0')
continue;
reload_money();
- if (money > cuser.money)
+ if (money > cuser->money)
continue;
for (j = 0, sig = 0; j < i; j++)
if (table[j].mybet == index) {
@@ -425,7 +425,7 @@ dice_main(void)
reload_money();
move(19, 0);
prints("\033[1;32m你現在有 \033[1;31m%u\033[1;32m Ptt$歐",
- cuser.money);
+ cuser->money);
if (sig != 2)
show_count(value,index, money);
}
@@ -450,7 +450,7 @@ dice_main(void)
if (table[j].mymoney * ya > 500) { /* 超過500塊錢才做log 減少io */
snprintf(data, sizeof(data),
"%-15s 押%-2d選項%-8d塊錢 中了%d倍 淨賺:%-8d\n",
- cuser.userid, table[j].mybet,
+ cuser->userid, table[j].mybet,
table[j].mymoney, ya, table[j].mymoney * ya);
fputs(data, winfp);
}
@@ -470,7 +470,7 @@ dice_main(void)
move(19, 0);
clrtoeol();
prints("\033[1;32m你現在有 \033[1;31m%u\033[1;32m Ptt$歐\033[m",
- cuser.money);
+ cuser->money);
getdata(23, 0, "\033[1;32m繼續奮鬥[\033[1;37my/n\033[1;32m]\033[m: ",
input, 2, LCECHO);
diff --git a/mbbsd/edit.c b/mbbsd/edit.c
index 36937d36..8cd5ebc7 100644
--- a/mbbsd/edit.c
+++ b/mbbsd/edit.c
@@ -805,8 +805,8 @@ write_header(FILE * fp)
{
if (curredit & EDIT_MAIL || curredit & EDIT_LIST) {
- fprintf(fp, "%s %s (%s)\n", str_author1, cuser.userid,
- cuser.username
+ fprintf(fp, "%s %s (%s)\n", str_author1, cuser->userid,
+ cuser->username
);
} else {
char *ptr;
@@ -819,7 +819,7 @@ write_header(FILE * fp)
} postlog;
memset(&postlog, 0, sizeof(postlog));
- strlcpy(postlog.author, cuser.userid, sizeof(postlog.author));
+ strlcpy(postlog.author, cuser->userid, sizeof(postlog.author));
ifuseanony = 0;
#ifdef HAVE_ANONYMOUS
if (currbrdattr & BRD_ANONYMOUS) {
@@ -837,7 +837,7 @@ write_header(FILE * fp)
} else {
if (!strcmp("r", real_name) || (!defanony && !real_name[0]))
snprintf(postlog.author, sizeof(postlog.author),
- "%s", cuser.userid);
+ "%s", cuser->userid);
else {
snprintf(postlog.author, sizeof(postlog.author),
"%s.", real_name);
@@ -860,17 +860,17 @@ write_header(FILE * fp)
fprintf(fp, "%s %s (%s) %s %s\n", str_author1, postlog.author,
(((!strcmp(real_name, "r") && defanony) ||
- (!real_name[0] && (!defanony))) ? cuser.username :
+ (!real_name[0] && (!defanony))) ? cuser->username :
"猜猜我是誰 ? ^o^"),
local_article ? str_post2 : str_post1, currboard);
} else {
- fprintf(fp, "%s %s (%s) %s %s\n", str_author1, cuser.userid,
- cuser.username,
+ fprintf(fp, "%s %s (%s) %s %s\n", str_author1, cuser->userid,
+ cuser->username,
local_article ? str_post2 : str_post1, currboard);
}
#else /* HAVE_ANONYMOUS */
- fprintf(fp, "%s %s (%s) %s %s\n", str_author1, cuser.userid,
- cuser.username,
+ fprintf(fp, "%s %s (%s) %s %s\n", str_author1, cuser->userid,
+ cuser->username,
local_article ? str_post2 : str_post1, currboard);
#endif /* HAVE_ANONYMOUS */
@@ -890,7 +890,7 @@ addsignature(FILE * fp, int ifuseanony)
static char msg[] = "請選擇簽名檔 (1-9, 0=不加 X=隨機)[X]: ";
char ch;
- if (!strcmp(cuser.userid, STR_GUEST)) {
+ if (!strcmp(cuser->userid, STR_GUEST)) {
fprintf(fp, "\n--\n※ 發信站 :" BBSNAME "(" MYHOSTNAME
") \n◆ From: %s\n", fromhost);
return;
@@ -898,7 +898,7 @@ addsignature(FILE * fp, int ifuseanony)
if (!ifuseanony) {
num = showsignature(fpath, &i);
if (num){
- msg[34] = ch = isdigit(cuser.signature) ? cuser.signature : 'X';
+ msg[34] = ch = isdigit(cuser->signature) ? cuser->signature : 'X';
getdata(0, 0, msg, buf, 4, DOECHO);
if (!buf[0])
@@ -908,7 +908,7 @@ addsignature(FILE * fp, int ifuseanony)
ch = buf[0];
else
ch = '1' + rand() % num;
- cuser.signature = buf[0];
+ cuser->signature = buf[0];
if (ch != '0') {
fpath[i] = ch;
@@ -1004,7 +1004,7 @@ write_file(char *fpath, int saveheader, int *islocal)
return KEEP_EDITING;
if (!*fpath) {
- sethomepath(fpath, cuser.userid);
+ sethomepath(fpath, cuser->userid);
strcpy(fpath, tempnam(fpath, "ve_"));
}
if ((fp = fopen(fpath, "w")) == NULL) {
@@ -1067,7 +1067,7 @@ write_file(char *fpath, int saveheader, int *islocal)
ptime = localtime(&now);
fprintf(fp,
"※ 編輯: %-15s 來自: %-20s (%02d/%02d %02d:%02d)\n",
- cuser.userid, fromhost,
+ cuser->userid, fromhost,
ptime->tm_mon + 1, ptime->tm_mday, ptime->tm_hour, ptime->tm_min);
}
fclose(fp);
@@ -1697,12 +1697,12 @@ vedit(char *fpath, int saveheader, int *islocal)
if (count >= 240) {
char buf[200];
snprintf(buf, sizeof(buf), "\033[1;33;46m%s\033[37m在\033[37;45m%s\n"
- "\033[37m板違法賺錢 , %s\033[m", cuser.userid,
+ "\033[37m板違法賺錢 , %s\033[m", cuser->userid,
currboard, ctime(&now));
log_file("etc/illegal_money", buf, 1);
money = 0;
- post_violatelaw(cuser.userid, "Ptt 系統警察", "違法賺錢", "扣除不法所得");
- mail_violatelaw(cuser.userid, "Ptt 系統警察", "違法賺錢", "扣除不法所得");
+ post_violatelaw(cuser->userid, "Ptt 系統警察", "違法賺錢", "扣除不法所得");
+ mail_violatelaw(cuser->userid, "Ptt 系統警察", "違法賺錢", "扣除不法所得");
demoney(10000);
abort_bbs(0);
} */
diff --git a/mbbsd/fav.c b/mbbsd/fav.c
index f265db52..53a5ccb4 100644
--- a/mbbsd/fav.c
+++ b/mbbsd/fav.c
@@ -874,7 +874,7 @@ void updatenewfav(int mode)
int i, fd, brdnum;
char fname[80], *brd;
- if(!(cuser.uflag2 & FAVNEW_FLAG))
+ if(!(cuser->uflag2 & FAVNEW_FLAG))
return;
setuserfile(fname, FAVNB);
diff --git a/mbbsd/friend.c b/mbbsd/friend.c
index 6d7ed3f5..17a1cc25 100644
--- a/mbbsd/friend.c
+++ b/mbbsd/friend.c
@@ -420,7 +420,7 @@ friend_edit(int type)
sscanf(line, "%s", uident); // XXX check buffer size
sethomefile(genbuf, uident,
type == FRIEND_ALOHA ? "aloha" : "postnotify");
- del_distinct(genbuf, cuser.userid);
+ del_distinct(genbuf, cuser->userid);
}
fclose(fp);
}
@@ -430,7 +430,7 @@ friend_edit(int type)
sscanf(line, "%s", uident); // XXX check buffer size
sethomefile(genbuf, uident,
type == FRIEND_ALOHA ? "aloha" : "postnotify");
- add_distinct(genbuf, cuser.userid);
+ add_distinct(genbuf, cuser->userid);
}
fclose(fp);
}
diff --git a/mbbsd/gamble.c b/mbbsd/gamble.c
index 33e67bb8..841d0926 100644
--- a/mbbsd/gamble.c
+++ b/mbbsd/gamble.c
@@ -101,7 +101,7 @@ append_ticket_record(char *direct, int ch, int n, int count)
snprintf(genbuf, sizeof(genbuf), "%s/" FN_TICKET_USER, direct);
if ((fp = fopen(genbuf, "a"))) {
- fprintf(fp, "%s %d %d\n", cuser.userid, ch, n);
+ fprintf(fp, "%s %d %d\n", cuser->userid, ch, n);
fclose(fp);
}
load_ticket_record(direct, ticket);
@@ -141,7 +141,7 @@ ticket(int bid)
move(20, 0);
reload_money();
prints("\033[44m錢: %-10d \033[m\n\033[1m請選擇要購買的種類(1~%d)"
- "[Q:離開]\033[m:", cuser.money, count);
+ "[Q:離開]\033[m:", cuser->money, count);
ch = igetch();
/*--
Tim011127
@@ -237,7 +237,7 @@ openticket(int bid)
if (bet != 98) {
money = total * price;
demoney(money * 0.02);
- mail_redenvelop("[賭場抽頭]", cuser.userid, money * 0.02, 'n');
+ mail_redenvelop("[賭場抽頭]", cuser->userid, money * 0.02, 'n');
money = ticket[bet] ? money * 0.95 / ticket[bet] : 9999999;
} else {
vice(price * 10, "賭盤退錢手續費");
diff --git a/mbbsd/gomo.c b/mbbsd/gomo.c
index d83f6f7d..23dc9584 100644
--- a/mbbsd/gomo.c
+++ b/mbbsd/gomo.c
@@ -189,7 +189,7 @@ HO_log(Horder_t *pool, char *user)
fileheader_t mymail;
snprintf(buf, sizeof(buf), "home/%c/%s/F.%d",
- cuser.userid[0], cuser.userid, rand() & 65535);
+ cuser->userid[0], cuser->userid, rand() & 65535);
log = fopen(buf, "w");
assert(log);
@@ -204,14 +204,14 @@ HO_log(Horder_t *pool, char *user)
} while (++ptr < v);
fclose(log);
- sethomepath(buf1, cuser.userid);
+ sethomepath(buf1, cuser->userid);
stampfile(buf1, &mymail);
mymail.filemode = FILE_READ ;
strlcpy(mymail.owner, "[備.忘.錄]", sizeof(mymail.owner));
snprintf(mymail.title, sizeof(mymail.title),
- "\033[37;41m棋譜\033[m %s VS %s", cuser.userid, user);
- sethomedir(title, cuser.userid);
+ "\033[37;41m棋譜\033[m %s VS %s", cuser->userid, user);
+ sethomedir(title, cuser->userid);
Rename(buf, buf1);
append_record(title, &mymail, sizeof(mymail));
@@ -289,16 +289,6 @@ gomo_key(int fd, int ch, Horder_t * mv)
return 0;
}
-static int
-reload_gomo()
-{
- passwd_query(usernum, &xuser);
- cuser.five_win = xuser.five_win;
- cuser.five_lose = xuser.five_lose;
- cuser.five_tie = xuser.five_tie;
- return 0;
-}
-
int
gomoku(int fd)
{
@@ -317,28 +307,27 @@ gomoku(int fd)
clear();
prints("\033[1;46m 五子棋對戰 \033[45m%30s VS %-30s\033[m",
- cuser.userid, my->mateid);
+ cuser->userid, my->mateid);
show_file("etc/@five", 1, -1, ONLY_COLOR);
move(11, 40);
prints("我是 %s", me == BBLACK ? "先手 ●, 有禁手" : "後手 ○");
move(16, 40);
- prints("\033[1;33m%s", cuser.userid);
+ prints("\033[1;33m%s", cuser->userid);
move(17, 40);
prints("\033[1;33m%s", my->mateid);
- reload_gomo();
move(16, 60);
prints("\033[1;31m%d\033[37m勝 \033[34m%d\033[37m敗 \033[36m%d\033[37m和"
- "\033[m", cuser.five_win, cuser.five_lose, cuser.five_tie);
+ "\033[m", cuser->five_win, cuser->five_lose, cuser->five_tie);
getuser(my->mateid);
move(17, 60);
prints("\033[1;31m%d\033[37m勝 \033[34m%d\033[37m敗 \033[36m%d\033[37m"
"和\033[m", xuser.five_win, xuser.five_lose, xuser.five_tie);
- cuser.five_lose++;
+ cuser->five_lose++;
/* 一進來先加一場敗場, 贏了後再扣回去, 避免快輸了惡意斷線 */
- passwd_update(usernum, &cuser);
+ // passwd_update(usernum, &cuser);
add_io(fd, 0);
@@ -365,10 +354,10 @@ gomoku(int fd)
if (lastcount <= -5 && !my->turn) {
move(19, 40);
outs("對手太久沒下, 你贏了!");
- cuser.five_lose--;
- cuser.five_win++;
+ cuser->five_lose--;
+ cuser->five_win++;
my->five_win++;
- passwd_update(usernum, &cuser);
+ // passwd_update(usernum, &cuser);
mv.x = mv.y = -2;
send(fd, &mv, sizeof(Horder_t), 0);
mv = *(v - 1);
@@ -387,8 +376,8 @@ gomoku(int fd)
iwantpass = 0;
if (ch == 'q') {
if (countgomo(pool) < 10) {
- cuser.five_lose--;
- passwd_update(usernum, &cuser);
+ cuser->five_lose--;
+// passwd_update(usernum, &cuser);
}
send(fd, '\0', 1, 0);
break;
@@ -413,10 +402,10 @@ gomoku(int fd)
}
continue;
} else if (hewantpass) {
- cuser.five_lose--;
- cuser.five_tie++;
+ cuser->five_lose--;
+ cuser->five_tie++;
my->five_tie++;
- passwd_update(usernum, &cuser);
+// passwd_update(usernum, &cuser);
mv.x = mv.y = -2;
send(fd, &mv, sizeof(Horder_t), 0);
mv = *(v - 1);
@@ -428,12 +417,12 @@ gomoku(int fd)
if (ch != sizeof(Horder_t)) {
lastcount = tick - now;
if (lastcount >= 0) {
- cuser.five_lose--;
+ cuser->five_lose--;
if (countgomo(pool) >= 10) {
- cuser.five_win++;
+ cuser->five_win++;
my->five_win++;
}
- passwd_update(usernum, &cuser);
+// passwd_update(usernum, &cuser);
outmsg("對方認輸了!!");
break;
} else {
@@ -443,10 +432,10 @@ gomoku(int fd)
}
} else if (mv.x == -2 && mv.y == -2) {
if (iwantpass == 1) {
- cuser.five_lose--;
- cuser.five_tie++;
+ cuser->five_lose--;
+ cuser->five_tie++;
my->five_tie++;
- passwd_update(usernum, &cuser);
+// passwd_update(usernum, &cuser);
break;
} else {
hewantpass = 1;
@@ -475,10 +464,10 @@ gomoku(int fd)
if (win) {
outmsg(win == 1 ? "對方贏了!" : "對方禁手");
if (win != 1) {
- cuser.five_lose--;
- cuser.five_win++;
+ cuser->five_lose--;
+ cuser->five_win++;
my->five_win++;
- passwd_update(usernum, &cuser);
+// passwd_update(usernum, &cuser);
} else
my->five_lose++;
break;
@@ -508,10 +497,10 @@ gomoku(int fd)
if (win) {
outmsg(win == 1 ? "我贏囉~~" : "禁手輸了");
if (win == 1) {
- cuser.five_lose--;
- cuser.five_win++;
+ cuser->five_lose--;
+ cuser->five_win++;
my->five_win++;
- passwd_update(usernum, &cuser);
+// passwd_update(usernum, &cuser);
} else
my->five_lose++;
break;
diff --git a/mbbsd/guess.c b/mbbsd/guess.c
index 5ec40080..bd092b27 100644
--- a/mbbsd/guess.c
+++ b/mbbsd/guess.c
@@ -29,7 +29,7 @@ get_money(void)
char data[20];
move(1, 0);
- prints("您目前有:%d Ptt$", cuser.money);
+ prints("您目前有:%d Ptt$", cuser->money);
do {
getdata(2, 0, "要賭多少(5-10或按q離開): ", data, 9, LCECHO);
money = 0;
@@ -45,7 +45,7 @@ get_money(void)
if (money != -1) {
money = atoi(data);
reload_money();
- if (money > cuser.money || money <= 4 || money > 10 ||
+ if (money > cuser->money || money <= 4 || money > 10 ||
money < 1)
money = -1;
}
@@ -53,7 +53,7 @@ get_money(void)
move(1, 0);
clrtoeol();
reload_money();
- prints("您目前有:%d Ptt$", cuser.money - money);
+ prints("您目前有:%d Ptt$", cuser->money - money);
return money;
}
@@ -231,7 +231,7 @@ guess_main()
lockreturn0(GUESSNUM, LOCK_MULTI);
reload_money();
- if (cuser.money < 5) {
+ if (cuser->money < 5) {
clear();
move(12, 35);
prints("錢不夠啦 至少要 5 Ptt$");
@@ -296,10 +296,10 @@ guess_main()
if ((file = fopen(LOGPASS, "a"))) {
fprintf(file, "電腦第%d次猜中, ", c_count);
if (youwin)
- fprintf(file, "%s 第%d次猜中, ", cuser.userid, count);
+ fprintf(file, "%s 第%d次猜中, ", cuser->userid, count);
else
- fprintf(file, "%s 沒猜中, ", cuser.userid);
- fprintf(file, "電腦賺走了%s %ld Ptt$\n", cuser.userid, money);
+ fprintf(file, "%s 沒猜中, ", cuser->userid);
+ fprintf(file, "電腦賺走了%s %ld Ptt$\n", cuser->userid, money);
fclose(file);
}
} else if (count < c_count) {
@@ -309,7 +309,7 @@ guess_main()
demoney(money * 2);
if ((file = fopen(LOGPASS, "a"))) {
fprintf(file, "id: %s, 第%d次猜中, 電腦第%d次猜中, "
- "贏了電腦 %ld Ptt$\n", cuser.userid, count,
+ "贏了電腦 %ld Ptt$\n", cuser->userid, count,
c_count, money * 2);
fclose(file);
}
@@ -317,7 +317,7 @@ guess_main()
prints("真厲害, 和電腦打成平手了, 拿回本錢%lu\n", money);
demoney(money);
if ((file = fopen(LOGPASS, "a"))) {
- fprintf(file, "id: %s 和電腦打成了平手\n", cuser.userid);
+ fprintf(file, "id: %s 和電腦打成了平手\n", cuser->userid);
fclose(file);
}
}
@@ -331,14 +331,14 @@ guess_main()
prints("真厲害, 錢被你賺走了");
if ((file = fopen(LOGPASS, "a"))) {
fprintf(file, "id: %s, 第%d次猜中, 贏了 %ld Ptt$\n",
- cuser.userid, count, TABLE[count] * money);
+ cuser->userid, count, TABLE[count] * money);
fclose(file);
}
} else if (count > 5) {
prints("唉, 太多次才猜出來了");
if ((file = fopen(LOGPASS, "a"))) {
fprintf(file, "id: %s, 第%d次才猜中, 賠了 %ld Ptt$\n",
- cuser.userid, count, money);
+ cuser->userid, count, money);
fclose(file);
}
} else {
@@ -348,7 +348,7 @@ guess_main()
prints("你拿回了%lu Ptt$\n", money);
if ((file = fopen(LOGPASS, "a"))) {
fprintf(file, "id: %s, 第%d次猜中, 拿回了本錢 %lu Ptt$\n",
- cuser.userid, count, money);
+ cuser->userid, count, money);
fclose(file);
}
}
@@ -361,7 +361,7 @@ guess_main()
move(18, 35);
prints("下次再來吧");
if ((file = fopen(BBSHOME "/etc/loseguess.log", "a"))) {
- fprintf(file, "id: %s 賭了 %ld Ptt$\n", cuser.userid, money);
+ fprintf(file, "id: %s 賭了 %ld Ptt$\n", cuser->userid, money);
fclose(file);
}
unlockutmpmode();
diff --git a/mbbsd/indict.c b/mbbsd/indict.c
index 317fb5b0..2a997bdb 100644
--- a/mbbsd/indict.c
+++ b/mbbsd/indict.c
@@ -25,7 +25,7 @@ addword(char *database,char word[])
if (buf[0]) {
getdata(13, 0, "確定新增?(Y/n)", a, sizeof(a), LCECHO);
if (a[0] != 'n')
- fprintf(fp, "%-65s[%s]\n", buf, cuser.userid);
+ fprintf(fp, "%-65s[%s]\n", buf, cuser->userid);
}
}
fclose(fp);
diff --git a/mbbsd/kaede.c b/mbbsd/kaede.c
index 9023557d..bf2e0302 100644
--- a/mbbsd/kaede.c
+++ b/mbbsd/kaede.c
@@ -18,7 +18,7 @@ Ptt_prints(char *str, int mode)
switch( str[++r] ){
case 's':
w += snprintf(&strbuf[w], sizeof(strbuf) - w,
- "%s", cuser.userid);
+ "%s", cuser->userid);
break;
case 't':
w += snprintf(&strbuf[w], sizeof(strbuf) - w,
@@ -30,23 +30,23 @@ Ptt_prints(char *str, int mode)
break;
case 'b':
w += snprintf(&strbuf[w], sizeof(strbuf) - w,
- "%d/%d", cuser.month, cuser.day);
+ "%d/%d", cuser->month, cuser->day);
break;
case 'l':
w += snprintf(&strbuf[w], sizeof(strbuf) - w,
- "%d", cuser.numlogins);
+ "%d", cuser->numlogins);
break;
case 'p':
w += snprintf(&strbuf[w], sizeof(strbuf) - w,
- "%d", cuser.numposts);
+ "%d", cuser->numposts);
break;
case 'n':
w += snprintf(&strbuf[w], sizeof(strbuf) - w,
- "%s", cuser.username);
+ "%s", cuser->username);
break;
case 'm':
w += snprintf(&strbuf[w], sizeof(strbuf) - w,
- "%d", cuser.money);
+ "%d", cuser->money);
break;
/* It's saver not to send these undefined escape string.
default:
diff --git a/mbbsd/lovepaper.c b/mbbsd/lovepaper.c
index 1ab87944..f5dfdfbb 100644
--- a/mbbsd/lovepaper.c
+++ b/mbbsd/lovepaper.c
@@ -1,4 +1,4 @@
-/* $Id: lovepaper.c,v 1.11 2003/01/19 16:06:06 kcwu Exp $ */
+/* $Id$ */
#include "bbs.h"
#define DATA "etc/lovepaper.dat"
@@ -15,7 +15,7 @@ x_love()
setutmpmode(LOVE);
gtime = localtime(&now);
snprintf(buf1, sizeof(buf1), "%c/%s/love%d%d",
- cuser.userid[0], cuser.userid, gtime->tm_sec, gtime->tm_min);
+ cuser->userid[0], cuser->userid, gtime->tm_sec, gtime->tm_min);
strcat(path, buf1);
move(1, 0);
clrtobot();
@@ -96,7 +96,7 @@ x_love()
stampfile(buf1, &mhdr);
Rename(path, buf1);
strncpy(mhdr.title, save_title, TTLEN);
- strlcpy(mhdr.owner, cuser.userid, sizeof(mhdr.owner));
+ strlcpy(mhdr.owner, cuser->userid, sizeof(mhdr.owner));
sethomedir(path, receiver);
if (append_record(path, &mhdr, sizeof(mhdr)) == -1)
return -1;
diff --git a/mbbsd/mail.c b/mbbsd/mail.c
index 85f4c142..49864cf6 100644
--- a/mbbsd/mail.c
+++ b/mbbsd/mail.c
@@ -12,7 +12,7 @@ setforward()
char buf[80], ip[50] = "", yn[4];
FILE *fp;
- sethomepath(buf, cuser.userid);
+ sethomepath(buf, cuser->userid);
strcat(buf, "/.forward");
if ((fp = fopen(buf, "r"))) {
fscanf(fp, "%s", ip); // XXX check buffer size
@@ -58,7 +58,7 @@ built_mail_index()
snprintf(genbuf, sizeof(genbuf),
BBSHOME "/bin/buildir " BBSHOME "/home/%c/%s",
- cuser.userid[0], cuser.userid);
+ cuser->userid[0], cuser->userid);
move(22, 0);
prints("\033[1;31m已經處理完畢!! 諸多不便 敬請原諒~\033[m");
pressanykey();
@@ -85,7 +85,7 @@ mailalert(char *userid)
int
mail_muser(userec_t muser, char *title, char *filename)
{
- return mail_id(muser.userid, title, filename, cuser.userid);
+ return mail_id(muser.userid, title, filename, cuser->userid);
}
/* Heat: 用id來寄信,內容則link準備好的檔案 */
@@ -140,7 +140,7 @@ m_internet()
void
m_init()
{
- sethomedir(currmaildir, cuser.userid);
+ sethomedir(currmaildir, cuser->userid);
}
int
@@ -159,8 +159,8 @@ chkmailbox()
mailsumlimit = 200;
else
mailsumlimit = 50;
- mailsumlimit += cuser.exmailbox * 10;
- mailmaxkeep = max_keepmail + cuser.exmailbox;
+ mailsumlimit += cuser->exmailbox * 10;
+ mailmaxkeep = max_keepmail + cuser->exmailbox;
m_init();
if ((mailkeep = get_num_records(currmaildir, sizeof(fileheader_t))) >
mailmaxkeep) {
@@ -224,7 +224,7 @@ hold_mail(char *fpath, char *receiver)
buf, sizeof(buf), LCECHO);
if (buf[0] == 'y')
- do_hold_mail(fpath, receiver, cuser.userid);
+ do_hold_mail(fpath, receiver, cuser->userid);
}
int
@@ -289,7 +289,7 @@ do_send(char *userid, char *title)
strlcpy(receiver, userid, sizeof(receiver));
sethomepath(genbuf, userid);
stampfile(genbuf, &mhdr);
- strlcpy(mhdr.owner, cuser.userid, sizeof(mhdr.owner));
+ strlcpy(mhdr.owner, cuser->userid, sizeof(mhdr.owner));
strncpy(mhdr.title, save_title, TTLEN);
if (vedit(genbuf, YEA, NULL) == -1) {
unlink(genbuf);
@@ -298,10 +298,10 @@ do_send(char *userid, char *title)
}
clear();
sethomefile(fpath, userid, FN_OVERRIDES);
- i = belong(fpath, cuser.userid);
+ i = belong(fpath, cuser->userid);
sethomefile(fpath, userid, FN_REJECT);
- if (i || !belong(fpath, cuser.userid)) {/* Ptt: 用belong有點討厭 */
+ if (i || !belong(fpath, cuser->userid)) {/* Ptt: 用belong有點討厭 */
sethomedir(fpath, userid);
if (append_record_forward(fpath, &mhdr, sizeof(mhdr)) == -1)
return -1;
@@ -447,7 +447,7 @@ multi_send(char *title)
strtok(ptr = genbuf + 3, " \n\r");
do {
if (searchuser(ptr) && !InNameList(ptr) &&
- strcmp(cuser.userid, ptr)) {
+ strcmp(cuser->userid, ptr)) {
AddNameList(ptr);
reciper++;
}
@@ -525,7 +525,7 @@ multi_send(char *title)
unlink(genbuf);
Link(fpath, genbuf);
- strlcpy(mymail.owner, cuser.userid, sizeof(mymail.owner));
+ strlcpy(mymail.owner, cuser->userid, sizeof(mymail.owner));
strlcpy(mymail.title, save_title, sizeof(mymail.title));
mymail.filemode |= FILE_MULTI; /* multi-send flag */
sethomedir(genbuf, p->word);
@@ -602,17 +602,17 @@ mail_all()
setutmpmode(MAILALL);
stand_title("寄信中...");
- sethomepath(genbuf, cuser.userid);
+ sethomepath(genbuf, cuser->userid);
stampfile(genbuf, &mymail);
unlink(genbuf);
Link(fpath, genbuf);
unlink(fpath);
strcpy(fpath, genbuf);
- strlcpy(mymail.owner, cuser.userid, sizeof(mymail.owner)); /* 站長 ID */
+ strlcpy(mymail.owner, cuser->userid, sizeof(mymail.owner)); /* 站長 ID */
strlcpy(mymail.title, save_title, sizeof(mymail.title));
- sethomedir(genbuf, cuser.userid);
+ sethomedir(genbuf, cuser->userid);
if (append_record_forward(genbuf, &mymail, sizeof(mymail)) == -1)
outs(err_uid);
@@ -622,13 +622,13 @@ mail_all()
userid = SHM->userid[i];
if (strcmp(userid, STR_GUEST) && strcmp(userid, "new") &&
- strcmp(userid, cuser.userid)) {
+ strcmp(userid, cuser->userid)) {
sethomepath(genbuf, userid);
stampfile(genbuf, &mymail);
unlink(genbuf);
Link(fpath, genbuf);
- strlcpy(mymail.owner, cuser.userid, sizeof(mymail.owner));
+ strlcpy(mymail.owner, cuser->userid, sizeof(mymail.owner));
strlcpy(mymail.title, save_title, sizeof(mymail.title));
/* mymail.filemode |= FILE_MARKED; Ptt 公告改成不會mark */
sethomedir(genbuf, userid);
@@ -649,8 +649,8 @@ mail_mbox()
char cmd[100];
fileheader_t fhdr;
- snprintf(cmd, sizeof(cmd), "/tmp/%s.uu", cuser.userid);
- snprintf(fhdr.title, sizeof(fhdr.title), "%s 私人資料", cuser.userid);
+ snprintf(cmd, sizeof(cmd), "/tmp/%s.uu", cuser->userid);
+ snprintf(fhdr.title, sizeof(fhdr.title), "%s 私人資料", cuser->userid);
doforward(cmd, &fhdr, 'Z');
return 0;
}
@@ -874,7 +874,7 @@ mail_del(int ent, fileheader_t * fhdr, char *direct)
unlink(genbuf);
if ((currmode & MODE_SELECT)) {
int index;
- sethomedir(genbuf, cuser.userid);
+ sethomedir(genbuf, cuser->userid);
index = getindex(genbuf, fhdr->filename, sizeof(fileheader_t));
delete_record(genbuf, sizeof(fileheader_t), index);
}
@@ -1032,7 +1032,7 @@ mail_edit(int ent, fileheader_t * fhdr, char *direct)
char genbuf[200];
if (!HAS_PERM(PERM_SYSOP) &&
- strcmp(cuser.userid, fhdr->owner) &&
+ strcmp(cuser->userid, fhdr->owner) &&
strcmp("[備.忘.錄]", fhdr->owner))
return DONOTHING;
@@ -1044,8 +1044,8 @@ mail_edit(int ent, fileheader_t * fhdr, char *direct)
static int
mail_nooutmail(int ent, fileheader_t * fhdr, char *direct)
{
- cuser.userlevel ^= PERM_NOOUTMAIL;
- passwd_update(usernum, &cuser);
+ cuser->userlevel ^= PERM_NOOUTMAIL;
+// passwd_update(usernum, &cuser);
return FULLUPDATE;
}
@@ -1123,7 +1123,7 @@ mail_cross_post(int ent, fileheader_t * fhdr, char *direct)
return FULLUPDATE;
ent = 1;
- if (HAS_PERM(PERM_SYSOP) || !strcmp(fhdr->owner, cuser.userid)) {
+ if (HAS_PERM(PERM_SYSOP) || !strcmp(fhdr->owner, cuser->userid)) {
getdata(2, 0, "(1)原文轉載 (2)舊轉錄格式?[1] ",
genbuf, 3, DOECHO);
if (genbuf[0] != '2') {
@@ -1154,7 +1154,7 @@ mail_cross_post(int ent, fileheader_t * fhdr, char *direct)
if (author)
strlcpy(xfile.owner, fhdr->owner, sizeof(xfile.owner));
else
- strlcpy(xfile.owner, cuser.userid, sizeof(xfile.owner));
+ strlcpy(xfile.owner, cuser->userid, sizeof(xfile.owner));
strlcpy(xfile.title, xtitle, sizeof(xfile.title));
if (genbuf[0] == 'l') {
xfile.filemode = FILE_LOCAL;
@@ -1170,7 +1170,7 @@ mail_cross_post(int ent, fileheader_t * fhdr, char *direct)
write_header(xptr);
strlcpy(currboard, xfpath, sizeof(currboard));
- fprintf(xptr, "※ [本文轉錄自 %s 信箱]\n\n", cuser.userid);
+ fprintf(xptr, "※ [本文轉錄自 %s 信箱]\n\n", cuser->userid);
b_suckinfile(xptr, fname);
addsignature(xptr, 0);
@@ -1185,8 +1185,8 @@ mail_cross_post(int ent, fileheader_t * fhdr, char *direct)
setbtotal(getbnum(xboard));
if (!xfile.filemode)
outgo_post(&xfile, xboard);
- cuser.numposts++;
- passwd_update(usernum, &cuser);
+ cuser->numposts++;
+// passwd_update(usernum, &cuser);
outs("文章轉錄完成");
pressanykey();
currmode = currmode0;
@@ -1202,8 +1202,8 @@ mail_man()
int mode0 = currutmp->mode;
int stat0 = currstat;
- sethomeman(buf, cuser.userid);
- snprintf(buf1, sizeof(buf1), "%s 的信件夾", cuser.userid);
+ sethomeman(buf, cuser->userid);
+ snprintf(buf1, sizeof(buf1), "%s 的信件夾", cuser->userid);
a_menu(buf1, buf, 1);
currutmp->mode = mode0;
currstat = stat0;
@@ -1227,7 +1227,7 @@ mail_cite(int ent, fileheader_t * fhdr, char *direct)
title[TTLEN] = '\0';
a_copyitem(fpath, title, 0, 1);
- if (cuser.userlevel >= PERM_BM) {
+ if (cuser->userlevel >= PERM_BM) {
move(2, 0);
clrtoeol();
move(3, 0);
@@ -1269,8 +1269,8 @@ mail_save(int ent, fileheader_t * fhdr, char *direct)
strncpy(title + 3, fhdr->title, TTLEN - 3);
title[TTLEN] = '\0';
a_copyitem(fpath, title, fhdr->owner, 1);
- sethomeman(fpath, cuser.userid);
- a_menu(cuser.userid, fpath, 1);
+ sethomeman(fpath, cuser->userid);
+ a_menu(cuser->userid, fpath, 1);
return FULLUPDATE;
}
return DONOTHING;
@@ -1289,7 +1289,7 @@ mail_waterball(int ent, fileheader_t * fhdr, char *direct)
return 1;
}
if (!address[0])
- strlcpy(address, cuser.email, sizeof(address));
+ strlcpy(address, cuser->email, sizeof(address));
move(b_lines - 8, 0);
outs("水球整理程式:\n"
"系統將會按照和不同人丟的水球各自獨立\n"
@@ -1337,16 +1337,16 @@ mail_waterball(int ent, fileheader_t * fhdr, char *direct)
cmode = (fname[0] != '0' && fname[0] != '1') ? 1 : fname[0] - '0';
snprintf(fname, sizeof(fname), BBSHOME "/jobspool/water.src.%s-%d",
- cuser.userid, (int)now);
+ cuser->userid, (int)now);
snprintf(genbuf, sizeof(genbuf), "cp " BBSHOME "/home/%c/%s/%s %s",
- cuser.userid[0], cuser.userid, fhdr->filename, fname);
+ cuser->userid[0], cuser->userid, fhdr->filename, fname);
system(genbuf);
/* dirty code ;x */
snprintf(fname, sizeof(fname), BBSHOME "/jobspool/water.des.%s-%d",
- cuser.userid, (int)now);
+ cuser->userid, (int)now);
fp = fopen(fname, "wt");
assert(fp);
- fprintf(fp, "%s\n%s\n%d\n", cuser.userid, address, cmode);
+ fprintf(fp, "%s\n%s\n%d\n", cuser->userid, address, cmode);
fclose(fp);
vmsg("設定完成, 系統將在下一個整點(尖峰時段除外)將資料寄給您");
return FULLUPDATE;
@@ -1454,7 +1454,7 @@ m_read()
i_read(RMAIL, currmaildir, mailtitle, maildoent, mail_comms, -1);
currbid = back_bid;
curredit = 0;
- currutmp->mailalert = load_mailalert(cuser.userid);
+ currutmp->mailalert = load_mailalert(cuser->userid);
return 0;
} else {
outs("您沒有來信");
@@ -1473,11 +1473,11 @@ send_inner_mail(char *fpath, char *title, char *receiver)
return -2;
sethomepath(genbuf, receiver);
stampfile(genbuf, &mymail);
- if (!strcmp(receiver, cuser.userid)) {
+ if (!strcmp(receiver, cuser->userid)) {
strlcpy(mymail.owner, "[" BBSNAME "]", sizeof(mymail.owner));
mymail.filemode = FILE_READ;
} else
- strlcpy(mymail.owner, cuser.userid, sizeof(mymail.owner));
+ strlcpy(mymail.owner, cuser->userid, sizeof(mymail.owner));
strncpy(mymail.title, title, TTLEN);
unlink(genbuf);
Link(fpath, genbuf);
@@ -1521,7 +1521,7 @@ bbs_sendmail(char *fpath, char *title, char *receiver)
} else {
snprintf(genbuf, sizeof(genbuf),
"/usr/sbin/sendmail -f %s%s %s > /dev/null",
- cuser.userid, str_mail_address, receiver);
+ cuser->userid, str_mail_address, receiver);
fin = fopen(fpath, "r");
}
fout = popen(genbuf, "w");
@@ -1530,9 +1530,9 @@ bbs_sendmail(char *fpath, char *title, char *receiver)
if (fpath)
fprintf(fout, "Reply-To: %s%s\nFrom: %s <%s%s>\n",
- cuser.userid, str_mail_address,
- cuser.username,
- cuser.userid, str_mail_address);
+ cuser->userid, str_mail_address,
+ cuser->username,
+ cuser->userid, str_mail_address);
fprintf(fout,"To: %s\nSubject: %s\n"
"Mime-Version: 1.0\r\n"
"Content-Type: text/plain; charset=\"big5\"\r\n"
@@ -1593,8 +1593,8 @@ bsmtp(char *fpath, char *title, char *rcpt, int method)
/* setup mail queue */
mqueue.mailtime = chrono;
mqueue.method = method;
- strlcpy(mqueue.sender, cuser.userid, sizeof(mqueue.sender));
- strlcpy(mqueue.username, cuser.username, sizeof(mqueue.username));
+ strlcpy(mqueue.sender, cuser->userid, sizeof(mqueue.sender));
+ strlcpy(mqueue.username, cuser->username, sizeof(mqueue.username));
strlcpy(mqueue.rcpt, rcpt, sizeof(mqueue.rcpt));
if (append_record("out/.DIR", (fileheader_t *) & mqueue, sizeof(mqueue)) < 0)
return 0;
@@ -1611,7 +1611,7 @@ doforward(char *direct, fileheader_t * fh, int mode)
char genbuf[200];
if (!address[0])
- strlcpy(address, cuser.email, sizeof(address));
+ strlcpy(address, cuser->email, sizeof(address));
if( mode == 'U' ){
move(b_lines - 2, 0);
@@ -1658,7 +1658,7 @@ doforward(char *direct, fileheader_t * fh, int mode)
char msg[200];
snprintf(msg, sizeof(msg), "%s mailforward to %s at %s",
- cuser.userid, address, Cdate(&now));
+ cuser->userid, address, Cdate(&now));
log_user(msg);
}
if (mode == 'Z') {
@@ -1666,13 +1666,13 @@ doforward(char *direct, fileheader_t * fh, int mode)
TAR_PATH " cfz /tmp/home.%s.tgz home/%c/%s; "
MUTT_PATH " -a /tmp/home.%s.tgz -s 'home.%s.tgz' '%s' </dev/null;"
"rm /tmp/home.%s.tgz",
- cuser.userid, cuser.userid[0], cuser.userid,
- cuser.userid, cuser.userid, address, cuser.userid);
+ cuser->userid, cuser->userid[0], cuser->userid,
+ cuser->userid, cuser->userid, address, cuser->userid);
system(fname);
return 0;
snprintf(fname, sizeof(fname), TAR_PATH " cfz - home/%c/%s | "
"/usr/bin/uuencode %s.tgz > %s",
- cuser.userid[0], cuser.userid, cuser.userid, direct);
+ cuser->userid[0], cuser->userid, cuser->userid, direct);
system(fname);
strlcpy(fname, direct, sizeof(fname));
} else if (mode == 'U') {
@@ -1748,7 +1748,7 @@ mail_justify(userec_t muser)
sethomepath(buf1, muser.userid);
stampfile(buf1, &mhdr);
unlink(buf1);
- strlcpy(mhdr.owner, cuser.userid, sizeof(mhdr.owner));
+ strlcpy(mhdr.owner, cuser->userid, sizeof(mhdr.owner));
strncpy(mhdr.title, "[審核通過]", TTLEN);
mhdr.filemode = 0;
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index 9ff9790c..bea7c3b7 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -102,7 +102,7 @@ log_user(char *msg)
char filename[200], buf[200];
snprintf(filename, sizeof(filename), BBSHOME "/home/%c/%s/USERLOG",
- cuser.userid[0], cuser.userid);
+ cuser->userid[0], cuser->userid);
snprintf(buf, sizeof(buf), "%s\n", msg);
log_file(filename, msg, 1);
}
@@ -115,14 +115,14 @@ log_usies(char *mode, char *mesg)
if (!mesg)
snprintf(genbuf, sizeof(genbuf),
- cuser.userid[0] ? "%s %s %-12s Stay:%d (%s)\n" :
+ cuser->userid[0] ? "%s %s %-12s Stay:%d (%s)\n" :
"%s %s %s Stay:%d (%s)\n",
- Cdate(&now), mode, cuser.userid,
- (int)(now - login_start_time) / 60, cuser.username);
+ Cdate(&now), mode, cuser->userid,
+ (int)(now - login_start_time) / 60, cuser->username);
else
snprintf(genbuf, sizeof(genbuf),
- cuser.userid[0] ? "%s %s %-12s %s\n" : "%s %s %s%s\n",
- Cdate(&now), mode, cuser.userid, mesg);
+ cuser->userid[0] ? "%s %s %-12s %s\n" : "%s %s %s%s\n",
+ Cdate(&now), mode, cuser->userid, mesg);
log_file(FN_USIES, genbuf, 1);
/* 追蹤使用者 */
@@ -134,9 +134,9 @@ static void
setflags(int mask, int value)
{
if (value)
- cuser.uflag |= mask;
+ cuser->uflag |= mask;
else
- cuser.uflag &= ~mask;
+ cuser->uflag &= ~mask;
}
void
@@ -157,28 +157,28 @@ u_exit(char *mode)
brc_finalize();
#ifdef ASSESS
- cuser.goodpost = currutmp->goodpost;
- cuser.badpost = currutmp->badpost;
- cuser.goodsale = currutmp->goodsale;
- cuser.badsale = currutmp->badsale;
+ cuser->goodpost = currutmp->goodpost;
+ cuser->badpost = currutmp->badpost;
+ cuser->goodsale = currutmp->goodsale;
+ cuser->badsale = currutmp->badsale;
#endif
- cuser.invisible = currutmp->invisible;
- cuser.pager = currutmp->pager;
- memcpy(cuser.mind, currutmp->mind, 4);
+ cuser->invisible = currutmp->invisible;
+ cuser->pager = currutmp->pager;
+ memcpy(cuser->mind, currutmp->mind, 4);
setutmpbid(0);
if (!(HAS_PERM(PERM_SYSOP) && HAS_PERM(PERM_DENYPOST)) &&
!currutmp->invisible)
do_aloha("<<下站通知>> -- 我走囉!");
purge_utmp(currutmp);
- if ((cuser.uflag != enter_uflag) || (currmode & MODE_DIRTY) || diff) {
- if (!diff && cuser.numlogins)
- cuser.numlogins = --cuser.numlogins;
+ if ((cuser->uflag != enter_uflag) || (currmode & MODE_DIRTY) || diff) {
+ if (!diff && cuser->numlogins)
+ cuser->numlogins = --cuser->numlogins;
/* Leeym 上站停留時間限制式 */
}
- passwd_update(usernum, &cuser);
- passwd_index_update(usernum, &cuser);
+ passwd_index_update(usernum, cuser);
+ freecuser();
log_usies(mode, NULL);
}
@@ -216,7 +216,7 @@ abort_bbs_debug(int sig)
reentrant = 1;
if (currmode)
u_exit("AXXED");
- setproctitle("debug me!(%d)(%s,%d)", sig, cuser.userid, currstat);
+ setproctitle("debug me!(%d)(%s,%d)", sig, cuser->userid, currstat);
sleep(3600); /* wait 60 mins for debug */
}
#endif
@@ -230,16 +230,6 @@ mysrand()
srand(time(NULL) + getpid()); /* 時間跟 pid 當 rand 的 seed */
}
-int
-dosearchuser(char *userid)
-{
- if ((usernum = getuser(userid)))
- memcpy(&cuser, &xuser, sizeof(cuser));
- else
- memset(&cuser, 0, sizeof(cuser));
- return usernum;
-}
-
void
talk_request(int sig)
{
@@ -288,7 +278,7 @@ show_call_in(int save, int which)
char genbuf[200];
time_t now;
if (!fp_writelog) {
- sethomefile(genbuf, cuser.userid, fn_writelog);
+ sethomefile(genbuf, cuser->userid, fn_writelog);
fp_writelog = fopen(genbuf, "a");
}
if (fp_writelog) {
@@ -403,7 +393,7 @@ write_request(int sig)
} else {
if (currutmp->mode != 0 &&
currutmp->pager != 0 &&
- cuser.userlevel != 0 &&
+ cuser->userlevel != 0 &&
currutmp->msgcount != 0 &&
currutmp->mode != TALK &&
currutmp->mode != EDITING &&
@@ -466,7 +456,7 @@ multi_user_check()
if (HAS_PERM(PERM_SYSOP))
return; /* don't check sysops */
- if (cuser.userlevel) {
+ if (cuser->userlevel) {
if (!(ui = (userinfo_t *) search_ulist(usernum)))
return; /* user isn't logged in */
@@ -480,7 +470,7 @@ multi_user_check()
if (genbuf[0] != 'n') {
if (pid > 0)
kill(pid, SIGHUP);
- log_usies("KICK ", cuser.username);
+ log_usies("KICK ", cuser->username);
} else {
if (search_ulistn(usernum, 3) != NULL)
system_abort(); /* Goodbye(); */
@@ -590,43 +580,43 @@ login_query()
if (strcasecmp(uid, str_new) == 0) {
#ifdef LOGINASNEW
new_register();
- mkuserdir(cuser.userid);
+ mkuserdir(cuser->userid);
break;
#else
outs("本系統目前無法以 new 註冊, 請用 guest 進入\n");
continue;
#endif
- } else if (uid[0] == '\0' || !dosearchuser(uid)) {
+ } else if (uid[0] == '\0' || !initcuser(uid)) {
outs(err_uid);
} else if (strcmp(uid, STR_GUEST)) {
getdata(21, 0, MSG_PASSWD,
passbuf, sizeof(passbuf), NOECHO);
passbuf[8] = '\0';
- if (!checkpasswd(cuser.passwd, passbuf)
+ if (!checkpasswd(cuser->passwd, passbuf)
/* || (HAS_PERM(PERM_SYSOP) && !use_shell_login_mode) */ ) {
- logattempt(cuser.userid, '-');
+ logattempt(cuser->userid, '-');
outs(ERR_PASSWD);
} else {
- logattempt(cuser.userid, ' ');
- if (strcasecmp("SYSOP", cuser.userid) == 0){
+ logattempt(cuser->userid, ' ');
+ if (strcasecmp("SYSOP", cuser->userid) == 0){
#ifdef NO_SYSOP_ACCOUNT
exit(0);
#else /* 自動加上各個主要權限 */
- cuser.userlevel = PERM_BASIC | PERM_CHAT | PERM_PAGE |
+ cuser->userlevel = PERM_BASIC | PERM_CHAT | PERM_PAGE |
PERM_POST | PERM_LOGINOK | PERM_MAILLIMIT |
PERM_CLOAK | PERM_SEECLOAK | PERM_XEMPT |
PERM_DENYPOST | PERM_BM | PERM_ACCOUNTS |
PERM_CHATROOM | PERM_BOARD | PERM_SYSOP | PERM_BBSADM;
- mkuserdir(cuser.userid);
+ mkuserdir(cuser->userid);
#endif
}
break;
}
} else { /* guest */
- cuser.userlevel = 0;
- cuser.uflag = COLOR_FLAG | PAGER_FLAG | BRDSORT_FLAG | MOVIE_FLAG;
- mkuserdir(cuser.userid);
+ cuser->userlevel = 0;
+ cuser->uflag = COLOR_FLAG | PAGER_FLAG | BRDSORT_FLAG | MOVIE_FLAG;
+ mkuserdir(cuser->userid);
break;
}
}
@@ -752,7 +742,7 @@ check_BM(void)
/* XXX: -_- */
int i;
- cuser.userlevel &= ~PERM_BM;
+ cuser->userlevel &= ~PERM_BM;
for( i = 0 ; i < numboards ; ++i )
if( is_BM_cache(i + 1) ) /* XXXbid */
return;
@@ -767,31 +757,31 @@ setup_utmp(int mode)
uinfo.pid = currpid = getpid();
uinfo.uid = usernum;
uinfo.mode = currstat = mode;
- uinfo.mailalert = load_mailalert(cuser.userid);
+ uinfo.mailalert = load_mailalert(cuser->userid);
#ifdef ASSESS
- uinfo.goodpost = cuser.goodpost;
- uinfo.badpost = cuser.badpost;
- uinfo.goodsale = cuser.goodsale;
- uinfo.badsale = cuser.badsale;
+ uinfo.goodpost = cuser->goodpost;
+ uinfo.badpost = cuser->badpost;
+ uinfo.goodsale = cuser->goodsale;
+ uinfo.badsale = cuser->badsale;
#endif
- uinfo.userlevel = cuser.userlevel;
- uinfo.sex = cuser.sex % 8;
+ uinfo.userlevel = cuser->userlevel;
+ uinfo.sex = cuser->sex % 8;
uinfo.lastact = time(NULL);
- strlcpy(uinfo.userid, cuser.userid, sizeof(uinfo.userid));
- //strlcpy(uinfo.realname, cuser.realname, sizeof(uinfo.realname));
- strlcpy(uinfo.username, cuser.username, sizeof(uinfo.username));
+ strlcpy(uinfo.userid, cuser->userid, sizeof(uinfo.userid));
+ //strlcpy(uinfo.realname, cuser->realname, sizeof(uinfo.realname));
+ strlcpy(uinfo.username, cuser->username, sizeof(uinfo.username));
strlcpy(uinfo.from, fromhost, sizeof(uinfo.from));
- uinfo.five_win = cuser.five_win;
- uinfo.five_lose = cuser.five_lose;
- uinfo.five_tie = cuser.five_tie;
- uinfo.chc_win = cuser.chc_win;
- uinfo.chc_lose = cuser.chc_lose;
- uinfo.chc_tie = cuser.chc_tie;
- uinfo.invisible = cuser.invisible % 2;
- uinfo.pager = cuser.pager % 5;
- memcpy(uinfo.mind, cuser.mind, 4);
+ uinfo.five_win = cuser->five_win;
+ uinfo.five_lose = cuser->five_lose;
+ uinfo.five_tie = cuser->five_tie;
+ uinfo.chc_win = cuser->chc_win;
+ uinfo.chc_lose = cuser->chc_lose;
+ uinfo.chc_tie = cuser->chc_tie;
+ uinfo.invisible = cuser->invisible % 2;
+ uinfo.pager = cuser->pager % 5;
+ memcpy(uinfo.mind, cuser->mind, 4);
#ifdef WHERE
uinfo.from_alias = where(fromhost);
#endif
@@ -807,7 +797,7 @@ setup_utmp(int mode)
uinfo.invisible = YEA;
getnewutmpent(&uinfo);
SHM->UTMPneedsort = 1;
- if (!(cuser.numlogins % 20) && cuser.userlevel & PERM_BM)
+ if (!(cuser->numlogins % 20) && cuser->userlevel & PERM_BM)
check_BM(); /* Ptt 自動取下離職板主權力 */
#ifndef _BBS_UTIL_C_
friend_load(0);
@@ -819,7 +809,7 @@ inline static void welcome_msg(void) {
prints("\033[m 歡迎您第 \033[1;33m%d\033[0;37m 度拜訪本站,"
"上次您是從 \033[1;33m%s\033[0;37m 連往本站,\n"
" 我記得那天是 \033[1;33m%s\033[0;37m。\n",
- ++cuser.numlogins, cuser.lasthost, Cdate(&cuser.lastlogin));
+ ++cuser->numlogins, cuser->lasthost, Cdate(&(cuser->lastlogin)));
pressanykey();
}
@@ -846,8 +836,8 @@ inline static void birthday_make_a_wish(struct tm *ptime, struct tm *tmp){
}
inline static void record_lasthost(char *fromhost, int len){
- strncpy(cuser.lasthost, fromhost, len);
- cuser.lasthost[len - 1] = '\0';
+ strncpy(cuser->lasthost, fromhost, len);
+ cuser->lasthost[len - 1] = '\0';
}
inline static void check_mailbox_quota(void){
@@ -874,25 +864,24 @@ static void init_guest_info(void)
"愛之味", "天上", "藍色珊瑚礁"
};
i = login_start_time % 13;
- snprintf(cuser.username, sizeof(cuser.username),
+ snprintf(cuser->username, sizeof(cuser->username),
"海邊漂來的%s", nick[(int)i]);
- strlcpy(currutmp->username, cuser.username,
+ strlcpy(currutmp->username, cuser->username,
sizeof(currutmp->username));
- strlcpy(cuser.realname, name[(int)i], sizeof(cuser.realname));
- //strlcpy(currutmp->realname, cuser.realname, sizeof(currutmp->realname));
- strlcpy(cuser.address, addr[(int)i], sizeof(cuser.address));
- cuser.sex = i % 8;
+ strlcpy(cuser->realname, name[(int)i], sizeof(cuser->realname));
+ strlcpy(cuser->address, addr[(int)i], sizeof(cuser->address));
+ cuser->sex = i % 8;
currutmp->pager = 2;
}
#ifdef FOREIGN_REG
inline static void foreign_warning(void){
- if ((cuser.uflag2 & FOREIGN) && !(cuser.uflag2 & LIVERIGHT)){
- if (login_start_time - cuser.firstlogin > (FOREIGN_REG_DAY - 5) * 24 * 3600){
- mail_muser(cuser, "[出入境管理局]", "etc/foreign_expired_warn");
+ if ((cuser->uflag2 & FOREIGN) && !(cuser->uflag2 & LIVERIGHT)){
+ if (login_start_time - cuser->firstlogin > (FOREIGN_REG_DAY - 5) * 24 * 3600){
+ mail_muser(*cuser, "[出入境管理局]", "etc/foreign_expired_warn");
}
- else if (login_start_time - cuser.firstlogin > FOREIGN_REG_DAY * 24 * 3600){
- cuser.userlevel &= ~(PERM_LOGINOK | PERM_POST);
+ else if (login_start_time - cuser->firstlogin > FOREIGN_REG_DAY * 24 * 3600){
+ cuser->userlevel &= ~(PERM_LOGINOK | PERM_POST);
vmsg("警告:請至出入境管理局申請永久居留");
}
}
@@ -916,8 +905,8 @@ user_login()
mysrand();
/* show welcome_login */
- ifbirth = (ptime->tm_mday == cuser.day &&
- ptime->tm_mon + 1 == cuser.month);
+ ifbirth = (ptime->tm_mday == cuser->day &&
+ ptime->tm_mon + 1 == cuser->month);
if (ifbirth)
more("etc/Welcome_birth", NA);
else {
@@ -934,7 +923,7 @@ user_login()
}
log_usies("ENTER", fromhost);
- setproctitle("%s: %s", margs, cuser.userid);
+ setproctitle("%s: %s", margs, cuser->userid);
resolve_fcache();
resolve_boards();
memset(&water[0], 0, sizeof(water_t) * 6);
@@ -952,10 +941,10 @@ user_login()
/* 初始化 uinfo、flag、mode */
setup_utmp(LOGIN);
currmode = MODE_STARTED;
- enter_uflag = cuser.uflag;
+ enter_uflag = cuser->uflag;
currutmp->birth = ifbirth;
- tmp = localtime(&cuser.lastlogin);
+ tmp = localtime(&(cuser->lastlogin));
if ((a = SHM->UTMPnumber) > SHM->max_user) {
SHM->max_user = a;
SHM->max_time = now;
@@ -972,7 +961,7 @@ user_login()
else
SHM->loginmsg.pid=0;
}
- if (cuser.userlevel) { /* not guest */
+ if (cuser->userlevel) { /* not guest */
move(t_lines - 4, 0);
welcome_msg();
@@ -982,7 +971,7 @@ user_login()
check_register();
record_lasthost(fromhost, 16);
restore_backup();
- } else if (!strcmp(cuser.userid, STR_GUEST)) {
+ } else if (!strcmp(cuser->userid, STR_GUEST)) {
init_guest_info();
pressanykey();
} else {
@@ -991,15 +980,15 @@ user_login()
}
if (!PERM_HIDE(currutmp))
- cuser.lastlogin = login_start_time;
+ cuser->lastlogin = login_start_time;
#ifdef FOREIGN_REG
foreign_warning();
#endif
- passwd_update(usernum, &cuser);
+ // passwd_update(usernum, &cuser);
for (i = 0; i < NUMVIEWFILE; i++)
- if ((cuser.loginview >> i) & 1)
+ if ((cuser->loginview >> i) & 1)
more(loginview_file[(int)i][0], YEA);
}
@@ -1083,7 +1072,7 @@ start_client()
b_closepolls();
SHM->close_vote_time = now;
}
- if (!(cuser.uflag & COLOR_FLAG))
+ if (!(cuser->uflag & COLOR_FLAG))
showansi = 0;
signal(SIGALRM, SIG_IGN);
diff --git a/mbbsd/menu.c b/mbbsd/menu.c
index 870b9572..1b8a5e5b 100644
--- a/mbbsd/menu.c
+++ b/mbbsd/menu.c
@@ -24,7 +24,6 @@ egetch()
}
}
-extern userec_t cuser;
extern char *fn_board;
extern char board_hidden_status;
@@ -113,14 +112,14 @@ show_status(void)
ptime->tm_mon + 1, ptime->tm_mday, myweek[i], myweek[i + 1],
ptime->tm_hour, ptime->tm_min, currutmp->birth ?
"生日要請客唷" : SHM->today_is,
- SHM->UTMPnumber, cuser.userid, msgs[currutmp->pager]);
+ SHM->UTMPnumber, cuser->userid, msgs[currutmp->pager]);
outmsg(mystatus);
}
static int
u_movie()
{
- cuser.uflag ^= MOVIE_FLAG;
+ cuser->uflag ^= MOVIE_FLAG;
return 0;
}
@@ -130,7 +129,7 @@ movie(int i)
static short history[MAX_HISTORY];
int j;
- if ((currstat != CLASS) && (cuser.uflag & MOVIE_FLAG) &&
+ if ((currstat != CLASS) && (cuser->uflag & MOVIE_FLAG) &&
!SHM->Pbusystate && SHM->max_film > 0) {
if (currstat == PSALE) {
i = PSALE;
@@ -177,7 +176,7 @@ show_menu(commands_t * p)
move(menu_row, 0);
while ((s = p[n].desc)) {
if (HAS_PERM(p[n].level)) {
- snprintf(buf, sizeof(buf), s + 2, state[cuser.proverb % 4]);
+ snprintf(buf, sizeof(buf), s + 2, state[cuser->proverb % 4]);
prints("%*s (\033[1;36m%c\033[0m)%s\n", menu_column, "", s[1],
buf);
}
diff --git a/mbbsd/othello.c b/mbbsd/othello.c
index 96fea2e2..b4625a58 100644
--- a/mbbsd/othello.c
+++ b/mbbsd/othello.c
@@ -95,7 +95,7 @@ printboard()
print_chess(4, 5, BLACK);
print_chess(5, 4, BLACK);
move(3, 56);
- prints("(黑)%s", cuser.userid);
+ prints("(黑)%s", cuser->userid);
move(3, 72);
prints(": 02");
move(4, 56);
@@ -229,7 +229,7 @@ end_of_game(int quit)
fp1 = fopen(SECRET, "a");
if (fp1) {
fprintf(fp1, "%d,%d,%s,%02d,%02d\n", think, which_table,
- cuser.userid, number[0], number[1]);
+ cuser->userid, number[0], number[1]);
fclose(fp1);
}
}
@@ -239,7 +239,7 @@ end_of_game(int quit)
fclose(fp);
return;
}
- fprintf(fp, "在%s級中, %s臨陣脫逃\n", opponent[think], cuser.userid);
+ fprintf(fp, "在%s級中, %s臨陣脫逃\n", opponent[think], cuser->userid);
if (fp)
fclose(fp);
return;
@@ -252,7 +252,7 @@ end_of_game(int quit)
demoney(200);
if (fp)
fprintf(fp, "在%s級中, %s以 %02d:%02d 贏了電腦%02d子\n",
- opponent[think], cuser.userid, number[0], number[1],
+ opponent[think], cuser->userid, number[0], number[1],
number[0] - number[1]);
} else if (number[1] > number[0]) {
prints("電腦贏了你%02d子", number[1] - number[0]);
@@ -260,16 +260,16 @@ end_of_game(int quit)
fprintf(fp, "在%s級中, ", opponent[think]);
if (number[1] - number[0] > 20)
fprintf(fp, "電腦以 %02d:%02d 慘電%s %02d子\n", number[1],
- number[0], cuser.userid, number[1] - number[0]);
+ number[0], cuser->userid, number[1] - number[0]);
else
fprintf(fp, "電腦以 %02d:%02d 贏了%s %02d子\n", number[1],
- number[0], cuser.userid, number[1] - number[0]);
+ number[0], cuser->userid, number[1] - number[0]);
}
} else {
prints("你和電腦打成平手!!");
if (fp)
fprintf(fp, "在%s級中, %s和電腦以 %02d:%02d 打成了平手\n",
- opponent[think], cuser.userid, number[1], number[0]);
+ opponent[think], cuser->userid, number[1], number[0]);
}
if (fp)
fclose(fp);
@@ -394,7 +394,7 @@ report()
else if (nowboard[i][j] == WHITE)
number[1]++;
move(3, 60);
- prints("%s", cuser.userid);
+ prints("%s", cuser->userid);
move(3, 72);
prints(": %02d", number[0]);
move(4, 60);
diff --git a/mbbsd/page.c b/mbbsd/page.c
index 1757412f..78e9ce0f 100644
--- a/mbbsd/page.c
+++ b/mbbsd/page.c
@@ -136,7 +136,7 @@ main_railway()
break;
line++;
- sethomepath(genbuf, cuser.userid);
+ sethomepath(genbuf, cuser->userid);
stampfile(genbuf, &mhdr);
strlcpy(mhdr.owner, "Ptt搜尋器", sizeof(mhdr.owner));
strncpy(mhdr.title, "火車時刻搜尋結果", TTLEN);
@@ -148,7 +148,7 @@ main_railway()
(type[0] == '1') ? "fast" : "slow", date, genbuf);
system(command);
- sethomedir(genbuf, cuser.userid);
+ sethomedir(genbuf, cuser->userid);
if (append_record(genbuf, &mhdr, sizeof(mhdr)) == -1)
return -1;
hpressanykey("\033[1;31m我們會把搜尋結果很快地寄給你唷 ^_^\033[m");
diff --git a/mbbsd/passwd.c b/mbbsd/passwd.c
index 777fd23a..95a3b39b 100644
--- a/mbbsd/passwd.c
+++ b/mbbsd/passwd.c
@@ -122,6 +122,36 @@ passwd_index_query(int num, userec_t * buf)
return 0;
}
+int initcuser(char *userid)
+{
+ int pwdfd;
+ userec_t buf;
+ char path[256];
+ // Ptt: setup cuser and usernum here
+ if(userid[0]=='\0') return -1;
+ if(!(usernum = searchuser(userid)) || usernum > MAX_USERS) return -1;
+
+ sethomefile(path, userid, ".passwd");
+ if((pwdfd = open(path, O_RDONLY)) < 0)
+ {
+ if(passwd_index_query(usernum, &buf)<0)
+ exit(1);
+ passwd_update(usernum, &buf);
+ if((pwdfd = open(path, O_RDONLY)) < 0) exit(1);
+ }
+ cuser = (userec_t *) mmap(NULL, sizeof(userec_t), PROT_READ, MAP_SHARED,
+ pwdfd, 0);
+
+ if(cuser == (userec_t *) -1) exit(1);
+ close(pwdfd);
+ return usernum;
+}
+
+int freecuser()
+{
+ return munmap(cuser, sizeof(userec_t));
+}
+
int
passwd_query(int num, userec_t * buf)
{
diff --git a/mbbsd/read.c b/mbbsd/read.c
index 8074c71b..6330e68b 100644
--- a/mbbsd/read.c
+++ b/mbbsd/read.c
@@ -498,9 +498,9 @@ select_read(keeploc_t * locmem, int sr_mode)
}
if ((fd = open(currdirect, O_RDONLY, 0)) != -1) {
- snprintf(genbuf, sizeof(genbuf), "SR.%s", cuser.userid);
+ snprintf(genbuf, sizeof(genbuf), "SR.%s", cuser->userid);
if (currstat == RMAIL)
- sethomefile(fpath, cuser.userid, genbuf);
+ sethomefile(fpath, cuser->userid, genbuf);
else
setbfile(fpath, currboard, genbuf);
if (((fr = open(fpath, O_WRONLY | O_CREAT | O_TRUNC, 0600)) != -1)) {
diff --git a/mbbsd/register.c b/mbbsd/register.c
index 0580e485..53de740e 100644
--- a/mbbsd/register.c
+++ b/mbbsd/register.c
@@ -278,7 +278,7 @@ new_register()
exit(1);
}
setuserid(allocid, newuser.userid);
- if( (uid = dosearchuser(newuser.userid)) )
+ if( (uid = initcuser(newuser.userid)) )
setumoney(uid, 0);
else{
fprintf(stderr, "無法建立帳號\n");
@@ -304,33 +304,33 @@ check_register()
stand_title("請詳細填寫個人資料");
- while (strlen(cuser.username) < 2)
- getdata(2, 0, "綽號暱稱:", cuser.username,
- sizeof(cuser.username), DOECHO);
+ while (strlen(cuser->username) < 2)
+ getdata(2, 0, "綽號暱稱:", cuser->username,
+ sizeof(cuser->username), DOECHO);
- for (ptr = cuser.username; *ptr; ptr++) {
+ for (ptr = cuser->username; *ptr; ptr++) {
if (*ptr == 9) /* TAB convert */
*ptr = ' ';
}
- while (strlen(cuser.realname) < 4)
- getdata(4, 0, "真實姓名:", cuser.realname,
- sizeof(cuser.realname), DOECHO);
+ while (strlen(cuser->realname) < 4)
+ getdata(4, 0, "真實姓名:", cuser->realname,
+ sizeof(cuser->realname), DOECHO);
- while (strlen(cuser.address) < 8)
- getdata(6, 0, "聯絡地址:", cuser.address,
- sizeof(cuser.address), DOECHO);
+ while (strlen(cuser->address) < 8)
+ getdata(6, 0, "聯絡地址:", cuser->address,
+ sizeof(cuser->address), DOECHO);
/*
- * if(!strchr(cuser.email, '@')) { bell(); move(t_lines - 4, 0); prints("
+ * if(!strchr(cuser->email, '@')) { bell(); move(t_lines - 4, 0); prints("
* 您的權益,請填寫真實的 E-mail address," "以資確認閣下身份,\n" "
* 033[44muser@domain_name\033[0m 或 \033[44muser"
* "@\\[ip_number\\]\033[0m。\n\n" "※ 如果您真的沒有 E-mail, turn]
* 即可。");
*
- * do { getdata(8, 0, "電子信箱:", cuser.email, sizeof(cuser.email),
- * DOECHO); if(!cuser.email[0]) sprintf(cuser.email, "%s%s",
- * cuser.userid, str_mail_address); } while(!strchr(cuser.email, '@'));
+ * do { getdata(8, 0, "電子信箱:", cuser->email, sizeof(cuser->email),
+ * DOECHO); if(!cuser->email[0]) sprintf(cuser->email, "%s%s",
+ * cuser->userid, str_mail_address); } while(!strchr(cuser->email, '@'));
*
* } */
if (!HAS_PERM(PERM_SYSOP)) {
@@ -342,8 +342,8 @@ check_register()
u_register();
#ifdef NEWUSER_LIMIT
- if (cuser.lastlogin - cuser.firstlogin < 3 * 86400)
- cuser.userlevel &= ~PERM_POST;
+ if (cuser->lastlogin - cuser->firstlogin < 3 * 86400)
+ cuser->userlevel &= ~PERM_POST;
more("etc/newuser", YEA);
#endif
}
diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c
index 6e3e5e00..767fdca1 100644
--- a/mbbsd/stuff.c
+++ b/mbbsd/stuff.c
@@ -35,6 +35,7 @@ sethomeman(char *buf, char *userid)
sprintf(buf, str_home_file, userid[0], userid, "man");
}
+
void
sethomefile(char *buf, char *userid, char *fname)
{
@@ -44,7 +45,7 @@ sethomefile(char *buf, char *userid, char *fname)
void
setuserfile(char *buf, char *fname)
{
- sprintf(buf, str_home_file, cuser.userid[0], cuser.userid, fname);
+ sprintf(buf, str_home_file, cuser->userid[0], cuser->userid, fname);
}
void
@@ -242,8 +243,8 @@ is_uBM(char *list, char *id)
int
is_BM(char *list)
{
- if (is_uBM(list, cuser.userid)) {
- cuser.userlevel |= PERM_BM; /* Ptt 自動加上BM的權利 */
+ if (is_uBM(list, cuser->userid)) {
+ cuser->userlevel |= PERM_BM; /* Ptt 自動加上BM的權利 */
return 1;
}
return 0;
diff --git a/mbbsd/syspost.c b/mbbsd/syspost.c
index 8fdc361c..1e4e25af 100644
--- a/mbbsd/syspost.c
+++ b/mbbsd/syspost.c
@@ -1,4 +1,4 @@
-/* $Id: syspost.c,v 1.18 2003/01/19 16:06:06 kcwu Exp $ */
+/* $Id$ */
#include "bbs.h"
int
@@ -86,12 +86,12 @@ post_change_perm(int oldperm, int newperm, char *sysopid, char *userid)
while (!getdata_str(5, 0, "請輸入理由以示負責:",
reason, sizeof(reason), DOECHO, "看板板主:"));
fprintf(fp, "\n \033[1;37m站長%s修改權限理由是:%s\033[m",
- cuser.userid, reason);
+ cuser->userid, reason);
fclose(fp);
snprintf(fhdr.title, sizeof(fhdr.title),
"[公安報告] 站長%s修改%s權限報告",
- cuser.userid, userid);
+ cuser->userid, userid);
strlcpy(fhdr.owner, "[系統安全局]", sizeof(fhdr.owner));
append_record("boards/S/Security/.DIR", &fhdr, sizeof(fhdr));
} else
@@ -148,7 +148,7 @@ post_newboard(char *bgroup, char *bname, char *bms)
snprintf(title, sizeof(title), "[新板成立] %s", bname);
snprintf(genbuf, sizeof(genbuf),
"%s 開了一個新板 %s : %s\n\n新任板主為 %s\n\n恭喜*^_^*\n",
- cuser.userid, bname, bgroup, bms);
+ cuser->userid, bname, bgroup, bms);
post_msg("Record", title, genbuf, "[系統]");
}
@@ -166,15 +166,15 @@ give_money_post(char *userid, int money)
return;
fprintf(fp, "作者: [系統安全局] 看板: Security\n"
"標題: [公安報告] 站長%s使用紅包機報告\n"
- "時間: %s\n", cuser.userid, ctime(&now));
+ "時間: %s\n", cuser->userid, ctime(&now));
clrtobot();
clear();
fprintf(fp, "\n 站長\033[1;32m%s\033[m給\033[1;33m%s %d 元\033[m",
- cuser.userid, userid, money);
+ cuser->userid, userid, money);
fclose(fp);
snprintf(fhdr.title, sizeof(fhdr.title), "[公安報告] 站長%s使用紅包機報告",
- cuser.userid);
+ cuser->userid);
strlcpy(fhdr.owner, "[系統安全局]", sizeof(fhdr.owner));
append_record("boards/S/Security/.DIR", &fhdr, sizeof(fhdr));
}
diff --git a/mbbsd/talk.c b/mbbsd/talk.c
index 7822e665..c54291a2 100644
--- a/mbbsd/talk.c
+++ b/mbbsd/talk.c
@@ -363,7 +363,7 @@ my_query(char *uident)
muser.username,
26 - strlen(muser.userid) - strlen(muser.username), "",
money[i]);
- if (uentp && ((fri_stat & HFM && !uentp->invisible) || strcmp(muser.userid,cuser.userid) == 0))
+ if (uentp && ((fri_stat & HFM && !uentp->invisible) || strcmp(muser.userid,cuser->userid) == 0))
prints(" ($%d)", muser.money);
prints("\n");
@@ -393,7 +393,7 @@ my_query(char *uident)
prints("《競標評比》 優 %d / 劣 %d", muser.goodsale, muser.badsale);
move(6, 40);
#endif
- if ((uentp && ((fri_stat & HFM) || strcmp(muser.userid,cuser.userid) == 0) && !uentp->invisible))
+ if ((uentp && ((fri_stat & HFM) || strcmp(muser.userid,cuser->userid) == 0) && !uentp->invisible))
prints("《 性 別 》%-28.28s\n", sex[muser.sex % 8]);
showplans(uident);
@@ -640,7 +640,7 @@ my_write(pid_t pid, char *prompt, char *id, int flag, userinfo_t * puin)
if (flag != 2) { /* aloha 的水球不用存下來 */
/* 存到自己的水球檔 */
if (!fp_writelog) {
- sethomefile(genbuf, cuser.userid, fn_writelog);
+ sethomefile(genbuf, cuser->userid, fn_writelog);
fp_writelog = fopen(genbuf, "a");
}
if (fp_writelog) {
@@ -670,7 +670,7 @@ my_write(pid_t pid, char *prompt, char *id, int flag, userinfo_t * puin)
uin->msgcount = write_pos + 1;
uin->pager = 2;
uin->msgs[write_pos].pid = currpid;
- strlcpy(uin->msgs[write_pos].userid, cuser.userid,
+ strlcpy(uin->msgs[write_pos].userid, cuser->userid,
sizeof(uin->msgs[write_pos].userid));
strlcpy(uin->msgs[write_pos].last_call_in, msg,
sizeof(uin->msgs[write_pos].last_call_in));
@@ -820,13 +820,13 @@ t_display(void)
fileheader_t mymail;
char title[128], buf[80];
- sethomepath(buf, cuser.userid);
+ sethomepath(buf, cuser->userid);
stampfile(buf, &mymail);
mymail.filemode = FILE_READ ;
strlcpy(mymail.owner, "[備.忘.錄]", sizeof(mymail.owner));
strlcpy(mymail.title, "熱線記錄", sizeof(mymail.title));
- sethomedir(title, cuser.userid);
+ sethomedir(title, cuser->userid);
Rename(genbuf, buf);
append_record(title, &mymail, sizeof(mymail));
} else if (*ans == 'c')
@@ -976,7 +976,7 @@ do_talk_char(talkwin_t * twin, int ch, FILE *flog)
fprintf(flog, "%s%s: %s%s\n",
(twin->eline == b_lines - 1) ? "\033[1;35m" : "",
(twin->eline == b_lines - 1) ?
- getuserid(currutmp->destuid) : cuser.userid, buf,
+ getuserid(currutmp->destuid) : cuser->userid, buf,
(ch == Ctrl('P')) ? "\033[37;45m(Up)\033[m" : "\033[m");
}
@@ -993,7 +993,7 @@ do_talk(int fd)
ptime = localtime(&now);
- sethomepath(fpath, cuser.userid);
+ sethomepath(fpath, cuser->userid);
strlcpy(fpath, tempnam(fpath, "talk_"), sizeof(fpath));
flog = fopen(fpath, "w");
@@ -1006,7 +1006,7 @@ do_talk(int fd)
setutmpmode(TALK);
ch = 58 - strlen(save_page_requestor);
- snprintf(genbuf, sizeof(genbuf), "%s【%s", cuser.userid, cuser.username);
+ snprintf(genbuf, sizeof(genbuf), "%s【%s", cuser->userid, cuser->username);
i = ch - strlen(genbuf);
if (i >= 0)
i = (i >> 1) + 1;
@@ -1103,14 +1103,14 @@ do_talk(int fd)
fileheader_t mymail;
char title[128];
- sethomepath(genbuf, cuser.userid);
+ sethomepath(genbuf, cuser->userid);
stampfile(genbuf, &mymail);
mymail.filemode = FILE_READ ;
strlcpy(mymail.owner, "[備.忘.錄]", sizeof(mymail.owner));
snprintf(mymail.title, sizeof(mymail.title),
"對話記錄 \033[1;36m(%s)\033[m",
getuserid(currutmp->destuid));
- sethomedir(title, cuser.userid);
+ sethomedir(title, cuser->userid);
Rename(fpath, genbuf);
append_record(title, &mymail, sizeof(mymail));
} else
@@ -1287,7 +1287,7 @@ my_talk(userinfo_t * uin, int fri_stat, char defact)
getuser(uin->userid);
if (uin->lockmode == CHICKEN || currutmp->lockmode == CHICKEN)
error = 1;
- if (!cuser.mychicken.name[0] || !xuser.mychicken.name[0])
+ if (!cuser->mychicken.name[0] || !xuser.mychicken.name[0])
error = 2;
if (error) {
outmsg(error == 2 ? "並非兩人都養寵物" :
@@ -1576,7 +1576,7 @@ int
pickup_maxpages(int pickupway, int nfriends)
{
int number;
- if (cuser.uflag & FRIEND_FLAG)
+ if (cuser->uflag & FRIEND_FLAG)
number = nfriends;
else
number = SHM->UTMPnumber +
@@ -1656,7 +1656,7 @@ pickup(pickup_t * currpickup, int pickup_way, int *page,
/* 產生好友區 */
which = *page * nPickups;
- if( (cuser.uflag & FRIEND_FLAG) || /* 只顯示好友模式 */
+ if( (cuser->uflag & FRIEND_FLAG) || /* 只顯示好友模式 */
((pickup_way == 0) && /* [嗨! 朋友] mode */
(
/* 含板友, 好友區最多只會有 (friendtotal + 板友) 個*/
@@ -1687,7 +1687,7 @@ pickup(pickup_t * currpickup, int pickup_way, int *page,
} else
*nfriend = 0;
- if (!(cuser.uflag & FRIEND_FLAG) && size < nPickups) {
+ if (!(cuser->uflag & FRIEND_FLAG) && size < nPickups) {
sorted_way = ((pickup_way == 0) ? 0 : (pickup_way - 1));
utmp = SHM->sorted[currsorted][sorted_way];
which = *page * nPickups - *nfriend;
@@ -1730,7 +1730,7 @@ draw_pickup(int drawall, pickup_t * pickup, int pickup_way,
#endif
if (drawall) {
- showtitle((cuser.uflag & FRIEND_FLAG) ? "好友列表" : "休閒聊天",
+ showtitle((cuser->uflag & FRIEND_FLAG) ? "好友列表" : "休閒聊天",
BBSName);
prints("\n"
"\033[7m %s P%c代號 %-17s%-17s%-13s%-10s\033[m\n",
@@ -1965,7 +1965,7 @@ userlist(void)
"代號 [%s]:", currutmp->userid);
if (!getdata(1, 0, buf, currutmp->userid,
sizeof(buf), DOECHO))
- strlcpy(currutmp->userid, cuser.userid, sizeof(currutmp->userid));
+ strlcpy(currutmp->userid, cuser->userid, sizeof(currutmp->userid));
redrawall = redraw = 1;
}
break;
@@ -2042,7 +2042,7 @@ userlist(void)
break;
case 's':
- if (!(cuser.uflag & FRIEND_FLAG)) {
+ if (!(cuser->uflag & FRIEND_FLAG)) {
int si; /* utmpshm->sorted[X][0][si] */
int fi; /* allpickuplist[fi] */
char swid[IDLEN + 1];
@@ -2149,7 +2149,7 @@ userlist(void)
#endif
case 'b': /* broadcast */
- if (cuser.uflag & FRIEND_FLAG || HAS_PERM(PERM_SYSOP)) {
+ if (cuser->uflag & FRIEND_FLAG || HAS_PERM(PERM_SYSOP)) {
char genbuf[60];
char ans[4];
@@ -2159,7 +2159,7 @@ userlist(void)
ans, sizeof(ans), LCECHO) &&
*ans == 'n')
break;
- if (!(cuser.uflag & FRIEND_FLAG) && HAS_PERM(PERM_SYSOP)) {
+ if (!(cuser->uflag & FRIEND_FLAG) && HAS_PERM(PERM_SYSOP)) {
getdata(1, 0, "再次確定站長廣播? [N]",
ans, sizeof(ans), LCECHO);
if( *ans != 'y' && *ans != 'Y' ){
@@ -2240,7 +2240,7 @@ userlist(void)
case 't':
if (HAS_PERM(PERM_LOGINOK)) {
if (uentp->pid != currpid &&
- strcmp(uentp->userid, cuser.userid) != 0) {
+ strcmp(uentp->userid, cuser->userid) != 0) {
move(1, 0);
clrtobot();
move(3, 0);
@@ -2288,14 +2288,14 @@ userlist(void)
case 'f':
if (HAS_PERM(PERM_LOGINOK)) {
- cuser.uflag ^= FRIEND_FLAG;
+ cuser->uflag ^= FRIEND_FLAG;
redrawall = redraw = 1;
}
break;
case 'g':
if (HAS_PERM(PERM_LOGINOK) &&
- strcmp(uentp->userid, cuser.userid) != 0) {
+ strcmp(uentp->userid, cuser->userid) != 0) {
char genbuf[128];
move(b_lines - 2, 0);
prints("要給 %s 多少錢呢? ", uentp->userid);
@@ -2313,18 +2313,18 @@ userlist(void)
}
reload_money();
- if (ch > cuser.money) {
+ if (ch > cuser->money) {
outs("\033[41m 現金不足~~\033[m");
} else {
deumoney(uentp->uid, ch - give_tax(ch));
prints("\033[44m 嗯..還剩下 %d 錢.."
"\033[m", demoney(-ch));
snprintf(genbuf, sizeof(genbuf),
- "%s\t給%s\t%d\t%s\n", cuser.userid,
+ "%s\t給%s\t%d\t%s\n", cuser->userid,
uentp->userid, ch,
ctime(&currutmp->lastact));
log_file(FN_MONEY, genbuf, 1);
- mail_redenvelop(cuser.userid, uentp->userid,
+ mail_redenvelop(cuser->userid, uentp->userid,
ch - give_tax(ch), 'Y');
}
} else {
@@ -2382,10 +2382,10 @@ userlist(void)
if (HAS_PERM(PERM_LOGINOK)) {
int tmp;
char *wm[3] = {"一般", "進階", "未來"};
- tmp = cuser.uflag2 & WATER_MASK;
- cuser.uflag2 -= tmp;
+ tmp = cuser->uflag2 & WATER_MASK;
+ cuser->uflag2 -= tmp;
tmp = (tmp + 1) % 3;
- cuser.uflag2 |= tmp;
+ cuser->uflag2 |= tmp;
move(4, 0);
prints("系統提供 一般 進階 未來 三種模式\n"
"在切換後請正常下線再重新登入, 以確保結構正確\n"
@@ -2406,8 +2406,8 @@ userlist(void)
case 'N':
oldgetdata(1, 0, "新的暱稱: ",
- cuser.username, sizeof(cuser.username), DOECHO);
- strcpy(currutmp->username, cuser.username);
+ cuser->username, sizeof(cuser->username), DOECHO);
+ strcpy(currutmp->username, cuser->username);
redrawall = redraw = 1;
break;
@@ -2427,7 +2427,7 @@ t_users(void)
int mode0 = currutmp->mode;
int stat0 = currstat;
- if( cuser.userid[0] != currutmp->userid[0] ){
+ if( cuser->userid[0] != currutmp->userid[0] ){
if( HAS_PERM(PERM_SYSOP) )
vmsg("warning: currutmp userid is changed");
else
@@ -2470,7 +2470,7 @@ t_idle(void)
currutmp->destuid = 0;
if (currutmp->destuid == 6)
- if (!cuser.userlevel ||
+ if (!cuser->userlevel ||
!getdata(b_lines - 1, 0, "發呆的理由:",
currutmp->chatid, sizeof(currutmp->chatid), DOECHO))
currutmp->destuid = 0;
@@ -2483,8 +2483,8 @@ t_idle(void)
getdata(b_lines - 1, 0, MSG_PASSWD, passbuf, sizeof(passbuf), NOECHO);
passbuf[8] = '\0';
}
- while (!checkpasswd(cuser.passwd, passbuf) &&
- strcmp(STR_GUEST, cuser.userid));
+ while (!checkpasswd(cuser->passwd, passbuf) &&
+ strcmp(STR_GUEST, cuser->userid));
currutmp->mode = mode0;
currutmp->destuid = destuid0;
diff --git a/mbbsd/user.c b/mbbsd/user.c
index c5a501eb..47cfa8e5 100644
--- a/mbbsd/user.c
+++ b/mbbsd/user.c
@@ -18,7 +18,7 @@ int
u_loginview()
{
int i;
- unsigned int pbits = cuser.loginview;
+ unsigned int pbits = cuser->loginview;
char choice[5];
clear();
@@ -40,9 +40,9 @@ u_loginview()
}
}
- if (pbits != cuser.loginview) {
- cuser.loginview = pbits;
- passwd_update(usernum, &cuser);
+ if (pbits != cuser->loginview) {
+ cuser->loginview = pbits;
+// passwd_update(usernum, &cuser);
}
return 0;
}
@@ -199,15 +199,15 @@ violate_law(userec_t * u, int unum)
snprintf(dst, sizeof(dst), "tmp/%s", u->userid);
Rename(src, dst);
log_usies("KILL", u->userid);
- post_violatelaw(u->userid, cuser.userid, reason, "砍除 ID");
+ post_violatelaw(u->userid, cuser->userid, reason, "砍除 ID");
kill_user(unum);
} else {
u->userlevel |= PERM_VIOLATELAW;
u->vl_count++;
passwd_update(unum, u);
- post_violatelaw(u->userid, cuser.userid, reason, "罰單處份");
- mail_violatelaw(u->userid, cuser.userid, reason, "罰單處份");
+ post_violatelaw(u->userid, cuser->userid, reason, "罰單處份");
+ mail_violatelaw(u->userid, cuser->userid, reason, "罰單處份");
}
pressanykey();
}
@@ -225,35 +225,35 @@ static void Customize(void)
prints("您目前的個人化設定: ");
move(4, 0);
prints("%-30s%10s\n", "A. 水球模式",
- wm[(cuser.uflag2 & WATER_MASK)]);
+ wm[(cuser->uflag2 & WATER_MASK)]);
prints("%-30s%10s\n", "B. 接受站外信",
- ((cuser.userlevel & PERM_NOOUTMAIL) ? "否" : "是"));
+ ((cuser->userlevel & PERM_NOOUTMAIL) ? "否" : "是"));
prints("%-30s%10s\n", "C. 新板自動進我的最愛",
- ((cuser.uflag2 & FAVNEW_FLAG) ? "是" : "否"));
+ ((cuser->uflag2 & FAVNEW_FLAG) ? "是" : "否"));
prints("%-30s%10s\n", "D. 目前的心情", mindbuf);
prints("%-30s%10s\n", "E. 高亮度顯示我的最愛",
- ((cuser.uflag2 & FAVNOHILIGHT) ? "否" : "是"));
+ ((cuser->uflag2 & FAVNOHILIGHT) ? "否" : "是"));
getdata(b_lines - 1, 0, "請按 [A-E] 切換設定,按 [Return] 結束:",
ans, sizeof(ans), DOECHO);
switch( ans[0] ){
case 'A':
case 'a':{
- int currentset = cuser.uflag2 & WATER_MASK;
+ int currentset = cuser->uflag2 & WATER_MASK;
currentset = (currentset + 1) % 3;
- cuser.uflag2 &= ~WATER_MASK;
- cuser.uflag2 |= currentset;
+ cuser->uflag2 &= ~WATER_MASK;
+ cuser->uflag2 |= currentset;
vmsg("修正水球模式後請正常離線再重新上線");
}
break;
case 'B':
case 'b':
- cuser.userlevel ^= PERM_NOOUTMAIL;
+ cuser->userlevel ^= PERM_NOOUTMAIL;
break;
case 'C':
case 'c':
- cuser.uflag2 ^= FAVNEW_FLAG;
- if (cuser.uflag2 & FAVNEW_FLAG)
+ cuser->uflag2 ^= FAVNEW_FLAG;
+ if (cuser->uflag2 & FAVNEW_FLAG)
subscribe_newfav();
break;
case 'D':
@@ -270,12 +270,12 @@ static void Customize(void)
break;
case 'E':
case 'e':
- cuser.uflag2 ^= FAVNOHILIGHT;
+ cuser->uflag2 ^= FAVNOHILIGHT;
break;
default:
done = 1;
}
- passwd_update(usernum, &cuser);
+// passwd_update(usernum, &cuser);
}
pressanykey();
}
@@ -331,7 +331,7 @@ uinfo_query(userec_t * u, int real, int unum)
getdata_buf(i++, 0, "真實姓名:",
x.realname, sizeof(x.realname), DOECHO);
#ifdef FOREIGN_REG
- getdata_buf(i++, 0, cuser.uflag2 & FOREIGN ? "護照號碼" : "身分證號:", x.ident, sizeof(x.ident), DOECHO);
+ getdata_buf(i++, 0, cuser->uflag2 & FOREIGN ? "護照號碼" : "身分證號:", x.ident, sizeof(x.ident), DOECHO);
#else
getdata_buf(i++, 0, "身分證號:", x.ident, sizeof(x.ident), DOECHO);
#endif
@@ -588,7 +588,7 @@ uinfo_query(userec_t * u, int real, int unum)
getdata(b_lines - 1, 0, msg_sure_ny, ans, 3, LCECHO);
if (*ans == 'y') {
if (flag)
- post_change_perm(temp, i, cuser.userid, x.userid);
+ post_change_perm(temp, i, cuser->userid, x.userid);
if (strcmp(u->userid, x.userid)) {
char src[STRLEN], dst[STRLEN];
@@ -628,7 +628,7 @@ uinfo_query(userec_t * u, int real, int unum)
"時間: %s\n"
" 站長\033[1;32m%s\033[m把\033[1;32m%s\033[m"
"的錢從\033[1;35m%ld\033[m改成\033[1;35m%d\033[m",
- ctime(&now), cuser.userid, x.userid, money, x.money);
+ ctime(&now), cuser->userid, x.userid, money, x.money);
clrtobot();
clear();
@@ -636,10 +636,10 @@ uinfo_query(userec_t * u, int real, int unum)
reason, sizeof(reason), DOECHO));
fprintf(fp, "\n \033[1;37m站長%s修改錢理由是:%s\033[m",
- cuser.userid, reason);
+ cuser->userid, reason);
fclose(fp);
snprintf(fhdr.title, sizeof(fhdr.title),
- "[公安報告] 站長%s修改%s錢報告", cuser.userid,
+ "[公安報告] 站長%s修改%s錢報告", cuser->userid,
x.userid);
strlcpy(fhdr.owner, "[系統安全局]", sizeof(fhdr.owner));
append_record("boards/S/Security/.DIR", &fhdr, sizeof(fhdr));
@@ -651,10 +651,9 @@ int
u_info()
{
move(2, 0);
- user_display(&cuser, 0);
- uinfo_query(&cuser, 0, usernum);
- //strlcpy(currutmp->realname, cuser.realname, sizeof(currutmp->realname));
- strlcpy(currutmp->username, cuser.username, sizeof(currutmp->username));
+ user_display(cuser, 0);
+ uinfo_query(cuser, 0, usernum);
+ strlcpy(currutmp->username, cuser->username, sizeof(currutmp->username));
return 0;
}
@@ -662,7 +661,7 @@ int
u_ansi()
{
showansi ^= 1;
- cuser.uflag ^= COLOR_FLAG;
+ cuser->uflag ^= COLOR_FLAG;
outs(reset_color);
return 0;
}
@@ -680,16 +679,16 @@ u_switchproverb()
/* char *state[4]={"用功\型","安逸型","自定型","SHUTUP"}; */
char buf[100];
- cuser.proverb = (cuser.proverb + 1) % 4;
+ cuser->proverb = (cuser->proverb + 1) % 4;
setuserfile(buf, fn_proverb);
- if (cuser.proverb == 2 && dashd(buf)) {
+ if (cuser->proverb == 2 && dashd(buf)) {
FILE *fp = fopen(buf, "a");
assert(fp);
fprintf(fp, "座右銘狀態為[自定型]要記得設座右銘的內容唷!!");
fclose(fp);
}
- passwd_update(usernum, &cuser);
+// passwd_update(usernum, &cuser);
return 0;
}
@@ -823,14 +822,14 @@ u_editcalendar()
int aborted;
setutmpmode(EDITPLAN);
- setcalfile(genbuf, cuser.userid);
+ setcalfile(genbuf, cuser->userid);
aborted = vedit(genbuf, NA, NULL);
if (aborted != -1)
outs("行事曆更新完畢");
pressanykey();
return 0;
} else if (genbuf[0] == 'd') {
- setcalfile(genbuf, cuser.userid);
+ setcalfile(genbuf, cuser->userid);
unlink(genbuf);
outmsg("行事曆刪除完畢");
}
@@ -905,7 +904,7 @@ ispersonalid(char *inid)
static char *
getregcode(char *buf)
{
- sprintf(buf, "%s", crypt(cuser.userid, "02"));
+ sprintf(buf, "%s", crypt(cuser->userid, "02"));
return buf;
}
@@ -944,7 +943,7 @@ toregister(char *email, char *genbuf, char *phone, char *career,
FILE *fn;
char buf[128];
- sethomefile(buf, cuser.userid, "justify.wait");
+ sethomefile(buf, cuser->userid, "justify.wait");
if (phone[0] != 0) {
fn = fopen(buf, "w");
assert(fn);
@@ -954,7 +953,7 @@ toregister(char *email, char *genbuf, char *phone, char *career,
}
clear();
stand_title("認證設定");
- if (cuser.userlevel & PERM_NOREGCODE){
+ if (cuser->userlevel & PERM_NOREGCODE){
strcpy(email, "x");
goto REGFORM2;
}
@@ -1011,12 +1010,12 @@ toregister(char *email, char *genbuf, char *phone, char *career,
"若您無 E-Mail 請輸入 x由站長手動認證");
}
}
- strncpy(cuser.email, email, sizeof(cuser.email));
+ strncpy(cuser->email, email, sizeof(cuser->email));
REGFORM2:
if (strcasecmp(email, "x") == 0) { /* 手動認證 */
if ((fn = fopen(fn_register, "a"))) {
fprintf(fn, "num: %d, %s", usernum, ctime(&now));
- fprintf(fn, "uid: %s\n", cuser.userid);
+ fprintf(fn, "uid: %s\n", cuser->userid);
fprintf(fn, "ident: %s\n", ident);
fprintf(fn, "name: %s\n", rname);
fprintf(fn, "career: %s\n", career);
@@ -1038,20 +1037,20 @@ toregister(char *email, char *genbuf, char *phone, char *career,
#endif
snprintf(genbuf, sizeof(genbuf),
"%s:%s:<Email>", phone, career);
- strncpy(cuser.justify, genbuf, REGLEN);
- sethomefile(buf, cuser.userid, "justify");
+ strncpy(cuser->justify, genbuf, REGLEN);
+ sethomefile(buf, cuser->userid, "justify");
}
snprintf(buf, sizeof(buf),
"您在 " BBSNAME " 的認證碼: %s", getregcode(genbuf));
- strlcpy(tmp, cuser.userid, sizeof(tmp));
- strlcpy(cuser.userid, "SYSOP", sizeof(cuser.userid));
+ strlcpy(tmp, cuser->userid, sizeof(tmp));
+ strlcpy(cuser->userid, "SYSOP", sizeof(cuser->userid));
#ifdef HAVEMOBILE
if (strcmp(email, "m") == 0 || strcmp(email, "M") == 0)
mobile_message(mobile, buf);
else
#endif
bsmtp("etc/registermail", buf, email, 0);
- strlcpy(cuser.userid, tmp, sizeof(cuser.userid));
+ strlcpy(cuser->userid, tmp, sizeof(cuser->userid));
outs("\n\n\n我們即將寄出認證信 (您應該會在 10 分鐘內收到)\n"
"收到後您可以跟據認證信標題的認證碼\n"
"輸入到 (U)ser -> (R)egister 後就可以完成註冊");
@@ -1174,7 +1173,7 @@ u_register(void)
char genbuf[200];
FILE *fn;
- if (cuser.userlevel & PERM_LOGINOK) {
+ if (cuser->userlevel & PERM_LOGINOK) {
outs("您的身份確認已經完成,不需填寫申請表");
return XEASY;
}
@@ -1183,7 +1182,7 @@ u_register(void)
if ((ptr = strchr(genbuf, '\n')))
*ptr = '\0';
if (strncmp(genbuf, "uid: ", 5) == 0 &&
- strcmp(genbuf + 5, cuser.userid) == 0) {
+ strcmp(genbuf + 5, cuser->userid) == 0) {
fclose(fn);
outs("您的註冊申請單尚在處理中,請耐心等候");
return XEASY;
@@ -1191,20 +1190,20 @@ u_register(void)
}
fclose(fn);
}
- strlcpy(ident, cuser.ident, sizeof(ident));
- strlcpy(rname, cuser.realname, sizeof(rname));
- strlcpy(addr, cuser.address, sizeof(addr));
- strlcpy(email, cuser.email, sizeof(email));
- snprintf(mobile, sizeof(mobile), "0%09d", cuser.mobile);
- if (cuser.month == 0 && cuser.day && cuser.year == 0)
+ strlcpy(ident, cuser->ident, sizeof(ident));
+ strlcpy(rname, cuser->realname, sizeof(rname));
+ strlcpy(addr, cuser->address, sizeof(addr));
+ strlcpy(email, cuser->email, sizeof(email));
+ snprintf(mobile, sizeof(mobile), "0%09d", cuser->mobile);
+ if (cuser->month == 0 && cuser->day && cuser->year == 0)
birthday[0] = 0;
else
snprintf(birthday, sizeof(birthday), "%02i/%02i/%02i",
- cuser.month, cuser.day, cuser.year % 100);
- sex_is[0] = (cuser.sex % 8) + '1';
+ cuser->month, cuser->day, cuser->year % 100);
+ sex_is[0] = (cuser->sex % 8) + '1';
sex_is[1] = 0;
career[0] = phone[0] = '\0';
- sethomefile(genbuf, cuser.userid, "justify.wait");
+ sethomefile(genbuf, cuser->userid, "justify.wait");
if ((fn = fopen(genbuf, "r"))) {
fgets(phone, 21, fn);
phone[strlen(phone) - 1] = 0;
@@ -1221,20 +1220,20 @@ u_register(void)
fclose(fn);
}
- if (cuser.userlevel & PERM_NOREGCODE) {
+ if (cuser->userlevel & PERM_NOREGCODE) {
vmsg("您不被允許\使用認證碼認證。請填寫註冊申請單");
goto REGFORM;
}
- if (cuser.year != 0 && /* 已經第一次填過了~ ^^" */
- strcmp(cuser.email, "x") != 0 && /* 上次手動認證失敗 */
- strcmp(cuser.email, "X") != 0) {
+ if (cuser->year != 0 && /* 已經第一次填過了~ ^^" */
+ strcmp(cuser->email, "x") != 0 && /* 上次手動認證失敗 */
+ strcmp(cuser->email, "X") != 0) {
clear();
stand_title("EMail認證");
move(2, 0);
prints("%s(%s) 您好,請輸入您的認證碼。\n"
"或您可以輸入 x來重新填寫 E-Mail 或改由站長手動認證\n",
- cuser.userid, cuser.username);
+ cuser->userid, cuser->username);
inregcode[0] = 0;
do{
getdata(10, 0, "您的輸入: ", inregcode, sizeof(inregcode), DOECHO);
@@ -1248,18 +1247,18 @@ u_register(void)
if (strcmp(inregcode, getregcode(regcode)) == 0) {
int unum;
- if ((unum = getuser(cuser.userid)) == 0) {
+ if ((unum = getuser(cuser->userid)) == 0) {
vmsg("系統錯誤,查無此人!");
u_exit("getuser error");
exit(0);
}
- mail_muser(cuser, "[註冊成功\囉]", "etc/registeredmail");
- if(cuser.uflag2 & FOREIGN)
- mail_muser(cuser, "[出入境管理局]", "etc/foreign_welcome");
- cuser.userlevel |= (PERM_LOGINOK | PERM_POST);
+ mail_muser(*cuser, "[註冊成功\囉]", "etc/registeredmail");
+ if(cuser->uflag2 & FOREIGN)
+ mail_muser(*cuser, "[出入境管理局]", "etc/foreign_welcome");
+ cuser->userlevel |= (PERM_LOGINOK | PERM_POST);
prints("\n註冊成功\, 重新上站後將取得完整權限\n"
"請按下任一鍵跳離後重新上站~ :)");
- sethomefile(genbuf, cuser.userid, "justify.wait");
+ sethomefile(genbuf, cuser->userid, "justify.wait");
unlink(genbuf);
pressanykey();
u_exit("registed");
@@ -1287,7 +1286,7 @@ u_register(void)
clear();
move(1, 0);
prints("%s(%s) 您好,請據實填寫以下的資料:",
- cuser.userid, cuser.username);
+ cuser->userid, cuser->username);
#ifdef FOREIGN_REG
fore[0] = 'y';
fore[1] = 0;
@@ -1374,10 +1373,10 @@ u_register(void)
len = strlen(birthday);
if (!len) {
snprintf(birthday, sizeof(birthday), "%02i/%02i/%02i",
- cuser.month, cuser.day, cuser.year % 100);
- mon = cuser.month;
- day = cuser.day;
- year = cuser.year;
+ cuser->month, cuser->day, cuser->year % 100);
+ mon = cuser->month;
+ day = cuser->day;
+ year = cuser->year;
} else if (len == 8) {
mon = (birthday[0] - '0') * 10 + (birthday[1] - '0');
day = (birthday[3] - '0') * 10 + (birthday[4] - '0');
@@ -1401,20 +1400,20 @@ u_register(void)
if (ans[0] == 'y')
break;
}
- strlcpy(cuser.ident, ident, sizeof(cuser.ident));
- strlcpy(cuser.realname, rname, sizeof(cuser.realname));
- strlcpy(cuser.address, addr, sizeof(cuser.address));
- strlcpy(cuser.email, email, sizeof(cuser.email));
- cuser.mobile = atoi(mobile);
- cuser.sex = (sex_is[0] - '1') % 8;
- cuser.month = mon;
- cuser.day = day;
- cuser.year = year;
+ strlcpy(cuser->ident, ident, sizeof(cuser->ident));
+ strlcpy(cuser->realname, rname, sizeof(cuser->realname));
+ strlcpy(cuser->address, addr, sizeof(cuser->address));
+ strlcpy(cuser->email, email, sizeof(cuser->email));
+ cuser->mobile = atoi(mobile);
+ cuser->sex = (sex_is[0] - '1') % 8;
+ cuser->month = mon;
+ cuser->day = day;
+ cuser->year = year;
#ifdef FOREIGN_REG
if (fore[0])
- cuser.uflag2 |= FOREIGN;
+ cuser->uflag2 |= FOREIGN;
else
- cuser.uflag2 &= ~FOREIGN;
+ cuser->uflag2 &= ~FOREIGN;
#endif
trim(career);
trim(addr);
@@ -1427,11 +1426,11 @@ u_register(void)
prints("最後Post一篇\033[32m自我介紹文章\033[m給大家吧,"
"告訴所有老骨頭\033[31m我來啦^$。\\n\n\n\n");
pressanykey();
- cuser.userlevel |= PERM_POST;
+ cuser->userlevel |= PERM_POST;
brc_initial_board("WhoAmI");
set_board();
do_post();
- cuser.userlevel &= ~PERM_POST;
+ cuser->userlevel &= ~PERM_POST;
return 0;
}
diff --git a/mbbsd/var.c b/mbbsd/var.c
index 89a88244..1b426b0d 100644
--- a/mbbsd/var.c
+++ b/mbbsd/var.c
@@ -95,7 +95,7 @@ pid_t currpid; /* current process ID */
time_t login_start_time;
time_t start_time;
time_t paste_time;
-userec_t cuser; /* current user structure */
+userec_t *cuser; /* current user structure */
userec_t xuser; /* lookup user structure */
crosspost_t postrecord; /* anti cross post */
unsigned int currbrdattr;
diff --git a/mbbsd/vote.c b/mbbsd/vote.c
index fa2a52e6..305b9613 100644
--- a/mbbsd/vote.c
+++ b/mbbsd/vote.c
@@ -874,7 +874,7 @@ user_vote_one(char *bname, int ind)
setbfile(buf, bname, STR_new_limited); /* Ptt */
if (dashf(buf)) {
setbfile(buf, bname, FN_CANVOTE);
- if (!belong(buf, cuser.userid)) {
+ if (!belong(buf, cuser->userid)) {
fclose(cfp);
outs("\n\n對不起! 這是私人投票..你並沒有受邀唷!");
pressanykey();
@@ -1040,7 +1040,7 @@ user_vote_one(char *bname, int ind)
fprintf(fcm,
"\033[36m○使用者\033[1;36m %s "
"\033[;36m的建議:\033[m\n",
- cuser.userid);
+ cuser->userid);
for (i = 0; i < 3; i++)
fprintf(fcm, " %s\n", mycomments[i]);
fprintf(fcm, "\n");
diff --git a/mbbsd/voteboard.c b/mbbsd/voteboard.c
index fe4008d7..9423218a 100644
--- a/mbbsd/voteboard.c
+++ b/mbbsd/voteboard.c
@@ -62,7 +62,7 @@ do_voteboardreply(fileheader_t * fhdr)
if(yes>=0) continue;
strtok(genbuf+4," \n");
- if (!strncmp(genbuf + 4, cuser.userid, IDLEN)) {
+ if (!strncmp(genbuf + 4, cuser->userid, IDLEN)) {
move(5, 10);
prints("您已經連署過本篇了");
getdata(17, 0, "要修改您之前的連署嗎?(Y/N) [N]", opnion, 3, LCECHO);
@@ -111,27 +111,27 @@ do_voteboardreply(fileheader_t * fhdr)
now -= 14 * 24 * 60 * 60;
}
fprintf(fo, "%s", genbuf);
- len = strlen(cuser.userid);
+ len = strlen(cuser->userid);
for(yes=0; fgets(genbuf, sizeof(genbuf), fi);) {
if (!strncmp("----------", genbuf, 10))
break;
- if (strlen(genbuf)<30 || (genbuf[4+len]==' ' && !strncmp(genbuf + 4, cuser.userid, len)))
+ if (strlen(genbuf)<30 || (genbuf[4+len]==' ' && !strncmp(genbuf + 4, cuser->userid, len)))
continue;
fprintf(fo, "%3d.%s", ++yes, genbuf + 4);
}
if (opnion[0] == 'y')
- fprintf(fo, "%3d.%-15s%-34s 來源:%s\n", ++yes, cuser.userid, reason, cuser.lasthost);
+ fprintf(fo, "%3d.%-15s%-34s 來源:%s\n", ++yes, cuser->userid, reason, cuser->lasthost);
fprintf(fo, "%s", genbuf);
for(no=0; fgets(genbuf, sizeof(genbuf), fi);) {
if (!strncmp("----------", genbuf, 10))
break;
- if (strlen(genbuf)<30 || (genbuf[4+len]==' ' && !strncmp(genbuf + 4, cuser.userid, len)))
+ if (strlen(genbuf)<30 || (genbuf[4+len]==' ' && !strncmp(genbuf + 4, cuser->userid, len)))
continue;
fprintf(fo, "%3d.%s", ++no, genbuf + 4);
}
if (opnion[0] == 'n')
- fprintf(fo, "%3d.%-15s%-34s 來源:%s\n", ++no, cuser.userid, reason, cuser.lasthost);
+ fprintf(fo, "%3d.%-15s%-34s 來源:%s\n", ++no, cuser->userid, reason, cuser->lasthost);
fprintf(fo, "----------總計----------\n");
fprintf(fo, "支持人數:%-9d反對人數:%-9d\n", yes, no);
fprintf(fo, "\n--\n※ 發信站 :" BBSNAME "(" MYHOSTNAME
@@ -246,7 +246,7 @@ do_voteboard(int type)
completeboard_permission,
completeboard_getname);
snprintf(title, sizeof(title), "[連署板主] %s", topic);
- snprintf(genbuf, sizeof(genbuf), "%s\n\n%s%s\n%s%s", "連署板主", "英文名稱: ", topic, "申請 ID : ", cuser.userid);
+ snprintf(genbuf, sizeof(genbuf), "%s\n\n%s%s\n%s%s", "連署板主", "英文名稱: ", topic, "申請 ID : ", cuser->userid);
strcat(genbuf, "\n申請政見: \n");
break;
case 6:
@@ -275,7 +275,7 @@ do_voteboard(int type)
snprintf(title, sizeof(title), "[連署小組長] %s", topic);
snprintf(genbuf, sizeof(genbuf),
"%s\n\n%s%s\n%s%s", "連署小組長", "小組名稱: ",
- topic, "申請 ID : ", cuser.userid);
+ topic, "申請 ID : ", cuser->userid);
strcat(genbuf, "\n申請政見: \n");
break;
case 8:
@@ -294,7 +294,7 @@ do_voteboard(int type)
return FULLUPDATE;
snprintf(title, sizeof(title), "[申請新群組] %s", topic);
snprintf(genbuf, sizeof(genbuf), "%s\n\n%s%s\n%s%s",
- "申請群組", "群組名稱: ", topic, "申請 ID : ", cuser.userid);
+ "申請群組", "群組名稱: ", topic, "申請 ID : ", cuser->userid);
strcat(genbuf, "\n申請政見: \n");
break;
default:
@@ -325,13 +325,13 @@ do_voteboard(int type)
outs("開檔失敗,請稍候重來一次");
return FULLUPDATE;
}
- fprintf(fp, "%s%s %s%s\n%s%s\n%s%s", "作者: ", cuser.userid,
+ fprintf(fp, "%s%s %s%s\n%s%s\n%s%s", "作者: ", cuser->userid,
"看板: ", currboard,
"標題: ", title,
"時間: ", ctime(&now));
fprintf(fp, "%s\n", genbuf);
fclose(fp);
- strlcpy(votefile.owner, cuser.userid, sizeof(votefile.owner));
+ strlcpy(votefile.owner, cuser->userid, sizeof(votefile.owner));
strlcpy(votefile.title, title, sizeof(votefile.title));
votefile.filemode |= FILE_VOTE;
setbdir(genbuf, currboard);
diff --git a/mbbsd/xyz.c b/mbbsd/xyz.c
index e0b850b5..1d83fd41 100644
--- a/mbbsd/xyz.c
+++ b/mbbsd/xyz.c
@@ -179,7 +179,7 @@ note()
} notedata_t;
notedata_t myitem;
- if (cuser.money < 5) {
+ if (cuser->money < 5) {
outmsg("\033[1;41m 哎呀! 要投五銀才能留言...沒錢耶..\033[m");
clrtoeol();
refresh();
@@ -201,8 +201,8 @@ note()
return 0;
} while (buf[0] == 'e');
demoney(-5);
- strcpy(myitem.userid, cuser.userid);
- strncpy(myitem.username, cuser.username, 18);
+ strcpy(myitem.userid, cuser->userid);
+ strncpy(myitem.username, cuser->username, 18);
myitem.username[18] = '\0';
myitem.date = now;
@@ -360,7 +360,7 @@ Goodbye()
return 0;
movie(999);
- if (cuser.userlevel) {
+ if (cuser->userlevel) {
getdata(b_lines - 1, 0,
"(G)隨風而逝 (M)托夢站長 (N)酸甜苦辣流言板?[G] ",
genbuf, 3, LCECHO);
@@ -373,8 +373,8 @@ Goodbye()
clear();
prints("\033[1;36m親愛的 \033[33m%s(%s)\033[36m,別忘了再度光臨\033[45;33m"
" %s \033[40;36m!\n以下是您在站內的註冊資料:\033[0m\n",
- cuser.userid, cuser.username, BBSName);
- user_display(&cuser, 0);
+ cuser->userid, cuser->username, BBSName);
+ user_display(cuser, 0);
pressanykey();
more("etc/Logout", NA);