From: Ted Lemon Date: Fri, 1 Oct 1999 03:42:12 +0000 (+0000) Subject: Adjust to New Parse Regime. X-Git-Tag: V3-BETA-1-PATCH-2~5^2~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b4f8a4a12cd425dfcde28ec846e20237b0e7955;p=thirdparty%2Fdhcp.git Adjust to New Parse Regime. --- diff --git a/common/resolv.c b/common/resolv.c index 64de8a410..2ee64c83c 100644 --- a/common/resolv.c +++ b/common/resolv.c @@ -22,11 +22,10 @@ #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; @@ -35,7 +34,8 @@ char path_resolv_conf [] = _PATH_RESOLV_CONF; void read_resolv_conf (parse_time) TIME parse_time; { - FILE *cfile; + int file; + struct parse *cfile; char *val; int token; int declaration = 0; @@ -43,14 +43,15 @@ void read_resolv_conf (parse_time) 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) @@ -76,7 +77,8 @@ void read_resolv_conf (parse_time) 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; @@ -87,7 +89,8 @@ void read_resolv_conf (parse_time) 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); @@ -107,7 +110,7 @@ void read_resolv_conf (parse_time) 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; @@ -158,7 +161,8 @@ void read_resolv_conf (parse_time) } else dl = dp; } - eol_token = 0; + close (file); + end_parse (&cfile); } /* Pick a name server from the /etc/resolv.conf file. */