From: Date: Wed, 19 Sep 2007 08:14:19 +0000 (+0200) Subject: Adding simple memcat application. X-Git-Tag: 0.2~24 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=a80982481a53e72d44a586e754369086f82a8bc4;p=m6w6%2Flibmemcached Adding simple memcat application. --- diff --git a/configure.in b/configure.in index dd64f6b2..9c84272d 100644 --- a/configure.in +++ b/configure.in @@ -1,4 +1,4 @@ -AC_INIT(src/main.c) +AC_INIT(src/memcat.c) AC_CONFIG_AUX_DIR(config) AM_CONFIG_HEADER(config.h) AM_INIT_AUTOMAKE("?", 0.2 ) diff --git a/include/memcached.h b/include/memcached.h index 461e7c96..da704b19 100644 --- a/include/memcached.h +++ b/include/memcached.h @@ -1,4 +1,3 @@ -#include /* * Summary: interface for memcached server * Description: main include file for libmemcached @@ -37,6 +36,8 @@ typedef struct memcached_host_st memcached_host_st; #define MEMCACHED_DEFAULT_COMMAND_SIZE 350 #define HUGE_STRING_LEN 8196 +#define WATCHPOINT printf("WATCHPOINT %s:%d\n", __FILE__, __LINE__);fflush(stdout); + typedef enum { MEMCACHED_SUCCESS, MEMCACHED_FAILURE, diff --git a/src/Makefile.am b/src/Makefile.am index ace7581c..47507bea 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ INCLUDES = -I$(top_builddir)/include LDADDS = ../lib/libmemcached.la -bin_PROGRAMS = main -main_SOURCES = main.c -main_LDADD = $(LDADDS) +bin_PROGRAMS = memcat +memcat_SOURCES = memcat.c +memcat_LDADD = $(LDADDS) diff --git a/src/main.c b/src/main.c deleted file mode 100644 index 554190e6..00000000 --- a/src/main.c +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include - -int main(int argc, char *argv[]) -{ - memcached_st memc; - - (void)memcached_init(&memc); - memcached_deinit(&memc); - - return 0; -}; diff --git a/src/memcat.c b/src/memcat.c new file mode 100644 index 00000000..ba20f3e7 --- /dev/null +++ b/src/memcat.c @@ -0,0 +1,32 @@ +#include +#include + +int main(int argc, char *argv[]) +{ + memcached_st *memc; + char *string; + unsigned int x; + size_t string_length; + uint16_t flags; + memcached_return rc; + + if (argc == 1) + return 0; + + memc= memcached_init(NULL); + + for (x= 1; x <= argc; x++) + { + string= memcached_get(memc, argv[1], strlen(argv[1]), + &string_length, &flags, &rc); + if (string) + { + printf("%.*s\n", string_length, string); + free(string); + } + } + + memcached_deinit(memc); + + return 0; +};