]> nuage.metani.fr Git - 3GPP.git/blob - bin/asn1-split.awk
Add strip-unaffected to remove unaffected IEs
[3GPP.git] / bin / asn1-split.awk
1 #!/bin/awk -f
2
3 BEGIN {
4 # A record is an IE heading
5 RS = "-- =+\n-- IE: [A-Z][A-Za-z0-9-]+"
6
7 # A field is a line
8 FS = "\n"
9
10 # Usage explanation
11 if (ARGC != "2") {
12 print "Usage: " ARGV[0] " file.asn"
13 print "Splits file.asn generated by txt2asn into one file per module"
14 exit
15 }
16 file_prefix = ARGV[1]
17 gsub(/.asn$/, "", file_prefix)
18
19 outfile = ""
20 heading = ""
21 }
22 {
23 # Search for the start of a module definition in every field (= line) of the IE
24 for (i = 1; i <= NF; i++) {
25 if ($i ~ /[[A-Z][A-Za-z0-9-]+ DEFINITIONS AUTOMATIC TAGS ::=/) {
26 split($i, module_name, " ")
27 outfile = file_prefix "-" module_name[1] ".asn"
28 }
29 }
30
31 # See below about heading
32 if (outfile != "") {
33 print heading $0 > outfile
34 }
35
36 # RT is the record terminator i.e., the string that matched RS
37 # It actually is the heading of the next record, so store it
38 # to be printed with the next record.
39
40 heading = RT
41 }
42