aboutsummaryrefslogtreecommitdiffstats
path: root/src/interface.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-06-15 18:06:21 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-06-15 18:06:21 +0000
commit80dd76db7f927be1b6a967f43f36d705b701f153 (patch)
tree8d95e5e8eaaa92c3e581b1c991c0f82cdb33d435 /src/interface.c
parent28d6bb796a0cf53c8d53e0de78e00e1fedcbf02d (diff)
downloadmpd-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 '')
-rw-r--r--src/interface.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/interface.c b/src/interface.c
index 89229050d..29e372a5e 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -542,20 +542,21 @@ void flushAllInterfaceBuffers() {
}
}
-int interfacePrintWithFD(int fd,char * buffer) {
- int i;
- int buflen;
+int interfacePrintWithFD(int fd, char * buffer, int buflen) {
+ static int i = 0;
int copylen;
Interface * interface;
- if(!(buflen = strlen(buffer))) return -1;
-
- for(i=0;i<interface_max_connections;i++) {
- if(interfaces[i].open && interfaces[i].fd==fd) break;
+ if(i>=interface_max_connections ||
+ !interfaces[i].open || interfaces[i].fd!=fd)
+ {
+ for(i=0;i<interface_max_connections;i++) {
+ if(interfaces[i].open && interfaces[i].fd==fd) break;
+ }
+ if(i==interface_max_connections) return -1;
}
/* if fd isn't found or interfaces is going to be closed, do nothing */
- if(i==interface_max_connections) return -1;
if(interfaces[i].expired) return 0;
interface = interfaces+i;