From f2505177108d592877fa4e19e49efcc58a477c39 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Mon, 11 Feb 2008 15:50:18 +0100 Subject: [PATCH] Added a simple utility for generating the DNS zone with ID's. --- maint/gen-zone | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 maint/gen-zone diff --git a/maint/gen-zone b/maint/gen-zone new file mode 100755 index 0000000..57d7982 --- /dev/null +++ b/maint/gen-zone @@ -0,0 +1,52 @@ +#!/usr/bin/perl -w +# Create a DNS zone with PCI ID records + +use strict; + +my %ids = (); +my %comments = (); +foreach our $file (@ARGV) { + my $fn = ($file =~ /\.gz$/) ? "zcat $file |" : ($file =~ /\.bz2$/) ? "bzcat $file |" : $file; + open F, $fn or die "Unable to open $file: $!"; + my @id = (); + my $comm = ""; + sub err($) { + print STDERR "Error in $file, line $.: @_\n"; + exit 1; + } + while () { + if (/^(#.*)/) { + $comm .= $_; + next; + } + chomp; + if (my ($indent, $id, $ignored, $name) = /^(\t*)(([0-9a-fA-Z]+ ?)*)(( |\t|$)\s*(.*))$/) { + my $depth = length $indent; + $depth <= @id or err "Mismatched indentation"; + @id = (@id[0..$depth-1], $id); + my $i = join(":", @id); + if ($i ne "") { + !exists $ids{$i} or die "ID $i defined twice"; + $ids{$i} = $name; + $comments{$i} = $comm if $comm; + } + } elsif (!/^$/) { + err "Parse error"; + } + $comm = ""; + } + close F; +} + +sub esc($) { + my ($x) = @_; + $x =~ s/^\s+//; + $x =~ s/"/\\"/g; + return $x; +} + +foreach my $i (keys %ids) { + my $j = join(".", reverse split(/[: ]/, $i)); + print "$j\tTXT \"i=", esc($ids{$i}), "\"\n"; + # print "$j\tTXT \"c=", esc($comments{$i}), "\"\n" +} -- 2.39.2