memcached 1.2.6 → 1.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (225) hide show
  1. data/CHANGELOG +2 -0
  2. data/Manifest +206 -12
  3. data/Rakefile +32 -1
  4. data/ext/extconf.rb +10 -35
  5. data/ext/libmemcached-0.32/AUTHORS +7 -0
  6. data/ext/libmemcached-0.32/COPYING +32 -0
  7. data/ext/libmemcached-0.32/ChangeLog +303 -0
  8. data/ext/libmemcached-0.32/INSTALL +302 -0
  9. data/ext/libmemcached-0.32/Makefile.am +36 -0
  10. data/ext/libmemcached-0.32/Makefile.in +828 -0
  11. data/ext/libmemcached-0.32/NEWS +1 -0
  12. data/ext/libmemcached-0.32/README +33 -0
  13. data/ext/libmemcached-0.32/THANKS +14 -0
  14. data/ext/libmemcached-0.32/TODO +11 -0
  15. data/ext/libmemcached-0.32/aclocal.m4 +1852 -0
  16. data/ext/libmemcached-0.32/clients/Makefile.am +73 -0
  17. data/ext/libmemcached-0.32/clients/Makefile.in +770 -0
  18. data/ext/libmemcached-0.32/clients/client_options.h +32 -0
  19. data/ext/libmemcached-0.32/clients/execute.c +64 -0
  20. data/ext/libmemcached-0.32/clients/execute.h +5 -0
  21. data/ext/libmemcached-0.32/clients/generator.c +74 -0
  22. data/ext/libmemcached-0.32/clients/generator.h +20 -0
  23. data/ext/libmemcached-0.32/clients/memcat.c +178 -0
  24. data/ext/libmemcached-0.32/clients/memcp.c +251 -0
  25. data/ext/libmemcached-0.32/clients/memdump.c +170 -0
  26. data/ext/libmemcached-0.32/clients/memerror.c +80 -0
  27. data/ext/libmemcached-0.32/clients/memflush.c +143 -0
  28. data/ext/libmemcached-0.32/clients/memrm.c +160 -0
  29. data/ext/libmemcached-0.32/clients/memslap.c +441 -0
  30. data/ext/libmemcached-0.32/clients/memstat.c +326 -0
  31. data/ext/libmemcached-0.32/clients/utilities.c +207 -0
  32. data/ext/libmemcached-0.32/clients/utilities.h +41 -0
  33. data/ext/libmemcached-0.32/config.h.in +252 -0
  34. data/ext/libmemcached-0.32/config/compile +143 -0
  35. data/ext/libmemcached-0.32/config/config.guess +1561 -0
  36. data/ext/libmemcached-0.32/config/config.rpath +666 -0
  37. data/ext/libmemcached-0.32/config/config.sub +1686 -0
  38. data/ext/libmemcached-0.32/config/depcomp +630 -0
  39. data/ext/libmemcached-0.32/config/install-sh +520 -0
  40. data/ext/libmemcached-0.32/config/ltmain.sh +8406 -0
  41. data/ext/libmemcached-0.32/config/missing +376 -0
  42. data/ext/libmemcached-0.32/configure +23048 -0
  43. data/ext/libmemcached-0.32/configure.ac +122 -0
  44. data/ext/libmemcached-0.32/docs/Makefile.am +415 -0
  45. data/ext/libmemcached-0.32/docs/Makefile.in +918 -0
  46. data/ext/libmemcached-0.32/docs/libmemcached.pod +123 -0
  47. data/ext/libmemcached-0.32/docs/libmemcached_examples.pod +115 -0
  48. data/ext/libmemcached-0.32/docs/libmemcachedutil.pod +40 -0
  49. data/ext/libmemcached-0.32/docs/memcached_analyze.pod +52 -0
  50. data/ext/libmemcached-0.32/docs/memcached_auto.pod +97 -0
  51. data/ext/libmemcached-0.32/docs/memcached_behavior.pod +224 -0
  52. data/ext/libmemcached-0.32/docs/memcached_callback.pod +123 -0
  53. data/ext/libmemcached-0.32/docs/memcached_create.pod +61 -0
  54. data/ext/libmemcached-0.32/docs/memcached_delete.pod +54 -0
  55. data/ext/libmemcached-0.32/docs/memcached_dump.pod +53 -0
  56. data/ext/libmemcached-0.32/docs/memcached_flush.pod +46 -0
  57. data/ext/libmemcached-0.32/docs/memcached_flush_buffers.pod +42 -0
  58. data/ext/libmemcached-0.32/docs/memcached_generate_hash_value.pod +57 -0
  59. data/ext/libmemcached-0.32/docs/memcached_get.pod +161 -0
  60. data/ext/libmemcached-0.32/docs/memcached_memory_allocators.pod +73 -0
  61. data/ext/libmemcached-0.32/docs/memcached_pool.pod +77 -0
  62. data/ext/libmemcached-0.32/docs/memcached_quit.pod +47 -0
  63. data/ext/libmemcached-0.32/docs/memcached_sasl.pod +63 -0
  64. data/ext/libmemcached-0.32/docs/memcached_server_st.pod +75 -0
  65. data/ext/libmemcached-0.32/docs/memcached_servers.pod +102 -0
  66. data/ext/libmemcached-0.32/docs/memcached_set.pod +187 -0
  67. data/ext/libmemcached-0.32/docs/memcached_stats.pod +82 -0
  68. data/ext/libmemcached-0.32/docs/memcached_strerror.pod +46 -0
  69. data/ext/libmemcached-0.32/docs/memcached_user_data.pod +49 -0
  70. data/ext/libmemcached-0.32/docs/memcached_verbosity.pod +41 -0
  71. data/ext/libmemcached-0.32/docs/memcached_version.pod +56 -0
  72. data/ext/libmemcached-0.32/docs/memcat.pod +37 -0
  73. data/ext/libmemcached-0.32/docs/memcp.pod +40 -0
  74. data/ext/libmemcached-0.32/docs/memdump.pod +31 -0
  75. data/ext/libmemcached-0.32/docs/memerror.pod +30 -0
  76. data/ext/libmemcached-0.32/docs/memflush.pod +35 -0
  77. data/ext/libmemcached-0.32/docs/memrm.pod +34 -0
  78. data/ext/libmemcached-0.32/docs/memslap.pod +33 -0
  79. data/ext/libmemcached-0.32/docs/memstat.pod +35 -0
  80. data/ext/libmemcached-0.32/libmemcached/Makefile.am +107 -0
  81. data/ext/libmemcached-0.32/libmemcached/Makefile.in +1050 -0
  82. data/ext/libmemcached-0.32/libmemcached/byteorder.c +31 -0
  83. data/ext/libmemcached-0.32/libmemcached/common.h +183 -0
  84. data/ext/libmemcached-0.32/libmemcached/crc.c +86 -0
  85. data/ext/libmemcached-0.32/libmemcached/hsieh_hash.c +68 -0
  86. data/ext/libmemcached-0.32/libmemcached/jenkins_hash.c +213 -0
  87. data/ext/libmemcached-0.32/libmemcached/libmemcached.ver +1 -0
  88. data/ext/libmemcached-0.32/libmemcached/libmemcached_probes.d +28 -0
  89. data/ext/libmemcached-0.32/libmemcached/libmemcached_probes.h +78 -0
  90. data/ext/libmemcached-0.32/libmemcached/md5.c +354 -0
  91. data/ext/libmemcached-0.32/libmemcached/memcached.c +152 -0
  92. data/ext/libmemcached-0.32/libmemcached/memcached.h +302 -0
  93. data/ext/libmemcached-0.32/libmemcached/memcached.hpp +799 -0
  94. data/ext/libmemcached-0.32/libmemcached/memcached/README.txt +7 -0
  95. data/ext/libmemcached-0.32/libmemcached/memcached/protocol_binary.h +366 -0
  96. data/ext/libmemcached-0.32/libmemcached/memcached_allocators.c +72 -0
  97. data/ext/libmemcached-0.32/libmemcached/memcached_analyze.c +100 -0
  98. data/ext/libmemcached-0.32/libmemcached/memcached_auto.c +207 -0
  99. data/ext/libmemcached-0.32/libmemcached/memcached_behavior.c +285 -0
  100. data/ext/libmemcached-0.32/libmemcached/memcached_callback.c +175 -0
  101. data/ext/libmemcached-0.32/libmemcached/memcached_configure.h.in +23 -0
  102. data/ext/libmemcached-0.32/libmemcached/memcached_connect.c +361 -0
  103. data/ext/libmemcached-0.32/libmemcached/memcached_constants.h +145 -0
  104. data/ext/libmemcached-0.32/libmemcached/memcached_delete.c +0 -0
  105. data/ext/libmemcached-0.32/libmemcached/memcached_do.c +34 -0
  106. data/ext/libmemcached-0.32/libmemcached/memcached_dump.c +79 -0
  107. data/ext/libmemcached-0.32/libmemcached/memcached_fetch.c +102 -0
  108. data/ext/libmemcached-0.32/libmemcached/memcached_flush.c +89 -0
  109. data/ext/libmemcached-0.32/libmemcached/memcached_flush_buffers.c +22 -0
  110. data/ext/libmemcached-0.32/libmemcached/memcached_get.c +495 -0
  111. data/ext/libmemcached-0.32/libmemcached/memcached_get.h +87 -0
  112. data/ext/libmemcached-0.32/libmemcached/memcached_hash.c +252 -0
  113. data/ext/libmemcached-0.32/libmemcached/memcached_hosts.c +510 -0
  114. data/ext/libmemcached-0.32/libmemcached/memcached_internal.h +31 -0
  115. data/ext/libmemcached-0.32/libmemcached/memcached_io.c +547 -0
  116. data/ext/libmemcached-0.32/libmemcached/memcached_io.h +59 -0
  117. data/ext/libmemcached-0.32/libmemcached/memcached_key.c +28 -0
  118. data/ext/libmemcached-0.32/libmemcached/memcached_parse.c +74 -0
  119. data/ext/libmemcached-0.32/libmemcached/memcached_pool.h +38 -0
  120. data/ext/libmemcached-0.32/libmemcached/memcached_purge.c +76 -0
  121. data/ext/libmemcached-0.32/libmemcached/memcached_quit.c +75 -0
  122. data/ext/libmemcached-0.32/libmemcached/memcached_response.c +528 -0
  123. data/ext/libmemcached-0.32/libmemcached/memcached_result.c +57 -0
  124. data/ext/libmemcached-0.32/libmemcached/memcached_result.h +59 -0
  125. data/ext/libmemcached-0.32/libmemcached/memcached_sasl.c +225 -0
  126. data/ext/libmemcached-0.32/libmemcached/memcached_sasl.h +44 -0
  127. data/ext/libmemcached-0.32/libmemcached/memcached_server.c +159 -0
  128. data/ext/libmemcached-0.32/libmemcached/memcached_server.h +93 -0
  129. data/ext/libmemcached-0.32/libmemcached/memcached_stats.c +454 -0
  130. data/ext/libmemcached-0.32/libmemcached/memcached_storage.c +514 -0
  131. data/ext/libmemcached-0.32/libmemcached/memcached_storage.h +107 -0
  132. data/ext/libmemcached-0.32/libmemcached/memcached_strerror.c +92 -0
  133. data/ext/libmemcached-0.32/libmemcached/memcached_string.c +138 -0
  134. data/ext/libmemcached-0.32/libmemcached/memcached_string.h +53 -0
  135. data/ext/libmemcached-0.32/libmemcached/memcached_types.h +44 -0
  136. data/ext/libmemcached-0.32/libmemcached/memcached_util.h +15 -0
  137. data/ext/libmemcached-0.32/libmemcached/memcached_verbosity.c +36 -0
  138. data/ext/libmemcached-0.32/libmemcached/memcached_version.c +112 -0
  139. data/ext/libmemcached-0.32/libmemcached/memcached_watchpoint.h +38 -0
  140. data/ext/libmemcached-0.32/libmemcached/murmur_hash.c +76 -0
  141. data/ext/libmemcached-0.32/libmemcached/visibility.h +51 -0
  142. data/ext/libmemcached-0.32/libmemcachedutil/Makefile.am +11 -0
  143. data/ext/libmemcached-0.32/libmemcachedutil/Makefile.in +602 -0
  144. data/ext/libmemcached-0.32/libmemcachedutil/libmemcachedutil.ver +1 -0
  145. data/ext/libmemcached-0.32/libmemcachedutil/memcached_pool.c +170 -0
  146. data/ext/libmemcached-0.32/m4/ac_cxx_compile_stdcxx_0x.m4 +103 -0
  147. data/ext/libmemcached-0.32/m4/ac_cxx_header_stdcxx_98.m4 +67 -0
  148. data/ext/libmemcached-0.32/m4/acx_pthread.m4 +276 -0
  149. data/ext/libmemcached-0.32/m4/byteorder.m4 +40 -0
  150. data/ext/libmemcached-0.32/m4/deprecated.m4 +17 -0
  151. data/ext/libmemcached-0.32/m4/enable_utillib.m4 +16 -0
  152. data/ext/libmemcached-0.32/m4/extensions.m4 +94 -0
  153. data/ext/libmemcached-0.32/m4/hsieh.m4 +18 -0
  154. data/ext/libmemcached-0.32/m4/lib-prefix.m4 +221 -0
  155. data/ext/libmemcached-0.32/m4/libtool.m4 +7360 -0
  156. data/ext/libmemcached-0.32/m4/ltoptions.m4 +368 -0
  157. data/ext/libmemcached-0.32/m4/ltsugar.m4 +123 -0
  158. data/ext/libmemcached-0.32/m4/ltversion.m4 +23 -0
  159. data/ext/libmemcached-0.32/m4/lt~obsolete.m4 +92 -0
  160. data/ext/libmemcached-0.32/m4/memcached.m4 +30 -0
  161. data/ext/libmemcached-0.32/m4/pandora_64bit.m4 +55 -0
  162. data/ext/libmemcached-0.32/m4/pandora_canonical.m4 +151 -0
  163. data/ext/libmemcached-0.32/m4/pandora_check_compiler_version.m4 +37 -0
  164. data/ext/libmemcached-0.32/m4/pandora_check_cxx_standard.m4 +16 -0
  165. data/ext/libmemcached-0.32/m4/pandora_enable_dtrace.m4 +41 -0
  166. data/ext/libmemcached-0.32/m4/pandora_ensure_gcc_version.m4 +36 -0
  167. data/ext/libmemcached-0.32/m4/pandora_have_better_malloc.m4 +54 -0
  168. data/ext/libmemcached-0.32/m4/pandora_have_sasl.m4 +133 -0
  169. data/ext/libmemcached-0.32/m4/pandora_header_assert.m4 +23 -0
  170. data/ext/libmemcached-0.32/m4/pandora_libtool.m4 +15 -0
  171. data/ext/libmemcached-0.32/m4/pandora_optimize.m4 +79 -0
  172. data/ext/libmemcached-0.32/m4/pandora_shared_ptr.m4 +56 -0
  173. data/ext/libmemcached-0.32/m4/pandora_vc_build.m4 +32 -0
  174. data/ext/libmemcached-0.32/m4/pandora_warnings.m4 +262 -0
  175. data/ext/libmemcached-0.32/m4/pod2man.m4 +7 -0
  176. data/ext/libmemcached-0.32/m4/protocol_binary.m4 +23 -0
  177. data/ext/libmemcached-0.32/m4/setsockopt.m4 +57 -0
  178. data/ext/libmemcached-0.32/m4/visibility.m4 +52 -0
  179. data/ext/libmemcached-0.32/support/Makefile.am +4 -0
  180. data/ext/libmemcached-0.32/support/Makefile.in +485 -0
  181. data/ext/libmemcached-0.32/support/libmemcached-fc.spec.in +105 -0
  182. data/ext/libmemcached-0.32/support/libmemcached.pc.in +10 -0
  183. data/ext/libmemcached-0.32/support/libmemcached.spec +105 -0
  184. data/ext/libmemcached-0.32/support/libmemcached.spec.in +105 -0
  185. data/ext/libmemcached-0.32/support/set_benchmark.sh +5 -0
  186. data/ext/libmemcached-0.32/tests/Makefile.am +105 -0
  187. data/ext/libmemcached-0.32/tests/Makefile.in +748 -0
  188. data/ext/libmemcached-0.32/tests/atomsmasher.c +245 -0
  189. data/ext/libmemcached-0.32/tests/function.c +4781 -0
  190. data/ext/libmemcached-0.32/tests/ketama_test_cases.h +108 -0
  191. data/ext/libmemcached-0.32/tests/output.cmp +7 -0
  192. data/ext/libmemcached-0.32/tests/output.res +7 -0
  193. data/ext/libmemcached-0.32/tests/output2.res +46 -0
  194. data/ext/libmemcached-0.32/tests/plus.cpp +293 -0
  195. data/ext/libmemcached-0.32/tests/r/memcat.res +19 -0
  196. data/ext/libmemcached-0.32/tests/r/memcp.res +27 -0
  197. data/ext/libmemcached-0.32/tests/r/memrm.res +19 -0
  198. data/ext/libmemcached-0.32/tests/r/memslap.res +33 -0
  199. data/ext/libmemcached-0.32/tests/r/memstat.res +33 -0
  200. data/ext/libmemcached-0.32/tests/server.c +118 -0
  201. data/ext/libmemcached-0.32/tests/server.h +25 -0
  202. data/ext/libmemcached-0.32/tests/start.c +16 -0
  203. data/ext/libmemcached-0.32/tests/t/memcat.test +4 -0
  204. data/ext/libmemcached-0.32/tests/t/memcp.test +3 -0
  205. data/ext/libmemcached-0.32/tests/t/memrm.test +3 -0
  206. data/ext/libmemcached-0.32/tests/t/memslap.test +5 -0
  207. data/ext/libmemcached-0.32/tests/t/memstat.test +3 -0
  208. data/ext/libmemcached-0.32/tests/test.c +137 -0
  209. data/ext/libmemcached-0.32/tests/test.h +46 -0
  210. data/ext/libmemcached-0.32/tests/udp.c +76 -0
  211. data/memcached.gemspec +4 -4
  212. data/test/unit/memcached_test.rb +30 -0
  213. metadata +213 -16
  214. data/ext/libmemcached-0.32.tar.gz +0 -0
  215. data/ext/libmemcached-1.patch +0 -270
  216. data/ext/libmemcached-10.patch +0 -12
  217. data/ext/libmemcached-2.patch +0 -116
  218. data/ext/libmemcached-3.patch +0 -8
  219. data/ext/libmemcached-4.patch +0 -40
  220. data/ext/libmemcached-5.patch +0 -832
  221. data/ext/libmemcached-6.patch +0 -20
  222. data/ext/libmemcached-7.patch +0 -2989
  223. data/ext/libmemcached-8.patch +0 -137
  224. data/ext/libmemcached-9.patch +0 -13
  225. data/ext/sasl.patch +0 -29283
