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.
10 memcached_server_st
*memcached_servers_parse(const char *server_strings
)
15 const char *begin_ptr
;
17 memcached_server_st
*servers
= NULL
;
18 memcached_return_t rc
;
20 WATCHPOINT_ASSERT(server_strings
);
22 end_ptr
= server_strings
+ strlen(server_strings
);
24 for (begin_ptr
= server_strings
, string
= index(server_strings
, ',');
26 string
= index(begin_ptr
, ','))
28 char buffer
[HUGE_STRING_LEN
];
35 memcpy(buffer
, begin_ptr
, (size_t) (string
- begin_ptr
));
36 buffer
[(unsigned int)(string
- begin_ptr
)]= 0;
41 size_t length
= strlen(begin_ptr
);
42 memcpy(buffer
, begin_ptr
, length
);
47 ptr
= index(buffer
, ':');
55 port
= (in_port_t
) strtoul(ptr
, (char **)NULL
, 10);
57 ptr2
= index(ptr
, ' ');
59 ptr2
= index(ptr
, ':');
63 weight
= (uint32_t) strtoul(ptr2
, (char **)NULL
, 10);
67 servers
= memcached_server_list_append_with_weight(servers
, buffer
, port
, weight
, &rc
);
69 if (isspace(*begin_ptr
))