4 memcached_response() is used to determine the return result
5 from an issued command.
9 #include "memcached_io.h"
11 memcached_return
memcached_response(memcached_st
*ptr
,
12 char *buffer
, size_t buffer_length
,
13 unsigned int server_key
)
18 memset(buffer
, 0, buffer_length
);
24 unsigned int read_length
;
26 read_length
= memcached_io_read(ptr
, server_key
,
30 return MEMCACHED_UNKNOWN_READ_FAILURE
;
32 if (*buffer_ptr
== '\n')
41 return MEMCACHED_SUCCESS
;
43 return MEMCACHED_SUCCESS
;
44 case 'S': /* STORED STATS SERVER_ERROR */
46 if (buffer
[2] == 'A') /* STORED STATS */
47 return MEMCACHED_SUCCESS
;
48 else if (buffer
[1] == 'E')
49 return MEMCACHED_SERVER_ERROR
;
50 else if (buffer
[1] == 'T')
51 return MEMCACHED_STORED
;
53 return MEMCACHED_UNKNOWN_READ_FAILURE
;
55 case 'D': /* DELETED */
56 return MEMCACHED_DELETED
;
57 case 'N': /* NOT_FOUND */
60 return MEMCACHED_NOTFOUND
;
61 else if (buffer
[4] == 'S')
62 return MEMCACHED_NOTSTORED
;
64 return MEMCACHED_UNKNOWN_READ_FAILURE
;
66 case 'E': /* PROTOCOL ERROR or END */
70 else if (buffer
[1] == 'R')
71 return MEMCACHED_PROTOCOL_ERROR
;
73 return MEMCACHED_UNKNOWN_READ_FAILURE
;
75 case 'C': /* CLIENT ERROR */
76 return MEMCACHED_CLIENT_ERROR
;
78 return MEMCACHED_UNKNOWN_READ_FAILURE
;
82 return MEMCACHED_SUCCESS
;