diff options
author | ptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-04-21 04:28:21 +0800 |
---|---|---|
committer | ptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-04-21 04:28:21 +0800 |
commit | 80d6431f5d2fa48f925712ccd98c1983404e7ee9 (patch) | |
tree | 6411ae9d890ba61413664da1f37f468259f4281c | |
parent | 82664ae2ecc5db24c614f7a625e859975f55a6b5 (diff) | |
download | pttbbs-80d6431f5d2fa48f925712ccd98c1983404e7ee9.tar pttbbs-80d6431f5d2fa48f925712ccd98c1983404e7ee9.tar.gz pttbbs-80d6431f5d2fa48f925712ccd98c1983404e7ee9.tar.bz2 pttbbs-80d6431f5d2fa48f925712ccd98c1983404e7ee9.tar.lz pttbbs-80d6431f5d2fa48f925712ccd98c1983404e7ee9.tar.xz pttbbs-80d6431f5d2fa48f925712ccd98c1983404e7ee9.tar.zst pttbbs-80d6431f5d2fa48f925712ccd98c1983404e7ee9.zip |
revert cuser from pointer to buffer.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1798 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
42 files changed, 567 insertions, 908 deletions
diff --git a/include/perm.h b/include/perm.h index 93232bdb..2d676bae 100644 --- a/include/perm.h +++ b/include/perm.h @@ -49,8 +49,8 @@ #define PERM_FORWARD (PERM_BASIC) /* to do the forwarding */ #define PERM_INTERNET (PERM_LOGINOK) /* 身份認證過關的才能寄信到 Internet */ -#define HAS_PERM(x) ((x) ? cuser->userlevel & (x) : 1) -#define HAVE_PERM(x) (cuser->userlevel&(x)) +#define HAS_PERM(x) ((x) ? cuser.userlevel & (x) : 1) +#define HAVE_PERM(x) (cuser.userlevel&(x)) #define PERM_HIDE(u) ((u)->userlevel & PERM_SYSOP && \ (u)->userlevel & PERM_DENYPOST) diff --git a/include/proto.h b/include/proto.h index b4bdab92..b3fed5a6 100644 --- a/include/proto.h +++ b/include/proto.h @@ -45,9 +45,6 @@ int inc_goodsale(int uid, int num); int inc_badsale(int uid, int num); void set_assess(int uid, unsigned char num, int type); -/* bbcall */ -int main_bbcall(void); - /* bbs */ void make_blist(void); int invalid_brdname(char *brd); @@ -99,7 +96,13 @@ void brc_trunc(int bid, time_t ftime); void brc_addlist(const char* fname); /* cache */ -int moneyof(int uid); +#define demoney(money) deumoney(usernum, money) +#define search_ulist(uid) search_ulistn(uid, 1) +#define getbcache(bid) (bcache + bid - 1) +#define moneyof(uid) SHM->money[uid - 1] +#define getbtotal(bid) SHM->total[bid - 1] +#define getbottomtotal(bid) SHM->n_bottom[bid-1] + int getuser(char *userid); void setuserid(int num, char *userid); int searchuser(char *userid); @@ -110,7 +113,6 @@ void addbrd_touchcache(void); void setapath(char *buf, char *boardname); void setutmpmode(unsigned int mode); void setadir(char *buf, char *path); -boardheader_t *getbcache(int bid); int apply_boards(int (*func)(boardheader_t *)); int haspostperm(char *bname); void inbtotal(int bid, int add); @@ -120,7 +122,6 @@ unsigned int safe_sleep(unsigned int seconds); int apply_ulist(int (*fptr)(userinfo_t *)); userinfo_t *search_ulistn(int uid, int unum); void purge_utmp(userinfo_t *uentp); -userinfo_t *search_ulist(int uid); int count_multi(void); void resolve_utmp(void); void attach_uhash(void); @@ -138,11 +139,8 @@ int count_logins(int uid, int show); void remove_from_uhash(int n); void add_to_uhash(int n, char *id); int setumoney(int uid, int money); -int getbtotal(int bid); -int getbottomtotal(int bid); userinfo_t *search_ulist_pid(int pid); userinfo_t *search_ulist_userid(char *userid); -int moneyof(int uid); void hbflreload(int bid); int hbflcheck(int bid, int uid); int updatemdcache(const char *cpath, const char *fpath); @@ -164,8 +162,7 @@ int give_tax(int money); int vice(int money, char* item); int inumoney(char *tuser, int money); int cal(void); -#define reload_money() cuser->money=moneyof(usernum) -int demoney(int money); +#define reload_money() cuser.money=moneyof(usernum) int deumoney(int uid, int money); int lockutmpmode(int unmode, int state); int unlockutmpmode(void); @@ -480,6 +477,9 @@ void initscr(void); void out_lines(char *str, int line); /* stuff */ +#define isprint2(ch) ((ch & 0x80) || isprint(ch)) +#define not_alpha(ch) (ch < 'A' || (ch > 'Z' && ch < 'a') || ch > 'z') +#define not_alnum(ch) (ch < '0' || (ch > '9' && ch < 'A') || (ch > 'Z' && ch < 'a') || ch > 'z') time_t gettime(int line, time_t dt, char* head); void setcalfile(char *buf, char *userid); void stand_title(char *title); @@ -508,20 +508,17 @@ void setbfile(char *buf, char *boardname, char *fname); void setbnfile(char *buf, char *boardname, char *fname, int n); int dashl(char *fname); char *subject(char *title); -int not_alnum(char ch); void setdirpath(char *buf, char *direct, char *fname); int str_checksum(char *str); void show_help(char *helptext[]); int belong(char *filelist, char *key); char *Cdatedate(time_t *clock); -int isprint2(char ch); void sethomeman(char *buf, char *userid); off_t dashs(char *fname); void cursor_clear(int row, int column); void cursor_show(int row, int column); void printdash(char *mesg); char *Cdatelite(time_t *clock); -int not_alpha(char ch); int valid_ident(char *ident); int userid_is_BM(char *userid, char *list); int is_uBM(char *list, char *id); diff --git a/include/pttstruct.h b/include/pttstruct.h index 48c35d49..80cef86c 100644 --- a/include/pttstruct.h +++ b/include/pttstruct.h @@ -114,7 +114,7 @@ typedef struct userec_t { #define WATER_ORIG 0x0 #define WATER_NEW 0x1 #define WATER_OFO 0x2 -#define WATERMODE(mode) ((cuser->uflag2 & WATER_MASK) == mode) +#define WATERMODE(mode) ((cuser.uflag2 & WATER_MASK) == mode) #define FAVNOHILIGHT 0x10 /* false if hilight favorite */ #define FAVNEW_FLAG 0x20 /* true if add new board into one's fav */ #define FOREIGN 0x100 /* true if a foreign */ diff --git a/mbbsd/admin.c b/mbbsd/admin.c index dfa825b4..f6d35a6c 100644 --- a/mbbsd/admin.c +++ b/mbbsd/admin.c @@ -23,7 +23,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; } @@ -357,7 +357,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); @@ -887,7 +887,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)) { @@ -936,7 +936,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); @@ -1019,7 +1019,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); @@ -1106,10 +1106,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 dba8c1d7..21696789 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, @@ -1189,7 +1189,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/bbcall.c b/mbbsd/bbcall.c deleted file mode 100644 index 93fe499d..00000000 --- a/mbbsd/bbcall.c +++ /dev/null @@ -1,274 +0,0 @@ -/* $Id: bbcall.c,v 1.9 2003/06/28 08:44:03 kcwu Exp $ */ -#include "bbs.h" - -#define SERVER_0941 "www.chips.com.tw" -#define SERVER_0943 "www.pager.com.tw" -#define SERVER_0948 "www.fitel.net.tw" -#define SERVER_0947 "www.hoyard.com.tw" -#define SERVER_0945 "203.73.181.254" - -#define CGI_0948 "/cgi-bin/Webpage.dll" -#define CGI_0941 "/cgi-bin/paging1.pl" -#define CGI_0947 "/scripts/fp_page1.dll" -#define CGI_0945 "/Scripts/fiss/PageForm.exe" -#define CGI_0943 "/tpn/tpnasp/dowebcall.asp" - -#define CGI_RAILWAY "http://www.railway.gov.tw/cgi-bin/timetk.cgi" - -#define REFER_0943 "http://www.pager.com.tw/tpn/webcall/webcall.asp" -#define REFER_0948 "http://www.fitel.net.tw/html/svc03.htm" -#define REFER_0941 "http://www.chips.com.tw:9100/WEB2P/page_1.htm" -#define REFER_0947 "http://web1.hoyard.com.tw/freeway/freewayi.html" -#define REFER_0945 "http://203.73.181.254/call.HTM" - -static void -pager_msg_encode(char *field, char *buf) -{ - char *cc = field; - unsigned char *p; - - for (p = (unsigned char *)buf; *p; p++) { - if ((*p >= '0' && *p <= '9') || - (*p >= 'A' && *p <= 'Z') || - (*p >= 'a' && *p <= 'z') || - *p == ' ') - *cc++ = *p == ' ' ? '+' : (char)*p; - else { - sprintf(cc, "%%%02X", (int)*p); - cc += 3; - } - } - *cc = 0; -} - -static void -Gettime(int flag, int *Year, int *Month, int *Day, int *Hour, - int *Minute) -{ - char ans[5]; - - do { - getdata(10, 0, "年[20-]:", ans, 3, LCECHO); - *Year = atoi(ans); - } while (*Year < 00 || *Year > 02); - do { - getdata(10, 15, "月[1-12]:", ans, 3, LCECHO); - } while (!IsSNum(ans) || (*Month = atoi(ans)) > 12 || *Month < 1); - do { - getdata(10, 30, "日[1-31]:", ans, 3, LCECHO); - } while (!IsSNum(ans) || (*Day = atoi(ans)) > 31 || *Day < 1); - do { - getdata(10, 45, "時[0-23]:", ans, 3, LCECHO); - } while (!IsSNum(ans) || (*Hour = atoi(ans)) > 23 || *Hour < 0); - do { - getdata(10, 60, "分[0-59]:", ans, 3, LCECHO); - } while (!IsSNum(ans) || (*Minute = atoi(ans)) > 59 || *Minute < 0); - if (flag == 1) - *Year -= 11; -} - -#define hpressanykey(a) {move(22, 0); prints(a); pressanykey();} - -static int -Connect(char *s, char *server) -{ - FILE *fp = fopen(BBSHOME "/log/bbcall.log", "a"); - int sockfd; - char result[2048]; - struct sockaddr_in serv_addr; - struct hostent *hp; - - sockfd = socket(AF_INET, SOCK_STREAM, 0); - if (sockfd < 0) - return 0; - - memset((char *)&serv_addr, 0, sizeof(serv_addr)); - serv_addr.sin_family = AF_INET; - - if ((hp = gethostbyname(server)) == NULL) - return 0; - - memcpy(&serv_addr.sin_addr, hp->h_addr, hp->h_length); - - if (!strcmp(server, SERVER_0941)) - serv_addr.sin_port = htons(9100); - else - serv_addr.sin_port = htons(80); - - if (connect(sockfd, (struct sockaddr *) & serv_addr, sizeof serv_addr)) { - hpressanykey("無法與伺服器取得連結,傳呼失敗"); - return 0; - } else { - mprints(20, 0, "\033[1;33m伺服器已經連接上,請稍候" - ".....................\033[m"); - refresh(); - } - - write(sockfd, s, strlen(s)); - shutdown(sockfd, 1); - - while (read(sockfd, result, sizeof(result)) > 0) { - fprintf(fp, "%s\n", result); - fflush(fp); - if (strstr(result, "正確") || - strstr(result, "等待") || - strstr(result, "再度") || - strstr(result, "完 成 回 應") || - strstr(result, "預約中") || - strstr(result, "傳送中")) { - close(sockfd); - hpressanykey("順利送出傳呼"); - return 0; - } - memset(result, 0, sizeof(result)); - } - fclose(fp); - close(sockfd); - hpressanykey("無法順利送出傳呼"); - return 0; -} - -#define PARA \ -"Connection: Keep-Alive\r\n"\ -"User-Agent: Lynx/2.6 libwww-FM/2.14\r\n"\ -"Content-type: application/x-www-form-urlencoded\r\n"\ -"Accept: text/html, text/plain, application/x-wais-source, "\ -"application/html, */*;q=0.001\r\n"\ -"Accept-Encoding: gzip\r\n"\ -"Accept-Language: en\r\n"\ -"Accept-Charset: iso-8859-1,*,utf-8\r\n" - -static void halpha0943(char* CoId) { - char tmpbuf[64],ans[2]; - char ID[8]; - char Msg[64], atrn[512], sendform[1024]; - int Year = 99, Month = 1, Day = 15, Hour = 13, Minute = 8; - - snprintf(tmpbuf, sizeof(tmpbuf), - "\033[1;37m請輸入您要傳呼的號碼\033[m : %s-", CoId); - if(!getdata(7,0, tmpbuf, ID, sizeof(ID), LCECHO) || - !getdata(8,0, "\033[1;37m請輸入傳呼訊息\033[m:", tmpbuf, 63, LCECHO)) { - hpressanykey("放棄傳呼"); - return; - } - pager_msg_encode(Msg,tmpbuf); - getdata(9, 0, "\033[1;37m如果你要馬上送請按 '1' " - "如果要定時送請按 '2': \033[m", ans, sizeof(ans), LCECHO); - - if(ans[0] != '1') - Gettime(0, &Year, &Month, &Day, &Hour, &Minute); - - snprintf(atrn, sizeof(atrn), - "CoId=%s&ID=%s&Year=19%02d&Month=%02d&Day=%02d" - "&Hour=%02d&Minute=%02d&Msg=%s", - CoId, ID,Year,Month,Day,Hour,Minute,Msg); - snprintf(sendform, sizeof(sendform), "POST %s HTTP/1.0\nReferer: " - "%s\n%sContent-length:%d\n\n%s", - CGI_0943, REFER_0943, PARA, strlen(atrn), atrn); - Connect(sendform, SERVER_0943); - return ; -} - -static void hcall0941() { - char ans[2]; - char PAGER_NO[8], TRAN_MSG[18], TIME[8]; - char trn[512], sendform[512]; - int year = 98, month = 12, day = 4, hour = 13, min = 8; - - if(!getdata(7, 0, "\033[1;37 請您輸入您要傳呼的號碼 : 0941- \033[m", - PAGER_NO, sizeof(PAGER_NO), LCECHO) || - !getdata(8, 0, "\033[1;37m請輸入傳呼訊息\033[m:", trn, 17, LCECHO)) { - hpressanykey("放棄傳呼"); - return; - } - pager_msg_encode(TRAN_MSG,trn); - getdata(9,0, "\033[1;37m如果你要馬上送請按 '1' " - "如果要定時送請按 '2': \033[m", ans, sizeof(ans), LCECHO); - if(ans[0] != '1') { - strlcpy(TIME, "DELAY", sizeof(TIME)); - Gettime(0, &year, &month, &day, &hour, &min); - } else - strlcpy(TIME, "NOW", sizeof(TIME)); - snprintf(trn, sizeof(trn), - "PAGER_NO=%s&TRAN_MSG=%s&MSG_TYPE=NUMERIC&%s=1" - "&year=19%02d&month=%02d&day=%02d&hour=%02d&min=%02d", - PAGER_NO, TRAN_MSG, TIME,year,month,day,hour,min); - - snprintf(sendform, sizeof(sendform), - "POST %s HTTP/1.0\nReferer: %s\n%s" - "Content-length:%d\n\n%s", - CGI_0941, REFER_0941, PARA, strlen(trn), trn); - - Connect(sendform, SERVER_0941); - return ; -} - -static void hcall0948() { - int year = 87, month = 12, day = 19, hour = 12, min = 0, ya = 0; - char svc_no[8], message[64], trn[256], sendform[512], ans[3]; - - move(7,0); - clrtoeol(); - - if(!getdata(7, 0, "\033[1;37m請輸入您要傳呼的號碼\033[m:0948-", - svc_no, sizeof(svc_no), LCECHO) || - !getdata(8, 0, "\033[1;37m請輸入傳呼訊息\033[m:", trn, 61, LCECHO)) { - hpressanykey("放棄傳呼"); - return; - } - pager_msg_encode(message, trn); - getdata(9, 0, "\033[1;37m如果你要馬上送請按 '1' " - "如果要定時送請按 '2'\033[m: ", ans, sizeof(ans), LCECHO); - if(ans[0] != '1') { - Gettime(1, &year, &month, &day, &hour, &min); - ya = 1; - } - - snprintf(trn, sizeof(trn), - "MfcISAPICommand=SinglePage&svc_no=%s&reminder=%d" - "&year=%02d&month=%02d&day=%02d&hour=%02d&min=%02d&message=%s", - svc_no, ya, year, month, day, hour, min, message); - - snprintf(sendform, sizeof(sendform), - "GET %s?%s Http/1.0\n\n", CGI_0948, trn); - - Connect(sendform, SERVER_0948); - return; -} - -int main_bbcall() { - char ch[2]; - - clear(); - move(0, 30); - prints("\033[1;37;45m 逼逼摳機 \033[m"); - move(3, 0); - prints("\033[1;31m ┌────────────────────" - "─────────┐\033[m\n"); - prints("\033[1;33m (1)0941 (2)0943 (3)0946 " - " (4)0948 \033[m\n"); - prints("\033[1;31m └────────────────────" - "─────────┘\033[m\n"); - getdata(7, 8, "\033[1;37m你的選擇? [1-4]\033[m", ch, sizeof(ch), LCECHO); - - switch(ch[0]) { - case '1': - hcall0941(); - break; - case '2': - halpha0943("0943"); - break; - case '3': - halpha0943("0946"); - break; - case '4': - hcall0948(); - break; - } - return 0; -} - - - - - diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index 4343cccb..4f197b3e 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -15,13 +15,13 @@ mail_by_link(char *owner, char *title, char *path) char genbuf[200]; fileheader_t mymail; - sethomepath(genbuf, 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); - sethomedir(genbuf, cuser->userid); + sethomedir(genbuf, cuser.userid); append_record(genbuf, &mymail, sizeof(mymail)); } @@ -34,12 +34,12 @@ 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"); u_exit("Cross Post"); @@ -56,16 +56,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; @@ -83,7 +83,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) || @@ -93,9 +93,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; } @@ -357,7 +357,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); } } @@ -395,7 +395,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); @@ -438,7 +438,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"); @@ -547,7 +547,7 @@ do_general(int isbid) if (!CheckPostPerm() #ifdef FOREIGN_REG // 不是外籍使用者在 PttForeign 板 - && !((cuser->uflag2 & FOREIGN) && strcmp(bp->brdname, "PttForeign") == 0) + && !((cuser.uflag2 & FOREIGN) && strcmp(bp->brdname, "PttForeign") == 0) #endif ) { vmsg("對不起,您目前無法在此發表文章!"); @@ -670,9 +670,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; @@ -715,7 +715,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) @@ -748,7 +748,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) @@ -955,7 +955,7 @@ edit_post(int ent, fileheader_t * fhdr, char *direct) return DONOTHING; if( !HAS_PERM(PERM_SYSOP) && - (!CheckPostPerm() || strcmp(fhdr->owner, cuser->userid) != 0) ) + (!CheckPostPerm() || strcmp(fhdr->owner, cuser.userid) != 0) ) return DONOTHING; if( currmode & MODE_SELECT ) @@ -1060,7 +1060,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') { @@ -1092,7 +1092,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; @@ -1120,7 +1120,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(); @@ -1386,7 +1386,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); @@ -1418,7 +1418,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++; @@ -1434,7 +1434,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; @@ -1574,13 +1574,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; } @@ -1603,7 +1603,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; @@ -1611,8 +1611,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); @@ -1621,19 +1621,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); @@ -1686,12 +1686,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("離上次推薦時間太近囉, 請多花點時間仔細閱\讀文章!"); @@ -1710,8 +1710,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 @@ -1802,7 +1802,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) { @@ -1856,10 +1856,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); @@ -1923,7 +1923,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 @@ -1936,14 +1936,14 @@ del_post(int ent, fileheader_t * fhdr, char *direct) deumoney(num, -fhdr->money); } if (!not_owned && strcmp(currboard, "Test")) { - if (cuser->numposts) - cuser->numposts--; + if (cuser.numposts) + cuser.numposts--; if (!(currmode & MODE_DIGEST && currmode & MODE_BOARD)){ move(b_lines - 1, 0); clrtoeol(); demoney(-fhdr->money); prints("%s,您的文章減為 %d 篇,支付清潔費 %d 銀", msg_del_ok, - cuser->numposts, fhdr->money); + cuser.numposts, fhdr->money); refresh(); pressanykey(); } @@ -2030,7 +2030,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); @@ -2272,11 +2272,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; @@ -2718,7 +2718,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 14a01ced..05fe5b72 100644 --- a/mbbsd/board.c +++ b/mbbsd/board.c @@ -204,7 +204,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; @@ -498,12 +498,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; } @@ -531,7 +531,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) @@ -599,7 +599,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; } } @@ -622,7 +622,7 @@ choose_board(int newflag) fav_load(); ++choose_board_depth; brdnum = 0; - if (!cuser->userlevel) /* guest yank all boards */ + if (!cuser.userlevel) /* guest yank all boards */ yank_flag = 2; do { @@ -771,7 +771,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; } @@ -797,7 +797,7 @@ choose_board(int newflag) fav_sort_by_class(); } else - cuser->uflag ^= BRDSORT_FLAG; + cuser.uflag ^= BRDSORT_FLAG; brdnum = -1; break; case 'y': @@ -990,12 +990,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/brc.c b/mbbsd/brc.c index 71ae8ee1..ede94386 100644 --- a/mbbsd/brc.c +++ b/mbbsd/brc.c @@ -209,7 +209,7 @@ brc_insert_record(brcbid_t bid, brcnbrd_t num, time_t* list) void brc_update(){ - if (brc_changed && cuser->userlevel && brc_num > 0) + if (brc_changed && cuser.userlevel && brc_num > 0) brc_insert_record(currbid, brc_num, brc_list); } @@ -352,7 +352,7 @@ brc_addlist(const char *fname) int n, i; time_t ftime; - if (!cuser->userlevel) + if (!cuser.userlevel) return; ftime = atoi(&fname[2]); diff --git a/mbbsd/cache.c b/mbbsd/cache.c index 2517ee1e..15398ece 100644 --- a/mbbsd/cache.c +++ b/mbbsd/cache.c @@ -315,12 +315,6 @@ apply_ulist(int (*fptr) (userinfo_t *)) } userinfo_t * -search_ulist(int uid) -{ - return search_ulistn(uid, 1); -} - -userinfo_t * search_ulist_pid(int pid) { register int i = 0, j, start = 0, end = SHM->UTMPnumber - 1; @@ -468,18 +462,6 @@ deumoney(int uid, int money) return setumoney(uid, SHM->money[uid - 1] + money); } -int -demoney(int money) -{ - return deumoney(usernum, money); -} - -int -moneyof(int uid) -{ /* ptt 改進金錢處理效率 */ - return SHM->money[uid - 1]; -} - /* * section - utmp */ @@ -494,7 +476,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); } } @@ -634,23 +616,6 @@ apply_boards(int (*func) (boardheader_t *)) } #endif -boardheader_t * -getbcache(int bid) -{ /* Ptt改寫 */ - return bcache + bid - 1; -} - -int -getbtotal(int bid) -{ - return SHM->total[bid - 1]; -} -int -getbottomtotal(int bid) -{ - return SHM->n_bottom[bid-1]; -} - void setbottomtotal(int bid) { @@ -731,7 +696,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)) @@ -787,7 +752,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 bfc06eb0..dca13c4d 100644 --- a/mbbsd/cal.c +++ b/mbbsd/cal.c @@ -68,7 +68,7 @@ vice(int money, char *item) 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; } @@ -94,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(); @@ -103,7 +103,7 @@ osong(char *defaultid) unlockutmpmode(); return 0; } - if (cuser->money < 200) { + if (cuser.money < 200) { move(22, 0); outs("點歌要200銀唷!...."); refresh(); @@ -113,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 先選歌]", @@ -137,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); @@ -165,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; @@ -183,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~>"))) { @@ -203,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) { @@ -213,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]) { @@ -251,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; } @@ -268,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, "付費隱身"); currutmp->invisible %= 2; outs((currutmp->invisible ^= 1) ? MSG_CLOAKED : MSG_UNCLOAK); @@ -288,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)) { @@ -304,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"); @@ -319,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, "購買信箱"); inmailbox(n); @@ -379,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", - 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 d5c1fe61..5cb644c2 100644 --- a/mbbsd/calendar.c +++ b/mbbsd/calendar.c @@ -129,7 +129,7 @@ ReadEvent(int today) static event_t head; head.next = NULL; - setcalfile(buf, cuser->userid); + sethomefile(buf, cuser.userid, "calendar"); fp = fopen(buf, "r"); if (fp) { while (fgets(buf, sizeof(buf), fp)) { diff --git a/mbbsd/card.c b/mbbsd/card.c index 806c5429..2ed12260 100644 --- a/mbbsd/card.c +++ b/mbbsd/card.c @@ -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 66238334..f94cfc5f 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); @@ -520,12 +520,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 b5027c40..17cda17e 100644 --- a/mbbsd/chc.c +++ b/mbbsd/chc.c @@ -779,8 +779,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)); @@ -808,8 +808,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) { @@ -819,7 +819,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; @@ -958,7 +958,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 56791de4..1685d842 100644 --- a/mbbsd/chicken.c +++ b/mbbsd/chicken.c @@ -86,7 +86,7 @@ int reload_chicken() { - chicken_t *mychicken = &cuser->mychicken; + chicken_t *mychicken = &cuser.mychicken; passwd_query(usernum, &xuser); memcpy(mychicken, &xuser.mychicken, sizeof(chicken_t)); @@ -101,7 +101,7 @@ reload_chicken() static int new_chicken() { - chicken_t *mychicken = &cuser->mychicken; + chicken_t *mychicken = &cuser.mychicken; char buf[150]; int price; @@ -126,7 +126,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; @@ -138,7 +138,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; @@ -283,7 +283,7 @@ show_chicken_data(chicken_t * thechicken, chicken_t * pkchicken) static void ch_eat() { - chicken_t *mychicken = &cuser->mychicken; + chicken_t *mychicken = &cuser.mychicken; if (mychicken->food) { mychicken->weight += time_change[(int)mychicken->type][WEIGHT] + mychicken->hp_max / 5; @@ -303,7 +303,7 @@ ch_eat() static void ch_clean() { - chicken_t *mychicken = &cuser->mychicken; + chicken_t *mychicken = &cuser.mychicken; mychicken->clean = 0; mychicken->tiredstrong += time_change[(int)mychicken->type][TIREDSTRONG] / 3; @@ -316,7 +316,7 @@ ch_guess() { char *guess[3] = {"剪刀", "石頭", "布"}, me, ch, win; - chicken_t *mychicken = &cuser->mychicken; + chicken_t *mychicken = &cuser.mychicken; mychicken->happy += time_change[(int)mychicken->type][HAPPY] * 1.5; mychicken->satis += time_change[(int)mychicken->type][SATIS]; mychicken->tiredstrong += time_change[(int)mychicken->type][TIREDSTRONG]; @@ -332,7 +332,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(); } @@ -340,7 +340,7 @@ ch_guess() static void ch_book() { - chicken_t *mychicken = &cuser->mychicken; + chicken_t *mychicken = &cuser.mychicken; mychicken->book += time_change[(int)mychicken->type][BOOK]; mychicken->tiredstrong += time_change[(int)mychicken->type][TIREDSTRONG]; show_file(CHICKEN_PIC "/read", 5, 14, NO_RELOAD); @@ -350,7 +350,7 @@ ch_book() static void ch_kiss() { - chicken_t *mychicken = &cuser->mychicken; + chicken_t *mychicken = &cuser.mychicken; mychicken->happy += time_change[(int)mychicken->type][HAPPY]; mychicken->satis += time_change[(int)mychicken->type][SATIS]; mychicken->tiredstrong += @@ -362,7 +362,7 @@ ch_kiss() static void ch_hit() { - chicken_t *mychicken = &cuser->mychicken; + chicken_t *mychicken = &cuser.mychicken; mychicken->attack += time_change[(int)mychicken->type][ATTACK]; mychicken->run += time_change[(int)mychicken->type][RUN]; mychicken->mm_max += time_change[(int)mychicken->type][MM_MAX] / 15; @@ -393,7 +393,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, "購買寵物,賭盤項目"); @@ -411,7 +411,7 @@ ch_buyitem(int money, char *picture, int *item, int haveticket) static void ch_eatoo() { - chicken_t *mychicken = &cuser->mychicken; + chicken_t *mychicken = &cuser.mychicken; if (mychicken->oo > 0) { mychicken->oo--; mychicken->tiredstrong = 0; @@ -425,7 +425,7 @@ ch_eatoo() static void ch_eatmedicine() { - chicken_t *mychicken = &cuser->mychicken; + chicken_t *mychicken = &cuser.mychicken; if (mychicken->medicine > 0) { mychicken->medicine--; mychicken->sick = 0; @@ -442,7 +442,7 @@ ch_eatmedicine() static void ch_kill() { - chicken_t *mychicken = &cuser->mychicken; + chicken_t *mychicken = &cuser.mychicken; char buf[150], ans[4]; snprintf(buf, sizeof(buf), "棄養這%s要被罰 100 元, 是否要棄養?(y/N)", @@ -454,7 +454,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; @@ -464,7 +464,7 @@ ch_kill() static int ch_sell() { - chicken_t *mychicken = &cuser->mychicken; + chicken_t *mychicken = &cuser.mychicken; /* * int money = (mychicken->weight - * time_change[(int)mychicken->type][WEIGHT]) @@ -514,11 +514,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; @@ -633,7 +633,7 @@ time_diff(chicken_t * thechicken) static void check_sick() { - chicken_t *mychicken = &cuser->mychicken; + chicken_t *mychicken = &cuser.mychicken; /* 髒病的 */ if (mychicken->tiredstrong > mychicken->hp * 0.3 && mychicken->clean > 150) mychicken->sick += (mychicken->clean - 150) / 10; @@ -651,7 +651,7 @@ check_sick() static int deadtype(chicken_t * thechicken) { - chicken_t *mychicken = &cuser->mychicken; + chicken_t *mychicken = &cuser.mychicken; int i; char buf[150]; @@ -673,12 +673,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; } @@ -722,7 +722,7 @@ isdeadth(chicken_t * thechicken) static void ch_changename() { - chicken_t *mychicken = &cuser->mychicken; + chicken_t *mychicken = &cuser.mychicken; char buf[150], newname[20] = ""; getdata_str(b_lines - 1, 0, "嗯..改個好名字吧:", newname, 18, DOECHO, @@ -732,7 +732,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)); @@ -743,7 +743,7 @@ ch_changename() static int select_menu() { - chicken_t *mychicken = &cuser->mychicken; + chicken_t *mychicken = &cuser.mychicken; char ch; reload_money(); @@ -758,7 +758,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], @@ -852,7 +852,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(); @@ -877,7 +877,7 @@ recover_chicken(chicken_t * thechicken) bell(); igetch(); thechicken->lastvisit = 0; - passwd_update(usernum, cuser); + passwd_update(usernum, &cuser); return 0; } @@ -886,9 +886,8 @@ recover_chicken(chicken_t * thechicken) int chicken_main() { - chicken_t *mychicken = &cuser->mychicken; + chicken_t *mychicken = &cuser.mychicken; 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()) { @@ -902,7 +901,7 @@ chicken_main() show_chicken_data(mychicken, NULL); } while (select_menu()); reload_money(); - passwd_update(usernum, cuser); + passwd_update(usernum, &cuser); unlockutmpmode(); return 0; } @@ -910,7 +909,7 @@ chicken_main() int chickenpk(int fd) { - chicken_t *mychicken = &cuser->mychicken; + chicken_t *mychicken = &cuser.mychicken; char mateid[IDLEN + 1], data[200], buf[200]; int ch = 0; @@ -1035,7 +1034,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 994bc000..b6336d93 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 1f13f64a..acc7bac0 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; @@ -1071,7 +1071,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); @@ -1701,12 +1701,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 aa0fd84d..8d1381cb 100644 --- a/mbbsd/fav.c +++ b/mbbsd/fav.c @@ -458,7 +458,7 @@ int fav_save(void) if (dashs(buf) == 4) { char buf3[128]; time_t now = time(NULL); - sprintf(buf3, "%s %s", cuser->userid, ctime(&now)); + sprintf(buf3, "%s %s", cuser.userid, ctime(&now)); log_file(BBSHOME"/dirty.hack", buf3, 1); return -1; } @@ -881,7 +881,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 92eadb22..eea78bdc 100644 --- a/mbbsd/friend.c +++ b/mbbsd/friend.c @@ -419,7 +419,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); } @@ -429,7 +429,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 841d0926..33e67bb8 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 91863888..55060b67 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)); @@ -307,27 +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); 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); @@ -354,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); @@ -376,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; @@ -402,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); @@ -417,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 { @@ -432,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; @@ -464,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; @@ -497,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 c4c2ee99..9c2aba5f 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 2a997bdb..317fb5b0 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 bf2e0302..9023557d 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 f5dfdfbb..826f6eb4 100644 --- a/mbbsd/lovepaper.c +++ b/mbbsd/lovepaper.c @@ -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 ff4583ea..6c0ae7c7 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; } @@ -868,7 +868,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); } @@ -1026,7 +1026,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; @@ -1038,8 +1038,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 TITLE_REDRAW; } @@ -1115,7 +1115,7 @@ mail_cross_post(int ent, fileheader_t * fhdr, char *direct) return TITLE_REDRAW; 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') { @@ -1146,7 +1146,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; @@ -1163,7 +1163,7 @@ mail_cross_post(int ent, fileheader_t * fhdr, char *direct) write_header(xptr); currboard = save_currboard; - fprintf(xptr, "※ [本文轉錄自 %s 信箱]\n\n", cuser->userid); + fprintf(xptr, "※ [本文轉錄自 %s 信箱]\n\n", cuser.userid); b_suckinfile(xptr, fname); addsignature(xptr, 0); @@ -1178,7 +1178,7 @@ mail_cross_post(int ent, fileheader_t * fhdr, char *direct) setbtotal(getbnum(xboard)); if (!xfile.filemode) outgo_post(&xfile, xboard); - cuser->numposts++; + cuser.numposts++; outmsg("文章轉錄完成"); pressanykey(); currmode = currmode0; @@ -1194,8 +1194,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; @@ -1219,7 +1219,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); @@ -1261,8 +1261,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; @@ -1281,7 +1281,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" @@ -1329,16 +1329,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; @@ -1446,7 +1446,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("您沒有來信"); @@ -1465,11 +1465,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); @@ -1513,7 +1513,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"); @@ -1522,9 +1522,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" @@ -1585,8 +1585,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; @@ -1603,7 +1603,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, 0); @@ -1650,7 +1650,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') { @@ -1658,13 +1658,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') { @@ -1740,7 +1740,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 fdca2a37..f3c3d778 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -103,7 +103,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); } @@ -116,18 +116,17 @@ log_usies(char *mode, char *mesg) if (!mesg) snprintf(genbuf, sizeof(genbuf), - cuser ? "%s %s %-12s Stay:%d (%s)" : - "%s %s %s Stay:%d (%s)", - Cdate(&now), mode, cuser ? cuser->userid :"", - (int)(now - login_start_time) / 60, cuser?cuser->username:""); + "%s %s %-12s Stay:%d (%s)", + Cdate(&now), mode, cuser.userid , + (int)(now - login_start_time) / 60, cuser.username); else snprintf(genbuf, sizeof(genbuf), - cuser ? "%s %s %-12s %s" : "%s %s %s%s", - Cdate(&now), mode, cuser? cuser->userid:"", mesg); + "%s %s %-12s %s\n", + Cdate(&now), mode, cuser.userid, mesg); log_file(FN_USIES, genbuf, 1); /* 追蹤使用者 */ - if (cuser && HAS_PERM(PERM_LOGUSER)) + if (HAS_PERM(PERM_LOGUSER)) log_user(genbuf); } @@ -136,9 +135,9 @@ static void setflags(int mask, int value) { if (value) - cuser->uflag |= mask; + cuser.uflag |= mask; else - cuser->uflag &= ~mask; + cuser.uflag &= ~mask; } void @@ -159,27 +158,27 @@ 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_update(usernum, &cuser); log_usies(mode, NULL); } @@ -217,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 @@ -279,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) { @@ -394,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 && @@ -457,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 */ @@ -471,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(); */ @@ -579,7 +578,7 @@ login_query() if (strcasecmp(uid, str_new) == 0) { #ifdef LOGINASNEW new_register(); - mkuserdir(cuser->userid); + mkuserdir(cuser.userid); break; #else outs("本系統目前無法以 new 註冊, 請用 guest 進入\n"); @@ -592,31 +591,31 @@ login_query() passbuf, sizeof(passbuf), NOECHO); passbuf[8] = '\0'; - if( initcuser(uid) < 1 || cuser == NULL || - !checkpasswd(cuser->passwd, passbuf) ){ - logattempt(cuser ? cuser->userid : "", '-'); + if( initcuser(uid) < 1 || cuser.userid[0] || + !checkpasswd(cuser.passwd, passbuf) ){ + 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 */ if (initcuser(uid)< 1) exit (0) ; - 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; } } @@ -742,7 +741,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; @@ -757,31 +756,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 @@ -797,7 +796,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); @@ -809,7 +808,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(); } @@ -836,8 +835,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){ @@ -864,24 +863,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(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){ + 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("警告:請至出入境管理局申請永久居留"); } } @@ -905,8 +904,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 { @@ -923,7 +922,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); @@ -941,10 +940,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; @@ -961,7 +960,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(); @@ -971,7 +970,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 { @@ -980,12 +979,12 @@ 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); fav_load(); /* subscribe new fav (deprecated) */ @@ -993,7 +992,7 @@ user_login() updatenewfav(1); for (i = 0; i < NUMVIEWFILE; i++) - if ((cuser->loginview >> i) & 1) + if ((cuser.loginview >> i) & 1) more(loginview_file[(int)i][0], YEA); } @@ -1077,7 +1076,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 1b8a5e5b..5f8276b8 100644 --- a/mbbsd/menu.c +++ b/mbbsd/menu.c @@ -112,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; } @@ -129,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; @@ -176,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 b4625a58..96fea2e2 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 78e9ce0f..1757412f 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 7058f12b..88bfcaf7 100644 --- a/mbbsd/passwd.c +++ b/mbbsd/passwd.c @@ -97,15 +97,13 @@ passwd_query(int num, userec_t * buf) return 0; } -userec_t userecbuf; int initcuser(char *userid) { // Ptt: setup cuser and usernum here - cuser = &userecbuf; if(userid[0]=='\0' || !(usernum = searchuser(userid)) || usernum > MAX_USERS) return -1; - passwd_query(usernum, &userecbuf); + passwd_query(usernum, &cuser); return usernum; } diff --git a/mbbsd/read.c b/mbbsd/read.c index 413ad26d..2456fdda 100644 --- a/mbbsd/read.c +++ b/mbbsd/read.c @@ -503,9 +503,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 7c7f4bf8..7e76e897 100644 --- a/mbbsd/register.c +++ b/mbbsd/register.c @@ -306,33 +306,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)) { @@ -344,8 +344,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 008f18f9..e088b116 100644 --- a/mbbsd/stuff.c +++ b/mbbsd/stuff.c @@ -12,12 +12,6 @@ static char *str_board_n_file = "boards/%c/%s/%s.%d"; static char *str_dotdir = STR_DOTDIR; void -setcalfile(char *buf, char *userid) -{ - sprintf(buf, "home/%c/%s/calendar", userid[0], userid); -} - -void sethomepath(char *buf, char *userid) { sprintf(buf, "home/%c/%s", userid[0], userid); @@ -45,7 +39,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 @@ -162,24 +156,6 @@ trim(char *buf) /* ----------------------------------------------------- */ /* 字串檢查函數:英文、數字、檔名、E-mail address */ /* ----------------------------------------------------- */ -int -isprint2(char ch) -{ - return ((ch & 0x80) || isprint(ch)); -} - -int -not_alpha(char ch) -{ - return (ch < 'A' || (ch > 'Z' && ch < 'a') || ch > 'z'); -} - -int -not_alnum(char ch) -{ - return (ch < '0' || (ch > '9' && ch < 'A') || - (ch > 'Z' && ch < 'a') || ch > 'z'); -} int invalid_pname(char *str) @@ -243,8 +219,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 1e4e25af..39ccf97e 100644 --- a/mbbsd/syspost.c +++ b/mbbsd/syspost.c @@ -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 256c5550..d667fb0a 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -382,7 +382,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"); @@ -412,7 +412,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); @@ -659,7 +659,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) { @@ -689,7 +689,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)); @@ -839,13 +839,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') @@ -995,7 +995,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"); } @@ -1024,7 +1024,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; @@ -1121,14 +1121,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 @@ -1302,7 +1302,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) { vmsg(error == 2 ? "並非兩人都養寵物" : @@ -1588,7 +1588,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 + @@ -1668,7 +1668,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 + 板友) 個*/ @@ -1699,7 +1699,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; @@ -1742,7 +1742,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", @@ -1977,7 +1977,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; @@ -2054,7 +2054,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]; @@ -2161,7 +2161,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]; @@ -2171,7 +2171,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' ){ @@ -2252,7 +2252,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); @@ -2300,14 +2300,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); @@ -2325,18 +2325,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 { @@ -2394,10 +2394,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" @@ -2418,8 +2418,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; @@ -2439,7 +2439,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 @@ -2482,7 +2482,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; @@ -2495,8 +2495,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 b1247477..c92c32ee 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -22,7 +22,7 @@ int u_loginview() { int i; - unsigned int pbits = cuser->loginview; + unsigned int pbits = cuser.loginview; char choice[5]; clear(); @@ -44,9 +44,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; } @@ -202,15 +202,15 @@ violate_law(userec_t * u, int unum) snprintf(src, sizeof(src), "home/%c/%s", u->userid[0], u->userid); snprintf(dst, sizeof(dst), "tmp/%s", u->userid); Rename(src, dst); - 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(); } @@ -228,35 +228,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, 3, 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': @@ -273,12 +273,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(); } @@ -334,7 +334,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 @@ -591,7 +591,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]; @@ -631,7 +631,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%d\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(); @@ -639,10 +639,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)); @@ -654,9 +654,9 @@ int u_info() { move(2, 0); - user_display(cuser, 0); - uinfo_query(cuser, 0, usernum); - 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; } @@ -664,7 +664,7 @@ int u_ansi() { showansi ^= 1; - cuser->uflag ^= COLOR_FLAG; + cuser.uflag ^= COLOR_FLAG; outs(reset_color); return 0; } @@ -682,16 +682,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; } @@ -821,20 +821,19 @@ u_editcalendar() getdata(b_lines - 1, 0, "行事曆 (D)刪除 (E)編輯 [Q]取消?[Q] ", genbuf, 3, LCECHO); + sethomefile(genbuf, cuser.userid, "calendar"); if (genbuf[0] == 'e') { int aborted; setutmpmode(EDITPLAN); - setcalfile(genbuf, cuser->userid); + sethomefile(genbuf, cuser.userid, "calendar"); aborted = vedit(genbuf, NA, NULL); if (aborted != -1) - outs("行事曆更新完畢"); - pressanykey(); + vmsg("行事曆更新完畢"); return 0; } else if (genbuf[0] == 'd') { - setcalfile(genbuf, cuser->userid); unlink(genbuf); - outmsg("行事曆刪除完畢"); + vmsg("行事曆刪除完畢"); } return 0; } @@ -907,7 +906,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; } @@ -946,7 +945,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); @@ -956,7 +955,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; } @@ -1013,12 +1012,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); @@ -1040,20 +1039,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 後就可以完成註冊"); @@ -1185,7 +1184,7 @@ u_register(void) char genbuf[200]; FILE *fn; - if (cuser->userlevel & PERM_LOGINOK) { + if (cuser.userlevel & PERM_LOGINOK) { outs("您的身份確認已經完成,不需填寫申請表"); return XEASY; } @@ -1194,7 +1193,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; @@ -1202,20 +1201,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; @@ -1232,20 +1231,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); @@ -1259,18 +1258,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"); @@ -1298,7 +1297,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; @@ -1394,10 +1393,10 @@ u_register(void) len = strlen(birthday); if (!len) { snprintf(birthday, 9, "%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'); @@ -1421,20 +1420,20 @@ u_register(void) if (ans[0] == 'y') break; } - strlcpy(cuser->ident, ident,11); - strlcpy(cuser->realname, rname, 20); - strlcpy(cuser->address, addr, 50); - strlcpy(cuser->email, email, 50); - cuser->mobile = atoi(mobile); - cuser->sex = (sex_is[0] - '1') % 8; - cuser->month = mon; - cuser->day = day; - cuser->year = year; + strlcpy(cuser.ident, ident,11); + strlcpy(cuser.realname, rname, 20); + strlcpy(cuser.address, addr, 50); + strlcpy(cuser.email, email, 50); + 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); @@ -1447,11 +1446,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 526f5824..c9347b20 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 = NULL; /* 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 b133ae3c..5dcaa432 100644 --- a/mbbsd/vote.c +++ b/mbbsd/vote.c @@ -872,7 +872,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); vmsg("\n\n對不起! 這是私人投票..你並沒有受邀唷!"); return FULLUPDATE; @@ -1035,7 +1035,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 7714b14e..3890df2a 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 1d83fd41..e0b850b5 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); |