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 unsigned int max_messages
;
21 memset(buffer
, 0, buffer_length
);
24 max_messages
= memcached_server_response_count(ptr
, server_key
);
25 for (x
= 0; x
<= max_messages
; x
++)
31 unsigned int read_length
;
33 read_length
= memcached_io_read(ptr
, server_key
,
37 return MEMCACHED_UNKNOWN_READ_FAILURE
;
39 if (*buffer_ptr
== '\n')
45 if (memcached_server_response_count(ptr
, server_key
))
46 memcached_server_response_decrement(ptr
, server_key
);
52 return MEMCACHED_SUCCESS
;
54 return MEMCACHED_SUCCESS
;
55 case 'S': /* STORED STATS SERVER_ERROR */
57 if (buffer
[2] == 'A') /* STORED STATS */
58 return MEMCACHED_STAT
;
59 else if (buffer
[1] == 'E')
60 return MEMCACHED_SERVER_ERROR
;
61 else if (buffer
[1] == 'T')
62 return MEMCACHED_STORED
;
64 return MEMCACHED_UNKNOWN_READ_FAILURE
;
66 case 'D': /* DELETED */
67 return MEMCACHED_DELETED
;
68 case 'N': /* NOT_FOUND */
71 return MEMCACHED_NOTFOUND
;
72 else if (buffer
[4] == 'S')
73 return MEMCACHED_NOTSTORED
;
75 return MEMCACHED_UNKNOWN_READ_FAILURE
;
77 case 'E': /* PROTOCOL ERROR or END */
81 else if (buffer
[1] == 'R')
82 return MEMCACHED_PROTOCOL_ERROR
;
84 return MEMCACHED_UNKNOWN_READ_FAILURE
;
86 case 'C': /* CLIENT ERROR */
87 return MEMCACHED_CLIENT_ERROR
;
89 return MEMCACHED_UNKNOWN_READ_FAILURE
;
93 return MEMCACHED_SUCCESS
;