#include <stdint.h>
+#include <libmemcached/common.h>
+#include <libmemcached/options.hpp>
+
#include <libmemcached/options/context.h>
-#include <libmemcached/options/string.h>
#include <libmemcached/options/symbol.h>
-#include <libmemcached/visibility.h>
-#include <libmemcached/prefix_key.h>
+#include <libmemcached/options/scanner.h>
+
+#include <iostream>
#pragma GCC diagnostic ignored "-Wold-style-cast"
-#include <libmemcached/options/scanner.h>
int conf_lex(YYSTYPE* lvalp, void* scanner);
%token CONFIGURE_FILE
%token EMPTY_LINE
%token SERVER
+%token SOCKET
%token SERVERS
%token SERVERS_OPTION
%token UNKNOWN_OPTION
/* Callbacks */
%token NAMESPACE
+/* Pool */
+%token POOL_MIN
+%token POOL_MAX
+
/* Hash types */
%token MD5
%token CRC
%token <number> FLOAT
%token <number> NUMBER
-%token PORT
-%token WEIGHT_START
+%token <number> PORT
+%token <number> 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
+%type <distribution> distribution
+%type <hash> hash
+%type <number> optional_port
+%type <number> optional_weight
+%type <string> string
%%
}
| INCLUDE ' ' string
{
- if ((context->rc= memcached_parse_configure_file(context->memc, $3.c_str, $3.length)) != MEMCACHED_SUCCESS)
+ if ((context->rc= memcached_parse_configure_file(*context->memc, $3.c_str, $3.size)) != 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)
+ if (memcached_failed(context->rc= memcached_server_add_with_weight(context->memc, $2.c_str, $3, $4)))
{
parser_abort(context, NULL);
}
}
| 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)
+ if (memcached_failed(context->rc= memcached_server_add_with_weight(context->memc, $2.c_str, $3, $4)))
{
parser_abort(context, NULL);
}
context->unset_server();
}
+ | SOCKET string
+ {
+ if (memcached_failed(context->rc= memcached_server_add_unix_socket(context->memc, $2.c_str)))
+ {
+ parser_abort(context, NULL);
+ }
+ }
| CONFIGURE_FILE string
{
- memcached_set_configuration_file(context->memc, $2.c_str, $2.length);
+ memcached_set_configuration_file(context->memc, $2.c_str, $2.size);
+ }
+ | POOL_MIN NUMBER
+ {
+ context->memc->configure.initial_pool_size= $2;
+ }
+ | POOL_MAX NUMBER
+ {
+ context->memc->configure.max_pool_size= $2;
}
| behaviors
;
behaviors:
NAMESPACE string
{
- if ((context->rc= memcached_set_prefix_key(context->memc, $2.c_str, $2.length)) != MEMCACHED_SUCCESS)
+ if ((context->rc= memcached_set_namespace(context->memc, $2.c_str, $2.size)) != MEMCACHED_SUCCESS)
{
parser_abort(context, NULL);;
}
optional_port:
- { }
+ { $$= MEMCACHED_DEFAULT_PORT;}
| PORT
{ };
;
optional_weight:
- { }
+ { $$= 1; }
| WEIGHT_START
{ }
;
| 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
+ $$.size= $1.size -2; // -2 removes the begin and end quote
}
;