summaryrefslogtreecommitdiffstats
path: root/mbbsd/stuff.c
diff options
context:
space:
mode:
authorptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-04-30 02:13:39 +0800
committerptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-04-30 02:13:39 +0800
commit6c783cd8609ba2e65267eaa2cda8c46d7fc4ac8c (patch)
tree8829f8b00e4343f8d8ea97606ce4e58ccb186034 /mbbsd/stuff.c
parent4b2f5eeff9950ef1b7dd620d77efffc876aa76fa (diff)
downloadpttbbs-6c783cd8609ba2e65267eaa2cda8c46d7fc4ac8c.tar
pttbbs-6c783cd8609ba2e65267eaa2cda8c46d7fc4ac8c.tar.gz
pttbbs-6c783cd8609ba2e65267eaa2cda8c46d7fc4ac8c.tar.bz2
pttbbs-6c783cd8609ba2e65267eaa2cda8c46d7fc4ac8c.tar.lz
pttbbs-6c783cd8609ba2e65267eaa2cda8c46d7fc4ac8c.tar.xz
pttbbs-6c783cd8609ba2e65267eaa2cda8c46d7fc4ac8c.tar.zst
pttbbs-6c783cd8609ba2e65267eaa2cda8c46d7fc4ac8c.zip
change log_file()
log_user() git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1889 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/stuff.c')
-rw-r--r--mbbsd/stuff.c39
1 files changed, 32 insertions, 7 deletions
diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c
index 7ffc4f92..be260cf3 100644
--- a/mbbsd/stuff.c
+++ b/mbbsd/stuff.c
@@ -425,11 +425,16 @@ vmsg_lines(const int lines, const char msg[])
return ch;
}
-char getans(char *prompt)
+char getans(const char *fmt,...)
{
- char ans[5];
+ char msg[256];
+ char ans[5];
+ va_list ap;
+ va_start(ap, fmt);
+ vsnprintf(msg , 128, fmt, ap);
+ va_end(ap);
- getdata(b_lines, 0, prompt, ans, sizeof(ans), LCECHO);
+ getdata(b_lines, 0, msg, ans, sizeof(ans), LCECHO);
return ans[0];
}
@@ -439,7 +444,7 @@ getkey(const char *fmt,...)
char msg[256], i;
va_list ap;
va_start(ap, fmt);
- i = vsnprintf(msg , 100, fmt, ap);
+ i = vsnprintf(msg , 128, fmt, ap);
va_end(ap);
return vmsg_lines(b_lines, msg);
}
@@ -450,7 +455,7 @@ vmsg(const char *fmt,...)
char msg[256] = "\033[1;36;44m กป ", i;
va_list ap;
va_start(ap, fmt);
- i = vsnprintf(msg + 14, 100, fmt, ap);
+ i = vsnprintf(msg + 14, 128, fmt, ap);
va_end(ap);
for(i = i + 14; i < 71; i++)
msg[(int)i] = ' ';
@@ -578,13 +583,33 @@ printdash(char *mesg)
outch('\n');
}
-int log_file(char *fn, char *buf, int ifcreate)
+int
+log_user(const char *fmt, ...)
+{
+ char msg[256], filename[256];
+ va_list ap;
+
+ va_start(ap, fmt);
+ vsnprintf(msg , 128, fmt, ap);
+ va_end(ap);
+
+ sethomefile(filename, cuser.userid, "USERLOG");
+ return log_file(filename, 1, "%s: %s %s", cuser.userid, msg, Cdate(&now));
+}
+
+int log_file(char *fn, int ifcreate, const char *fmt,...)
{
int fd;
+ char msg[256];
+ va_list ap;
+ va_start(ap, fmt);
+ vsnprintf(msg , 128, fmt, ap);
+ va_end(ap);
+
if( (fd = open(fn, O_APPEND | O_WRONLY | (ifcreate ? O_CREAT : 0),
(ifcreate ? 0664 : 0))) < 0 )
return -1;
- if( write(fd, buf, strlen(buf)) < 0 ){
+ if( write(fd, msg, strlen(msg)) < 0 ){
close(fd);
return -1;
}