blob: 19f584849cb8625872e776e2d1061dc19595e53e [file] [log] [blame]
fbrosson533407a2018-04-04 21:44:29 +00001#!/usr/bin/env perl
Bence Szépkúti468a76f2020-05-26 00:33:31 +02002#
3# Copyright (C) 2015, 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>;
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +010016
17my @consts;
18my $state = 'out';
19while (<>)
20{
Manuel Pégourié-Gonnardae738c22015-07-01 19:32:00 +020021 if( $state eq 'out' and /^(typedef )?enum \{/ ) {
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +010022 $state = 'in';
23 } elsif( $state eq 'out' and /^(typedef )?enum/ ) {
24 $state = 'start';
25 } elsif( $state eq 'start' and /{/ ) {
26 $state = 'in';
27 } elsif( $state eq 'in' and /}/ ) {
28 $state = 'out';
29 } elsif( $state eq 'in' ) {
30 s/=.*//; s!/\*.*!!; s/,.*//; s/\s+//g; chomp;
31 push @consts, $_ if $_;
32 }
33}
34
35open my $fh, '>', 'enum-consts' or die;
36print $fh "$_\n" for sort @consts;
37close $fh or die;
38
39printf "%8d enum-consts\n", scalar @consts;