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
)
19 memset(buffer
, 0, buffer_length
);
22 for (x
= 0; x
<= ptr
->stack_responses
; x
++)
27 unsigned int read_length
;
29 read_length
= memcached_io_read(ptr
, server_key
,
33 return MEMCACHED_UNKNOWN_READ_FAILURE
;
35 if (*buffer_ptr
== '\n')
41 ptr
->stack_responses
= 0;
46 return MEMCACHED_SUCCESS
;
48 return MEMCACHED_SUCCESS
;
49 case 'S': /* STORED STATS SERVER_ERROR */
51 if (buffer
[2] == 'A') /* STORED STATS */
52 return MEMCACHED_SUCCESS
;
53 else if (buffer
[1] == 'E')
54 return MEMCACHED_SERVER_ERROR
;
55 else if (buffer
[1] == 'T')
56 return MEMCACHED_STORED
;
58 return MEMCACHED_UNKNOWN_READ_FAILURE
;
60 case 'D': /* DELETED */
61 return MEMCACHED_DELETED
;
62 case 'N': /* NOT_FOUND */
65 return MEMCACHED_NOTFOUND
;
66 else if (buffer
[4] == 'S')
67 return MEMCACHED_NOTSTORED
;
69 return MEMCACHED_UNKNOWN_READ_FAILURE
;
71 case 'E': /* PROTOCOL ERROR or END */
75 else if (buffer
[1] == 'R')
76 return MEMCACHED_PROTOCOL_ERROR
;
78 return MEMCACHED_UNKNOWN_READ_FAILURE
;
80 case 'C': /* CLIENT ERROR */
81 return MEMCACHED_CLIENT_ERROR
;
83 return MEMCACHED_UNKNOWN_READ_FAILURE
;
87 return MEMCACHED_SUCCESS
;