#!/usr/bin/perl

# =======================================================================
# translate MIB into label/oid pairs
# Copyright (C) 2001  Thomas Aeby
# All Rights Reserved
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
# 
# =======================================================================
# 
# Author: Thomas Aeby
# E-Mail: aeby@graeff.com
# 
# =======================================================================
# 
# @(#) $Id: mibcompile.pl,v 1.1 2001/11/12 19:42:02 aeby Exp $
# 
# Revision History:
# 
# $Log: mibcompile.pl,v $
# Revision 1.1  2001/11/12 19:42:02  aeby
# mibcompile uses "snmptranslate" to compile a mib into etc/mibs.txt format
#
#  
# =======================================================================


my @snmptranslate = ("snmptranslate");

foreach my $mib (@ARGV) {
    push( @snmptranslate, "-m", $mib );
}

push( @snmptranslate, "-Tos" );
unless( open( SNMP, "-|" ) ) {
    exec( @snmptranslate );
    print STDERR "snmptranslate command is unavailable\n";
    exit(1);
}

my $oid;
my $label;
while( <SNMP> ) {
    chomp( $oid = $_ );
    chomp( $label = <SNMP> );
    $oid =~ s/^\.//;
    $label =~ s/^.*\.//;
    print "$label\t$oid\n";
}
