Finished RPM support. You can now type "make rpm" to build an rpm.
[m6w6/libmemcached] / src / utilities.c
1 #include <ctype.h>
2 #include <memcached.h>
3
4 void parse_opt_servers(memcached_st *memc,
5 char *server_strings)
6 {
7 char *string;
8 unsigned int port;
9 char *begin_ptr;
10 char *end_ptr;
11
12 assert(server_strings);
13 assert(memc);
14
15 end_ptr= server_strings + strlen(server_strings);
16
17 for (begin_ptr= server_strings, string= index(server_strings, ',');
18 begin_ptr != end_ptr;
19 string= index(begin_ptr, ','))
20 {
21 char buffer[HUGE_STRING_LEN];
22 char *ptr;
23 port= 0;
24
25 memset(buffer, 0, HUGE_STRING_LEN);
26 if (string)
27 {
28 memcpy(buffer, begin_ptr, string - begin_ptr);
29 begin_ptr= string+1;
30 }
31 else
32 {
33 size_t length= strlen(begin_ptr);
34 memcpy(buffer, begin_ptr, length);
35 begin_ptr= end_ptr;
36 }
37
38 ptr= index(buffer, ':');
39
40 if (ptr)
41 {
42 ptr[0]= 0;
43
44 ptr++;
45
46 port= strtol(ptr, (char **)NULL, 10);
47 }
48
49 memcached_server_add(memc, buffer, port);
50
51 if (isspace(*begin_ptr))
52 begin_ptr++;
53 }
54 }