diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-05-03 23:19:01 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-05-03 23:19:01 +0800 |
commit | 923905e83ad2d075f0d40125e8acbd0ca88ea938 (patch) | |
tree | bd8287047cf35c6c7e1e98057876d7be07e470a3 /mbbsd/stuff.c | |
parent | 79890093f845d2c70ffec2e0699700380e623cd8 (diff) | |
download | pttbbs-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/stuff.c')
-rw-r--r-- | mbbsd/stuff.c | 27 |
1 files changed, 17 insertions, 10 deletions
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; } |