-
Notifications
You must be signed in to change notification settings - Fork 2
/
res_init.c
50 lines (46 loc) · 1.11 KB
/
res_init.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <winsock.h>
#include <ddeml.h>
#include <stdlib.h>
#include <string.h>
#include "dns.h"
#include "tx.h"
struct state _res =
{
RES_TIMEOUT, /* retransmition time interval */
4, /* number of times to retransmit */
RES_DEFAULT, /* options flags */
1, /* number of name servers */
};
void
res_init()
{
int i;
char *pch;
int nSearches;
char achAddresses[4];
int aiAddresses[4];
memset(_res.nsaddr, 0, 4);
_res.nscount = 1;
strncpy(_res.defdname, hostinfo.achDomainName, sizeof(_res.defdname));
for (i = 0; i < MAXNS && i < hostinfo.nHosts; i++)
{
sscanf(hostinfo.aachHosts[i], "%d.%d.%d.%d",
&aiAddresses[0],
&aiAddresses[1],
&aiAddresses[2],
&aiAddresses[3]);
achAddresses[0] = aiAddresses[0];
achAddresses[1] = aiAddresses[1];
achAddresses[2] = aiAddresses[2];
achAddresses[3] = aiAddresses[3];
memcpy(&_res.nsaddr_list[i],
achAddresses, 4);
}
_res.nscount = i ? i : 1;
if (!_res.defdname[0])
{
if ((pch = strchr(hostinfo.achHostName, '.')) != 0)
strcpy(_res.defdname, pch + 1);
}
_res.options |= RES_INIT;
}