* Copyright (c) 1985 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
static char sccsid
[] = "@(#)res_init.c 5.4 (Berkeley) %G%";
#include <arpa/nameser.h>
* Resolver configuration file. Contains the address of the
* inital name server to query and the default domain for
* non fully qualified domain names.
char *conffile
= CONFFILE
;
char *conffile
= "/usr/local/lib/resolv.conf";
* Resolver state default settings
RES_RECURSE
|RES_DEFNAMES
,
* Read the configuration file for default settings.
* Return true if the name server address is initialized.
extern u_long
inet_addr();
extern char *index(), *getenv();
_res
.options
|= RES_INIT
;
_res
.nsaddr
.sin_family
= AF_INET
;
_res
.nsaddr
.sin_addr
.s_addr
= INADDR_ANY
;
_res
.nsaddr
.sin_port
= htons(NAMESERVER_PORT
);
/* first try reading the config file */
if ((fp
= fopen(conffile
, "r")) != NULL
) {
if (fgets(_res
.defdname
, sizeof(_res
.defdname
), fp
) == NULL
)
else if ((cp
= index(_res
.defdname
, '\n')) != NULL
)
if (fgets(buf
, sizeof (buf
), fp
) != NULL
)
_res
.nsaddr
.sin_addr
.s_addr
= inet_addr(buf
);
/* Allow user to override the local domain definition */
if ((cp
= getenv("LOCALDOMAIN")) != NULL
)
strncpy(_res
.defdname
, cp
, sizeof(_res
.defdname
));