blob: beac35f6d769ab39ab897b80310215c79a1381a1 [file] [log] [blame]
Harald Welte3bd59c92015-08-30 19:09:55 +02001#!/usr/bin/perl -w
2use 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
10my $l;
11my %h;
12
13while ($l = <STDIN>) {
14 chomp($l);
15 if ($l =~ /^(\S+)\s+(\S+)\s+::=\s+(\d+)/) {
16 $h{$2}{$3} = $1;
17 }
18}
19
20foreach my $k (keys %h) {
21 if ($k eq 'INTEGER') {
22 next;
23 }
24 printf("%s ::= INTEGER {\n", $k);
Harald Welte175cc0f2019-09-19 11:42:13 +020025 foreach my $r (sort { $a <=> $b } keys %{$h{$k}}) {
Harald Welte3bd59c92015-08-30 19:09:55 +020026 printf("\t%s(%d),\n", $h{$k}{$r}, $r);
27 }
28 printf("}\n");
29}