]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Adjust to New Parse Regime.
authorTed Lemon <source@isc.org>
Fri, 1 Oct 1999 03:42:12 +0000 (03:42 +0000)
committerTed Lemon <source@isc.org>
Fri, 1 Oct 1999 03:42:12 +0000 (03:42 +0000)
common/resolv.c

index 64de8a41013bd66616c8f8367b7a45a771d8ae51..2ee64c83cdb004748c95e259d02e8a8d73acf0ef 100644 (file)
 
 #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. */