#!/usr/bin/perl
#
# VarList [files]
#
# This script generates a list of the currently-implemented MIB variables. It
# must be run in a source directory that has the source files for the release
# that you want.
#
# The approach is to first read the mibtbl.t file, which contains a  list  of
# the  variables names plus the symbolic "magic" constants for each.  It then
# greps thru the v_*.c and *.C files  for  the  cases  that  reference  these
# constants.   The  successes  here produces a list of the variables that are
# actually implemented. Note that this doesn't mean that they work correctly.
#
# If there is no file list on the command, line, we use a default list.

$, = ' ';
$Hfile = "mibtbl.h";
$Tfile = "mibtbl.t";
$Cfiles = "@ARGV" || "v_*.[bc] *.C";

open(I,"<$Tfile")
	|| die "Can't read \"$Hfile\" [$!]\n";

for (<I>) {
#	if (/#define\s+([-_\w]*)\s+(\d+)\s+\/\*\s*([-_\w]*)\s*\*\//) # mibtbl.h
	if (/\{\&V(\w+), (X\w+),.*, R., v_/) {	# mibtbl.t
		$sym{$1} = $2;	# %sym translates variable to symbol.
#		$var{$2} = $1;	# %var translates symbol to variable.
	}
}
close(I);

$cases = `grep case $Cfiles`;	# List of all the case statements.

for $v (sort keys %sym) {
	$s = $sym{$v};
	if ($cases =~ "case $s:") {
		print "$v	is implemented.\n";
	} else {
		print "$v	not implemented.\n";
	}
}
