ipc_recv_message: store message_type, don’t compare. add distinct EOF retval

Also use ELOG, which requires i3-msg to provide logging functions.
This commit is contained in:
Michael Stapelberg
2013-01-23 18:50:21 +01:00
parent e8fa3eeebd
commit dcb8ac84f8
5 changed files with 53 additions and 25 deletions

@ -101,15 +101,18 @@ void display_running_version(void) {
err(EXIT_FAILURE, "IPC: write()");
uint32_t reply_length;
uint32_t reply_type;
uint8_t *reply;
int ret;
if ((ret = ipc_recv_message(sockfd, I3_IPC_MESSAGE_TYPE_GET_VERSION,
&reply_length, &reply)) != 0) {
if ((ret = ipc_recv_message(sockfd, &reply_type, &reply_length, &reply)) != 0) {
if (ret == -1)
err(EXIT_FAILURE, "IPC: read()");
exit(EXIT_FAILURE);
}
if (reply_type != I3_IPC_MESSAGE_TYPE_GET_VERSION)
errx(EXIT_FAILURE, "Got reply type %d, but expected %d (GET_VERSION)", reply_type, I3_IPC_MESSAGE_TYPE_GET_VERSION);
#if YAJL_MAJOR >= 2
yajl_handle handle = yajl_alloc(&version_callbacks, NULL, NULL);
#else