1 | #define DNS_USE_GETTIMEOFDAY_FOR_ID 1 |
1 | /* $Id: evdns.c,v 1.8 2007/11/04 16:52:52 root Exp $ */ |
2 | #define HAVE_STRUCT_IN6_ADDR 1 |
|
|
3 | |
2 | |
4 | /* The original version of this module was written by Adam Langley; for |
3 | /* The original version of this module was written by Adam Langley; for |
5 | * a history of modifications, check out the subversion logs. |
4 | * a history of modifications, check out the subversion logs. |
6 | * |
5 | * |
7 | * When editing this module, try to keep it re-mergeable by Adam. Don't |
6 | * When editing this module, try to keep it re-mergeable by Adam. Don't |
… | |
… | |
39 | #ifdef HAVE_CONFIG_H |
38 | #ifdef HAVE_CONFIG_H |
40 | #include "config.h" |
39 | #include "config.h" |
41 | #endif |
40 | #endif |
42 | |
41 | |
43 | #ifdef WIN32 |
42 | #ifdef WIN32 |
|
|
43 | #ifndef EV_EMBED |
|
|
44 | #include "misc.h" |
|
|
45 | #endif |
44 | #endif |
46 | #endif |
45 | |
47 | |
46 | /* #define NDEBUG */ |
48 | /* #define NDEBUG */ |
47 | |
49 | |
48 | #ifndef DNS_USE_CPU_CLOCK_FOR_ID |
50 | #ifndef DNS_USE_CPU_CLOCK_FOR_ID |
… | |
… | |
2544 | if (flags & DNS_OPTION_NAMESERVERS) evdns_nameserver_ip_add("127.0.0.1"); |
2546 | if (flags & DNS_OPTION_NAMESERVERS) evdns_nameserver_ip_add("127.0.0.1"); |
2545 | } |
2547 | } |
2546 | |
2548 | |
2547 | #ifndef HAVE_STRTOK_R |
2549 | #ifndef HAVE_STRTOK_R |
2548 | static char * |
2550 | static char * |
2549 | fake_strtok_r(char *s, const char *delim, char **state) { |
2551 | strtok_r(char *s, const char *delim, char **state) { |
2550 | return strtok(s, delim); |
2552 | return strtok(s, delim); |
2551 | } |
2553 | } |
2552 | #endif |
2554 | #endif |
2553 | |
2555 | |
2554 | /* helper version of atoi which returns -1 on error */ |
2556 | /* helper version of atoi which returns -1 on error */ |
… | |
… | |
2620 | |
2622 | |
2621 | static void |
2623 | static void |
2622 | resolv_conf_parse_line(char *const start, int flags) { |
2624 | resolv_conf_parse_line(char *const start, int flags) { |
2623 | char *strtok_state; |
2625 | char *strtok_state; |
2624 | static const char *const delims = " \t"; |
2626 | static const char *const delims = " \t"; |
2625 | #define NEXT_TOKEN fake_strtok_r(NULL, delims, &strtok_state) |
2627 | #define NEXT_TOKEN strtok_r(NULL, delims, &strtok_state) |
2626 | |
2628 | |
2627 | char *const first_token = fake_strtok_r(start, delims, &strtok_state); |
2629 | char *const first_token = strtok_r(start, delims, &strtok_state); |
2628 | if (!first_token) return; |
2630 | if (!first_token) return; |
2629 | |
2631 | |
2630 | if (!strcmp(first_token, "nameserver") && (flags & DNS_OPTION_NAMESERVERS)) { |
2632 | if (!strcmp(first_token, "nameserver") && (flags & DNS_OPTION_NAMESERVERS)) { |
2631 | const char *const nameserver = NEXT_TOKEN; |
2633 | const char *const nameserver = NEXT_TOKEN; |
2632 | struct in_addr ina; |
2634 | struct in_addr ina; |