diff options
author | ptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-04-06 04:32:52 +0800 |
---|---|---|
committer | ptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-04-06 04:32:52 +0800 |
commit | 2d49c43abc05fc453ff3ff154fbe3a8dfd1fb571 (patch) | |
tree | c543fe6446c7acaf1781d93d5d9010fd2bcef3a5 /mbbsd | |
parent | 9b691d3d21047d1121ab62994e124385359bbdaa (diff) | |
download | pttbbs-2d49c43abc05fc453ff3ff154fbe3a8dfd1fb571.tar pttbbs-2d49c43abc05fc453ff3ff154fbe3a8dfd1fb571.tar.gz pttbbs-2d49c43abc05fc453ff3ff154fbe3a8dfd1fb571.tar.bz2 pttbbs-2d49c43abc05fc453ff3ff154fbe3a8dfd1fb571.tar.lz pttbbs-2d49c43abc05fc453ff3ff154fbe3a8dfd1fb571.tar.xz pttbbs-2d49c43abc05fc453ff3ff154fbe3a8dfd1fb571.tar.zst pttbbs-2d49c43abc05fc453ff3ff154fbe3a8dfd1fb571.zip |
add push_bottom function
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1698 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/bbs.c | 47 | ||||
-rw-r--r-- | mbbsd/cache.c | 6 | ||||
-rw-r--r-- | mbbsd/passwd.c | 30 |
3 files changed, 74 insertions, 9 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index be55fa57..c9beeffd 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -2314,6 +2314,43 @@ board_etc() setbdir(currdirect, currboard); return NEWDIRECT; } +static int +push_bottom(int ent, fileheader_t * fhdr, char *direct) +{ + int num, i; + char buf[256]; + if ((currmode & MODE_DIGEST) || !(currmode & MODE_BOARD)) + return DONOTHING; + setbfile(buf, currboard, ".BOTTOM"); + num = get_num_records(buf, sizeof(fileheader_t)); + if(getans(fhdr->filemode & FILE_BOTTOM ? + "¨ú®ø«n¤½½?(y/N)": + "¥[¤J«n¤½§i?(y/N)")!='y') return READ_REDRAW; + fhdr->filemode ^= FILE_BOTTOM; + if(fhdr->filemode & FILE_BOTTOM) + { + if(num >= 5) + { + outmsg("¤£±o¶W¹L 5 ½g«n¤½§i ½Ðºë²!"); + pressanykey(); + return READ_REDRAW; + } + append_record(buf, fhdr, sizeof(fileheader_t)); + } + else + { + fileheader_t headers[5]; + if(num>5) num=5; + num = get_records(buf, &headers, sizeof(fileheader_t), 1, num); + for(i=0; i<num; i++) + { + if(!strcmp(fhdr->filename, headers[i].filename)) + delete_record(buf, sizeof(fileheader_t), i+1); + } + } + substitute_record(direct, fhdr, sizeof(fileheader_t), ent); + return READ_REDRAW; +} static int good_post(int ent, fileheader_t * fhdr, char *direct) @@ -2325,10 +2362,9 @@ good_post(int ent, fileheader_t * fhdr, char *direct) if ((currmode & MODE_DIGEST) || !(currmode & MODE_BOARD)) return DONOTHING; - getdata(1, 0, fhdr->filemode & FILE_DIGEST ? - "¨ú®ø¬ÝªO¤åºK?(Y/n)" : "¦¬¤J¬ÝªO¤åºK?(Y/n)", genbuf2, 3, LCECHO); - if(genbuf2[0] == 'n') - return FULLUPDATE; + if(getans(fhdr->filemode & FILE_DIGEST ? + "¨ú®ø¬ÝªO¤åºK?(Y/n)" : "¦¬¤J¬ÝªO¤åºK?(Y/n)") == 'n') + return READ_REDRAW; if (fhdr->filemode & FILE_DIGEST) { fhdr->filemode = (fhdr->filemode & ~FILE_DIGEST); @@ -2710,9 +2746,6 @@ Select() void mobile_message(char *mobile, char *message) { - - - bsmtp(char *fpath, char *title, char *rcpt, int method); } diff --git a/mbbsd/cache.c b/mbbsd/cache.c index 67a405d3..21319c8e 100644 --- a/mbbsd/cache.c +++ b/mbbsd/cache.c @@ -460,7 +460,7 @@ setumoney(int uid, int money) int deumoney(int uid, int money) { - if (money < 0 && SHM->money[uid - 1] < -money) + if (money < 0 && moneyof(uid) < -money) return setumoney(uid, 0); else return setumoney(uid, SHM->money[uid - 1] + money); @@ -475,6 +475,10 @@ demoney(int money) int moneyof(int uid) { /* ptt §ï¶iª÷¿ú³B²z®Ä²v */ + if(SHM->money[uid - 1] == -1) + { + SHM->money[uid - 1] = passwd_query_money(uid); + } return SHM->money[uid - 1]; } diff --git a/mbbsd/passwd.c b/mbbsd/passwd.c index 0f46f65f..ce6cd233 100644 --- a/mbbsd/passwd.c +++ b/mbbsd/passwd.c @@ -49,7 +49,9 @@ passwd_init() } int -passwd_update_money(int num) /* update money only */ +passwd_update_money(int num) +/* update money only + Ptt: don't call it directly, call deumoney() */ { userec_t user; int pwdfd, money = moneyof(num); @@ -77,6 +79,32 @@ passwd_update_money(int num) /* update money only */ } int +passwd_query_money(int num) +/* query money only + Ptt: don't call it directly, call moneyof() */ +{ + userec_t user; + int pwdfd, money; + char path[256]; + + if (num < 1 || num > MAX_USERS) + return -1; + + sethomefile(path, getuserid(num), ".passwd"); + + if ((pwdfd = open(path, O_WRONLY)) < 0) + { + if(passwd_index_query(num, &user)<0) // tempory code, will be removed + return -1; + return user.money; + } + if(lseek(pwdfd, (off_t)((int)&user.money - (int)&user), SEEK_SET) >= 0) + read(pwdfd, &money, sizeof(int)); + close(pwdfd); + return money; +} + +int passwd_index_update(int num, userec_t * buf) { int pwdfd; |