Skip to content

Commit

Permalink
fix mkoidmap to gather multiline descriptions better
Browse files Browse the repository at this point in the history
  • Loading branch information
ollyg committed Aug 14, 2023
1 parent 4f0f864 commit 1cc1b4e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions EXTRAS/scripts/mkoidmap
Original file line number Diff line number Diff line change
Expand Up @@ -101,45 +101,52 @@ sub parse_mibs {

my @report = read_lines($out, 'latin-1');
my %details = ();
my $descr_on = 0;

LINEOUT: foreach my $line (@report) {
if ($line =~ m/^::=/) { # end of details
$oidmap{$details{oid}} ||= join ',',
($details{mib} .'::'. $details{leaf}),
map {$details{$_} || ''} (qw/type mode index status syntax descr/);
%details = ();
$descr_on = 0;
next LINEOUT;
}

if ($line =~ m/^\.\d/) { # oid
$details{oid} = $line;
$descr_on = 0;
next LINEOUT;
}

if ($line =~ m/^(\S+)\s/) { # leaf name
if ($line =~ m/^(\S+)\s/ and not $descr_on) { # leaf name
$details{leaf} = $1;
next LINEOUT;
}

if ($line =~ m/^\s+-- FROM\s+([-#\w]+)/) {
$details{mib} = $1;
$descr_on = 0;
next LINEOUT;
}

if ($line =~ m/^\s+MAX-ACCESS\s+([-\w]+)/) {
$details{mode} = $1;
$descr_on = 0;
next LINEOUT;
}

if ($line =~ m/^\s+INDEX\s+{([^}]+)}/) {
$details{index} = join ':',
map {s/\s+//g; $_}
split m/,/, $1;
$descr_on = 0;
next LINEOUT;
}

if ($line =~ m/^\s+STATUS\s+([-\w]+)/) {
$details{status} = $1;
$descr_on = 0;
next LINEOUT;
}

Expand All @@ -151,14 +158,16 @@ sub parse_mibs {
map {s/\s+//g; $_}
map {s/[{}]//g; $_}
split m/,/, $syntax;
$descr_on = 0;
next LINEOUT;
}

if ($line =~ m/^(?: DESCR| )/) {
if ($line =~ m/^\s+DESCRIPTION/ or $descr_on) {
$details{descr} .= join '',
map {s/\s+/ /g; $_}
map {s/"//g; $_}
map {s/^\s+DESCRIPTION\s+//; $_} ($line);
$descr_on = 1;
next LINEOUT;
}
}
Expand Down

0 comments on commit 1cc1b4e

Please sign in to comment.