blob: 57b91de89fb549623464e153d09af1ed3df29b9d [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
Bence Szépkúti51b41d52020-05-26 01:54:15 +02004# 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úti468a76f2020-05-26 00:33:31 +020017#
18# This file is part of Mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +010019
20use warnings;
21use strict;
22
23use utf8;
24use open qw(:std utf8);
25
Manuel Pégourié-Gonnardd1ddd292015-04-09 10:15:10 +020026-d 'include/mbedtls' or die "$0: must be run from root\n";
27
Manuel Pégourié-Gonnarde137ea62015-04-09 10:47:44 +020028@ARGV = grep { ! /compat-1\.3\.h/ } <include/mbedtls/*.h>;
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +010029
30my @consts;
31my $state = 'out';
32while (<>)
33{
Manuel Pégourié-Gonnardae738c22015-07-01 19:32:00 +020034 if( $state eq 'out' and /^(typedef )?enum \{/ ) {
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +010035 $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
48open my $fh, '>', 'enum-consts' or die;
49print $fh "$_\n" for sort @consts;
50close $fh or die;
51
52printf "%8d enum-consts\n", scalar @consts;