From: Brian Aker Date: Fri, 18 Mar 2011 10:43:48 +0000 (-0700) Subject: Merge in all of the new parser work. X-Git-Tag: 0.51~15^2~75^2~23 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=10f3d6bf1bc11c235779ae735f30758cfb035686;p=m6w6%2Flibmemcached Merge in all of the new parser work. --- diff --git a/.bzrignore b/.bzrignore index 87578c4b..e7ff2911 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1,6 +1,7 @@ *.exe *.lo *.pop +*.rpm */*.l[oa] */*/*.l[oa] */*/.deps @@ -40,6 +41,7 @@ config/ltmain.sh config/missing config/pandora_vc_revinfo config/plugin.ac +config/top.h configure docs/*.[13] docs/*.html @@ -73,7 +75,16 @@ libmemcached-?.??/ libmemcached.pop libmemcached/configure.h libmemcached/dtrace_probes.h +libmemcached/generated_probes.h libmemcached/memcached_configure.h +libmemcached/options/parser.cc +libmemcached/options/parser.h +libmemcached/options/parser.output +libmemcached/options/parsers.cc +libmemcached/options/parsers.h +libmemcached/options/parsers.output +libmemcached/options/scanner.cc +libmemcached/options/scanner.h libmemcached_examples.pop libmemcachedutil.pop libtool @@ -185,5 +196,4 @@ tests/testhashkit tests/testplus tests/testudp unittests/unittests -config/top.h -libmemcached/generated_probes.h +clients/memparse diff --git a/Makefile.am b/Makefile.am index 31585120..7a09b51f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -15,6 +15,7 @@ nobase_include_HEADERS = check_PROGRAMS = EXTRA_HEADERS = BUILT_SOURCES= +DISTCLEANFILES= EXTRA_DIST= \ ${srcdir}/m4/pandora_*.m4 \ .quickly \ diff --git a/clients/include.am b/clients/include.am index a709e38d..f7503754 100644 --- a/clients/include.am +++ b/clients/include.am @@ -18,6 +18,7 @@ bin_PROGRAMS+= \ clients/memdump \ clients/memerror \ clients/memflush \ + clients/memparse \ clients/memrm \ clients/memstat @@ -50,6 +51,9 @@ clients_libgenexec_la_SOURCES= clients/generator.c clients/execute.c clients_memcat_SOURCES= clients/memcat.c clients_memcat_LDADD= $(CLIENTS_LDADDS) +clients_memparse_SOURCES= clients/memparse.cc +clients_memparse_LDADD= $(CLIENTS_LDADDS) + clients_memcp_SOURCES= clients/memcp.c clients_memcp_LDADD= $(CLIENTS_LDADDS) diff --git a/clients/memparse.cc b/clients/memparse.cc new file mode 100644 index 00000000..50eedfc6 --- /dev/null +++ b/clients/memparse.cc @@ -0,0 +1,66 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +#include + +#include + +int main(int argc, char *argv[]) +{ + + if (argc != 2) + { + std::cerr << "Wrong number of arguments" << std::endl; + return EXIT_FAILURE; + } + + memcached_st *memc; + + memc= memcached_create(NULL); + + memcached_return_t rc= memcached_parse_options(memc, argv[1], strlen(argv[1])); + + if (rc != MEMCACHED_SUCCESS) + { + std::cerr << "Failed to parse options" << std::endl; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} diff --git a/configure.ac b/configure.ac index c3b4300f..2af6cae1 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,6 @@ #!/usr/bin/env bash -# libmemcached +# LibmemcacheD +# Copyright (C) 2011 Data Differential, http://datadifferential.com/ # Copyright (C) 2006-2010 Brian Aker, Monty Taylor, Trond Norbye # All rights reserved. # @@ -12,6 +13,8 @@ AC_CONFIG_SRCDIR([libmemcached/memcached.c]) AC_CONFIG_AUX_DIR(config) PANDORA_CANONICAL_TARGET(no-vc-changelog) +AC_CHECK_PROGS([YACC], ['bison'], [:]) +AC_CHECK_PROGS([LEX], ['flex'], [:]) #shared library versioning MEMCACHED_UTIL_LIBRARY_VERSION=1:0:0 diff --git a/libmemcached/behavior.c b/libmemcached/behavior.c index f88f0a77..da111351 100644 --- a/libmemcached/behavior.c +++ b/libmemcached/behavior.c @@ -227,6 +227,9 @@ memcached_return_t memcached_behavior_set(memcached_st *ptr, } } break; + case MEMCACHED_BEHAVIOR_LOAD_FROM_FILE: + ptr->flags.load_from_file= set_flag(data); + break; case MEMCACHED_BEHAVIOR_MAX: default: /* Shouldn't get here */ @@ -382,6 +385,8 @@ uint64_t memcached_behavior_get(memcached_st *ptr, return ptr->flags.cork; case MEMCACHED_BEHAVIOR_TCP_KEEPALIVE: return ptr->flags.tcp_keepalive; + case MEMCACHED_BEHAVIOR_LOAD_FROM_FILE: + return ptr->flags.load_from_file; case MEMCACHED_BEHAVIOR_MAX: default: WATCHPOINT_ASSERT(0); /* Programming mistake if it gets this far */ diff --git a/libmemcached/constants.h b/libmemcached/constants.h index b12a3890..00abb7bf 100644 --- a/libmemcached/constants.h +++ b/libmemcached/constants.h @@ -121,6 +121,7 @@ typedef enum { MEMCACHED_BEHAVIOR_CORK, MEMCACHED_BEHAVIOR_TCP_KEEPALIVE, MEMCACHED_BEHAVIOR_TCP_KEEPIDLE, + MEMCACHED_BEHAVIOR_LOAD_FROM_FILE, MEMCACHED_BEHAVIOR_MAX } memcached_behavior_t; diff --git a/libmemcached/include.am b/libmemcached/include.am index 7d4841f8..75bcf600 100644 --- a/libmemcached/include.am +++ b/libmemcached/include.am @@ -2,6 +2,10 @@ # included from Top Level Makefile.am # All paths should be given relative to the root +libmemcached_libmemcached_la_SOURCES = + +include libmemcached/options/include.am + EXTRA_DIST+= \ libmemcached/configure.h.in \ libmemcached/libmemcached_probes.d \ @@ -38,6 +42,7 @@ nobase_include_HEADERS+= \ libmemcached/memcached.h \ libmemcached/memcached.hpp \ libmemcached/memcached/protocol_binary.h \ + libmemcached/options.h \ libmemcached/parse.h \ libmemcached/platform.h \ libmemcached/protocol/cache.h \ @@ -84,7 +89,7 @@ libmemcached_libmemcachedinternal_la_SOURCES= \ lib_LTLIBRARIES+= libmemcached/libmemcached.la libmemcached_libmemcached_la_CFLAGS= ${AM_CFLAGS} ${NO_CONVERSION} -libmemcached_libmemcached_la_SOURCES = \ +libmemcached_libmemcached_la_SOURCES+= \ libmemcached/allocators.c \ libmemcached/analyze.c \ libmemcached/auto.c \ @@ -98,6 +103,7 @@ libmemcached_libmemcached_la_SOURCES = \ libmemcached/flush_buffers.c \ libmemcached/get.c \ libmemcached/hash.c \ + libmemcached/options.cc \ libmemcached/hosts.c \ libmemcached/io.c \ libmemcached/key.c \ @@ -115,6 +121,8 @@ libmemcached_libmemcached_la_SOURCES = \ libmemcached/verbosity.c \ libmemcached/version.c +libmemcached/options.cc: libmemcached/options/parser.h + libmemcached_libmemcached_la_DEPENDENCIES= libmemcached/libmemcachedcallbacks.la libmemcached/libmemcachedinternal.la libhashkit/libhashkitinc.la libmemcached_libmemcached_la_LIBADD= $(LIBM) libmemcached/libmemcachedcallbacks.la libmemcached/libmemcachedinternal.la libhashkit/libhashkitinc.la diff --git a/libmemcached/memcached.c b/libmemcached/memcached.c index 81895afa..b0333569 100644 --- a/libmemcached/memcached.c +++ b/libmemcached/memcached.c @@ -34,7 +34,9 @@ static const memcached_st global_copy= { .use_sort_hosts= false, .use_udp= false, .verify_key= false, - .tcp_keepalive= false + .tcp_keepalive= false, + .load_from_file= false + } }; diff --git a/libmemcached/memcached.h b/libmemcached/memcached.h index c099d76e..56a5a78f 100644 --- a/libmemcached/memcached.h +++ b/libmemcached/memcached.h @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -82,6 +83,7 @@ struct memcached_st { bool use_udp:1; bool verify_key:1; bool tcp_keepalive:1; + bool load_from_file:1; } flags; memcached_server_distribution_t distribution; hashkit_st hashkit; diff --git a/libmemcached/options.cc b/libmemcached/options.cc new file mode 100644 index 00000000..1bf2ffa1 --- /dev/null +++ b/libmemcached/options.cc @@ -0,0 +1,71 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "common.h" + +#include +#include + +int libmemcached_parse(type_st *, yyscan_t *); + +memcached_return_t memcached_parse_options(memcached_st *self, char const *option_string, size_t length) +{ + type_st pp; + + memset(&pp, 0, sizeof(type_st)); + + pp.buf= option_string; + pp.memc= self; + pp.length= length; + libmemcached_lex_init(&pp.yyscanner); + libmemcached_set_extra(&pp, pp.yyscanner); + bool success= libmemcached_parse(&pp, pp.yyscanner) == 0; + libmemcached_lex_destroy(pp.yyscanner); + + if (not success) + return MEMCACHED_INVALID_ARGUMENTS; + + return MEMCACHED_SUCCESS; +} + +memcached_return_t memcached_parse_file_options(memcached_st *ptr, const char *filename) +{ + (void)ptr; + (void)filename; + + return MEMCACHED_SUCCESS; +} diff --git a/libmemcached/options.h b/libmemcached/options.h new file mode 100644 index 00000000..a2351548 --- /dev/null +++ b/libmemcached/options.h @@ -0,0 +1,52 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +LIBMEMCACHED_API + memcached_return_t memcached_parse_options(memcached_st *ptr, const char *option_string, size_t length); + +LIBMEMCACHED_API + memcached_return_t memcached_parse_file_options(memcached_st *ptr, const char *filename); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached/options/include.am b/libmemcached/options/include.am new file mode 100644 index 00000000..2e60573b --- /dev/null +++ b/libmemcached/options/include.am @@ -0,0 +1,37 @@ +# vim:ft=automake +# included from Top Level Makefile.am +# All paths should be given relative to the root + +DISTCLEANFILES+= \ + libmemcached/options/parser.output \ + libmemcached/options/parser.cc \ + libmemcached/options/parser.h \ + libmemcached/options/scanner.cc \ + libmemcached/options/scanner.h + +EXTRA_DIST+= \ + libmemcached/options/scanner.l \ + libmemcached/options/parser.yy + +noinst_HEADERS+= \ + libmemcached/options/parser.h \ + libmemcached/options/scanner.h \ + libmemcached/options/server.h \ + libmemcached/options/string.h \ + libmemcached/options/symbol.h \ + libmemcached/options/type.h + +libmemcached_libmemcached_la_SOURCES+= \ + libmemcached/options/parser.cc \ + libmemcached/options/scanner.cc + +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/lex_string.h b/libmemcached/options/lex_string.h new file mode 100644 index 00000000..991acba8 --- /dev/null +++ b/libmemcached/options/lex_string.h @@ -0,0 +1,16 @@ +#pragma once + +#include +#include + +struct string_t +{ + const char *c_str; + size_t length; +}; + +inline std::ostream& operator<<(std::ostream& output, const string_t& arg) +{ + output << arg.c_str; + return output; +} diff --git a/libmemcached/options/parser.yy b/libmemcached/options/parser.yy new file mode 100644 index 00000000..ae7e6d5f --- /dev/null +++ b/libmemcached/options/parser.yy @@ -0,0 +1,141 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +%{ + +#include +#include + +#include +#include +#include + +#pragma GCC diagnostic ignored "-Wold-style-cast" +#include + +inline int libmemcached_error(YYLTYPE *locp, type_st *parser, yyscan_t *scanner, const char *str) +{ + std::cerr << str << std::endl; + return 0; +} + + +%} + +%error-verbose +%debug +%defines +%expect 0 +%output "libmemcached/options/parser.cc" +%defines "libmemcached/options/parser.h" +%lex-param { yyscan_t *scanner } +%name-prefix="libmemcached_" +%parse-param { type_st *parser } +%parse-param { yyscan_t *scanner } +%locations +%pure-parser +%require "2.2" +%start statement +%verbose + +%token EQ +%token SERVER +%token SERVERS +%token TCPNODELAY +%token UNKNOWN +%token VERIFY_KEY +%token COMMA + +%token NUMBER +%token FLOAT +%token IDENTIFIER +%token SERVER_WITH_PORT + +%type server + +%% + +statement: + expression + { } + | statement expression + { } + ; + + +expression: + SERVER EQ server + { + (void) memcached_server_add(parser->memc, $3.c_str, $3.port); + } + | SERVERS EQ server_list + { } + | TCPNODELAY + { + memcached_behavior_set(parser->memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, true); + } + | VERIFY_KEY + { + memcached_behavior_set(parser->memc, MEMCACHED_BEHAVIOR_VERIFY_KEY, true); + } + ; + +server_list: + server + { + (void) memcached_server_add(parser->memc, $1.c_str, $1.port); + } + | server_list COMMA server + { + (void) memcached_server_add(parser->memc, $3.c_str, $3.port); + } + ; + +server: + SERVER_WITH_PORT NUMBER + { + $$.c_str= $1.c_str; + $$.length= $1.length; + $$.port= $2; + } + | IDENTIFIER + { + $$.c_str= $1.c_str; + $$.length= $1.length; + $$.port= 80; + } + ; diff --git a/libmemcached/options/scanner.l b/libmemcached/options/scanner.l new file mode 100644 index 00000000..e11fcf49 --- /dev/null +++ b/libmemcached/options/scanner.l @@ -0,0 +1,89 @@ + +%top{ + +#pragma GCC diagnostic ignored "-Wold-style-cast" +#pragma GCC diagnostic ignored "-Wunused-parameter" +#pragma GCC diagnostic ignored "-fpermissive" + +#include +#include +#include +#include + +} + + +%{ +#include +#include + +#define PARAM yyget_extra(yyscanner) + +static void get_lex_chars(char* buffer, int& result, int max_size, struct type_st *parser) +{ + if (parser->pos >= parser->length) + { + result = YY_NULL; + } + else + { + result = parser->length - parser->pos; + result > (int)max_size ? result = max_size : 0; + memcpy(buffer, parser->buf + parser->pos, result); + parser->pos += result; + } +} + + +#define YY_INPUT(buffer, result, max_size) get_lex_chars(buffer, result, max_size, PARAM) + +%} + +%option bison-locations +%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="libmemcached_" +%option reentrant + +%% + +[=] { return EQ; } +[,] { return COMMA; } + +[0-9]+ { yylval->number = atoi(yytext); return (NUMBER); } + +([0-9]*.[0-9]+) { yylval->double_number = atof(yytext); return (FLOAT); } + +[ \t\r\n] ; /* skip whitespace */ + +"--SERVER" { return SERVER; } +"--SERVERS" { return SERVERS; } +"--TCP_NODELAY" { return TCPNODELAY; } +"--TCP-NODELAY" { return TCPNODELAY; } +"--VERIFY_KEY" { return VERIFY_KEY; } +"--VERIFY-KEY" { return VERIFY_KEY; } + +[A-Za-z][A-Za-z0-9_]*[:] { + yylval->string.c_str = yytext; + yylval->string.length = yyleng; + return SERVER_WITH_PORT; + } + +[A-Za-z][A-Za-z0-9_]* { + yylval->string.c_str = yytext; + yylval->string.length = yyleng; + return IDENTIFIER; + } +[-] ; + +. { + std::cerr << "Near " << yytext << std::endl; + return UNKNOWN; + } + +%% diff --git a/libmemcached/options/server.h b/libmemcached/options/server.h new file mode 100644 index 00000000..af6e0f3e --- /dev/null +++ b/libmemcached/options/server.h @@ -0,0 +1,56 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#include +#include +#include + +struct server_t +{ + const char *c_str; + size_t length; + in_port_t port; +}; + +inline std::ostream& operator<<(std::ostream& output, const server_t& arg) +{ + output.write(arg.c_str, arg.length); + output << ':' << arg.port; + return output; +} diff --git a/libmemcached/options/string.h b/libmemcached/options/string.h new file mode 100644 index 00000000..82d60acb --- /dev/null +++ b/libmemcached/options/string.h @@ -0,0 +1,53 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#include +#include + +struct string_t +{ + const char *c_str; + size_t length; +}; + +inline std::ostream& operator<<(std::ostream& output, const string_t& arg) +{ + output.write(arg.c_str, arg.length); + return output; +} diff --git a/libmemcached/options/symbol.h b/libmemcached/options/symbol.h new file mode 100644 index 00000000..508dacbd --- /dev/null +++ b/libmemcached/options/symbol.h @@ -0,0 +1,51 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#include +#include + +union YYSTYPE +{ + long long number; + string_t string; + server_t server; + double double_number; +}; + +typedef union YYSTYPE YYSTYPE; diff --git a/libmemcached/options/type.h b/libmemcached/options/type.h new file mode 100644 index 00000000..aa73acf3 --- /dev/null +++ b/libmemcached/options/type.h @@ -0,0 +1,49 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#pragma once + +#include + +struct type_st +{ + void *yyscanner; + char *buf; + int pos; + int length; + memcached_st *memc; +}; diff --git a/m4/pandora_warnings.m4 b/m4/pandora_warnings.m4 index 30ff3434..7ef435ff 100644 --- a/m4/pandora_warnings.m4 +++ b/m4/pandora_warnings.m4 @@ -129,7 +129,7 @@ AC_DEFUN([PANDORA_WARNINGS],[ m4_if(PW_LESS_WARNINGS,[no],[ BASE_WARNINGS_FULL="${W_CONVERSION} -Wstrict-aliasing" CC_WARNINGS_FULL="-Wswitch-default -Wswitch-enum -Wwrite-strings" - CXX_WARNINGS_FULL="-Weffc++ -Wold-style-cast" + CXX_WARNINGS_FULL="" NO_OLD_STYLE_CAST="-Wno-old-style-cast" NO_EFF_CXX="-Wno-effc++" ],[