example_t_memcached_light_SOURCES+= example/t/memcached_light.cc
example_t_memcached_light_SOURCES+= tests/libmemcached-1.0/memcached_get.cc
+example_t_memcached_light_SOURCES+= tests/libmemcached-1.0/print.cc
example_t_memcached_light_SOURCES+= tests/libmemcached-1.0/setup_and_teardowns.cc
example_t_memcached_light_CXXFLAGS = $(AM_CXXFLAGS)
example_t_memcached_light_DEPENDENCIES= $(MEMCACHED_LIGHT_TESTS_LDADDS) example/memcached_light
uint32_t timeouts;
} io_wait_count;
uint8_t major_version; // Default definition of UINT8_MAX means that it has not been set.
- uint8_t micro_version; // ditto
+ uint8_t micro_version; // ditto, and note that this is the third, not second version bit
uint8_t minor_version; // ditto
memcached_connection_t type;
char *read_ptr;
{
/* Find the space, and then move one past it to copy version */
char *response_ptr= index(buffer, ' ');
- response_ptr++;
- long int version= strtol(response_ptr, (char **)NULL, 10);
+ char *endptr;
+ long int version= strtol(response_ptr, &endptr, 10);
if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX or version == 0)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
}
instance->major_version= uint8_t(version);
- response_ptr= index(response_ptr, '.');
- response_ptr++;
-
- version= strtol(response_ptr, (char **)NULL, 10);
+ endptr++;
+ version= strtol(endptr, &endptr, 10);
if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
}
instance->minor_version= uint8_t(version);
- response_ptr= index(response_ptr, '.');
- response_ptr++;
-
- version= strtol(response_ptr, (char **)NULL, 10);
+ endptr++;
+ version= strtol(endptr, &endptr, 10);
if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
return MEMCACHED_UNKNOWN_READ_FAILURE;
}
- char *p;
- long int version= strtol(version_buffer, &p, 10);
+ char *endptr;
+ long int version= strtol(version_buffer, &endptr, 10);
if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX or version == 0)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
}
instance->major_version= uint8_t(version);
- version= strtol(p +1, &p, 10);
+ endptr++;
+ version= strtol(endptr, &endptr, 10);
if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
- return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse micro version"));
+ return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse minor version"));
}
instance->minor_version= uint8_t(version);
- version= strtol(p + 1, NULL, 10);
- if (errno == ERANGE)
+ endptr++;
+ version= strtol(endptr, &endptr, 10);
+ if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse micro version"));
} \
} while (0)
+#define test_skip_hint(__expected, __actual, __hint) \
+do \
+{ \
+ if (libtest::_compare_hint(__FILE__, __LINE__, __func__, (__expected), (__actual), (__hint)) == false) \
+ { \
+ return TEST_SKIPPED; \
+ } \
+} while (0)
+
#define test_skip_valgrind() \
do \
{ \
# define HAVE_ULONG 1
typedef unsigned long int ulong;
#endif
+
+#define RPACKAGE "memcached"
+#define RVERSION "1.4.13"
-#if defined(RMEMCACHED_PACKAGE)
-#undef VERSION
-#define VERSION VERSION_NUMBER
-#endif
-
-#if defined(RMEMCACHED_PACKAGE)
-#undef PACKAGE
-#define PACKAGE RMEMCACHED_PACKAGE
-#endif
-
-
])
])dnl CONFIG_EXTRA
noinst_HEADERS+= memcached/trace.h
noinst_HEADERS+= memcached/util.h
-memcached_memcached_SOURCES=
memcached_memcached_CFLAGS=
memcached_memcached_LDADD=
+memcached_memcached_SOURCES=
memcached_memcached_SOURCES+=
memcached_memcached_SOURCES+= memcached/assoc.c
memcached_memcached_SOURCES+= memcached/trace.h
memcached_memcached_SOURCES+= memcached/util.c
-memcached_memcached_CFLAGS+= -DHAVE_CONFIG_H -std=c99
memcached_memcached_CFLAGS+= ${PTHREAD_CFLAGS}
-memcached_memcached_CFLAGS+= -DRMEMCACHED_VERSION="\"1.4.13\""
-memcached_memcached_CFLAGS+= -DRMEMCACHED_PACKAGE="\"memcached\""
+memcached_memcached_CFLAGS+= -DHAVE_CONFIG_H -std=c99
memcached_memcached_LDADD+= $(LIBEVENT_LDFLAGS)
memcached_memcached_LDADD+= ${PTHREAD_LIBS}
switch (c->cmd) {
case PROTOCOL_BINARY_CMD_VERSION:
if (extlen == 0 && keylen == 0 && bodylen == 0) {
- write_bin_response(c, VERSION, 0, 0, strlen(VERSION));
+ write_bin_response(c, RVERSION, 0, 0, strlen(RVERSION));
} else {
protocol_error = 1;
}
APPEND_STAT("pid", "%lu", (long)pid);
APPEND_STAT("uptime", "%u", now);
APPEND_STAT("time", "%ld", now + (long)process_started);
- APPEND_STAT("version", "%s", VERSION);
+ APPEND_STAT("version", "%s", RVERSION);
APPEND_STAT("libevent", "%s", event_get_version());
APPEND_STAT("pointer_size", "%d", (int)(8 * sizeof(void *)));
} else if (ntokens == 2 && (strcmp(tokens[COMMAND_TOKEN].value, "version") == 0)) {
- out_string(c, "VERSION " VERSION);
+ out_string(c, "VERSION " RVERSION);
} else if (ntokens == 2 && (strcmp(tokens[COMMAND_TOKEN].value, "quit") == 0)) {
}
#endif
- setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, (void *)&flags, sizeof(flags));
+ error = setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &flags, sizeof(flags));
+ if (error != 0)
+ {
+ perror("setsockopt(SO_REUSEADDR)");
+ }
+
if (IS_UDP(transport)) {
maximize_sndbuf(sfd);
} else {
}
static void usage(void) {
- printf(PACKAGE " " VERSION "\n");
+ printf(RPACKAGE " " RVERSION "\n");
printf("-p <num> TCP port number to listen on (default: 11211)\n"
"-U <num> UDP port number to listen on (default: 11211, 0 is off)\n"
"-s <file> UNIX socket path to listen on (disables network support)\n"
}
static void usage_license(void) {
- printf(PACKAGE " " VERSION "\n\n");
+ printf(RPACKAGE " " RVERSION "\n\n");
printf(
"Copyright (c) 2003, Danga Interactive, Inc. <http://www.danga.com/>\n"
"All rights reserved.\n"
tests_failure_SOURCES+= tests/libmemcached-1.0/callback_counter.cc
tests_failure_SOURCES+= tests/libmemcached-1.0/fetch_all_results.cc
tests_failure_SOURCES+= tests/libmemcached-1.0/generate.cc
+tests_failure_SOURCES+= tests/libmemcached-1.0/print.cc
tests_failure_CXXFLAGS = $(AM_CXXFLAGS)
tests_failure_DEPENDENCIES= $(TESTS_LDADDS)
tests_testudp_CFLAGS= $(AM_CFLAGS) $(NO_CONVERSION) $(NO_STRICT_ALIASING)
tests_testudp_SOURCES=
-tests_testudp_SOURCES+= tests/mem_udp.cc
+
tests_testudp_SOURCES+= clients/execute.cc
tests_testudp_SOURCES+= clients/generator.cc
tests_testudp_SOURCES+= tests/libmemcached-1.0/callback_counter.cc
tests_testudp_SOURCES+= tests/libmemcached-1.0/fetch_all_results.cc
tests_testudp_SOURCES+= tests/libmemcached-1.0/generate.cc
-
+tests_testudp_SOURCES+= tests/libmemcached-1.0/print.cc
+tests_testudp_SOURCES+= tests/mem_udp.cc
tests_testudp_DEPENDENCIES= $(TESTS_LDADDS)
tests_testudp_LDADD= $(tests_testudp_DEPENDENCIES)
check_PROGRAMS+= tests/testudp
tests_testplus_SOURCES+= tests/libmemcached-1.0/callback_counter.cc
tests_testplus_SOURCES+= tests/libmemcached-1.0/fetch_all_results.cc
tests_testplus_SOURCES+= tests/libmemcached-1.0/generate.cc
+tests_testplus_SOURCES+= tests/libmemcached-1.0/print.cc
tests_testplus_CXXFLAGS = $(AM_CXXFLAGS) $(NO_EFF_CXX)
tests_testplus_DEPENDENCIES= $(TESTS_LDADDS)
#include "tests/print.h"
-memcached_return_t server_print_callback(const memcached_st *ptr,
+memcached_return_t server_print_callback(const memcached_st*,
const memcached_server_st *server,
void *context)
{
- (void)ptr;
-
if (context)
{
std::cerr << memcached_server_name(server) << ":" << memcached_server_port(server) << std::endl;
return MEMCACHED_SUCCESS;
}
+
+const char * print_version(memcached_st *memc)
+{
+ memcached_server_fn callbacks[1];
+ callbacks[0]= server_print_version_callback;
+ memcached_server_cursor(memc, callbacks, NULL, 1);
+
+ return "print_version()";
+}
+
+
+memcached_return_t server_print_version_callback(const memcached_st *,
+ const memcached_server_st *server,
+ void *)
+{
+ std::cerr << "Server: " << memcached_server_name(server) << ":" << memcached_server_port(server) << " "
+ << int(server->major_version) << "."
+ << int(server->minor_version) << "."
+ << int(server->micro_version)
+ << std::endl;
+
+ return MEMCACHED_SUCCESS;
+}
#include <libmemcached/util.h>
+#include "tests/print.h"
#include "tests/libmemcached-1.0/setup_and_teardowns.h"
#include <sys/stat.h>
*/
test_return_t pre_binary(memcached_st *memc)
{
+ test_true(memcached_server_count(memc) > 0);
test_skip(true, libmemcached_util_version_check(memc, 1, 4, 4));
test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, true));
memcached_return_t server_print_callback(const memcached_st *ptr,
const memcached_server_st *server,
void *context);
+
+memcached_return_t server_print_version_callback(const memcached_st *ptr,
+ const memcached_server_st *server,
+ void *context);
+
+const char * print_version(memcached_st *memc);
#include "tests/libmemcached-1.0/generate.h"
#include "tests/memc.h"
+#include "tests/print.h"
class LibmemcachedRunner : public libtest::Runner {
public: