X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;ds=inline;f=libmemcached%2Foptions.cc;h=02b885fca60e69e6f6efd54c1bea381c874c352b;hb=3dee67d04099cc5e2986ed94aa612f429f54d6fb;hp=dde4ccbe0b8e47cb5c7ec3c51171ab1d2f719174;hpb=1d076426d9ff399efc40d8556d8bc883b47ed87c;p=m6w6%2Flibmemcached diff --git a/libmemcached/options.cc b/libmemcached/options.cc index dde4ccbe..02b885fc 100644 --- a/libmemcached/options.cc +++ b/libmemcached/options.cc @@ -37,10 +37,9 @@ #include "common.h" -#include -#include +#include -int libmemcached_parse(Context*, yyscan_t *); +#include const char *memcached_parse_filename(memcached_st *memc) { @@ -54,9 +53,15 @@ size_t memcached_parse_filename_length(memcached_st *memc) static memcached_return_t _parse_file_options(memcached_st *self, memcached_string_t *filename) { - FILE *fp= fopen(filename->c_str, "r"); + std::string real_name(filename->c_str, filename->size); + FILE *fp= fopen(real_name.c_str(), "r"); if (! fp) - return memcached_set_errno(self, errno, NULL); + { + memcached_string_t tmp; + tmp.c_str= real_name.c_str(); + tmp.size= real_name.size(); + return memcached_set_errno(self, errno, &tmp); + } char buffer[BUFSIZ]; memcached_return_t rc= MEMCACHED_INVALID_ARGUMENTS; @@ -76,7 +81,7 @@ static memcached_return_t _parse_file_options(memcached_st *self, memcached_stri return rc; } -memcached_return_t libmemcached_check_configuration(const char *option_string, size_t length, const char *error_buffer, size_t error_buffer_size) +memcached_return_t libmemcached_check_configuration(const char *option_string, size_t length, char *error_buffer, size_t error_buffer_size) { memcached_st memc, *memc_ptr; @@ -86,7 +91,7 @@ memcached_return_t libmemcached_check_configuration(const char *option_string, s memcached_return_t rc= memcached_parse_configuration(memc_ptr, option_string, length); if (rc != MEMCACHED_SUCCESS && error_buffer && error_buffer_size) { - strncpy(error_buffer, error_buffer_size, memcached_last_error_message(memc_ptr)); + strncpy(error_buffer, memcached_last_error_message(memc_ptr), error_buffer_size); } if (rc== MEMCACHED_SUCCESS && memcached_behavior_get(memc_ptr, MEMCACHED_BEHAVIOR_LOAD_FROM_FILE)) @@ -96,7 +101,7 @@ memcached_return_t libmemcached_check_configuration(const char *option_string, s if (rc != MEMCACHED_SUCCESS && error_buffer && error_buffer_size) { - strncpy(error_buffer, error_buffer_size, memcached_last_error_message(memc_ptr)); + strncpy(error_buffer, memcached_last_error_message(memc_ptr), error_buffer_size); } } @@ -111,14 +116,12 @@ memcached_return_t memcached_parse_configuration(memcached_st *self, char const if (! self) return memcached_set_error(self, MEMCACHED_INVALID_ARGUMENTS, NULL); - Context context(option_string, length, self); + memcached_return_t rc; + Context context(option_string, length, self, rc); - bool success= libmemcached_parse(&context, context.scanner) == 0; + context.start(); - if (not success) - return MEMCACHED_PARSE_ERROR; - - return MEMCACHED_SUCCESS; + return rc; } void memcached_set_configuration_file(memcached_st *self, const char *filename, size_t filename_length)