blob: 8584e8419419328cc7699e81d227b6ae6861f4aa [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);
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}