diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-06-15 18:06:21 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-06-15 18:06:21 +0000 |
commit | 80dd76db7f927be1b6a967f43f36d705b701f153 (patch) | |
tree | 8d95e5e8eaaa92c3e581b1c991c0f82cdb33d435 /src/myfprintf.c | |
parent | 28d6bb796a0cf53c8d53e0de78e00e1fedcbf02d (diff) | |
download | mpd-80dd76db7f927be1b6a967f43f36d705b701f153.tar.gz mpd-80dd76db7f927be1b6a967f43f36d705b701f153.tar.xz mpd-80dd76db7f927be1b6a967f43f36d705b701f153.zip |
fix C99 stuff for commandError
also some slight optimizations to interfacePrintWithFD() and myfprintf()
git-svn-id: https://svn.musicpd.org/mpd/trunk@1503 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/myfprintf.c')
-rw-r--r-- | src/myfprintf.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/myfprintf.c b/src/myfprintf.c index 42bc0049a..e2c366a1d 100644 --- a/src/myfprintf.c +++ b/src/myfprintf.c @@ -37,8 +37,7 @@ FILE * myfprintf_err; char * myfprintf_outFilename; char * myfprintf_errFilename; -void blockingWrite(int fd, char * string) { - int len = strlen(string); +void blockingWrite(int fd, char * string, int len) { int ret; while(len) { @@ -71,28 +70,26 @@ void myfprintf(FILE * fp, char * format, ... ) { char buffer[BUFFER_LENGTH+1]; va_list arglist; int fd = fileno(fp); - int fcntlret; memset(buffer,0,BUFFER_LENGTH+1); va_start(arglist,format); - while((fcntlret=fcntl(fd,F_GETFL))==-1 && errno==EINTR); if(myfprintf_stdLogMode && (fd==1 || fd==2)) { time_t t = time(NULL); if(fd==1) fp = myfprintf_out; else fp = myfprintf_err; strftime(buffer,14,"%b %e %R",localtime(&t)); - blockingWrite(fd,buffer); - blockingWrite(fd," : "); + blockingWrite(fd,buffer,strlen(buffer)); + blockingWrite(fd," : ",3); vsnprintf(buffer,BUFFER_LENGTH,format,arglist); - blockingWrite(fd,buffer); + blockingWrite(fd,buffer,strlen(buffer)); } else { + int len; vsnprintf(buffer,BUFFER_LENGTH,format,arglist); - if(!(fcntlret & O_NONBLOCK) || - interfacePrintWithFD(fd,buffer)<0) - { - blockingWrite(fd,buffer); + len = strlen(buffer); + if(interfacePrintWithFD(fd,buffer,len)<0) { + blockingWrite(fd,buffer,len); } } |