#ifndef lint
static char copyright[] =
-"$Id: resolv.c,v 1.8 1999/03/16 05:50:37 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: resolv.c,v 1.9 1999/10/01 03:42:12 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
-#include "dhctoken.h"
struct name_server *name_servers;
struct domain_search_list *domains;
void read_resolv_conf (parse_time)
TIME parse_time;
{
- FILE *cfile;
+ int file;
+ struct parse *cfile;
char *val;
int token;
int declaration = 0;
struct domain_search_list *dp, *dl, *nd;
struct iaddr *iaddr;
- new_parse (path_resolv_conf);
-
- eol_token = 1;
- if ((cfile = fopen (path_resolv_conf, "r")) == NULL) {
+ if ((file = open (path_resolv_conf, O_RDONLY)) == NULL) {
log_error ("Can't open %s: %m", path_resolv_conf);
return;
}
+ cfile = (struct parse *)0;
+ new_parse (&cfile, file, (char *)0, 0, path_resolv_conf);
+ cfile -> eol_token = 1;
+
do {
token = next_token (&val, cfile);
if (token == EOF)
nd = new_domain_search_list
("read_resolv_conf");
if (!nd)
- log_fatal ("No memory for %s", dn);
+ log_fatal ("No memory for %s",
+ dn);
nd -> next =
(struct domain_search_list *)0;
*dp = nd;
token = peek_token (&val, cfile);
} while (token != EOL);
if (token != EOL) {
- parse_warn ("junk after domain declaration");
+ parse_warn (cfile,
+ "junk after domain declaration");
skip_to_semi (cfile);
}
token = next_token (&val, cfile);
if (!ns) {
ns = new_name_server ("read_resolv_conf");
if (!ns)
- log_fatal ("No memory for nameserver %s",
+ log_fatal ("No memory for nameserver %s",
piaddr (iaddr));
ns -> next = (struct name_server *)0;
*sp = ns;
} else
dl = dp;
}
- eol_token = 0;
+ close (file);
+ end_parse (&cfile);
}
/* Pick a name server from the /etc/resolv.conf file. */