Created
March 13, 2010 09:26
-
-
Save rayboyd/331221 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int sendrecv(libre rdb, char *sendbuf) | |
{ | |
int s, r; | |
char recvbuf[LIBRE_MAX_BUFSIZE]; | |
/* send data */ | |
s = send(rdb->fd, sendbuf, strlen(sendbuf), 0); | |
if (s < 0) return LIBRE_FAILURE; | |
free(sendbuf); | |
/* receive and process */ | |
memset(recvbuf, 0, LIBRE_MAX_BUFSIZE); | |
r = recv(rdb->fd, recvbuf, LIBRE_MAX_BUFSIZE, 0); | |
if (r < 0) return LIBRE_FAILURE; | |
/* check reply type and process reply acordingly */ | |
switch(recvbuf[0]) { | |
case LIBRE_RECV_ERROR: | |
return recv_error(rdb, recvbuf); | |
case LIBRE_RECV_INLINE: | |
return recv_inline(rdb, recvbuf); | |
case LIBRE_RECV_INTEGER: | |
return recv_integer(rdb, recvbuf); | |
case LIBRE_RECV_BULK: | |
return recv_bulk(rdb, recvbuf); | |
case LIBRE_RECV_MULTIBULK: | |
return recv_multibulk(rdb, recvbuf); | |
default: | |
return LIBRE_FAILURE; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment