Clean up error messages when encountering new messages.
authorBrian Aker <brian@tangent.org>
Tue, 5 Apr 2011 21:03:09 +0000 (14:03 -0700)
committerBrian Aker <brian@tangent.org>
Tue, 5 Apr 2011 21:03:09 +0000 (14:03 -0700)
.bzrignore
ChangeLog
libmemcached/hosts.c
libmemcached/options/parser.am
libmemcached/options/parser.yy [deleted file]
libmemcached/options/scanner.l [deleted file]
libmemcached/server.h

index 06c56d6932753800ba5105272c51b4748ce41d0c..1fe320b9ad0517d2e267e4a210d81fd70b274667 100644 (file)
@@ -20,6 +20,7 @@ Makefile.in
 TAGS
 aclocal.m4
 autom4te.cache
+clients/memaslap
 clients/memcapable
 clients/memcat
 clients/memcp
@@ -172,6 +173,7 @@ memflush.pop
 memrm.pop
 memslap.pop
 memstat.pop
+out
 patch
 patch2
 stamp-h1
@@ -181,6 +183,7 @@ support/libmemcached-fc.spec
 support/libmemcached.pc
 support/libmemcached.spec
 tests/atomsmasher
+tests/hash_plus
 tests/hashplus
 tests/memplus
 tests/output.cmp
index b2ca1f743bb58f53157ae650cfeb78570dd2a7b8..828dae77631ba1917d05647bbacebfe54f451217 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,6 @@
   * Fix calls to auto methods so that if value is not passed in nothing bad happens.
   * New parser calls for generating memcached_st objects.
   * New error system.
-
   * A behavior change has been now made that if you specify a weight for any
   server, we enable the weight flag and do weight balancing.
 
index eafbb1b534ca083e76cb76fc75698403047549fe..65a4cd416bc34b9be06919f1259084c3ae5b4aae 100644 (file)
@@ -226,8 +226,8 @@ static memcached_return_t update_continuum(memcached_st *ptr)
           for (uint32_t x= 0; x < pointer_per_hash; x++)
           {
             uint32_t value= ketama_server_hash(sort_host, (size_t)sort_host_length, x);
-             ptr->ketama.continuum[continuum_index].index= host_index;
-             ptr->ketama.continuum[continuum_index++].value= value;
+            ptr->ketama.continuum[continuum_index].index= host_index;
+            ptr->ketama.continuum[continuum_index++].value= value;
           }
         }
         else
@@ -274,9 +274,9 @@ static memcached_return_t update_continuum(memcached_st *ptr)
         {
           for (uint32_t x = 0; x < pointer_per_hash; x++)
           {
-             uint32_t value= ketama_server_hash(sort_host, (size_t)sort_host_length, x);
-             ptr->ketama.continuum[continuum_index].index= host_index;
-             ptr->ketama.continuum[continuum_index++].value= value;
+            uint32_t value= ketama_server_hash(sort_host, (size_t)sort_host_length, x);
+            ptr->ketama.continuum[continuum_index].index= host_index;
+            ptr->ketama.continuum[continuum_index++].value= value;
           }
         }
         else
@@ -444,3 +444,20 @@ static memcached_return_t server_add(memcached_st *ptr, const char *hostname,
 
   return run_distribution(ptr);
 }
