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 | f744bd7 | 2020-06-05 13:02:18 +0200 | [diff] [blame^] | 4 | # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
| 5 | # |
| 6 | # This file is provided under the Apache License 2.0, or the |
| 7 | # GNU General Public License v2.0 or later. |
| 8 | # |
| 9 | # ********** |
| 10 | # Apache License 2.0: |
Bence Szépkúti | 51b41d5 | 2020-05-26 01:54:15 +0200 | [diff] [blame] | 11 | # |
| 12 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 13 | # not use this file except in compliance with the License. |
| 14 | # You may obtain a copy of the License at |
| 15 | # |
| 16 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 17 | # |
| 18 | # Unless required by applicable law or agreed to in writing, software |
| 19 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 20 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 21 | # See the License for the specific language governing permissions and |
| 22 | # limitations under the License. |
Bence Szépkúti | 468a76f | 2020-05-26 00:33:31 +0200 | [diff] [blame] | 23 | # |
Bence Szépkúti | f744bd7 | 2020-06-05 13:02:18 +0200 | [diff] [blame^] | 24 | # ********** |
| 25 | # |
| 26 | # ********** |
| 27 | # GNU General Public License v2.0 or later: |
| 28 | # |
| 29 | # This program is free software; you can redistribute it and/or modify |
| 30 | # it under the terms of the GNU General Public License as published by |
| 31 | # the Free Software Foundation; either version 2 of the License, or |
| 32 | # (at your option) any later version. |
| 33 | # |
| 34 | # This program is distributed in the hope that it will be useful, |
| 35 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 36 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 37 | # GNU General Public License for more details. |
| 38 | # |
| 39 | # You should have received a copy of the GNU General Public License along |
| 40 | # with this program; if not, write to the Free Software Foundation, Inc., |
| 41 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 42 | # |
| 43 | # ********** |
| 44 | # |
Bence Szépkúti | 468a76f | 2020-05-26 00:33:31 +0200 | [diff] [blame] | 45 | # 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] | 46 | |
| 47 | use warnings; |
| 48 | use strict; |
| 49 | |
| 50 | use utf8; |
| 51 | use open qw(:std utf8); |
| 52 | |
Manuel Pégourié-Gonnard | d1ddd29 | 2015-04-09 10:15:10 +0200 | [diff] [blame] | 53 | -d 'include/mbedtls' or die "$0: must be run from root\n"; |
| 54 | |
Manuel Pégourié-Gonnard | e137ea6 | 2015-04-09 10:47:44 +0200 | [diff] [blame] | 55 | @ARGV = grep { ! /compat-1\.3\.h/ } <include/mbedtls/*.h>; |
Manuel Pégourié-Gonnard | 3385cf4 | 2015-04-02 17:59:30 +0100 | [diff] [blame] | 56 | |
| 57 | my @consts; |
| 58 | my $state = 'out'; |
| 59 | while (<>) |
| 60 | { |
Manuel Pégourié-Gonnard | ae738c2 | 2015-07-01 19:32:00 +0200 | [diff] [blame] | 61 | if( $state eq 'out' and /^(typedef )?enum \{/ ) { |
Manuel Pégourié-Gonnard | 3385cf4 | 2015-04-02 17:59:30 +0100 | [diff] [blame] | 62 | $state = 'in'; |
| 63 | } elsif( $state eq 'out' and /^(typedef )?enum/ ) { |
| 64 | $state = 'start'; |
| 65 | } elsif( $state eq 'start' and /{/ ) { |
| 66 | $state = 'in'; |
| 67 | } elsif( $state eq 'in' and /}/ ) { |
| 68 | $state = 'out'; |
| 69 | } elsif( $state eq 'in' ) { |
| 70 | s/=.*//; s!/\*.*!!; s/,.*//; s/\s+//g; chomp; |
| 71 | push @consts, $_ if $_; |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | open my $fh, '>', 'enum-consts' or die; |
| 76 | print $fh "$_\n" for sort @consts; |
| 77 | close $fh or die; |
| 78 | |
| 79 | printf "%8d enum-consts\n", scalar @consts; |