blob: e59517b886e9876fa4e03e836cb7886204a4847a [file] [log] [blame]
fbrosson533407a2018-04-04 21:44:29 +00001#!/usr/bin/env perl
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +01002
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>;
Christoph M. Wintersteiger8a0f5bb2018-12-14 15:46:34 +000012push @ARGV, "3rdparty/everest/include/everest/everest.h";
13push @ARGV, "3rdparty/everest/include/everest/x25519.h";
14
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +010015
16my @consts;
17my $state = 'out';
18while (<>)
19{
Manuel Pégourié-Gonnardae738c22015-07-01 19:32:00 +020020 if( $state eq 'out' and /^(typedef )?enum \{/ ) {
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +010021 $state = 'in';
22 } elsif( $state eq 'out' and /^(typedef )?enum/ ) {
23 $state = 'start';
24 } elsif( $state eq 'start' and /{/ ) {
25 $state = 'in';
26 } elsif( $state eq 'in' and /}/ ) {
27 $state = 'out';
Christoph M. Wintersteiger7cc4c682018-12-14 13:18:52 +000028 } elsif( $state eq 'in' and not /^#/) {
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +010029 s/=.*//; s!/\*.*!!; s/,.*//; s/\s+//g; chomp;
30 push @consts, $_ if $_;
31 }
32}
33
34open my $fh, '>', 'enum-consts' or die;
35print $fh "$_\n" for sort @consts;
36close $fh or die;
37
38printf "%8d enum-consts\n", scalar @consts;