Just print the server response as is

Fixes #284.
This commit is contained in:
Bastien Dejean 2015-08-15 10:55:40 +02:00
parent 09c603a85e
commit 5f74f080b3
2 changed files with 4 additions and 11 deletions

12
bspc.c
View file

@ -73,9 +73,8 @@ int main(int argc, char *argv[])
if (send(fd, msg, msg_len, 0) == -1)
err("Failed to send the data.\n");
int ret = 0, nb, p;
int ret = 0, nb;
while ((nb = recv(fd, rsp, sizeof(rsp)-1, 0)) > 0) {
int peek = recv(fd, &p, 1, MSG_PEEK);
if (nb == 1 && rsp[0] < MSG_LENGTH) {
ret = rsp[0];
if (ret == MSG_UNKNOWN) {
@ -84,15 +83,8 @@ int main(int argc, char *argv[])
warn("Invalid syntax.\n");
}
} else {
rsp[nb--] = '\0';
if (peek > 0) {
rsp[nb] = '\0';
printf("%s", rsp);
} else {
while (nb >= 0 && isspace(rsp[nb])) {
rsp[nb--] = '\0';
}
printf("%s\n", rsp);
}
fflush(stdout);
}
}

View file

@ -1148,6 +1148,7 @@ int get_setting(coordinates_t loc, char *name, FILE* rsp)
#undef GETBOOL
else
return MSG_FAILURE;
fprintf(rsp, "\n");
return MSG_SUCCESS;
}