From: Mark Atwood Date: Wed, 19 Sep 2007 10:09:51 +0000 (-0700) Subject: parse --servers option X-Git-Tag: 0.2~21 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=17593c4477c4f4f66706c0d0f7e5dddeade6a9f5;p=awesomized%2Flibmemcached parse --servers option --- diff --git a/src/memcat.c b/src/memcat.c index 77c0f858..ff8319be 100644 --- a/src/memcat.c +++ b/src/memcat.c @@ -8,6 +8,19 @@ static int opt_verbose; static int opt_displayflag; static char *opt_servers; +struct memcached_st *parse_opt_servers (struct memcached_st *m, + char *opt_servers) +{ + char *s, *hostname; + unsigned int portnum; + while (s = strsep(&opt_servers, ",")) { + hostname = strsep(&s, ":"); + portnum = atoi(s); + memcached_server_add(m, hostname, portnum); + } + return m; +} + int main(int argc, char *argv[]) { memcached_st *memc; @@ -56,8 +69,10 @@ int main(int argc, char *argv[]) } } - /* todo, turn opt_servers into something to pass to memcached_init */ - memc= memcached_init(NULL); + memc = malloc(sizeof(struct memcached_st)); + memcached_init(memc); + memc= parse_opt_servers(memc, opt_servers); + memc= memcached_init(memc); for (x= 1; x < argc; x++) {