/* LibMemcached
+ * Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/
* Copyright (C) 2006-2009 Brian Aker
* All rights reserved.
*
/* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */
#undef NDEBUG
-#include <config.h>
+#include <mem_config.h>
#ifdef HAVE_POLL_H
#include <poll.h>
#include <unistd.h>
#include <libmemcached-1.0/memcached.h>
-#include <libmemcached/socket.hpp>
-#include <libmemcached/memcached/protocol_binary.h>
-#include <libmemcached/byteorder.h>
-#include <clients/utilities.h>
+
+#include "libmemcached/socket.hpp"
+#include "libmemcached/memcached/protocol_binary.h"
+#include "libmemcached/byteorder.h"
+#include "clients/utilities.h"
+
+#include <vector>
#ifdef linux
/* /usr/include/netinet/in.h defines macros from ntohs() to _bswap_nn to
if (error != 0)
{
if (error != EAI_SYSTEM)
+ {
fprintf(stderr, "getaddrinfo(): %s\n", gai_strerror(error));
+ }
else
+ {
perror("getaddrinfo()");
+ }
}
return ai;
*/
static memcached_socket_t set_noblock(void)
{
-#ifdef WIN32
+#if defined(_WIN32)
u_long arg = 1;
if (ioctlsocket(sock, FIONBIO, &arg) == SOCKET_ERROR)
{
}
}
else
- fprintf(stderr, "Failed to create socket: %s\n",
- strerror(get_socket_errno()));
+ {
+ fprintf(stderr, "Failed to create socket: %s\n", strerror(get_socket_errno()));
+ }
freeaddrinfo(ai);
}
{
if (verbose)
{
- fprintf(stderr, "\n%s:%d: %s", file, line, expression);
+ fprintf(stdout, "\n%s:%d: %s", file, line, expression);
}
if (do_core)
ssize_t nr= timeout_io_op(sock, POLLIN, ((char*) buf) + offset, len - offset);
switch (nr) {
case -1 :
- fprintf(stderr, "Errno: %d %s\n", get_socket_errno(), strerror(errno));
+ fprintf(stderr, "Errno: %d %s\n", get_socket_errno(), strerror(errno));
verify(get_socket_errno() == EINTR || get_socket_errno() == EAGAIN);
break;
verify(*key != NULL);
char *ptr= end + 1;
+ errno= 0;
unsigned long val= strtoul(ptr, &end, 10); /* flags */
+ verify(errno == 0);
verify(ptr != end);
verify(val == 0);
verify(end != NULL);
+ errno= 0;
*ndata = (ssize_t)strtoul(end, &end, 10); /* size */
+ verify(errno == 0);
verify(ptr != end);
verify(end != NULL);
while (end and *end != '\n' and isspace(*end))
char *ptr= buffer + 6 + strlen(key) + 1;
char *end;
+ errno= 0;
unsigned long val= strtoul(ptr, &end, 10); /* flags */
+ verify(errno == 0);
verify(ptr != end);
verify(val == 0);
verify(end != NULL);
+
+ errno= 0;
val= strtoul(end, &end, 10); /* size */
+ verify(errno == 0);
verify(ptr != end);
verify(val == datasize);
verify(end != NULL);
char *ptr= buffer + 6 + strlen(key) + 1;
char *end;
+ errno= 0;
unsigned long val= strtoul(ptr, &end, 10); /* flags */
+ verify(errno == 0);
verify(ptr != end);
verify(val == 0);
verify(end != NULL);
+
+ errno= 0;
val= strtoul(end, &end, 10); /* size */
+ verify(errno == 0);
verify(ptr != end);
verify(val == datasize);
verify(end != NULL);
+
+ errno= 0;
*cas= strtoul(end, &end, 10); /* cas */
+ verify(errno == 0);
verify(ptr != end);
verify(val == datasize);
verify(end != NULL);
"test_ascii_mget4 test_ascii_mget5 "
"test_ascii_mget6\r\n"));
- char *returned[nkeys];
+ std::vector<char *> returned;
+ returned.resize(nkeys);
for (uint32_t x= 0; x < nkeys; ++x)
{
struct test_type_st tests= { true, true };
int total= 0;
int failed= 0;
- const char *hostname= "localhost";
- const char *port= "11211";
+ const char *hostname= NULL;
+ const char *port= MEMCACHED_DEFAULT_PORT_STRING;
int cmd;
bool prompt= false;
const char *testname= NULL;
}
}
+ if (hostname)
+ {
+ fprintf(stderr, "No hostname was provided.\n");
+ return EXIT_FAILURE;
+ }
+
initialize_sockets();
sock= connect_server(hostname, port);
if (sock == INVALID_SOCKET)
reconnect= true;
++failed;
if (verbose)
+ {
fprintf(stderr, "\n");
+ }
}
else if (ret == TEST_PASS_RECONNECT)
+ {
reconnect= true;
+ }
+
+ if (ret == TEST_FAIL)
+ {
+ fprintf(stderr, "%s\n", status_msg[ret]);
+ }
+ else
+ {
+ fprintf(stdout, "%s\n", status_msg[ret]);
+ }
- fprintf(stderr, "%s\n", status_msg[ret]);
if (reconnect)
{
closesocket(sock);