506dbb07a6f5760a663f7d849e785fed7deaff97
[awesomized/libmemcached] / lib / memcached_verbosity.c
1 #include <memcached.h>
2
3 memcached_return memcached_verbosity(memcached_st *ptr, unsigned int verbosity)
4 {
5 unsigned int x;
6 size_t send_length;
7 memcached_return rc;
8 char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
9
10 rc= memcached_connect(ptr);
11
12 if (rc != MEMCACHED_SUCCESS)
13 rc= MEMCACHED_SOME_ERRORS;
14
15 send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
16 "verbosity %u\r\n", verbosity);
17
18 for (x= 0; x < ptr->number_of_hosts; x++)
19 {
20 memcached_return rc;
21
22 if ((write(ptr->hosts[x].fd, buffer, send_length) == -1))
23 return MEMCACHED_WRITE_FAILURE;
24
25 rc= memcached_response(ptr, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, x);
26
27 if (rc != MEMCACHED_SUCCESS)
28 rc= MEMCACHED_SOME_ERRORS;
29 }
30
31 return rc;
32 }