blob: 4e0baec50186e16eb7bd09d519f8d5c39445260f [file] [log] [blame]
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +01001#!/usr/bin/perl
2
3use warnings;
4use strict;
5
6use utf8;
7use open qw(:std utf8);
8
9@ARGV = <include/mbedtls/*.h>;
10
11my @consts;
12my $state = 'out';
13while (<>)
14{
15 if( $state eq 'out' and /^(typedef )?enum {/ ) {
16 $state = 'in';
17 } elsif( $state eq 'out' and /^(typedef )?enum/ ) {
18 $state = 'start';
19 } elsif( $state eq 'start' and /{/ ) {
20 $state = 'in';
21 } elsif( $state eq 'in' and /}/ ) {
22 $state = 'out';
23 } elsif( $state eq 'in' ) {
24 s/=.*//; s!/\*.*!!; s/,.*//; s/\s+//g; chomp;
25 push @consts, $_ if $_;
26 }
27}
28
29open my $fh, '>', 'enum-consts' or die;
30print $fh "$_\n" for sort @consts;
31close $fh or die;
32
33printf "%8d enum-consts\n", scalar @consts;