From 8e14c77ef2bb46136c1d2f5b202a54f714badad0 Mon Sep 17 00:00:00 2001 From: kcwu Date: Sat, 6 Sep 2003 19:52:57 +0000 Subject: clean up git-svn-id: http://opensvn.csie.org/pttbbs/trunk@1166 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- pttbbs/include/config.h | 13 ++---------- pttbbs/include/proto.h | 2 +- pttbbs/mbbsd/admin.c | 14 ++++--------- pttbbs/mbbsd/bbs.c | 4 ++-- pttbbs/mbbsd/board.c | 29 +-------------------------- pttbbs/mbbsd/cache.c | 2 +- pttbbs/mbbsd/cal.c | 22 ++++++++------------ pttbbs/mbbsd/chat.c | 37 ---------------------------------- pttbbs/mbbsd/chicken.c | 20 +++++++++---------- pttbbs/mbbsd/edit.c | 14 +------------ pttbbs/mbbsd/friend.c | 19 +++++++----------- pttbbs/mbbsd/gamble.c | 2 +- pttbbs/mbbsd/indict.c | 52 +++++++++++++++++++++--------------------------- pttbbs/mbbsd/mail.c | 18 ++++------------- pttbbs/mbbsd/mbbsd.c | 9 +++------ pttbbs/mbbsd/page.c | 4 +--- pttbbs/mbbsd/read.c | 8 ++++---- pttbbs/mbbsd/record.c | 4 ++-- pttbbs/mbbsd/register.c | 4 +--- pttbbs/mbbsd/talk.c | 28 +++++++------------------- pttbbs/mbbsd/user.c | 3 +-- pttbbs/mbbsd/var.c | 3 --- pttbbs/mbbsd/voteboard.c | 2 +- pttbbs/mbbsd/xyz.c | 20 +++++-------------- 24 files changed, 90 insertions(+), 243 deletions(-) diff --git a/pttbbs/include/config.h b/pttbbs/include/config.h index 88d70e5a..c3d7d2fa 100644 --- a/pttbbs/include/config.h +++ b/pttbbs/include/config.h @@ -29,7 +29,7 @@ #define MAX_POST_MONEY 100 #endif -#ifndef MAX_CHICKEN_MONEY /* ¾iÂû³õì§Q¤W­­ */ +#ifndef MAX_CHICKEN_MONEY /* ¾iÂû³õÀò§Q¤W­­ */ #define MAX_CHICKEN_MONEY 100 #endif @@ -121,7 +121,6 @@ #undef SUPPORT_GB /* ¬O§_¤ä´©gb */ -#define DEFAULTBOARD "SYSOP" /* ¹w³]¬ÝªO */ #define LOGINASNEW /* ±Ä¥Î¤W¯¸¥Ó½Ð±b¸¹¨î«× */ #define NO_WATER_POST /* ¨¾¤îBlahBlah¦¡Äé¤ô */ #define USE_BSMTP /* ¨Ï¥ÎopusªºBSMTP ±H¦¬«H? */ @@ -135,8 +134,7 @@ #undef HAVE_INFO /* Åã¥Üµ{¦¡ª©¥»»¡©ú */ #undef HAVE_LICENSE /* Åã¥Ü GNU ª©Åvµe­± */ #define FAST_LOGIN /* Login ¤£Àˬd»·ºÝ¨Ï¥ÎªÌ */ -#define HAVE_CAL /* ´£¥\­pºâ¾÷ */ -#undef POSTBUG /* board/mail post ¨S¦³ bug ¤F */ +#define HAVE_CAL /* ´£¨Ñ­pºâ¾÷ */ #undef HAVE_REPORT /* ¨t²Î°lÂܳø§i */ #undef EMAIL_JUSTIFY /* µo¥X InterNet Email ¨­¥÷»{ÃÒ«H¨ç */ #undef NEWUSER_LIMIT /* ·s¤â¤W¸ôªº¤T¤Ñ­­¨î */ @@ -158,13 +156,6 @@ #define SHOWBOARD /* ¬Ý¨£¨Ï¥ÎªÌ¬ÝªO */ #define SHOWPID /* ¬Ý¨£¨Ï¥ÎªÌ PID */ -#define REALINFO /* ¯u¹ê©m¦W */ -#ifdef REALINFO -#undef ACTS_REALNAMES /* ¥D¥Ø¿ýªº (U)ser Åã¥Ü¯u¹ê©m¦W */ -#undef POST_REALNAMES /* ¶K¤å¥ó®Éªþ¤W¯u¹ê©m¦W */ -#undef MAIL_REALNAMES /* ±H¯¸¤º«H¥ó®Éªþ¤W¯u¹ê©m¦W */ -#endif - #define DOTIMEOUT #ifdef DOTIMEOUT #define IDLE_TIMEOUT (43200) /* ¤@¯ë±¡ªp¤§ timeout (12hr) */ diff --git a/pttbbs/include/proto.h b/pttbbs/include/proto.h index 073e9520..bbb603df 100644 --- a/pttbbs/include/proto.h +++ b/pttbbs/include/proto.h @@ -240,7 +240,7 @@ int guess_main(); /* indict */ int x_dict(); -int use_dict(); +int use_dict(char *dict,char *database); /* io */ int getdata(int line, int col, char *prompt, char *buf, int len, int echo); diff --git a/pttbbs/mbbsd/admin.c b/pttbbs/mbbsd/admin.c index 99c87621..e6f30b20 100644 --- a/pttbbs/mbbsd/admin.c +++ b/pttbbs/mbbsd/admin.c @@ -33,7 +33,7 @@ search_key_user(char *passwdfile, int mode) int ch; int coun = 0; FILE *fp1 = fopen(passwdfile, "r"); - char friendfile[128]="",buf[128], key[22], genbuf[8], + char friendfile[128]="", key[22], genbuf[8], *keymatch; @@ -46,8 +46,7 @@ search_key_user(char *passwdfile, int mode) while ((fread(&user, sizeof(user), 1, fp1)) > 0 && coun < MAX_USERS) { if (!(++coun & 15)) { move(1, 0); - snprintf(buf, sizeof(buf), "²Ä [%d] µ§¸ê®Æ\n", coun); - outs(buf); + prints("²Ä [%d] µ§¸ê®Æ\n", coun); refresh(); } keymatch = NULL; @@ -73,8 +72,7 @@ search_key_user(char *passwdfile, int mode) if(keymatch) { move(1, 0); - snprintf(buf, sizeof(buf), "²Ä [%d] µ§¸ê®Æ\n", coun); - outs(buf); + prints("²Ä [%d] µ§¸ê®Æ\n", coun); refresh(); user_display(&user, 1); @@ -110,11 +108,10 @@ search_key_user(char *passwdfile, int mode) return 0; } else { move(b_lines - 1, 0); - genbuf[0] = 'n'; getdata(0, 0, "¥Ø«eªº PASSWD ÀɨS¦³¦¹ ID¡A·s¼W¶Ü¡H[y/N]", genbuf, 3, LCECHO); - if (genbuf[0] == 'n') { + if (genbuf[0] != 'y') { outs("¥Ø«eªºPASSWDSÀɨS¦³¦¹id " "½Ð¥ýnew¤@­Ó³o­Óidªº±b¸¹"); } else { @@ -479,9 +476,6 @@ x_file() case '9': fpath = "etc/hint"; break; - case 'a': - fpath = "etc/teashop"; - break; case 'b': fpath = "etc/sysop"; break; diff --git a/pttbbs/mbbsd/bbs.c b/pttbbs/mbbsd/bbs.c index 27c8ab25..47eeb65b 100644 --- a/pttbbs/mbbsd/bbs.c +++ b/pttbbs/mbbsd/bbs.c @@ -636,10 +636,10 @@ do_post() static void do_generalboardreply(fileheader_t * fhdr) { - char genbuf[200]; + char genbuf[3]; getdata(b_lines - 1, 0, "¡¶ ¦^À³¦Ü (F)¬ÝªO (M)§@ªÌ«H½c (B)¤GªÌ¬Ò¬O (Q)¨ú®ø¡H[F] ", - genbuf, 3, LCECHO); + genbuf, sizeof(genbuf), LCECHO); switch (genbuf[0]) { case 'm': mail_reply(0, fhdr, 0); diff --git a/pttbbs/mbbsd/board.c b/pttbbs/mbbsd/board.c index eb6a13d4..5214d3cc 100644 --- a/pttbbs/mbbsd/board.c +++ b/pttbbs/mbbsd/board.c @@ -935,7 +935,7 @@ show_brdlist(int head, int clsflag, int newflag) move(1, 0); outs( " " - "¢© ¢~¡X\033[33m¡´\n" + "¢© ùú¡X\033[33m¡´\n" " ùá¡X \033[m " "¢¨¢i\033[47m¡ó\033[40m¢i¢i¢©ùç\n" " \033[44m ¡s¡s¡s¡s¡s¡s¡s¡s " @@ -1579,30 +1579,3 @@ New() currstat = stat0; return 0; } - -/* - * int v_favorite(){ char fname[256]; char inbuf[2048]; FILE* fp; int nGroup; - * char* strtmp; - * - * setuserfile(fname,str_favorite); - * - * if (!(fp=fopen(fname,"r"))) return -1; move(0,0); clrtobot(); - * fgets(inbuf,sizeof(inbuf),fp); nGroup=atoi(inbuf); - * - * currutmp->nGroup=0; currutmp->ninRoot=0; - * - * while(nGroup!=currutmp->nGroup+1){ fgets(inbuf,sizeof(inbuf),fp); - * prints("%s\n",strtmp=strtok(inbuf," \n")); - * strcpy(currutmp->gfavorite[currutmp->nGroup++],strtmp); - * while((strtmp=strtok(NULL, " \n"))){ prints(" %s - * %d\n",strtmp,getbnum(strtmp)); } currutmp->nGroup++; } - * prints("+++%d+++\n",currutmp->nGroup); - * - * fgets(inbuf,sizeof(inbuf),fp); - * - * for(strtmp=strtok(inbuf, " \n");strtmp;strtmp=strtok(NULL, " \n")){ if - * (strtmp[0]!='#') prints("*** %s %d\n",strtmp, getbnum(strtmp)); else - * prints("*** %s %d\n",strtmp+1, -1); currutmp->ninRoot++; } - * - * fclose(fp); pressanykey(); return 0; } - */ diff --git a/pttbbs/mbbsd/cache.c b/pttbbs/mbbsd/cache.c index 945fed88..7059d4e2 100644 --- a/pttbbs/mbbsd/cache.c +++ b/pttbbs/mbbsd/cache.c @@ -936,7 +936,7 @@ reload_fcache(void) while (fgets(buf, sizeof(buf), fp)) { if (buf[0] && buf[0] != '#' && buf[0] != ' ' && buf[0] != '\n') { - sscanf(buf, "%s", SHM->domain[SHM->top]); + sscanf(buf, "%s", SHM->domain[SHM->top]); // XXX check buffer size po = buf + strlen(SHM->domain[SHM->top]); while (*po == ' ') po++; diff --git a/pttbbs/mbbsd/cal.c b/pttbbs/mbbsd/cal.c index 89383f99..fceaf2b1 100644 --- a/pttbbs/mbbsd/cal.c +++ b/pttbbs/mbbsd/cal.c @@ -118,9 +118,7 @@ osong(char *defaultid) } move(12, 0); clrtobot(); - snprintf(buf, sizeof(buf), - "¿Ë·Rªº %s Åwªï¨Ó¨ì¼Ú®á¦Û°ÊÂIºq¨t²Î\n", cuser.userid); - outs(buf); + prints("¿Ë·Rªº %s Åwªï¨Ó¨ì¼Ú®á¦Û°ÊÂIºq¨t²Î\n", cuser.userid); trans_buffer[0] = 0; if (!defaultid) { getdata(13, 0, "­nÂIµ¹½Ö©O:[¥iª½±µ«ö Enter ¥ý¿ïºq]", @@ -174,12 +172,12 @@ osong(char *defaultid) "¡º %s ÂIµ¹ %s ", (ano[0] == 'y') ? "°Î¦WªÌ" : cuser.userid, destid); - while (fgets(buf, 200, fp)) { + while (fgets(buf, sizeof(buf), fp)) { char *po; if (!strncmp(buf, "¼ÐÃD: ", 6)) { clear(); move(10, 10); - prints("%s", buf); + outs(buf); pressanykey(); fclose(fp); fclose(fp1); @@ -313,9 +311,7 @@ p_exmail() int n; if (cuser.exmailbox >= MAX_EXKEEPMAIL) { - snprintf(buf, sizeof(buf), - "®e¶q³Ì¦h¼W¥[ %d «Ê¡A¤£¯à¦A¶R¤F¡C", MAX_EXKEEPMAIL); - outs(buf); + prints("®e¶q³Ì¦h¼W¥[ %d «Ê¡A¤£¯à¦A¶R¤F¡C", MAX_EXKEEPMAIL); refresh(); return 0; } @@ -477,11 +473,11 @@ cal() float a = 0; char flo = 0, ch = 0; char mode[6] = {' ', '=', '+', '-', '*', '/'}, cmode = 0; - char buf[100] = "[ 0] [ ] ", b[20] = "0"; + char b[20] = "0"; move(b_lines - 1, 0); clrtoeol(); - outs(buf); + outs("[ 0] [ ] "); move(b_lines, 0); clrtoeol(); outs("\033[44m ¤p­pºâ¾÷ \033[31;47m (0123456789+-*/=) " @@ -502,8 +498,7 @@ cal() b[0] = '0'; b[1] = 0; move(b_lines - 1, 0); - snprintf(buf, sizeof(buf), "[%13.2f] [%c] ", a, ch); - outs(buf); + prints("[%13.2f] [%c] ", a, ch); break; case '.': if (!flo) @@ -527,8 +522,7 @@ cal() else b[0] = ch; move(b_lines - 1, 0); - snprintf(buf, sizeof(buf), "[%13s] [%c]", b, mode[(int)cmode]); - outs(buf); + prints("[%13s] [%c]", b, mode[(int)cmode]); break; case 'q': return 0; diff --git a/pttbbs/mbbsd/chat.c b/pttbbs/mbbsd/chat.c index 55d3129d..5493608f 100644 --- a/pttbbs/mbbsd/chat.c +++ b/pttbbs/mbbsd/chat.c @@ -295,43 +295,6 @@ chat_cmd(char *buf, int fd) return 0; } -#if 0 -static char * -select_address() -{ - int c; - FILE *fp; - char nametab[25][90]; - char iptab[25][18], buf[80]; - - move(1, 0); - clrtobot(); - outs("\n \033[36m¡i§ä­Ó¦a¤è©ï©ïºb§a!¡j\033[m " - "¡· ¡i¥H¤U¬°¥»¯¸µn°O¦³®×ªº¯ù¼Ó¡j \n"); - trans_buffer[0] = 0; - if ((fp = fopen("etc/teashop", "r"))) { - for (c = 0; fscanf(fp, "%s%s", iptab[c], nametab[c]) != EOF; c++) { - snprintf(buf, sizeof(buf), - "\n (\033[36m%d\033[0m) %-30s [%s]", - c + 1, nametab[c], iptab[c]); - outs(buf); - } - getdata(20, 10, "¡¹\033[32m ½Ð¿ï¾Ü¡A[0]Â÷¶}¡G\033[0m", buf, 3, - LCECHO); - if (buf[1]) - buf[0] = (buf[0] + 1) * 10 + (buf[1] - '1'); - else - buf[0] -= '1'; - if (buf[0] >= 0 && buf[0] < c) - strlcpy(trans_buffer, iptab[(int)buf[0]], sizeof(trans_buffer)); - } else { - outs("¥»¯¸¨S¦³µn°O¥ô¦ó¦X®æ¯ù¼Ó"); - pressanykey(); - } - return trans_buffer; -} -#endif - #define MAXLASTCMD 6 static int chatid_len = 10; diff --git a/pttbbs/mbbsd/chicken.c b/pttbbs/mbbsd/chicken.c index 23ed4279..0c769fe7 100644 --- a/pttbbs/mbbsd/chicken.c +++ b/pttbbs/mbbsd/chicken.c @@ -6,39 +6,39 @@ static const char *cage[17] = { "½Ï¥Í", "¶g·³", "¥®¦~", "¤Ö¦~", "«C¬K", "«C¦~", "«C¦~", "¬¡¤O", "§§¦~", "§§¦~", "§§¦~", "¤¤¦~", -"¤¤¦~", "¦Ñ¦~", "¦Ñ¦~", "¦Ñáàáà", "¥j§Æ"}; + "¤¤¦~", "¦Ñ¦~", "¦Ñ¦~", "¦Ñáàáà", "¥j§Æ"}; static const char *chicken_type[NUM_KINDS] = { "¤pÂû", "¬ü¤Ö¤k", "«i¤h", "»jµï", "®£Às", "¦ÑÆN", "¿ß", "Äúµ§¤p·s", "ª¯ª¯", "´cÅ]", "§ÔªÌ", "£««ó", -"°¨­^¤E", "´N¥i¤H", "ù²ú"}; + "°¨­^¤E", "´N¥i¤H", "ù²ú"}; static const char *chicken_food[NUM_KINDS] = { "Âû¹}®Æ", "Àç¾i«p¤ù", "Âû±Æ«K·í", "¦º½¹½º", "«ÍÅé", "¤pÂû", "¿ß»æ°®", "¤pºµ»æ°®", "Ä_¿ý", "ÆF®ð", "¶º¹Î", "«K·í", -"Âû»L", "¯º¸Ü¤å³¹", "¤ôªG¨F©Ô"}; + "Âû»L", "¯º¸Ü¤å³¹", "¤ôªG¨F©Ô"}; static const int egg_price[NUM_KINDS] = { 5, 25, 30, 40, 80, 50, 15, 35, 17, 100, 85, 200, -200, 100, 77}; + 200, 100, 77}; static const int food_price[NUM_KINDS] = { 4, 6, 8, 10, 12, 12, 5, 6, 5, 20, 15, 23, -23, 10, 19}; + 23, 10, 19}; static const char *attack_type[NUM_KINDS] = { "°Ö", "Ã@¥´", "ºl", "«r", "¼²À»", "°Ö", "§ì", "½ð", "«r", "¿U¿N", "·tÀ»", "´Ò¥´", -"¼CÀ»", "§N­á¥ú½u", "­»§k¤@ªT"}; + "¼CÀ»", "§N­á¥ú½u", "­»§k¤@ªT"}; static const char *damage_degree[] = { "°A¤l¦üªº", "ÄÌÄo¦üªº", "¤p¤Oªº", "»´·Lªº", "¦³ÂI¯kªº", "¨Ï¤Oªº", "¶Ë¤Hªº", "­«­«ªº", "¨Ï¥þ¤Oªº", "´c¬½¬½ªº", "¦MÀIªº", "ºÆ¨gªº", "²r¯Pªº", "¨g­·¼É«B¦üªº", "Åå¤Ñ°Ê¦aªº", -"­P©Rªº", NULL}; + "­P©Rªº", NULL}; enum { OO, FOOD, WEIGHT, CLEAN, RUN, ATTACK, BOOK, HAPPY, SATIS, @@ -104,7 +104,7 @@ new_chicken() clear(); move(2, 0); - outs("ÅwªïÆ[Á{ \033[33m¡·\033[37;44m PttÃdª«¥«³õ \033[33;40m¡·\033[m.. " + outs("Åwªï¥úÁ{ \033[33m¡·\033[37;44m PttÃdª«¥«³õ \033[33;40m¡·\033[m.. " "¥Ø«e³J»ù¡G\n" "(a)¤pÂû $5 (b)¬ü¤Ö¤k $25 (c)«i¤h $30 (d)»jµï $40 " "(e)®£Às $80\n" @@ -167,7 +167,7 @@ show_file(char *filename, int y, int lines, int mode) move(y, 0); clrtoline(lines + y); if ((fp = fopen(filename, "r"))) { - while (fgets(buf, 256, fp) && lines--) + while (fgets(buf, sizeof(buf), fp) && lines--) outs(Ptt_prints(buf, mode)); fclose(fp); } else @@ -480,7 +480,7 @@ ch_sell() else if (money > MAX_CHICKEN_MONEY) money = MAX_CHICKEN_MONEY; //¨¾¤î©ÇÂû - if (mychicken->type == 1 || mychicken->type == 7) { + if (mychicken->type == 1 || mychicken->type == 7) { outs("\n\033[31m £­..¿Ë·Rªº..³c½æ¤H¤f¬O·|¥Çªkªº­ò..\033[m"); pressanykey(); return 0; diff --git a/pttbbs/mbbsd/edit.c b/pttbbs/mbbsd/edit.c index 202157ae..10f33d33 100644 --- a/pttbbs/mbbsd/edit.c +++ b/pttbbs/mbbsd/edit.c @@ -1,4 +1,4 @@ -/* $Id: edit.c,v 1.39 2003/07/17 06:11:14 victor Exp $ */ +/* $Id$ */ /* edit.c, ¥Î¨Ó´£¨Ñ bbs¤Wªº¤å¦r½s¿è¾¹, §Y ve. * ²{¦b³o¤@­Ó¬O´c·d¹Lªºª©¥», ¤ñ¸û¤£Ã­©w, ¥Î¤ñ¸û¦hªº cpu, ¦ý¬O¥i¥H¬Ù¤U³\¦h * ªº°O¾ÐÅé (¥H Ptt¬°¨Ò, ¦b¤E¤d¤H¤W¯¸ªº®É­Ô, ¬ù¥i¬Ù¤U 50MB ªº°O¾ÐÅé) @@ -806,11 +806,7 @@ write_header(FILE * fp) if (curredit & EDIT_MAIL || curredit & EDIT_LIST) { fprintf(fp, "%s %s (%s)\n", str_author1, cuser.userid, -#if defined(REALINFO) && defined(MAIL_REALNAMES) - cuser.realname -#else cuser.username -#endif ); } else { char *ptr; @@ -869,20 +865,12 @@ write_header(FILE * fp) local_article ? str_post2 : str_post1, currboard); } else { fprintf(fp, "%s %s (%s) %s %s\n", str_author1, cuser.userid, -#if defined(REALINFO) && defined(POSTS_REALNAMES) - cuser.realname, -#else cuser.username, -#endif local_article ? str_post2 : str_post1, currboard); } #else /* HAVE_ANONYMOUS */ fprintf(fp, "%s %s (%s) %s %s\n", str_author1, cuser.userid, -#if defined(REALINFO) && defined(POSTS_REALNAMES) - cuser.realname, -#else cuser.username, -#endif local_article ? str_post2 : str_post1, currboard); #endif /* HAVE_ANONYMOUS */ diff --git a/pttbbs/mbbsd/friend.c b/pttbbs/mbbsd/friend.c index 16e36c63..3f97ee71 100644 --- a/pttbbs/mbbsd/friend.c +++ b/pttbbs/mbbsd/friend.c @@ -152,18 +152,14 @@ friend_append(int type, int count) for (j = i = 0; i <= 4; i++) if (i != type) { ++j; - snprintf(buf, sizeof(buf), - " (%d) %-s\n", j, friend_list[(int)i]); - outs(buf); + prints(" (%d) %-s\n", j, friend_list[(int)i]); } if (HAVE_PERM(PERM_SYSOP) || currmode & MODE_BOARD) for (; i < 8; ++i) if (i != type) { ++j; - snprintf(buf, sizeof(buf), - " (%d) %s ªOªº %s\n", j, currboard, + prints(" (%d) %s ªOªº %s\n", j, currboard, friend_list[(int)i]); - outs(buf); } outs(" (S) ¿ï¾Ü¨ä¥L¬ÝªOªº¯S§O¦W³æ"); getdata(11, 0, "½Ð¿ï¾Ü ©Î ª½±µ[Enter] ©ñ±ó:", buf, 3, LCECHO); @@ -187,7 +183,7 @@ friend_append(int type, int count) while (fgets(buf, 80, fp) && (unsigned)count <= friend_max[type]) { char the_id[15]; - sscanf(buf, "%s", the_id); + sscanf(buf, "%s", the_id); // XXX check buffer size if (!belong(fpath, the_id)) { if ((fp1 = fopen(fpath, "a"))) { flock(fileno(fp1), LOCK_EX); @@ -311,7 +307,7 @@ friend_water(char *message, int type) userinfo_t *uentp; int tuid; - sscanf(line, "%s", userid); + sscanf(line, "%s", userid); // XXX check buffer size if ((tuid = searchuser(userid)) && tuid != usernum && (uentp = (userinfo_t *) search_ulist(tuid)) && isvisible_uid(tuid)) @@ -344,8 +340,7 @@ friend_edit(int type) while (1) { stand_title(friend_list[type]); move(0, 40); - snprintf(line, sizeof(line), "(¦W³æ¤W­­:%d­Ó¤H)", friend_max[type]); - outs(line); + prints("(¦W³æ¤W­­:%d­Ó¤H)", friend_max[type]); count = 0; CreateNameList(); @@ -421,7 +416,7 @@ friend_edit(int type) snprintf(genbuf, sizeof(genbuf), "%s.old", fpath); if ((fp = fopen(genbuf, "r"))) { while (fgets(line, 80, fp)) { - sscanf(line, "%s", uident); + sscanf(line, "%s", uident); // XXX check buffer size sethomefile(genbuf, uident, type == FRIEND_ALOHA ? "aloha" : "postnotify"); del_distinct(genbuf, cuser.userid); @@ -431,7 +426,7 @@ friend_edit(int type) snprintf(genbuf, sizeof(genbuf), "%s", fpath); if ((fp = fopen(genbuf, "r"))) { while (fgets(line, 80, fp)) { - sscanf(line, "%s", uident); + sscanf(line, "%s", uident); // XXX check buffer size sethomefile(genbuf, uident, type == FRIEND_ALOHA ? "aloha" : "postnotify"); add_distinct(genbuf, cuser.userid); diff --git a/pttbbs/mbbsd/gamble.c b/pttbbs/mbbsd/gamble.c index 4e2f348f..53e076ad 100644 --- a/pttbbs/mbbsd/gamble.c +++ b/pttbbs/mbbsd/gamble.c @@ -17,7 +17,7 @@ load_ticket_record(char *direct, int ticket[]) snprintf(buf, sizeof(buf), "%s/" FN_TICKET_RECORD, direct); if (!(fp = fopen(buf, "r"))) return 0; - for (i = 0; i < MAX_ITEM && fscanf(fp, "%9d ", &ticket[i]); i++) + for (i = 0; i < MAX_ITEM && fscanf(fp, "%9d ", &ticket[i])==1; i++) total = total + ticket[i]; fclose(fp); return total; diff --git a/pttbbs/mbbsd/indict.c b/pttbbs/mbbsd/indict.c index cdd2712d..317fb5b0 100644 --- a/pttbbs/mbbsd/indict.c +++ b/pttbbs/mbbsd/indict.c @@ -1,12 +1,12 @@ -/* $Id: indict.c,v 1.13 2003/06/28 08:48:36 kcwu Exp $ */ +/* $Id$ */ #include "bbs.h" #define REFER "etc/dicts" static void -addword(char word[]) +addword(char *database,char word[]) { - char buf[150], temp[150], a[3]; + char buf[150], a[3]; FILE *fp = fopen(database, "r+"); if (fp == NULL) { @@ -19,8 +19,7 @@ addword(char word[]) clear(); move(4, 0); outs(" \033[31mĵ§i\033[m:­Y»W·N¶ñ¼g°²¸ê®Æ±N\033[36m¬åid\033[m³B¥÷\n"); - snprintf(temp, sizeof(temp), "\n¿é¤J½d¨Ò\n:\033[33m%s\033[m", buf); - outs(temp); + prints("\n¿é¤J½d¨Ò\n:\033[33m%s\033[m", buf); outs("\n½Ð¨Ì¤W¦C½d¨Ò¿é¤J¤@¦æ¸ê®Æ(ª½±µenter©ñ±ó)\n"); getdata(10, 0, ":", buf, 65, DOECHO); if (buf[0]) { @@ -34,11 +33,12 @@ addword(char word[]) } static int -choose_dict(void) +choose_dict(char *dict,int dictlen,char *database,int databaselen) { - int c; +#define MAX_DICT 10 + int n,c; FILE *fp; - char buf[10][21], data[10][21], cho[130]; + char buf[MAX_DICT][21], data[MAX_DICT][21], cho[10]; move(12, 0); clrtobot(); @@ -46,21 +46,18 @@ choose_dict(void) "¡´ \033[45;33m¦r¨å­ò ¡º ­n¬d­þ¤@¥»¡H\033[m ¡´"); if ((fp = fopen(REFER, "r"))) { - for (c = 0; fscanf(fp, "%s %s", buf[c], data[c]) != EOF; c++) { - snprintf(cho, sizeof(cho), "\n " - "(\033[36m%d\033[m) %-20s¤j¦r¨å", c + 1, buf[c]); - outs(cho); + for(n=0; n= 0 && cho[0] < c) { - strlcpy(dict, buf[(int)cho[0]], sizeof(dict)); - strlcpy(database, data[(int)cho[0]], sizeof(database)); + if (c >= 1 && c <= n) { + strlcpy(dict, buf[c-1], dictlen); + strlcpy(database, data[c-1], databaselen); return 1; } else return 0; @@ -69,7 +66,7 @@ choose_dict(void) } int -use_dict() +use_dict(char *dict,char *database) { FILE *fp; char lang[150], word[80] = ""; @@ -88,13 +85,9 @@ use_dict() strlcpy(&buf[100], "\033[m\n", sizeof(buf) - 100); for (;;) { move(0, 0); - snprintf(lang, sizeof(lang), - " ½Ð¿é¤JÃöÁä¦r¦ê(%s) ©Î«ü¥O(h,t,a)\n", dict); - outs(lang); - snprintf(lang, sizeof(lang), - "[\033[32m<ÃöÁä¦r>\033[m|\033[32mh\033[m:help|\033[32m" + prints(" ½Ð¿é¤JÃöÁä¦r¦ê(%s) ©Î«ü¥O(h,t,a)\n", dict); + prints("[\033[32m<ÃöÁä¦r>\033[m|\033[32mh\033[m:help|\033[32m" "t\033[m:©Ò¦³¸ê®Æ|\033[32ma\033[m:·s¼W¸ê®Æ%s]\n:", sys); - outs(lang); getdata(2, 0, ":", word, 18, DOECHO); outs("¸ê®Æ·j´M¤¤½Ðµy­Ô...."); str_lower(word, word); @@ -108,7 +101,7 @@ use_dict() clear(); move(4, 0); outs(buf); - addword(word); + addword(database,word); continue; } else if (word[0] == 't') word[0] = 0; @@ -162,7 +155,7 @@ use_dict() clear(); move(4, 0); outs(buf); - addword(word); + addword(database,word); } } } @@ -171,7 +164,8 @@ use_dict() int x_dict() { - if (choose_dict()) - use_dict(); + char dict[41], database[41]; + if (choose_dict(dict,sizeof(dict),database,sizeof(database))) + use_dict(dict,database); return 0; } diff --git a/pttbbs/mbbsd/mail.c b/pttbbs/mbbsd/mail.c index b45bde0c..da078f1e 100644 --- a/pttbbs/mbbsd/mail.c +++ b/pttbbs/mbbsd/mail.c @@ -15,7 +15,7 @@ setforward() sethomepath(buf, cuser.userid); strcat(buf, "/.forward"); if ((fp = fopen(buf, "r"))) { - fscanf(fp, "%s", ip); + fscanf(fp, "%s", ip); // XXX check buffer size fclose(fp); } getdata_buf(b_lines - 1, 0, "½Ð¿é¤J«H½c¦Û°ÊÂà±Hªºemail¦a§}:", @@ -811,23 +811,20 @@ m_new() static void mailtitle() { - char buf[256] = ""; + char buf[256]; showtitle("\0¶l¥ó¿ï³æ", BBSName); - snprintf(buf, sizeof(buf), - "[¡ö]Â÷¶}[¡ô¡õ]¿ï¾Ü[¡÷]¾\\Ū«H¥ó [R]¦^«H [x]Âà¹F " + prints("[¡ö]Â÷¶}[¡ô¡õ]¿ï¾Ü[¡÷]¾\\Ū«H¥ó [R]¦^«H [x]Âà¹F " "[y]¸s²Õ¦^«H [O]¯¸¥~«H:%s [h]¨D§U\n\033[7m" "½s¸¹ ¤é ´Á §@ ªÌ «H ¥ó ¼Ð ÃD \033[32m", HAS_PERM(PERM_NOOUTMAIL) ? "\033[31mÃö\033[m" : "¶}"); - outs(buf); buf[0] = 0; if (mailsumlimit) { snprintf(buf, sizeof(buf), "(®e¶q:%d/%dk %d/%d½g)", mailsum, mailsumlimit, mailkeep, mailmaxkeep); } - snprintf(buf, sizeof(buf), "%s%*s\033[m", buf, 29 - (int)strlen(buf), ""); - outs(buf); + prints("%-29s\033[m", buf); } static void @@ -960,10 +957,6 @@ mail_read(int ent, fileheader_t * fhdr, char *direct) mail_del(ent, fhdr, direct); else { fhdr->filemode |= FILE_READ; -#ifdef POSTBUG - if (replied) - bug_possible = YEA; -#endif if ((currmode & MODE_SELECT)) { int index; @@ -972,9 +965,6 @@ mail_read(int ent, fileheader_t * fhdr, char *direct) substitute_record(direct, fhdr, sizeof(*fhdr), ent); } else substitute_record(currmaildir, fhdr, sizeof(*fhdr), ent); -#ifdef POSTBUG - bug_possible = NA; -#endif } return FULLUPDATE; } diff --git a/pttbbs/mbbsd/mbbsd.c b/pttbbs/mbbsd/mbbsd.c index 3d5ba494..92e3b5e5 100644 --- a/pttbbs/mbbsd/mbbsd.c +++ b/pttbbs/mbbsd/mbbsd.c @@ -255,18 +255,15 @@ talk_request(int sig) bell(); bell(); if (currutmp->msgcount) { - char buf[200]; char timebuf[100]; time_t now = time(0); - snprintf(buf, sizeof(buf), - "\033[33;41m¡¹%s\033[34;47m [%s] %s \033[0m", + move(0, 0); + clrtoeol(); + prints("\033[33;41m¡¹%s\033[34;47m [%s] %s \033[0m", SHM->uinfo[currutmp->destuip].userid, my_ctime(&now,timebuf,sizeof(timebuf)), (currutmp->sig == 2) ? "­«­n®ø®§¼s¼½¡I(½ÐCtrl-U,l¬d¬Ý¼ö°T°O¿ý)" : "©I¥s¡B©I¥s¡AÅ¥¨ì½Ð¦^µª"); - move(0, 0); - clrtoeol(); - outs(buf); refresh(); } else { unsigned char mode0 = currutmp->mode; diff --git a/pttbbs/mbbsd/page.c b/pttbbs/mbbsd/page.c index 9583f4c9..1757412f 100644 --- a/pttbbs/mbbsd/page.c +++ b/pttbbs/mbbsd/page.c @@ -8,15 +8,13 @@ static void print_station(const char *addr[6][100], int path, int *line, int *num) { int i; - char genbuf[128]; *num = 0; move(*line,0); do{ for(i=0; i<7 && addr[path - 1][*num]!=NULL; i++){ - sprintf(genbuf, " %2d.%-6s", (*num)+1, addr[path - 1][*num]); + prints(" %2d.%-6s", (*num)+1, addr[path - 1][*num]); (*num)++; - outs(genbuf); } outs("\n"); (*line)++; diff --git a/pttbbs/mbbsd/read.c b/pttbbs/mbbsd/read.c index cd20bd44..8ad1b32e 100644 --- a/pttbbs/mbbsd/read.c +++ b/pttbbs/mbbsd/read.c @@ -630,10 +630,10 @@ i_read_key(onekey_t * rcmdlist, keeploc_t * locmem, int ch, int bid) return READ_REDRAW; case 'G': - if (select_read(locmem,RS_THREAD)) /* marked articles */ - return NEWDIRECT; - else - return READ_REDRAW; + if (select_read(locmem,RS_THREAD)) /* marked articles */ + return NEWDIRECT; + else + return READ_REDRAW; case '/': case '?': diff --git a/pttbbs/mbbsd/record.c b/pttbbs/mbbsd/record.c index 491af517..e4c2897f 100644 --- a/pttbbs/mbbsd/record.c +++ b/pttbbs/mbbsd/record.c @@ -582,9 +582,9 @@ append_record(char *fpath, fileheader_t * record, int size) strncpy(buf, fpath, n + 1); buf[n + 1] = 0; for (m = strlen(buf) - 2; buf[m] != '/' && m > 0; m--); - strcat(buf, ".forward"); + strcat(buf, ".forward"); // XXX check buffer size if ((fp = fopen(buf, "r"))) { - fscanf(fp, "%s", address); + fscanf(fp, "%s", address); // XXX check buffer size fclose(fp); if (buf[0] != 0 && buf[0] != ' ') { buf[n + 1] = 0; diff --git a/pttbbs/mbbsd/register.c b/pttbbs/mbbsd/register.c index a9c3d672..51540ba1 100644 --- a/pttbbs/mbbsd/register.c +++ b/pttbbs/mbbsd/register.c @@ -222,9 +222,7 @@ new_register() if (id == 999999) outs("¦¹¥N¸¹¤w¸g¦³¤H¨Ï¥Î ¬O¤£¦º¤§¨­"); else { - snprintf(passbuf, sizeof(passbuf), - "¦¹¥N¸¹¤w¸g¦³¤H¨Ï¥Î ÁÙ¦³%d¤Ñ¤~¹L´Á \n", id / (60 * 24)); - outs(passbuf); + prints("¦¹¥N¸¹¤w¸g¦³¤H¨Ï¥Î ÁÙ¦³%d¤Ñ¤~¹L´Á \n", id / (60 * 24)); } } else break; diff --git a/pttbbs/mbbsd/talk.c b/pttbbs/mbbsd/talk.c index 7b08e203..32718676 100644 --- a/pttbbs/mbbsd/talk.c +++ b/pttbbs/mbbsd/talk.c @@ -26,9 +26,6 @@ typedef struct pickup_t { int friend, uoffset; } pickup_t; -//extern int bind( /* int,struct sockaddr *, int */ ); -//extern char *getuserid(); - /* °O¿ý friend ªº user number */ // #define PICKUP_WAYS 7 @@ -320,22 +317,17 @@ my_kick(userinfo_t * uentp) static void chicken_query(char *userid) { - char buf[100]; - if (getuser(userid)) { if (xuser.mychicken.name[0]) { time_diff(&(xuser.mychicken)); if (!isdeadth(&(xuser.mychicken))) { show_chicken_data(&(xuser.mychicken), NULL); - snprintf(buf, sizeof(buf), - "\n\n¥H¤W¬O %s ªºÃdª«¸ê®Æ..", userid); - outs(buf); + prints("\n\n¥H¤W¬O %s ªºÃdª«¸ê®Æ..", userid); } } else { move(1, 0); clrtobot(); - snprintf(buf, sizeof(buf), "\n\n%s ¨Ã¨S¦³¾iÃdª«..", userid); - outs(buf); + prints("\n\n%s ¨Ã¨S¦³¾iÃdª«..", userid); } pressanykey(); } @@ -1465,7 +1457,7 @@ static char * descript(int show_mode, userinfo_t * uentp, time_t diff) { switch (show_mode) { - case 1: + case 1: return friend_descript(uentp); case 0: return (((uentp->pager != 2 && uentp->pager != 3 && diff) || @@ -2277,9 +2269,7 @@ userlist(void) if (HAS_PERM(PERM_LOGINOK) && strcmp(uentp->userid, cuser.userid) != 0) { move(b_lines - 2, 0); - snprintf(genbuf, sizeof(genbuf), - "­nµ¹ %s ¦h¤Ö¿ú©O? ", uentp->userid); - outs(genbuf); + prints("­nµ¹ %s ¦h¤Ö¿ú©O? ", uentp->userid); if (getdata(b_lines - 1, 0, "[»È¦æÂà±b]: ", genbuf, 7, LCECHO)) { clrtoeol(); @@ -2291,10 +2281,8 @@ userlist(void) outs("\033[41m ²{ª÷¤£¨¬~~\033[m"); } else { deumoney(uentp->uid, ch - give_tax(ch)); - snprintf(genbuf, sizeof(genbuf), - "\033[44m ¶â..ÁٳѤU %d ¿ú.." + prints("\033[44m ¶â..ÁٳѤU %d ¿ú.." "\033[m", demoney(-ch)); - outs(genbuf); snprintf(genbuf, sizeof(genbuf), "%s\tµ¹%s\t%d\t%s", cuser.userid, uentp->userid, ch, @@ -2431,7 +2419,7 @@ t_idle(void) int mode0 = currutmp->mode; int stat0 = currstat; char genbuf[20]; - char buf[80], passbuf[PASSLEN]; + char passbuf[PASSLEN]; setutmpmode(IDLE); getdata(b_lines - 1, 0, "²z¥Ñ¡G[0]µo§b (1)±µ¹q¸Ü (2)³V­¹ (3)¥´½OºÎ " @@ -2453,10 +2441,8 @@ t_idle(void) do { move(b_lines - 2, 0); clrtoeol(); - snprintf(buf, sizeof(buf), - "(Âê©w¿Ã¹õ)µo§b­ì¦]: %s", (currutmp->destuid != 6) ? + prints("(Âê©w¿Ã¹õ)µo§b­ì¦]: %s", (currutmp->destuid != 6) ? IdleTypeTable[currutmp->destuid] : currutmp->chatid); - outs(buf); refresh(); getdata(b_lines - 1, 0, MSG_PASSWD, passbuf, sizeof(passbuf), NOECHO); passbuf[8] = '\0'; diff --git a/pttbbs/mbbsd/user.c b/pttbbs/mbbsd/user.c index 8849b9ff..c3e63595 100644 --- a/pttbbs/mbbsd/user.c +++ b/pttbbs/mbbsd/user.c @@ -835,9 +835,8 @@ getfield(int line, char *info, char *desc, char *buf, int len) char prompt[STRLEN]; char genbuf[200]; - snprintf(genbuf, sizeof(genbuf), "­ì¥ý³]©w¡G%-30.30s (%s)", buf, info); move(line, 2); - outs(genbuf); + prints("­ì¥ý³]©w¡G%-30.30s (%s)", buf, info); snprintf(prompt, sizeof(prompt), "%s¡G", desc); if (getdata_str(line + 1, 2, prompt, genbuf, len, DOECHO, buf)) strcpy(buf, genbuf); diff --git a/pttbbs/mbbsd/var.c b/pttbbs/mbbsd/var.c index 277bef8d..5125442e 100644 --- a/pttbbs/mbbsd/var.c +++ b/pttbbs/mbbsd/var.c @@ -312,9 +312,6 @@ char *ModeTypeTable[MAX_MODES] = { "" }; -/* indict.c */ -char dict[41], database[41]; - /* term.c */ int b_lines = 23; int t_lines = 24; diff --git a/pttbbs/mbbsd/voteboard.c b/pttbbs/mbbsd/voteboard.c index d477a12d..a0db074e 100644 --- a/pttbbs/mbbsd/voteboard.c +++ b/pttbbs/mbbsd/voteboard.c @@ -1,4 +1,4 @@ -/* $Id: voteboard.c,v 1.18 2003/06/28 08:47:45 kcwu Exp $ */ +/* $Id$ */ #include "bbs.h" #define VOTEBOARD "NewBoard" diff --git a/pttbbs/mbbsd/xyz.c b/pttbbs/mbbsd/xyz.c index aead7e5d..e0b850b5 100644 --- a/pttbbs/mbbsd/xyz.c +++ b/pttbbs/mbbsd/xyz.c @@ -7,9 +7,7 @@ int x_90() { - strcpy(dict, "(90)­ã¦ÒÃÒ¸¹/©m¦W/¾Ç®Õ/¬ì¨t/Ãþ²Õ"); - strcpy(database, "etc/90"); - use_dict(); + use_dict("(90)­ã¦ÒÃÒ¸¹/©m¦W/¾Ç®Õ/¬ì¨t/Ãþ²Õ", "etc/90"); return 0; } @@ -17,27 +15,21 @@ x_90() int x_89() { - strcpy(dict, "(89)­ã¦ÒÃÒ¸¹/©m¦W/¾Ç®Õ/¬ì¨t/Ãþ²Õ"); - strcpy(database, "etc/89"); - use_dict(); + use_dict("(89)­ã¦ÒÃÒ¸¹/©m¦W/¾Ç®Õ/¬ì¨t/Ãþ²Õ", "etc/89"); return 0; } /* Ptt88¦~«×¤j¾ÇÁp©Û¬dº]¨t²Î */ int x_88() { - strcpy(dict, "(88)­ã¦ÒÃÒ¸¹/©m¦W/¾Ç®Õ/¬ì¨t/Ãþ²Õ"); - strcpy(database, "etc/88"); - use_dict(); + use_dict("(88)­ã¦ÒÃÒ¸¹/©m¦W/¾Ç®Õ/¬ì¨t/Ãþ²Õ", "etc/88"); return 0; } /* Ptt87¦~«×¤j¾ÇÁp©Û¬dº]¨t²Î */ int x_87() { - strcpy(dict, "(87)­ã¦ÒÃÒ¸¹/©m¦W/¾Ç®Õ/¬ì¨t"); - strcpy(database, "etc/87"); - use_dict(); + use_dict("(87)­ã¦ÒÃÒ¸¹/©m¦W/¾Ç®Õ/¬ì¨t", "etc/87"); return 0; } @@ -45,9 +37,7 @@ x_87() int x_86() { - strcpy(dict, "(86)­ã¦ÒÃÒ¸¹/©m¦W/¾Ç®Õ/¬ì¨t"); - strcpy(database, "etc/86"); - use_dict(); + use_dict("(86)­ã¦ÒÃÒ¸¹/©m¦W/¾Ç®Õ/¬ì¨t", "etc/86"); return 0; } -- cgit v1.2.3