memcached 1.2.6 → 1.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/Manifest +206 -12
- data/Rakefile +32 -1
- data/ext/extconf.rb +10 -35
- data/ext/libmemcached-0.32/AUTHORS +7 -0
- data/ext/libmemcached-0.32/COPYING +32 -0
- data/ext/libmemcached-0.32/ChangeLog +303 -0
- data/ext/libmemcached-0.32/INSTALL +302 -0
- data/ext/libmemcached-0.32/Makefile.am +36 -0
- data/ext/libmemcached-0.32/Makefile.in +828 -0
- data/ext/libmemcached-0.32/NEWS +1 -0
- data/ext/libmemcached-0.32/README +33 -0
- data/ext/libmemcached-0.32/THANKS +14 -0
- data/ext/libmemcached-0.32/TODO +11 -0
- data/ext/libmemcached-0.32/aclocal.m4 +1852 -0
- data/ext/libmemcached-0.32/clients/Makefile.am +73 -0
- data/ext/libmemcached-0.32/clients/Makefile.in +770 -0
- data/ext/libmemcached-0.32/clients/client_options.h +32 -0
- data/ext/libmemcached-0.32/clients/execute.c +64 -0
- data/ext/libmemcached-0.32/clients/execute.h +5 -0
- data/ext/libmemcached-0.32/clients/generator.c +74 -0
- data/ext/libmemcached-0.32/clients/generator.h +20 -0
- data/ext/libmemcached-0.32/clients/memcat.c +178 -0
- data/ext/libmemcached-0.32/clients/memcp.c +251 -0
- data/ext/libmemcached-0.32/clients/memdump.c +170 -0
- data/ext/libmemcached-0.32/clients/memerror.c +80 -0
- data/ext/libmemcached-0.32/clients/memflush.c +143 -0
- data/ext/libmemcached-0.32/clients/memrm.c +160 -0
- data/ext/libmemcached-0.32/clients/memslap.c +441 -0
- data/ext/libmemcached-0.32/clients/memstat.c +326 -0
- data/ext/libmemcached-0.32/clients/utilities.c +207 -0
- data/ext/libmemcached-0.32/clients/utilities.h +41 -0
- data/ext/libmemcached-0.32/config.h.in +252 -0
- data/ext/libmemcached-0.32/config/compile +143 -0
- data/ext/libmemcached-0.32/config/config.guess +1561 -0
- data/ext/libmemcached-0.32/config/config.rpath +666 -0
- data/ext/libmemcached-0.32/config/config.sub +1686 -0
- data/ext/libmemcached-0.32/config/depcomp +630 -0
- data/ext/libmemcached-0.32/config/install-sh +520 -0
- data/ext/libmemcached-0.32/config/ltmain.sh +8406 -0
- data/ext/libmemcached-0.32/config/missing +376 -0
- data/ext/libmemcached-0.32/configure +23048 -0
- data/ext/libmemcached-0.32/configure.ac +122 -0
- data/ext/libmemcached-0.32/docs/Makefile.am +415 -0
- data/ext/libmemcached-0.32/docs/Makefile.in +918 -0
- data/ext/libmemcached-0.32/docs/libmemcached.pod +123 -0
- data/ext/libmemcached-0.32/docs/libmemcached_examples.pod +115 -0
- data/ext/libmemcached-0.32/docs/libmemcachedutil.pod +40 -0
- data/ext/libmemcached-0.32/docs/memcached_analyze.pod +52 -0
- data/ext/libmemcached-0.32/docs/memcached_auto.pod +97 -0
- data/ext/libmemcached-0.32/docs/memcached_behavior.pod +224 -0
- data/ext/libmemcached-0.32/docs/memcached_callback.pod +123 -0
- data/ext/libmemcached-0.32/docs/memcached_create.pod +61 -0
- data/ext/libmemcached-0.32/docs/memcached_delete.pod +54 -0
- data/ext/libmemcached-0.32/docs/memcached_dump.pod +53 -0
- data/ext/libmemcached-0.32/docs/memcached_flush.pod +46 -0
- data/ext/libmemcached-0.32/docs/memcached_flush_buffers.pod +42 -0
- data/ext/libmemcached-0.32/docs/memcached_generate_hash_value.pod +57 -0
- data/ext/libmemcached-0.32/docs/memcached_get.pod +161 -0
- data/ext/libmemcached-0.32/docs/memcached_memory_allocators.pod +73 -0
- data/ext/libmemcached-0.32/docs/memcached_pool.pod +77 -0
- data/ext/libmemcached-0.32/docs/memcached_quit.pod +47 -0
- data/ext/libmemcached-0.32/docs/memcached_sasl.pod +63 -0
- data/ext/libmemcached-0.32/docs/memcached_server_st.pod +75 -0
- data/ext/libmemcached-0.32/docs/memcached_servers.pod +102 -0
- data/ext/libmemcached-0.32/docs/memcached_set.pod +187 -0
- data/ext/libmemcached-0.32/docs/memcached_stats.pod +82 -0
- data/ext/libmemcached-0.32/docs/memcached_strerror.pod +46 -0
- data/ext/libmemcached-0.32/docs/memcached_user_data.pod +49 -0
- data/ext/libmemcached-0.32/docs/memcached_verbosity.pod +41 -0
- data/ext/libmemcached-0.32/docs/memcached_version.pod +56 -0
- data/ext/libmemcached-0.32/docs/memcat.pod +37 -0
- data/ext/libmemcached-0.32/docs/memcp.pod +40 -0
- data/ext/libmemcached-0.32/docs/memdump.pod +31 -0
- data/ext/libmemcached-0.32/docs/memerror.pod +30 -0
- data/ext/libmemcached-0.32/docs/memflush.pod +35 -0
- data/ext/libmemcached-0.32/docs/memrm.pod +34 -0
- data/ext/libmemcached-0.32/docs/memslap.pod +33 -0
- data/ext/libmemcached-0.32/docs/memstat.pod +35 -0
- data/ext/libmemcached-0.32/libmemcached/Makefile.am +107 -0
- data/ext/libmemcached-0.32/libmemcached/Makefile.in +1050 -0
- data/ext/libmemcached-0.32/libmemcached/byteorder.c +31 -0
- data/ext/libmemcached-0.32/libmemcached/common.h +183 -0
- data/ext/libmemcached-0.32/libmemcached/crc.c +86 -0
- data/ext/libmemcached-0.32/libmemcached/hsieh_hash.c +68 -0
- data/ext/libmemcached-0.32/libmemcached/jenkins_hash.c +213 -0
- data/ext/libmemcached-0.32/libmemcached/libmemcached.ver +1 -0
- data/ext/libmemcached-0.32/libmemcached/libmemcached_probes.d +28 -0
- data/ext/libmemcached-0.32/libmemcached/libmemcached_probes.h +78 -0
- data/ext/libmemcached-0.32/libmemcached/md5.c +354 -0
- data/ext/libmemcached-0.32/libmemcached/memcached.c +152 -0
- data/ext/libmemcached-0.32/libmemcached/memcached.h +302 -0
- data/ext/libmemcached-0.32/libmemcached/memcached.hpp +799 -0
- data/ext/libmemcached-0.32/libmemcached/memcached/README.txt +7 -0
- data/ext/libmemcached-0.32/libmemcached/memcached/protocol_binary.h +366 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_allocators.c +72 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_analyze.c +100 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_auto.c +207 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_behavior.c +285 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_callback.c +175 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_configure.h.in +23 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_connect.c +361 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_constants.h +145 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_delete.c +0 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_do.c +34 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_dump.c +79 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_fetch.c +102 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_flush.c +89 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_flush_buffers.c +22 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_get.c +495 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_get.h +87 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_hash.c +252 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_hosts.c +510 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_internal.h +31 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_io.c +547 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_io.h +59 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_key.c +28 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_parse.c +74 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_pool.h +38 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_purge.c +76 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_quit.c +75 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_response.c +528 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_result.c +57 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_result.h +59 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_sasl.c +225 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_sasl.h +44 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_server.c +159 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_server.h +93 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_stats.c +454 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_storage.c +514 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_storage.h +107 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_strerror.c +92 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_string.c +138 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_string.h +53 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_types.h +44 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_util.h +15 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_verbosity.c +36 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_version.c +112 -0
- data/ext/libmemcached-0.32/libmemcached/memcached_watchpoint.h +38 -0
- data/ext/libmemcached-0.32/libmemcached/murmur_hash.c +76 -0
- data/ext/libmemcached-0.32/libmemcached/visibility.h +51 -0
- data/ext/libmemcached-0.32/libmemcachedutil/Makefile.am +11 -0
- data/ext/libmemcached-0.32/libmemcachedutil/Makefile.in +602 -0
- data/ext/libmemcached-0.32/libmemcachedutil/libmemcachedutil.ver +1 -0
- data/ext/libmemcached-0.32/libmemcachedutil/memcached_pool.c +170 -0
- data/ext/libmemcached-0.32/m4/ac_cxx_compile_stdcxx_0x.m4 +103 -0
- data/ext/libmemcached-0.32/m4/ac_cxx_header_stdcxx_98.m4 +67 -0
- data/ext/libmemcached-0.32/m4/acx_pthread.m4 +276 -0
- data/ext/libmemcached-0.32/m4/byteorder.m4 +40 -0
- data/ext/libmemcached-0.32/m4/deprecated.m4 +17 -0
- data/ext/libmemcached-0.32/m4/enable_utillib.m4 +16 -0
- data/ext/libmemcached-0.32/m4/extensions.m4 +94 -0
- data/ext/libmemcached-0.32/m4/hsieh.m4 +18 -0
- data/ext/libmemcached-0.32/m4/lib-prefix.m4 +221 -0
- data/ext/libmemcached-0.32/m4/libtool.m4 +7360 -0
- data/ext/libmemcached-0.32/m4/ltoptions.m4 +368 -0
- data/ext/libmemcached-0.32/m4/ltsugar.m4 +123 -0
- data/ext/libmemcached-0.32/m4/ltversion.m4 +23 -0
- data/ext/libmemcached-0.32/m4/lt~obsolete.m4 +92 -0
- data/ext/libmemcached-0.32/m4/memcached.m4 +30 -0
- data/ext/libmemcached-0.32/m4/pandora_64bit.m4 +55 -0
- data/ext/libmemcached-0.32/m4/pandora_canonical.m4 +151 -0
- data/ext/libmemcached-0.32/m4/pandora_check_compiler_version.m4 +37 -0
- data/ext/libmemcached-0.32/m4/pandora_check_cxx_standard.m4 +16 -0
- data/ext/libmemcached-0.32/m4/pandora_enable_dtrace.m4 +41 -0
- data/ext/libmemcached-0.32/m4/pandora_ensure_gcc_version.m4 +36 -0
- data/ext/libmemcached-0.32/m4/pandora_have_better_malloc.m4 +54 -0
- data/ext/libmemcached-0.32/m4/pandora_have_sasl.m4 +133 -0
- data/ext/libmemcached-0.32/m4/pandora_header_assert.m4 +23 -0
- data/ext/libmemcached-0.32/m4/pandora_libtool.m4 +15 -0
- data/ext/libmemcached-0.32/m4/pandora_optimize.m4 +79 -0
- data/ext/libmemcached-0.32/m4/pandora_shared_ptr.m4 +56 -0
- data/ext/libmemcached-0.32/m4/pandora_vc_build.m4 +32 -0
- data/ext/libmemcached-0.32/m4/pandora_warnings.m4 +262 -0
- data/ext/libmemcached-0.32/m4/pod2man.m4 +7 -0
- data/ext/libmemcached-0.32/m4/protocol_binary.m4 +23 -0
- data/ext/libmemcached-0.32/m4/setsockopt.m4 +57 -0
- data/ext/libmemcached-0.32/m4/visibility.m4 +52 -0
- data/ext/libmemcached-0.32/support/Makefile.am +4 -0
- data/ext/libmemcached-0.32/support/Makefile.in +485 -0
- data/ext/libmemcached-0.32/support/libmemcached-fc.spec.in +105 -0
- data/ext/libmemcached-0.32/support/libmemcached.pc.in +10 -0
- data/ext/libmemcached-0.32/support/libmemcached.spec +105 -0
- data/ext/libmemcached-0.32/support/libmemcached.spec.in +105 -0
- data/ext/libmemcached-0.32/support/set_benchmark.sh +5 -0
- data/ext/libmemcached-0.32/tests/Makefile.am +105 -0
- data/ext/libmemcached-0.32/tests/Makefile.in +748 -0
- data/ext/libmemcached-0.32/tests/atomsmasher.c +245 -0
- data/ext/libmemcached-0.32/tests/function.c +4781 -0
- data/ext/libmemcached-0.32/tests/ketama_test_cases.h +108 -0
- data/ext/libmemcached-0.32/tests/output.cmp +7 -0
- data/ext/libmemcached-0.32/tests/output.res +7 -0
- data/ext/libmemcached-0.32/tests/output2.res +46 -0
- data/ext/libmemcached-0.32/tests/plus.cpp +293 -0
- data/ext/libmemcached-0.32/tests/r/memcat.res +19 -0
- data/ext/libmemcached-0.32/tests/r/memcp.res +27 -0
- data/ext/libmemcached-0.32/tests/r/memrm.res +19 -0
- data/ext/libmemcached-0.32/tests/r/memslap.res +33 -0
- data/ext/libmemcached-0.32/tests/r/memstat.res +33 -0
- data/ext/libmemcached-0.32/tests/server.c +118 -0
- data/ext/libmemcached-0.32/tests/server.h +25 -0
- data/ext/libmemcached-0.32/tests/start.c +16 -0
- data/ext/libmemcached-0.32/tests/t/memcat.test +4 -0
- data/ext/libmemcached-0.32/tests/t/memcp.test +3 -0
- data/ext/libmemcached-0.32/tests/t/memrm.test +3 -0
- data/ext/libmemcached-0.32/tests/t/memslap.test +5 -0
- data/ext/libmemcached-0.32/tests/t/memstat.test +3 -0
- data/ext/libmemcached-0.32/tests/test.c +137 -0
- data/ext/libmemcached-0.32/tests/test.h +46 -0
- data/ext/libmemcached-0.32/tests/udp.c +76 -0
- data/memcached.gemspec +4 -4
- data/test/unit/memcached_test.rb +30 -0
- metadata +213 -16
- data/ext/libmemcached-0.32.tar.gz +0 -0
- data/ext/libmemcached-1.patch +0 -270
- data/ext/libmemcached-10.patch +0 -12
- data/ext/libmemcached-2.patch +0 -116
- data/ext/libmemcached-3.patch +0 -8
- data/ext/libmemcached-4.patch +0 -40
- data/ext/libmemcached-5.patch +0 -832
- data/ext/libmemcached-6.patch +0 -20
- data/ext/libmemcached-7.patch +0 -2989
- data/ext/libmemcached-8.patch +0 -137
- data/ext/libmemcached-9.patch +0 -13
- 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
|
+
}
|