2 I debated about putting this in the client library since it does an
3 action I don't really believe belongs in the library.
5 Frankly its too damn useful not to be here though.
8 #include "libmemcached/memcached.h"
11 memcached_server_st
*memcached_servers_parse(const char *server_strings
)
16 const char *begin_ptr
;
18 memcached_server_st
*servers
= NULL
;
21 WATCHPOINT_ASSERT(server_strings
);
23 end_ptr
= server_strings
+ strlen(server_strings
);
25 for (begin_ptr
= server_strings
, string
= index(server_strings
, ',');
27 string
= index(begin_ptr
, ','))
29 char buffer
[HUGE_STRING_LEN
];
36 memcpy(buffer
, begin_ptr
, string
- begin_ptr
);
37 buffer
[(unsigned int)(string
- begin_ptr
)]= 0;
42 size_t length
= strlen(begin_ptr
);
43 memcpy(buffer
, begin_ptr
, length
);
48 ptr
= index(buffer
, ':');
56 port
= strtoul(ptr
, (char **)NULL
, 10);
58 ptr2
= index(ptr
, ' ');
60 ptr2
= index(ptr
, ':');
64 weight
= strtoul(ptr2
, (char **)NULL
, 10);
68 servers
= memcached_server_list_append_with_weight(servers
, buffer
, port
, weight
, &rc
);
70 if (isspace(*begin_ptr
))