ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/evdns.c
(Generate patch)

Comparing libev/evdns.c (file contents):
Revision 1.3 by root, Thu Nov 1 17:35:02 2007 UTC vs.
Revision 1.4 by root, Thu Nov 1 17:45:30 2007 UTC

1#define DNS_USE_GETTIMEOFDAY_FOR_ID 1 1#define DNS_USE_GETTIMEOFDAY_FOR_ID 1
2#define HAVE_STRUCT_IN6_ADDR 1
2 3
3/* The original version of this module was written by Adam Langley; for 4/* The original version of this module was written by Adam Langley; for
4 * a history of modifications, check out the subversion logs. 5 * a history of modifications, check out the subversion logs.
5 * 6 *
6 * When editing this module, try to keep it re-mergeable by Adam. Don't 7 * When editing this module, try to keep it re-mergeable by Adam. Don't
173 char request_appended; /* true if the request pointer is data which follows this struct */ 174 char request_appended; /* true if the request pointer is data which follows this struct */
174 char transmit_me; /* needs to be transmitted */ 175 char transmit_me; /* needs to be transmitted */
175}; 176};
176 177
177#ifndef HAVE_STRUCT_IN6_ADDR 178#ifndef HAVE_STRUCT_IN6_ADDR
178struct xin6_addr { 179struct in6_addr {
179 u8 s6_addr[16]; 180 u8 s6_addr[16];
180}; 181};
181#endif 182#endif
182 183
183struct reply { 184struct reply {
188 u32 addrcount; 189 u32 addrcount;
189 u32 addresses[MAX_ADDRS]; 190 u32 addresses[MAX_ADDRS];
190 } a; 191 } a;
191 struct { 192 struct {
192 u32 addrcount; 193 u32 addrcount;
193 struct xin6_addr addresses[MAX_ADDRS]; 194 struct in6_addr addresses[MAX_ADDRS];
194 } aaaa; 195 } aaaa;
195 struct { 196 struct {
196 char name[HOST_NAME_MAX]; 197 char name[HOST_NAME_MAX];
197 } ptr; 198 } ptr;
198 } data; 199 } data;
2263 if (!req) return 1; 2264 if (!req) return 1;
2264 request_submit(req); 2265 request_submit(req);
2265 return 0; 2266 return 0;
2266} 2267}
2267 2268
2268int evdns_resolve_reverse_ipv6(struct xin6_addr *in, int flags, evdns_callback_type callback, void *ptr) { 2269int evdns_resolve_reverse_ipv6(struct in6_addr *in, int flags, evdns_callback_type callback, void *ptr) {
2269 char buf[96]; 2270 char buf[96];
2270 char *cp; 2271 char *cp;
2271 struct request *req; 2272 struct request *req;
2272 int i; 2273 int i;
2273 assert(in); 2274 assert(in);
2542 /* if the file isn't found then we assume a local resolver */ 2543 /* if the file isn't found then we assume a local resolver */
2543 if (flags & DNS_OPTION_SEARCH) search_set_from_hostname(); 2544 if (flags & DNS_OPTION_SEARCH) search_set_from_hostname();
2544 if (flags & DNS_OPTION_NAMESERVERS) evdns_nameserver_ip_add("127.0.0.1"); 2545 if (flags & DNS_OPTION_NAMESERVERS) evdns_nameserver_ip_add("127.0.0.1");
2545} 2546}
2546 2547
2548#ifndef HAVE_STRTOK_R
2549static char *
2550fake_strtok_r(char *s, const char *delim, char **state) {
2551 return strtok(s, delim);
2552}
2553#endif
2547 2554
2548/* helper version of atoi which returns -1 on error */ 2555/* helper version of atoi which returns -1 on error */
2549static int 2556static int
2550strtoint(const char *const str) { 2557strtoint(const char *const str) {
2551 char *endptr; 2558 char *endptr;
2614 2621
2615static void 2622static void
2616resolv_conf_parse_line(char *const start, int flags) { 2623resolv_conf_parse_line(char *const start, int flags) {
2617 char *strtok_state; 2624 char *strtok_state;
2618 static const char *const delims = " \t"; 2625 static const char *const delims = " \t";
2619#define NEXT_TOKEN strtok(NULL, delims, &strtok_state) 2626#define NEXT_TOKEN fake_strtok_r(NULL, delims, &strtok_state)
2620 2627
2621 char *const first_token = strtok(start, delims, &strtok_state); 2628 char *const first_token = fake_strtok_r(start, delims, &strtok_state);
2622 if (!first_token) return; 2629 if (!first_token) return;
2623 2630
2624 if (!strcmp(first_token, "nameserver") && (flags & DNS_OPTION_NAMESERVERS)) { 2631 if (!strcmp(first_token, "nameserver") && (flags & DNS_OPTION_NAMESERVERS)) {
2625 const char *const nameserver = NEXT_TOKEN; 2632 const char *const nameserver = NEXT_TOKEN;
2626 struct in_addr ina; 2633 struct in_addr ina;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines