home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / unix / volume26 / hostcvt / patch03 < prev    next >
Encoding:
Text File  |  1993-07-09  |  2.7 KB  |  109 lines

  1. Newsgroups: comp.sources.unix
  2. From: rogers@amadeus.wr.tek.com (Roger S. Southwick)
  3. Subject: v26i293: hostcvt - convert /etc/hosts files into DNS zone files, Patch03
  4. Sender: unix-sources-moderator@gw.home.vix.com
  5. Approved: vixie@gw.home.vix.com
  6.  
  7. Submitted-By: rogers@amadeus.wr.tek.com (Roger S. Southwick)
  8. Posting-Number: Volume 26, Issue 293
  9. Archive-Name: hostcvt/patch03
  10.  
  11. This is Official patch #3 for the hostcvt program (v25i093).  This patch
  12. adds a -d flag which deletes (ignores) any duplicate IP addresses found
  13. in the input host file.
  14.  
  15. Feed this to the stdin of Larry Wall's fine patch program (I've tested with
  16. patch version 2.0.1.6 Patch level: 12) and enjoy the results.
  17.  
  18.     -Roger      (Roger.S.Southwick@tek.com)
  19.         UUCP:    ...!uunet!tektronix!Roger.S.Southwick
  20.  
  21. Index: main.c
  22. Prereq: 1.8
  23. 11c11
  24. < static char *RCSid = "$Id: main.c,v 1.8 92/03/24 17:46:28 rogers Release $";
  25. ---
  26. > static char *RCSid = "$Id: main.c,v 1.10 93/07/07 15:21:02 rogers Release $";
  27. 26a27
  28. >     char *h_ip;
  29. 63c64
  30. <     int domainflag, kflag, Sflag;
  31. ---
  32. >     int domainflag, kflag, Sflag, dflag;
  33. 66c67
  34. <     errflag = outputflag = domainflag = 0;
  35. ---
  36. >     errflag = outputflag = domainflag = dflag = 0;
  37. 70c71
  38. <     while ((ch = egetopt(argc, argv, "Skh:n:o:s:")) != -1)
  39. ---
  40. >     while ((ch = egetopt(argc, argv, "dSkh:n:o:s:")) != -1)
  41. 111a113,116
  42. >         case 'd':        /* Delete duplicate IP addresses */
  43. >         dflag++;
  44. >         break;
  45. 138c143
  46. <     (void) fprintf(stderr, "usage: hostcvt [-k] [-S] [-h hostsfile] [-n netlistfile]\n\t\t[-s soabasefile] [-o outputfile] domain\n");
  47. ---
  48. >     (void) fprintf(stderr, "usage: hostcvt [-d] [-k] [-S] [-h hostsfile] [-n netlistfile]\n\t\t[-s soabasefile] [-o outputfile] domain\n");
  49. 180a186,191
  50. >     if(dflag && dupip(ipaddr)){
  51. >         (void)fprintf(stderr, "hostcvt: duplicated IP address (%s) ignored\n", ipaddr);
  52. >         continue;
  53. >     }
  54. 206c217
  55. <         savehp(hp);
  56. ---
  57. >         savehp(hp, ipaddr);
  58. 228a240,261
  59. >  * Look thru our list of already known hosts by IP address,
  60. >  * and return TRUE if it's already known.
  61. >  */
  62. > int 
  63. > dupip(ipaddr)
  64. > char *ipaddr;
  65. > {
  66. >     register hn_tp hp;
  67. >     u_long ip;
  68. >     for(ip = inet_addr(ipaddr), hp = hntop; hp != NULL; hp = hp->h_next) {
  69. >     if(inet_addr(hp->h_ip) == ip){
  70. >         return(1);
  71. >     }
  72. >     }
  73. >     return(0);
  74. > }
  75. >     
  76. > /*
  77. 297c330
  78. < savehp(hp)
  79. ---
  80. > savehp(hp, ipaddr)
  81. 298a332
  82. > char *ipaddr;
  83. 310a345
  84. >     np->h_ip = strsave(ipaddr);
  85. Index: hostcvt.8
  86. Prereq: 1.5
  87. 2c2
  88. < .\" $Id: hostcvt.8,v 1.5 92/03/24 17:40:29 rogers Release $
  89. ---
  90. > .\" $Id: hostcvt.8,v 1.7 93/07/07 15:23:09 rogers Release $
  91. 4c4
  92. < .TH HOSTCVT 8 "03-24-92"
  93. ---
  94. > .TH HOSTCVT 8 "07-07-93"
  95. 13a14,15
  96. > .I -d
  97. > ] [
  98. 66a69,71
  99. > .TP
  100. > .BI \-d
  101. > Delete (ignore) any duplicated IP addresses in the input file.
  102.