#!/usr/local/bin/perl # Extracts global-function prototypes. # It strongly depends on my coding style.. $st = 0; while (<>) { if ($st == 2 && /^\s*\{\s*$/) { printf "%s %s;\n", $w1, $w2; $st = 0; } elsif ($st == 1 && /^\s*(\w+\(.*\))\s*$/) { $w2 = "$1"; $st = 2; } elsif (/(static|inline)/) { # printf "match: '%s'\n", $1; $st = 0; } elsif (/^\s*(\w+(\s+[\w\(\)\[\]\*]+)*)\s*\n/) { # printf "match: '%s' '%s'\n", $1, $2; $w1 = "$1"; $st = 1; } else { $st = 0; } }