+0.49
+ * 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.
+
0.48 Tue Mar 15 23:05:18 PDT 2011
* Fix memory leak in server parse.
* Move test framework out to be its own library (easier to work with Gearman).
return MEMCACHED_SUCCESS;
}
-memcached_return_t memcached_parse_file_options(memcached_st *ptr, const char *filename)
+memcached_return_t memcached_parse_file_options(memcached_st *self, const char *filename)
{
- (void)ptr;
- (void)filename;
+ FILE *fp= fopen(filename, "r");
+
+ if (! fp)
+ return memcached_set_errno(self, errno, NULL);
- return MEMCACHED_SUCCESS;
+ char buffer[BUFSIZ];
+ memcached_return_t rc= MEMCACHED_INVALID_ARGUMENTS;
+ while (fgets(buffer, sizeof(buffer), fp))
+ {
+ size_t length= strlen(buffer);
+
+ if (length == 1 and buffer[0] == '\n')
+ continue;
+
+ rc= memcached_parse_options(self, buffer, length);
+
+ if (rc != MEMCACHED_SUCCESS)
+ break;
+ }
+ fclose(fp);
+
+ return rc;
}
%token SERVER
%token SERVERS
%token UNKNOWN
+%token COMMENT
+%token EMPTY_LINE
%token DASH_OPTION
{ }
| statement ' ' DASH_OPTION expression
{ }
+ | COMMENT
+ { }
+ | EMPTY_LINE
+ { }
;
[\t\r\n] ; /* skip whitespace */
+^#.*$ {
+ return COMMENT;
+ }
+
"--" { return DASH_OPTION; }
SERVER { return SERVER; }
return STRING;
}
-\"[[:alnum:]]*\" {
+\".*\" {
yylval->string.c_str = yytext;
yylval->string.length = yyleng;
return QUOTED_STRING;
--- /dev/null
+# http://en.wikipedia.org/wiki/Consistent_hashing
+--distribution=consistent
+
+# Store one additional copy on each node.
+--number-of-replicas=2
+--prefix-key="my_foo"
+--prefix-key="my_prefix"
+--server=localhost:11211
+--server=localhost:11212
+--server=localhost:11213
+--verify-key
{"server", 0, (test_callback_fn)server_test },
{"servers", 0, (test_callback_fn)servers_test },
{"prefix_key", 0, (test_callback_fn)parser_key_prefix_test },
+ {"memcached_parse_file_options", 0, (test_callback_fn)memcached_parse_file_options_test },
{0, 0, (test_callback_fn)0}
};
(void)junk;
return _test_option(distribution_strings);
}
+
+test_return_t memcached_parse_file_options_test(memcached_st *junk)
+{
+ (void)junk;
+ memcached_st memc;
+ memcached_st *memc_ptr= memcached_create(&memc);
+
+ test_true(memc_ptr);
+
+ memcached_return_t rc= memcached_parse_file_options(memc_ptr, "support/example.cnf");
+ test_true_got(rc == MEMCACHED_SUCCESS, rc == MEMCACHED_INVALID_ARGUMENTS ? memcached_last_error_message(&memc) : memcached_strerror(NULL, rc));
+ memcached_free(memc_ptr);
+
+ return TEST_SUCCESS;
+}
LIBTEST_INTERNAL_API
test_return_t parser_key_prefix_test(memcached_st *junk);
+LIBTEST_INTERNAL_API
+test_return_t memcached_parse_file_options_test(memcached_st *junk);
+
#ifdef __cplusplus
}
#endif