blob: c8e26366cd9369c863bba75d4aa3d908fcac945c [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
Manuel Pégourié-Gonnardd1ddd292015-04-09 10:15:10 +02009-d 'include/mbedtls' or die "$0: must be run from root\n";
10
Manuel Pégourié-Gonnarde137ea62015-04-09 10:47:44 +020011@ARGV = grep { ! /compat-1\.3\.h/ } <include/mbedtls/*.h>;
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +010012
13my @consts;
14my $state = 'out';
15while (<>)
16{
17 if( $state eq 'out' and /^(typedef )?enum {/ ) {
18 $state = 'in';
19 } elsif( $state eq 'out' and /^(typedef )?enum/ ) {
20 $state = 'start';
21 } elsif( $state eq 'start' and /{/ ) {
22 $state = 'in';
23 } elsif( $state eq 'in' and /}/ ) {
24 $state = 'out';
25 } elsif( $state eq 'in' ) {
26 s/=.*//; s!/\*.*!!; s/,.*//; s/\s+//g; chomp;
27 push @consts, $_ if $_;
28 }
29}
30
31open my $fh, '>', 'enum-consts' or die;
32print $fh "$_\n" for sort @consts;
33close $fh or die;
34
35printf "%8d enum-consts\n", scalar @consts;