fbrosson | 533407a | 2018-04-04 21:44:29 +0000 | [diff] [blame] | 1 | #!/usr/bin/env perl |
Bence Szépkúti | 468a76f | 2020-05-26 00:33:31 +0200 | [diff] [blame] | 2 | # |
| 3 | # Copyright (C) 2015, Arm Limited, All Rights Reserved |
Bence Szépkúti | 51b41d5 | 2020-05-26 01:54:15 +0200 | [diff] [blame^] | 4 | # SPDX-License-Identifier: Apache-2.0 |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 7 | # not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
Bence Szépkúti | 468a76f | 2020-05-26 00:33:31 +0200 | [diff] [blame] | 17 | # |
| 18 | # This file is part of Mbed TLS (https://tls.mbed.org) |
Manuel Pégourié-Gonnard | 3385cf4 | 2015-04-02 17:59:30 +0100 | [diff] [blame] | 19 | |
| 20 | use warnings; |
| 21 | use strict; |
| 22 | |
| 23 | use utf8; |
| 24 | use open qw(:std utf8); |
| 25 | |
Manuel Pégourié-Gonnard | d1ddd29 | 2015-04-09 10:15:10 +0200 | [diff] [blame] | 26 | -d 'include/mbedtls' or die "$0: must be run from root\n"; |
| 27 | |
Manuel Pégourié-Gonnard | e137ea6 | 2015-04-09 10:47:44 +0200 | [diff] [blame] | 28 | @ARGV = grep { ! /compat-1\.3\.h/ } <include/mbedtls/*.h>; |
Manuel Pégourié-Gonnard | 3385cf4 | 2015-04-02 17:59:30 +0100 | [diff] [blame] | 29 | |
| 30 | my @consts; |
| 31 | my $state = 'out'; |
| 32 | while (<>) |
| 33 | { |
Manuel Pégourié-Gonnard | ae738c2 | 2015-07-01 19:32:00 +0200 | [diff] [blame] | 34 | if( $state eq 'out' and /^(typedef )?enum \{/ ) { |
Manuel Pégourié-Gonnard | 3385cf4 | 2015-04-02 17:59:30 +0100 | [diff] [blame] | 35 | $state = 'in'; |
| 36 | } elsif( $state eq 'out' and /^(typedef )?enum/ ) { |
| 37 | $state = 'start'; |
| 38 | } elsif( $state eq 'start' and /{/ ) { |
| 39 | $state = 'in'; |
| 40 | } elsif( $state eq 'in' and /}/ ) { |
| 41 | $state = 'out'; |
| 42 | } elsif( $state eq 'in' ) { |
| 43 | s/=.*//; s!/\*.*!!; s/,.*//; s/\s+//g; chomp; |
| 44 | push @consts, $_ if $_; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | open my $fh, '>', 'enum-consts' or die; |
| 49 | print $fh "$_\n" for sort @consts; |
| 50 | close $fh or die; |
| 51 | |
| 52 | printf "%8d enum-consts\n", scalar @consts; |