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.18 by root, Tue Nov 6 17:20:42 2007 UTC

1#define DNS_USE_GETTIMEOFDAY_FOR_ID 1 1/* $Id: evdns.c,v 1.18 2007/11/06 17:20:42 root Exp $ */
2 2
3/* 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
4 * a history of modifications, check out the subversion logs. 4 * a history of modifications, check out the subversion logs.
5 * 5 *
6 * 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
38#ifdef HAVE_CONFIG_H 38#ifdef HAVE_CONFIG_H
39#include "config.h" 39#include "config.h"
40#endif 40#endif
41 41
42#ifdef WIN32 42#ifdef WIN32
43#ifndef EV_STANDALONE
43#include "misc.h" 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
173 char request_appended; /* true if the request pointer is data which follows this struct */ 175 char request_appended; /* true if the request pointer is data which follows this struct */
174 char transmit_me; /* needs to be transmitted */ 176 char transmit_me; /* needs to be transmitted */
175}; 177};
176 178
177#ifndef HAVE_STRUCT_IN6_ADDR 179#ifndef HAVE_STRUCT_IN6_ADDR
178struct xin6_addr { 180struct in6_addr {
179 u8 s6_addr[16]; 181 u8 s6_addr[16];
180}; 182};
181#endif 183#endif
182 184
183struct reply { 185struct reply {
188 u32 addrcount; 190 u32 addrcount;
189 u32 addresses[MAX_ADDRS]; 191 u32 addresses[MAX_ADDRS];
190 } a; 192 } a;
191 struct { 193 struct {
192 u32 addrcount; 194 u32 addrcount;
193 struct xin6_addr addresses[MAX_ADDRS]; 195 struct in6_addr addresses[MAX_ADDRS];
194 } aaaa; 196 } aaaa;
195 struct { 197 struct {
196 char name[HOST_NAME_MAX]; 198 char name[HOST_NAME_MAX];
197 } ptr; 199 } ptr;
198 } data; 200 } data;
2263 if (!req) return 1; 2265 if (!req) return 1;
2264 request_submit(req); 2266 request_submit(req);
2265 return 0; 2267 return 0;
2266} 2268}
2267 2269
2268int evdns_resolve_reverse_ipv6(struct xin6_addr *in, int flags, evdns_callback_type callback, void *ptr) { 2270int evdns_resolve_reverse_ipv6(struct in6_addr *in, int flags, evdns_callback_type callback, void *ptr) {
2269 char buf[96]; 2271 char buf[96];
2270 char *cp; 2272 char *cp;
2271 struct request *req; 2273 struct request *req;
2272 int i; 2274 int i;
2273 assert(in); 2275 assert(in);
2542 /* if the file isn't found then we assume a local resolver */ 2544 /* if the file isn't found then we assume a local resolver */
2543 if (flags & DNS_OPTION_SEARCH) search_set_from_hostname(); 2545 if (flags & DNS_OPTION_SEARCH) search_set_from_hostname();
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
2549#ifndef HAVE_STRTOK_R
2550static char *
2551strtok_r(char *s, const char *delim, char **state) {
2552 return strtok(s, delim);
2553}
2554#endif
2547 2555
2548/* helper version of atoi which returns -1 on error */ 2556/* helper version of atoi which returns -1 on error */
2549static int 2557static int
2550strtoint(const char *const str) { 2558strtoint(const char *const str) {
2551 char *endptr; 2559 char *endptr;
2614 2622
2615static void 2623static void
2616resolv_conf_parse_line(char *const start, int flags) { 2624resolv_conf_parse_line(char *const start, int flags) {
2617 char *strtok_state; 2625 char *strtok_state;
2618 static const char *const delims = " \t"; 2626 static const char *const delims = " \t";
2619#define NEXT_TOKEN strtok(NULL, delims, &strtok_state) 2627#define NEXT_TOKEN strtok_r(NULL, delims, &strtok_state)
2620 2628
2621 char *const first_token = strtok(start, delims, &strtok_state); 2629 char *const first_token = strtok_r(start, delims, &strtok_state);
2622 if (!first_token) return; 2630 if (!first_token) return;
2623 2631
2624 if (!strcmp(first_token, "nameserver") && (flags & DNS_OPTION_NAMESERVERS)) { 2632 if (!strcmp(first_token, "nameserver") && (flags & DNS_OPTION_NAMESERVERS)) {
2625 const char *const nameserver = NEXT_TOKEN; 2633 const char *const nameserver = NEXT_TOKEN;
2626 struct in_addr ina; 2634 struct in_addr ina;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines