Harald Welte | 3bd59c9 | 2015-08-30 19:09:55 +0200 | [diff] [blame] | 1 | #!/usr/bin/perl -w |
| 2 | use strict; |
| 3 | |
| 4 | # small script to extract the constants from |
| 5 | # {HNBAP,RUA,RANAP}-Constants.asn and print them in an ASN.1 format that |
| 6 | # will trigger asn1c to generate associated enums in C. |
| 7 | # |
| 8 | # Usage: ./asn1enum.pl < HNBAP-Constants.asn |
| 9 | |
| 10 | my $l; |
| 11 | my %h; |
| 12 | |
| 13 | while ($l = <STDIN>) { |
| 14 | chomp($l); |
| 15 | if ($l =~ /^(\S+)\s+(\S+)\s+::=\s+(\d+)/) { |
| 16 | $h{$2}{$3} = $1; |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | foreach my $k (keys %h) { |
| 21 | if ($k eq 'INTEGER') { |
| 22 | next; |
| 23 | } |
| 24 | printf("%s ::= INTEGER {\n", $k); |
| 25 | foreach my $r (sort { $a <=> $b } keys $h{$k}) { |
| 26 | printf("\t%s(%d),\n", $h{$k}{$r}, $r); |
| 27 | } |
| 28 | printf("}\n"); |
| 29 | } |