#!/usr/local/bin/perl

open(STDOUT, ">index.tex");

print '\magnification 1200',"\n";
print '\baselineskip 18 true pt',"\n";
print '\vsize 8.9 true in',"\n";
print '\hsize=6.9 true in',"\n";
print "\n";
print '\settabs 12 \columns',"\n";
print "\n";

foreach $file (@ARGV) {
   open(FILES,"$file");
   if ($file =~ /[^(\.h|\.c)\n]$/) {
#	print 'not a .h or .c ',"$file\n";
        next;
   }
   print '\noindent',"\n";
   $file =~ s/_/\\_/g;
   print '{\bf ',$file,':}\hfil\break',"\n";
   while(<FILES>) {
	if (/^void/ || /^double/ || /^char/ || /^int/ || /^real/ || /^FILE/
		    || /^integral/ || /^node/ || /^list/ || /^element/ 
		    || /^rational/ || /^molecules/ || /^fcomplex/ 
		    || /^vector/ || /^float/ ) 
	{
	   chop;
#       	FOR FUNCTIONS THAT END UP IN {
	   if ($_ =~ /\{$/) { chop };
#		FOR FUNCTIONS THAT SPAN MORE THAN ONE LINE
	   if ($_ =~ /[^\)]\s*$/) {
		$abb = ' } \cr \+ && {\it ';
		$abc = <FILES>;
		$_ .= $abb;
		$_ .= $abc;
		chop;
	   	if ($_ =~ /\{$/) { chop };
	   }
#	      TEX HAS THE _ AS KEYWORD
	      $_ =~ s/_/\\_/g;
	      print '\+ & {\it ',$_,' } \cr',"\n" if ($_ =~ /[^;]$/);
#	      print $_,"\n" if ($_ =~ /^[^void]/);
	}
   }
   print '\bigskip',"\n";
   print "\n";
   close(FILES);
}
print "\n";
print '\vfil',"\n";
print '\eject',"\n";
print '\bye',"\n";

close(STDOUT);