X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/49cdcf9f86b74f6d37466cb3f366988d9f98599e..2d474861a3772dcb9bdbf7d013e5e53c0d5b2821:/usr/src/old/htable/htable.c diff --git a/usr/src/old/htable/htable.c b/usr/src/old/htable/htable.c index b43360ac11..02974e9867 100644 --- a/usr/src/old/htable/htable.c +++ b/usr/src/old/htable/htable.c @@ -1,6 +1,18 @@ +/* + * Copyright (c) 1983 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +char copyright[] = +"@(#) Copyright (c) 1983 Regents of the University of California.\n\ + All rights reserved.\n"; +#endif not lint + #ifndef lint -static char sccsid[] = "@(#)htable.c 4.10 (Berkeley) %G%"; -#endif +static char sccsid[] = "@(#)htable.c 5.5 (Berkeley) %G%"; +#endif not lint /* * htable - convert NIC host table into a UNIX format. @@ -160,6 +172,8 @@ lower(str) while (*cp) { if (isupper(*cp)) *cp = tolower(*cp); + if (*cp == '.') + break; cp++; } return (str); @@ -333,6 +347,7 @@ copygateways(f, filename) char dname[80]; char gname[80]; char junk[80]; + char buf[500]; u_long addr; int net, metric; extern int errno; @@ -347,24 +362,23 @@ copygateways(f, filename) return; } /* format: {net | host} XX gateway XX metric DD [passive]\n */ -#define readentry(fp) \ - fscanf((fp), "%s %s gateway %s metric %d %s\n", \ - type, dname, gname, &metric, junk) for (;;) { junk[0] = 0; - if (readentry(lhf) == EOF) + if (fgets(buf, sizeof(buf), lhf) == (char *)NULL) break; + fputs(buf, gf); + if (buf[0] == '#' || + sscanf(buf, "%s %s gateway %s metric %d %s", + type, dname, gname, &metric, junk) < 5) + continue; if (strcmp(type, "net")) - goto dumpit; + continue; if (!getnetaddr(dname, &net)) - goto dumpit; + continue; if (!gethostaddr(gname, &addr)) - goto dumpit; + continue; nl = newname(gname); (void) savegateway(nl, net, addr, metric); -dumpit: - fprintf(gf, "%s %s gateway %s metric %d %s\n", - type, dname, gname, metric, junk); } fclose(lhf); } @@ -511,6 +525,7 @@ savegateway(namelist, net, addr, metric) gp->g_metric = metric; if (metric == 1) gp->g_dst = gp; + return (gp); } connectedto(net)