diff options
author | jack <jack@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-05-03 05:58:08 +0800 |
---|---|---|
committer | jack <jack@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-05-03 05:58:08 +0800 |
commit | e443776eb7025c569df22f801965f0ec84798e35 (patch) | |
tree | a6200d5ccc57109dfece0b30180da83a9915785c | |
parent | 886fd091d3cc9e39e342e13e994fb63acb30c34b (diff) | |
download | pttbbs-e443776eb7025c569df22f801965f0ec84798e35.tar pttbbs-e443776eb7025c569df22f801965f0ec84798e35.tar.gz pttbbs-e443776eb7025c569df22f801965f0ec84798e35.tar.bz2 pttbbs-e443776eb7025c569df22f801965f0ec84798e35.tar.lz pttbbs-e443776eb7025c569df22f801965f0ec84798e35.tar.xz pttbbs-e443776eb7025c569df22f801965f0ec84798e35.tar.zst pttbbs-e443776eb7025c569df22f801965f0ec84798e35.zip |
merge trunk to branches and corrected confliction
git-svn-id: http://opensvn.csie.org/pttbbs/branches/Jaky.i18n@1919 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
42 files changed, 1036 insertions, 1975 deletions
diff --git a/include/config.h b/include/config.h index 8e280dbd..6ac1a261 100644 --- a/include/config.h +++ b/include/config.h @@ -34,7 +34,7 @@ #endif #ifndef LANG_FILE -#define LANG_FILE "lang.big5" /* ¹w³]»y¨¥ÀÉ */ +#define LANG_FILE {"lang.big5"} /* ¹w³]»y¨¥ÀÉ */ #endif #ifndef MAX_POST_MONEY /* µoªí¤å³¹½Z¶Oªº¤W */ diff --git a/include/modes.h b/include/modes.h index 16d23754..4c629f2f 100644 --- a/include/modes.h +++ b/include/modes.h @@ -13,7 +13,8 @@ #define READ_REDRAW 9 #define PART_REDRAW 10 #define TITLE_REDRAW 11 -#define POS_NEXT 101 /* cursor_pos(locmem, locmem->crs_ln + 1, 1);*/ +#define READ_SKIP 12 +#define HEADERS_RELOAD 13 /* user ¾Þ§@ª¬ºA»P¼Ò¦¡ */ #define IDLE 0 @@ -128,21 +129,24 @@ #define RS_FORWARD 0x01 /* backward */ #define RS_TITLE 0x02 /* author/title */ -#define RS_RELATED 0x04 +#define RS_KEYWORD 0x04 #define RS_FIRST 0x08 /* find first article */ #define RS_CURRENT 0x10 /* match current read article */ -#define RS_THREAD 0x20 /* search the first article */ +#define RS_MARK 0x20 /* search the first article */ #define RS_AUTHOR 0x40 /* search author's article */ #define RS_NEWPOST 0x80 /* search new posts */ -#define CURSOR_FIRST (RS_RELATED | RS_TITLE | RS_FIRST) -#define CURSOR_NEXT (RS_RELATED | RS_TITLE | RS_FORWARD) -#define CURSOR_PREV (RS_RELATED | RS_TITLE) -#define RELATE_FIRST (RS_RELATED | RS_TITLE | RS_FIRST | RS_CURRENT) -#define RELATE_NEXT (RS_RELATED | RS_TITLE | RS_FORWARD | RS_CURRENT) -#define RELATE_PREV (RS_RELATED | RS_TITLE | RS_CURRENT) -#define THREAD_NEXT (RS_THREAD | RS_FORWARD) -#define THREAD_PREV (RS_THREAD) +#define CURSOR_FIRST (RS_TITLE | RS_FIRST) +#define CURSOR_NEXT (RS_TITLE | RS_FORWARD) +#define CURSOR_PREV (RS_TITLE) +#define RELATE_FIRST (RS_TITLE | RS_FIRST | RS_CURRENT) +#define RELATE_NEXT (RS_TITLE | RS_FORWARD | RS_CURRENT) +#define RELATE_PREV (RS_TITLE | RS_CURRENT) +#define NEWPOST_NEXT (RS_NEWPOST | RS_FORWARD) +#define NEWPOST_PREV (RS_NEWPOST) +#define AUTHOR_NEXT (RS_AUTHOR | RS_FORWARD) +#define AUTHOR_PREV (RS_AUTHOR) + enum {STRIP_ALL = 0, ONLY_COLOR, NO_RELOAD}; diff --git a/include/perm.h b/include/perm.h index 2d676bae..02c03d0f 100644 --- a/include/perm.h +++ b/include/perm.h @@ -11,7 +11,7 @@ #define PERM_CLOAK 000000000100 /* ¥Ø«eÁô§Î¤¤ */ #define PERM_SEECLOAK 000000000200 /* ¬Ý¨£§ÔªÌ */ #define PERM_XEMPT 000000000400 /* ¥Ã¤[«O¯d±b¸¹ */ -#define PERM_DENYPOST 000000001000 /* ¯¸ªøÁô¨³N */ +#define PERM_SYSOPHIDE 000000001000 /* ¯¸ªøÁô¨³N */ #define PERM_BM 000000002000 /* ªO¥D */ #define PERM_ACCOUNTS 000000004000 /* ±b¸¹Á`ºÞ */ #define PERM_CHATROOM 000000010000 /* ²á¤Ñ«ÇÁ`ºÞ */ @@ -51,8 +51,7 @@ #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) +#define PERM_HIDE(u) (u && (u)->userlevel & PERM_SYSOPHIDE) #define IS_BOARD(bptr) ((bptr)->brdname[0] && \ !((bptr)->brdattr & BRD_GROUPBOARD)) diff --git a/include/proto.h b/include/proto.h index 9e9b70f7..a2e182c8 100644 --- a/include/proto.h +++ b/include/proto.h @@ -58,7 +58,6 @@ int Select(void); void do_reply_title(int row, char *title); int cmpfmode(fileheader_t *fhdr); int cmpfilename(fileheader_t *fhdr); -int getindex(char *fpath, char *fname, int size); void outgo_post(fileheader_t *fh, char *board); int edit_title(int ent, fileheader_t *fhdr, char *direct); int whereami(int ent, fileheader_t *fhdr, char *direct); @@ -102,7 +101,7 @@ void brc_addlist(const char* fname); #define moneyof(uid) SHM->money[uid - 1] #define getbtotal(bid) SHM->total[bid - 1] #define getbottomtotal(bid) SHM->n_bottom[bid-1] - +void sort_bcache(void); int getuser(char *userid); void setuserid(int num, char *userid); int searchuser(char *userid); @@ -312,7 +311,6 @@ void init_alarm(void); int num_in_buf(void); int ochar(int c); int rget(int x,char *prompt); -char getans(char *prompt); /* kaede */ int Rename(char* src, char* dst); @@ -353,7 +351,6 @@ void my_send(char *uident); void show_call_in(int save, int which); void write_request (int sig); void log_usies(char *mode, char *mesg); -void log_user(char *msg); void system_abort(void); void abort_bbs(int sig); void del_distinct(char *fname, char *line); @@ -444,6 +441,8 @@ int apply_record(char *fpath, int (*fptr)(), int size); int search_rec(char* dirname, int (*filecheck)()); int append_record_forward(char *fpath, fileheader_t *record, int size); int get_sum_records(char* fpath, int size); +int substitute_ref_record(char* direct, fileheader_t *fhdr, int ent); +int getindex(char *fpath, fileheader_t *fh, int start); /* register */ int getnewuserid(void); @@ -454,13 +453,13 @@ void check_register(void); char *genpasswd(char *pw); /* screen */ +void mouts(int y, int x, char *str); void move(int y, int x); void outs(char *str); void clrtoeol(void); void clear(void); void refresh(void); void clrtobot(void); -void mprints(int y, int x, char *str); void outmsg(char *msg); void region_scroll_up(int top, int bottom); void outc(unsigned char ch); @@ -480,11 +479,15 @@ void out_lines(char *str, int line); #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') +#define pressanykey() vmsg_lines(b_lines, NULL) +int vmsg_lines(int lines, const char *msg); +int log_user(const char *fmt, ...); time_t gettime(int line, time_t dt, char* head); void setcalfile(char *buf, char *userid); void stand_title(char *title); -void pressanykey(void); -int vmsg (const char *fmt,...) GCC_CHECK_FORMAT(1,2); +char getans(const char *fmt,...); +int getkey(const char *fmt,...) GCC_CHECK_FORMAT(1,2); +int vmsg(const char *fmt,...) GCC_CHECK_FORMAT(1,2); void trim(char *buf); void bell(void); void setbpath(char *buf, char *boardname); @@ -493,7 +496,7 @@ void sethomepath(char *buf, char *userid); void sethomedir(char *buf, char *userid); char *Cdate(time_t *clock); void sethomefile(char *buf, char *userid, char *fname); -int log_file(char *filename, char *buf, int flags); +int log_file(char *fn, int ifcreate, const char *fmt,...); void str_lower(char *t, char *s); int strstr_lower(char *str, char *tag); int cursor_key(int row, int column); diff --git a/include/pttstruct.h b/include/pttstruct.h index 7b7ffc28..2c989e88 100644 --- a/include/pttstruct.h +++ b/include/pttstruct.h @@ -428,9 +428,9 @@ typedef struct { /* i18n(internationlization) */ char *i18nstr[MAX_LANG][MAX_STRING]; - char i18nstrbody[20 * MAX_LANG * MAX_STRING]; - /* Based on the statistis, we found the lengh of one string - is 20 bytes approximately. + char i18nstrbody[22 * MAX_LANG * MAX_STRING]; + /* Based on the statistics, we found the lengh of one string + is 22 bytes approximately. */ } SHM_t; diff --git a/mbbsd/admin.c b/mbbsd/admin.c index f6d35a6c..e828e3f3 100644 --- a/mbbsd/admin.c +++ b/mbbsd/admin.c @@ -134,7 +134,6 @@ search_key_user(char *passwdfile, int mode) fclose(fp1); return 0; } else { - move(b_lines - 1, 0); getdata(0, 0, "¥Ø«eªº PASSWD ÀɨS¦³¦¹ ID¡A·s¼W¶Ü¡H[y/N]", genbuf, 3, LCECHO); @@ -232,9 +231,10 @@ setperms(unsigned int pbits, char *pstring[]) ((pbits >> (i + 16)) & 1 ? "£¾" : "¢æ")); } clrtobot(); - while (getdata(b_lines - 1, 0, "½Ð«ö [A-5] ¤Á´«³]©w¡A«ö [Return] µ²§ô¡G", - choice, sizeof(choice), LCECHO)) { - i = choice[0] - 'a'; + while ( + (i = getkey("½Ð«ö [A-5] ¤Á´«³]©w¡A«ö [Return] µ²§ô¡G"))!='\r') + { + i = i - 'a'; if (i < 0) i = choice[0] - '0' + 26; if (i >= NUMPERMS) @@ -263,6 +263,7 @@ void delete_symbolic_link(boardheader_t *bh, int bid) memset(bh, 0, sizeof(boardheader_t)); substitute_record(fn_board, bh, sizeof(boardheader_t), bid); reset_board(bid); + sort_bcache(); log_usies("DelLink", bh->brdname); } @@ -361,6 +362,7 @@ m_mod_board(char *bname) post_msg("Security", bh.title, "½Ðª`·N§R°£ªº¦Xªk©Ê", "[¨t²Î¦w¥þ§½]"); substitute_record(fn_board, &bh, sizeof(bh), bid); reset_board(bid); + sort_bcache(); log_usies("DelBoard", bh.title); outs("§RªO§¹²¦"); } @@ -448,6 +450,7 @@ m_mod_board(char *bname) setup_man(&newbh); substitute_record(fn_board, &newbh, sizeof(newbh), bid); reset_board(bid); + sort_bcache(); log_usies("SetBoard", newbh.brdname); } } @@ -607,6 +610,7 @@ static int add_board_record(boardheader_t *board) if ((bid = getbnum("")) > 0) { substitute_record(fn_board, board, sizeof(boardheader_t), bid); reset_board(bid); + sort_bcache(); } else if (append_record(fn_board, (fileheader_t *)board, sizeof(boardheader_t)) == -1) { return -1; } else { @@ -705,6 +709,7 @@ m_newbrd(int recover) } add_board_record(&newboard); + getbcache(class_bid)->childcount = 0; pressanykey(); setup_man(&newboard); @@ -954,15 +959,13 @@ scan_register_form(char *regfile, int automode, int neednum) prints("%d.%-12s¡G%s\n", n - 2, finfo[n], fdata[n]); } if (muser.userlevel & PERM_LOGINOK) { - getdata(b_lines - 1, 0, "\033[1;32m¦¹±b¸¹¤w¸g§¹¦¨µù¥U, " - "§ó·s(Y/N/Skip)¡H\033[m[N] ", ans, sizeof(ans), LCECHO); + ans[0] = getkey("¦¹±b¸¹¤w¸g§¹¦¨µù¥U, " + "§ó·s(Y/N/Skip)¡H[N] "); if (ans[0] != 'y' && ans[0] != 's') ans[0] = 'd'; } else { - move(b_lines - 1, 0); - prints("¬O§_±µ¨ü¦¹¸ê®Æ(Y/N/Q/Del/Skip)¡H[S] "); if (search_ulist(unum) == NULL) - ans[0] = igetch(); + ans[0] = vmsg_lines(22, "¬O§_±µ¨ü¦¹¸ê®Æ(Y/N/Q/Del/Skip)¡H[S])"); else ans[0] = 's'; if ('A' <= ans[0] && ans[0] <= 'Z') @@ -1066,12 +1069,9 @@ scan_register_form(char *regfile, int automode, int neednum) strlcpy(muser.realname, fdata[2], sizeof(muser.realname)); strlcpy(muser.address, fdata[4], sizeof(muser.address)); strlcpy(muser.email, fdata[6], sizeof(muser.email)); - snprintf(genbuf, sizeof(genbuf), - "%s:%s:%s", fdata[5], fdata[3], uid); strncpy(muser.justify, genbuf, REGLEN); sethomefile(buf, muser.userid, "justify"); - strncat(genbuf, "\n", sizeof(genbuf)); - log_file(buf, genbuf, 1); + log_file(buf, 1, "%s:%s:%s\n", fdata[5], fdata[3], uid); passwd_update(unum, &muser); if ((fout = fopen(logfile, "a"))) { @@ -1160,10 +1160,9 @@ cat_register() { if (system("cat register.new.tmp >> register.new") == 0 && system("rm -f register.new.tmp") == 0) - mprints(22, 0, "OK ÂP~~ Ä~Äò¥h¾Ä°«§a!!"); + vmsg("OK ÂP~~ Ä~Äò¥h¾Ä°«§a!!"); else - mprints(22, 0, "¨S¿ìªkCAT¹L¥h©O ¥hÀˬd¤@¤U¨t²Î§a!!"); - pressanykey(); + vmsg("¨S¿ìªkCAT¹L¥h©O ¥hÀˬd¤@¤U¨t²Î§a!!"); return 0; } diff --git a/mbbsd/announce.c b/mbbsd/announce.c index d60e35ed..e09f0448 100644 --- a/mbbsd/announce.c +++ b/mbbsd/announce.c @@ -298,9 +298,8 @@ a_pasteitem(menu_t * pm, int mode) if (dashd(copyfile)) { for (i = 0; copyfile[i] && copyfile[i] == pm->path[i]; i++); if (!copyfile[i]) { - outs(SHM->i18nstr[cuser.language][197]); - igetch(); - return; + vmsg(SHM->i18nstr[cuser.language][197]); + return; } } if (mode) { @@ -664,9 +663,7 @@ a_showname(menu_t * pm) sym = 1; } if (sym) { - pressanykey(); - move(b_lines - 1, 1); - prints(SHM->i18nstr[cuser.language][219], &buf[i + 1]); + vmsg(SHM->i18nstr[cuser.language][219], &buf[i + 1]); } } } @@ -894,21 +891,19 @@ a_menu(char *maintitle, char *path, int lastlevel) Fexit = 1; if (currstat == OSONG) { /* XXX: ¥u¿ïºq¥¼ÂIºq¥iÄé±Æ¦æº] */ - char buf[128]; - snprintf(buf, sizeof(buf), - "%s\n", fhdr->title); - log_file(FN_USSONG, buf, 1); + log_file(FN_USSONG, 1, + "%s\n", fhdr->title); } free(me.header); return FULLUPDATE; } } - if (more_result == 1) { + if (more_result == READ_PREV) { if (--me.now < 0) { me.now = 0; break; } - } else if (more_result == 3) { + } else if (more_result == READ_NEXT) { if (++me.now >= me.num) { me.now = me.num - 1; break; diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index baea27a5..950a7a4b 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -30,12 +30,9 @@ mail_by_link(char *owner, char *title, char *path) void anticrosspost() { - char buf[200]; - - snprintf(buf, sizeof(buf), - "\033[1;33;46m%s \033[37;45mcross post ¤å³¹ \033[37m %s\033[m\n", - cuser.userid, ctime(&now)); - log_file("etc/illegal_money", buf, 1); + log_file("etc/illegal_money", 1, + "\033[1;33;46m%s \033[37;45mcross post ¤å³¹ \033[37m %s\033[m\n", + cuser.userid, ctime(&now)); post_violatelaw(cuser.userid, "Ptt¨t²Îĵ¹î", "Cross-post", "»@³æ³B¥÷"); cuser.userlevel |= PERM_VIOLATELAW; @@ -57,7 +54,7 @@ save_violatelaw() stand_title("ú»@³æ¤¤¤ß"); if (!(cuser.userlevel & PERM_VIOLATELAW)) { - mprints(22, 0, "\033[1;31m§AµL²á°Ú? §A¤S¨S¦³³Q¶}»@³æ~~\033[m"); + mouts(22, 0, "\033[1;31m§AµL²á°Ú? §A¤S¨S¦³³Q¶}»@³æ~~\033[m"); pressanykey(); return 0; } @@ -66,7 +63,7 @@ save_violatelaw() snprintf(buf, sizeof(buf), "\033[1;31m³o¬O§A²Ä %d ¦¸¹H¤Ï¥»¯¸ªk³W" "¥²¶·Ãº¥X %d $Ptt ,§A¥u¦³ %d ¤¸, ¿ú¤£°÷°Õ!!\033[m", (int)cuser.vl_count, (int)cuser.vl_count * 1000, cuser.money); - mprints(22, 0, buf); + mouts(22, 0, buf); pressanykey(); return 0; } @@ -77,19 +74,19 @@ save_violatelaw() if (!getdata(10, 0, "½T©w¶Ü¡H[y/n]:", ok, sizeof(ok), LCECHO) || ok[0] == 'n' || ok[0] == 'N') { - mprints(22, 0, "\033[1;31mµ¥§A·Q³q¤F¦A¨Ó§a!! " + mouts(22, 0, "\033[1;31mµ¥§A·Q³q¤F¦A¨Ó§a!! " "§Ú¬Û«H§A¤£·|ª¾¿ù¤£§ïªº~~~\033[m"); pressanykey(); return 0; } snprintf(buf, sizeof(buf), "³o¬O§A²Ä %d ¦¸¹Hªk ¥²¶·Ãº¥X %d $Ptt", cuser.vl_count, cuser.vl_count * 1000); - mprints(11, 0, buf); + mouts(11, 0, buf); if (!getdata(10, 0, "n¥I¿ú[y/n]:", ok, sizeof(ok), LCECHO) || ok[0] == 'N' || ok[0] == 'n') { - mprints(22, 0, "\033[1;31m ¶â ¦s°÷¿ú ¦A¨Ó§a!!!\033[m"); + mouts(22, 0, "\033[1;31m ¶â ¦s°÷¿ú ¦A¨Ó§a!!!\033[m"); pressanykey(); return 0; } @@ -238,24 +235,6 @@ readdoent(int num, fileheader_t * ent) } int -cmpfilename(fileheader_t * fhdr) -{ - return (!strcmp(fhdr->filename, currfile)); -} - -int -cmpfmode(fileheader_t * fhdr) -{ - return (fhdr->filemode & currfmode); -} - -int -cmpfowner(fileheader_t * fhdr) -{ - return !strcasecmp(fhdr->owner, currowner); -} - -int whereami(int ent, fileheader_t * fhdr, char *direct) { boardheader_t *bh, *p[32], *root; @@ -282,27 +261,7 @@ whereami(int ent, fileheader_t * fhdr, char *direct) return FULLUPDATE; } -static int -substitute_check(fileheader_t * fhdr) -{ - fileheader_t hdr; - char genbuf[100]; - int num = 0; - - /* rocker.011018: ¦ê±µ¼Ò¦¡¥Îreference¼W¶i®Ä²v */ - if ((currmode & MODE_SELECT) && (fhdr->money & FHR_REFERENCE)) { - num = fhdr->money & ~FHR_REFERENCE; - setbdir(genbuf, currboard); - get_record(genbuf, &hdr, sizeof(hdr), num); - /* ¦A³o¸Ìncheck¤@¤Uì¨Óªºdir¸Ì±¬O¤£¬O¦³³Q¤H°Ê¹L... */ - if (strcmp(hdr.filename, fhdr->filename)) - num = getindex(genbuf, fhdr->filename, sizeof(fileheader_t)); - - substitute_record(genbuf, fhdr, sizeof(*fhdr), num); - } - return num; -} static int do_select(int ent, fileheader_t * fhdr, char *direct) { @@ -815,26 +774,6 @@ do_generalboardreply(fileheader_t * fhdr) *quote_file = 0; } -int -getindex(char *fpath, char *fname, int size) -{ -#define READSIZE 64 // 8192 / sizeof(fileheader_t) - int fd, i, len, now = 1; /* now starts from 1 */ - fileheader_t fhdrs[READSIZE]; - - if ((fd = open(fpath, O_RDONLY, 0)) != -1) { - while( (len = read(fd, fhdrs, sizeof(fhdrs))) > 0 ){ - len /= sizeof(fileheader_t); - for( i = 0 ; i < len ; ++i, ++now ) - if (!strcmp(fhdrs[i].filename, fname)) { - close(fd); - return now; - } - } - close(fd); - } - return 0; -} int invalid_brdname(char *brd) @@ -942,8 +881,7 @@ reply_post(int ent, fileheader_t * fhdr, char *direct) static int edit_post(int ent, fileheader_t * fhdr, char *direct) { - int num; - char fpath[80], fpath0[80]; + char fpath[80]; char genbuf[200]; fileheader_t postfile; boardheader_t *bp = getbcache(currbid); @@ -967,50 +905,15 @@ edit_post(int ent, fileheader_t * fhdr, char *direct) #endif setutmpmode(REEDIT); + setbpath(fpath, currboard); + stampfile(fpath, &postfile); setdirpath(genbuf, direct, fhdr->filename); local_article = fhdr->filemode & FILE_LOCAL; + Copy(genbuf, fpath); strlcpy(save_title, fhdr->title, sizeof(save_title)); - /* rocker.011018: ³o¸Ì¬O¤£¬O¸ÓÀˬd¤@¤Uקï¤å³¹«áªºmoney©M즳ªº¤ñ¸û? */ - if (vedit(genbuf, 0, NULL) != -1) { - substitute_record(direct, fhdr, sizeof(*fhdr), ent); - setbpath(fpath, currboard); - stampfile(fpath, &postfile); - strlcpy(genbuf, fhdr->filename, sizeof(genbuf)); - setbfile(fpath0, currboard, fhdr->filename); - - for(num = 2; genbuf[num] != 0; num++){ - if(genbuf[num] == '.'){ - genbuf[num] = 0; - break; - } - } - - sprintf(postfile.filename, "%s.A.%3.3X", genbuf, rand() & 0xFFF); - setdirpath(fpath, fpath, postfile.filename); - unlink(fpath); - - Rename(fpath0, fpath); - - /* rocker.011018: fix ¦ê±µ¼Ò¦¡§ï¤å³¹«á¤å³¹´N¤£¨£ªºbug */ - if ((currmode & MODE_SELECT) && (fhdr->money & FHR_REFERENCE)) { - fileheader_t hdr; - - num = fhdr->money & ~FHR_REFERENCE; - setbdir(fpath0, currboard); - get_record(fpath0, &hdr, sizeof(hdr), num); - - /* ¦A³o¸Ìncheck¤@¤Uì¨Óªºdir¸Ì±¬O¤£¬O¦³³Q¤H°Ê¹L... */ - if (!strcmp(hdr.filename, fhdr->filename)) { - strlcpy(hdr.filename, postfile.filename, sizeof(hdr.filename)); - strlcpy(hdr.title, save_title, sizeof(hdr.title)); - substitute_record(fpath0, &hdr, sizeof(hdr), num); - } - } - strlcpy(fhdr->filename, postfile.filename, sizeof(fhdr->filename)); - strlcpy(fhdr->title, save_title, sizeof(fhdr->title)); - brc_addlist(postfile.filename); - substitute_record(direct, fhdr, sizeof(*fhdr), ent); + if (vedit(fpath, 0, NULL) != -1) { + Rename(fpath, genbuf); if (!(currbrdattr & BRD_HIDE) && (!bp->level || (currbrdattr & BRD_POSTMASK))) do_crosspost(ALLPOST, fhdr, fpath); } @@ -1135,110 +1038,35 @@ read_post(int ent, fileheader_t * fhdr, char *direct) int more_result; if (fhdr->owner[0] == '-') - return DONOTHING; + return READ_SKIP; setdirpath(genbuf, direct, fhdr->filename); if ((more_result = more(genbuf, YEA)) == -1) - return FULLUPDATE; + return READ_SKIP; brc_addlist(fhdr->filename); strncpy(currtitle, subject(fhdr->title), TTLEN); - strncpy(currowner, subject(fhdr->owner), IDLEN + 2); - - switch (more_result) { - case 1: - return READ_PREV; - case 2: - return RELATE_PREV; - case 3: - return READ_NEXT; - case 4: - return RELATE_NEXT; - case 5: - return RELATE_FIRST; - case 6: - return FULLUPDATE; - case 7: - case 8: - if (CheckPostPerm()) { - strlcpy(quote_file, genbuf, sizeof(quote_file)); - do_reply(fhdr); - *quote_file = 0; - } - return FULLUPDATE; - case 9: - return 'A'; - case 10: - return 'a'; - case 11: - return '/'; - case 12: - return '?'; - } - - - outmsg("\033[34;46m ¾\\Ū¤å³¹ \033[31;47m (R/Y)\033[30m¦^«H \033[31m" - "(=[]<>)\033[30m¬ÛÃö¥DÃD \033[31m(¡ô¡õ)\033[30m¤W¤U«Ê \033[31m(¡ö)" - "\033[30mÂ÷¶} \033[m"); - switch (egetch()) { - case 'q': - case 'Q': - case KEY_LEFT: - break; - - case ' ': - case KEY_RIGHT: - case KEY_DOWN: - case KEY_PGDN: - case 'n': - case Ctrl('N'): - return READ_NEXT; - - case KEY_UP: - case 'p': - case Ctrl('P'): - case KEY_PGUP: - return READ_PREV; - - case '=': - return RELATE_FIRST; - - case ']': - case 't': - return RELATE_NEXT; - - case '[': - return RELATE_PREV; - - case '.': - case '>': - return THREAD_NEXT; - - case ',': - case '<': - return THREAD_PREV; - - case Ctrl('I'): - t_idle(); - return FULLUPDATE; - - case 'X': - recommend(ent, fhdr, direct); - return FULLUPDATE; - - case 'y': - case 'r': - case 'R': - case 'Y': - if (CheckPostPerm()) { - strlcpy(quote_file, genbuf, sizeof(quote_file)); - do_reply(fhdr); - *quote_file = 0; - } - } - return FULLUPDATE; + if (more_result) + { + if(more_result == 999) + { + if (CheckPostPerm()) { + strlcpy(quote_file, genbuf, sizeof(quote_file)); + do_reply(fhdr); + *quote_file = 0; + } + return FULLUPDATE; + } + if(more_result == 998) + { + recommend(ent, fhdr, direct); + return FULLUPDATE; + } + else return more_result; + } +return FULLUPDATE; } /* ----------------------------------------------------- */ @@ -1327,9 +1155,7 @@ hold_gamble(int ent, fileheader_t * fhdr, char *direct) openticket(currbid); return FULLUPDATE; } else if (dashf(genbuf)) { - move(b_lines - 1, 0); - prints(" ¥Ø«e¨t²Î¥¿¦b³B²z¶}¼ú¨Æ©y, ½Ðµ²ªG¥XÄl«á¦AÁ|¿ì......."); - pressanykey(); + vmsg(" ¥Ø«e¨t²Î¥¿¦b³B²z¶}¼ú¨Æ©y, ½Ðµ²ªG¥XÄl«á¦AÁ|¿ì......."); return FULLUPDATE; } getdata(b_lines - 2, 0, "nÁ|¿ì½ä½L (N/y):", yn, 3, LCECHO); @@ -1438,9 +1264,7 @@ edit_title(int ent, fileheader_t * fhdr, char *direct) getdata(b_lines - 1, 0, "½T©w(Y/N)?[n] ", genbuf, 3, DOECHO); if ((genbuf[0] == 'y' || genbuf[0] == 'Y') && dirty) { *fhdr = tmpfhdr; - substitute_record(direct, fhdr, sizeof(*fhdr), ent); - /* rocker.011018: ³o¸ÌÀ³¸Ó§ï¦¨¥Îreferenceªº¤è¦¡¨ú±oì¨ÓªºÀÉ®× */ - substitute_check(fhdr); + substitute_ref_record(direct, fhdr, ent); } return FULLUPDATE; } @@ -1452,7 +1276,7 @@ solve_post(int ent, fileheader_t * fhdr, char *direct) { if (HAS_PERM(PERM_SYSOP)) { fhdr->filemode ^= FILE_SOLVED; - substitute_record(direct, fhdr, sizeof(*fhdr), ent); + substitute_ref_record(direct, fhdr, ent); return PART_REDRAW; } return DONOTHING; @@ -1474,8 +1298,7 @@ recommend_cancel(int ent, fileheader_t * fhdr, char *direct) #endif fhdr->recommend = 0; - substitute_record(direct, fhdr, sizeof(*fhdr), ent); - substitute_check(fhdr); + substitute_ref_record(direct, fhdr, ent); return FULLUPDATE; } static int @@ -1492,7 +1315,7 @@ do_add_recommend(char *direct, fileheader_t *fhdr, int ent, char *buf) 3.Y±Àªº®ÉÔ«e¤å³Q§R, ±N¥[¨ì«á¤åªº±À¤å¼Æ */ setdirpath(path, direct, fhdr->filename); - if( log_file(path, buf, 0) == -1 ){ // ¤£ CREATE + if( log_file(path, 0, buf) == -1 ){ // ¤£ CREATE vmsg("±ÀÂË/Äv¼Ð¥¢±Ñ"); return -1; } @@ -1553,6 +1376,7 @@ do_bid(int ent, fileheader_t * fhdr, boardheader_t *bp, char *direct, struct t break; } bidinfo.flag |= SALE_COMMENTED; + substitute_record(fpath, &bidinfo, sizeof(bidinfo), 1); } } @@ -1693,9 +1517,7 @@ recommend(int ent, fileheader_t * fhdr, char *direct) #ifndef DEBUG if (!(currmode & MODE_BOARD) && getuser(cuser.userid) && now - lastrecommend < 40) { - move(b_lines - 1, 0); - prints("Â÷¤W¦¸±ÀÂˮɶ¡¤ÓªñÅo, ½Ð¦hªáÂI®É¶¡¥J²Ó¾\\Ū¤å³¹!"); - pressanykey(); + vmsg("Â÷¤W¦¸±ÀÂˮɶ¡¤ÓªñÅo, ½Ð¦hªáÂI®É¶¡¥J²Ó¾\\Ū¤å³¹!"); return FULLUPDATE; } #endif @@ -1753,9 +1575,8 @@ mark_post(int ent, fileheader_t * fhdr, char *direct) inc_goodpost(searchuser(fhdr->owner), -1 * (fhdr->recommend / 10)); } #endif - - substitute_record(direct, fhdr, sizeof(*fhdr), ent); - substitute_check(fhdr); + + substitute_ref_record(direct, fhdr, ent); return PART_REDRAW; } @@ -1796,33 +1617,8 @@ del_range(int ent, fileheader_t *fhdr, char *direct) if (*num1 == 'y') { outmsg("³B²z¤¤,½Ðµy«á..."); refresh(); - if (currmode & MODE_SELECT) { - int fd, size = sizeof(fileheader_t); - char genbuf[100]; - fileheader_t rsfh; - int i = inum1, now; - if (currstat == RMAIL) - sethomedir(genbuf, cuser.userid); - else - setbdir(genbuf, currboard); - if ((fd = (open(direct, O_RDONLY, 0))) != -1) { - if (lseek(fd, (off_t) (size * (inum1 - 1)), SEEK_SET) != - -1) { - while (read(fd, &rsfh, size) == size) { - if (i > inum2) - break; - now = getindex(genbuf, rsfh.filename, size); - strlcpy(currfile, rsfh.filename, sizeof(currfile)); - delete_record(genbuf, sizeof(fileheader_t), now); - // cmpfilename); - i++; - } - } - close(fd); - } - } #ifdef SAFE_ARTICLE_DELETE - if(bp && bp->nuser > 20 ) + if(bp && !(currmode & MODE_DIGEST) && bp->nuser > 20 ) safe_article_delete_range(direct, inum1, inum2); else delete_range(direct, inum1, inum2); @@ -1845,7 +1641,7 @@ static int del_post(int ent, fileheader_t * fhdr, char *direct) { char genbuf[100], newpath[256]; - int not_owned; + int num, not_owned; boardheader_t *bp; bp = getbcache(currbid); @@ -1862,35 +1658,19 @@ del_post(int ent, fileheader_t * fhdr, char *direct) !strcmp(cuser.userid, STR_GUEST)) return DONOTHING; + if (currmode & MODE_SELECT) { + vmsg("½Ð¦^¨ì¤@¯ë¼Ò¦¡¦A§R°£¤å³¹"); + return DONOTHING; + } getdata(1, 0, msg_del_ny, genbuf, 3, LCECHO); if (genbuf[0] == 'y') { - strlcpy(currfile, fhdr->filename, sizeof(currfile)); if( #ifdef SAFE_ARTICLE_DELETE - (bp->nuser>20 && !safe_article_delete(ent, fhdr, direct)) || + (bp->nuser>20 && !(currmode & MODE_DIGEST) && + !safe_article_delete(ent, fhdr, direct)) || #endif !delete_record(direct, sizeof(fileheader_t), ent) ) { - int num; - if (currmode & MODE_SELECT) { - /* rocker.011018: §Q¥Îreference´î§Cloading */ - fileheader_t hdr; - - /* fhdr->money is not real money now, it's a reference instead. - * see select_read() in read.c */ - num = fhdr->money & ~FHR_REFERENCE; - setbdir(genbuf, currboard); - get_record(genbuf, &hdr, sizeof(hdr), num); - - /* ¦A³o¸Ìncheck¤@¤Uì¨Óªºdir¸Ì±¬O¤£¬O¦³³Q¤H°Ê¹L... */ - if (strcmp(hdr.filename, fhdr->filename)) { - num = getindex(genbuf, fhdr->filename, sizeof(fileheader_t)); - get_record(genbuf, &hdr, sizeof(hdr), num); - } - /* rocker.011018: ³o¸ÌnÁÙì³Q¯}Ãaªºmoney */ - fhdr->money = hdr.money; - delete_record(genbuf, sizeof(fileheader_t), num); - } cancelpost(fhdr, not_owned, newpath); if(fhdr->filemode & FILE_ANONYMOUS) @@ -1939,13 +1719,9 @@ del_post(int ent, fileheader_t * fhdr, char *direct) if (cuser.numposts) cuser.numposts--; if (!(currmode & MODE_DIGEST && currmode & MODE_BOARD)){ - move(b_lines - 1, 0); - clrtoeol(); demoney(-fhdr->money); - prints("%s¡A±zªº¤å³¹´î¬° %d ½g¡A¤ä¥I²M¼ä¶O %d »È", msg_del_ok, + vmsg("±zªº¤å³¹´î¬° %d ½g¡A¤ä¥I²M¼ä¶O %d »È", cuser.numposts, fhdr->money); - refresh(); - pressanykey(); } } return DIRCHANGED; @@ -1959,30 +1735,24 @@ show_filename(int ent, fileheader_t * fhdr, char *direct) { if(!HAS_PERM(PERM_SYSOP)) return DONOTHING; - move(b_lines - 1, 0); - prints("ÀɮצWºÙ: %s ", fhdr->filename); - pressanykey(); + vmsg("ÀɮצWºÙ: %s ", fhdr->filename); return PART_REDRAW; } static int view_postmoney(int ent, fileheader_t * fhdr, char *direct) { - move(b_lines - 1, 0); if(currmode & MODE_SELECT){ vmsg("½Ð¦bÂ÷¶}¥Ø«eªº¿ï¾Ü¼Ò¦¡¦A¬d¸ß"); return FULLUPDATE; } - clrtoeol(); if(fhdr->filemode & FILE_ANONYMOUS) /* When the file is anonymous posted, fhdr->money is author. * see do_general() */ - prints("°Î¦WºÞ²z½s¸¹: %d (¦P¤@¤H³Q¬d¸ß®É½s¸¹¬Û¦P, ¦¹½s¸¹¨C¤H¬Ý¨ì¤£¬Û¦P)", + vmsg("°Î¦WºÞ²z½s¸¹: %d (¦P¤@¤H¸¹½X·|¤@¼Ë)", fhdr->money + currutmp->pid); else - prints("³o¤@½g¤å³¹È %d »È", fhdr->money); - refresh(); - pressanykey(); + vmsg("³o¤@½g¤å³¹È %d »È", fhdr->money); return FULLUPDATE; } @@ -2084,7 +1854,7 @@ sequent_messages(fileheader_t * fptr) "\033[30m¤U¤@«Ê \033[31m(¡ö,q)\033[30mÂ÷¶} \033[m"); continue_flag = 0; - switch (egetch()) { + switch (igetch()) { case KEY_LEFT: case 'e': case 'q': @@ -2319,13 +2089,13 @@ push_bottom(int ent, fileheader_t * fhdr, char *direct) char buf[256]; if ((currmode & MODE_DIGEST) || !(currmode & MODE_BOARD)) return DONOTHING; - setbottomtotal(currbid); // Ptt : will be remove when stable + setbottomtotal(currbid); // <- Ptt : will be remove when stable num = getbottomtotal(currbid); if(getans(fhdr->filemode & FILE_BOTTOM ? "¨ú®ø¸m©³¤½§i?(y/N)": "¥[¤J¸m©³¤½§i?(y/N)")!='y') return READ_REDRAW; fhdr->filemode ^= FILE_BOTTOM; - if(fhdr->filemode & FILE_BOTTOM) + if(fhdr->filemode & FILE_BOTTOM ) { sprintf(buf, "%s.bottom", direct); if(num >= 5) @@ -2333,7 +2103,9 @@ push_bottom(int ent, fileheader_t * fhdr, char *direct) vmsg("¤£±o¶W¹L 5 ½g«n¤½§i ½Ðºë²!"); return READ_REDRAW; } + fhdr->money = ent | FHR_REFERENCE; append_record(buf, fhdr, sizeof(fileheader_t)); + } else { @@ -2407,26 +2179,7 @@ good_post(int ent, fileheader_t * fhdr, char *direct) delta = 1000; } } - substitute_record(direct, fhdr, sizeof(*fhdr), ent); - /* rocker.011018: ¦ê±µ¼Ò¦¡¥Îreference¼W¶i®Ä²v */ - if ((currmode & MODE_SELECT) && (fhdr->money & FHR_REFERENCE)) { - fileheader_t hdr; - char genbuf[100]; - int num; - - num = fhdr->money & ~FHR_REFERENCE; - setbdir(genbuf, currboard); - get_record(genbuf, &hdr, sizeof(hdr), num); - - /* ¦A³o¸Ìncheck¤@¤Uì¨Óªºdir¸Ì±¬O¤£¬O¦³³Q¤H°Ê¹L... */ - if (strcmp(hdr.filename, fhdr->filename)) { - num = getindex(genbuf, fhdr->filename, sizeof(fileheader_t)); - get_record(genbuf, &hdr, sizeof(hdr), num); - } - fhdr->money = hdr.money + delta; - - substitute_record(genbuf, fhdr, sizeof(*fhdr), num); - } + substitute_ref_record(direct, fhdr, ent); return FULLUPDATE; } @@ -2496,7 +2249,7 @@ change_hidden(int ent, fileheader_t * fhdr, char *direct) bp = getbcache(currbid); if (((bp->brdattr & BRD_HIDE) && (bp->brdattr & BRD_POSTMASK))) { - if (getans("¥Ø«eªO¦bÁô§Îª¬ºA, n¸ÑÁô§Î¹À(Y/N)?[N]") != 'y') + if (getans("¥Ø«eªO¦bÁô§Îª¬ºA, n¸ÑÁô§Î¹À(y/N)?") != 'y') return FULLUPDATE; bp->brdattr &= ~BRD_HIDE; bp->brdattr &= ~BRD_POSTMASK; @@ -2504,7 +2257,7 @@ change_hidden(int ent, fileheader_t * fhdr, char *direct) board_hidden_status = 0; hbflreload(currbid); } else { - if (getans("¥Ø«eªO¦b²{§Îª¬ºA, nÁô§Î¹À(Y/N)?[N]") != 'y') + if (getans("¥Ø«eªO¦b²{§Îª¬ºA, nÁô§Î¹À(y/N)?") != 'y') return FULLUPDATE; bp->brdattr |= BRD_HIDE; bp->brdattr |= BRD_POSTMASK; @@ -2714,12 +2467,9 @@ ReadSelect() static void log_board(char *mode, time_t usetime) { - char buf[256]; - if (usetime > 30) { - snprintf(buf, sizeof(buf), "USE %-20.20s Stay: %5ld (%s) %s\n", - mode, usetime, cuser.userid, ctime(&now)); - log_file(FN_USEBOARD, buf, 1); + log_file(FN_USEBOARD, 1, "USE %-20.20s Stay: %5ld (%s) %s\n", + mode, usetime, cuser.userid, ctime(&now)); } } #endif diff --git a/mbbsd/board.c b/mbbsd/board.c index 7921f3e4..58bd0c0f 100644 --- a/mbbsd/board.c +++ b/mbbsd/board.c @@ -95,27 +95,6 @@ HasPerm(boardheader_t * bptr) return 1; } -#if 0 -static int -have_author(char *brdname) -{ - char dirname[100]; - - snprintf(dirname, sizeof(dirname), - SHM->i18nstr[cuser.language][470], - currauthor, brdname); - move(b_lines, 0); - clrtoeol(); - outs(dirname); - refresh(); - - setbdir(dirname, brdname); - str_lower(currowner, currauthor); - - return search_rec(dirname, cmpfowner); -} -#endif - static int check_newpost(boardstat_t * ptr) { /* Ptt §ï */ @@ -207,10 +186,9 @@ load_boards(char *key) int type = cuser.uflag & BRDSORT_FLAG ? 1 : 0; int i, n; int state; - char byMALLOC = 0, needREALLOC = 0; if (class_bid > 0) { - bptr = &bcache[class_bid - 1]; + bptr = getbcache(class_bid); if (bptr->firstchild[type] == NULL || bptr->childcount <= 0) load_uidofgid(class_bid, type); } @@ -235,7 +213,7 @@ load_boards(char *key) else if (get_item_type(&fav->favh[i]) == FAVT_FOLDER ) state = NBRD_FOLDER; else { - bptr = &bcache[ fav_getid(&fav->favh[i]) - 1]; + bptr = getbcache(fav_getid(&fav->favh[i])); state = NBRD_BOARD; if (is_set_attr(&fav->favh[i], FAVH_UNREAD)) state |= NBRD_UNREAD; @@ -252,7 +230,7 @@ load_boards(char *key) else continue; }else{ - bptr = &bcache[ fav_getid(&fav->favh[i]) - 1]; + bptr = getbcache(fav_getid(&fav->favh[i])); if( HasPerm(bptr) && strcasestr(bptr->title, key)) state = NBRD_BOARD; else @@ -270,8 +248,6 @@ load_boards(char *key) } if (brdnum == 0) addnewbrdstat(0, 0); - byMALLOC = 0; - needREALLOC = (get_data_number(fav) != brdnum); } #if HOTBOARDCACHE else if( class_bid == -1 ){ @@ -298,12 +274,6 @@ load_boards(char *key) continue; addnewbrdstat(n, state); } -#ifdef CRITICAL_MEMORY - byMALLOC = 1; -#else - byMALLOC = 0; -#endif - needREALLOC = 1; } #if ! HOTBOARDCACHE if (class_bid == -1) @@ -311,9 +281,10 @@ load_boards(char *key) #endif } else { /* load boards of a subclass */ int childcount = bptr->childcount; - nbrd = (boardstat_t *) malloc(childcount * sizeof(boardstat_t)); - for (bptr = bptr->firstchild[type]; bptr != NULL; - bptr = bptr->next[type]) { + nbrd = (boardstat_t *) malloc((childcount+2) * sizeof(boardstat_t)); + // ¹w¯d¨âÓ¥H§K¤j¶q¶}ª©®É±¾½Õ + for (bptr = bptr->firstchild[type]; bptr != NULL && + brdnum < childcount+2; bptr = bptr->next[type]) { n = getbid(bptr); state = HasPerm(bptr); if ( !(state || GROUPOP()) || TITLE_MATCH(bptr, key) ) @@ -329,21 +300,10 @@ load_boards(char *key) } addnewbrdstat(n, state); } - byMALLOC = 0; - needREALLOC = (childcount != brdnum); - } - - if( needREALLOC ){ - if( byMALLOC ){ - boardstat_t *newnbrd; - newnbrd = (boardstat_t *)malloc(sizeof(boardstat_t) * brdnum); - memcpy(newnbrd, nbrd, sizeof(boardstat_t) * brdnum); - FREE(nbrd); - nbrd = newnbrd; - } - else { - nbrd = (boardstat_t *)realloc(nbrd, sizeof(boardstat_t) * brdnum); - } + if(childcount < brdnum) //Ptt: dirty fix fix soon + getbcache(class_bid)->childcount = 0; + + } } @@ -458,7 +418,7 @@ show_brdlist(int head, int clsflag, int newflag) if (yank_flag == 0 && get_fav_type(&nbrd[0]) == 0){ move(3, 0); - prints(SHM->i18nstr[cuser.language][483]); + outs(SHM->i18nstr[cuser.language][483]); return; } @@ -494,7 +454,7 @@ show_brdlist(int head, int clsflag, int newflag) } if (class_bid == 1) - prints(" "); + outs(" "); if (!newflag) { prints("%5d%c%s", head, !(B_BH(ptr)->brdattr & BRD_HIDE) ? ' ' : @@ -504,14 +464,14 @@ show_brdlist(int head, int clsflag, int newflag) unread[ptr->myattr & NBRD_UNREAD ? 1 : 0]); } else { if (B_BH(ptr)->brdattr & BRD_GROUPBOARD) - prints(" "); + outs(" "); else prints("%6d%s", (int)(B_TOTAL(ptr)), unread[ptr->myattr & NBRD_UNREAD ? 1 : 0]); } if (class_bid != 1) { if (!GROUPOP() && !HasPerm(B_BH(ptr))) { - prints(SHM->i18nstr[cuser.language][486]); + outs(SHM->i18nstr[cuser.language][486]); } else { prints("%s%-13s\033[m%s%5.5s\033[0;37m%2.2s\033[m%-34.34s", @@ -524,15 +484,15 @@ show_brdlist(int head, int clsflag, int newflag) B_BH(ptr)->title, B_BH(ptr)->title + 5, B_BH(ptr)->title + 7); if (B_BH(ptr)->brdattr & BRD_BAD) - prints(" X "); + outs(" X "); else if (B_BH(ptr)->nuser >= 5000) - prints(SHM->i18nstr[cuser.language][487]); + outs(SHM->i18nstr[cuser.language][487]); else if (B_BH(ptr)->nuser >= 2000) - prints(SHM->i18nstr[cuser.language][488]); + outs(SHM->i18nstr[cuser.language][488]); else if (B_BH(ptr)->nuser >= 1000) - prints(SHM->i18nstr[cuser.language][489]); + outs(SHM->i18nstr[cuser.language][489]); else if (B_BH(ptr)->nuser >= 100) - prints("\033[1mHOT\033[m"); + outs("\033[1mHOT\033[m"); else if (B_BH(ptr)->nuser > 50) prints("\033[1;31m%2d\033[m ", B_BH(ptr)->nuser); else if (B_BH(ptr)->nuser > 10) @@ -564,9 +524,35 @@ set_menu_BM(char *BM) static void replace_link_by_target(boardstat_t *board) { - board->bid = BRD_LINK_TARGET(&bcache[board->bid - 1]); + board->bid = BRD_LINK_TARGET(getbcache(board->bid)); board->myattr &= ~NBRD_SYMBOLIC; } +static int +paste_taged_brds(int gid) +{ + fav_t *fav; + int bid, tmp; + + if (gid == 0 || ! (HAS_PERM(PERM_SYSOP) || GROUPOP()) || + getans("¶K¤W¼Ð°Oªº¬ÝªO?(y/N)")=='n') return 0; + fav = get_current_fav(); + for (tmp = 0; tmp < fav->DataTail; tmp++) { + bid = fav_getid(&fav->favh[tmp]); + boardheader_t *bh = getbcache(bid); + if( !is_set_attr(&fav->favh[tmp], FAVH_ADM_TAG)) + continue; + set_attr(&fav->favh[tmp], FAVH_ADM_TAG, 0); + if (bh->gid != gid) { + bh->gid = gid; + substitute_record(FN_BOARD, bh, + sizeof(boardheader_t), bid); + reset_board(bid); + log_usies("SetBoardGID", bh->brdname); + } + } + sort_bcache(); + return 1; +} static void choose_board(int newflag) @@ -590,8 +576,7 @@ choose_board(int newflag) load_boards(keyword); if (brdnum <= 0 && yank_flag > 0) { if (keyword[0] != 0) { - mprints(b_lines - 1, 0, SHM->i18nstr[cuser.language][510]); - pressanykey(); + vmsg(SHM->i18nstr[cuser.language][510]); keyword[0] = 0; brdnum = -1; continue; @@ -602,7 +587,8 @@ choose_board(int newflag) continue; } if (HAS_PERM(PERM_SYSOP) || GROUPOP()) { - if (m_newbrd(0) == -1) + if (paste_taged_brds(class_bid) || + m_newbrd(0) == -1) break; brdnum = -1; continue; @@ -730,7 +716,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] + getbcache(class_bid)->firstchild[cuser.uflag & BRDSORT_FLAG ? 1 : 0] = NULL; brdnum = -1; } @@ -768,7 +754,7 @@ choose_board(int newflag) ptr = &nbrd[num]; if (ptr->myattr & NBRD_SYMBOLIC) { if (getans(SHM->i18nstr[cuser.language][514]) == 'y') - delete_symbolic_link(&bcache[ptr->bid - 1], ptr->bid); + delete_symbolic_link(getbcache(ptr->bid), ptr->bid); } brdnum = -1; } @@ -792,26 +778,9 @@ choose_board(int newflag) } break; case Ctrl('P'): - if (class_bid != 0 && - (HAS_PERM(PERM_SYSOP) || GROUPOP())) { - fav_t *fav = get_current_fav(); - for (tmp = 0; tmp < fav->DataTail; tmp++) { - short bid = fav_getid(&fav->favh[tmp]); - boardheader_t *bh = &bcache[ bid - 1 ]; - if( !is_set_attr(&fav->favh[tmp], FAVH_ADM_TAG)) - continue; - set_attr(&fav->favh[tmp], FAVH_ADM_TAG, 0); - if (bh->gid != class_bid) { - bh->gid = class_bid; - substitute_record(FN_BOARD, bh, - sizeof(boardheader_t), bid); - reset_board(bid); - log_usies("SetBoardGID", bh->brdname); - } - } - brdnum = -1; - } - break; + if (paste_taged_brds(class_bid)) + brdnum = -1; + break; case 'L': if (HAS_PERM(PERM_SYSOP) && class_bid > 0) { if (make_symbolic_link_interactively(class_bid) < 0) @@ -1009,7 +978,7 @@ choose_board(int newflag) case 'W': if (class_bid > 0 && (HAS_PERM(PERM_SYSOP) || GROUPOP())) { - setbpath(buf, bcache[class_bid - 1].brdname); + setbpath(buf, getbcache(class_bid)->brdname); mkdir(buf, 0755); /* Ptt:¶}¸s²Õ¥Ø¿ý */ b_note_edit_bname(class_bid); brdnum = -1; diff --git a/mbbsd/cache.c b/mbbsd/cache.c index d35b0839..2569a45f 100644 --- a/mbbsd/cache.c +++ b/mbbsd/cache.c @@ -471,13 +471,9 @@ setutmpmode(unsigned int mode) { if (currstat != mode) currutmp->mode = currstat = mode; - /* °lÂÜ¨Ï¥ÎªÌ */ 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)); - log_user(msg); + log_user("setutmpmode to %s(%d)", modestring(currutmp, 0), mode); } } #endif @@ -504,11 +500,15 @@ cmpboardclass(boardheader_t ** brd, boardheader_t ** tmp) strcasecmp((*brd)->brdname, (*tmp)->brdname); } -static void +void sort_bcache(void) { int i; - /* critical section ¤£¯à³æ¿W©I¥s ©I¥sreload_bcache or reset_board */ + /* critical section ºÉ¶q¤£n©I¥s */ + /* ¥u¦³·s¼W ©Î²¾°£¬ÝªO »Ýn©I¥s¨ì */ + if(SHM->Bbusystate) + { sleep(1); return; } + SHM->Bbusystate = 1; for (i = 0; i < SHM->Bnumber; i++) { SHM->bsorted[1][i] = SHM->bsorted[0][i] = &bcache[i]; } @@ -516,6 +516,12 @@ sort_bcache(void) (QCAST) cmpboardname); qsort(SHM->bsorted[1], SHM->Bnumber, sizeof(boardheader_t *), (QCAST) cmpboardclass); + + for (i = 0; i < SHM->Bnumber; i++) { + bcache[i].firstchild[0] = NULL; + bcache[i].firstchild[1] = NULL; + } + SHM->Bbusystate = 0; } void @@ -525,7 +531,7 @@ reload_bcache(void) safe_sleep(1); } else { - int fd, i; + int fd; SHM->Bbusystate = 1; if ((fd = open(fn_board, O_RDONLY)) > 0) { @@ -538,12 +544,8 @@ reload_bcache(void) /* µ¥©Ò¦³ boards ¸ê®Æ§ó·s«á¦A³]©w uptime */ SHM->Buptime = SHM->Btouchtime; log_usies("CACHE", "reload bcache"); - sort_bcache(); - for (i = 0; i < SHM->Bnumber; ++i) { - bcache[i].firstchild[0] = NULL; - bcache[i].firstchild[1] = NULL; - } SHM->Bbusystate = 0; + sort_bcache(); } } @@ -571,7 +573,7 @@ void addbrd_touchcache(void) void reset_board(int bid) /* XXXbid: from 1 */ { /* Ptt: ³o¼Ë´N¤£¥Î¦Ñ¬Otouch board¤F */ - int fd, i, nuser; + int fd, nuser; boardheader_t *bhdr; if (--bid < 0) @@ -589,11 +591,6 @@ reset_board(int bid) /* XXXbid: from 1 */ read(fd, bhdr, sizeof(boardheader_t)); close(fd); } - sort_bcache(); - for (i = 0; i < SHM->Bnumber; i++) { - bcache[i].firstchild[0] = NULL; - bcache[i].firstchild[1] = NULL; - } SHM->busystate_b[bid] = 0; buildBMcache(bid + 1); /* XXXbid */ @@ -628,6 +625,9 @@ setbottomtotal(int bid) n = get_num_records(genbuf, sizeof(fileheader_t)); if(n>5) { +#ifdef DEBUG_BOTTOM + log_file("fix_bottom", 1, "%s n:%d\n", genbuf, n); +#endif unlink(genbuf); SHM->n_bottom[bid-1]=0; } diff --git a/mbbsd/cal.c b/mbbsd/cal.c index 427fce04..efaf30da 100644 --- a/mbbsd/cal.c +++ b/mbbsd/cal.c @@ -59,13 +59,12 @@ unlockutmpmode() int vice(int money, char *item) { - char buf[128], vice[12]; + char buf[128]; unsigned int viceserial = (currutmp->lastact % 1000000) * 100 + rand() % 100; demoney(-money); setuserfile(buf, VICE_NEW); - sprintf(vice,"%8.8d\n", viceserial); - log_file(buf, vice, 1); + log_file(buf, 1, "%8.8d\n", viceserial); snprintf(buf, sizeof(buf), SHM->i18nstr[cuser.language][534], item, money, viceserial); mail_id(cuser.userid, buf, "etc/vice.txt", SHM->i18nstr[cuser.language][535]); @@ -96,18 +95,13 @@ osong(char *defaultid) /* Jaky ¤@¤H¤@¤ÑÂI¤@º */ if (!strcmp(buf, Cdatedate(&cuser.lastsong)) && !HAS_PERM(PERM_SYSOP)) { move(22, 0); - outs(SHM->i18nstr[cuser.language][536]); - refresh(); - pressanykey(); - + vmsg(SHM->i18nstr[cuser.language][536]); unlockutmpmode(); return 0; } if (cuser.money < 200) { move(22, 0); - outs(SHM->i18nstr[cuser.language][537]); - refresh(); - pressanykey(); + vmsg(SHM->i18nstr[cuser.language][537]); unlockutmpmode(); return 0; } @@ -256,18 +250,12 @@ inmailbox(int m) int p_cloak() { - char buf[4]; - getdata(b_lines - 1, 0, - currutmp->invisible ? SHM->i18nstr[cuser.language][557] : SHM->i18nstr[cuser.language][558], - buf, sizeof(buf), LCECHO); - if (buf[0] != 'y') + if (getans(currutmp->invisible ? SHM->i18nstr[cuser.language][557] : SHM->i18nstr[cuser.language][558]) != 'y') return 0; if (cuser.money >= 19) { vice(19, SHM->i18nstr[cuser.language][559]); currutmp->invisible %= 2; - outs((currutmp->invisible ^= 1) ? MSG_CLOAKED : MSG_UNCLOAK); - refresh(); - safe_sleep(1); + vmsg((currutmp->invisible ^= 1) ? MSG_CLOAKED : MSG_UNCLOAK); } return 0; } @@ -276,10 +264,7 @@ p_cloak() int p_from() { - char ans[4]; - - getdata(b_lines - 2, 0, SHM->i18nstr[cuser.language][560], ans, sizeof(ans), LCECHO); - if (ans[0] != 'y') + if (getans(SHM->i18nstr[cuser.language][560]) != 'y') return 0; reload_money(); if (cuser.money < 49) @@ -299,8 +284,7 @@ p_exmail() int n; if (cuser.exmailbox >= MAX_EXKEEPMAIL) { - prints(SHM->i18nstr[cuser.language][563], MAX_EXKEEPMAIL); - refresh(); + vmsg(SHM->i18nstr[cuser.language][563], MAX_EXKEEPMAIL); return 0; } snprintf(buf, sizeof(buf), @@ -364,14 +348,14 @@ int p_give() { int money, tax; - char id[IDLEN + 1], genbuf[90]; + char id[IDLEN + 1], money_buf[20]; move(1, 0); usercomplete(SHM->i18nstr[cuser.language][568], id); if (!id[0] || !strcmp(cuser.userid, id) || - !getdata(2, 0, SHM->i18nstr[cuser.language][569], genbuf, 7, LCECHO)) + !getdata(2, 0, SHM->i18nstr[cuser.language][569], money_buf, 7, LCECHO)) return 0; - money = atoi(genbuf); + money = atoi(money_buf); reload_money(); if (money > 0 && cuser.money >= money) { tax = give_tax(money); @@ -379,12 +363,9 @@ p_give() return 0; /* ú§¹µ|´N¨S¿úµ¹¤F */ deumoney(searchuser(id), money - tax); demoney(-money); - snprintf(genbuf, sizeof(genbuf), SHM->i18nstr[cuser.language][570], - cuser.userid, id, money - tax, ctime(&now)); - log_file(FN_MONEY, genbuf, 1); - genbuf[0] = 'n'; - getdata(3, 0, SHM->i18nstr[cuser.language][571], genbuf, 2, LCECHO); - mail_redenvelop(cuser.userid, id, money - tax, genbuf[0]); + log_file(FN_MONEY,1, SHM->i18nstr[cuser.language][570], + cuser.userid, id, money - tax, ctime(&now)); + mail_redenvelop(cuser.userid, id, money - tax, getans(SHM->i18nstr[cuser.language][571])); } return 0; } @@ -432,26 +413,3 @@ p_sysinfo(void) return 0; } -/* ¤ppºâ¾÷ */ -#if 0 -static void -ccount(float *a, float b, int cmode) -{ - switch (cmode) { - case 0: - case 1: - case 2: - *a += b; - break; - case 3: - *a -= b; - break; - case 4: - *a *= b; - break; - case 5: - *a /= b; - break; - } -} -#endif diff --git a/mbbsd/card.c b/mbbsd/card.c index a402e152..1b20cd41 100644 --- a/mbbsd/card.c +++ b/mbbsd/card.c @@ -41,7 +41,7 @@ card_select(int *now) (*now == 2) ? cc[1] : cc[0], (*now == 3) ? cc[1] : cc[0], (*now == 4) ? cc[1] : cc[0]); - switch (egetch()) { + switch (igetch()) { case 'Q': case 'q': return 0; @@ -449,16 +449,12 @@ card_jack(int *db) if ((card_number(me[0]) == 0 && card_number(me[1]) == 12) || (card_number(me[1]) == 0 && card_number(me[0]) == 12)) { if (card_flower(me[0]) == 0 && card_flower(me[1]) == 0) { - move(b_lines - 1, 0); - prints(SHM->i18nstr[cuser.language][639], JACK * 10); game_log(JACK, JACK * 10); - pressanykey(); + vmsg(SHM->i18nstr[cuser.language][639], JACK * 10); return 0; } else { - move(b_lines - 1, 0); - prints(SHM->i18nstr[cuser.language][640], JACK * 5); game_log(JACK, JACK * 5); - pressanykey(); + vmsg(SHM->i18nstr[cuser.language][640], JACK * 5); return 0; } } @@ -466,10 +462,8 @@ card_jack(int *db) (card_number(cpu[1]) == 0 && card_number(cpu[0]) == 12)) { c[0] = 1; card_show(cpu, c, me, m); - move(b_lines - 1, 0); - prints(SHM->i18nstr[cuser.language][641]); game_log(JACK, 0); - pressanykey(); + vmsg(SHM->i18nstr[cuser.language][641]); return 0; } if ((*db < 0) && (card_number(me[0]) == card_number(me[1])) && @@ -484,27 +478,21 @@ card_jack(int *db) m[i] = 1; card_show(cpu, c, me, m); if (card_alls_lower(me) > 21) { - move(b_lines - 1, 0); - prints(SHM->i18nstr[cuser.language][642]); game_log(JACK, 0); - pressanykey(); + vmsg(SHM->i18nstr[cuser.language][642]); return 0; } i++; if ((i == 3) && (card_number(me[0]) == 7) && (card_number(me[1]) == 7) && (card_number(me[2]) == 7)) { - move(b_lines - 1, 0); - prints(SHM->i18nstr[cuser.language][643], JACK * 7); game_log(JACK, JACK * 7); - pressanykey(); + vmsg(SHM->i18nstr[cuser.language][643], JACK * 7); return 0; } } if (i == 5) { /* ¹L¤Ãö */ - move(b_lines - 1, 0); - prints(SHM->i18nstr[cuser.language][644], 5 * JACK); game_log(JACK, JACK * 5); - pressanykey(); + vmsg(SHM->i18nstr[cuser.language][644], 5 * JACK); return 0; } j = 2; @@ -515,19 +503,15 @@ card_jack(int *db) c[j] = 1; if (card_alls_lower(cpu) > 21) { card_show(cpu, c, me, m); - move(b_lines - 1, 0); - prints(SHM->i18nstr[cuser.language][645], JACK * 2); game_log(JACK, JACK * 2); - pressanykey(); + vmsg(SHM->i18nstr[cuser.language][645], JACK * 2); return 0; } j++; } card_show(cpu, c, me, m); - move(b_lines - 1, 0); - prints(SHM->i18nstr[cuser.language][646]); game_log(JACK, 0); - pressanykey(); + vmsg(SHM->i18nstr[cuser.language][646]); return 0; } @@ -594,19 +578,15 @@ ten_helf() m[i] = 1; card_show(cpu, c, me, m); if (card_all(me) > 21) { - move(b_lines - 1, 0); - prints(SHM->i18nstr[cuser.language][651]); game_log(TEN_HALF, 0); - pressanykey(); + vmsg(SHM->i18nstr[cuser.language][651]); return 0; } i++; } if (i == 5) { /* ¹L¤Ãö */ - move(b_lines - 1, 0); - prints(SHM->i18nstr[cuser.language][652], 5 * PMONEY); game_log(TEN_HALF, PMONEY * 5); - pressanykey(); + vmsg(SHM->i18nstr[cuser.language][652], 5 * PMONEY); return 0; } j = 1; @@ -617,19 +597,15 @@ ten_helf() c[j] = 1; if (card_all(cpu) > 21) { card_show(cpu, c, me, m); - move(b_lines - 1, 0); - prints(SHM->i18nstr[cuser.language][653], PMONEY * 2); game_log(TEN_HALF, PMONEY * 2); - pressanykey(); + vmsg(SHM->i18nstr[cuser.language][653], PMONEY * 2); return 0; } j++; } card_show(cpu, c, me, m); - move(b_lines - 1, 0); - prints(SHM->i18nstr[cuser.language][654]); game_log(TEN_HALF, 0); - pressanykey(); + vmsg(SHM->i18nstr[cuser.language][654]); return 0; } diff --git a/mbbsd/chat.c b/mbbsd/chat.c index 2c550820..53066280 100644 --- a/mbbsd/chat.c +++ b/mbbsd/chat.c @@ -387,7 +387,7 @@ t_chat() while (chatting) { move(b_lines - 1, currchar + chatid_len); - ch = igetkey(); + ch = igetch(); switch (ch) { case KEY_DOWN: diff --git a/mbbsd/chc.c b/mbbsd/chc.c index 0788b96f..b5bd8696 100644 --- a/mbbsd/chc.c +++ b/mbbsd/chc.c @@ -552,14 +552,14 @@ hisplay(int s, chcusr_t *user1, chcusr_t *user2, board_t board, board_t tmpbrd) if (chc_lefttime < 0) { chc_lefttime = 0; - /* to make him break out igetkey() */ + /* to make him break out igetch() */ chc_from.r = -2; chc_broadcast_send(act_list, board); } chc_drawline(board, user1, user2, TIME_ROW); move(1, 0); oflush(); - switch (igetkey()) { + switch (igetch()) { case 'q': endgame = 2; endturn = 1; @@ -630,7 +630,7 @@ myplay(int s, chcusr_t *user1, chcusr_t *user2, board_t board, board_t tmpbrd) chc_drawline(board, user1, user2, TIME_ROW); chc_movecur(chc_cursor.r, chc_cursor.c); oflush(); - ch = igetkey(); + ch = igetch(); chc_lefttime = CHC_TIMEOUT - (now - start_time); if (chc_lefttime < 0) ch = 'q'; diff --git a/mbbsd/chicken.c b/mbbsd/chicken.c index eeb5b1f9..2c63f274 100644 --- a/mbbsd/chicken.c +++ b/mbbsd/chicken.c @@ -81,25 +81,23 @@ static int new_chicken() { chicken_t *mychicken = &cuser.mychicken; - char buf[150]; - int price; + int price, i; clear(); move(2, 0); outs(SHM->i18nstr[cuser.language][867]); - getdata_str(7, 0, SHM->i18nstr[cuser.language][868], buf, 3, LCECHO, "0"); + i = getans(SHM->i18nstr[cuser.language][868]); - buf[0] -= 'a'; - if (buf[0] < 0 || buf[0] > NUM_KINDS - 1) + i -= 'a'; + if (i < 0 || i > NUM_KINDS - 1) return 0; - mychicken->type = buf[0]; + mychicken->type = i; reload_money(); price = egg_price[(int)mychicken->type]; if (cuser.money < price) { - prints(SHM->i18nstr[cuser.language][869], price); - refresh(); + vmsg(SHM->i18nstr[cuser.language][869], price); return 0; } vice(price, SHM->i18nstr[cuser.language][870]); @@ -107,10 +105,9 @@ new_chicken() getdata(8, 0, SHM->i18nstr[cuser.language][871], mychicken->name, sizeof(mychicken->name), DOECHO); - snprintf(buf, sizeof(buf), - SHM->i18nstr[cuser.language][872], cuser.userid, - mychicken->name, chicken_type[(int)mychicken->type], ctime(&now)); - log_file(CHICKENLOG, buf, 1); + log_file(CHICKENLOG, 1, SHM->i18nstr[cuser.language][872], + cuser.userid, + mychicken->name, chicken_type[(int)mychicken->type], ctime(&now)); mychicken->lastvisit = mychicken->birthday = mychicken->cbirth = now; mychicken->food = 0; mychicken->weight = time_change[(int)mychicken->type][WEIGHT] / 3; @@ -359,12 +356,10 @@ ch_buyitem(int money, char *picture, int *item, int haveticket) else demoney(-money * num); show_file(picture, 5, 14, NO_RELOAD); + pressanykey(); } else { - move(b_lines - 1, 0); - clrtoeol(); - outs(SHM->i18nstr[cuser.language][903]); + vmsg(SHM->i18nstr[cuser.language][903]); } - pressanykey(); } static void @@ -402,19 +397,16 @@ static void ch_kill() { chicken_t *mychicken = &cuser.mychicken; - char buf[150], ans[4]; + int ans; - snprintf(buf, sizeof(buf), SHM->i18nstr[cuser.language][904], - chicken_type[(int)mychicken->type]); - getdata_str(23, 0, buf, ans, sizeof(ans), DOECHO, "N"); - if (ans[0] == 'y') { + ans = getans(SHM->i18nstr[cuser.language][904]); + if (ans == 'y') { vice(100, SHM->i18nstr[cuser.language][905]); more(CHICKEN_PIC "/deadth", YEA); - snprintf(buf, sizeof(buf), + log_file(CHICKENLOG, 1, SHM->i18nstr[cuser.language][906], cuser.userid, mychicken->name, chicken_type[(int)mychicken->type], ctime(&now)); - log_file(CHICKENLOG, buf, 1); mychicken->name[0] = 0; } } @@ -443,8 +435,7 @@ ch_sell() int money = (age * food_price[(int)mychicken->type] * 3 + (mychicken->hp_max * 10 + mychicken->weight) / time_change[(int)mychicken->type][HP_MAX]) * 3 / 2 - - mychicken->sick; - char buf[150], ans[4]; + mychicken->sick, ans; if (money < 0) money = 0; @@ -466,14 +457,12 @@ ch_sell() pressanykey(); return 0; } - snprintf(buf, sizeof(buf), SHM->i18nstr[cuser.language][910], age, - chicken_type[(int)mychicken->type], money); - getdata_str(23, 0, buf, ans, sizeof(ans), DOECHO, "N"); - if (ans[0] == 'y') { - snprintf(buf, sizeof(buf), SHM->i18nstr[cuser.language][911], - cuser.userid, mychicken->name, - chicken_type[(int)mychicken->type], money, ctime(&now)); - log_file(CHICKENLOG, buf, 1); + ans = getans(SHM->i18nstr[cuser.language][910], age, + chicken_type[(int)mychicken->type], money); + if (ans == 'y') { + log_file(CHICKENLOG, 1, SHM->i18nstr[cuser.language][911], + cuser.userid, mychicken->name, + chicken_type[(int)mychicken->type], money, ctime(&now)); mychicken->lastvisit = mychicken->name[0] = 0; passwd_update(usernum, &cuser); more(CHICKEN_PIC "/sell", YEA); @@ -610,7 +599,6 @@ deadtype(chicken_t * thechicken) { chicken_t *mychicken = &cuser.mychicken; int i; - char buf[150]; if (thechicken->hp <= 0) /* hp¥ÎºÉ */ i = 1; @@ -627,12 +615,10 @@ deadtype(chicken_t * thechicken) return 0; if (thechicken == mychicken) { - snprintf(buf, sizeof(buf), - SHM->i18nstr[cuser.language][912], - cuser.userid, thechicken->name, - chicken_type[(int)thechicken->type], - ctime(&now)); - log_file(CHICKENLOG, buf, 1); + log_file(CHICKENLOG, 1, + SHM->i18nstr[cuser.language][912], + cuser.userid, thechicken->name, + chicken_type[(int)thechicken->type], ctime(&now)); mychicken->name[0] = 0; passwd_update(usernum, &cuser); } @@ -679,19 +665,16 @@ static void ch_changename() { chicken_t *mychicken = &cuser.mychicken; - char buf[150], newname[20] = ""; + char newname[20] = ""; getdata_str(b_lines - 1, 0, SHM->i18nstr[cuser.language][913], newname, 18, DOECHO, mychicken->name); if (strlen(newname) >= 3 && strcmp(newname, mychicken->name)) { - snprintf(buf, sizeof(buf), - SHM->i18nstr[cuser.language][914], - cuser.userid, mychicken->name, - chicken_type[(int)mychicken->type], - newname, ctime(&now)); strlcpy(mychicken->name, newname, sizeof(mychicken->name)); - log_file(CHICKENLOG, buf, 1); + log_file(CHICKENLOG, 1, SHM->i18nstr[cuser.language][914], + cuser.userid, mychicken->name, + chicken_type[(int)mychicken->type], newname, ctime(&now)); } } @@ -880,20 +863,18 @@ chickenpk(int fd) memcpy(&ouser, &xuser, sizeof(userec_t)); reload_chicken(); if (!ochicken->name[0] || !mychicken->name[0]) { - outmsg(SHM->i18nstr[cuser.language][925]); /* Ptt:§«¤îpage®É§âÃdª«½æ±¼ */ bell(); - refresh(); + vmsg(SHM->i18nstr[cuser.language][925]); /* Ptt:§«¤îpage®É§âÃdª«½æ±¼ */ add_io(0, 0); close(fd); unlockutmpmode(); - sleep(1); return 0; } show_chicken_data(ochicken, mychicken); add_io(fd, 3); /* §âfd¥[¨ìigetchºÊµø */ while (1) { r = rand(); - ch = igetkey(); + ch = igetch(); getuser(mateid); memcpy(&ouser, &xuser, sizeof(userec_t)); reload_chicken(); diff --git a/mbbsd/dark.c b/mbbsd/dark.c index 71058894..e26dd890 100644 --- a/mbbsd/dark.c +++ b/mbbsd/dark.c @@ -33,14 +33,6 @@ brdswap(sint y, sint x, sint ly, sint lx) brd[ly][lx].value = -1; } -static void -pprints(sint y, sint x, char *s) -{ - move(y, x); - clrtoeol(); - prints("%s", s); -} - static sint Is_win(item att, item det, sint y, sint x, sint ly, sint lx) { @@ -370,11 +362,11 @@ main_dark(int fd, userinfo_t * uin) if (currutmp->turn) { brd_rand(); send(fd, &brd, sizeof(brd), 0); - pprints(21, 0, " [1;37m[1;33m¡»[1;37m§A¬O¥ý¤â[m"); - pprints(22, 0, " [1;33m¡»[5;35m½ü¨ì§A¤U¤F[m"); + mouts(21, 0, " [1;37m[1;33m¡»[1;37m§A¬O¥ý¤â[m"); + mouts(22, 0, " [1;33m¡»[5;35m½ü¨ì§A¤U¤F[m"); } else { recv(fd, &brd, sizeof(brd), 0); - pprints(21, 0, " [1;33m¡»[1;37m§A¬O«á¤â[m"); + mouts(21, 0, " [1;33m¡»[1;37m§A¬O«á¤â[m"); } move(12, 3); prints("%s[0³Ó0±Ñ][5;31m¢þ¢û[1;37m.[m%s[0³Ó0±Ñ]", currutmp->userid, currutmp->mateid); @@ -396,7 +388,7 @@ main_dark(int fd, userinfo_t * uin) end = -1; break; } - ch = igetkey(); + ch = igetch(); if (ch == I_OTHERDATA) { ch = recv(fd, &curr, sizeof(curr), 0); if (ch != sizeof(curr)) { @@ -412,20 +404,20 @@ main_dark(int fd, userinfo_t * uin) break; } if (curr.end == -3) - pprints(23, 30, "\033[33mn¨D¦X´Ñ\033[m"); + mouts(23, 30, "\033[33mn¨D¦X´Ñ\033[m"); else if (curr.end == -4) - pprints(23, 30, "\033[33mn¨D´«Ãä\033[m"); + mouts(23, 30, "\033[33mn¨D´«Ãä\033[m"); else if (curr.end == -5) - pprints(23, 30, "\033[33mn¨D³s¦Y\033[m"); + mouts(23, 30, "\033[33mn¨D³s¦Y\033[m"); else - pprints(23, 30, ""); + mouts(23, 30, ""); recv(fd, &brd, sizeof(brd), 0); my = curr.y; mx = curr.x; redraw(); if (curr.end) - pprints(22, 0, " [1;33m¡»[5;35m½ü¨ì§A¤U¤F[m"); + mouts(22, 0, " [1;33m¡»[5;35m½ü¨ì§A¤U¤F[m"); move(cury[my], curx[mx]); } else { if (currutmp->turn == 'p') { @@ -434,7 +426,7 @@ main_dark(int fd, userinfo_t * uin) currutmp->turn = 'e'; break; } else { - pprints(23, 30, ""); + mouts(23, 30, ""); *buf = 0; currutmp->turn = (uin->turn) ? 0 : 1; } @@ -442,17 +434,17 @@ main_dark(int fd, userinfo_t * uin) if (ch == 'y') { currutmp->color = (currutmp->color == '1') ? '0' : '1'; uin->color = (uin->color == '1') ? '0' : '1'; - pprints(21, 0, (currutmp->color == '1') ? " \033[1;33m¡»[1;31m§A«ù¬õ¦â´Ñ\033[m" : " \033[1;33m¡»[1;36m§A«ù¶Â¦â´Ñ\033[m"); + mouts(21, 0, (currutmp->color == '1') ? " \033[1;33m¡»[1;31m§A«ù¬õ¦â´Ñ\033[m" : " \033[1;33m¡»[1;36m§A«ù¶Â¦â´Ñ\033[m"); } else { - pprints(23, 30, ""); + mouts(23, 30, ""); currutmp->turn = (uin->turn) ? 0 : 1; } } else if (currutmp->turn == 'g') { if (ch == 'y') { cont = 1; - pprints(21, 0, " \033[1;33m¡»[1;31m§A«ù¬õ¦â´Ñ\033[m ¥i³s¦Y"); + mouts(21, 0, " \033[1;33m¡»[1;31m§A«ù¬õ¦â´Ñ\033[m ¥i³s¦Y"); } else { - pprints(23, 30, ""); + mouts(23, 30, ""); currutmp->turn = (uin->turn) ? 0 : 1; } } @@ -460,7 +452,7 @@ main_dark(int fd, userinfo_t * uin) if (uin->turn == 'g') { cont = 1; uin->turn = (currutmp->turn) ? 0 : 1; - pprints(21, 10, "¥i³s¦Y"); + mouts(21, 10, "¥i³s¦Y"); } end = playing(fd, currutmp->color - '0', ch, &go_on, uin); @@ -493,12 +485,12 @@ main_dark(int fd, userinfo_t * uin) continue; } if (!i && currutmp->color == '1') { - pprints(21, 0, " \033[1;33m¡»[1;31m§A«ù¬õ¦â´Ñ\033[m"); + mouts(21, 0, " \033[1;33m¡»[1;31m§A«ù¬õ¦â´Ñ\033[m"); i++; move(cury[my], curx[mx]); } if (!i && currutmp->color == '0') { - pprints(21, 0, " \033[1;33m¡»[1;36m§A«ù¶Â¦â´Ñ\033[m"); + mouts(21, 0, " \033[1;33m¡»[1;36m§A«ù¶Â¦â´Ñ\033[m"); i++; move(cury[my], curx[mx]); } @@ -540,7 +532,7 @@ main_dark(int fd, userinfo_t * uin) } break; case -3: - pprints(22, 0, "[1;31m¦X´Ñò!! ¤U¦¸¦b¤À°ª¤U§a ^_^[m"); + mouts(22, 0, "[1;31m¦X´Ñò!! ¤U¦¸¦b¤À°ª¤U§a ^_^[m"); break; default: add_io(0, 0); diff --git a/mbbsd/edit.c b/mbbsd/edit.c index acc7bac0..d8f376fc 100644 --- a/mbbsd/edit.c +++ b/mbbsd/edit.c @@ -258,7 +258,7 @@ ask(char *prompt) standout(); prints("%s", prompt); standend(); - ch = igetkey(); + ch = igetch(); move(0, 0); clrtoeol(); return (ch); @@ -966,7 +966,6 @@ write_file(char *fpath, int saveheader, int *islocal) switch (ans[0]) { case 'a': outs("¤å³¹\033[1m ¨S¦³ \033[m¦s¤J"); - safe_sleep(1); aborted = -1; break; case 'r': @@ -1051,7 +1050,7 @@ write_file(char *fpath, int saveheader, int *islocal) } currline = NULL; - if (postrecord.times > MAX_CROSSNUM - 1) + if (postrecord.times > MAX_CROSSNUM-1 && hbflcheck(currbid, currutmp->uid)) anticrosspost(); if (po && sum == 3) { @@ -1682,7 +1681,7 @@ vedit(char *fpath, int saveheader, int *islocal) move(curr_window_line, ch); if (!line_dirty && strcmp(line, currline->data)) strcpy(line, currline->data); - ch = igetkey(); + ch = igetch(); /* jochang debug */ if ((interval = (now - th))) { th = now; @@ -1697,19 +1696,6 @@ vedit(char *fpath, int saveheader, int *islocal) count = 0; tin = interval; } - /* ³sÄò240Óinterval¤@¼Ë , ¤À©ú¬O¦bÀÄ°] - if (count >= 240) { - char buf[200]; - snprintf(buf, sizeof(buf), "\033[1;33;46m%s\033[37m¦b\033[37;45m%s\n" - "\033[37mªO¹HªkÁÈ¿ú , %s\033[m", cuser.userid, - currboard, ctime(&now)); - log_file("etc/illegal_money", buf, 1); - money = 0; - post_violatelaw(cuser.userid, "Ptt ¨t²Îĵ¹î", "¹HªkÁÈ¿ú", "¦©°£¤£ªk©Ò±o"); - mail_violatelaw(cuser.userid, "Ptt ¨t²Îĵ¹î", "¹HªkÁÈ¿ú", "¦©°£¤£ªk©Ò±o"); - demoney(10000); - abort_bbs(0); - } */ if (raw_mode) switch (ch) { case Ctrl('S'): @@ -1836,28 +1822,27 @@ vedit(char *fpath, int saveheader, int *islocal) char *tmp, *apos = ans; int fg, bg; - strlcpy(color, "\033[", sizeof(color)); + strcpy(color, "\033["); if (isdigit(*apos)) { - snprintf(color, sizeof(color), - "%s%c", color, *(apos++)); + sprintf(color,"%s%c", color, *(apos++)); if (*apos) - snprintf(color, sizeof(color), "%s;", color); + strcat(color, ";"); } if (*apos) { if ((tmp = strchr(t, toupper(*(apos++))))) fg = tmp - t + 30; else fg = 37; - snprintf(color, sizeof(color), "%s%d", color, fg); + sprintf(color, "%s%d", color, fg); } if (*apos) { if ((tmp = strchr(t, toupper(*(apos++))))) bg = tmp - t + 40; else bg = 40; - snprintf(color, sizeof(color), "%s;%d", color, bg); + sprintf(color, "%s;%d", color, bg); } - snprintf(color, sizeof(color), "%sm", color); + strcat(color, "m"); insert_string(color); } else insert_string(reset_color); @@ -2023,7 +2008,7 @@ vedit(char *fpath, int saveheader, int *islocal) case '\n': #ifdef MAX_EDIT_LINE if( totaln == MAX_EDIT_LINE ){ - vmsg("MAX_EDIT_LINE exceed"); + outs("MAX_EDIT_LINE exceed"); break; } #endif diff --git a/mbbsd/fav.c b/mbbsd/fav.c index 4c915868..932fffd9 100644 --- a/mbbsd/fav.c +++ b/mbbsd/fav.c @@ -456,10 +456,8 @@ int fav_save(void) write_favrec(fd, fp); close(fd); if (dashs(buf) == 4) { - char buf3[128]; time_t now = time(NULL); - sprintf(buf3, "%s %s", cuser.userid, ctime(&now)); - log_file(BBSHOME"/dirty.hack", buf3, 1); + log_file(BBSHOME"/dirty.hack", 1, "%s %s", cuser.userid, ctime(&now)); return -1; } Rename(buf, buf2); diff --git a/mbbsd/gamble.c b/mbbsd/gamble.c index 33e67bb8..512df7f2 100644 --- a/mbbsd/gamble.c +++ b/mbbsd/gamble.c @@ -159,9 +159,7 @@ ticket(int bid) ch_buyitem(price, "etc/buyticket", &n, 0); if (bid && !dashf(fn_ticket)) { - move(b_lines - 1, 0); - prints("«z!! @£«®º...ªO¥D¤w¸g°±¤î¤Uª`¤F ¤£¯à½äÂP"); - pressanykey(); + vmsg("«z!! @£«®º...ªO¥D¤w¸g°±¤î¤Uª`¤F ¤£¯à½äÂP"); break; } diff --git a/mbbsd/gomo.c b/mbbsd/gomo.c index 55060b67..82e9af8f 100644 --- a/mbbsd/gomo.c +++ b/mbbsd/gomo.c @@ -371,7 +371,7 @@ gomoku(int fd) } else clrtoeol(); BGOTOCUR(mv.x, mv.y); - ch = igetkey(); + ch = igetch(); if (ch != I_OTHERDATA) iwantpass = 0; if (ch == 'q') { @@ -174,6 +174,7 @@ dogetch() if (len == 0 || errno != EINTR) abort_bbs(0); /* raise(SIGHUP); */ + } #ifdef SKIP_TELNET_CONTROL_SIGNAL } while( inbuf[0] == -1 ); @@ -198,9 +199,32 @@ static int water_which_flag = 0; int igetch() { - register int ch; - while ((ch = dogetch())) { + register int ch, mode = 0, last = 0; + while ((ch = dogetch())) { + if (mode == 0 && ch == KEY_ESC) // here is state machine for 2 bytes key + mode = 1; + else if (mode == 1) { /* Escape sequence */ + if (ch == '[' || ch == 'O') + mode = 2; + else if (ch == '1' || ch == '4') + { mode = 3; last = ch; } + else + { + KEY_ESC_arg = ch; + return KEY_ESC; + } + } else if (mode == 2 && ch >= 'A' && ch <= 'D') /* Cursor key */ + return KEY_UP + (ch - 'A'); + else if (mode == 2 && ch >= '1' && ch <= '6') + { mode = 3; last = ch; } + else if (mode == 3 && ch == '~') { /* Ins Del Home End PgUp PgDn */ + return KEY_HOME + (last - '1'); + } + else // here is switch for default keys switch (ch) { + case IAC: + case '\n': /* filters */ + continue; #ifdef DEBUG case Ctrl('Q'):{ struct rusage ru; @@ -234,8 +258,8 @@ igetch() free(screen0); redoscr(); continue; - } else - return (ch); + } + return ch; case KEY_TAB: if (WATERMODE(WATER_ORIG) || WATERMODE(WATER_NEW)) if (currutmp != NULL && watermode > 0) { @@ -244,8 +268,7 @@ igetch() t_display_new(); continue; } - return ch; - break; + return ch; case Ctrl('R'): if (currutmp == NULL) @@ -304,9 +327,7 @@ igetch() continue; } } - return ch; - case '\n': /* Ptt§â \n®³±¼ */ - continue; + return ch; case Ctrl('T'): if (WATERMODE(WATER_ORIG) || WATERMODE(WATER_NEW)) { if (watermode > 0) { @@ -318,7 +339,7 @@ igetch() continue; } } - return (ch); + return ch; case Ctrl('F'): if (WATERMODE(WATER_NEW)) { @@ -337,7 +358,7 @@ igetch() continue; } } - return ch; + return ch; case Ctrl('G'): if (WATERMODE(WATER_NEW)) { @@ -352,14 +373,10 @@ igetch() continue; } } - return ch; - case IAC: - // disallow user input telnet protocol leading char IAC chr(255) - // TODO parse telnet protocol - continue; + return ch; default: - return ch; + return ch; } } return 0; @@ -485,7 +502,7 @@ oldgetdata(int line, int col, char *prompt, char *buf, int len, int echo) edit_outs(buf); clen = currchar = strlen(buf); - while (move(y, x + currchar), (ch = igetkey()) != '\r') { + while (move(y, x + currchar), (ch = igetch()) != '\r') { switch (ch) { case KEY_DOWN: case Ctrl('N'): case KEY_UP: case Ctrl('P'): @@ -587,14 +604,6 @@ getdata_buf(int line, int col, char *prompt, char *buf, int len, int echo) return oldgetdata(line, col, prompt, buf, len, echo); } -char -getans(char *prompt) -{ - char ans[5]; - - getdata(b_lines, 0, prompt, ans, sizeof(ans), LCECHO); - return ans[0]; -} int getdata_str(int line, int col, char *prompt, char *buf, int len, int echo, char *defaultstr) @@ -611,61 +620,4 @@ getdata(int line, int col, char *prompt, char *buf, int len, int echo) return oldgetdata(line, col, prompt, buf, len, echo); } -int -rget(int x, char *prompt) -{ - register int ch; - - move(x, 0); - clrtobot(); - outs(prompt); - refresh(); - ch = igetch(); - if (ch >= 'A' && ch <= 'Z') - ch = tolower(ch); - - return ch; -} - - -int -igetkey() -{ - int mode; - int ch, last; - - mode = last = 0; - while (1) { - if( !(ch = igetch()) ) - continue; - if (mode == 0) { - if (ch == KEY_ESC) - mode = 1; - else - return ch; /* Normal Key */ - } else if (mode == 1) { /* Escape sequence */ - if (ch == '[' || ch == 'O') - mode = 2; - else if (ch == '1' || ch == '4') - mode = 3; - else { - KEY_ESC_arg = ch; - return KEY_ESC; - } - } else if (mode == 2) { /* Cursor key */ - if (ch >= 'A' && ch <= 'D') - return KEY_UP + (ch - 'A'); - else if (ch >= '1' && ch <= '6') - mode = 3; - else - return ch; - } else if (mode == 3) { /* Ins Del Home End PgUp PgDn */ - if (ch == '~') - return KEY_HOME + (last - '1'); - else - return ch; - } - last = ch; - } -} diff --git a/mbbsd/mail.c b/mbbsd/mail.c index ef017d31..830a04fd 100644 --- a/mbbsd/mail.c +++ b/mbbsd/mail.c @@ -24,20 +24,14 @@ setforward() getdata(b_lines, 0, "½T©w¶}±Ò¦Û°ÊÂà«H¥\\¯à?(Y/n)", yn, sizeof(yn), LCECHO); if (yn[0] != 'n' && (fp = fopen(buf, "w"))) { - move(b_lines, 0); - clrtoeol(); fprintf(fp, "%s", ip); fclose(fp); - outs("³]©w§¹¦¨!"); - refresh(); + vmsg("³]©w§¹¦¨!"); return 0; } } - move(b_lines, 0); - clrtoeol(); - outs("¨ú®ø¦Û°ÊÂà«H!"); unlink(buf); - refresh(); + vmsg("¨ú®ø¦Û°ÊÂà«H!"); return 0; } @@ -163,27 +157,13 @@ chkmailbox() mailmaxkeep = max_keepmail + cuser.exmailbox; m_init(); if ((mailkeep = get_num_records(currmaildir, sizeof(fileheader_t))) > - mailmaxkeep) { - move(b_lines, 0); - clrtoeol(); + mailmaxkeep || + (mailsum = get_sum_records(currmaildir, sizeof(fileheader_t))) > + mailsumlimit) { bell(); - prints("±z«O¦s«H¥ó¼Æ¥Ø %d ¶W¥X¤W %d, ½Ð¾ã²z", - mailkeep, mailmaxkeep); bell(); - refresh(); - igetch(); - return mailkeep; - } - if ((mailsum = get_sum_records(currmaildir, sizeof(fileheader_t))) > - mailsumlimit) { - move(b_lines, 0); - clrtoeol(); - bell(); - prints("±z«O¦s«H¥ó®e¶q %d(k)¶W¥X¤W %d(k), ½Ð¾ã²z", - mailsum, mailsumlimit); - bell(); - refresh(); - igetch(); + vmsg("±z«O¦s«H¥ó¼Æ¥Ø©Î®e¶q %d ¶W¥X¤W %d, ½Ð¾ã²z", + mailkeep, mailmaxkeep); return mailkeep; } } @@ -498,13 +478,9 @@ multi_send(char *title) if (vedit(fpath, YEA, NULL) == -1) { unlink(fpath); curredit = 0; - outs(msg_cancel); - pressanykey(); + vmsg(msg_cancel); return; } - stand_title("±H«H¤¤..."); - refresh(); - listing = 80; for (p = toplev; p; p = p->next) { @@ -530,15 +506,14 @@ multi_send(char *title) mymail.filemode |= FILE_MULTI; /* multi-send flag */ sethomedir(genbuf, p->word); if (append_record_forward(genbuf, &mymail, sizeof(mymail)) == -1) - outs(err_uid); + vmsg(err_uid); mailalert(p->word); } hold_mail(fpath, NULL); unlink(fpath); curredit = 0; } else - outs(msg_cancel); - pressanykey(); + vmsg(msg_cancel); } static int @@ -636,8 +611,7 @@ mail_all() outs(err_uid); snprintf(genbuf, sizeof(genbuf), "%*s %5d / %5d", IDLEN + 1, userid, i + 1, unum); - outmsg(genbuf); - refresh(); + vmsg(genbuf); } } return 0; @@ -726,32 +700,21 @@ read_new_mail(fileheader_t * fptr) while (!done) { int more_result = more(fname, YEA); - switch (more_result) { - case 1: - return READ_PREV; - case 2: - return RELATE_PREV; - case 3: - return READ_NEXT; - case 4: - return RELATE_NEXT; - case 5: - return RELATE_FIRST; - case 6: - return 0; - case 7: + switch (more_result) { + case 999: mail_reply(idc, fptr, currmaildir); - return FULLUPDATE; - case 8: - multi_reply(idc, fptr, currmaildir); - return FULLUPDATE; - } - move(b_lines, 0); - clrtoeol(); - outs(msg_mailer); - refresh(); - - switch (egetch()) { + return FULLUPDATE; + case -1: + return READ_SKIP; + case 0: + break; + default: + return more_result; + } + + outmsg(msg_mailer); + + switch (igetch()) { case 'r': case 'R': mail_reply(idc, fptr, currmaildir); @@ -860,22 +823,19 @@ mail_del(int ent, fileheader_t * fhdr, char *direct) if (fhdr->filemode & FILE_MARKED) return DONOTHING; - getdata(1, 0, msg_del_ny, genbuf, 3, LCECHO); - if (genbuf[0] == 'y') { - strlcpy(currfile, fhdr->filename, sizeof(currfile)); + if (currmode & MODE_SELECT) { + vmsg("½Ð¥ý¦^¨ì¥¿±`¼Ò¦¡«á¦A¶i¦æ§R°£..."); + return READ_REDRAW; + } + + if (getans(msg_del_ny) == 'y') { if (!delete_record(direct, sizeof(*fhdr), ent)) { setdirpath(genbuf, direct, fhdr->filename); unlink(genbuf); - if ((currmode & MODE_SELECT)) { - int index; - sethomedir(genbuf, cuser.userid); - index = getindex(genbuf, fhdr->filename, sizeof(fileheader_t)); - delete_record(genbuf, sizeof(fileheader_t), index); - } return DIRCHANGED; } } - return TITLE_REDRAW; + return READ_REDRAW; } static int @@ -893,42 +853,22 @@ mail_read(int ent, fileheader_t * fhdr, char *direct) if (more_result != -1) { fhdr->filemode |= FILE_READ; - if ((currmode & MODE_SELECT)) { - int index; - - index = getindex(currmaildir, fhdr->filename, - sizeof(fileheader_t)); - substitute_record(currmaildir, fhdr, sizeof(*fhdr), index); - substitute_record(direct, fhdr, sizeof(*fhdr), ent); - } else - substitute_record(currmaildir, fhdr, sizeof(*fhdr), ent); + substitute_ref_record(direct, fhdr, ent); } switch (more_result) { - case 1: - return READ_PREV; - case 2: - return RELATE_PREV; - case 3: - return READ_NEXT; - case 4: - return RELATE_NEXT; - case 5: - return RELATE_FIRST; - case 6: - return FULLUPDATE; - case 7: + case 999: mail_reply(ent, fhdr, direct); return FULLUPDATE; - case 8: - multi_reply(ent, fhdr, direct); - return FULLUPDATE; + case -1: + return READ_SKIP; + case 0: + break; + default: + return more_result; } - move(b_lines, 0); - clrtoeol(); - refresh(); - outs(msg_mailer); + outmsg(msg_mailer); - switch (egetch()) { + switch (igetch()) { case 'r': case 'R': replied = YEA; @@ -950,14 +890,7 @@ mail_read(int ent, fileheader_t * fhdr, char *direct) mail_del(ent, fhdr, direct); else { fhdr->filemode |= FILE_READ; - if ((currmode & MODE_SELECT)) { - int index; - - index = getindex(currmaildir, fhdr->filename, sizeof(fileheader_t)); - substitute_record(currmaildir, fhdr, sizeof(*fhdr), index); - substitute_record(direct, fhdr, sizeof(*fhdr), ent); - } else - substitute_record(currmaildir, fhdr, sizeof(*fhdr), ent); + substitute_ref_record(direct, fhdr, ent); } return FULLUPDATE; } @@ -1049,14 +982,7 @@ mail_mark(int ent, fileheader_t * fhdr, char *direct) { fhdr->filemode ^= FILE_MARKED; - if ((currmode & MODE_SELECT)) { - int index; - - index = getindex(currmaildir, fhdr->filename, sizeof(fileheader_t)); - substitute_record(currmaildir, fhdr, sizeof(*fhdr), index); - substitute_record(direct, fhdr, sizeof(*fhdr), ent); - } else - substitute_record(currmaildir, fhdr, sizeof(*fhdr), ent); + substitute_ref_record(direct, fhdr, ent); return PART_REDRAW; } @@ -1606,8 +1532,7 @@ doforward(char *direct, fileheader_t * fh, int mode) strlcpy(address, cuser.email, sizeof(address)); if( mode == 'U' ){ - move(b_lines, 0); - prints("±N¶i¦æ uuencode ¡CY±z¤£²M·¡¤°»ò¬O uuencode ½Ð§ï¥Î FÂà±H¡C"); + vmsg("±N¶i¦æ uuencode ¡CY±z¤£²M·¡¤°»ò¬O uuencode ½Ð§ï¥Î FÂà±H¡C"); } if (address[0]) { @@ -1632,7 +1557,7 @@ doforward(char *direct, fileheader_t * fh, int mode) snprintf(address, sizeof(address), "%s.bbs@%s", fname, MYHOSTNAME); } else { - outmsg("¨ú®øÂà±H"); + vmsg("¨ú®øÂà±H"); return 1; } } while (mode == 'Z' && strstr(address, MYHOSTNAME)); @@ -1640,19 +1565,12 @@ doforward(char *direct, fileheader_t * fh, int mode) if (invalidaddr(address)) return -2; - snprintf(fname, sizeof(fname), "¥¿Âà±Hµ¹ %s, ½ÐµyÔ...", address); - outmsg(fname); - move(b_lines, 0); + outmsg("¥¿Âà±H½ÐµyÔ..."); refresh(); /* °lÂÜ¨Ï¥ÎªÌ */ - if (HAS_PERM(PERM_LOGUSER)) { - char msg[200]; - - snprintf(msg, sizeof(msg), "%s mailforward to %s at %s", - cuser.userid, address, Cdate(&now)); - log_user(msg); - } + if (HAS_PERM(PERM_LOGUSER)) + log_user("mailforward to %s ",address); if (mode == 'Z') { snprintf(fname, sizeof(fname), TAR_PATH " cfz /tmp/home.%s.tgz home/%c/%s; " diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index 927a7333..804b2af3 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -98,36 +98,22 @@ reapchild(int sig) } void -log_user(char *msg) -{ - char filename[200], buf[200]; - - snprintf(filename, sizeof(filename), BBSHOME "/home/%c/%s/USERLOG", - cuser.userid[0], cuser.userid); - snprintf(buf, sizeof(buf), "%s\n", msg); - log_file(filename, msg, 1); -} - - -void log_usies(char *mode, char *mesg) { - char genbuf[200]; if (!mesg) - snprintf(genbuf, sizeof(genbuf), + log_file(FN_USIES, 1, "%s %s %-12s Stay:%d (%s)\n", Cdate(&now), mode, cuser.userid , (int)(now - login_start_time) / 60, cuser.username); else - snprintf(genbuf, sizeof(genbuf), + log_file(FN_USIES, 1, "%s %s %-12s %s\n", Cdate(&now), mode, cuser.userid, mesg); - log_file(FN_USIES, genbuf, 1); /* °lÂÜ¨Ï¥ÎªÌ */ if (HAS_PERM(PERM_LOGUSER)) - log_user(genbuf); + log_user("logout"); } @@ -168,7 +154,7 @@ u_exit(char *mode) cuser.pager = currutmp->pager; memcpy(cuser.mind, currutmp->mind, 4); setutmpbid(0); - if (!(HAS_PERM(PERM_SYSOP) && HAS_PERM(PERM_DENYPOST)) && + if (!(HAS_PERM(PERM_SYSOP) && HAS_PERM(PERM_SYSOPHIDE)) && !currutmp->invisible) do_aloha("<<¤U¯¸³qª¾>> -- §Ú¨«Åo¡I"); @@ -183,18 +169,6 @@ u_exit(char *mode) } void -system_abort() -{ - if (currmode) - u_exit("ABORT"); - - clear(); - refresh(); - fprintf(stdout, "ÁÂÁÂ¥úÁ{, °O±o±`¨Ó³á !\n"); - exit(0); -} - -void abort_bbs(int sig) { if (currmode) @@ -424,7 +398,7 @@ write_request(int sig) memmove(&currutmp->msgs[0], &currutmp->msgs[1], sizeof(msgque_t) * currutmp->msgcount); - igetkey(); + igetch(); } } @@ -473,14 +447,12 @@ multi_user_check() log_usies("KICK ", cuser.username); } else { if (search_ulistn(usernum, 3) != NULL) - system_abort(); /* Goodbye(); */ + abort_bbs(0); /* Goodbye(); */ } } else { /* allow multiple guest user */ if (search_ulistn(usernum, 100) != NULL) { - outs("\n©êºp¡A¥Ø«e¤w¦³¤Ó¦h guest ¦b¯¸¤W, ½Ð¥Înewµù¥U¡C\n"); - pressanykey(); - oflush(); + vmsg("\n©êºp¡A¥Ø«e¤w¦³¤Ó¦h guest ¦b¯¸¤W, ½Ð¥Înewµù¥U¡C\n"); exit(1); } } @@ -604,7 +576,7 @@ login_query() 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_SYSOPHIDE | PERM_BM | PERM_ACCOUNTS | PERM_CHATROOM | PERM_BOARD | PERM_SYSOP | PERM_BBSADM; mkuserdir(cuser.userid); #endif @@ -873,7 +845,7 @@ static void init_guest_info(void) currutmp->pager = 2; } -#ifdef FOREIGN_REG +#ifdef FOREIGN_REG_DAY 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){ @@ -949,7 +921,7 @@ user_login() SHM->max_time = now; } - if (!(HAS_PERM(PERM_SYSOP) && HAS_PERM(PERM_DENYPOST)) && + if (!(HAS_PERM(PERM_SYSOP) && HAS_PERM(PERM_SYSOPHIDE)) && !currutmp->invisible) do_aloha("<<¤W¯¸³qª¾>> -- §Ú¨Ó°Õ¡I"); @@ -981,7 +953,7 @@ user_login() if (!PERM_HIDE(currutmp)) cuser.lastlogin = login_start_time; -#ifdef FOREIGN_REG +#ifdef FOREIGN_REG_DAY foreign_warning(); #endif passwd_update(usernum, &cuser); diff --git a/mbbsd/menu.c b/mbbsd/menu.c index 5f8276b8..3c4dcbae 100644 --- a/mbbsd/menu.c +++ b/mbbsd/menu.c @@ -5,25 +5,6 @@ static int refscreen = NA; extern char *boardprefix; extern struct utmpfile_t *utmpshm; - -int -egetch() -{ - int rval; - - while (1) { - rval = igetkey(); - if (talkrequest) { - talkreply(); - refscreen = YEA; - return rval; - } - if (rval != Ctrl('L')) - return rval; - redoscr(); - } -} - extern char *fn_board; extern char board_hidden_status; @@ -311,7 +292,7 @@ domenu(int cmdmode, char *cmdtitle, int cmd, commands_t cmdtable[]) pos++; cursor_show(menu_row + pos, menu_column); - } while (((cmd = egetch()) != EOF) || refscreen); + } while (((cmd = igetch()) != EOF) || refscreen); abort_bbs(0); } diff --git a/mbbsd/more.c b/mbbsd/more.c index 69a56bef..a2b3a66f 100644 --- a/mbbsd/more.c +++ b/mbbsd/more.c @@ -23,11 +23,9 @@ static char *more_help[] = { "(TAB) URL³sµ²", "(Ctrl-T) ¦s¨ì¼È¦sÀÉ", "(:/f/b) ¸õ¦Ü¬Y¶/¤U/¤W½g", - "(F/B) ¸õ¦Ü¦P¤@·j´M¥DÃD¤U/¤W½g", "(a/A) ¸õ¦Ü¦P¤@§@ªÌ¤U/¤W½g", "([/]) ¥DÃD¦¡¾\\Ū ¤W/¤U", "(t) ¥DÃD¦¡´`§Ç¾\\Ū", - "(Ctrl-C) ¤ppºâ¾÷", "(q)(¡ö) µ²§ô", "(h)(H)(?) »²§U»¡©úµe±", NULL @@ -330,7 +328,7 @@ more(char *fpath, int promptend) while (line == b_lines || (line > 0 && viewed == fsize)) { - switch ((ch = egetch())) { + switch ((ch = igetch())) { case ':': { char buf[10]; @@ -383,47 +381,42 @@ more(char *fpath, int promptend) lino = line = 0; } break; - case 'r': + case 'r': // Ptt: put all reply/recommend function here case 'R': case 'Y': - close(fd); - return 7; case 'y': close(fd); - return 8; + return 999; + case 'X': + close(fd); + return 998; case 'A': close(fd); - return 9; + return AUTHOR_PREV; case 'a': close(fd); - return 10; + return AUTHOR_NEXT; case 'F': + case 'f': close(fd); - return 11; + return READ_NEXT; case 'B': + case 'b': close(fd); - return 12; + return READ_PREV; case KEY_LEFT: - close(fd); - return 6; case 'q': close(fd); - return 0; - case 'b': - close(fd); - return 1; - case 'f': - close(fd); - return 3; + return FULLUPDATE; case ']': /* Kaede ¬°¤F¥DÃD¾\Ū¤è«K */ close(fd); - return 4; + return RELATE_NEXT; case '[': /* Kaede ¬°¤F¥DÃD¾\Ū¤è«K */ close(fd); - return 2; + return RELATE_PREV; case '=': /* Kaede ¬°¤F¥DÃD¾\Ū¤è«K */ close(fd); - return 5; + return RELATE_FIRST; case Ctrl('F'): case KEY_PGDN: line = 1; @@ -431,14 +424,14 @@ more(char *fpath, int promptend) case 't': if (viewed == fsize) { close(fd); - return 4; + return RELATE_NEXT; } line = 1; break; case ' ': if (viewed == fsize) { close(fd); - return 3; + return READ_NEXT; } line = 1; break; @@ -455,7 +448,7 @@ more(char *fpath, int promptend) if (viewed == fsize || (promptend == 2 && (ch == '\r' || ch == '\n'))) { close(fd); - return 3; + return READ_NEXT; } line = t_lines - 2; break; @@ -490,12 +483,8 @@ more(char *fpath, int promptend) getdata(b_lines - 2, 0, "§â³o½g¤å³¹¦¬¤J¨ì¼È¦sÀÉ¡H[y/N] ", buf, 4, LCECHO); if (buf[0] == 'y') { - char tmpbuf[128]; - - setuserfile(tmpbuf, ask_tmpbuf(b_lines - 1)); - snprintf(buf, sizeof(buf), - "cp -f %s %s", fpath, tmpbuf); - system(buf); + setuserfile(buf, ask_tmpbuf(b_lines - 1)); + Copy(fpath, buf); } if (pageno) pageno--; @@ -526,7 +515,7 @@ more(char *fpath, int promptend) pageno = line = 0; else { close(fd); - return 1; + return READ_PREV; } } } @@ -539,7 +528,7 @@ more(char *fpath, int promptend) if (pageno <= 1) { if (lino == 1 || !pageno) { close(fd); - return 1; + return READ_PREV; } if (header && lino <= 5) { more_goto(fd, viewed = pagebreak[scrollup = lino = diff --git a/mbbsd/name.c b/mbbsd/name.c index 9d467352..3cb2b698 100644 --- a/mbbsd/name.c +++ b/mbbsd/name.c @@ -264,7 +264,6 @@ namecomplete(char *prompt, char *data) prints("%*s", IDLEN + 1, ""); standend(); move(y, x); - refresh(); while ((ch = igetch()) != EOF) { if (ch == '\n' || ch == '\r') { @@ -309,8 +308,7 @@ namecomplete(char *prompt, char *data) len = MaxLen(morelist, p_lines); } if (morelist) { - move(b_lines, 0); - outs(msg_more); + vmsg(msg_more); } move(y, x); continue; @@ -356,7 +354,6 @@ namecomplete(char *prompt, char *data) raise(SIGHUP); /* jochang: don't know if this is * necessary... */ outc('\n'); - refresh(); if (clearbot) { move(2, 0); clrtobot(); @@ -434,8 +431,7 @@ usercomplete(char *prompt, char *data) len = UserMaxLen((arrptr) cwlist, cwnum, morenum, p_lines); } if (morenum < cwnum) { - move(b_lines, 0); - outs(msg_more); + vmsg(msg_more); } else morenum = 0; move(y, x); @@ -478,7 +474,6 @@ usercomplete(char *prompt, char *data) /* longjmp(byebye, -1); */ raise(SIGHUP); /* jochang: don't know if this is necessary */ outc('\n'); - refresh(); if (clearbot) { move(2, 0); clrtobot(); @@ -561,7 +556,6 @@ generalnamecomplete(char *prompt, char *data, int len, size_t nmemb, prints("%*s", IDLEN + 1, ""); standend(); move(y, x); - refresh(); ptr = 0; data[ptr] = 0; @@ -611,8 +605,7 @@ generalnamecomplete(char *prompt, char *data, int len, size_t nmemb, col += len + 2; } if (morelist != end + 1) { - move(b_lines, 0); - outs(msg_more); + vmsg(msg_more); } move(y, x); continue; @@ -651,7 +644,6 @@ generalnamecomplete(char *prompt, char *data, int len, size_t nmemb, } outc('\n'); - refresh(); if (clearbot) { move(2, 0); clrtobot(); diff --git a/mbbsd/othello.c b/mbbsd/othello.c index 96fea2e2..eba90375 100644 --- a/mbbsd/othello.c +++ b/mbbsd/othello.c @@ -124,7 +124,7 @@ get_key(char nowx, char nowy) int ch; move(STARTX - 1 + nowx * 2, STARTY - 1 + nowy * 4); - ch = igetkey(); + ch = igetch(); move(STARTX - 1 + nowx * 2, STARTY - 2 + nowy * 4); if (nowboard[(int)nowx][(int)nowy] != HINT || if_hint == 1) outs(CHESS_TYPE[(int)nowboard[(int)nowx][(int)nowy]]); @@ -274,7 +274,7 @@ end_of_game(int quit) if (fp) fclose(fp); move(1, 1); - igetkey(); + igetch(); } static void diff --git a/mbbsd/read.c b/mbbsd/read.c index 2456fdda..c2c33111 100644 --- a/mbbsd/read.c +++ b/mbbsd/read.c @@ -3,7 +3,6 @@ static fileheader_t *headers = NULL; static int last_line; // PTT: last_line ´å¼Ð¥i«üªº³Ì«á¤@Ó -static int hit_thread; #include <sys/mman.h> @@ -95,7 +94,7 @@ AskTag(char *msg) num = TagNum; snprintf(buf, sizeof(buf), "¡» %s A)¤å³¹ T)¼Ð°O Q)uit?", msg); - switch (rget(b_lines - 1, buf)) { + switch (getans(buf)) { case 'q': num = -1; break; @@ -172,7 +171,7 @@ TagPruner(int bid) if (getans("§R°£©Ò¦³¼Ð°O[N]?") != 'y') return READ_REDRAW; #ifdef SAFE_ARTICLE_DELETE - if(bp && bp->nuser>20) + if(bp && !(currmode & MODE_DIGEST) && bp->nuser>20 ) safe_delete_range(currdirect, 0, 0); else #endif @@ -230,211 +229,77 @@ fixkeep(char *s, int first) /* calc cursor pos and show cursor correctly */ static int -cursor_pos(keeploc_t * locmem, int val, int from_top) +cursor_pos(keeploc_t * locmem, int val, int from_top, int isshow) { - int top; - - if (val > last_line) { - bell(); + int top=locmem->top_ln; + if (!last_line){ + cursor_show(3 , 0); + return DONOTHING; + } + if (val > last_line){ + bell(); val = last_line; } - if (val <= 0) { - bell(); + if (val <= 0){ + bell(); val = 1; } - top = locmem->top_ln; if (val >= top && val < top + p_lines) { - cursor_clear(3 + locmem->crs_ln - top, 0); + if(isshow){ + cursor_clear(3 + locmem->crs_ln - top, 0); + cursor_show(3 + val - top, 0); + } locmem->crs_ln = val; - cursor_show(3 + val - top, 0); return DONOTHING; } locmem->top_ln = val - from_top; if (locmem->top_ln <= 0) locmem->top_ln = 1; locmem->crs_ln = val; - return PARTUPDATE; -} - -static int -move_cursor_line(keeploc_t * locmem, int mode) -{ - int top, crs; - int reload = 0; - - top = locmem->top_ln; - crs = locmem->crs_ln; - if (mode == READ_PREV) { - if (crs <= top) { - top -= p_lines - 1; - if (top < 1) - top = 1; - reload = 1; - } - if (--crs < 1) { - crs = 1; - reload = -1; - } - } else if (mode == READ_NEXT) { - if (crs >= top + p_lines - 1) { - top += p_lines - 1; - reload = 1; - } - if (++crs > last_line) { - crs = last_line; - reload = -1; - } - } - locmem->top_ln = top; - locmem->crs_ln = crs; - return reload; + return isshow ? PARTUPDATE : HEADERS_RELOAD; } static int -thread(keeploc_t * locmem, int stype) +thread(keeploc_t * locmem, int stypen) { - static char a_ans[32], t_ans[32]; - char ans[32], s_pmt[64]; - register char *tag, *query = NULL; - register int now, pos, match, near = 0; - fileheader_t fh; - int circulate_flag = 1; /* circulate at end or begin */ - int fd = -1; - - match = hit_thread = 0; - now = pos = locmem->crs_ln; - if (stype == 'A') { - if (!*currowner) - return DONOTHING; - str_lower(a_ans, currowner); - query = a_ans; - circulate_flag = 0; - stype = 0; - } else if (stype == 'a') { - if (!*currowner) - return DONOTHING; - str_lower(a_ans, currowner); - query = a_ans; - circulate_flag = 0; - stype = RS_FORWARD; - } else if (stype == '/') { - if (!*t_ans) - return DONOTHING; - query = t_ans; - circulate_flag = 0; - stype = RS_TITLE | RS_FORWARD; - } else if (stype == '?') { - if (!*t_ans) - return DONOTHING; - circulate_flag = 0; - query = t_ans; - stype = RS_TITLE; - } else if (stype & RS_RELATED) { - tag = headers[pos - locmem->top_ln].title; - if (stype & RS_CURRENT) { - if (stype & RS_FIRST) { - if (!strncmp(currtitle, tag, TTLEN)) - return DONOTHING; - near = 0; - } - query = currtitle; - } else { - query = subject(tag); - if (stype & RS_FIRST) { - if (query == tag) - return DONOTHING; - near = 0; - } - } - } else if (!(stype & RS_THREAD)) { - query = (stype & RS_TITLE) ? t_ans : a_ans; - if (!*query && query == a_ans) { - if (*currowner) - strlcpy(a_ans, currowner, sizeof(a_ans)); - else if (*currauthor) - strlcpy(a_ans, currauthor, sizeof(a_ans)); - } - snprintf(s_pmt, sizeof(s_pmt), - "%s·j´M%s [%s] ", (stype & RS_FORWARD) ? "©¹«á" : "©¹«e", - (stype & RS_TITLE) ? "¼ÐÃD" : "§@ªÌ", query); - getdata(b_lines - 1, 0, s_pmt, ans, sizeof(ans), DOECHO); - if (*ans) - strcpy(query, ans); - else if (*query == '\0') - return DONOTHING; - } - tag = fh.owner; - - do { - if (!circulate_flag || stype & RS_RELATED) { - if (stype & RS_FORWARD) { - if (++now > last_line){ - if( fd != -1 ) - close(fd); - return DONOTHING; - } - } else { - if (--now <= 0 || now < pos - 200) { - if( fd ) - close(fd); - if ((stype & RS_FIRST) && (near)) { - hit_thread = 1; - return cursor_pos(locmem, near, 10); - } - return DONOTHING; - } + fileheader_t fh; + int pos = locmem->crs_ln, jump = 200, new_ln; + int fd = -1, step = stypen & RS_FORWARD ? 1 : -1; + char *key = + (stypen & RS_AUTHOR ? headers[pos - locmem->top_ln].owner : + (subject( stypen & RS_CURRENT ? + currtitle : + headers[pos - locmem->top_ln].title ))); + + for(new_ln = pos + step ; + new_ln > 0 && new_ln <= last_line && --jump>0; + new_ln += step) { + get_record_keep(currdirect, &fh, sizeof(fileheader_t), new_ln, &fd); + if(stypen & RS_TITLE){ + if(stypen & RS_FIRST) { + if(!strcmp(fh.title, key)) break; } - } else { - if (stype & RS_FORWARD) { - if (++now > last_line) - now = 1; - } else if (--now <= 0) - now = last_line; + else + if(!strcmp(subject(fh.title), key)) break; } - - get_record_keep(currdirect, &fh, sizeof(fileheader_t), now, &fd); - - if (fh.owner[0] == '-') - continue; - - if (stype & RS_THREAD) { - if (strncasecmp(fh.title, str_reply, 3)) { - hit_thread = 1; - if( fd ) - close(fd); - return cursor_pos(locmem, now, 10); - } - continue; + else if(stypen & RS_NEWPOST){ + if(strncmp(fh.title,"Re:",3)) break; } - if (stype & RS_TITLE) - tag = subject(fh.title); - - if (((stype & RS_RELATED) && !strncmp(tag, query, 40)) || - (!(stype & RS_RELATED) && ((query == currowner) ? - !strcmp(tag, query) : - strstr_lower(tag, query)))) { - if ((stype & RS_FIRST) && tag != fh.title) { - near = now; - continue; - } - hit_thread = 1; - match = cursor_pos(locmem, now, 10); - if ((!(stype & RS_CURRENT)) && - (stype & RS_RELATED) && - strncmp(currtitle, query, TTLEN)) { - strncpy(currtitle, query, TTLEN); - match = PARTUPDATE; - } - break; + else{ // RS_AUTHOR + if(!strcmp(subject(fh.owner), key)) break; } - } while (now != pos); - + } if( fd != -1 ) close(fd); - return match; + if( jump <=0 || new_ln<=0 || new_ln > last_line ) + new_ln = pos; //didn't find + else{ + strncpy(currtitle, fh.title, TTLEN); + strncpy(currtitle, fh.title, TTLEN); + } + return new_ln; } - #ifdef INTERNET_EMAIL static void mail_forward(fileheader_t * fhdr, char *direct, int mode) @@ -448,19 +313,17 @@ mail_forward(fileheader_t * fhdr, char *direct, int mode) *p = '\0'; switch (i = doforward(buf, fhdr, mode)) { case 0: - outmsg(msg_fwd_ok); + vmsg(msg_fwd_ok); break; case -1: - outmsg(msg_fwd_err1); + vmsg(msg_fwd_err1); break; case -2: - outmsg(msg_fwd_err2); + vmsg(msg_fwd_err2); break; default: break; } - refresh(); - sleep(1); } #endif @@ -468,311 +331,312 @@ static int select_read(keeploc_t * locmem, int sr_mode) { #define READSIZE 64 // 8192 / sizeof(fileheader_t) - char *tag, *query = NULL, *temp; - fileheader_t fhs[READSIZE]; - char fpath[80], genbuf[MAXPATHLEN], buf3[5]; - static char t_ans[TTLEN + 1] = ""; - static char a_ans[TTLEN + 1] = ""; - int fd, fr, size = sizeof(fileheader_t), i, len; - struct stat st; - /* rocker.011018: make a reference number for process article */ - int reference = 0; - - if ((currmode & MODE_SELECT)) - return -1; - if (sr_mode == RS_TITLE) - query = subject(headers[locmem->crs_ln - locmem->top_ln].title); - else if (sr_mode == RS_NEWPOST) { - strlcpy(buf3, "Re: ", sizeof(buf3)); - query = buf3; - } - else if (sr_mode == RS_THREAD) { - - } else { - char buff[80]; - char newdata[35]; - - query = (sr_mode == RS_RELATED) ? t_ans : a_ans; - snprintf(buff, sizeof(buff), "·j´M%s [%s] ", - (sr_mode == RS_RELATED) ? "¼ÐÃD" : "§@ªÌ", query); - getdata(b_lines, 0, buff, newdata, sizeof(newdata), DOECHO); - if (newdata[0]) - strcpy(query, newdata); - if (!(*query)) - return DONOTHING; + fileheader_t fhs[READSIZE]; + char newdirect[MAXPATHLEN]; + char keyword[TTLEN + 1] = ""; + char genbuf[MAXPATHLEN], *p = strstr(currdirect, "SR"); + static int _mode = 0; + int len, fd, fr, i, count=0, reference = 0; + + fileheader_t *fh = &headers[locmem->crs_ln - locmem->top_ln]; + if(sr_mode & RS_AUTHOR) + { + if(!getdata(b_lines, 0, + currmode & MODE_SELECT ? "¼W¥[±ø¥ó §@ªÌ:":"·j´M§@ªÌ:", + keyword, IDLEN+1, LCECHO)) + return READ_REDRAW; + } + else if(sr_mode & RS_KEYWORD) + { + if(!getdata(b_lines, 0, + currmode & MODE_SELECT ? "¼W¥[±ø¥ó ¼ÐÃD:":"·j´M¼ÐÃD:", + keyword, TTLEN, DOECHO)) + return READ_REDRAW; +#ifdef KEYWORD_LOG + log_file("keyword_search_log", 1, "%s:%s\n", currboard, keyword); +#endif + } + else + { + if(p && _mode & sr_mode & (RS_TITLE | RS_NEWPOST | RS_MARK)) + return DONOTHING; + // Ptt: only once for these modes. + if(sr_mode & RS_TITLE) + strcpy(keyword, subject(fh->title)); } - if ((fd = open(currdirect, O_RDONLY, 0)) != -1) { - snprintf(genbuf, sizeof(genbuf), "SR.%s", cuser.userid); - if (currstat == RMAIL) - sethomefile(fpath, cuser.userid, genbuf); - else - setbfile(fpath, currboard, genbuf); - if (((fr = open(fpath, O_WRONLY | O_CREAT | O_TRUNC, 0600)) != -1)) { - switch (sr_mode) { - case RS_TITLE: - while( (len = read(fd, fhs, sizeof(fhs))) > 0 ){ - len /= sizeof(fileheader_t); - for( i = 0 ; i < len ; ++i ){ - ++reference; - tag = subject(fhs[i].title); - if (!strncmp(tag, query, 40)) { - fhs[i].money = reference | FHR_REFERENCE; - write(fr, &fhs[i], size); - } - } - } - break; - case RS_RELATED: - while( (len = read(fd, fhs, sizeof(fhs))) > 0 ){ - len /= sizeof(fileheader_t); - for( i = 0 ; i < len ; ++i ){ - ++reference; - tag = fhs[i].title; - if (strcasestr(tag, query)) { - fhs[i].money = reference | FHR_REFERENCE; - write(fr, &fhs[i], size); - } - } - } - break; - case RS_NEWPOST: - while( (len = read(fd, fhs, sizeof(fhs))) > 0 ){ - len /= sizeof(fileheader_t); - for( i = 0 ; i < len ; ++i ){ - ++reference; - tag = fhs[i].title; - temp = strstr(tag, query); - if (temp == NULL || temp != tag) { - fhs[i].money = reference | FHR_REFERENCE; - write(fr, &fhs[i], size); - } - } - } - break; - case RS_AUTHOR: - while( (len = read(fd, fhs, sizeof(fhs))) > 0 ){ - len /= sizeof(fileheader_t); - for( i = 0 ; i < len ; ++i ){ - ++reference; - tag = fhs[i].owner; - if (strcasestr(tag, query)) { - fhs[i].money = reference | FHR_REFERENCE; - write(fr, &fhs[i], size); - } - } - } - break; - case RS_THREAD: - while( (len = read(fd, fhs, sizeof(fhs))) > 0 ){ - len /= sizeof(fileheader_t); - for( i = 0 ; i < len ; ++i ){ - ++reference; - if (fhs[i].filemode & FILE_MARKED) { - fhs[i].money = reference | FHR_REFERENCE; - write(fr, &fhs[i], size); - } - } - } - break; - } - fstat(fr, &st); - close(fr); - } - close(fd); - if (st.st_size) { - currmode |= MODE_SELECT; - strlcpy(currdirect, fpath, sizeof(currdirect)); - } - } - return READ_REDRAW; + if(p == NULL) + _mode = sr_mode; + else + _mode |= sr_mode; + + snprintf(genbuf, sizeof(genbuf), "%s.%X.%X.%X", + p ? p : "SR", + sr_mode, strlen(keyword), StringHash(keyword)); + if( strlen(genbuf) > MAXPATHLEN - 50 ) + return READ_REDRAW; // avoid overflow + + if (currstat == RMAIL) + sethomefile(newdirect, cuser.userid, genbuf); + else + setbfile(newdirect, currboard, genbuf); + + if( now - dasht(newdirect) < 3600 ) + count = dashs(newdirect); + else { + if( (fd = open(newdirect, O_CREAT | O_RDWR, 0600)) == -1 ) + return READ_REDRAW; + if( (fr = open(currdirect, O_RDONLY, 0)) != -1 ) { + while( (len = read(fr, fhs, sizeof(fhs))) > 0 ){ + len /= sizeof(fileheader_t); + for( i = 0 ; i < len ; ++i ){ + reference++; + if( sr_mode & RS_MARK && + !(fhs[i].filemode & FILE_MARKED) ) + continue; + else if(sr_mode & RS_NEWPOST && + !strncmp(fhs[i].title, "Re:", 3)) + continue; + else if(sr_mode & RS_AUTHOR && + !strcasestr(fhs[i].owner, keyword)) + continue; + else if(sr_mode & RS_KEYWORD && + !strcasestr(fhs[i].title, keyword)) + continue; + else if(sr_mode & RS_TITLE && + strcmp(subject(fhs[i].title), keyword)) + continue; + ++count; + if(p == NULL) + fhs[i].money = reference | FHR_REFERENCE; + write(fd, &fhs[i], sizeof(fileheader_t)); + } + } // end while + close(fr); + } + close(fd); + } + + if(count) { + strlcpy(currdirect, newdirect, sizeof(currdirect)); + currmode |= MODE_SELECT; + return NEWDIRECT; + } + return READ_REDRAW; } static int -i_read_key(onekey_t * rcmdlist, keeploc_t * locmem, int ch, int bid, int bottom_line) +i_read_key(onekey_t * rcmdlist, keeploc_t * locmem, + int bid, int bottom_line) { - int mode = DONOTHING; - int num; - char direct[60]; - switch (ch) { - case 'q': - case 'e': - case KEY_LEFT: - if(currmode & MODE_SELECT){ - char genbuf[256]; - fileheader_t *fhdr = &headers[locmem->crs_ln - locmem->top_ln]; - board_select(); - setbdir(genbuf, currboard); - locmem = getkeep(genbuf, 0, 1); - locmem->crs_ln = getindex(genbuf, fhdr->filename, sizeof(fileheader_t)); - num = locmem->crs_ln - p_lines + 1; - locmem->top_ln = num < 1 ? 1 : num; - - return NEWDIRECT; + int mode = DONOTHING, num, new_top=10; + int ch, new_ln = locmem->crs_ln, lastmode=0; + char direct[60]; + static char default_ch = 0; + + do { + if( (mode = cursor_pos(locmem, new_ln, new_top, default_ch ? 0 : 1)) + != DONOTHING ) + return mode; + + if( !default_ch ) + ch = igetch(); + else{ + if(new_ln != locmem->crs_ln) {// move fault + default_ch=0; + return FULLUPDATE; + } + ch = default_ch; } - return (currmode & MODE_ETC) ? board_etc() : - (currmode & MODE_DIGEST) ? board_digest() : DOQUIT; - case Ctrl('L'): - redoscr(); - break; - case Ctrl('H'): - if (select_read(locmem, RS_NEWPOST)) - return NEWDIRECT; - else - return READ_REDRAW; - case 'a': - case 'A': - if (select_read(locmem, RS_AUTHOR)) - return NEWDIRECT; - else - return READ_REDRAW; - case 'G': - if (select_read(locmem,RS_THREAD)) /* marked articles */ - return NEWDIRECT; - else - return READ_REDRAW; - - case '/': - case '?': - if (select_read(locmem, RS_RELATED)) - return NEWDIRECT; - else - return READ_REDRAW; - case 'S': - if (select_read(locmem, RS_TITLE)) - return NEWDIRECT; - else - return READ_REDRAW; - /* quick search title first */ - case '=': - return thread(locmem, RELATE_FIRST); - case '\\': - return thread(locmem, CURSOR_FIRST); - /* quick search title forword */ - case ']': - return thread(locmem, RELATE_NEXT); - case '+': - return thread(locmem, CURSOR_NEXT); - /* quick search title backword */ - case '[': - return thread(locmem, RELATE_PREV); - case '-': - return thread(locmem, CURSOR_PREV); - case '<': - case ',': - return thread(locmem, THREAD_PREV); - case '.': - case '>': - return thread(locmem, THREAD_NEXT); - case 'p': - case 'k': - case KEY_UP: - return cursor_pos(locmem, locmem->crs_ln - 1, p_lines - 2); - case 'n': - case 'j': - case KEY_DOWN: - return cursor_pos(locmem, locmem->crs_ln + 1, 1); - case ' ': - case KEY_PGDN: - case 'N': - case Ctrl('F'): - if (last_line >= locmem->top_ln + p_lines) { - if (last_line > locmem->top_ln + p_lines) - locmem->top_ln += p_lines; + new_top = 10; // default 10 + switch (ch) { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + if( (num = search_num(ch, last_line)) != -1 ) + new_ln = num + 1; + break; + case 'q': + case 'e': + case KEY_LEFT: + if(currmode & MODE_SELECT){ + char genbuf[256]; + fileheader_t *fhdr = &headers[locmem->crs_ln - locmem->top_ln]; + board_select(); + setbdir(genbuf, currboard); + locmem = getkeep(genbuf, 0, 1); + locmem->crs_ln = fhdr->money & ~FHR_REFERENCE; + num = locmem->crs_ln - p_lines + 1; + locmem->top_ln = num < 1 ? 1 : num; + mode = NEWDIRECT; + } else - locmem->top_ln += p_lines - 1; - locmem->crs_ln = locmem->top_ln; - return PARTUPDATE; - } - cursor_clear(3 + locmem->crs_ln - locmem->top_ln, 0); - locmem->crs_ln = last_line; - cursor_show(3 + locmem->crs_ln - locmem->top_ln, 0); - break; - case KEY_PGUP: - case Ctrl('B'): - case 'P': - if (locmem->top_ln > 1) { - locmem->top_ln -= p_lines; - if (locmem->top_ln <= 0) - locmem->top_ln = 1; - locmem->crs_ln = locmem->top_ln; - return PARTUPDATE; - } - break; - case KEY_END: - case '$': - if (last_line >= locmem->top_ln + p_lines) { - locmem->top_ln = last_line - p_lines + 1; - if (locmem->top_ln <= 0) - locmem->top_ln = 1; - locmem->crs_ln = last_line; - return PARTUPDATE; - } - cursor_clear(3 + locmem->crs_ln - locmem->top_ln, 0); - locmem->crs_ln = last_line; - cursor_show(3 + locmem->crs_ln - locmem->top_ln, 0); - break; - case 'F': - case 'U': - if (HAS_PERM(PERM_FORWARD)) { - mail_forward(&headers[locmem->crs_ln - locmem->top_ln], - currdirect, ch /* == 'U' */ ); - /* by CharlieL */ - return READ_REDRAW; - } - break; - case Ctrl('Q'): - return my_query(headers[locmem->crs_ln - locmem->top_ln].owner); - case Ctrl('S'): - if (HAS_PERM(PERM_ACCOUNTS)) { - int id; - userec_t muser; - - strlcpy(currauthor, - headers[locmem->crs_ln - locmem->top_ln].owner, - sizeof(currauthor)); - stand_title("¨Ï¥ÎªÌ³]©w"); - move(1, 0); - if ((id = getuser(headers[locmem->crs_ln - locmem->top_ln].owner))) { - memcpy(&muser, &xuser, sizeof(muser)); - user_display(&muser, 1); - uinfo_query(&muser, 1, id); + mode = (currmode & MODE_ETC) ? board_etc() : + (currmode & MODE_DIGEST) ? board_digest() : DOQUIT; + break; + case Ctrl('L'): + redoscr(); + break; + + case Ctrl('H'): + mode = select_read(locmem, RS_NEWPOST); + break; + + case 'a': + case 'A': + mode = select_read(locmem, RS_AUTHOR); + break; + + case 'G': + mode = select_read(locmem, RS_MARK); + break; + + case '/': + case '?': + mode = select_read(locmem, RS_KEYWORD); + break; + + case 'S': + mode = select_read(locmem, RS_TITLE); + break; + + case '=': + new_ln = thread(locmem, RELATE_FIRST); + break; + + case '\\': + new_ln = thread(locmem, CURSOR_FIRST); + break; + + case ']': + new_ln = thread(locmem, RELATE_NEXT); + break; + + case '+': + new_ln = thread(locmem, CURSOR_NEXT); + break; + + case '[': + new_ln = thread(locmem, RELATE_PREV); + break; + + case '-': + new_ln = thread(locmem, CURSOR_PREV); + break; + + case '<': + case ',': + new_ln = thread(locmem, NEWPOST_PREV); + break; + + case '.': + case '>': + new_ln = thread(locmem, NEWPOST_NEXT); + break; + + case 'p': + case 'k': + case KEY_UP: + new_ln = locmem->crs_ln - 1; + new_top = p_lines - 2; + break; + + case 'n': + case 'j': + case KEY_DOWN: + new_ln = locmem->crs_ln + 1; + new_top = 1; + break; + + case ' ': + case KEY_PGDN: + case 'N': + case Ctrl('F'): + new_ln = locmem->top_ln + p_lines; + new_top = 0; + break; + + case KEY_PGUP: + case Ctrl('B'): + case 'P': + new_ln = locmem->top_ln - p_lines; + new_top = 0; + break; + + case KEY_END: + case '$': + new_ln = last_line; + new_top = p_lines-1; + break; + + case 'F': + case 'U': + if (HAS_PERM(PERM_FORWARD)) { + mail_forward(&headers[locmem->crs_ln - locmem->top_ln], + currdirect, ch /* == 'U' */ ); + /* by CharlieL */ + mode = READ_REDRAW; } - return FULLUPDATE; - } - break; + break; + + case Ctrl('Q'): + mode = my_query(headers[locmem->crs_ln - locmem->top_ln].owner); + break; - /* rocker.011018: ±Ä¥Î·sªºtag¼Ò¦¡ */ - case 't': - /* ±N쥻¦b Read() ¸Ì±ªº "TagNum = 0" ²¾¦Ü¦¹³B */ - if ((currstat & RMAIL && TagBoard != 0) || + case Ctrl('S'): + if (HAS_PERM(PERM_ACCOUNTS)) { + int id; + userec_t muser; + + strlcpy(currauthor, + headers[locmem->crs_ln - locmem->top_ln].owner, + sizeof(currauthor)); + stand_title("¨Ï¥ÎªÌ³]©w"); + move(1, 0); + if ((id = getuser(headers[locmem->crs_ln - locmem->top_ln].owner))) { + memcpy(&muser, &xuser, sizeof(muser)); + user_display(&muser, 1); + uinfo_query(&muser, 1, id); + } + mode = FULLUPDATE; + } + break; + + /* rocker.011018: ±Ä¥Î·sªºtag¼Ò¦¡ */ + case 't': + /* ±N쥻¦b Read() ¸Ì±ªº "TagNum = 0" ²¾¦Ü¦¹³B */ + if ((currstat & RMAIL && TagBoard != 0) || (!(currstat & RMAIL) && TagBoard != bid)) { - if (currstat & RMAIL) - TagBoard = 0; - else - TagBoard = bid; - TagNum = 0; - } - /* rocker.011112: ¸Ñ¨M¦Aselect mode¼Ð°O¤å³¹ªº°ÝÃD */ - if (Tagger(atoi(headers[locmem->crs_ln - locmem->top_ln].filename + 2), - (currmode & MODE_SELECT) ? - (headers[locmem->crs_ln - locmem->top_ln].money & ~FHR_REFERENCE) : - locmem->crs_ln, TAG_TOGGLE)) - return POS_NEXT; - return DONOTHING; + if (currstat & RMAIL) + TagBoard = 0; + else + TagBoard = bid; + TagNum = 0; + } + /* rocker.011112: ¸Ñ¨M¦Aselect mode¼Ð°O¤å³¹ªº°ÝÃD */ + if (Tagger(atoi(headers[locmem->crs_ln - locmem->top_ln].filename + 2), + (currmode & MODE_SELECT) ? + (headers[locmem->crs_ln - locmem->top_ln].money & ~FHR_REFERENCE) : + locmem->crs_ln, TAG_TOGGLE)) + locmem->crs_ln = locmem->crs_ln + 1; + mode = PART_REDRAW; + break; case Ctrl('C'): if (TagNum) { TagNum = 0; - return FULLUPDATE; + mode = FULLUPDATE; } - return DONOTHING; + break; case Ctrl('T'): - return TagThread(currdirect); + mode = TagThread(currdirect); + break; + case Ctrl('D'): - return TagPruner(bid); + mode = TagPruner(bid); + break; + case '\n': case '\r': case 'l': @@ -780,25 +644,70 @@ i_read_key(onekey_t * rcmdlist, keeploc_t * locmem, int ch, int bid, int bottom_ ch = 'r'; default: if( ch == 'h' && currmode & (MODE_ETC | MODE_DIGEST) ) - return DONOTHING; + break; if (ch > 0 && ch <= onekey_size) { int (*func)() = rcmdlist[ch - 1]; - if (func != NULL) - { - num = locmem->crs_ln - bottom_line; - if (num>0) - { - sprintf(direct,"%s.bottom", currdirect); - mode = (*func)(num, &headers[locmem->crs_ln-locmem->top_ln], - direct); - } - else - mode = (*func)(locmem->crs_ln, - &headers[locmem->crs_ln - locmem->top_ln], currdirect); - } - break; - } - } + if (func != NULL){ + num = locmem->crs_ln - bottom_line; + + if( num > 0 ){ + sprintf(direct,"%s.bottom", currdirect); + mode= (*func)(num, &headers[locmem->crs_ln-locmem->top_ln], + direct); + } + else + mode = (*func)(locmem->crs_ln, + &headers[locmem->crs_ln - locmem->top_ln], + currdirect); + if(mode == READ_SKIP) + mode = lastmode; + + // ¥H¤U³o´XºØ mode n¦A³B²z´å¼Ð + if(mode == READ_PREV || mode == READ_NEXT || + mode == RELATE_PREV || mode == RELATE_FIRST || + mode == AUTHOR_NEXT || mode == AUTHOR_PREV || + mode == RELATE_NEXT){ + lastmode = mode; + + switch(mode){ + case READ_PREV: + new_ln = locmem->crs_ln - 1; + break; + case READ_NEXT: + new_ln = locmem->crs_ln + 1; + break; + case RELATE_PREV: + new_ln = thread(locmem, RELATE_PREV); + break; + case RELATE_NEXT: + new_ln = thread(locmem, RELATE_NEXT); + /* XXX: Ū¨ì³Ì«á¤@½gn¸õ¥X¨Ó */ + if( new_ln == locmem->crs_ln ){ + default_ch = 0; + return FULLUPDATE; + } + break; + case RELATE_FIRST: + new_ln = thread(locmem, RELATE_FIRST); + break; + case AUTHOR_PREV: + new_ln = thread(locmem, AUTHOR_PREV); + break; + case AUTHOR_NEXT: + new_ln = thread(locmem, AUTHOR_NEXT); + break; + } + mode = DONOTHING; default_ch = 'r'; + } + else { + default_ch = 0; + lastmode = 0; + } + } //end if (func != NULL) + } // ch > 0 && ch <= onekey_size + break; + } // end switch + } while (mode == DONOTHING); return mode; } @@ -806,38 +715,39 @@ int get_records_and_bottom(char *direct, fileheader_t* headers, int recbase, int p_lines, int last_line, int bottom_line) { - int n = bottom_line - recbase + 1, rv; - char directbottom[60]; + int n = bottom_line - recbase + 1, rv; + char directbottom[60]; - if(n>=p_lines || (currmode & (MODE_SELECT | MODE_DIGEST))) - return get_records(direct, headers, sizeof(fileheader_t), recbase, - p_lines); + if( !last_line ) + return 0; + if( n >= p_lines || (currmode & (MODE_SELECT | MODE_DIGEST)) ) + return get_records(direct, headers, sizeof(fileheader_t), recbase, + p_lines); sprintf(directbottom, "%s.bottom", direct); - if (n<=0) - return get_records(directbottom, headers, sizeof(fileheader_t), 1-n, - last_line-recbase + 1); + if( n <= 0 ) + return get_records(directbottom, headers, sizeof(fileheader_t), 1-n, + last_line-recbase + 1); - rv = get_records(direct, headers, sizeof(fileheader_t), recbase, n); + rv = get_records(direct, headers, sizeof(fileheader_t), recbase, n); + + if( bottom_line < last_line ) + rv += get_records(directbottom, headers+n, sizeof(fileheader_t), 1, + p_lines - n ); + return rv; +} - if(bottom_line<last_line) - rv += get_records(directbottom, headers+n, sizeof(fileheader_t), 1, - p_lines - n ); - return rv; -} void -i_read(int cmdmode, char *direct, void (*dotitle) (), void (*doentry) (), onekey_t * rcmdlist, int bidcache) +i_read(int cmdmode, char *direct, void (*dotitle) (), + void (*doentry) (), onekey_t * rcmdlist, int bidcache) { keeploc_t *locmem = NULL; - int recbase = 0, mode, ch; + int recbase = 0, mode; int num = 0, entries = 0, n_bottom=0; int i; - int jump = 0; - char genbuf[4]; char currdirect0[64]; int last_line0 = last_line; int bottom_line = 0; - int hit_thread0 = hit_thread; fileheader_t *headers0 = headers; strlcpy(currdirect0, currdirect, sizeof(currdirect0)); @@ -866,36 +776,6 @@ i_read(int cmdmode, char *direct, void (*dotitle) (), void (*doentry) (), onekey bottom_line = last_line = get_num_records(currdirect, FHSZ); if (mode == NEWDIRECT) { - if (last_line == 0) { - if (curredit & EDIT_ITEM) { - outs("¨S¦³ª««~"); - refresh(); - goto return_i_read; - } else if (curredit & EDIT_MAIL) { - outs("¨S¦³¨Ó«H"); - refresh(); - goto return_i_read; - } else if (currmode & MODE_ETC) { - board_etc(); /* Kaede */ - outmsg("©|¥¼¦¬¿ý¨ä¥¦¤å³¹"); - refresh(); - } else if (currmode & MODE_DIGEST) { - board_digest(); /* Kaede */ - outmsg("©|¥¼¦¬¿ý¤åºK"); - refresh(); - } else if (currmode & MODE_SELECT) { - board_select(); /* Leeym */ - outmsg("¨S¦³¦¹¨t¦Cªº¤å³¹"); - refresh(); - } else { - getdata(b_lines - 1, 0, - "¬ÝªO·s¦¨¥ß (P)µoªí¤å³¹ (Q)Â÷¶}¡H[Q] ", - genbuf, 4, LCECHO); - if (genbuf[0] == 'p') - do_post(); - goto return_i_read; - } - } num = last_line - p_lines + 1; locmem = getkeep(currdirect, num < 1 ? 1 : num, last_line); } @@ -906,11 +786,10 @@ i_read(int cmdmode, char *direct, void (*dotitle) (), void (*doentry) (), onekey case PARTUPDATE: if (last_line < locmem->top_ln + p_lines) { - if (bidcache > 0 && !(currmode & (MODE_SELECT | MODE_DIGEST))) - { - bottom_line = getbtotal(currbid); - num = bottom_line+getbottomtotal(currbid); - } + if (bidcache > 0 && !(currmode & (MODE_SELECT | MODE_DIGEST))){ + bottom_line = getbtotal(currbid); + num = bottom_line+getbottomtotal(currbid); + } else num = get_num_records(currdirect, FHSZ); @@ -919,9 +798,7 @@ i_read(int cmdmode, char *direct, void (*dotitle) (), void (*doentry) (), onekey recbase = -1; } } - if (last_line == 0) - goto return_i_read; - else if (recbase != locmem->top_ln) { + if (recbase != locmem->top_ln) { //headers reload recbase = locmem->top_ln; if (recbase > last_line) { recbase = last_line - p_lines + 1; @@ -938,8 +815,11 @@ i_read(int cmdmode, char *direct, void (*dotitle) (), void (*doentry) (), onekey clrtobot(); case PART_REDRAW: move(3, 0); - for (i = 0; i < entries; i++) - (*doentry) (locmem->top_ln + i, &headers[i]); + if( last_line == 0 ) + outs(" ¨S¦³¤å³¹..."); + else + for( i = 0; i < entries ; i++ ) + (*doentry) (locmem->top_ln + i, &headers[i]); case READ_REDRAW: outmsg(curredit & EDIT_ITEM ? "\033[44m ¨p¤H¦¬Âà \033[30;47m Ä~Äò? \033[m" : @@ -947,82 +827,29 @@ i_read(int cmdmode, char *direct, void (*dotitle) (), void (*doentry) (), onekey break; case TITLE_REDRAW: (*dotitle) (); - break; - case READ_PREV: - case READ_NEXT: - case RELATE_PREV: - case RELATE_NEXT: - case RELATE_FIRST: - case POS_NEXT: - case 'A': - case 'a': - case '/': - case '?': - jump = 1; - break; - } - - /* Ū¨úÁä½L¡A¥[¥H³B²z¡A³]©w mode */ - if (!jump) { - assert(3 + locmem->crs_ln - locmem->top_ln>=0); // FIXME dunno why - cursor_show(3 + locmem->crs_ln - locmem->top_ln, 0); - ch = egetch(); - mode = DONOTHING; - } else - ch = ' '; - - if (mode == POS_NEXT) { - mode = cursor_pos(locmem, locmem->crs_ln + 1, 1); - if (mode == DONOTHING) - mode = PART_REDRAW; - jump = 0; - } else if (ch >= '0' && ch <= '9') { - if ((i = search_num(ch, last_line)) != -1) - mode = cursor_pos(locmem, i + 1, 10); - } else { - if (!jump) - mode = i_read_key(rcmdlist, locmem, ch, currbid, - bottom_line); - while (mode == READ_NEXT || mode == READ_PREV || - mode == RELATE_FIRST || mode == RELATE_NEXT || - mode == RELATE_PREV || mode == THREAD_NEXT || - mode == THREAD_PREV || mode == 'A' || mode == 'a' || - mode == '/' || mode == '?') { - int reload; - - if (mode == READ_NEXT || mode == READ_PREV) - reload = move_cursor_line(locmem, mode); - else { - reload = thread(locmem, mode); - if (!hit_thread) { - mode = FULLUPDATE; - break; - } - } - - if (reload == -1) { - mode = FULLUPDATE; - break; - } else if (reload) { - recbase = locmem->top_ln; - - entries=get_records_and_bottom(currdirect, - headers, recbase, p_lines, last_line, bottom_line); - + break; + + case HEADERS_RELOAD: + if (recbase != locmem->top_ln) { + recbase = locmem->top_ln; + if (recbase > last_line) { + recbase = last_line - p_lines + 1; + if (recbase < 1) + recbase = 1; + locmem->top_ln = recbase; } - num = locmem->crs_ln - locmem->top_ln; - if (headers[num].owner[0] != '-') - mode = i_read_key(rcmdlist, locmem, ch, currbid, - bottom_line); + entries = + get_records_and_bottom(currdirect, headers, recbase, + p_lines, last_line, bottom_line); } - } + break; + } //end switch + mode = i_read_key(rcmdlist, locmem, currbid, bottom_line); } while (mode != DOQUIT); #undef FHSZ -return_i_read: free(headers); last_line = last_line0; - hit_thread = hit_thread0; headers = headers0; strlcpy(currdirect, currdirect0, sizeof(currdirect)); return; diff --git a/mbbsd/record.c b/mbbsd/record.c index 605f5417..c8393f6f 100644 --- a/mbbsd/record.c +++ b/mbbsd/record.c @@ -127,6 +127,66 @@ substitute_record(char *fpath, void *rptr, int size, int id) return 0; } +int +substitute_ref_record(char *direct, fileheader_t * fhdr, int ent) +{ + fileheader_t hdr; + char genbuf[256]; + int num = 0; + + /* rocker.011018: ¦ê±µ¼Ò¦¡¥Îreference¼W¶i®Ä²v */ + if ((fhdr->money & FHR_REFERENCE) && + (num = fhdr->money & ~FHR_REFERENCE)){ + setdirpath(genbuf, direct, ".DIR"); + get_record(genbuf, &hdr, sizeof(hdr), num); + if (strcmp(hdr.filename, fhdr->filename)) + { + if((num = getindex(genbuf, fhdr, num))>0) + { + substitute_record(genbuf, fhdr, sizeof(*fhdr), num); + } + } + else if(num>0) + { + fhdr->money = hdr.money; + substitute_record(genbuf, fhdr, sizeof(*fhdr), num); + } + fhdr->money = FHR_REFERENCE | num ; // Ptt: update now! + } + substitute_record(direct, fhdr, sizeof(*fhdr), ent); + return num; +} + +int +getindex(char *direct, fileheader_t *fh_o, int end) +{ // Ptt: ±q«e±§ä«Ü¶O¤O ¤Ó¼É¤O + int fd=-1, begin=1, i, stamp, s; + fileheader_t fh; + + i = get_num_records(direct, sizeof(fileheader_t)); + if(end>i) end = i; + stamp = atoi(fh_o->filename+2); + i=(begin+end)/2; + for(; end>begin+1; i=(begin+end)/2) + { + if(get_record_keep(direct, &fh, sizeof(fileheader_t), i, &fd)==-1) + break; + if(!fh.filename[0]) break; + s = atoi(fh.filename+2); + if (s > stamp) end = i+1; + else if(s == stamp) + { + close(fd); + fh_o->money = fh.money; + return i; + } + else begin = i; + } + if(fd==-1) close(fd); + return 0; +} + + /* rocker.011022: ÁקKlockÀɶ}±Ò®É¤£¥¿±`Â_½u,³y¦¨¥Ã¤[lock */ #ifndef _BBS_UTIL_C_ static int @@ -311,26 +371,6 @@ delete_range(char *fpath, int id1, int id2) return 0; } #endif -int -search_rec(char *dirname, int (*filecheck) ()) -{ - fileheader_t fhdr; - FILE *fp; - int ans = 0; - - if (!(fp = fopen(dirname, "r"))) - return 0; - - while (fread(&fhdr, sizeof(fhdr), 1, fp)) { - ans++; - if ((*filecheck) (&fhdr)) { - fclose(fp); - return ans; - } - } - fclose(fp); - return 0; -} #ifdef SAFE_ARTICLE_DELETE diff --git a/mbbsd/register.c b/mbbsd/register.c index 9e6c60b3..71d653a2 100644 --- a/mbbsd/register.c +++ b/mbbsd/register.c @@ -175,9 +175,7 @@ getnewuserid() i = searchnewuser(1); if ((i <= 0) || (i > MAX_USERS)) { passwd_unlock(); - if (more("etc/user_full", NA) == -1) - fprintf(stdout, "©êºp¡A¨Ï¥ÎªÌ±b¸¹¤w¸gº¡¤F¡AµLªkµù¥U·sªº±b¸¹\n\r"); - safe_sleep(2); + vmsg("©êºp¡A¨Ï¥ÎªÌ±b¸¹¤w¸gº¡¤F¡AµLªkµù¥U·sªº±b¸¹"); exit(1); } snprintf(genbuf, sizeof(genbuf), "uid %d", i); @@ -203,10 +201,7 @@ new_register() if( passbuf[0] == 'y' ) break; if( passbuf[0] == 'n' ){ - clear(); - outs("\n©êºp, ±z¶·n±µ¨ü¨Ï¥ÎªÌ±ø´Ú¤~¯àµù¥U±b¸¹¨É¨ü§Ú̪ºªA°Èò!"); - pressanykey(); - oflush(); + vmsg("\n©êºp, ±z¶·n±µ¨ü¨Ï¥ÎªÌ±ø´Ú¤~¯àµù¥U±b¸¹¨É¨ü§Ú̪ºªA°Èò!"); exit(1); } vmsg("½Ð¿é¤J yªí¥Ü±µ¨ü, nªí¥Ü¤£±µ¨ü"); @@ -217,11 +212,7 @@ new_register() try = 0; while (1) { if (++try >= 6) { - outs("\n±z¹Á¸Õ¿ù»~ªº¿é¤J¤Ó¦h¡A½Ð¤U¦¸¦A¨Ó§a\n"); - refresh(); - - pressanykey(); - oflush(); + vmsg("\n±z¹Á¸Õ¿ù»~ªº¿é¤J¤Ó¦h¡A½Ð¤U¦¸¦A¨Ó§a\n"); exit(1); } getdata(17, 0, msg_uid, newuser.userid, @@ -243,11 +234,7 @@ new_register() try = 0; while (1) { if (++try >= 6) { - outs("\n±z¹Á¸Õ¿ù»~ªº¿é¤J¤Ó¦h¡A½Ð¤U¦¸¦A¨Ó§a\n"); - refresh(); - - pressanykey(); - oflush(); + vmsg("\n±z¹Á¸Õ¿ù»~ªº¿é¤J¤Ó¦h¡A½Ð¤U¦¸¦A¨Ó§a\n"); exit(1); } if ((getdata(19, 0, "½Ð³]©w±K½X¡G", passbuf, diff --git a/mbbsd/screen.c b/mbbsd/screen.c index 43df3757..dcfafe2e 100644 --- a/mbbsd/screen.c +++ b/mbbsd/screen.c @@ -445,7 +445,7 @@ prints(char *fmt,...) } void -mprints(int y, int x, char *str) +mouts(int y, int x, char *str) { move(y, x); clrtoeol(); diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c index eb0d32e6..7d9b4652 100644 --- a/mbbsd/stuff.c +++ b/mbbsd/stuff.c @@ -401,60 +401,70 @@ capture_screen() } } -void -pressanykey() +int +vmsg_lines(const int lines, const char msg[]) { int ch; - outmsg(SHM->i18nstr[cuser.language][1883]); - do { - ch = igetkey(); + move(lines, 0); + clrtoeol(); - if (ch == Ctrl('T')) { + if (msg) + outs((char *)msg); + else + outs("\033[45;1m \033[37m" + "\033[200m\033[1431m\033[506m¡¼ ½Ð«ö \033[33m(Space/Return)\033[37m Ä~Äò ¡¼\033[201m (^T) ¦¬¨ì¼È¦sÀÉ \033[m"); + + do { + if( (ch = igetch()) == Ctrl('T') ) capture_screen(); - break; - } - } while ((ch != ' ') && (ch != KEY_LEFT) && (ch != '\r') && (ch != '\n')); - move(b_lines, 0); + } while( ch == 0 ); + + move(lines, 0); clrtoeol(); - refresh(); + return ch; } -int -vmsg(const char *fmt,...) +char getans(const char *fmt,...) { - va_list ap; - char msg[80] = {0}; - int ch; - + char msg[256]; + char ans[5]; + va_list ap; va_start(ap, fmt); - vsnprintf(msg, sizeof(msg), fmt, ap); + vsnprintf(msg , 128, fmt, ap); va_end(ap); - move(b_lines, 0); - clrtoeol(); - - if (*msg) - prints(SHM->i18nstr[cuser.language][1884], msg); - else - outs(SHM->i18nstr[cuser.language][1885]); - - do { - ch = igetkey(); - - if (ch == Ctrl('T')) { - capture_screen(); - break; - } - } while ((ch != ' ') && (ch != KEY_LEFT) && (ch != '\r') && (ch != '\n')); + getdata(b_lines, 0, msg, ans, sizeof(ans), LCECHO); + return ans[0]; +} +int +getkey(const char *fmt,...) +{ + char msg[256], i; + va_list ap; + va_start(ap, fmt); + i = vsnprintf(msg , 128, fmt, ap); + va_end(ap); + return vmsg_lines(b_lines, msg); +} - move(b_lines, 0); - clrtoeol(); - refresh(); - return ch; +int +vmsg(const char *fmt,...) +{ + char msg[256] = "\033[1;36;44m ¡» ", i; + va_list ap; + va_start(ap, fmt); + i = vsnprintf(msg + 14, 128, fmt, ap); + va_end(ap); + for(i = i + 14; i < 71; i++) + msg[(int)i] = ' '; + strcat(msg + 71, + "\033[33;46m \033[200m\033[1431m\033[506m[«ö¥ô·NÁäÄ~Äò]\033[201m \033[m"); + return vmsg_lines(b_lines, msg); } + void bell() { @@ -544,7 +554,7 @@ cursor_key(int row, int column) int ch; cursor_show(row, column); - ch = egetch(); + ch = igetch(); move(row, column); outs(STR_UNCUR); return ch; @@ -573,13 +583,33 @@ printdash(char *mesg) outch('\n'); } -int log_file(char *fn, char *buf, int ifcreate) +int +log_user(const char *fmt, ...) +{ + char msg[256], filename[256]; + va_list ap; + + va_start(ap, fmt); + vsnprintf(msg , 128, fmt, ap); + va_end(ap); + + sethomefile(filename, cuser.userid, "USERLOG"); + return log_file(filename, 1, "%s: %s %s", cuser.userid, msg, Cdate(&now)); +} + +int log_file(char *fn, int ifcreate, const char *fmt,...) { int fd; + char msg[256]; + va_list ap; + va_start(ap, fmt); + vsnprintf(msg , 128, fmt, ap); + va_end(ap); + if( (fd = open(fn, O_APPEND | O_WRONLY | (ifcreate ? O_CREAT : 0), (ifcreate ? 0664 : 0))) < 0 ) return -1; - if( write(fd, buf, strlen(buf)) < 0 ){ + if( write(fd, msg, strlen(msg)) < 0 ){ close(fd); return -1; } diff --git a/mbbsd/talk.c b/mbbsd/talk.c index d667fb0a..8c0c2ec3 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -58,7 +58,7 @@ iswritable_stat(userinfo_t * uentp, int fri_stat) int isvisible_stat(userinfo_t * me, userinfo_t * uentp, int fri_stat) { - if (uentp->userid[0] == 0) + if (!uentp || uentp->userid[0] == 0) return 0; if (PERM_HIDE(uentp) && !(PERM_HIDE(me))) /* ¹ï¤èµµ¦âÁô§Î¦Ó§A¨S¦³ */ @@ -512,7 +512,7 @@ my_write2(void) which = 0; do { - switch ((ch = igetkey())) { + switch ((ch = igetch())) { case Ctrl('T'): case KEY_UP: if (water_usies != 1) { @@ -592,9 +592,7 @@ my_write(pid_t pid, char *prompt, char *id, int flag, userinfo_t * puin) strlcpy(destid, id, sizeof(destid)); if (!uin && !(flag == 0 && water_which->count > 0)) { - outmsg("\033[1;33;41mÁV¿|! ¹ï¤è¤w¸¨¶]¤F(¤£¦b¯¸¤W)! \033[37m~>_<~\033[m"); - clrtoeol(); - refresh(); + vmsg("ÁV¿|! ¹ï¤è¤w¸¨¶]¤F(¤£¦b¯¸¤W)! "); watermode = -1; return 0; } @@ -608,9 +606,6 @@ my_write(pid_t pid, char *prompt, char *id, int flag, userinfo_t * puin) /* ¤@¯ë¤ô²y */ watermode = 0; if (!(len = getdata(0, 0, prompt, msg, 56, DOECHO))) { - outmsg("\033[1;33;42mºâ¤F! ©ñ§A¤@°¨...\033[m"); - clrtoeol(); - refresh(); currutmp->chatid[0] = c0; currutmp->mode = mode0; currstat = currstat0; @@ -635,9 +630,6 @@ my_write(pid_t pid, char *prompt, char *id, int flag, userinfo_t * puin) snprintf(buf, sizeof(buf), "¥áµ¹ %s : %s [Y/n]?", uin->userid, msg); getdata(0, 0, buf, genbuf, 3, LCECHO); if (genbuf[0] == 'n') { - outmsg("\033[1;33;42mºâ¤F! ©ñ§A¤@°¨...\033[m"); - clrtoeol(); - refresh(); currutmp->chatid[0] = c0; currutmp->mode = mode0; currstat = currstat0; @@ -647,9 +639,7 @@ my_write(pid_t pid, char *prompt, char *id, int flag, userinfo_t * puin) } watermode = -1; if (!uin || !*uin->userid || strcasecmp(destid, uin->userid)) { - outmsg("\033[1;33;41mÁV¿|! ¹ï¤è¤w¸¨¶]¤F(¤£¦b¯¸¤W)! \033[37m~>_<~\033[m"); - clrtoeol(); - refresh(); + vmsg("ÁV¿|! ¹ï¤è¤w¸¨¶]¤F(¤£¦b¯¸¤W)! "); currutmp->chatid[0] = c0; currutmp->mode = mode0; currstat = currstat0; @@ -712,7 +702,6 @@ my_write(pid_t pid, char *prompt, char *id, int flag, userinfo_t * puin) } clrtoeol(); - refresh(); currutmp->chatid[0] = c0; currutmp->mode = mode0; @@ -1055,7 +1044,7 @@ do_talk(int fd) add_io(fd, 0); while (1) { - ch = igetkey(); + ch = igetch(); if (ch == I_OTHERDATA) { datac = recv(fd, data, sizeof(data), 0); if (datac <= 0) @@ -1765,7 +1754,6 @@ draw_pickup(int drawall, pickup_t * pickup, int pickup_way, "%-2d\033[m\n", msg_pickup_way[pickup_way], SHM->UTMPnumber, myfriend, friendme, currutmp->brc_id ? (bfriend + 1) : 0, badfriend); - for (i = 0, ch = page * nPickups + 1; i < nPickups; ++i, ++ch) { move(i + 3, 0); prints("a"); @@ -1854,7 +1842,7 @@ draw_pickup(int drawall, pickup_t * pickup, int pickup_way, #endif ); - refresh(); + //refresh(); } } @@ -1965,7 +1953,7 @@ userlist(void) case 'H': if (HAS_PERM(PERM_SYSOP)) { - currutmp->userlevel ^= PERM_DENYPOST; + currutmp->userlevel ^= PERM_SYSOPHIDE; redrawall = redraw = 1; } break; @@ -2308,7 +2296,7 @@ userlist(void) case 'g': if (HAS_PERM(PERM_LOGINOK) && strcmp(uentp->userid, cuser.userid) != 0) { - char genbuf[128]; + char genbuf[10]; move(b_lines - 2, 0); prints("nµ¹ %s ¦h¤Ö¿ú©O? ", uentp->userid); if (getdata(b_lines - 1, 0, "[»È¦æÂà±b]: ", @@ -2318,8 +2306,8 @@ userlist(void) redrawall = redraw = 1; break; } - sprintf(genbuf, "½T©wnµ¹ %s %d Ptt ¹ô¶Ü? [N/y]", uentp->userid, ch); - if (getans(genbuf) != 'y'){ + if (getans("½T©wnµ¹ %s %d Ptt ¹ô¶Ü? [N/y]", + uentp->userid, ch) != 'y'){ redrawall = redraw = 1; break; } @@ -2329,19 +2317,16 @@ userlist(void) outs("\033[41m ²{ª÷¤£¨¬~~\033[m"); } else { deumoney(uentp->uid, ch - give_tax(ch)); - prints("\033[44m ¶â..ÁٳѤU %d ¿ú.." - "\033[m", demoney(-ch)); - snprintf(genbuf, sizeof(genbuf), - "%s\tµ¹%s\t%d\t%s\n", cuser.userid, - uentp->userid, ch, - ctime(&currutmp->lastact)); - log_file(FN_MONEY, genbuf, 1); + log_file(FN_MONEY, 1, + "%s\tµ¹%s\t%d\t%s\n", cuser.userid, + uentp->userid, ch, ctime(&currutmp->lastact)); mail_redenvelop(cuser.userid, uentp->userid, ch - give_tax(ch), 'Y'); + vmsg(" ¶â..ÁٳѤU %d ¿ú..", demoney(-ch)); } } else { clrtoeol(); - outs("\033[41m ¥æ©ö¨ú®ø! \033[m"); + vmsg(" ¥æ©ö¨ú®ø! "); } redrawall = redraw = 1; } @@ -2398,12 +2383,9 @@ userlist(void) cuser.uflag2 -= tmp; tmp = (tmp + 1) % 3; cuser.uflag2 |= tmp; - move(4, 0); - prints("¨t²Î´£¨Ñ ¤@¯ë ¶i¶¥ ¥¼¨Ó ¤TºØ¼Ò¦¡\n" + vmsg("¨t²Î´£¨Ñ ¤@¯ë ¶i¶¥ ¥¼¨Ó ¤TºØ¼Ò¦¡\n" "¦b¤Á´««á½Ð¥¿±`¤U½u¦A«·sµn¤J, ¥H½T«Oµ²ºc¥¿½T\n" "¥Ø«e¤Á´«¨ì %s ¤ô²y¼Ò¦¡\n", wm[tmp]); - refresh(); - sleep(2); redrawall = redraw = 1; } break; @@ -2617,7 +2599,6 @@ talkreply(void) char genbuf[200]; int a, sig = currutmp->sig; - talkrequest = NA; uip = &SHM->uinfo[currutmp->destuip]; snprintf(page_requestor, sizeof(page_requestor), "%s (%s)", uip->userid, uip->username); diff --git a/mbbsd/user.c b/mbbsd/user.c index 4a544620..bd4ed6b8 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -23,7 +23,6 @@ u_loginview() { int i; unsigned int pbits = cuser.loginview; - char choice[5]; clear(); move(4, 0); @@ -32,9 +31,9 @@ u_loginview() loginview_file[i][1], ((pbits >> i) & 1 ? "£¾" : "¢æ")); clrtobot(); - while (getdata(b_lines - 1, 0, "½Ð«ö [A-N] ¤Á´«³]©w¡A«ö [Return] µ²§ô¡G", - choice, 3, LCECHO)) { - i = choice[0] - 'a'; + while ((i = getkey("½Ð«ö [A-N] ¤Á´«³]©w¡A«ö [Return] µ²§ô¡G"))!='\r') + { + i = i - 'a'; if (i >= NUMVIEWFILE || i < 0) bell(); else { @@ -217,7 +216,7 @@ violate_law(userec_t * u, int unum) static void Customize(void) { - char ans[4], done = 0, mindbuf[5]; + char done = 0, mindbuf[5]; char *wm[3] = {"¤@¯ë", "¶i¶¥", "¥¼¨Ó"}; showtitle("Ó¤H¤Æ³]©w", "Ó¤H¤Æ³]©w"); @@ -236,11 +235,7 @@ static void Customize(void) prints("%-30s%10s\n", "D. ¥Ø«eªº¤ß±¡", mindbuf); prints("%-30s%10s\n", "E. °ª«G«×Åã¥Ü§Úªº³Ì·R", ((cuser.uflag2 & FAVNOHILIGHT) ? "§_" : "¬O")); - getdata(b_lines - 1, 0, "½Ð«ö [A-E] ¤Á´«³]©w¡A«ö [Return] µ²§ô¡G", - ans, 3, DOECHO); - - switch( ans[0] ){ - case 'A': + switch(getkey("½Ð«ö [A-E] ¤Á´«³]©w¡A«ö [Return] µ²§ô¡G")){ case 'a':{ int currentset = cuser.uflag2 & WATER_MASK; currentset = (currentset + 1) % 3; @@ -249,17 +244,14 @@ static void Customize(void) vmsg("×¥¿¤ô²y¼Ò¦¡«á½Ð¥¿±`Â÷½u¦A«·s¤W½u"); } break; - case 'B': case 'b': cuser.userlevel ^= PERM_NOOUTMAIL; break; - case 'C': case 'c': cuser.uflag2 ^= FAVNEW_FLAG; if (cuser.uflag2 & FAVNEW_FLAG) subscribe_newfav(); break; - case 'D': case 'd':{ getdata(b_lines - 1, 0, "²{¦bªº¤ß±¡? ", mindbuf, sizeof(mindbuf), DOECHO); @@ -271,7 +263,6 @@ static void Customize(void) memcpy(currutmp->mind, mindbuf, 4); } break; - case 'E': case 'e': cuser.uflag2 ^= FAVNOHILIGHT; break; @@ -280,7 +271,7 @@ static void Customize(void) } passwd_update(usernum, &cuser); } - pressanykey(); + vmsg("³]©w§¹¦¨"); } void @@ -288,8 +279,8 @@ uinfo_query(userec_t * u, int real, int unum) { userec_t x; register int i = 0, fail, mail_changed; - int uid; - char ans[4], buf[STRLEN], *p; + int uid, ans; + char buf[STRLEN], *p; char genbuf[200], reason[50]; int money = 0; fileheader_t fhdr; @@ -300,23 +291,22 @@ uinfo_query(userec_t * u, int real, int unum) fail = mail_changed = 0; memcpy(&x, u, sizeof(userec_t)); - getdata(b_lines - 1, 0, real ? + ans = getans(real ? "(1)§ï¸ê®Æ(2)³]±K½X(3)³]Åv(4)¬å±b¸¹(5)§ïID" "(6)±þ/´_¬¡Ãdª«(7)¼f§P [0]µ²§ô " : - "½Ð¿ï¾Ü (1)קï¸ê®Æ (2)³]©w±K½X (C) Ó¤H¤Æ³]©w ==> [0]µ²§ô ", - ans, sizeof(ans), DOECHO); + "½Ð¿ï¾Ü (1)קï¸ê®Æ (2)³]©w±K½X (C) Ó¤H¤Æ³]©w ==> [0]µ²§ô "); - if (ans[0] > '2' && ans[0] != 'C' && ans[0] != 'c' && !real) - ans[0] = '0'; + if (ans > '2' && ans != 'C' && ans != 'c' && !real) + ans = '0'; - if (ans[0] == '1' || ans[0] == '3') { + if (ans == '1' || ans == '3') { clear(); i = 1; move(i++, 0); outs(msg_uid); outs(x.userid); } - switch (ans[0]) { + switch (ans) { case 'C': case 'c': Customize(); @@ -588,8 +578,7 @@ uinfo_query(userec_t * u, int real, int unum) pressanykey(); return; } - getdata(b_lines - 1, 0, msg_sure_ny, ans, 3, LCECHO); - if (*ans == 'y') { + if (getans(msg_sure_ny) == 'y') { if (flag) post_change_perm(temp, i, cuser.userid, x.userid); if (strcmp(u->userid, x.userid)) { @@ -1061,6 +1050,7 @@ toregister(char *email, char *genbuf, char *phone, char *career, } } +#ifndef FOREIGN_REG static int HaveRejectStr(char *s, char **rej) { int i; @@ -1088,6 +1078,7 @@ static int HaveRejectStr(char *s, char **rej) } return 0; } +#endif static char *isvalidname(char *rname) { @@ -1368,11 +1359,11 @@ u_register(void) getfield(11, "§t\033[1;33m¿¤¥«\033[m¤Îªù¹ì¸¹½X" "(¥x¥_½Ð¥[\033[1;33m¦æ¬F°Ï\033[m)", "¥Ø«e¦í§}", addr, 50); - if( (errcode = isvalidaddr(addr) + if( (errcode = isvalidaddr(addr)) == NULL #ifdef FOREIGN_REG - && fore[0] ==0 + && fore[0] == 0 #endif - ) == NULL ) + ) break; else vmsg(errcode); @@ -1500,7 +1491,7 @@ u_list_CB(int num, userec_t * uentp) permstr[0] = 'S'; else if (level & PERM_ACCOUNTS) permstr[0] = 'A'; - else if (level & PERM_DENYPOST) + else if (level & PERM_SYSOPHIDE) permstr[0] = 'p'; if (level & (PERM_BOARD)) @@ -1551,6 +1542,6 @@ u_list() clrtoeol(); prints("\033[34;46m ¤wÅã¥Ü %d/%d ªº¨Ï¥ÎªÌ(¨t²Î®e¶qµL¤W) " "\033[31;47m (½Ð«ö¥ô·NÁäÄ~Äò) \033[m", usercounter, totalusers); - egetch(); + igetch(); return 0; } diff --git a/mbbsd/var.c b/mbbsd/var.c index c9347b20..3ff019f0 100644 --- a/mbbsd/var.c +++ b/mbbsd/var.c @@ -84,9 +84,7 @@ char paste_title[STRLEN]; char paste_path[256]; char currtitle[TTLEN + 1] = "\0"; char vetitle[TTLEN + 1] = "\0"; -char currowner[IDLEN + 2] = "\0"; char currauthor[IDLEN + 2] = "\0"; -char currfile[FNLEN];/* current file name @ bbs.c mail.c */ char *currboard = "\0"; char currBM[IDLEN * 3 + 10]; char reset_color[4] = "\033[m"; @@ -382,7 +380,6 @@ char real_name[IDLEN + 1]; int local_article; /* mbbsd.c */ -int talkrequest = NA; char fromhost[STRLEN] = "\0"; char water_usies = 0; FILE *fp_writelog = NULL; diff --git a/mbbsd/vote.c b/mbbsd/vote.c index a6cb52c4..5325e64c 100644 --- a/mbbsd/vote.c +++ b/mbbsd/vote.c @@ -535,7 +535,7 @@ vote_view_all(char *bname) setbfile(buf, bname, STR_new_control); move(0, 0); if ((fp = fopen(buf, "r"))) { - prints("(0) "); + outs("(0) "); x = 0; fclose(fp); @@ -760,7 +760,6 @@ vote_maintain(char *bname) move((i % 15) + 2, (i / 15) * 40); prints(buf); } - refresh(); } snprintf(buf, sizeof(buf), "%c) ", num + 'A'); getdata((num % 15) + 2, (num / 15) * 40, buf, diff --git a/mbbsd/xyz.c b/mbbsd/xyz.c index e0b850b5..b20b9d74 100644 --- a/mbbsd/xyz.c +++ b/mbbsd/xyz.c @@ -180,9 +180,7 @@ note() notedata_t myitem; if (cuser.money < 5) { - outmsg("\033[1;41m «u§r! n§ë¤»È¤~¯à¯d¨¥...¨S¿úC..\033[m"); - clrtoeol(); - refresh(); + vmsg("\033[1;41m «u§r! n§ë¤»È¤~¯à¯d¨¥...¨S¿úC..\033[m"); return 0; } setutmpmode(EDNOTE); @@ -313,7 +311,7 @@ mail_sysop() move(12, 0); clrtobot(); - prints("%16s %-18sÅv³d¹º¤À\n\n", "½s¸¹", "¯¸ªø ID"); + outs(" ½s¸¹ ¯¸ªø ID Åv³d¹º¤À\n\n"); for (i = 0; i < j; i++) prints("%15d. \033[1;%dm%-16s%s\033[0m\n", diff --git a/util/Makefile b/util/Makefile index 0f6e38af..bc6dbf1b 100644 --- a/util/Makefile +++ b/util/Makefile @@ -27,7 +27,7 @@ CPROG_WITH_UTIL= \ # ¤U±³o¨Çµ{¦¡, ·|ª½±µ³Q compile CPROG_WITHOUT_UTIL= \ - shmsweep uhash_loader showboard antispam \ + shmsweep uhash_loader showboard \ countalldice webgrep bbsrf initbbs \ userlist tunepasswd buildir merge_passwd \ merge_board xchatd bbsmail diff --git a/util/antispam.c b/util/antispam.c deleted file mode 100644 index e5b2ed59..00000000 --- a/util/antispam.c +++ /dev/null @@ -1,122 +0,0 @@ -/* $Id$ */ -/* §ì¼s§i«Hªºµ{¦¡ */ -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <sys/types.h> -#include "config.h" - -#define WINDOW 100 /* ¤@¦¸window¦h¤ÖÓserver */ -#define LEVEL 21 /* Y´X¦¸«´_´Nºâ¼s§i«H */ - -#define mailog BBSHOME "/etc/mailog" -#define spamlog BBSHOME "/etc/spam" - -typedef struct sendinfo -{ - char time[18]; - char from[50]; - char userid[20]; - int count; -} -sendinfo; - -int -main(int argc, char **argv) -{ - char buf[200], *from, *userid; - int num = -1, numb = -1, n, nb; - FILE *fp = fopen(mailog, "r"), *fo; - sendinfo data[WINDOW]; - sendinfo bad[WINDOW]; - - unlink(spamlog); - fo = fopen(spamlog, "a"); - memset(data, 0, sizeof(data)); - memset(bad, 0, sizeof(bad)); - - if (!fp || !fo) - return 0; - - while (fgets(buf, 200, fp)) - { - strtok(buf, "\r\n"); - from = strchr(buf, '>') + 2; - userid = strstr(buf, " =>"); - - if (!from || !userid) - continue; - - *userid = 0; - userid += 4; - - if (strstr(from, "MAILER-DAEMON") - || strstr(from, userid)) - continue; /* °h«H³qª¾¤£ºÞ */ - /* ¬O§_¤w¬Obadhost */ - - for (nb = 0; nb < WINDOW && bad[nb].from[0]; nb++) - if (!strcmp(bad[nb].from, from)) - break; - - if (nb < WINDOW && bad[nb].from[0]) - { - bad[nb].count++; - continue; - } - - /* ²¬d¹L¥h°O¿ý */ - - for (n = 0; n < WINDOW && data[n].from[0]; n++) - if (!strcmp(data[n].from, from)) - break; - - if (n < WINDOW && data[n].from[0]) - { - if (!strncmp(data[n].userid, userid, 20)) - continue; - /* Â൹¦P¤@Ó¤H´N¤£ºÞ */ - strncpy(data[n].userid, userid, 20); - if (++data[n].count >= LEVEL) - { - /* Åܦ¨bad ²¾data¨ìbad ªÅ¯Ê¥Ñ«á¤@µ§¸ê®Æ¸É¤W */ - if (nb >= WINDOW) - { - numb = (numb + 1) % WINDOW; - nb = numb; - fprintf(fo, "%s %s «ÂбH %d ¦¸\n", - bad[nb].time, bad[nb].from, bad[nb].count); -/* printf(" %s send %d times\n", - bad[nb].from, bad[nb].count); */ - } - memcpy(&bad[nb], &data[n], sizeof(sendinfo)); - memcpy(&data[n], &data[n + 1], sizeof(sendinfo) * (WINDOW - n - 1)); - if (num > n) - num--; - } - } - else - { - if (n >= WINDOW) - { - num = (num + 1) % WINDOW; - n = num; - } -/* printf("[%s] to [%s]\n", from, userid); */ - buf[17] = 0; - strncpy(data[n].time, buf, 17); - strncpy(data[n].from, from, 50); - strncpy(data[n].userid, userid, 20); - } - } - - for (nb = 0; nb < WINDOW && bad[nb].from[0]; nb++) - { - fprintf(fo, "%s %s «ÂбH %d ¦¸\n", bad[nb].time, - bad[nb].from, bad[nb].count); -/* printf(" %s send %d times\n", bad[nb].from, bad[nb].count); */ - } - fclose(fp); - fclose(fo); - return 0; -} diff --git a/util/killdeadbbs.c b/util/killdeadbbs.c deleted file mode 100644 index 0c83fe29..00000000 --- a/util/killdeadbbs.c +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef FreeBSD -int main(int argc, char **argv) -{ - puts("this program is only for FreeBSD"); -} -#else -#include <err.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <signal.h> -#include <kvm.h> -#include <fcntl.h> -#include <limits.h> -#include <sys/param.h> -#include <sys/sysctl.h> -#include <sys/user.h> -#include "config.h" // for BBSUID - -int main(int argc, char **argv) -{ - kvm_t *kd; - struct kinfo_proc *kp; - char errbuf[_POSIX2_LINE_MAX]; - int nentries, i, npids; - pid_t pids[8192]; - kd = kvm_openfiles("/dev/null", "/dev/null", NULL, O_RDONLY, errbuf); - if( kd == NULL ) - errx(1, "%s", errbuf); - - if ((kp = kvm_getprocs(kd, KERN_PROC_UID, BBSUID, &nentries)) == 0 || - nentries < 0) - errx(1, "%s", kvm_geterr(kd)); - - for( npids = 0, i = nentries ; --i >= 0 ; ++kp ){ - if( strncmp(kp->ki_comm, "mbbsd", 5) == 0 ){ - if( kp->ki_runtime > (60 * 1000000) ){ // 60 secs - kill(kp->ki_pid, 1); - pids[npids++] = kp->ki_pid; - printf("%d\n", kp->ki_pid); - } - } - } - - if( npids != 0 ){ - sleep(2); - while( --npids >= 0 ) - kill(pids[npids], 9); - } - - kvm_close(kd); - return 0; -} - -#endif diff --git a/util/lunar-1,15run.pl b/util/lunar-1,15run.pl deleted file mode 100644 index d4cd2f20..00000000 --- a/util/lunar-1,15run.pl +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/perl -use lib '/home/bbs/bin/'; -use LocalVars; -# ¨C¹A¾äªì¤@, ¤Q¤´N·|¶]¤@¦¸ $ARGV[0] -# ¸ê®Æ¨Ó·½ http://tw.weathers.yahoo.com/ -open FH, "$LYNX -source http://tw.weathers.yahoo.com/ | grep '¥Á°ê'|"; -$din = <FH>; -close FH; - -($month, $day) = $din =~ /¹A¾ä (.*?)¤ë (.*?)¤é/; -system("@ARGV") if( $day eq '¤@' || $day eq '¤@¤Q¤' ); diff --git a/util/testkenben.txt b/util/testkenben.txt deleted file mode 100644 index df3893d3..00000000 --- a/util/testkenben.txt +++ /dev/null @@ -1,11 +0,0 @@ -HCGH-306 ¦Ë¤k ¡·¦³¤K¨ö¡I¡I¡I 7/24 jennywen/molly -Foolshome ¹ÎÅé ¡·CCC~~~¤dÁH¦~ 1/14 truth/citizen/nathon -KHCHS-87-306·s²ø ¡·³£¶]¨ìþ¸Ì¥h¤F 6/12 -TGHS8714 «n¤k ¡·²z©Ê¤Ñ®ð¡F·P©Ê¥ 8/07 grassflying/EPOCH -PttDoc ¼Tù ¡·Ptt Document Pr 8/07 -Delphi µ{³] ¡·Delphi¨g·Q¦± 3/09 cying -ciacia_Her ¥xÆW ¡·ciacia¥Î¤å¦r¬D³ 8/16 sherbet -CS87Love ¤¤¤s ¡··R©O! 8/08 sylna/fancydream -Wanfang ¥xÆW ¡·´Nȱo¤F·R¸UªÚ 8/07 zkkk -KS87-308 ¶¯¤¤ ¡´¶¯¤¤¤K±¾¯Z¡m¤@¤ 8/07 SBT/shouhou - |