+
+memcached_return_t memcached_server_add_parsed(memcached_st *ptr,
+                                               const char *hostname,
+                                               size_t hostname_length,
+                                               in_port_t port,
+                                               uint32_t weight)
+{
+  char buffer[NI_MAXHOST];
+
+  memcpy(buffer, hostname, hostname_length);
+  buffer[hostname_length]= 0;
+
+  return server_add(ptr, buffer,
+                    port,
+                    weight,
+                    MEMCACHED_CONNECTION_TCP);
+}
index 7bfd21c7518430ea8be29c8d8d9caf9ef9b5a0db..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,29 +0,0 @@
-#  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
-#
-#  Libmemcached Scanner and Parser
-#
-#  Copyright (C) 2011 DataDifferental, http://datadifferential.com
-#  
-#  This program is free software: you can redistribute it and/or modify
-#  it under the terms of the GNU Affero General Public License as
-#  published by the Free Software Foundation, either version 3 of the
-#  License, or (at your option) any later version.
-#  
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU Affero General Public License for more details.
-#  
-#  You should have received a copy of the GNU Affero General Public License
-#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-
-libmemcached/options/parser.h: libmemcached/options/parser.cc
-
-libmemcached/options/parser.cc: libmemcached/options/parser.yy libmemcached/options/scanner.l libmemcached/options/scanner.h
-       $(AM_V_YACC)$(am__skipyacc) $(YACC) $(YLFLAGS) $(AM_YFLAGS) -o $@ $<
-
-libmemcached/options/scanner.h: libmemcached/options/scanner.cc
-
-libmemcached/options/scanner.cc: libmemcached/options/scanner.l libmemcached/options/parser.yy
-       $(AM_V_GEN)$(LEX) $<
diff --git a/libmemcached/options/parser.yy b/libmemcached/options/parser.yy
deleted file mode 100644 (file)
index e950076..0000000
+++ /dev/null
@@ -1,460 +0,0 @@
-/*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
- *  Libmemcached Scanner and Parser
- *
- *  Copyright (C) 2011 DataDifferental, http://datadifferential.com
- *  
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU Affero General Public License as
- *  published by the Free Software Foundation, either version 3 of the
- *  License, or (at your option) any later version.
- *  
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU Affero General Public License for more details.
- *  
- *  You should have received a copy of the GNU Affero General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-%error-verbose
-%debug
-%defines
-%expect 0
-%output "libmemcached/options/parser.cc"
-%defines "libmemcached/options/parser.h"
-%lex-param { yyscan_t *scanner }
-%name-prefix="config_"
-%parse-param { Context *context }
-%parse-param { yyscan_t *scanner }
-%pure-parser
-%require "2.2"
-%start begin
-%verbose
-
-%{
-
-#include <config.h>
-
-#include <stdint.h>
-
-#include <libmemcached/options/context.h>
-#include <libmemcached/options/build.h>
-#include <libmemcached/options/string.h>
-#include <libmemcached/options/symbol.h>
-#include <libmemcached/visibility.h>
-#include <libmemcached/prefix_key.h>
-
-#pragma GCC diagnostic ignored "-Wold-style-cast"
-#include <libmemcached/options/scanner.h>
-
-int conf_lex(YYSTYPE* lvalp, void* scanner);
-
-#define parser_abort(A, B) do { parser::abort_func((A), (B)); YYABORT; } while (0) 
-
-inline void config_error(Context *context, yyscan_t *scanner, const char *error)
-{
-  if (not context->end())
-    parser::abort_func(context, error);
-}
-
-%}
-
-%token COMMENT
-%token END
-%token ERROR
-%token RESET
-%token PARSER_DEBUG
-%token INCLUDE
-%token CONFIGURE_FILE
-%token EMPTY_LINE
-%token SERVER
-%token SERVERS
-%token SERVERS_OPTION
-%token UNKNOWN_OPTION
-%token UNKNOWN
-
-/* All behavior options */
-%token AUTO_EJECT_HOSTS
-%token BINARY_PROTOCOL
-%token BUFFER_REQUESTS
-%token CONNECT_TIMEOUT
-%token DISTRIBUTION
-%token HASH
-%token HASH_WITH_PREFIX_KEY
-%token IO_BYTES_WATERMARK
-%token IO_KEY_PREFETCH
-%token IO_MSG_WATERMARK
-%token KETAMA_HASH
-%token KETAMA_WEIGHTED
-%token NOREPLY
-%token NUMBER_OF_REPLICAS
-%token POLL_TIMEOUT
-%token RANDOMIZE_REPLICA_READ
-%token RCV_TIMEOUT
-%token RETRY_TIMEOUT
-%token SERVER_FAILURE_LIMIT
-%token SND_TIMEOUT
-%token SOCKET_RECV_SIZE
-%token SOCKET_SEND_SIZE
-%token SORT_HOSTS
-%token SUPPORT_CAS
-%token _TCP_NODELAY
-%token _TCP_KEEPALIVE
-%token _TCP_KEEPIDLE
-%token USER_DATA
-%token USE_UDP
-%token VERIFY_KEY
-
-/* Callbacks */
-%token PREFIX_KEY
-
-/* Hash types */
-%token MD5
-%token CRC
-%token FNV1_64
-%token FNV1A_64
-%token FNV1_32
-%token FNV1A_32
-%token HSIEH
-%token MURMUR
-%token JENKINS
-
-/* Distributions */
-%token CONSISTENT
-%token MODULA
-%token RANDOM
-
-/* Boolean values */
-%token <boolean> TRUE
-%token <boolean> FALSE
-
-%nonassoc ','
-%nonassoc '='
-
-%token <number> FLOAT
-%token <number> NUMBER
-%token PORT
-%token WEIGHT_START
-%token <server> IPADDRESS
-%token <server> HOSTNAME
-%token <string> STRING
-%token <string> QUOTED_STRING
-%token <string> FILE_PATH
-
-%type <string> string
-%type <distribution> distribution
-%type <hash> hash
-%type <behavior> behavior_boolean
-%type <behavior> behavior_number
-
-%%
-
-begin:
-          statement
-        | begin ' ' statement
-        ;
-
-statement:
-         expression
-          { }
-        | COMMENT
-          { }
-        | EMPTY_LINE
-          { }
-        | END
-          {
-            context->set_end();
-            YYACCEPT;
-          }
-        | ERROR
-          {
-            context->rc= MEMCACHED_PARSE_USER_ERROR;
-            parser_abort(context, NULL);
-          }
-        | RESET
-          {
-            memcached_reset(context->memc);
-          }
-        | PARSER_DEBUG
-          {
-            yydebug= 1;
-          }
-        | INCLUDE ' ' string
-          {
-            if ((context->rc= memcached_parse_configure_file(context->memc, $3.c_str, $3.length)) != MEMCACHED_SUCCESS)
-            {
-              parser_abort(context, NULL);
-            }
-          }
-        ;
-
-
-expression:
-          SERVER HOSTNAME optional_port optional_weight
-          {
-            if ((context->rc= memcached_server_add_with_weight(context->memc, $2.c_str, $2.port, $2.weight)) != MEMCACHED_SUCCESS)
-            {
-              parser_abort(context, NULL);
-            }
-            context->unset_server();
-          }
-        | SERVER IPADDRESS optional_port optional_weight
-          {
-            if ((context->rc= memcached_server_add_with_weight(context->memc, $2.c_str, $2.port, $2.weight)) != MEMCACHED_SUCCESS)
-            {
-              parser_abort(context, NULL);
-            }
-            context->unset_server();
-          }
-        | CONFIGURE_FILE string
-          {
-            memcached_set_configuration_file(context->memc, $2.c_str, $2.length);
-          }
-        | behaviors
-        ;
-
-behaviors:
-          PREFIX_KEY string
-          {
-            if ((context->rc= memcached_set_prefix_key(context->memc, $2.c_str, $2.length)) != MEMCACHED_SUCCESS)
-            {
-              parser_abort(context, NULL);;
-            }
-          }
-        | DISTRIBUTION distribution
-          {
-            if ((context->rc= memcached_behavior_set(context->memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, $2)) != MEMCACHED_SUCCESS)
-            {
-              parser_abort(context, NULL);;
-            }
-          }
-        | DISTRIBUTION distribution ',' hash
-          {
-            if ((context->rc= memcached_behavior_set(context->memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, $2)) != MEMCACHED_SUCCESS)
-            {
-              parser_abort(context, NULL);;
-            }
-            if ((context->rc= memcached_behavior_set_distribution_hash(context->memc, $4)) != MEMCACHED_SUCCESS)
-            {
-              parser_abort(context, NULL);;
-            }
-          }
-        | HASH hash
-          {
-            if ((context->rc= memcached_behavior_set(context->memc, MEMCACHED_BEHAVIOR_HASH, $2)) != MEMCACHED_SUCCESS)
-            {
-              parser_abort(context, NULL);; 
-            }
-          }
-        | behavior_number NUMBER
-          {
-            if ((context->rc= memcached_behavior_set(context->memc, $1, $2)) != MEMCACHED_SUCCESS)
-            {
-              parser_abort(context, NULL);;
-            }
-          }
-        | behavior_boolean
-          {
-            if ((context->rc= memcached_behavior_set(context->memc, $1, true)) != MEMCACHED_SUCCESS)
-            {
-              parser_abort(context, NULL);;
-            }
-          }
-        |  USER_DATA
-          {
-          }
-        ;
-
-behavior_number:
-          CONNECT_TIMEOUT
-          {
-            $$= MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT;
-          }
-        | IO_MSG_WATERMARK
-          {
-            $$= MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK;
-          }
-        | IO_BYTES_WATERMARK
-          {
-            $$= MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK;
-          }
-        | IO_KEY_PREFETCH
-          {
-            $$= MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH;
-          }
-        | NUMBER_OF_REPLICAS
-          {
-            $$= MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS;
-          }
-        | POLL_TIMEOUT
-          {
-            $$= MEMCACHED_BEHAVIOR_POLL_TIMEOUT;
-          }
-        |  RCV_TIMEOUT
-          {
-            $$= MEMCACHED_BEHAVIOR_RCV_TIMEOUT;
-          }
-        |  RETRY_TIMEOUT
-          {
-            $$= MEMCACHED_BEHAVIOR_RETRY_TIMEOUT;
-          }
-        |  SERVER_FAILURE_LIMIT
-          {
-            $$= MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT;
-          }
-        |  SND_TIMEOUT
-          {
-            $$= MEMCACHED_BEHAVIOR_SND_TIMEOUT;
-          }
-        |  SOCKET_RECV_SIZE
-          {
-            $$= MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE;
-          }
-        |  SOCKET_SEND_SIZE
-          {
-            $$= MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE;
-          }
-        ;
-
-behavior_boolean: 
-          AUTO_EJECT_HOSTS
-          {
-            $$= MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS;
-          }
-        | BINARY_PROTOCOL
-          {
-            $$= MEMCACHED_BEHAVIOR_BINARY_PROTOCOL;
-          }
-        | BUFFER_REQUESTS
-          {
-            $$= MEMCACHED_BEHAVIOR_BUFFER_REQUESTS;
-          }
-        | HASH_WITH_PREFIX_KEY
-          {
-            $$= MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY;
-          }
-        | NOREPLY
-          {
-            $$= MEMCACHED_BEHAVIOR_NOREPLY;
-          }
-        |  RANDOMIZE_REPLICA_READ
-          {
-            $$= MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ;
-          }
-        |  SORT_HOSTS
-          {
-            $$= MEMCACHED_BEHAVIOR_SORT_HOSTS;
-          }
-        |  SUPPORT_CAS
-          {
-            $$= MEMCACHED_BEHAVIOR_SUPPORT_CAS;
-          }
-        |  _TCP_NODELAY
-          {
-            $$= MEMCACHED_BEHAVIOR_TCP_NODELAY;
-          }
-        |  _TCP_KEEPALIVE
-          {
-            $$= MEMCACHED_BEHAVIOR_TCP_KEEPALIVE;
-          }
-        |  _TCP_KEEPIDLE
-          {
-            $$= MEMCACHED_BEHAVIOR_TCP_KEEPIDLE;
-          }
-        |  USE_UDP
-          {
-            $$= MEMCACHED_BEHAVIOR_USE_UDP;
-          }
-        |  VERIFY_KEY
-          {
-            $$= MEMCACHED_BEHAVIOR_VERIFY_KEY;
-          }
-
-
-optional_port:
-          { }
-        | PORT
-          { };
-        ;
-
-optional_weight:
-          { }
-        | WEIGHT_START
-          { }
-        ;
-
-hash:
-          MD5
-          {
-            $$= MEMCACHED_HASH_MD5;
-          }
-        | CRC
-          {
-            $$= MEMCACHED_HASH_CRC;
-          }
-        | FNV1_64
-          {
-            $$= MEMCACHED_HASH_FNV1_64;
-          }
-        | FNV1A_64
-          {
-            $$= MEMCACHED_HASH_FNV1A_64;
-          }
-        | FNV1_32
-          {
-            $$= MEMCACHED_HASH_FNV1_32;
-          }
-        | FNV1A_32
-          {
-            $$= MEMCACHED_HASH_FNV1A_32;
-          }
-        | HSIEH
-          {
-            $$= MEMCACHED_HASH_HSIEH;
-          }
-        | MURMUR
-          {
-            $$= MEMCACHED_HASH_MURMUR;
-          }
-        | JENKINS
-          {
-            $$= MEMCACHED_HASH_JENKINS;
-          }
-        ;
-
-string:
-          STRING
-          {
-            $$= $1;
-          }
-        | QUOTED_STRING
-          {
-            $$.c_str= $1.c_str +1; // +1 to move use passed the initial quote
-            $$.length= $1.length -1; // -1 removes the end quote
-          }
-        ;
-
-distribution:
-          CONSISTENT
-          {
-            $$= MEMCACHED_DISTRIBUTION_CONSISTENT;
-          }
-        | MODULA
-          {
-            $$= MEMCACHED_DISTRIBUTION_MODULA;
-          }
-        | RANDOM
-          {
-            $$= MEMCACHED_DISTRIBUTION_RANDOM;
-          }
-        ;
-
-%% 
-
-void Context::start() 
-{
-  config_parse(this, (void **)scanner);
-}
-
diff --git a/libmemcached/options/scanner.l b/libmemcached/options/scanner.l
deleted file mode 100644 (file)
index 8f3e09d..0000000
+++ /dev/null
@@ -1,233 +0,0 @@
-/*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
- *  Libmemcached Scanner and Parser
- *
- *  Copyright (C) 2011 DataDifferental, http://datadifferential.com
- * 
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU Affero General Public License as
- *  published by the Free Software Foundation, either version 3 of the
- *  License, or (at your option) any later version.
- * 
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU Affero General Public License for more details.
- * 
- *  You should have received a copy of the GNU Affero General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-%top{
-
-#pragma GCC diagnostic ignored "-Wold-style-cast"
-#pragma GCC diagnostic ignored "-Wsign-compare"
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-
-#include <libmemcached/options/context.h>
-#include <libmemcached/options/parser.h>
-#include <libmemcached/options/string.h>
-#include <libmemcached/options/symbol.h>
-
-#define YY_EXTRA_TYPE Context*
-
-}
-
-
-%{
-#include <cstdlib>
-#include <cstring>
-
-#define PARAM yyget_extra(yyscanner)
-
-#define get_lex_chars(buffer, result, max_size, context) \
-{ \
-  if (context->pos >= context->length) \
-  { \
-    result= YY_NULL; \
-  } \
-  else \
-  { \
-    result= (int)(context->length - context->pos); \
-    (size_t)result > (size_t)max_size ? result= max_size : 0; \
-    memcpy(buffer, context->buf + context->pos, result); \
-    context->pos += result; \
-  } \
-}
-
-
-#define YY_INPUT(buffer, result, max_size) get_lex_chars(buffer, result, max_size, PARAM)
-
-%}
-
-%option 8bit
-%option bison-bridge
-%option case-insensitive
-%option debug
-%option nounput
-%option noyywrap
-%option outfile="libmemcached/options/scanner.cc" header-file="libmemcached/options/scanner.h"
-%option perf-report
-%option prefix="config_"
-%option reentrant
-
-%%
-
-
-=|,|[ ]       { return yytext[0];}
-
-[[:digit:]]+ { yylval->number = atoi(yytext); return (NUMBER); }
-
-:[[:digit:]]{1,5} { yylval->server.port = atoi(yytext +1); return PORT; }
-
-"/?"[[:digit:]]{1,5} { yylval->server.weight = atoi(yytext +2); return WEIGHT_START; }
-
-[\t\r\n] ; /* skip whitespace */
-
-
-^#.*$ {
-      return COMMENT;
-    }
-
-"--SERVER="                          { yyextra->begin= yytext; yyextra->set_server(); return SERVER; }
-
-"--VERIFY_KEY"                      { yyextra->begin= yytext; return VERIFY_KEY; }
-"--VERIFY-KEY"                      { yyextra->begin= yytext; return VERIFY_KEY; }
-"--AUTO_EJECT_HOSTS"           { yyextra->begin= yytext; return AUTO_EJECT_HOSTS; }
-"--AUTO-EJECT_HOSTS"           { yyextra->begin= yytext; return AUTO_EJECT_HOSTS; }
-"--BINARY_PROTOCOL"                    { yyextra->begin= yytext; return BINARY_PROTOCOL; }
-"--BINARY-PROTOCOL"                    { yyextra->begin= yytext; return BINARY_PROTOCOL; }
-"--BUFFER_REQUESTS"                    { yyextra->begin= yytext; return BUFFER_REQUESTS; }
-"--BUFFER-REQUESTS"                    { yyextra->begin= yytext; return BUFFER_REQUESTS; }
-"--CONFIGURE_FILE="                    { yyextra->begin= yytext; return CONFIGURE_FILE; }
-"--CONFIGURE-FILE="                    { yyextra->begin= yytext; return CONFIGURE_FILE; }
-"--CONNECT_TIMEOUT="                   { yyextra->begin= yytext; return CONNECT_TIMEOUT; }
-"--CONNECT-TIMEOUT="                   { yyextra->begin= yytext; return CONNECT_TIMEOUT; }
-"--DISTRIBUTION="                      { yyextra->begin= yytext; return DISTRIBUTION; }
-"--HASH="                              { yyextra->begin= yytext; return HASH; }
-"--HASH_WITH_PREFIX_KEY"               { yyextra->begin= yytext; return HASH_WITH_PREFIX_KEY; }
-"--HASH-WITH-PREFIX_KEY"               { yyextra->begin= yytext; return HASH_WITH_PREFIX_KEY; }
-"--IO_BYTES_WATERMARK="                { yyextra->begin= yytext; return IO_BYTES_WATERMARK; }
-"--IO-BYTES-WATERMARK="                { yyextra->begin= yytext; return IO_BYTES_WATERMARK; }
-"--IO_KEY_PREFETCH="                   { yyextra->begin= yytext; return IO_KEY_PREFETCH; }
-"--IO-KEY-PREFETCH="                   { yyextra->begin= yytext; return IO_KEY_PREFETCH; }
-"--IO_MSG_WATERMARK="          { yyextra->begin= yytext; return IO_MSG_WATERMARK; }
-"--IO-MSG-WATERMARK="          { yyextra->begin= yytext; return IO_MSG_WATERMARK; }
-"--NOREPLY"                         { yyextra->begin= yytext; return NOREPLY; }
-"--NUMBER_OF_REPLICAS="                { yyextra->begin= yytext; return NUMBER_OF_REPLICAS; }
-"--NUMBER-OF-REPLICAS="                { yyextra->begin= yytext; return NUMBER_OF_REPLICAS; }
-"--POLL_TIMEOUT="                      { yyextra->begin= yytext; return POLL_TIMEOUT; }
-"--POLL-TIMEOUT="                      { yyextra->begin= yytext; return POLL_TIMEOUT; }
-"--RANDOMIZE_REPLICA_READ"             { yyextra->begin= yytext; return RANDOMIZE_REPLICA_READ; }
-"--RANDOMIZE-REPLICA-READ"             { yyextra->begin= yytext; return RANDOMIZE_REPLICA_READ; }
-"--RCV_TIMEOUT="                       { yyextra->begin= yytext; return RCV_TIMEOUT; }
-"--RCV-TIMEOUT="                       { yyextra->begin= yytext; return RCV_TIMEOUT; }
-"--RETRY_TIMEOUT="                     { yyextra->begin= yytext; return RETRY_TIMEOUT; }
-"--RETRY-TIMEOUT="                     { yyextra->begin= yytext; return RETRY_TIMEOUT; }
-"--SERVER_FAILURE_LIMIT="              { yyextra->begin= yytext; return SERVER_FAILURE_LIMIT; }
-"--SERVER-FAILURE-LIMIT="              { yyextra->begin= yytext; return SERVER_FAILURE_LIMIT; }
-"--SND_TIMEOUT="                       { yyextra->begin= yytext; return SND_TIMEOUT; }
-"--SND-TIMEOUT="                       { yyextra->begin= yytext; return SND_TIMEOUT; }
-"--SOCKET_RECV_SIZE="          { yyextra->begin= yytext; return SOCKET_RECV_SIZE; }
-"--SOCKET-RECV-SIZE="          { yyextra->begin= yytext; return SOCKET_RECV_SIZE; }
-"--SOCKET_SEND_SIZE="          { yyextra->begin= yytext; return SOCKET_SEND_SIZE; }
-"--SOCKET-SEND-SIZE="          { yyextra->begin= yytext; return SOCKET_SEND_SIZE; }
-"--SORT_HOSTS"                 { yyextra->begin= yytext; return SORT_HOSTS; }
-"--SORT-HOSTS"                 { yyextra->begin= yytext; return SORT_HOSTS; }
-"--SUPPORT_CAS"                        { yyextra->begin= yytext; return SUPPORT_CAS; }
-"--SUPPORT-CAS"                        { yyextra->begin= yytext; return SUPPORT_CAS; }
-"--TCP_NODELAY"                        { yyextra->begin= yytext; return _TCP_NODELAY; }
-"--TCP-NODELAY"                        { yyextra->begin= yytext; return _TCP_NODELAY; }
-"--TCP_KEEPALIVE"                      { yyextra->begin= yytext; return _TCP_KEEPALIVE; }
-"--TCP-KEEPALIVE"                      { yyextra->begin= yytext; return _TCP_KEEPALIVE; }
-"--TCP_KEEPIDLE"                       { yyextra->begin= yytext; return _TCP_KEEPIDLE; }
-"--TCP-KEEPIDLE"                       { yyextra->begin= yytext; return _TCP_KEEPIDLE; }
-"--USER_DATA"                  { yyextra->begin= yytext; return USER_DATA; }
-"--USER-DATA"                  { yyextra->begin= yytext; return USER_DATA; }
-"--USE_UDP"                            { yyextra->begin= yytext; return USE_UDP; }
-"--USE-UDP"                            { yyextra->begin= yytext; return USE_UDP; }
-
-"--PREFIX-KEY="                                { yyextra->begin= yytext; return PREFIX_KEY; }
-"--PREFIX_KEY="                                { yyextra->begin= yytext; return PREFIX_KEY; }
-
-INCLUDE           { yyextra->begin= yytext; return INCLUDE; }
-RESET           { yyextra->begin= yytext; return RESET; }
-DEBUG           { yyextra->begin= yytext; return PARSER_DEBUG; }
-SERVERS           { yyextra->begin= yytext; return SERVERS; }
-END           { yyextra->begin= yytext; return END; }
-ERROR           { yyextra->begin= yytext; return ERROR; }
-
-TRUE           { return TRUE; }
-FALSE           { return FALSE; }
-
-
-"--"[[:alnum:]]*   {
-      yyextra->begin= yytext;
-      return UNKNOWN_OPTION;
-    }
-
-CONSISTENT      { return CONSISTENT; }
-MODULA          { return MODULA; }
-RANDOM          { return RANDOM; }
-
-MD5                    { return MD5; }
-CRC                    { return CRC; }
-FNV1_64                        { return FNV1_64; }
-FNV1A_64                       { return FNV1A_64; }
-FNV1_32                        { return FNV1_32; }
-FNV1A_32                       { return FNV1A_32; }
-HSIEH                  { return HSIEH; }
-MURMUR                 { return MURMUR; }
-JENKINS                        { return JENKINS; }
-
-(([[:digit:]]{1,3}"."){3}([[:digit:]]{1,3})) {
-      yylval->server.port= MEMCACHED_DEFAULT_PORT;
-      yylval->server.weight= 1;
-      yylval->server.c_str= yyextra->set_hostname(yytext, yyleng);
-      if (yylval->server.c_str)
-        yylval->server.length= yyleng;
-      return IPADDRESS;
-    }
-
-[[:alnum:]]["."[:alnum:]_-]+[[:alnum:]] {
-      if (yyextra->is_server())
-      {
-        yylval->server.port= MEMCACHED_DEFAULT_PORT;
-        yylval->server.weight= 1;
-        yylval->server.c_str= yyextra->set_hostname(yytext, yyleng);
-        if (yylval->server.c_str)
-          yylval->server.length= yyleng;
-
-        return HOSTNAME;
-      }
-
-      yylval->string.c_str = yytext;
-      yylval->string.length = yyleng;
-
-      return STRING;
-    }
-
-(\".*\") {
-      yylval->string.c_str = yytext;
-      yylval->string.length = yyleng;
-      return QUOTED_STRING;
-    }
-
-.   {
-      yyextra->begin= yytext;
-      return UNKNOWN;
-    }
-
-%%
-
-void Context::init_scanner()
-{
-  yylex_init(&scanner);
-  yyset_extra(this, scanner);
-}
-
-void Context::destroy_scanner()
-{
-  yylex_destroy(scanner);
-}
-
index fd731e0e1445d4b52ec4125b032bfbb2e3879c52..98f5ed68553d1d29e069859a7c967d510fd34547 100644 (file)
@@ -93,6 +93,13 @@ LIBMEMCACHED_API
 memcached_return_t memcached_server_add(memcached_st *ptr,
                                         const char *hostname, in_port_t port);
 
+LIBMEMCACHED_LOCAL
+  memcached_return_t memcached_server_add_parsed(memcached_st *ptr,
+                                                 const char *hostname,
+                                                 size_t hostname_length,
+                                                 in_port_t port,
+                                                 uint32_t weight);
+
 LIBMEMCACHED_API
 memcached_return_t memcached_server_add_udp_with_weight(memcached_st *ptr,
                                                         const char *hostname,