dhilst

Perl script to generate basic prototypes..

Typedefs are not supported and you need to code your
functions with follow patter:
type
function_indetifier (list_of_parameters)
{ ... hereafter makes no difference

usage: cat souce.c | perl prot.pl > prots.txt
then copy and paste where you want...




# Create the prototypes for all functions
# on a given C source file
use strict;
use warnings;

my @ctypes = qw(
unsigned
signed
long
short
int
float
double
struct
char
static
const
);

my @contents = <>;

for my $line (0 .. $#contents) {
my $lref = \$contents[$line];
my $prot = '';
for (@ctypes) {
if ($$lref =~ /^$_/) {
my $func = $contents[++$line];
$func =~ s/\w*,/,/g;
$func =~ s/\w*\)/)/g;
$prot = "$$lref $func;";
$prot =~ s/\n//g;
print "$prot\n";
next;
}
}
}

test: http://ideone.com/5tE0F
note: I will coment that hash implementation soon..