X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Foptions.cc;h=b404652ec5e97bd8ccd0e479a87ae3a5f3c420d7;hb=18ace40ddb7271f3f5e71965f74fe11d7754bd8f;hp=35e8b783ac6e782507f989aebbd6be2748bfed0c;hpb=ecf02b501d387ee5761eb31db6f760de60ac09a1;p=awesomized%2Flibmemcached diff --git a/libmemcached/options.cc b/libmemcached/options.cc index 35e8b783..b404652e 100644 --- a/libmemcached/options.cc +++ b/libmemcached/options.cc @@ -35,12 +35,11 @@ * */ -#include "common.h" +#include "libmemcached/common.h" -#include -#include +#include -int libmemcached_parse(Context*, yyscan_t *); +#include const char *memcached_parse_filename(memcached_st *memc) { @@ -54,9 +53,20 @@ 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"); + memcached_array_st *real_name= memcached_strcpy(self, filename->c_str, filename->size); + + if (not real_name) + return MEMCACHED_MEMORY_ALLOCATION_FAILURE; + + FILE *fp= fopen(memcached_array_string(real_name), "r"); if (! fp) - return memcached_set_errno(self, errno, NULL); + { + memcached_string_t error_message= memcached_array_to_string(real_name); + memcached_return_t rc= memcached_set_errno(self, errno, &error_message); + memcached_array_free(real_name); + return rc; + } + memcached_array_free(real_name); char buffer[BUFSIZ]; memcached_return_t rc= MEMCACHED_INVALID_ARGUMENTS; @@ -76,7 +86,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; @@ -114,7 +124,7 @@ memcached_return_t memcached_parse_configuration(memcached_st *self, char const memcached_return_t rc; Context context(option_string, length, self, rc); - libmemcached_parse(&context, context.scanner); + context.start(); return rc; }