@@ -0,0 +1,170 @@
1
+ #include "libmemcached/common.h"
2
+ #include <stdio.h>
3
+ #include <stdlib.h>
4
+ #include <inttypes.h>
5
+ #include <unistd.h>
6
+ #include <getopt.h>
7
+ #include <sys/types.h>
8
+ #include <sys/stat.h>
9
+ #include <sys/types.h>
10
+ #include <fcntl.h>
11
+ #include <errno.h>
12
+ #include <strings.h>
13
+ #include <string.h>
14
+
15
+ #include <libmemcached/memcached.h>
16
+
17
+ #include "client_options.h"
18
+ #include "utilities.h"
19
+
20
+ #define PROGRAM_NAME "memdump"
21
+ #define PROGRAM_DESCRIPTION "Dump all values from one or many servers."
22
+
23
+ /* Prototypes */
24
+ void options_parse(int argc, char *argv[]);
25
+
26
+ static int opt_binary=0;
27
+ static int opt_verbose= 0;
28
+ static char *opt_servers= NULL;
29
+ static char *opt_hash= NULL;
30
+ static char *opt_username;
31
+ static char *opt_passwd;
32
+
33
+ /* Print the keys and counter how many were found */
34
+ static memcached_return key_printer(memcached_st *ptr __attribute__((unused)),
35
+ const char *key, size_t key_length,
36
+ void *context __attribute__((unused)))
37
+ {
38
+ printf("%.*s\n", (uint32_t)key_length, key);
39
+
40
+ return MEMCACHED_SUCCESS;
41
+ }
42
+
43
+ int main(int argc, char *argv[])
44
+ {
45
+ memcached_st *memc;
46
+ memcached_return rc;
47
+ memcached_server_st *servers;
48
+ memcached_dump_func callbacks[1];
49
+
50
+ callbacks[0]= &key_printer;
51
+
52
+ options_parse(argc, argv);
53
+
54
+ memc= memcached_create(NULL);
55
+ process_hash_option(memc, opt_hash);
56
+
57
+ if (!opt_servers)
58
+ {
59
+ char *temp;
60
+
61
+ if ((temp= getenv("MEMCACHED_SERVERS")))
62
+ opt_servers= strdup(temp);
63
+ else
64
+ {
65
+ fprintf(stderr, "No Servers provided\n");
66
+ exit(1);
67
+ }
68
+ }
69
+
70
+ if (opt_servers)
71
+ servers= memcached_servers_parse(opt_servers);
72
+ else
73
+ servers= memcached_servers_parse(argv[--argc]);
74
+
75
+ memcached_server_push(memc, servers);
76
+ memcached_server_list_free(servers);
77
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL,
78
+ (uint64_t)opt_binary);
79
+ if (!initialize_sasl(memc, opt_username, opt_passwd))
80
+ {
81
+ memcached_free(memc);
82
+ return 1;
83
+ }
84
+
85
+ rc= memcached_dump(memc, callbacks, NULL, 1);
86
+
87
+ if (rc != MEMCACHED_SUCCESS)
88
+ {
89
+ fprintf(stderr, "memdump: memcache error %s", memcached_strerror(memc, rc));
90
+ if (memc->cached_errno)
91
+ fprintf(stderr, " system error %s", strerror(memc->cached_errno));
92
+ fprintf(stderr, "\n");
93
+ }
94
+
95
+ memcached_free(memc);
96
+
97
+ if (opt_servers)
98
+ free(opt_servers);
99
+ if (opt_hash)
100
+ free(opt_hash);
101
+
102
+ shutdown_sasl();
103
+
104
+ return 0;
105
+ }
106
+
107
+ void options_parse(int argc, char *argv[])
108
+ {
109
+ int option_index= 0;
110
+ int option_rv;
111
+
112
+ static struct option long_options[]=
113
+ {
114
+ {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION},
115
+ {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP},
116
+ {(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE},
117
+ {(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG},
118
+ {(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS},
119
+ {(OPTIONSTRING)"hash", required_argument, NULL, OPT_HASH},
120
+ {(OPTIONSTRING)"binary", no_argument, NULL, OPT_BINARY},
121
+ {(OPTIONSTRING)"username", required_argument, NULL, OPT_USERNAME},
122
+ {(OPTIONSTRING)"password", required_argument, NULL, OPT_PASSWD},
123
+ {0, 0, 0, 0}
124
+ };
125
+
126
+ while (1)
127
+ {
128
+ option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index);
129
+
130
+ if (option_rv == -1) break;
131
+
132
+ switch (option_rv)
133
+ {
134
+ case 0:
135
+ break;
136
+ case OPT_BINARY:
137
+ opt_binary = 1;
138
+ break;
139
+ case OPT_VERBOSE: /* --verbose or -v */
140
+ opt_verbose = OPT_VERBOSE;
141
+ break;
142
+ case OPT_DEBUG: /* --debug or -d */
143
+ opt_verbose = OPT_DEBUG;
144
+ break;
145
+ case OPT_VERSION: /* --version or -V */
146
+ version_command(PROGRAM_NAME);
147
+ break;
148
+ case OPT_HELP: /* --help or -h */
149
+ help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, NULL);
150
+ break;
151
+ case OPT_SERVERS: /* --servers or -s */
152
+ opt_servers= strdup(optarg);
153
+ break;
154
+ case OPT_HASH:
155
+ opt_hash= strdup(optarg);
156
+ break;
157
+ case OPT_USERNAME:
158
+ opt_username= optarg;
159
+ break;
160
+ case OPT_PASSWD:
161
+ opt_passwd= optarg;
162
+ break;
163
+ case '?':
164
+ /* getopt_long already printed an error message. */
165
+ exit(1);
166
+ default:
167
+ abort();
168
+ }
169
+ }
170
+ }
@@ -0,0 +1,80 @@
1
+ #include "libmemcached/common.h"
2
+ #include <stdio.h>
3
+ #include <inttypes.h>
4
+ #include <string.h>
5
+ #include <unistd.h>
6
+ #include <getopt.h>
7
+ #include <stdlib.h>
8
+ #include <libmemcached/memcached.h>
9
+
10
+ #include "utilities.h"
11
+
12
+ #define PROGRAM_NAME "memerror"
13
+ #define PROGRAM_DESCRIPTION "Translate a memcached errror code into a string."
14
+
15
+
16
+ /* Prototypes */
17
+ void options_parse(int argc, char *argv[]);
18
+
19
+ static int opt_verbose= 0;
20
+
21
+ int main(int argc, char *argv[])
22
+ {
23
+ options_parse(argc, argv);
24
+
25
+ if (argc != 2)
26
+ return 1;
27
+
28
+ printf("%s\n", memcached_strerror(NULL, atoi(argv[1])));
29
+
30
+ return 0;
31
+ }
32
+
33
+
34
+ void options_parse(int argc, char *argv[])
35
+ {
36
+ int option_index= 0;
37
+ int option_rv;
38
+
39
+ memcached_programs_help_st help_options[]=
40
+ {
41
+ {0},
42
+ };
43
+
44
+ static struct option long_options[]=
45
+ {
46
+ {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION},
47
+ {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP},
48
+ {(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE},
49
+ {(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG},
50
+ {0, 0, 0, 0},
51
+ };
52
+
53
+ while (1)
54
+ {
55
+ option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index);
56
+ if (option_rv == -1) break;
57
+ switch (option_rv)
58
+ {
59
+ case 0:
60
+ break;
61
+ case OPT_VERBOSE: /* --verbose or -v */
62
+ opt_verbose = OPT_VERBOSE;
63
+ break;
64
+ case OPT_DEBUG: /* --debug or -d */
65
+ opt_verbose = OPT_DEBUG;
66
+ break;
67
+ case OPT_VERSION: /* --version or -V */
68
+ version_command(PROGRAM_NAME);
69
+ break;
70
+ case OPT_HELP: /* --help or -h */
71
+ help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, help_options);
72
+ break;
73
+ case '?':
74
+ /* getopt_long already printed an error message. */
75
+ exit(1);
76
+ default:
77
+ abort();
78
+ }
79
+ }
80
+ }
@@ -0,0 +1,143 @@
1
+ #include "libmemcached/common.h"
2
+ #include <stdio.h>
3
+ #include <unistd.h>
4
+ #include <string.h>
5
+ #include <getopt.h>
6
+ #include <libmemcached/memcached.h>
7
+ #include "client_options.h"
8
+ #include "utilities.h"
9
+
10
+ static int opt_binary= 0;
11
+ static int opt_verbose= 0;
12
+ static time_t opt_expire= 0;
13
+ static char *opt_servers= NULL;
14
+ static char *opt_username;
15
+ static char *opt_passwd;
16
+
17
+ #define PROGRAM_NAME "memflush"
18
+ #define PROGRAM_DESCRIPTION "Erase all data in a server of memcached servers."
19
+
20
+ /* Prototypes */
21
+ void options_parse(int argc, char *argv[]);
22
+
23
+ int main(int argc, char *argv[])
24
+ {
25
+ memcached_st *memc;
26
+ memcached_return rc;
27
+ memcached_server_st *servers;
28
+
29
+ options_parse(argc, argv);
30
+
31
+ if (!opt_servers)
32
+ {
33
+ char *temp;
34
+
35
+ if ((temp= getenv("MEMCACHED_SERVERS")))
36
+ opt_servers= strdup(temp);
37
+ else
38
+ {
39
+ fprintf(stderr, "No Servers provided\n");
40
+ exit(1);
41
+ }
42
+ }
43
+
44
+ memc= memcached_create(NULL);
45
+
46
+ servers= memcached_servers_parse(opt_servers);
47
+ memcached_server_push(memc, servers);
48
+ memcached_server_list_free(servers);
49
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL,
50
+ (uint64_t) opt_binary);
51
+
52
+ if (!initialize_sasl(memc, opt_username, opt_passwd))
53
+ {
54
+ memcached_free(memc);
55
+ return 1;
56
+ }
57
+
58
+ rc = memcached_flush(memc, opt_expire);
59
+ if (rc != MEMCACHED_SUCCESS)
60
+ {
61
+ fprintf(stderr, "memflush: memcache error %s",
62
+ memcached_strerror(memc, rc));
63
+ if (memc->cached_errno)
64
+ fprintf(stderr, " system error %s", strerror(memc->cached_errno));
65
+ fprintf(stderr, "\n");
66
+ }
67
+
68
+ memcached_free(memc);
69
+
70
+ free(opt_servers);
71
+
72
+ shutdown_sasl();
73
+
74
+ return 0;
75
+ }
76
+
77
+
78
+ void options_parse(int argc, char *argv[])
79
+ {
80
+ memcached_programs_help_st help_options[]=
81
+ {
82
+ {0},
83
+ };
84
+
85
+ static struct option long_options[]=
86
+ {
87
+ {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION},
88
+ {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP},
89
+ {(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE},
90
+ {(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG},
91
+ {(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS},
92
+ {(OPTIONSTRING)"expire", required_argument, NULL, OPT_EXPIRE},
93
+ {(OPTIONSTRING)"binary", no_argument, NULL, OPT_BINARY},
94
+ {(OPTIONSTRING)"username", required_argument, NULL, OPT_USERNAME},
95
+ {(OPTIONSTRING)"password", required_argument, NULL, OPT_PASSWD},
96
+ {0, 0, 0, 0},
97
+ };
98
+ int option_index= 0;
99
+ int option_rv;
100
+
101
+ while (1)
102
+ {
103
+ option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index);
104
+ if (option_rv == -1) break;
105
+ switch (option_rv)
106
+ {
107
+ case 0:
108
+ break;
109
+ case OPT_BINARY:
110
+ opt_binary = 1;
111
+ break;
112
+ case OPT_VERBOSE: /* --verbose or -v */
113
+ opt_verbose = OPT_VERBOSE;
114
+ break;
115
+ case OPT_DEBUG: /* --debug or -d */
116
+ opt_verbose = OPT_DEBUG;
117
+ break;
118
+ case OPT_VERSION: /* --version or -V */
119
+ version_command(PROGRAM_NAME);
120
+ break;
121
+ case OPT_HELP: /* --help or -h */
122
+ help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, help_options);
123
+ break;
124
+ case OPT_SERVERS: /* --servers or -s */
125
+ opt_servers= strdup(optarg);
126
+ break;
127
+ case OPT_EXPIRE: /* --expire */
128
+ opt_expire= (time_t)strtoll(optarg, (char **)NULL, 10);
129
+ break;
130
+ case OPT_USERNAME:
131
+ opt_username= optarg;
132
+ break;
133
+ case OPT_PASSWD:
134
+ opt_passwd= optarg;
135
+ break;
136
+ case '?':
137
+ /* getopt_long already printed an error message. */
138
+ exit(1);
139
+ default:
140
+ abort();
141
+ }
142
+ }
143
+ }
@@ -0,0 +1,160 @@
1
+ #include "libmemcached/common.h"
2
+ #include <stdio.h>
3
+ #include <unistd.h>
4
+ #include <getopt.h>
5
+ #include <libmemcached/memcached.h>
6
+ #include <string.h>
7
+ #include "client_options.h"
8
+ #include "utilities.h"
9
+
10
+ static int opt_binary= 0;
11
+ static int opt_verbose= 0;
12
+ static time_t opt_expire= 0;
13
+ static char *opt_servers= NULL;
14
+ static char *opt_hash= NULL;
15
+ static char *opt_username;
16
+ static char *opt_passwd;
17
+
18
+ #define PROGRAM_NAME "memrm"
19
+ #define PROGRAM_DESCRIPTION "Erase a key or set of keys from a memcached cluster."
20
+
21
+ /* Prototypes */
22
+ void options_parse(int argc, char *argv[]);
23
+
24
+ int main(int argc, char *argv[])
25
+ {
26
+ memcached_st *memc;
27
+ memcached_return rc;
28
+ memcached_server_st *servers;
29
+
30
+ options_parse(argc, argv);
31
+
32
+ if (!opt_servers)
33
+ {
34
+ char *temp;
35
+
36
+ if ((temp= getenv("MEMCACHED_SERVERS")))
37
+ opt_servers= strdup(temp);
38
+ else
39
+ {
40
+ fprintf(stderr, "No Servers provided\n");
41
+ exit(1);
42
+ }
43
+ }
44
+
45
+ memc= memcached_create(NULL);
46
+ process_hash_option(memc, opt_hash);
47
+
48
+ servers= memcached_servers_parse(opt_servers);
49
+ memcached_server_push(memc, servers);
50
+ memcached_server_list_free(servers);
51
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL,
52
+ (uint64_t) opt_binary);
53
+
54
+ if (!initialize_sasl(memc, opt_username, opt_passwd))
55
+ {
56
+ memcached_free(memc);
57
+ return 1;
58
+ }
59
+
60
+ while (optind < argc)
61
+ {
62
+ if (opt_verbose)
63
+ printf("key: %s\nexpires: %llu\n", argv[optind], (unsigned long long)opt_expire);
64
+ rc = memcached_delete(memc, argv[optind], strlen(argv[optind]), opt_expire);
65
+
66
+ if (rc != MEMCACHED_SUCCESS)
67
+ {
68
+ fprintf(stderr, "memrm: %s: memcache error %s",
69
+ argv[optind], memcached_strerror(memc, rc));
70
+ if (memc->cached_errno)
71
+ fprintf(stderr, " system error %s", strerror(memc->cached_errno));
72
+ fprintf(stderr, "\n");
73
+ }
74
+
75
+ optind++;
76
+ }
77
+
78
+ memcached_free(memc);
79
+
80
+ if (opt_servers)
81
+ free(opt_servers);
82
+ if (opt_hash)
83
+ free(opt_hash);
84
+
85
+ shutdown_sasl();
86
+
87
+ return 0;
88
+ }
89
+
90
+
91
+ void options_parse(int argc, char *argv[])
92
+ {
93
+ memcached_programs_help_st help_options[]=
94
+ {
95
+ {0},
96
+ };
97
+
98
+ static struct option long_options[]=
99
+ {
100
+ {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION},
101
+ {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP},
102
+ {(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE},
103
+ {(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG},
104
+ {(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS},
105
+ {(OPTIONSTRING)"expire", required_argument, NULL, OPT_EXPIRE},
106
+ {(OPTIONSTRING)"hash", required_argument, NULL, OPT_HASH},
107
+ {(OPTIONSTRING)"binary", no_argument, NULL, OPT_BINARY},
108
+ {(OPTIONSTRING)"username", required_argument, NULL, OPT_USERNAME},
109
+ {(OPTIONSTRING)"password", required_argument, NULL, OPT_PASSWD},
110
+ {0, 0, 0, 0},
111
+ };
112
+ int option_index= 0;
113
+ int option_rv;
114
+
115
+ while (1)
116
+ {
117
+ option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index);
118
+ if (option_rv == -1) break;
119
+ switch (option_rv)
120
+ {
121
+ case 0:
122
+ break;
123
+ case OPT_BINARY:
124
+ opt_binary = 1;
125
+ break;
126
+ case OPT_VERBOSE: /* --verbose or -v */
127
+ opt_verbose = OPT_VERBOSE;
128
+ break;
129
+ case OPT_DEBUG: /* --debug or -d */
130
+ opt_verbose = OPT_DEBUG;
131
+ break;
132
+ case OPT_VERSION: /* --version or -V */
133
+ version_command(PROGRAM_NAME);
134
+ break;
135
+ case OPT_HELP: /* --help or -h */
136
+ help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, help_options);
137
+ break;
138
+ case OPT_SERVERS: /* --servers or -s */
139
+ opt_servers= strdup(optarg);
140
+ break;
141
+ case OPT_EXPIRE: /* --expire */
142
+ opt_expire= (time_t)strtoll(optarg, (char **)NULL, 10);
143
+ break;
144
+ case OPT_HASH:
145
+ opt_hash= strdup(optarg);
146
+ break;
147
+ case OPT_USERNAME:
148
+ opt_username= optarg;
149
+ break;
150
+ case OPT_PASSWD:
151
+ opt_passwd= optarg;
152
+ break;
153
+ case '?':
154
+ /* getopt_long already printed an error message. */
155
+ exit(1);
156
+ default:
157
+ abort();
158
+ }
159
+ }
160
+ }