Fix CFLAGS in socket.
[awesomized/libmemcached] / libmemcached / flag.cc
1 /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
2 *
3 * Libmemcached library
4 *
5 * Copyright (C) 2012 Data Differential, http://datadifferential.com/
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
9 * met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 *
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following disclaimer
16 * in the documentation and/or other materials provided with the
17 * distribution.
18 *
19 * * The names of its contributors may not be used to endorse or
20 * promote products derived from this software without specific prior
21 * written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *
35 */
36
37 #include <libmemcached/common.h>
38
39 bool memcached_flag(const memcached_st& memc, const memcached_flag_t flag)
40 {
41 switch (flag)
42 {
43 case MEMCACHED_FLAG_AUTO_EJECT_HOSTS:
44 return memcached_is_auto_eject_hosts(&memc);
45
46 case MEMCACHED_FLAG_BINARY_PROTOCOL:
47 return memcached_is_binary(&memc);
48
49 case MEMCACHED_FLAG_BUFFER_REQUESTS:
50 return memcached_is_buffering(&memc);
51
52 case MEMCACHED_FLAG_HASH_WITH_NAMESPACE:
53 return memcached_is_hash_with_namespace(&memc);
54
55 case MEMCACHED_FLAG_NO_BLOCK:
56 return memcached_is_no_block(&memc);
57
58 case MEMCACHED_FLAG_REPLY:
59 return memcached_is_replying(&memc);
60
61 case MEMCACHED_FLAG_RANDOMIZE_REPLICA_READ:
62 return memcached_is_randomize_replica_read(&memc);
63
64 case MEMCACHED_FLAG_SUPPORT_CAS:
65 return memcached_is_cas(&memc);
66
67 case MEMCACHED_FLAG_TCP_NODELAY:
68 return memcached_is_tcp_nodelay(&memc);
69
70 case MEMCACHED_FLAG_USE_SORT_HOSTS:
71 return memcached_is_use_sort_hosts(&memc);
72
73 case MEMCACHED_FLAG_USE_UDP:
74 return memcached_is_udp(&memc);
75
76 case MEMCACHED_FLAG_VERIFY_KEY:
77 return memcached_is_verify_key(&memc);
78
79 case MEMCACHED_FLAG_TCP_KEEPALIVE:
80 return memcached_is_use_sort_hosts(&memc);
81
82 case MEMCACHED_FLAG_IS_AES:
83 return memcached_is_aes(&memc);
84
85 case MEMCACHED_FLAG_IS_FETCHING_VERSION:
86 return memcached_is_fetching_version(&memc);
87 }
88
89 abort();
90 }
91
92 void memcached_flag(memcached_st& memc, const memcached_flag_t flag, const bool arg)
93 {
94 switch (flag)
95 {
96 case MEMCACHED_FLAG_AUTO_EJECT_HOSTS:
97 memcached_set_auto_eject_hosts(memc, arg);
98 break;
99
100 case MEMCACHED_FLAG_BINARY_PROTOCOL:
101 memcached_set_binary(memc, arg);
102 break;
103
104 case MEMCACHED_FLAG_BUFFER_REQUESTS:
105 memcached_set_buffering(memc, arg);
106 break;
107
108 case MEMCACHED_FLAG_HASH_WITH_NAMESPACE:
109 memcached_set_hash_with_namespace(memc, arg);
110 break;
111
112 case MEMCACHED_FLAG_NO_BLOCK:
113 memcached_set_no_block(memc, arg);
114 break;
115
116 case MEMCACHED_FLAG_REPLY:
117 memcached_set_replying(memc, arg);
118 break;
119
120 case MEMCACHED_FLAG_RANDOMIZE_REPLICA_READ:
121 memcached_set_randomize_replica_read(memc, arg);
122 break;
123
124 case MEMCACHED_FLAG_SUPPORT_CAS:
125 memcached_set_cas(memc, arg);
126 break;
127
128 case MEMCACHED_FLAG_TCP_NODELAY:
129 memcached_set_tcp_nodelay(memc, arg);
130 break;
131
132 case MEMCACHED_FLAG_USE_SORT_HOSTS:
133 memcached_set_use_sort_hosts(memc, arg);
134 break;
135
136 case MEMCACHED_FLAG_USE_UDP:
137 memcached_set_udp(memc, arg);
138 break;
139
140 case MEMCACHED_FLAG_VERIFY_KEY:
141 memcached_set_verify_key(memc, arg);
142 break;
143
144 case MEMCACHED_FLAG_TCP_KEEPALIVE:
145 memcached_set_use_sort_hosts(memc, arg);
146 break;
147
148 case MEMCACHED_FLAG_IS_AES:
149 memcached_set_aes(memc, arg);
150 break;
151
152 case MEMCACHED_FLAG_IS_FETCHING_VERSION:
153 memcached_set_fetching_version(memc, arg);
154 break;
155 }
156 }