#! /usr/bin/perl

# this script generats a header-file from `mm/slab.c'

if (! -e $ARGV[0]) {
	print STDERR "\n  NO SUCH FILE: ", $ARGV[0], "\n";
	print STDERR "  YOU NEED KERNEL SOURCE !!!\n\n";
	print "#define NO_SUCH_FILE // ", $ARGV[0], "\n";
	exit(0);
}

while (<>) {
	if (/^#include/ || /^(int|long|unsigned|static int)\s.*\s=\s/ || /^struct .*];$/) {
		print "// $_";
		next;
	}
	if (/^#ifdef\s+__KERNEL__$/) {
		print "#if 1 /*__KERNEL__*/\n";
		next;
	}
	if (/^static [_a-z].*\(.*\)$/) {
		$sv = $_;
		$_ = <>;
		last unless (/^{$/);
		print "// $sv";
		while (<>) {
			last if (/^}/);
		}
		next;
	}
	last if (/\s+=\s+{/ || /\b__initdata\b/ || /^struct\s.*=\s{$/ || /^static\s+.*\[.+\];$|^[a-z].*\)$/);
	print $_;
}

printf "\n\n/* CUT CUT CUT */\n";
