#!/usr/local/bin/perl
#
#  This program extracts some of the types defined 
#  in the OpenGL header files 
#

$x   = "X.h";
$gl  = "/usr/include/GL/gl.h";
$glx = "/usr/include/GL/glx.h";

%t=(
	'int'    , 'INT',
	'float'  , 'FLOAT',
	'double' , 'DOUBLE',
	'short'  , 'SHORT',
	'long'   , 'LONG',
	'char'   , 'CHAR',
	'XID'    , 'U_LONG',
);

sub gettypes {
	local($file)=@_;
	open(FILE,$file) || die "cant open $file\n";
	while(<FILE>) {
		if(/typedef/) {
			foreach $k (keys(%t)) {
				print "$1\t\tT_$t{$k}\n" if(/typedef\s+$k\s+(\w+)\s*\;/);
				print "$1\t\tT_$t{$k}\n" if(/typedef\s+signed\s+$k\s+(\w+)\s*\;/);
				print "$1\t\tT_U_$t{$k}\n" if(/typedef\s+unsigned\s+$k\s+(\w+)\s*\;/);
			}
		}
	}
	close(FILE);
}

gettypes($x);
gettypes($gl);
gettypes($glx);

