blob: d60a0fb169d6ece1cb74aed858139516acf326b2 [file] [log] [blame]
fbrosson533407a2018-04-04 21:44:29 +00001#!/usr/bin/env perl
Bence Szépkúti700ee442020-05-26 00:33:31 +02002#
3# Copyright (C) 2015-2019, Arm Limited, All Rights Reserved
4#
5# This file is part of Mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +01006
7use warnings;
8use strict;
9
10use utf8;
11use open qw(:std utf8);
12
Manuel Pégourié-Gonnardd1ddd292015-04-09 10:15:10 +020013-d 'include/mbedtls' or die "$0: must be run from root\n";
14
Manuel Pégourié-Gonnarde137ea62015-04-09 10:47:44 +020015@ARGV = grep { ! /compat-1\.3\.h/ } <include/mbedtls/*.h>;
Christoph M. Wintersteiger8a0f5bb2018-12-14 15:46:34 +000016push @ARGV, "3rdparty/everest/include/everest/everest.h";
17push @ARGV, "3rdparty/everest/include/everest/x25519.h";
18
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +010019
20my @consts;
21my $state = 'out';
22while (<>)
23{
Manuel Pégourié-Gonnardae738c22015-07-01 19:32:00 +020024 if( $state eq 'out' and /^(typedef )?enum \{/ ) {
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +010025 $state = 'in';
26 } elsif( $state eq 'out' and /^(typedef )?enum/ ) {
27 $state = 'start';
28 } elsif( $state eq 'start' and /{/ ) {
29 $state = 'in';
30 } elsif( $state eq 'in' and /}/ ) {
31 $state = 'out';
Christoph M. Wintersteiger7cc4c682018-12-14 13:18:52 +000032 } elsif( $state eq 'in' and not /^#/) {
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +010033 s/=.*//; s!/\*.*!!; s/,.*//; s/\s+//g; chomp;
34 push @consts, $_ if $_;
35 }
36}
37
38open my $fh, '>', 'enum-consts' or die;
39print $fh "$_\n" for sort @consts;
40close $fh or die;
41
42printf "%8d enum-consts\n", scalar @consts;