diff options
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/admin.c | 18 | ||||
-rw-r--r-- | mbbsd/announce.c | 26 | ||||
-rw-r--r-- | mbbsd/assess.c | 2 | ||||
-rw-r--r-- | mbbsd/bbs.c | 94 | ||||
-rw-r--r-- | mbbsd/board.c | 4 | ||||
-rw-r--r-- | mbbsd/brc.c | 2 | ||||
-rw-r--r-- | mbbsd/cache.c | 16 | ||||
-rw-r--r-- | mbbsd/cal.c | 6 | ||||
-rw-r--r-- | mbbsd/calendar.c | 2 | ||||
-rw-r--r-- | mbbsd/chat.c | 26 | ||||
-rw-r--r-- | mbbsd/chc.c | 24 | ||||
-rw-r--r-- | mbbsd/chicken.c | 8 | ||||
-rw-r--r-- | mbbsd/dice.c | 4 | ||||
-rw-r--r-- | mbbsd/edit.c | 8 | ||||
-rw-r--r-- | mbbsd/file.c | 10 | ||||
-rw-r--r-- | mbbsd/friend.c | 14 | ||||
-rw-r--r-- | mbbsd/gamble.c | 6 | ||||
-rw-r--r-- | mbbsd/guess.c | 4 | ||||
-rw-r--r-- | mbbsd/indict.c | 2 | ||||
-rw-r--r-- | mbbsd/io.c | 14 | ||||
-rw-r--r-- | mbbsd/kaede.c | 6 | ||||
-rw-r--r-- | mbbsd/mail.c | 52 | ||||
-rw-r--r-- | mbbsd/mbbsd.c | 30 | ||||
-rw-r--r-- | mbbsd/menu.c | 4 | ||||
-rw-r--r-- | mbbsd/more.c | 2 | ||||
-rw-r--r-- | mbbsd/name.c | 33 | ||||
-rw-r--r-- | mbbsd/passwd.c | 2 | ||||
-rw-r--r-- | mbbsd/read.c | 23 | ||||
-rw-r--r-- | mbbsd/record.c | 37 | ||||
-rw-r--r-- | mbbsd/register.c | 8 | ||||
-rw-r--r-- | mbbsd/screen.c | 12 | ||||
-rw-r--r-- | mbbsd/stuff.c | 91 | ||||
-rw-r--r-- | mbbsd/syspost.c | 12 | ||||
-rw-r--r-- | mbbsd/talk.c | 35 | ||||
-rw-r--r-- | mbbsd/user.c | 18 | ||||
-rw-r--r-- | mbbsd/var.c | 4 | ||||
-rw-r--r-- | mbbsd/vice.c | 6 | ||||
-rw-r--r-- | mbbsd/vote.c | 20 | ||||
-rw-r--r-- | mbbsd/voteboard.c | 2 |
39 files changed, 346 insertions, 341 deletions
diff --git a/mbbsd/admin.c b/mbbsd/admin.c index 7d024957..ea175e90 100644 --- a/mbbsd/admin.c +++ b/mbbsd/admin.c @@ -53,7 +53,7 @@ m_user(void) } static int -search_key_user(char *passwdfile, int mode) +search_key_user(const char *passwdfile, int mode) { userec_t user; int ch; @@ -211,14 +211,14 @@ search_user_bybakpwd(void) } static void -bperm_msg(boardheader_t * board) +bperm_msg(const boardheader_t * board) { prints("\n設定 [%s] 看板之(%s)權限:", board->brdname, board->brdattr & BRD_POSTMASK ? "發表" : "閱\讀"); } unsigned int -setperms(unsigned int pbits, char * const pstring[]) +setperms(unsigned int pbits, const char * const pstring[]) { register int i; @@ -311,7 +311,7 @@ AddingChessCountryFiles(const char* apath) /* 自動設立精華區 */ void -setup_man(boardheader_t * board, boardheader_t * oldboard) +setup_man(const boardheader_t * board, const boardheader_t * oldboard) { char genbuf[200]; @@ -341,7 +341,7 @@ int dir_cmp(const void *a, const void *b) atoi( &((fileheader_t *)b)->filename[2] )); } -void merge_dir(char *dir1, char *dir2, int isoutter) +void merge_dir(const char *dir1, const char *dir2, int isoutter) { int i, pn, sn; fileheader_t *fh; @@ -781,7 +781,7 @@ x_file(void) return FULLUPDATE; } -static int add_board_record(boardheader_t *board) +static int add_board_record(const boardheader_t *board) { int bid; if ((bid = getbnum("")) > 0) { @@ -897,7 +897,7 @@ m_newbrd(int recover) return 0; } -int make_symbolic_link(char *bname, int gid) +int make_symbolic_link(const char *bname, int gid) { boardheader_t newboard; int bid; @@ -1036,7 +1036,7 @@ auto_scan(char fdata[][STRLEN], char ans[]) /* 處理 Register Form */ int -scan_register_form(char *regfile, int automode, int neednum) +scan_register_form(const char *regfile, int automode, int neednum) { char genbuf[200]; char *logfile = "register.log"; @@ -1347,7 +1347,7 @@ cat_register(void) } static void -give_id_money(char *user_id, int money, FILE * log_fp, char *mail_title, time4_t t) +give_id_money(const char *user_id, int money, FILE * log_fp, const char *mail_title, time4_t t) { char tt[TTLEN + 1] = {0}; diff --git a/mbbsd/announce.c b/mbbsd/announce.c index 7c2954ec..927d999e 100644 --- a/mbbsd/announce.c +++ b/mbbsd/announce.c @@ -11,7 +11,7 @@ struct CopyTmp { static struct CopyTmp *copytmp; void -a_copyitem(char *fpath, char *title, char *owner, int mode) +a_copyitem(const char *fpath, const char *title, const char *owner, int mode) { if(copytmp == NULL) { copytmp = (struct CopyTmp*)malloc(sizeof(struct CopyTmp)); @@ -36,7 +36,7 @@ a_copyitem(char *fpath, char *title, char *owner, int mode) #define FHSZ sizeof(fileheader_t) static void -a_loadname(menu_t * pm) +a_loadname(const menu_t * pm) { char buf[PATHLEN]; int len; @@ -48,7 +48,7 @@ a_loadname(menu_t * pm) } static void -a_timestamp(char *buf, time4_t *time) +a_timestamp(char *buf, const time4_t *time) { struct tm *pt = localtime4(time); @@ -56,7 +56,7 @@ a_timestamp(char *buf, time4_t *time) } static void -a_showmenu(menu_t * pm) +a_showmenu(const menu_t * pm) { char *title, *editor; int n; @@ -167,7 +167,7 @@ a_showhelp(int level) } static void -a_forward(char *path, fileheader_t * pitem, int mode) +a_forward(const char *path, const fileheader_t * pitem, int mode) { fileheader_t fhdr; @@ -187,7 +187,7 @@ a_forward(char *path, fileheader_t * pitem, int mode) } static void -a_additem(menu_t * pm, fileheader_t * myheader) +a_additem(menu_t * pm, const fileheader_t * myheader) { char buf[PATHLEN]; @@ -381,7 +381,7 @@ a_pasteitem(menu_t * pm, int mode) } static void -a_appenditem(menu_t * pm, int isask) +a_appenditem(const menu_t * pm, int isask) { char fname[PATHLEN]; char buf[ANSILINELEN]; @@ -614,7 +614,7 @@ a_delete(menu_t * pm) } static void -a_newtitle(menu_t * pm) +a_newtitle(const menu_t * pm) { char buf[PATHLEN]; fileheader_t item; @@ -628,7 +628,7 @@ a_newtitle(menu_t * pm) } } static void -a_hideitem(menu_t * pm) +a_hideitem(const menu_t * pm) { fileheader_t *item = &pm->header[pm->now - pm->page]; char buf[PATHLEN]; @@ -643,7 +643,7 @@ a_hideitem(menu_t * pm) substitute_record(buf, item, FHSZ, pm->now + 1); } static void -a_editsign(menu_t * pm) +a_editsign(const menu_t * pm) { char buf[PATHLEN]; fileheader_t item; @@ -660,7 +660,7 @@ a_editsign(menu_t * pm) } static void -a_showname(menu_t * pm) +a_showname(const menu_t * pm) { char buf[PATHLEN]; int len; @@ -714,7 +714,7 @@ atitle(void) #endif static int -isvisible_man(menu_t * me) +isvisible_man(const menu_t * me) { fileheader_t *fhdr = &me->header[me->now - me->page]; if (me->level < MANAGER && ((fhdr->filemode & FILE_BM) || @@ -728,7 +728,7 @@ isvisible_man(menu_t * me) return 1; } int -a_menu(char *maintitle, char *path, int lastlevel, char *trans_buffer) +a_menu(const char *maintitle, char *path, int lastlevel, char *trans_buffer) { static char Fexit; // 用來跳出 recursion menu_t me; diff --git a/mbbsd/assess.c b/mbbsd/assess.c index f79053af..6b21ff29 100644 --- a/mbbsd/assess.c +++ b/mbbsd/assess.c @@ -35,7 +35,7 @@ modify_column(goodsale); /* inc_goodsale */ modify_column(badsale); /* inc_badsale */ #if 0 //unused function -void set_assess(char *userid, unsigned char num, int type) +void set_assess(const char *userid, unsigned char num, int type) { userec_t xuser; int uid = getuser(userid, &xuser); diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index cf6a51c7..8798cdb6 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -3,8 +3,8 @@ #define WHEREAMI_LEVEL 16 -static int recommend(int ent, fileheader_t * fhdr, char *direct); -int mailalert(char *userid); +static int recommend(int ent, fileheader_t * fhdr, const char *direct); +int mailalert(const char *userid); #ifdef ASSESS static char * const badpost_reason[] = { @@ -185,12 +185,12 @@ readdoent(int num, fileheader_t * ent) else if (ent->filemode & FILE_SOLVED) type = (type == ' ') ? 's': 'S'; } - title = subject(mark = ent->title); + title = subject(ent->title); if (ent->filemode & FILE_VOTE) color = '2', mark = "ˇ"; else if (ent->filemode & FILE_BID) color = '6', mark = "$"; - else if (title == mark) + else if (title == ent->title) color = '1', mark = "□"; else color = '3', mark = "R:"; @@ -249,7 +249,7 @@ readdoent(int num, fileheader_t * ent) } int -whereami(int ent, fileheader_t * fhdr, char *direct) +whereami(int ent, const fileheader_t * fhdr, const char *direct) { boardheader_t *bh, *p[WHEREAMI_LEVEL], *root; int i, j; @@ -277,7 +277,7 @@ whereami(int ent, fileheader_t * fhdr, char *direct) static int -do_select(int ent, fileheader_t * fhdr, char *direct) +do_select(int ent, const fileheader_t * fhdr, const char *direct) { char bname[20]; char bpath[60]; @@ -320,7 +320,7 @@ do_select(int ent, fileheader_t * fhdr, char *direct) /* 改良 innbbsd 轉出信件、連線砍信之處理程序 */ /* ----------------------------------------------------- */ void -outgo_post(fileheader_t *fh, char *board, char *userid, char *username) +outgo_post(const fileheader_t *fh, const char *board, const char *userid, const char *username) { FILE *foo; @@ -332,7 +332,7 @@ outgo_post(fileheader_t *fh, char *board, char *userid, char *username) } static void -cancelpost(fileheader_t *fh, int by_BM, char *newpath) +cancelpost(const fileheader_t *fh, int by_BM, char *newpath) { FILE *fin, *fout; char *ptr, *brd; @@ -382,7 +382,7 @@ cancelpost(fileheader_t *fh, int by_BM, char *newpath) /* 發表、回應、編輯、轉錄文章 */ /* ----------------------------------------------------- */ void -do_reply_title(int row, char *title) +do_reply_title(int row, const char *title) { char genbuf[200]; char genbuf2[4]; @@ -399,7 +399,7 @@ do_reply_title(int row, char *title) } /* static void -do_unanonymous_post(char *fpath) +do_unanonymous_post(const char *fpath) { fileheader_t mhdr; char title[128]; @@ -427,7 +427,7 @@ static time4_t water_counts = 0; #endif void -do_crosspost(char *brd, fileheader_t *postfile, const char *fpath) +do_crosspost(const char *brd, fileheader_t *postfile, const char *fpath) { char genbuf[200]; int len = 42-strlen(currboard); @@ -808,7 +808,7 @@ do_post_openbid(void) } static void -do_generalboardreply(fileheader_t * fhdr) +do_generalboardreply(const fileheader_t * fhdr) { char genbuf[3]; @@ -848,7 +848,7 @@ do_generalboardreply(fileheader_t * fhdr) int -invalid_brdname(char *brd) +invalid_brdname(const char *brd) { register char ch, rv=0; @@ -863,7 +863,7 @@ invalid_brdname(char *brd) } static int -b_call_in(int ent, fileheader_t * fhdr, char *direct) +b_call_in(int ent, const fileheader_t * fhdr, const char *direct) { userinfo_t *u = search_ulist(searchuser(fhdr->owner, NULL)); if (u) { @@ -877,7 +877,7 @@ b_call_in(int ent, fileheader_t * fhdr, char *direct) static int -b_posttype(int ent, fileheader_t * fhdr, char *direct) +b_posttype(int ent, const fileheader_t * fhdr, const char *direct) { boardheader_t *bp; int i, aborted; @@ -927,7 +927,7 @@ b_posttype(int ent, fileheader_t * fhdr, char *direct) } static int -do_reply(fileheader_t * fhdr) +do_reply(const fileheader_t * fhdr) { boardheader_t *bp; if (!CheckPostPerm() ) return DONOTHING; @@ -953,13 +953,13 @@ do_reply(fileheader_t * fhdr) } static int -reply_post(int ent, fileheader_t * fhdr, char *direct) +reply_post(int ent, const fileheader_t * fhdr, const char *direct) { return do_reply(fhdr); } static int -edit_post(int ent, fileheader_t * fhdr, char *direct) +edit_post(int ent, fileheader_t * fhdr, const char *direct) { char fpath[80]; char genbuf[200]; @@ -1008,7 +1008,7 @@ edit_post(int ent, fileheader_t * fhdr, char *direct) #define UPDATE_USEREC (currmode |= MODE_DIRTY) static int -cross_post(int ent, fileheader_t * fhdr, char *direct) +cross_post(int ent, const fileheader_t * fhdr, const char *direct) { char xboard[20], fname[80], xfpath[80], xtitle[80]; char inputbuf[10], genbuf[200], genbuf2[4]; @@ -1142,7 +1142,7 @@ cross_post(int ent, fileheader_t * fhdr, char *direct) } static int -read_post(int ent, fileheader_t * fhdr, char *direct) +read_post(int ent, fileheader_t * fhdr, const char *direct) { char genbuf[200]; int more_result; @@ -1172,7 +1172,7 @@ read_post(int ent, fileheader_t * fhdr, char *direct) } int -do_limitedit(int ent, fileheader_t * fhdr, char *direct) +do_limitedit(int ent, fileheader_t * fhdr, const char *direct) { char genbuf[256], buf[256]; int temp; @@ -1314,7 +1314,7 @@ stop_gamble(void) return 1; } static int -join_gamble(int ent, fileheader_t * fhdr, char *direct) +join_gamble(int ent, const fileheader_t * fhdr, const char *direct) { if (!HAS_PERM(PERM_LOGINOK)) return DONOTHING; @@ -1326,7 +1326,7 @@ join_gamble(int ent, fileheader_t * fhdr, char *direct) return FULLUPDATE; } static int -hold_gamble(int ent, fileheader_t * fhdr, char *direct) +hold_gamble(int ent, const fileheader_t * fhdr, const char *direct) { char fn_ticket[128], fn_ticket_end[128], genbuf[128], msg[256] = "", yn[10] = ""; @@ -1428,7 +1428,7 @@ hold_gamble(int ent, fileheader_t * fhdr, char *direct) #endif static int -cite_post(int ent, fileheader_t * fhdr, char *direct) +cite_post(int ent, const fileheader_t * fhdr, const char *direct) { char fpath[256]; char title[TTLEN + 1]; @@ -1443,7 +1443,7 @@ cite_post(int ent, fileheader_t * fhdr, char *direct) } int -edit_title(int ent, fileheader_t * fhdr, char *direct) +edit_title(int ent, fileheader_t * fhdr, const char *direct) { char genbuf[200]; fileheader_t tmpfhdr = *fhdr; @@ -1477,7 +1477,7 @@ edit_title(int ent, fileheader_t * fhdr, char *direct) } static int -solve_post(int ent, fileheader_t * fhdr, char *direct) +solve_post(int ent, fileheader_t * fhdr, const char *direct) { if ((currmode & MODE_BOARD)) { fhdr->filemode ^= FILE_SOLVED; @@ -1489,7 +1489,7 @@ solve_post(int ent, fileheader_t * fhdr, char *direct) static int -recommend_cancel(int ent, fileheader_t * fhdr, char *direct) +recommend_cancel(int ent, fileheader_t * fhdr, const char *direct) { char yn[5]; if (!(currmode & MODE_BOARD)) @@ -1509,8 +1509,8 @@ recommend_cancel(int ent, fileheader_t * fhdr, char *direct) } static int -do_add_recommend(char *direct, fileheader_t *fhdr, - int ent, char *buf, int type) +do_add_recommend(const char *direct, fileheader_t *fhdr, + int ent, const char *buf, int type) { char path[256]; int update = 0; @@ -1556,8 +1556,8 @@ do_add_recommend(char *direct, fileheader_t *fhdr, } static int -do_bid(int ent, fileheader_t * fhdr, boardheader_t *bp, - char *direct, struct tm *ptime) +do_bid(int ent, fileheader_t * fhdr, const boardheader_t *bp, + const char *direct, const struct tm *ptime) { char genbuf[200], fpath[256],say[30],*money; bid_t bidinfo; @@ -1710,7 +1710,7 @@ do_bid(int ent, fileheader_t * fhdr, boardheader_t *bp, } static int -recommend(int ent, fileheader_t * fhdr, char *direct) +recommend(int ent, fileheader_t * fhdr, const char *direct) { struct tm *ptime = localtime4(&now); char buf[200], msg[53], @@ -1799,7 +1799,7 @@ recommend(int ent, fileheader_t * fhdr, char *direct) } static int -mark_post(int ent, fileheader_t * fhdr, char *direct) +mark_post(int ent, fileheader_t * fhdr, const char *direct) { char buf[STRLEN], fpath[STRLEN]; @@ -1831,7 +1831,7 @@ mark_post(int ent, fileheader_t * fhdr, char *direct) } int -del_range(int ent, fileheader_t *fhdr, char *direct) +del_range(int ent, const fileheader_t *fhdr, const char *direct) { char num1[8], num2[8]; int inum1, inum2; @@ -1996,7 +1996,7 @@ del_post(int ent, fileheader_t * fhdr, char *direct) } static int // Ptt: 修石頭文 -show_filename(int ent, fileheader_t * fhdr, char *direct) +show_filename(int ent, const fileheader_t * fhdr, const char *direct) { if(!HAS_PERM(PERM_SYSOP)) return DONOTHING; @@ -2005,7 +2005,7 @@ show_filename(int ent, fileheader_t * fhdr, char *direct) } static int -view_postmoney(int ent, fileheader_t * fhdr, char *direct) +view_postmoney(int ent, const fileheader_t * fhdr, const char *direct) { if(currmode & MODE_SELECT){ vmsg("請在離開目前的選擇模式再查詢"); @@ -2024,7 +2024,7 @@ view_postmoney(int ent, fileheader_t * fhdr, char *direct) #ifdef OUTJOBSPOOL /* 看板備份 */ static int -tar_addqueue(int ent, fileheader_t * fhdr, char *direct) +tar_addqueue(int ent, const fileheader_t * fhdr, const char *direct) { char email[60], qfn[80], ans[2]; FILE *fp; @@ -2146,7 +2146,7 @@ sequent_messages(void * voidfptr, void *optarg) } static int -sequential_read(int ent, fileheader_t * fhdr, char *direct) +sequential_read(int ent, const fileheader_t * fhdr, const char *direct) { char buf[40]; struct SeqReadArg arg; @@ -2336,7 +2336,7 @@ board_digest(void) static int -push_bottom(int ent, fileheader_t *fhdr, char *direct) +push_bottom(int ent, fileheader_t *fhdr, const char *direct) { int num; char buf[256]; @@ -2367,7 +2367,7 @@ push_bottom(int ent, fileheader_t *fhdr, char *direct) } static int -good_post(int ent, fileheader_t * fhdr, char *direct) +good_post(int ent, fileheader_t * fhdr, const char *direct) { char genbuf[200]; char genbuf2[200]; @@ -2442,7 +2442,7 @@ b_help(void) } static int -b_changerecommend(int ent, fileheader_t * fhdr, char *direct) +b_changerecommend(int ent, const fileheader_t * fhdr, const char *direct) { boardheader_t *bp=NULL; if (!((currmode & MODE_BOARD) || HAS_PERM(PERM_SYSOP))) @@ -2477,7 +2477,7 @@ b_changerecommend(int ent, fileheader_t * fhdr, char *direct) char board_hidden_status; #ifdef BMCHS static int -change_hidden(int ent, fileheader_t * fhdr, char *direct) +change_hidden(int ent, const fileheader_t * fhdr, const char *direct) { boardheader_t *bp; if (!((currmode & MODE_BOARD) || HAS_PERM(PERM_SYSOP))) @@ -2507,7 +2507,7 @@ change_hidden(int ent, fileheader_t * fhdr, char *direct) } static int -change_counting(int ent, fileheader_t * fhdr, char *direct) +change_counting(int ent, const fileheader_t * fhdr, const char *direct) { boardheader_t *bp; @@ -2539,7 +2539,7 @@ change_counting(int ent, fileheader_t * fhdr, char *direct) * 改變目前所在板文章的預設儲存方式 */ static int -change_localsave(int ent, fileheader_t * fhdr, char *direct) +change_localsave(int ent, const fileheader_t * fhdr, const char *direct) { boardheader_t *bp; if (!((currmode & MODE_BOARD) || HAS_PERM(PERM_SYSOP))) @@ -2593,7 +2593,7 @@ change_restrictedpost(int ent, fileheader_t * fhdr, char *direct){ * 設定看板冷靜功能, 限制使用者發文時間 */ static int -change_cooldown(int ent, fileheader_t * fhdr, char *direct) +change_cooldown(int ent, const fileheader_t * fhdr, const char *direct) { boardheader_t *bp = getbcache(currbid); @@ -2787,7 +2787,7 @@ ReadSelect(void) #ifdef LOG_BOARD static void -log_board(char *mode, time4_t usetime) +log_board(iconst char *mode, time4_t usetime) { if (usetime > 30) { log_file(FN_USEBOARD, LOG_CREAT | LOG_VF, @@ -2808,7 +2808,7 @@ Select(void) #ifdef HAVEMOBILE void -mobile_message(char *mobile, char *message) +mobile_message(const char *mobile, char *message) { bsmtp(char *fpath, char *title, char *rcpt, int method); } diff --git a/mbbsd/board.c b/mbbsd/board.c index 1364eaf6..c81411a8 100644 --- a/mbbsd/board.c +++ b/mbbsd/board.c @@ -36,11 +36,11 @@ static char yank_flag = 1; #define IS_LISTING_BRD() (yank_flag == 1) #define IS_LISTING_GUEST() (yank_flag == 2) -inline int getbid(boardheader_t *fh) +inline int getbid(const boardheader_t *fh) { return (fh - bcache); } -inline boardheader_t *getparent(boardheader_t *fh) +inline boardheader_t *getparent(const boardheader_t *fh) { if(fh->parent>0) return &bcache[fh->parent-1]; diff --git a/mbbsd/brc.c b/mbbsd/brc.c index 151501d7..0ffbc9bc 100644 --- a/mbbsd/brc.c +++ b/mbbsd/brc.c @@ -182,7 +182,7 @@ brc_get_buf(int size){ } static inline void -brc_insert_record(brcbid_t bid, brcnbrd_t num, time4_t* list) +brc_insert_record(brcbid_t bid, brcnbrd_t num, const time4_t* list) { char *ptr; int new_size, end_size; diff --git a/mbbsd/cache.c b/mbbsd/cache.c index 98a06563..7ec29f32 100644 --- a/mbbsd/cache.c +++ b/mbbsd/cache.c @@ -35,7 +35,7 @@ safe_sleep(unsigned int seconds) * section - SHM */ static void -attach_err(int shmkey, char *name) +attach_err(int shmkey, const char *name) { fprintf(stderr, "[%s error] key = %x\n", name, shmkey); fprintf(stderr, "errno = %d: %s\n", errno, strerror(errno)); @@ -149,7 +149,7 @@ sem_lock(int op, int semid) */ void -add_to_uhash(int n, char *id) +add_to_uhash(int n, const char *id) { int *p, h = StringHash(id)%(1<<HASH_BITS); int times; @@ -210,7 +210,7 @@ searchuser(const char *userid, char *rightid) } int -getuser(char *userid, userec_t *xuser) +getuser(const char *userid, userec_t *xuser) { int uid; @@ -230,7 +230,7 @@ getuserid(int num) } void -setuserid(int num, char *userid) +setuserid(int num, const char *userid) { if (num > 0 && num <= MAX_USERS) { /* Ptt: it may cause problems @@ -276,7 +276,7 @@ u_namearray(char buf[][IDLEN + 1], int *pnum, char *tag) #endif void -getnewutmpent(userinfo_t * up) +getnewutmpent(const userinfo_t * up) { /* Ptt:這裡加上 hash 觀念找空的 utmp */ register int i; @@ -296,7 +296,7 @@ getnewutmpent(userinfo_t * up) } int -apply_ulist(int (*fptr) (userinfo_t *)) +apply_ulist(int (*fptr) (const userinfo_t *)) { register userinfo_t *uentp; register int i, state; @@ -373,7 +373,7 @@ search_ulistn(int uid, int unum) } userinfo_t * -search_ulist_userid(char *userid) +search_ulist_userid(const char *userid) { register int i = 0, j, start = 0, end = SHM->UTMPnumber - 1; int *ulist; @@ -744,7 +744,7 @@ getbnum(const char *bname) } int -haspostperm(char *bname) +haspostperm(const char *bname) { register int i; char buf[200]; diff --git a/mbbsd/cal.c b/mbbsd/cal.c index 1b2c054e..d2119f36 100644 --- a/mbbsd/cal.c +++ b/mbbsd/cal.c @@ -60,7 +60,7 @@ unlockutmpmode(void) /* Heat:發票 */ int -vice(int money, char *item) +vice(int money, const char *item) { char buf[128]; unsigned int viceserial = (currutmp->lastact % 10000) * 10000 + random() % 10000; @@ -84,7 +84,7 @@ vice(int money, char *item) #define OSONGPATH "etc/SONGO" static int -osong(char *defaultid) +osong(const char *defaultid) { char destid[IDLEN + 1], buf[200], genbuf[200], filename[256], say[51]; @@ -321,7 +321,7 @@ p_exmail(void) } void -mail_redenvelop(char *from, char *to, int money, char mode) +mail_redenvelop(const char *from, const char *to, int money, char mode) { char genbuf[200]; fileheader_t fhdr; diff --git a/mbbsd/calendar.c b/mbbsd/calendar.c index 385b9f82..f3cafca2 100644 --- a/mbbsd/calendar.c +++ b/mbbsd/calendar.c @@ -60,7 +60,7 @@ ParseDate(char *date, event_t * t) } static int -ParseColor(char *color) +ParseColor(const char *color) { struct { char *str; diff --git a/mbbsd/chat.c b/mbbsd/chat.c index 59cacb4b..fc91a379 100644 --- a/mbbsd/chat.c +++ b/mbbsd/chat.c @@ -5,7 +5,7 @@ static int chatline; static FILE *flog; static void -printchatline(char *str) +printchatline(const char *str) { move(chatline, 0); if (*str == '>' && !PERM_HIDE(currutmp)) @@ -25,7 +25,7 @@ printchatline(char *str) } static void -chat_clear(void) +chat_clear(char*unused) { for (chatline = 2; chatline < STOP_LINE; chatline++) { move(chatline, 0); @@ -38,7 +38,7 @@ chat_clear(void) } static void -print_chatid(char *chatid) +print_chatid(const char *chatid) { move(b_lines - 1, 0); clrtoeol(); @@ -47,7 +47,7 @@ print_chatid(char *chatid) } static int -chat_send(int fd, char *buf) +chat_send(int fd, const char *buf) { int len; char genbuf[200]; @@ -63,7 +63,7 @@ struct ChatBuf { }; static int -chat_recv(struct ChatBuf *cb, int fd, char chatroom[IDLEN], char *chatid) +chat_recv(struct ChatBuf *cb, int fd, char *chatroom, char *chatid) { int c, len; char *bptr; @@ -82,7 +82,7 @@ chat_recv(struct ChatBuf *cb, int fd, char chatroom[IDLEN], char *chatid) if (*bptr == '/') { switch (bptr[1]) { case 'c': - chat_clear(); + chat_clear(NULL); break; case 'n': strncpy(chatid, bptr + 2, 8); @@ -114,7 +114,7 @@ chat_recv(struct ChatBuf *cb, int fd, char chatroom[IDLEN], char *chatid) } static int -printuserent(userinfo_t * uentp) +printuserent(const userinfo_t * uentp) { static char uline[80]; static int cnt; @@ -145,7 +145,7 @@ printuserent(userinfo_t * uentp) } static void -chathelp(char *cmd, char *desc) +chathelp(const char *cmd, const char *desc) { char buf[STRLEN]; @@ -185,7 +185,7 @@ chat_help(char *arg) } static void -chat_date(void) +chat_date(char *unused) { char genbuf[200]; @@ -195,7 +195,7 @@ chat_date(void) } static void -chat_pager(void) +chat_pager(char *unused) { char genbuf[200]; @@ -243,7 +243,7 @@ chat_query(char *arg) } static void -chat_users(void) +chat_users(char* unused) { printchatline(""); printchatline("【 " BBSNAME "的遊客列表 】"); @@ -256,7 +256,7 @@ chat_users(void) typedef struct chat_command_t { char *cmdname; /* Chatroom command length */ - void (*cmdfunc) (); /* Pointer to function */ + void (*cmdfunc) (char *); /* Pointer to function */ } chat_command_t; static const chat_command_t chat_cmdtbl[] = { @@ -270,7 +270,7 @@ static const chat_command_t chat_cmdtbl[] = { }; static int -chat_cmd_match(char *buf, char *str) +chat_cmd_match(const char *buf, const char *str) { while (*str && *buf && !isspace((int)*buf)) if (tolower(*buf++) != *str++) diff --git a/mbbsd/chc.c b/mbbsd/chc.c index b0d075d9..1b664aea 100644 --- a/mbbsd/chc.c +++ b/mbbsd/chc.c @@ -20,7 +20,7 @@ enum Kind { #define CHC_TIMEOUT 300 #define CHC_LOG "chc_log" /* log file name */ -typedef int (*play_func_t) (int, chcusr_t *, chcusr_t *, board_t, board_t); +typedef int (*play_func_t) (int, const chcusr_t *, const chcusr_t *, board_t, board_t); typedef struct drc_t { rc_t from, to; @@ -172,7 +172,7 @@ chc_movecur(int r, int c) } static char * -getstep(board_t board, rc_t *from, rc_t *to, char buf[]) +getstep(board_t board, const rc_t *from, const rc_t *to, char buf[]) { int turn, fc, tc; char *dir; @@ -237,7 +237,7 @@ showstep(board_t board) } static void -chc_drawline(board_t board, chcusr_t *user1, chcusr_t *user2, int line) +chc_drawline(board_t board, const chcusr_t *user1, const chcusr_t *user2, int line) { int i, j; @@ -314,7 +314,7 @@ chc_drawline(board_t board, chcusr_t *user1, chcusr_t *user2, int line) } static void -chc_redraw(chcusr_t *user1, chcusr_t *user2, board_t board) +chc_redraw(const chcusr_t *user1, const chcusr_t *user2, board_t board) { int i; for (i = 0; i <= 22; i++) @@ -329,7 +329,7 @@ chc_redraw(chcusr_t *user1, chcusr_t *user2, board_t board) * Start of the log function. */ int -chc_log_open(chcusr_t *user1, chcusr_t *user2, char *file) +chc_log_open(const chcusr_t *user1, const chcusr_t *user2, const char *file) { char buf[128]; if ((chcd->chessfp = fopen(file, "w")) == NULL) @@ -352,7 +352,7 @@ chc_log_close(void) } int -chc_log(char *desc) +chc_log(const char *desc) { if (chcd->chessfp) return fputs(desc, chcd->chessfp); @@ -360,7 +360,7 @@ chc_log(char *desc) } int -chc_log_step(board_t board, rc_t *from, rc_t *to) +chc_log_step(board_t board, const rc_t *from, const rc_t *to) { char buf[80]; sprintf(buf, " %s\n", chcd->last_movestr); @@ -613,7 +613,7 @@ chc_ischeck(board_t board, int turn) */ static void -chcusr_put(userec_t *userec, chcusr_t *user) +chcusr_put(userec_t *userec, const chcusr_t *user) { userec->chc_win = user->win; userec->chc_lose = user->lose; @@ -622,7 +622,7 @@ chcusr_put(userec_t *userec, chcusr_t *user) } static void -chcusr_get(userec_t *userec, chcusr_t *user) +chcusr_get(const userec_t *userec, chcusr_t *user) { strlcpy(user->userid, userec->userid, sizeof(user->userid)); user->win = userec->chc_win; @@ -635,7 +635,7 @@ chcusr_get(userec_t *userec, chcusr_t *user) } static int -hisplay(int s, chcusr_t *user1, chcusr_t *user2, board_t board, board_t tmpbrd) +hisplay(int s, const chcusr_t *user1, const chcusr_t *user2, board_t board, board_t tmpbrd) { int start_time; int endgame = 0, endturn = 0; @@ -712,7 +712,7 @@ hisplay(int s, chcusr_t *user1, chcusr_t *user2, board_t board, board_t tmpbrd) } static int -myplay(int s, chcusr_t *user1, chcusr_t *user2, board_t board, board_t tmpbrd) +myplay(int s, const chcusr_t *user1, const chcusr_t *user2, board_t board, board_t tmpbrd) { int ch, start_time; int endgame = 0, endturn = 0; @@ -829,7 +829,7 @@ int round_to_int(double x) * see http://www.wordiq.com/definition/ELO_rating_system */ static void -count_chess_elo_rating(chcusr_t *user1, chcusr_t *user2, double myres) +count_chess_elo_rating(chcusr_t *user1, const chcusr_t *user2, double myres) { double k; double exp_res; diff --git a/mbbsd/chicken.c b/mbbsd/chicken.c index 9ee66616..859025a4 100644 --- a/mbbsd/chicken.c +++ b/mbbsd/chicken.c @@ -156,7 +156,7 @@ new_chicken(void) } static void -show_chicken_stat(chicken_t * thechicken, int age) +show_chicken_stat(const chicken_t * thechicken, int age) { struct tm *ptime; @@ -359,7 +359,7 @@ ch_hit(void) } void -ch_buyitem(int money, char *picture, int *item, int haveticket) +ch_buyitem(int money, const char *picture, int *item, int haveticket) { int num = 0; char buf[5]; @@ -620,7 +620,7 @@ check_sick(void) } static int -deadtype(chicken_t * thechicken) +deadtype(const chicken_t * thechicken) { chicken_t *mychicken = &cuser.mychicken; int i; @@ -677,7 +677,7 @@ showdeadth(int type) } int -isdeadth(chicken_t * thechicken) +isdeadth(const chicken_t * thechicken) { int i; diff --git a/mbbsd/dice.c b/mbbsd/dice.c index f3b7ff90..f7cf6537 100644 --- a/mbbsd/dice.c +++ b/mbbsd/dice.c @@ -70,7 +70,7 @@ bingo(int flag[100],int mybet) } int -IsNum(char *a, int n) +IsNum(const char *a, int n) { int i; @@ -222,7 +222,7 @@ del(int value[100],int total, dicedata_t * table) } static int -IsLegal(char *data) +IsLegal(const char *data) { int money = atoi(data); if (IsNum(data, strlen(data)) && money <= B_MAX && money >= B_MIN) diff --git a/mbbsd/edit.c b/mbbsd/edit.c index 12524430..33bec6aa 100644 --- a/mbbsd/edit.c +++ b/mbbsd/edit.c @@ -623,7 +623,7 @@ delete_line(textline_t * line, int saved) } static int -ask(char *prompt) +ask(const char *prompt) { int ch; @@ -1094,7 +1094,7 @@ restore_backup(void) /* 引用文章 */ static int -garbage_line(char *str) +garbage_line(const char *str) { int qlevel = 0; @@ -1233,7 +1233,7 @@ check_quote(void) /* 檔案處理:讀檔、存檔、標題、簽名檔 */ static void -read_file(char *fpath) +read_file(const char *fpath) { FILE *fp; @@ -1586,7 +1586,7 @@ setup_block_begin_end_number(short *begin, short *end) * BLOCK_APPEND append mode */ static void -block_save_to_file(char *fname, int mode) +block_save_to_file(const char *fname, int mode) { textline_t *begin, *end; char fp_tmpbuf[80]; diff --git a/mbbsd/file.c b/mbbsd/file.c index d0e7d097..cf13fb36 100644 --- a/mbbsd/file.c +++ b/mbbsd/file.c @@ -10,7 +10,7 @@ * 傳回 file 檔的行數 * @param file */ -int file_count_line(char *file) +int file_count_line(const char *file) { FILE *fp; int count = 0; @@ -33,7 +33,7 @@ int file_count_line(char *file) * @param string * @return 成功傳回 0,失敗傳回 -1。 */ -int file_append_line(char *file, char *string) +int file_append_line(const char *file, const char *string) { FILE *fp; if ((fp = fopen(file, "a")) == NULL) @@ -52,7 +52,7 @@ int file_append_line(char *file, char *string) * @param string * @param case_sensitive 字串比對是否 case sensitive */ -int file_delete_line(char *file, char *string, int case_sensitive) +int file_delete_line(const char *file, const char *string, int case_sensitive) { FILE *fp, *nfp = NULL; char fnew[80]; @@ -81,7 +81,7 @@ int file_delete_line(char *file, char *string, int case_sensitive) /** * 傳回檔案 file 中是否有 string 這個字串。 */ -int file_exist_record(char *file, char *string) +int file_exist_record(const char *file, const char *string) { FILE *fp; char buf[STRLEN], *ptr; @@ -106,7 +106,7 @@ int file_exist_record(char *file, char *string) * 第一個參數是檔案中的一行,第二個參數為 info。 * @param info 一個額外的參數。 */ -int file_foreach_entry(char *file, int (*func)(char *, int), int info) +int file_foreach_entry(const char *file, int (*func)(char *, int), int info) { char line[80]; FILE *fp; diff --git a/mbbsd/friend.c b/mbbsd/friend.c index 76d1fd88..855056be 100644 --- a/mbbsd/friend.c +++ b/mbbsd/friend.c @@ -57,13 +57,13 @@ setfriendfile(char *fpath, int type) } inline static int -friend_count(char *fname) +friend_count(const char *fname) { return file_count_line(fname); } void -friend_add(char *uident, int type, char* des) +friend_add(const char *uident, int type, const char* des) { char fpath[80]; @@ -180,7 +180,7 @@ friend_append(int type, int count) } void -friend_delete(char *uident, int type) +friend_delete(const char *uident, int type) { char fn[80]; setfriendfile(fn, type); @@ -188,7 +188,7 @@ friend_delete(char *uident, int type) } static void -delete_user_friend(char *uident, char *friend, int type) +delete_user_friend(const char *uident, const char *friend, int type) { char fn[80]; #if 0 @@ -204,7 +204,7 @@ delete_user_friend(char *uident, char *friend, int type) } void -friend_delete_all(char *uident, int type) +friend_delete_all(const char *uident, int type) { char buf[80], line[80]; FILE *fp; @@ -223,7 +223,7 @@ friend_delete_all(char *uident, int type) } static void -friend_editdesc(char *uident, int type) +friend_editdesc(const char *uident, int type) { FILE *fp=NULL, *nfp=NULL; char fnnew[200], genbuf[STRLEN], fn[200]; @@ -298,7 +298,7 @@ void friend_load(int type) } static void -friend_water(char *message, int type) +friend_water(const char *message, int type) { /* 群體水球 added by Ptt */ char fpath[80], line[80], userid[IDLEN + 1]; FILE *fp; diff --git a/mbbsd/gamble.c b/mbbsd/gamble.c index 85761fa0..447c7102 100644 --- a/mbbsd/gamble.c +++ b/mbbsd/gamble.c @@ -6,7 +6,7 @@ #define MAX_SUBJECT_LEN 650 //8*81 = 648 最大 主題長度 static int -load_ticket_record(char *direct, int ticket[]) +load_ticket_record(const char *direct, int ticket[]) { char buf[256]; int i, total = 0; @@ -21,7 +21,7 @@ load_ticket_record(char *direct, int ticket[]) } static int -show_ticket_data(char betname[MAX_ITEM][MAX_ITEM_LEN],char *direct, int *price, boardheader_t * bh) +show_ticket_data(char betname[MAX_ITEM][MAX_ITEM_LEN],const char *direct, int *price, const boardheader_t * bh) { int i, count, total = 0, end = 0, ticket[MAX_ITEM] = {0, 0, 0, 0, 0, 0, 0, 0}; FILE *fp; @@ -90,7 +90,7 @@ show_ticket_data(char betname[MAX_ITEM][MAX_ITEM_LEN],char *direct, int *price, } static int -append_ticket_record(char *direct, int ch, int n, int count) +append_ticket_record(const char *direct, int ch, int n, int count) { FILE *fp; int ticket[8] = {0, 0, 0, 0, 0, 0, 0, 0}, i; diff --git a/mbbsd/guess.c b/mbbsd/guess.c index 68ea0591..a6bd7ddb 100644 --- a/mbbsd/guess.c +++ b/mbbsd/guess.c @@ -58,7 +58,7 @@ get_money(void) } static int -check_data(char *str) +check_data(const char *str) { int i, j; @@ -86,7 +86,7 @@ get_data(char data[5], int count) } static int -guess_play(char *data, char *answer, int count) +guess_play(const char *data, const char *answer, int count) { int A_num = 0, B_num = 0; int i, j; diff --git a/mbbsd/indict.c b/mbbsd/indict.c index deb9ba09..8b87e0e3 100644 --- a/mbbsd/indict.c +++ b/mbbsd/indict.c @@ -4,7 +4,7 @@ #define REFER "etc/dicts" static void -addword(char *database,char word[]) +addword(const char *database,char word[]) { char buf[150], a[3]; FILE *fp = fopen(database, "r+"); @@ -54,7 +54,7 @@ init_buf(void) memset(inbuf, 0, IBUFSIZE); } void -output(char *s, int len) +output(const char *s, int len) { /* Invalid if len >= OBUFSIZE */ @@ -433,7 +433,7 @@ igetch(void) * NO_RELOAD: 不 strip (?) */ int -strip_ansi(char *buf, char *str, int mode) +strip_ansi(char *buf, const char *str, int mode) { register int count = 0; static const char EscapeFlag[] = { @@ -463,7 +463,7 @@ strip_ansi(char *buf, char *str, int mode) *buf++ = *str; ++count; }else{ - register char* p = str + 1; + const char* p = str + 1; if( *p != '[' ){ ++str; continue; @@ -528,7 +528,7 @@ strip_nonebig5(unsigned char *str, int maxlen) } int -oldgetdata(int line, int col, char *prompt, char *buf, int len, int echo) +oldgetdata(int line, int col, const char *prompt, char *buf, int len, int echo) { register int ch, i; int clen; @@ -679,14 +679,14 @@ oldgetdata(int line, int col, char *prompt, char *buf, int len, int echo) /* Ptt */ int -getdata_buf(int line, int col, char *prompt, char *buf, int len, int echo) +getdata_buf(int line, int col, const char *prompt, char *buf, int len, int echo) { return oldgetdata(line, col, prompt, buf, len, echo); } int -getdata_str(int line, int col, char *prompt, char *buf, int len, int echo, char *defaultstr) +getdata_str(int line, int col, const char *prompt, char *buf, int len, int echo, const char *defaultstr) { strlcpy(buf, defaultstr, len); @@ -694,7 +694,7 @@ getdata_str(int line, int col, char *prompt, char *buf, int len, int echo, char } int -getdata(int line, int col, char *prompt, char *buf, int len, int echo) +getdata(int line, int col, const char *prompt, char *buf, int len, int echo) { buf[0] = 0; return oldgetdata(line, col, prompt, buf, len, echo); diff --git a/mbbsd/kaede.c b/mbbsd/kaede.c index 199fda16..43da0653 100644 --- a/mbbsd/kaede.c +++ b/mbbsd/kaede.c @@ -64,7 +64,7 @@ Ptt_prints(char *str, int mode) } int -Rename(char *src, char *dst) +Rename(const char *src, const char *dst) { char buf[256]; if (rename(src, dst) == 0) @@ -79,7 +79,7 @@ Rename(char *src, char *dst) } int -Copy(char *src, char *dst) +Copy(const char *src, const char *dst) { int fi, fo, bytes; char buf[8192]; @@ -94,7 +94,7 @@ Copy(char *src, char *dst) return 0; } int -Link(char *src, char *dst) +Link(const char *src, const char *dst) { if (strcmp(src, BBSHOME "/home") == 0) return 1; diff --git a/mbbsd/mail.c b/mbbsd/mail.c index 9fb5ecca..4058224b 100644 --- a/mbbsd/mail.c +++ b/mbbsd/mail.c @@ -61,7 +61,7 @@ built_mail_index(void) } int -mailalert(char *userid) +mailalert(const char *userid) { userinfo_t *uentp = NULL; int n, tuid, i; @@ -77,13 +77,13 @@ mailalert(char *userid) } int -mail_muser(userec_t muser, char *title, char *filename) +mail_muser(userec_t muser, const char *title, const char *filename) { return mail_id(muser.userid, title, filename, cuser.userid); } int -mail_id(char *id, char *title, char *src, char *owner) +mail_id(const char *id, const char *title, const char *src, const char *owner) { fileheader_t mhdr; char dst[128], dirf[128]; @@ -102,7 +102,7 @@ mail_id(char *id, char *title, char *src, char *owner) } int -invalidaddr(char *addr) +invalidaddr(const char *addr) { if (*addr == '\0') return 1; /* blank */ @@ -179,7 +179,7 @@ chkmailbox(void) } static void -do_hold_mail(char *fpath, char *receiver, char *holder) +do_hold_mail(const char *fpath, const char *receiver, const char *holder) { char buf[80], title[128]; @@ -204,7 +204,7 @@ do_hold_mail(char *fpath, char *receiver, char *holder) } void -hold_mail(char *fpath, char *receiver) +hold_mail(const char *fpath, const char *receiver) { char buf[4]; @@ -216,7 +216,7 @@ hold_mail(char *fpath, char *receiver) } int -do_send(char *userid, char *title) +do_send(const char *userid, const char *title) { fileheader_t mhdr; char fpath[STRLEN]; @@ -302,7 +302,7 @@ do_send(char *userid, char *title) } void -my_send(char *uident) +my_send(const char *uident) { switch (do_send(uident, NULL)) { case -1: @@ -526,7 +526,7 @@ multi_send(char *title) } static int -multi_reply(int ent, fileheader_t * fhdr, char *direct) +multi_reply(int ent, fileheader_t * fhdr, const char *direct) { if (!(fhdr->filemode & FILE_MULTI)) return mail_reply(ent, fhdr, direct); @@ -637,7 +637,7 @@ mail_mbox(void) } static int -m_forward(int ent, fileheader_t * fhdr, char *direct) +m_forward(int ent, fileheader_t * fhdr, const char *direct) { char uid[STRLEN]; @@ -835,7 +835,7 @@ maildoent(int num, fileheader_t * ent) static int -mail_del(int ent, fileheader_t * fhdr, char *direct) +mail_del(int ent, const fileheader_t * fhdr, const char *direct) { char genbuf[200]; @@ -860,7 +860,7 @@ mail_del(int ent, fileheader_t * fhdr, char *direct) } static int -mail_read(int ent, fileheader_t * fhdr, char *direct) +mail_read(int ent, fileheader_t * fhdr, const char *direct) { char buf[64]; char done, delete_it, replied; @@ -918,7 +918,7 @@ mail_read(int ent, fileheader_t * fhdr, char *direct) /* in boards/mail 回信給原作者,轉信站亦可 */ int -mail_reply(int ent, fileheader_t * fhdr, char *direct) +mail_reply(int ent, const fileheader_t * fhdr, const char *direct) { char uid[STRLEN]; char *t; @@ -974,7 +974,7 @@ mail_reply(int ent, fileheader_t * fhdr, char *direct) } static int -mail_edit(int ent, fileheader_t * fhdr, char *direct) +mail_edit(int ent, fileheader_t * fhdr, const char *direct) { char genbuf[200]; @@ -989,7 +989,7 @@ mail_edit(int ent, fileheader_t * fhdr, char *direct) } static int -mail_nooutmail(int ent, fileheader_t * fhdr, char *direct) +mail_nooutmail(int ent, fileheader_t * fhdr, const char *direct) { cuser.uflag2 ^= REJ_OUTTAMAIL; passwd_update(usernum, &cuser); @@ -998,7 +998,7 @@ mail_nooutmail(int ent, fileheader_t * fhdr, char *direct) } static int -mail_mark(int ent, fileheader_t * fhdr, char *direct) +mail_mark(int ent, fileheader_t * fhdr, const char *direct) { fhdr->filemode ^= FILE_MARKED; @@ -1007,7 +1007,7 @@ mail_mark(int ent, fileheader_t * fhdr, char *direct) } /* help for mail reading */ -static char * const mail_help[] = { +static const char * const mail_help[] = { "\0電子信箱操作說明", "\01基本命令", "(p)(↑) 前一篇文章", @@ -1040,7 +1040,7 @@ m_help(void) } static int -mail_cross_post(int ent, fileheader_t * fhdr, char *direct) +mail_cross_post(int ent, fileheader_t * fhdr, const char *direct) { char xboard[20], fname[80], xfpath[80], xtitle[80], inputbuf[10]; fileheader_t xfile; @@ -1166,7 +1166,7 @@ mail_man(void) } static int -mail_cite(int ent, fileheader_t * fhdr, char *direct) +mail_cite(int ent, fileheader_t * fhdr, const char *direct) { char fpath[256]; char title[TTLEN + 1]; @@ -1207,7 +1207,7 @@ mail_cite(int ent, fileheader_t * fhdr, char *direct) } static int -mail_save(int ent, fileheader_t * fhdr, char *direct) +mail_save(int ent, fileheader_t * fhdr, const char *direct) { char fpath[256]; char title[TTLEN + 1]; @@ -1227,7 +1227,7 @@ mail_save(int ent, fileheader_t * fhdr, char *direct) #ifdef OUTJOBSPOOL static int -mail_waterball(int ent, fileheader_t * fhdr, char *direct) +mail_waterball(int ent, fileheader_t * fhdr, const char *direct) { static char address[60], cmode = 1; char fname[500], genbuf[200]; @@ -1413,7 +1413,7 @@ m_read(void) /* 寄站內信 */ static int -send_inner_mail(char *fpath, char *title, char *receiver) +send_inner_mail(const char *fpath, const char *title, const char *receiver) { char genbuf[256]; fileheader_t mymail; @@ -1449,7 +1449,7 @@ send_inner_mail(char *fpath, char *title, char *receiver) #ifndef USE_BSMTP static int -bbs_sendmail(char *fpath, char *title, char *receiver) +bbs_sendmail(const char *fpath, const char *title, char *receiver) { char *ptr; char genbuf[256]; @@ -1512,7 +1512,7 @@ bbs_sendmail(char *fpath, char *title, char *receiver) #else /* USE_BSMTP */ int -bsmtp(char *fpath, char *title, char *rcpt, int method) +bsmtp(const char *fpath, const char *title, const char *rcpt, int method) { char buf[80], *ptr; time4_t chrono; @@ -1561,7 +1561,7 @@ bsmtp(char *fpath, char *title, char *rcpt, int method) #endif /* USE_BSMTP */ int -doforward(char *direct, fileheader_t * fh, int mode) +doforward(const char *direct, const fileheader_t * fh, int mode) { static char address[60]; char fname[500]; @@ -1654,7 +1654,7 @@ doforward(char *direct, fileheader_t * fh, int mode) } int -load_mailalert(char *userid) +load_mailalert(const char *userid) { struct stat st; char maildir[256]; diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index 7e4df1ca..ba5d3c10 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -13,8 +13,8 @@ #define SOCKET_QLEN 4 -static void do_aloha(char *hello); -static void getremotename(struct sockaddr_in * from, char *rhost, char *rname); +static void do_aloha(const char *hello); +static void getremotename(const struct sockaddr_in * from, char *rhost, char *rname); #ifdef CONVERT void big2gb_init(void*); @@ -114,7 +114,7 @@ reapchild(int sig) } void -log_usies(char *mode, char *mesg) +log_usies(const char *mode, const char *mesg) { if (!mesg) @@ -143,7 +143,7 @@ setflags(int mask, int value) } void -u_exit(char *mode) +u_exit(const char *mode) { int diff = (time(0) - login_start_time) / 60; int dirty = currmode & MODE_DIRTY; @@ -288,7 +288,7 @@ show_call_in(int save, int which) } static int -add_history_water(water_t * w, msgque_t * msg) +add_history_water(water_t * w, const msgque_t * msg) { memcpy(&w->msg[w->top], msg, sizeof(msgque_t)); w->top++; @@ -301,7 +301,7 @@ add_history_water(water_t * w, msgque_t * msg) } static int -add_history(msgque_t * msg) +add_history(const msgque_t * msg) { int i = 0, j, waterinit = 0; water_t *tmp; @@ -500,7 +500,7 @@ multi_user_check(void) static char * const str_badlogin = "logins.bad"; static void -logattempt(char *uid, char type) +logattempt(const char *uid, char type) { char fname[40]; int fd, len; @@ -525,7 +525,7 @@ logattempt(char *uid, char type) } } -inline static void mkuserdir(char *userid) +inline static void mkuserdir(const char *userid) { char genbuf[200]; sethomepath(genbuf, userid); @@ -633,7 +633,7 @@ login_query(void) } void -add_distinct(char *fname, char *line) +add_distinct(const char *fname, const char *line) { FILE *fp; int n = 0; @@ -679,7 +679,7 @@ add_distinct(char *fname, char *line) } void -del_distinct(char *fname, char *line) +del_distinct(const char *fname, const char *line) { FILE *fp; int n = 0; @@ -721,7 +721,7 @@ del_distinct(char *fname, char *line) #ifdef WHERE static int -where(char *from) +where(const char *from) { int i; @@ -836,7 +836,7 @@ inline static void check_bad_login(void) } } -inline static void birthday_make_a_wish(struct tm *ptime, struct tm *tmp) +inline static void birthday_make_a_wish(const struct tm *ptime, const struct tm *tmp) { if (tmp->tm_mday != ptime->tm_mday) { more("etc/birth.post", YEA); @@ -846,7 +846,7 @@ inline static void birthday_make_a_wish(struct tm *ptime, struct tm *tmp) } } -inline static void record_lasthost(char *fromhost) +inline static void record_lasthost(const char *fromhost) { strlcpy(cuser.lasthost, fromhost, sizeof(cuser.lasthost)); } @@ -1019,7 +1019,7 @@ user_login(void) } static void -do_aloha(char *hello) +do_aloha(const char *hello) { FILE *fp; char userid[80]; @@ -1152,7 +1152,7 @@ timeout(int sig) #endif static void -getremotename(struct sockaddr_in * from, char *rhost, char *rname) +getremotename(const struct sockaddr_in * from, char *rhost, char *rname) { /* get remote host name */ diff --git a/mbbsd/menu.c b/mbbsd/menu.c index f6baaa49..ebd5887e 100644 --- a/mbbsd/menu.c +++ b/mbbsd/menu.c @@ -8,7 +8,7 @@ extern struct utmpfile_t *utmpshm; extern char board_hidden_status; void -showtitle(char *title, char *mid) +showtitle(const char *title, const char *mid) { char buf[40], numreg[50]; #ifndef DEBUG @@ -163,7 +163,7 @@ show_menu(const commands_t * p) } void -domenu(int cmdmode, char *cmdtitle, int cmd, const commands_t cmdtable[]) +domenu(int cmdmode, const char *cmdtitle, int cmd, const commands_t cmdtable[]) { int lastcmdptr; int n, pos, total, i; diff --git a/mbbsd/more.c b/mbbsd/more.c index f540e051..9ea28a40 100644 --- a/mbbsd/more.c +++ b/mbbsd/more.c @@ -11,7 +11,7 @@ struct MorePool { unsigned char more_pool[MORE_BUFSIZE]; }; -static char * const more_help[] = { +static const char * const more_help[] = { "\0閱\讀文章功\能鍵使用說明", "\01游標移動功\能鍵", "(↑) 上捲一行", diff --git a/mbbsd/name.c b/mbbsd/name.c index 40c3d39e..b87c324a 100644 --- a/mbbsd/name.c +++ b/mbbsd/name.c @@ -63,7 +63,7 @@ CreateNameList(void) } void -AddNameList(char *name) +AddNameList(const char *name) { word_t *node; @@ -79,7 +79,7 @@ AddNameList(char *name) } int -RemoveNameList(char *name) +RemoveNameList(const char *name) { word_t *curr, *prev = NULL; @@ -102,9 +102,9 @@ RemoveNameList(char *name) } static inline int -InList(word_t * list, char *name) +InList(const word_t * list, const char *name) { - word_t *p; + const word_t *p; for (p = list; p; p = p->next) if (!strcmp(p->word, name)) @@ -113,13 +113,13 @@ InList(word_t * list, char *name) } int -InNameList(char *name) +InNameList(const char *name) { return InList(toplev, name); } void -ShowNameList(int row, int column, char *prompt) +ShowNameList(int row, int column, const char *prompt) { word_t *p; @@ -142,7 +142,7 @@ ShowNameList(int row, int column, char *prompt) } void -ToggleNameList(int *reciper, char *listfile, char *msg) +ToggleNameList(int *reciper, const char *listfile, const char *msg) { FILE *fp; char genbuf[200]; @@ -164,7 +164,7 @@ ToggleNameList(int *reciper, char *listfile, char *msg) } static int -NumInList(word_t * list) +NumInList(const word_t * list) { register int i; @@ -174,9 +174,10 @@ NumInList(word_t * list) } int -chkstr(char *otag, char *tag, char *name) +chkstr(char *otag, const char *tag, const char *name) { - char ch, *oname = name; + char ch; + const char *oname = name; while (*tag) { ch = *name++; @@ -232,7 +233,7 @@ ClearSubList(word_t * list) } static int -MaxLen(word_t * list, int count) +MaxLen(const word_t * list, int count) { int len = strlen(list->word); int t; @@ -247,7 +248,7 @@ MaxLen(word_t * list, int count) } void -namecomplete(char *prompt, char *data) +namecomplete(const char *prompt, char *data) { char *temp; word_t *cwlist, *morelist; @@ -374,7 +375,7 @@ namecomplete(char *prompt, char *data) } void -usercomplete(char *prompt, char *data) +usercomplete(const char *prompt, char *data) { char *temp; char *cwbuf, *cwlist; @@ -563,7 +564,7 @@ gnc_complete(char *data, int *start, int *end, int -generalnamecomplete(char *prompt, char *data, int len, size_t nmemb, +generalnamecomplete(const char *prompt, char *data, int len, size_t nmemb, gnc_comp_func compar, gnc_perm_func permission, gnc_getname_func getname) { @@ -701,7 +702,7 @@ generalnamecomplete(char *prompt, char *data, int len, size_t nmemb, /* general complete functions (brdshm) */ int -completeboard_compar(int where, char *str, int len) +completeboard_compar(int where, const char *str, int len) { boardheader_t *bh = &bcache[SHM->bsorted[0][where]]; return strncasecmp(bh->brdname, str, len); @@ -733,7 +734,7 @@ completeboard_getname(int where) /* general complete functions (utmpshm) */ int -completeutmp_compar(int where, char *str, int len) +completeutmp_compar(int where, const char *str, int len) { userinfo_t *u = &SHM->uinfo[SHM->sorted[SHM->currsorted][0][where]]; return strncasecmp(u->userid, str, len); diff --git a/mbbsd/passwd.c b/mbbsd/passwd.c index 1c5ee2f8..809edc2d 100644 --- a/mbbsd/passwd.c +++ b/mbbsd/passwd.c @@ -98,7 +98,7 @@ passwd_query(int num, userec_t * buf) return 0; } -int initcuser(char *userid) +int initcuser(const char *userid) { // Ptt: setup cuser and usernum here if(userid[0]=='\0' || diff --git a/mbbsd/read.c b/mbbsd/read.c index 233e70d1..29b1c79f 100644 --- a/mbbsd/read.c +++ b/mbbsd/read.c @@ -96,7 +96,7 @@ EnumTagFhdr(fileheader_t * fhdr, char *direct, int locus) /* ow: whole tag list */ int -AskTag(char *msg) +AskTag(const char *msg) { int num; @@ -116,11 +116,12 @@ AskTag(char *msg) #define BATCH_SIZE 65536 -char * -f_map(char *fpath, int *fsize) +static char * +f_map(const char *fpath, int *fsize) { int fd, size; struct stat st; + char *map; if ((fd = open(fpath, O_RDONLY)) < 0) return (char *)-1; @@ -129,15 +130,15 @@ f_map(char *fpath, int *fsize) close(fd); return (char *)-1; } - fpath = (char *)mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); + map = (char *)mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); close(fd); *fsize = size; - return fpath; + return map; } static int -TagThread(char *direct) +TagThread(const char *direct) { int fsize, count; char *title, *fimage; @@ -199,7 +200,7 @@ TagPruner(int bid) /* cursor & reading record position control */ /* ----------------------------------------------------- */ keeploc_t * -getkeep(char *s, int def_topline, int def_cursline) +getkeep(const char *s, int def_topline, int def_cursline) { /* 為省記憶體, 且避免 malloc/free 不成對, getkeep 最好不要 malloc, * 只記 s 的 hash 值, @@ -252,7 +253,7 @@ getkeep(char *s, int def_topline, int def_cursline) } void -fixkeep(char *s, int first) +fixkeep(const char *s, int first) { keeploc_t *k; @@ -308,7 +309,7 @@ cursor_pos(keeploc_t * locmem, int val, int from_top, int isshow) * @return 新的游標位置 */ static int -thread(keeploc_t * locmem, int stypen) +thread(const keeploc_t * locmem, int stypen) { fileheader_t fh; int pos = locmem->crs_ln, jump = 200, new_ln; @@ -357,7 +358,7 @@ thread(keeploc_t * locmem, int stypen) #ifdef INTERNET_EMAIL static void -mail_forward(fileheader_t * fhdr, char *direct, int mode) +mail_forward(const fileheader_t * fhdr, const char *direct, int mode) { int i; char buf[STRLEN]; @@ -383,7 +384,7 @@ mail_forward(fileheader_t * fhdr, char *direct, int mode) #endif static int -select_read(keeploc_t * locmem, int sr_mode) +select_read(const keeploc_t * locmem, int sr_mode) { #define READSIZE 64 // 8192 / sizeof(fileheader_t) fileheader_t fhs[READSIZE]; diff --git a/mbbsd/record.c b/mbbsd/record.c index 7de68780..288c1749 100644 --- a/mbbsd/record.c +++ b/mbbsd/record.c @@ -23,7 +23,7 @@ PttLock(int fd, int start, int size, int mode) #define safewrite write int -get_num_records(char *fpath, int size) +get_num_records(const char *fpath, int size) { struct stat st; if (stat(fpath, &st) == -1) @@ -32,7 +32,7 @@ get_num_records(char *fpath, int size) } int -get_sum_records(char *fpath, int size) +get_sum_records(const char *fpath, int size) { struct stat st; int ans = 0; @@ -59,7 +59,7 @@ get_sum_records(char *fpath, int size) } int -get_record_keep(char *fpath, void *rptr, int size, int id, int *fd) +get_record_keep(const char *fpath, void *rptr, int size, int id, int *fd) { /* 和 get_record() 一樣. 不過藉由 *fd, 可使同一個檔案不要一直重複開關 */ if (id >= 1 && @@ -75,7 +75,7 @@ get_record_keep(char *fpath, void *rptr, int size, int id, int *fd) } int -get_record(char *fpath, void *rptr, int size, int id) +get_record(const char *fpath, void *rptr, int size, int id) { int fd = -1; @@ -92,7 +92,7 @@ get_record(char *fpath, void *rptr, int size, int id) } int -get_records(char *fpath, void *rptr, int size, int id, int number) +get_records(const char *fpath, void *rptr, int size, int id, int number) { int fd; @@ -112,7 +112,7 @@ get_records(char *fpath, void *rptr, int size, int id, int number) } int -substitute_record(char *fpath, void *rptr, int size, int id) +substitute_record(const char *fpath, const void *rptr, int size, int id) { int fd; int offset=size * (id - 1); @@ -129,7 +129,7 @@ substitute_record(char *fpath, void *rptr, int size, int id) } int -substitute_ref_record(char *direct, fileheader_t * fhdr, int ent) +substitute_ref_record(const char *direct, fileheader_t * fhdr, int ent) { fileheader_t hdr; char genbuf[256]; @@ -157,7 +157,7 @@ substitute_ref_record(char *direct, fileheader_t * fhdr, int ent) } int -getindex(char *direct, fileheader_t *fh_o, int end) +getindex(const char *direct, fileheader_t *fh_o, int end) { // Ptt: 從前面找很費力 太暴力 int fd = -1, begin = 1, i, stamp, s, times; fileheader_t fh; @@ -208,7 +208,7 @@ getindex(char *direct, fileheader_t *fh_o, int end) /* rocker.011022: 避免lock檔開啟時不正常斷線,造成永久lock */ #ifndef _BBS_UTIL_C_ static int -force_open(char *fname) +force_open(const char *fname) { int fd; time4_t expire; @@ -233,7 +233,7 @@ typedef struct nol_t { #ifndef _BBS_UTIL_C_ static void -nolfilename(nol_t * n, char *fpath) +nolfilename(nol_t * n, const char *fpath) { snprintf(n->newfn, sizeof(n->newfn), "%s.new", fpath); snprintf(n->oldfn, sizeof(n->oldfn), "%s.old", fpath); @@ -242,7 +242,7 @@ nolfilename(nol_t * n, char *fpath) #endif int -delete_records(char fpath[], int size, int id, int num) +delete_records(const char *fpath, int size, int id, int num) { char abuf[BUFSIZE]; int fi, fo, locksize=0, readsize=0, offset = size * (id - 1), c, d=0; @@ -286,7 +286,7 @@ delete_records(char fpath[], int size, int id, int num) } -int delete_record(char fpath[], int size, int id) +int delete_record(const char *fpath, int size, int id) { return delete_records(fpath, size, id, 1); } @@ -294,7 +294,7 @@ int delete_record(char fpath[], int size, int id) #ifndef _BBS_UTIL_C_ #ifdef SAFE_ARTICLE_DELETE -void safe_delete_range(char *fpath, int id1, int id2) +void safe_delete_range(const char *fpath, int id1, int id2) { int fd, i; fileheader_t fhdr; @@ -320,7 +320,7 @@ void safe_delete_range(char *fpath, int id1, int id2) #endif int -delete_range(char *fpath, int id1, int id2) +delete_range(const char *fpath, int id1, int id2) { fileheader_t fhdr; nol_t my; @@ -394,7 +394,7 @@ delete_range(char *fpath, int id1, int id2) #ifdef SAFE_ARTICLE_DELETE int -safe_article_delete(int ent, fileheader_t *fhdr, char *direct) +safe_article_delete(int ent, const fileheader_t *fhdr, const char *direct) { fileheader_t newfhdr; memcpy(&newfhdr, fhdr, sizeof(fileheader_t)); @@ -406,7 +406,7 @@ safe_article_delete(int ent, fileheader_t *fhdr, char *direct) } int -safe_article_delete_range(char *direct, int from, int to) +safe_article_delete_range(const char *direct, int from, int to) { fileheader_t newfhdr; int fd; @@ -443,13 +443,14 @@ safe_article_delete_range(char *direct, int from, int to) #endif int -apply_record(char *fpath, int (*fptr) (void *item, void *optarg), int size, void *arg){ +apply_record(const char *fpath, int (*fptr) (void *item, void *optarg), int size, void *arg){ char abuf[BUFSIZE]; int fp; if((fp=open(fpath, O_RDONLY, 0)) == -1) return -1; + assert(size<=sizeof(abuf)); while (read(fp, abuf, size) == (size_t)size) if ((*fptr) (abuf, arg) == QUIT) { close(fp); @@ -539,7 +540,7 @@ stamplink(char *fpath, fileheader_t * fh) } int -append_record(char *fpath, fileheader_t * record, int size) +append_record(const char *fpath, const fileheader_t * record, int size) { int fd, fsize=0, index; struct stat st; diff --git a/mbbsd/register.c b/mbbsd/register.c index 8d47a30c..246e1dad 100644 --- a/mbbsd/register.c +++ b/mbbsd/register.c @@ -27,7 +27,7 @@ genpasswd(char *pw) // NOTE it will clean string in "plain" int -checkpasswd(char *passwd, char *plain) +checkpasswd(const char *passwd, char *plain) { int ok; char *pw; @@ -43,7 +43,7 @@ checkpasswd(char *passwd, char *plain) /* 檢查 user 註冊情況 */ int -bad_user_id(char *userid) +bad_user_id(const char *userid) { int len, i; len = strlen(userid); @@ -79,7 +79,7 @@ bad_user_id(char *userid) /* (b) is the object to be compared */ /* -------------------------------- */ static int -compute_user_value(userec_t * urec, time4_t clock) +compute_user_value(const userec_t * urec, time4_t clock) { int value; @@ -105,7 +105,7 @@ compute_user_value(userec_t * urec, time4_t clock) } int -check_and_expire_account(int uid, userec_t * urec) +check_and_expire_account(int uid, const userec_t * urec) { char genbuf[200], genbuf2[200]; int val; diff --git a/mbbsd/screen.c b/mbbsd/screen.c index 43f1b7e1..7435716f 100644 --- a/mbbsd/screen.c +++ b/mbbsd/screen.c @@ -80,7 +80,7 @@ rel_move(int was_col, int was_ln, int new_col, int new_ln) } static void -standoutput(char *buf, int ds, int de, int sso, int eso) +standoutput(const char *buf, int ds, int de, int sso, int eso) { int st_start, st_end; @@ -407,7 +407,7 @@ out_lines(const char *str, int line) } void -outmsg(char *msg) +outmsg(const char *msg) { move(b_lines, 0); clrtoeol(); @@ -427,7 +427,7 @@ prints(const char *fmt,...) } void -mouts(int y, int x, char *str) +mouts(int y, int x, const char *str) { move(y, x); clrtoeol(); @@ -505,7 +505,7 @@ standend(void) } } -void screen_backup(int len, screenline_t *bp, void *buf) +void screen_backup(int len, const screenline_t *bp, void *buf) { int i; size_t offset=0; @@ -517,7 +517,7 @@ void screen_backup(int len, screenline_t *bp, void *buf) } } -size_t screen_backupsize(int len, screenline_t *bp) +size_t screen_backupsize(int len, const screenline_t *bp) { int i; size_t sum=0; @@ -526,7 +526,7 @@ size_t screen_backupsize(int len, screenline_t *bp) return sum; } -void screen_restore(int len, screenline_t *bp, void *buf) +void screen_restore(int len, screenline_t *bp, const void *buf) { int i; size_t offset=0; diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c index ecc85458..2a42fd5e 100644 --- a/mbbsd/stuff.c +++ b/mbbsd/stuff.c @@ -88,12 +88,13 @@ setbnfile(char *buf, const char *boardname, const char *fname, int n) * fname: direct 的檔名部分 */ void -setdirpath(char *buf, char *direct, char *fname) +setdirpath(char *buf, const char *direct, const char *fname) { + char *p; strcpy(buf, direct); - direct = strrchr(buf, '/'); - assert(direct); - strcpy(direct + 1, fname); + p = strrchr(buf, '/'); + assert(p); + strcpy(p + 1, fname); } /** @@ -115,7 +116,7 @@ subject(char *title) /* 字串轉換檢查函數 */ /* ----------------------------------------------------- */ int -str_checksum(char *str) +str_checksum(const char *str) { int n = 1; if (strlen(str) < 6) @@ -131,7 +132,7 @@ str_checksum(char *str) * @param s */ void -str_lower(char *t, char *s) +str_lower(char *t, const char *s) { register unsigned char ch; @@ -179,9 +180,9 @@ void chomp(char *src) /* ----------------------------------------------------- */ int -invalid_pname(char *str) +invalid_pname(const char *str) { - char *p1, *p2, *p3; + const char *p1, *p2, *p3; p1 = str; while (*p1) { @@ -198,22 +199,20 @@ invalid_pname(char *str) } int -valid_ident(char *ident) +valid_ident(const char *ident) { char *invalid[] = {"unknown@", "root@", "gopher@", "bbs@", "@bbs", "guest@", "@ppp", "@slip", NULL}; - char buf[128]; int i; - str_lower(buf, ident); for (i = 0; invalid[i]; i++) - if (strstr(buf, invalid[i])) + if (strcasestr(ident, invalid[i])) return 0; return 1; } int -is_uBM(char *list, char *id) +is_uBM(const char *list, const char *id) { register int len; @@ -238,7 +237,7 @@ is_uBM(char *list, char *id) } int -is_BM(char *list) +is_BM(const char *list) { if (is_uBM(list, cuser.userid)) { cuser.userlevel |= PERM_BM; /* Ptt 自動加上BM的權利 */ @@ -248,10 +247,11 @@ is_BM(char *list) } int -userid_is_BM(char *userid, char *list) +userid_is_BM(const char *userid, const char *list) { register int ch, len; + // TODO merge with is_uBM ch = list[0]; if ((ch > ' ') && (ch < 128)) { len = strlen(userid); @@ -279,7 +279,7 @@ userid_is_BM(char *userid, char *list) * @param fname */ off_t -dashs(char *fname) +dashs(const char *fname) { struct stat st; @@ -294,7 +294,7 @@ dashs(char *fname) * @param fname */ time4_t -dasht(char *fname) +dasht(const char *fname) { struct stat st; @@ -309,7 +309,7 @@ dasht(char *fname) * @param fname */ int -dashl(char *fname) +dashl(const char *fname) { struct stat st; @@ -321,7 +321,7 @@ dashl(char *fname) * @param fname */ int -dashf(char *fname) +dashf(const char *fname) { struct stat st; @@ -333,7 +333,7 @@ dashf(char *fname) * @param fname */ int -dashd(char *fname) +dashd(const char *fname) { struct stat st; @@ -341,7 +341,7 @@ dashd(char *fname) } #define BUFFER_SIZE 8192 -static int copy_file_to_file(char *src, char *dst) +static int copy_file_to_file(const char *src, const char *dst) { char buf[BUFFER_SIZE]; int fdr, fdw, len; @@ -369,7 +369,7 @@ static int copy_file_to_file(char *src, char *dst) } #undef BUFFER_SIZE -static int copy_file_to_dir(char *src, char *dst) +static int copy_file_to_dir(const char *src, const char *dst) { char buf[256]; char *slash; @@ -380,7 +380,7 @@ static int copy_file_to_dir(char *src, char *dst) return copy_file_to_file(src, buf); } -static int copy_dir_to_dir(char *src, char *dst) +static int copy_dir_to_dir(const char *src, const char *dst) { DIR *dir; struct dirent *entry; @@ -416,7 +416,7 @@ static int copy_dir_to_dir(char *src, char *dst) * @param src and dst are file or dir * @return -1 if failed */ -int copy_file(char *src, char *dst) +int copy_file(const char *src, const char *dst) { struct stat st; @@ -436,18 +436,19 @@ int copy_file(char *src, char *dst) } int -belong(char *filelist, char *key) +belong(const char *filelist, const char *key) { return file_exist_record(filelist, key); } unsigned int -ipstr2int(char *ip) +ipstr2int(const char *ip) { unsigned int i, val = 0; char buf[32]; char *nil, *p; - strcpy(buf, ip); + + strlcpy(buf, ip, sizeof(buf)); p = buf; for (i = 0; i < 4; i++) { nil = strchr(p, '.'); @@ -463,7 +464,7 @@ ipstr2int(char *ip) #ifndef _BBS_UTIL_C_ /* getdata_buf */ time4_t -gettime(int line, time4_t dt, char*head) +gettime(int line, time4_t dt, const char*head) { char yn[7]; int i; @@ -493,7 +494,7 @@ gettime(int line, time4_t dt, char*head) #endif char * -Cdate(time4_t *clock) +Cdate(const time4_t *clock) { time_t temp = (time_t)*clock; struct tm *mytm = localtime(&temp); @@ -503,7 +504,7 @@ Cdate(time4_t *clock) } char * -Cdatelite(time4_t *clock) +Cdatelite(const time4_t *clock) { time_t temp = (time_t)*clock; struct tm *mytm = localtime(&temp); @@ -513,7 +514,7 @@ Cdatelite(time4_t *clock) } char * -Cdatedate(time4_t * clock) +Cdatedate(const time4_t * clock) { time_t temp = (time_t)*clock; struct tm *mytm = localtime(&temp); @@ -649,7 +650,7 @@ vmsg(const char *fmt,...) * @return 失敗傳回 0,否則為 1。 */ int -show_file(char *filename, int y, int lines, int mode) +show_file(const char *filename, int y, int lines, int mode) { FILE *fp; char buf[256]; @@ -732,7 +733,7 @@ search_num(int ch, int max) * @param title */ void -stand_title(char *title) +stand_title(const char *title) { clear(); prints("\033[1;37;46m【 %s 】\033[m\n", title); @@ -766,7 +767,7 @@ cursor_key(int row, int column) } void -printdash(char *mesg) +printdash(const char *mesg) { int head = 0, tail; @@ -804,7 +805,7 @@ log_user(const char *fmt, ...) } int -log_file(char *fn, int flag, const char *fmt,...) +log_file(const char *fn, int flag, const char *fmt,...) { int fd; char msg[256]; @@ -832,9 +833,9 @@ log_file(char *fn, int flag, const char *fmt,...) } void -show_help(char * const helptext[]) +show_help(const char * const helptext[]) { - char *str; + const char *str; int i; clear(); @@ -896,16 +897,16 @@ void FREE(void *ptr) #endif unsigned -StringHash(unsigned char *s) +StringHash(const unsigned char *s) { return fnv1a_32_strcase(s, FNV1_32_INIT); } -inline int *intbsearch(int key, int *base0, int nmemb) +inline int *intbsearch(int key, const int *base0, int nmemb) { /* 改自 /usr/src/lib/libc/stdlib/bsearch.c , 專給搜 int array 用的, 不透過 compar function 故較快些 */ - const char *base = (char *)base0; + const char *base = (const char *)base0; size_t lim; int *p; @@ -928,14 +929,14 @@ int qsort_intcompar(const void *a, const void *b) #ifdef TIMET64 char * -ctime4(time4_t *clock) +ctime4(const time4_t *clock) { time_t temp = (time_t)*clock; return ctime(&temp); } -struct tm *localtime4(time4_t *t) +struct tm *localtime4(const time4_t *t) { if( t == NULL ) return localtime(NULL); @@ -955,7 +956,7 @@ time4_t time4(time4_t *ptr) #endif #ifdef OUTTACACHE -int tobind(char * host, int port) +int tobind(const char * host, int port) { int sockfd, val; struct sockaddr_in servaddr; @@ -987,7 +988,7 @@ int tobind(char * host, int port) return sockfd; } -int toconnect(char *host, int port) +int toconnect(const char *host, int port) { int sock; struct sockaddr_in serv_name; @@ -1025,7 +1026,7 @@ int toread(int fd, void *buf, int len) /** * same as write(2), but write until exactly size len */ -int towrite(int fd, void *buf, int len) +int towrite(int fd, const void *buf, int len) { int l; for( l = 0 ; len > 0 ; ) diff --git a/mbbsd/syspost.c b/mbbsd/syspost.c index ab686d6a..42289ce4 100644 --- a/mbbsd/syspost.c +++ b/mbbsd/syspost.c @@ -2,7 +2,7 @@ #include "bbs.h" int -post_msg(char *bname, char *title, char *msg, char *author) +post_msg(const char *bname, const char *title, const char *msg, const char *author) { FILE *fp; int bid; @@ -35,7 +35,7 @@ post_msg(char *bname, char *title, char *msg, char *author) } int -post_file(char *bname, char *title, char *filename, char *author) +post_file(const char *bname, const char *title, const char *filename, const char *author) { int size = dashs(filename); char *msg; @@ -55,7 +55,7 @@ post_file(char *bname, char *title, char *filename, char *author) } void -post_change_perm(int oldperm, int newperm, char *sysopid, char *userid) +post_change_perm(int oldperm, int newperm, const char *sysopid, const char *userid) { FILE *fp; fileheader_t fhdr; @@ -99,7 +99,7 @@ post_change_perm(int oldperm, int newperm, char *sysopid, char *userid) } void -post_violatelaw(char *crime, char *police, char *reason, char *result) +post_violatelaw(const char *crime, const char *police, const char *reason, const char *result) { char genbuf[200]; fileheader_t fhdr; @@ -144,7 +144,7 @@ post_violatelaw(char *crime, char *police, char *reason, char *result) } void -post_newboard(char *bgroup, char *bname, char *bms) +post_newboard(const char *bgroup, const char *bname, const char *bms) { char genbuf[256], title[128]; snprintf(title, sizeof(title), "[新板成立] %s", bname); @@ -155,7 +155,7 @@ post_newboard(char *bgroup, char *bname, char *bms) } void -give_money_post(char *userid, int money) +give_money_post(const char *userid, int money) { FILE *fp; fileheader_t fhdr; diff --git a/mbbsd/talk.c b/mbbsd/talk.c index 732fa862..58e691b6 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -44,7 +44,7 @@ static char page_requestor[40]; userinfo_t *uip; int -iswritable_stat(userinfo_t * uentp, int fri_stat) +iswritable_stat(const userinfo_t * uentp, int fri_stat) { if (uentp == currutmp) return 0; @@ -59,7 +59,7 @@ iswritable_stat(userinfo_t * uentp, int fri_stat) } int -isvisible_stat(userinfo_t * me, userinfo_t * uentp, int fri_stat) +isvisible_stat(const userinfo_t * me, const userinfo_t * uentp, int fri_stat) { if (!uentp || uentp->userid[0] == 0) return 0; @@ -77,8 +77,8 @@ isvisible_stat(userinfo_t * me, userinfo_t * uentp, int fri_stat) return !(fri_stat & HRM); } -char * -modestring(userinfo_t * uentp, int simple) +const char * +modestring(const userinfo_t * uentp, int simple) { static char modestr[40]; static char *const notonline = "不在站上"; @@ -156,9 +156,10 @@ modestring(userinfo_t * uentp, int simple) } int -set_friend_bit(userinfo_t * me, userinfo_t * ui) +set_friend_bit(const userinfo_t * me, const userinfo_t * ui) { - int unum, *myfriends, hit = 0; + int unum, hit = 0; + const int *myfriends; /* 判斷對方是否為我的朋友 ? */ if( intbsearch(ui->uid, me->friend, me->nFriends) ) @@ -303,7 +304,7 @@ logout_friend_online(userinfo_t * utmp) int -friend_stat(userinfo_t * me, userinfo_t * ui) +friend_stat(const userinfo_t * me, const userinfo_t * ui) { int i, j, hit = 0; /* 看板好友 */ @@ -353,7 +354,7 @@ my_kick(userinfo_t * uentp) } static void -chicken_query(char *userid) +chicken_query(const char *userid) { userec_t xuser; if (getuser(userid, &xuser)) { @@ -373,7 +374,7 @@ chicken_query(char *userid) } int -my_query(char *uident) +my_query(const char *uident) { userec_t muser; int tuid, i, fri_stat = 0; @@ -448,7 +449,7 @@ my_query(char *uident) static char t_last_write[80]; static void -water_scr(water_t * tw, int which, char type) +water_scr(const water_t * tw, int which, char type) { if (type == 1) { int i; @@ -634,7 +635,7 @@ my_write2(void) * 回答小主人 flag = WATERBALL_CONFIRM_ANSWER, 8 (pre-edit) */ int -my_write(pid_t pid, char *prompt, char *id, int flag, userinfo_t * puin) +my_write(pid_t pid, const char *prompt, const char *id, int flag, userinfo_t * puin) { int len, currstat0 = currstat, fri_stat; char msg[80], destid[IDLEN + 1]; @@ -1618,7 +1619,7 @@ t_showhelp(void) /* Kaede show friend description */ static char * -friend_descript(userinfo_t * uentp, char *desc_buf, int desc_buflen) +friend_descript(const userinfo_t * uentp, char *desc_buf, int desc_buflen) { char *space_buf = "", *flag; char fpath[80], name[IDLEN + 2], *desc, *ptr; @@ -1656,8 +1657,8 @@ friend_descript(userinfo_t * uentp, char *desc_buf, int desc_buflen) } /* XXX 為什麼 diff 是 time_t */ -static char * -descript(int show_mode, userinfo_t * uentp, time4_t diff) +static const char * +descript(int show_mode, const userinfo_t * uentp, time4_t diff) { static char description[30]; switch (show_mode) { @@ -2085,7 +2086,7 @@ void set_withme_flag(void) } int -call_in(userinfo_t * uentp, int fri_stat) +call_in(const userinfo_t * uentp, int fri_stat) { if (iswritable_stat(uentp, fri_stat)) { char genbuf[60]; @@ -2827,7 +2828,7 @@ t_talk(void) } int -reply_connection_request(userinfo_t *uip) +reply_connection_request(const userinfo_t *uip) { char buf[4], genbuf[200]; @@ -2841,7 +2842,7 @@ reply_connection_request(userinfo_t *uip) } int -establish_talk_connection(userinfo_t *uip) +establish_talk_connection(const userinfo_t *uip) { int a; struct hostent *h; diff --git a/mbbsd/user.c b/mbbsd/user.c index 9327dd59..8c17c443 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -59,7 +59,7 @@ u_loginview(void) } void -user_display(userec_t * u, int real) +user_display(const userec_t * u, int real) { int diff = 0; char genbuf[200]; @@ -172,7 +172,7 @@ user_display(userec_t * u, int real) } void -mail_violatelaw(char *crime, char *police, char *reason, char *result) +mail_violatelaw(const char *crime, const char *police, const char *reason, const char *result) { char genbuf[200]; fileheader_t fhdr; @@ -781,7 +781,7 @@ u_cloak(void) } void -showplans(char *uid) +showplans(const char *uid) { char genbuf[200]; @@ -955,7 +955,7 @@ u_editcalendar(void) /* 使用者填寫註冊表格 */ static void -getfield(int line, char *info, char *desc, char *buf, int len) +getfield(int line, const char *info, const char *desc, char *buf, int len) { char prompt[STRLEN]; char genbuf[200]; @@ -991,7 +991,7 @@ getregcode(char *buf) } static int -isvalidemail(char *email) +isvalidemail(const char *email) { FILE *fp; char buf[128], *c; @@ -1141,7 +1141,7 @@ toregister(char *email, char *genbuf, char *phone, char *career, } } -static int HaveRejectStr(char *s, char **rej) +static int HaveRejectStr(const char *s, const char **rej) { int i; char *ptr, *rejectstr[] = @@ -1174,7 +1174,7 @@ static char *isvalidname(char *rname) #ifdef FOREIGN_REG return NULL; #else - char *rejectstr[] = + const char *rejectstr[] = {"肥", "胖", "豬頭", "小白", "小明", "路人", "老王", "老李", "寶貝", "先生", "帥哥", "老頭", "小姊", "小姐", "美女", "小妹", "大頭", "公主", "同學", "寶寶", "公子", "大頭", "小小", "小弟", "小妹", @@ -1196,7 +1196,7 @@ static char *isvalidname(char *rname) static char *isvalidcareer(char *career) { #ifndef FOREIGN_REG - char *rejectstr[] = {NULL}; + const char *rejectstr[] = {NULL}; if (!(removespace(career) && career[0] < 0 && strlen(career) >= 6) || strcmp(career, "家裡") == 0 || HaveRejectStr(career, rejectstr) ) return "您的輸入不正確"; @@ -1215,7 +1215,7 @@ static char *isvalidcareer(char *career) static char *isvalidaddr(char *addr) { - char *rejectstr[] = + const char *rejectstr[] = {"地球", "銀河", "火星", NULL}; if (!removespace(addr) || addr[0] > 0 || strlen(addr) < 15) diff --git a/mbbsd/var.c b/mbbsd/var.c index 1d6d7752..515499f5 100644 --- a/mbbsd/var.c +++ b/mbbsd/var.c @@ -2,7 +2,7 @@ #define INCLUDE_VAR_H #include "bbs.h" -char * const str_permid[] = { +const char * const str_permid[] = { "基本權力", /* PERM_BASIC */ "進入聊天室", /* PERM_CHAT */ "找人聊天", /* PERM_PAGE */ @@ -41,7 +41,7 @@ char * const str_permid[] = { "Ptt" /* PERM_PTT */ }; -char * const str_permboard[] = { +const char * const str_permboard[] = { "不可 Zap", /* BRD_NOZAP */ "不列入統計", /* BRD_NOCOUNT */ "不轉信", /* BRD_NOTRAN */ diff --git a/mbbsd/vice.c b/mbbsd/vice.c index 460a1c5a..3f69e440 100644 --- a/mbbsd/vice.c +++ b/mbbsd/vice.c @@ -33,7 +33,7 @@ vice_load(char tbingo[6][15]) } static int -check(char tbingo[6][15], char *data) +check(char tbingo[6][15], const char *data) { int i = 0, j; @@ -48,7 +48,7 @@ check(char tbingo[6][15], char *data) } /* TODO Ptt:showfile ran_showfile more 三者要合 */ static int -ran_showfile(int y, int x, char *filename, int maxnum) +ran_showfile(int y, int x, const char *filename, int maxnum) { FILE *fs; char buf[512]; @@ -70,7 +70,7 @@ ran_showfile(int y, int x, char *filename, int maxnum) } static int -ran_showmfile(char *filename, int maxnum) +ran_showmfile(const char *filename, int maxnum) { char buf[256]; diff --git a/mbbsd/vote.c b/mbbsd/vote.c index 191acf88..e354f1d4 100644 --- a/mbbsd/vote.c +++ b/mbbsd/vote.c @@ -128,7 +128,7 @@ b_suckinfile(FILE * fp, char *fname) } static void -b_count(char *buf, int counts[], short item_num, int *total) +b_count(const char *buf, int counts[], short item_num, int *total) { short choice; int fd; @@ -150,7 +150,7 @@ b_count(char *buf, int counts[], short item_num, int *total) static int -b_nonzeroNum(char *buf) +b_nonzeroNum(const char *buf) { int i = 0; char inchar; @@ -166,7 +166,7 @@ b_nonzeroNum(char *buf) } static void -vote_report(char *bname, char *fname, char *fpath) +vote_report(const char *bname, const char *fname, char *fpath) { register char *ip; time4_t dtime; @@ -434,7 +434,7 @@ auto_close_polls(void) } static int -vote_view(vote_buffer_t *vbuf, char *bname, int vote_index) +vote_view(vote_buffer_t *vbuf, const char *bname, int vote_index) { boardheader_t *fhp; FILE *fp; @@ -544,7 +544,7 @@ vote_view(vote_buffer_t *vbuf, char *bname, int vote_index) } static int -vote_view_all(vote_buffer_t *vbuf, char *bname) +vote_view_all(vote_buffer_t *vbuf, const char *bname) { int i; int x = -1; @@ -592,7 +592,7 @@ vote_view_all(vote_buffer_t *vbuf, char *bname) } static int -vote_maintain(char *bname) +vote_maintain(const char *bname) { FILE *fp = NULL; char inbuf[STRLEN], buf[STRLEN]; @@ -767,7 +767,7 @@ vote_maintain(char *bname) } static int -vote_flag(vote_buffer_t *vbuf, char *bname, int index, char val) +vote_flag(vote_buffer_t *vbuf, const char *bname, int index, char val) { char buf[256], flag; int fd, num, size; @@ -795,7 +795,7 @@ vote_flag(vote_buffer_t *vbuf, char *bname, int index, char val) } static int -user_vote_one(vote_buffer_t *vbuf, char *bname, int ind) +user_vote_one(vote_buffer_t *vbuf, const char *bname, int ind) { FILE *cfp, *fcm; char buf[STRLEN], redo; @@ -1004,7 +1004,7 @@ user_vote_one(vote_buffer_t *vbuf, char *bname, int ind) } static int -user_vote(char *bname) +user_vote(const char *bname) { int pos; boardheader_t *fhp; @@ -1076,7 +1076,7 @@ user_vote(char *bname) } static int -vote_results(char *bname) +vote_results(const char *bname) { char buf[STRLEN]; diff --git a/mbbsd/voteboard.c b/mbbsd/voteboard.c index 73cc0742..17f1f945 100644 --- a/mbbsd/voteboard.c +++ b/mbbsd/voteboard.c @@ -3,7 +3,7 @@ #define VOTEBOARD "NewBoard" void -do_voteboardreply(fileheader_t * fhdr) +do_voteboardreply(const fileheader_t * fhdr) { char genbuf[256]; char reason[36]=""; |