From 98832397c2155e6470119ce3e7e32ceaed4eb49f Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Wed, 17 Apr 2002 12:41:10 +0000 Subject: Patch from Axel Barnitzke to add basic support for struct _res. This is a minimalist implementation, but should work for most anything out there. --- libc/inet/resolv.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c index fa7ba37fe..3fd9b81cd 100644 --- a/libc/inet/resolv.c +++ b/libc/inet/resolv.c @@ -1034,11 +1034,77 @@ struct netent * getnetbyname(const char * name) #ifdef L_res_init +struct __res_state * __res; + +#ifndef _res +#define _res (*__res_state()) +#endif int res_init(void) { + struct __res_state *rp = __res; + if(!__res) { + rp = (struct __res_state *) malloc(sizeof(struct __res_state)); + memset(rp, 0, sizeof(struct __res_state)); + __res = rp; + } + + (void) open_nameservers(); + rp->retrans = RES_TIMEOUT; + rp->retry = 4; + rp->options = RES_INIT; + rp->id = (u_int) random(); + rp->nsaddr.sin_addr.s_addr = INADDR_ANY; + rp->nsaddr.sin_family = AF_INET; + rp->nsaddr.sin_port = htons(NAMESERVER_PORT); + rp->ndots = 1; + /** rp->pfcode = 0; **/ + rp->_vcsock = -1; + /** rp->_flags = 0; **/ + /** rp->qhook = NULL; **/ + /** rp->rhook = NULL; **/ + /** rp->_u._ext.nsinit = 0; **/ + + if(searchdomains) { + int i; + for(i=0; idnsrch[i] = searchdomain[i]; + } + } + + if(nameservers) { + int i; + struct in_addr a; + for(i=0; insaddr_list[i].sin_addr = a; + rp->nsaddr_list[i].sin_family = AF_INET; + rp->nsaddr_list[i].sin_port = htons(NAMESERVER_PORT); + } + } + } + rp->nscount = nameservers; + return(0); } + +struct __res_state * __res_state (void) +{ + if(!__res) { + res_init(); + } + return __res; +} + +void res_close( void ) +{ + if(__res) { + free(__res); + __res = NULL; + } + return; +} + #endif -- cgit v1.2.3