summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-05-03 23:19:01 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-05-03 23:19:01 +0800
commit923905e83ad2d075f0d40125e8acbd0ca88ea938 (patch)
treebd8287047cf35c6c7e1e98057876d7be07e470a3 /mbbsd
parent79890093f845d2c70ffec2e0699700380e623cd8 (diff)
downloadpttbbs-923905e83ad2d075f0d40125e8acbd0ca88ea938.tar
pttbbs-923905e83ad2d075f0d40125e8acbd0ca88ea938.tar.gz
pttbbs-923905e83ad2d075f0d40125e8acbd0ca88ea938.tar.bz2
pttbbs-923905e83ad2d075f0d40125e8acbd0ca88ea938.tar.lz
pttbbs-923905e83ad2d075f0d40125e8acbd0ca88ea938.tar.xz
pttbbs-923905e83ad2d075f0d40125e8acbd0ca88ea938.tar.zst
pttbbs-923905e83ad2d075f0d40125e8acbd0ca88ea938.zip
in log_file(), use LOG_VF if need to vfprintf().
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1921 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/admin.c3
-rw-r--r--mbbsd/announce.c4
-rw-r--r--mbbsd/bbs.c5
-rw-r--r--mbbsd/cache.c2
-rw-r--r--mbbsd/cal.c4
-rw-r--r--mbbsd/chicken.c11
-rw-r--r--mbbsd/fav.c3
-rw-r--r--mbbsd/mbbsd.c4
-rw-r--r--mbbsd/read.c3
-rw-r--r--mbbsd/stuff.c27
-rw-r--r--mbbsd/talk.c2
11 files changed, 40 insertions, 28 deletions
diff --git a/mbbsd/admin.c b/mbbsd/admin.c
index e828e3f3..c2a429f5 100644
--- a/mbbsd/admin.c
+++ b/mbbsd/admin.c
@@ -1071,7 +1071,8 @@ scan_register_form(char *regfile, int automode, int neednum)
strlcpy(muser.email, fdata[6], sizeof(muser.email));
strncpy(muser.justify, genbuf, REGLEN);
sethomefile(buf, muser.userid, "justify");
- log_file(buf, 1, "%s:%s:%s\n", fdata[5], fdata[3], uid);
+ log_file(buf, LOG_CREAT | LOG_VF,
+ "%s:%s:%s\n", fdata[5], fdata[3], uid);
passwd_update(unum, &muser);
if ((fout = fopen(logfile, "a"))) {
diff --git a/mbbsd/announce.c b/mbbsd/announce.c
index 663a9daa..092723db 100644
--- a/mbbsd/announce.c
+++ b/mbbsd/announce.c
@@ -911,8 +911,8 @@ a_menu(char *maintitle, char *path, int lastlevel)
Fexit = 1;
if (currstat == OSONG) {
/* XXX: 只選歌未點歌可灌排行榜 */
- log_file(FN_USSONG, 1,
- "%s\n", fhdr->title);
+ log_file(FN_USSONG, LOG_CREAT | LOG_VF,
+ "%s\n", fhdr->title);
}
free(me.header);
return FULLUPDATE;
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index 33bf74cd..6ac455de 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -30,7 +30,7 @@ mail_by_link(char *owner, char *title, char *path)
void
anticrosspost()
{
- log_file("etc/illegal_money", 1,
+ log_file("etc/illegal_money", LOG_CREAT | LOG_VF,
"\033[1;33;46m%s \033[37;45mcross post 文章 \033[37m %s\033[m\n",
cuser.userid, ctime(&now));
@@ -2468,7 +2468,8 @@ static void
log_board(char *mode, time_t usetime)
{
if (usetime > 30) {
- log_file(FN_USEBOARD, 1, "USE %-20.20s Stay: %5ld (%s) %s\n",
+ log_file(FN_USEBOARD, LOG_CREAT | LOG_VF,
+ "USE %-20.20s Stay: %5ld (%s) %s\n",
mode, usetime, cuser.userid, ctime(&now));
}
}
diff --git a/mbbsd/cache.c b/mbbsd/cache.c
index c78dbed4..51b9ce90 100644
--- a/mbbsd/cache.c
+++ b/mbbsd/cache.c
@@ -626,7 +626,7 @@ setbottomtotal(int bid)
if(n>5)
{
#ifdef DEBUG_BOTTOM
- log_file("fix_bottom", 1, "%s n:%d\n", genbuf, n);
+ log_file("fix_bottom", LOG_CREAT | LOG_VF, "%s n:%d\n", genbuf, n);
#endif
unlink(genbuf);
SHM->n_bottom[bid-1]=0;
diff --git a/mbbsd/cal.c b/mbbsd/cal.c
index a2b1ae48..a59eb9f9 100644
--- a/mbbsd/cal.c
+++ b/mbbsd/cal.c
@@ -64,7 +64,7 @@ vice(int money, char *item)
demoney(-money);
setuserfile(buf, VICE_NEW);
- log_file(buf, 1, "%8.8d\n", viceserial);
+ log_file(buf, LOG_CREAT | LOG_VF, "%8.8d\n", viceserial);
snprintf(buf, sizeof(buf),
"%s 花了%d$ 編號[%08d]", item, money, viceserial);
mail_id(cuser.userid, buf, "etc/vice.txt", "Ptt經濟部");
@@ -374,7 +374,7 @@ p_give()
return 0; /* 繳完稅就沒錢給了 */
deumoney(searchuser(id), money - tax);
demoney(-money);
- log_file(FN_MONEY,1, "%s\t給%s\t%d\t%s",
+ log_file(FN_MONEY, LOG_CREAT | LOG_VF, "%s\t給%s\t%d\t%s",
cuser.userid, id, money - tax, ctime(&now));
mail_redenvelop(cuser.userid, id, money - tax, getans("要自行書寫紅包袋嗎?[y/N]"));
}
diff --git a/mbbsd/chicken.c b/mbbsd/chicken.c
index 7af6a7b3..78bcf358 100644
--- a/mbbsd/chicken.c
+++ b/mbbsd/chicken.c
@@ -134,7 +134,7 @@ new_chicken()
getdata(8, 0, "幫牠取個好名字:", mychicken->name,
sizeof(mychicken->name), DOECHO);
- log_file(CHICKENLOG, 1,
+ log_file(CHICKENLOG, LOG_CREAT | LOG_VF,
"\033[31m%s \033[m養了一隻叫\033[33m %s \033[m的 "
"\033[32m%s\033[m 於 %s\n", cuser.userid,
mychicken->name, chicken_type[(int)mychicken->type], ctime(&now));
@@ -445,7 +445,7 @@ ch_kill()
vice(100, "棄養寵物費");
more(CHICKEN_PIC "/deadth", YEA);
- log_file(CHICKENLOG, 1,
+ log_file(CHICKENLOG, LOG_CREAT | LOG_VF,
"\033[31m%s \033[m把 \033[33m%s\033[m\033[32m %s "
"\033[m宰了 於 %s\n", cuser.userid, mychicken->name,
chicken_type[(int)mychicken->type], ctime(&now));
@@ -502,7 +502,8 @@ ch_sell()
ans = getans("這隻%d歲%s可以賣 %d 元, 是否要賣?(y/N)", age,
chicken_type[(int)mychicken->type], money);
if (ans == 'y') {
- log_file(CHICKENLOG, 1, "\033[31m%s\033[m 把 \033[33m%s\033[m "
+ log_file(CHICKENLOG, LOG_CREAT | LOG_VF,
+ "\033[31m%s\033[m 把 \033[33m%s\033[m "
"\033[32m%s\033[m 用 \033[36m%d\033[m 賣了 於 %s\n",
cuser.userid, mychicken->name,
chicken_type[(int)mychicken->type], money, ctime(&now));
@@ -658,7 +659,7 @@ deadtype(chicken_t * thechicken)
return 0;
if (thechicken == mychicken) {
- log_file(CHICKENLOG, 1,
+ log_file(CHICKENLOG, LOG_CREAT | LOG_VF,
"\033[31m%s\033[m 所疼愛的\033[33m %s\033[32m %s "
"\033[m掛了 於 %s\n", cuser.userid, thechicken->name,
chicken_type[(int)thechicken->type], ctime(&now));
@@ -715,7 +716,7 @@ ch_changename()
if (strlen(newname) >= 3 && strcmp(newname, mychicken->name)) {
strlcpy(mychicken->name, newname, sizeof(mychicken->name));
- log_file(CHICKENLOG, 1,
+ log_file(CHICKENLOG, LOG_CREAT | LOG_VF,
"\033[31m%s\033[m 把疼愛的\033[33m %s\033[32m %s "
"\033[m改名為\033[33m %s\033[m 於 %s\n",
cuser.userid, mychicken->name,
diff --git a/mbbsd/fav.c b/mbbsd/fav.c
index fddccbb8..c5bd6c0d 100644
--- a/mbbsd/fav.c
+++ b/mbbsd/fav.c
@@ -457,7 +457,8 @@ int fav_save(void)
close(fd);
if (dashs(buf) == 4) {
time_t now = time(NULL);
- log_file(BBSHOME"/dirty.hack", 1, "%s %s", cuser.userid, ctime(&now));
+ log_file(BBSHOME "/dirty.hack", LOG_CREAT | LOG_VF,
+ "%s %s", cuser.userid, ctime(&now));
return -1;
}
Rename(buf, buf2);
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index 804b2af3..32bda2f8 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -102,12 +102,12 @@ log_usies(char *mode, char *mesg)
{
if (!mesg)
- log_file(FN_USIES, 1,
+ log_file(FN_USIES, LOG_CREAT | LOG_VF,
"%s %s %-12s Stay:%d (%s)\n",
Cdate(&now), mode, cuser.userid ,
(int)(now - login_start_time) / 60, cuser.username);
else
- log_file(FN_USIES, 1,
+ log_file(FN_USIES, LOG_CREAT | LOG_VF,
"%s %s %-12s %s\n",
Cdate(&now), mode, cuser.userid, mesg);
diff --git a/mbbsd/read.c b/mbbsd/read.c
index c2c33111..b732ac0c 100644
--- a/mbbsd/read.c
+++ b/mbbsd/read.c
@@ -353,7 +353,8 @@ select_read(keeploc_t * locmem, int sr_mode)
keyword, TTLEN, DOECHO))
return READ_REDRAW;
#ifdef KEYWORD_LOG
- log_file("keyword_search_log", 1, "%s:%s\n", currboard, keyword);
+ log_file("keyword_search_log", LOG_CREAT | LOG_VF,
+ "%s:%s\n", currboard, keyword);
#endif
}
else
diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c
index be260cf3..14c83953 100644
--- a/mbbsd/stuff.c
+++ b/mbbsd/stuff.c
@@ -594,22 +594,29 @@ log_user(const char *fmt, ...)
va_end(ap);
sethomefile(filename, cuser.userid, "USERLOG");
- return log_file(filename, 1, "%s: %s %s", cuser.userid, msg, Cdate(&now));
+ return log_file(filename, LOG_CREAT | LOG_VF,
+ "%s: %s %s", cuser.userid, msg, Cdate(&now));
}
-int log_file(char *fn, int ifcreate, const char *fmt,...)
+int log_file(char *fn, int flag, const char *fmt,...)
{
int fd;
- char msg[256];
- va_list ap;
- va_start(ap, fmt);
- vsnprintf(msg , 128, fmt, ap);
- va_end(ap);
+ char msg[256], *realmsg;
+ if( !(flag & LOG_VF) ){
+ realmsg = fmt;
+ }
+ else{
+ va_list ap;
+ va_start(ap, fmt);
+ vsnprintf(msg , 128, fmt, ap);
+ va_end(ap);
+ realmsg = msg;
+ }
- if( (fd = open(fn, O_APPEND | O_WRONLY | (ifcreate ? O_CREAT : 0),
- (ifcreate ? 0664 : 0))) < 0 )
+ if( (fd = open(fn, O_APPEND | O_WRONLY | ((flag & LOG_CREAT)? O_CREAT : 0),
+ ((flag & LOG_CREAT) ? 0664 : 0))) < 0 )
return -1;
- if( write(fd, msg, strlen(msg)) < 0 ){
+ if( write(fd, realmsg, strlen(realmsg)) < 0 ){
close(fd);
return -1;
}
diff --git a/mbbsd/talk.c b/mbbsd/talk.c
index 8c0c2ec3..bea9480d 100644
--- a/mbbsd/talk.c
+++ b/mbbsd/talk.c
@@ -2317,7 +2317,7 @@ userlist(void)
outs("\033[41m 現金不足~~\033[m");
} else {
deumoney(uentp->uid, ch - give_tax(ch));
- log_file(FN_MONEY, 1,
+ log_file(FN_MONEY, LOG_CREAT | LOG_VF,
"%s\t給%s\t%d\t%s\n", cuser.userid,
uentp->userid, ch, ctime(&currutmp->lastact));
mail_redenvelop(cuser.userid, uentp->userid,