5 # Information about each ASN.1 line, indexed by number
7 # text: the complete line
8 # field: the field, without suffix (if there is one)
9 # structure: the outer structure (if it is a field)
10 # condition: the condition, if there is one
12 # Information about each field description, indexed by outer structure and field name (when a description is for a coma-separated list of fields, a separate entry is created for each field).
14 # field_description_len: how many descriptions lines (0 means none)
15 # field_description: the lines of a field descritpion, indexed from 1
20 if (!
(1 in text
)) { return ; }
21 #print "entering asn1_print";
22 for (line=
1; line
<=line_number
; line
++) {
23 #if (field[line] != "") {
24 # print "Ligne " line " champs " field[line] ;
25 # print "Structure " structure[line] ;
26 # print "Description de longueur " field_description_len[structure[line]][field[line]];
28 if (((field
[line
] != "") &&
29 (field_description_len
[structure
[line
]][field
[line
]] > 0)) ||
30 ((condition
[line
] != "") &&
31 (condition_description_len
[condition
[line
]] > 0))) {
34 position =
index(text
[line
], field
[line
]) - 1;
36 #print "ligne " line " position " position " field " field[line] " structure " structure[line];
38 for (i=
0;i
<position
;i
++) {
39 indentation = indentation
" ";
42 #print "Il y a " field_description_len[structure[line]][field[line]] " ligne(s)";
46 if (field_description_len
[structure
[line
]][field
[line
]] > 0) {
47 for (i=
1;i
<=field_description_len
[structure
[line
]][field
[line
]]; i
++) {
49 print indentation
"-- " field_description
[structure
[line
]][field
[line
]][i
];
54 if (condition_description_len
[condition
[line
]] > 0) {
57 for(i=
1;i
<=condition_description_len
[condition
[line
]];i
++) {
58 gsub(/(, )*[Nn
]eed
[MNSR
],*/, "", condition_description
[condition
[line
]][i
]);
59 print indentation
"--" condition_description
[condition
[line
]][i
];
64 if (condition_code
[condition
[line
]] ==
"")
65 { sub(/-- Cond
[A
-Za
-z0
-9_
-]+/, "", text
[line
]); }
67 { sub(/-- Cond
[A
-Za
-z0
-9_
-]+/, "-- Need " condition_code
[condition
[line
]], text
[line
]); }
76 if (text
[line
] ~
/-- Cond
[A
-Za
-z0
-9_
-]+/)
79 if (condition_code
[condition
[line
]] ==
"")
80 { sub(/-- Cond
[A
-Za
-z0
-9_
-]+/, "", text
[line
]); }
83 #print "Ligne " text[condition_reference[line]];
85 sub(/-- Cond
[A
-Za
-z0
-9_
-]+/, "-- Need " condition_code
[condition
[line
]], text
[line
]); }
87 #if((line>0) || (text[line] ~ /[a-zA-Z0-9-]/)) {
98 delete field_description_len
;
99 delete field_description
;
100 delete condition_description_len
;
101 delete condition_description
;
102 delete condition_code
;
103 delete condition_reference
;
105 #print "end of asn1_print"
108 function need_code
(aaa
)
110 if (aaa ~
/[Nn
]eed M
[ ,.
]/) { return "M" }
111 if (aaa ~
/[Nn
]eed N
[ ,.
]/) { return "N" }
112 if (aaa ~
/[Nn
]eed R
[ ,.
]/) { return "R" }
113 if (aaa ~
/[Nn
]eed S
[ ,.
]/) { return "S" }
121 return gsub(/{/, "", local_bbb1
) - gsub(/}/, "", local_bbb2
)
125 add_line_after
!= "" ;
128 wide_separator =
"" ;
129 for(i=
0;i
<=
140;i
++) {
130 wide_separator = wide_separator
"-" ;
133 ie_separator =
"-- " ;
134 for (i=
0;i
<=
137;i
++) {
135 ie_separator = ie_separator
"=" ;
140 /^
[0-9]+(\.
[0-9]+)*\t/ {
141 if (in_IE ==
"yes") { asn1_print
(); }
145 /^
[A
-Za
-z0
-9-]+ message$
/ {
146 # No need to print this
150 /^
[A
-Za
-z0
-9-]+ information element$
/ {
151 # No need to print this
165 direct_print =
"no" ;
175 if (next_line ==
"condition") {
178 if ((next_line ==
"field description") || (next_line ==
"field name")){
182 if (next_line
!= "field description") {
185 # #if (empty_line == "yes") {
189 current_condition =
"" ;
190 if (empty_line ==
"yes") { next; }
194 #print "empty_line set to yes" ;
200 # The empty_line condition is meant for what is directly printed, i.e. messages decriptions
201 # ASN.1, field descriptions and conditions descriptions are not directly printed, so
202 # this should not apply to them
206 #if ((next_line == "field description") || (next_line == "field name")){
208 #print "empty_line set to no"
213 /^
-[[:space
:]]+ParentIE
-WithEM$
/ {
217 /^
-[[:space
:]]+[A
-Za
-z0
-9-]+$
/ {
220 # if (empty_line == "yes") {
229 #if (IE_name == "PosSI-SchedulingInfo") { print "IE trouvé" ; }
236 /^
-[[:space
:]]+Multiplicity and type constraints? definitions?$
/ {
239 if (in_IE ==
"yes") {
245 # In this case, directly print ASN.1 without processing
246 direct_print =
"yes" ;
249 print "-- IE: Constants";
257 /^
-[[:space
:]]+End of
[A
-Za
-z0
-9-]+$
/ {
258 if (in_IE ==
"yes") {
266 /^
NR-InterNodeDefinitions
/ {
269 print "-- IE: NR-InterNodeDefinitions";
277 direct_print =
"yes" ;
281 /^Conditional
[Pp
]resence
/ {
285 $0 =
"Conditional presence" ;
286 for(i=
0;i
<=
140;i
++) {
287 separator = separator
"-" ;
290 #add_line_after = separator ;
291 next_line =
"condition" ;
292 #print "Conditional Presence"
293 #if (IE_name == "PosSI-SchedulingInfo") { print "condition trouvée" ; }
296 # Need to catch "x and y field descriptions"
298 /field descriptions$
/ {
302 for(i=
0;i
<=
140;i
++) {
303 separator = separator
"-" ;
306 # add_line_after = separator ;
307 next_line =
"field name" ;
311 #print "Trouvé description des champs de " $1;
316 #/^[A-Za-z0-9-]+[[:space:]]+[A-Za-z0-9-]+/ {
317 # if (next_line == "field description") {
318 # add_line_after = separator ;
319 # next_line = "field name";
323 # This is matched for any non-empty line
327 if ((in_IE ==
"yes") && (in_ASN1 ==
"no")){
329 # if we are coming from a "IE X field description" statement
330 # or we were in a field description
331 if ((next_line ==
"field name") || (next_line ==
"field description")) {
334 # If the whole line is a coma-separated list in an IE (=> field names)
335 if (/^
[A
-Za
-z0
-9-]+(, [A
-Za
-z0
-9-]+)*$
/) {
336 # Then, this is a new field, or list of fields
341 # remove leading/trailing spaces
342 sub(/^
[[:space
:]]+/, "", names
);
343 sub(/[[:space
:]]+$
/, "", names
);
345 # remove comas and duplicate spaces
346 gsub(/,/, "", names
);
347 gsub(/[[:space
:]]+/, " ", names
);
349 #print "coucou " names;
353 # this will delete any previous field_list
354 ret =
split(names
, field_list
, " ");
357 #print "split returned " ret ;
358 #for (abc in field_list)
359 #{ print "field_list contient " field_list[abc];}
363 #add_line_after = " ";
365 # Add one entry for each of the fields
366 for (ii in field_list
) {
367 num = field_description_len
[field_struct
][field_list
[ii
]] =
0;
368 #print "Trouvé description de " field_list[ii];
371 if (next_line ==
"field name") {
372 next_line =
"field description";
375 else { next_line =
"field name" ; }
380 # This is a field description
382 #if (index($0,"BAP")!=0) {
383 #print "BAP trouvé" $0 ;
385 #print "contenu " $0;
387 if ((next_line ==
"field name") || (next_line ==
"field description")) {
388 for (ii in field_list
) {
389 field_description_len
[field_struct
][field_list
[ii
]]++;
390 num = field_description_len
[field_struct
][field_list
[ii
]];
391 field_description
[field_struct
][field_list
[ii
]][num
] =
$0;
392 #print "ajouté une ligne pour " field_list[ii] "dans " field_struct;
400 else if ((in_ASN1 ==
"yes") && (direct_print ==
"yes")) {
408 # sub(/-[vr][0-9]+$/, "", $1);
410 # current_structure = $1 ;
416 if (in_IE ==
"yes") {
418 #print "$0 est " $0 " in_ASN1 est " in_ASN1;
419 if (next_line ==
"condition") {
420 #print "branche condition " $0;
421 if ($1 != "Conditional") {
422 if (index(conditions
, $1) != 0) {
423 current_condition =
$1 ;
424 condition_description_len
[current_condition
] =
1 ;
426 condition_description
[current_condition
][1] =
$0 ;
427 condition_code
[current_condition
] = need_code
($0);
430 #print "-- Condition: " $1;
432 #print "Condition " current_condition " trouvée";
436 #if ((in_ASN1 == "no") && !(/^\s*$/)) {
440 # prints first line of condition
445 #print "La description est " $0;
446 condition_description_len
[current_condition
]++;
447 condition_description
[current_condition
][condition_description_len
[current_condition
]] =
$0 ;
448 condition_code
[current_condition
] = need_code
($0);
454 #print "in_ASN1 est " in_ASN1 " ligne " $0;
455 if ((in_ASN1 ==
"no") && !
(/^\s
*$
/)) {
460 if (in_ASN1 ==
"no") {
462 # prints subsequent lines of condition or IE description
463 if ((!
(/\S
/) && (empty_line ==
"yes"))) {next}
469 if((line_number==
0) && (/^
[[:space
:]]*$
/)) { next ; }
471 text
[line_number
] =
$0;
473 if (/Multiplicity
/) {
477 #print "text[" line_number "] est " text[line_number];
478 if (/^
[A
-Za
-z0
-9-]+[[:space
:]]+:/) {
480 sub(/-[vr
][0-9]+(-IEs
)*$
/, "", $1);
482 current_structure =
$1 ;
483 text_level
[line_number
] = level
(text
[line_number
]);
489 if (/[[:space
:]]+[a
-z
][A
-Za
-z0
-9-]*/) {
490 text_level
[line_number
] = text_level
[line_number
-1] + level
(text
[line_number
]) ;
493 sub(/-[vr
][0-9]+$
/, "", $1);
494 # remove ToAddModList extension suffixes
495 sub(/ToAddModListExt
/, "ToAddModList", $1);
496 sub(/ToAddModListSizeExt
/, "ToAddModList", $1);
498 field
[line_number
] =
$1;
500 #print "field est " field[line_number];
501 structure
[line_number
] = current_structure
;
502 field_description_len
[current_structure
][$1] =
0;
507 field
[line_number
] =
"";
508 text_level
[line_number
] = text_level
[line_number
-1] + level
(text
[line_number
]) ;
511 if (/-- Cond
[A
-Za
-z0
-9_
-]+$
/) {
512 if(/}\s
*(OPTIONAL
)*,*\s
*-- Cond
[A
-Za
-z0
-9_
-]+$
/) {
515 # The condition should be placed above the field name,
516 # It is something like
517 # field0 ..... level X
518 # field1 { ..... level X+1
519 # abc ABC, ..... level X+1
520 # def DEF ..... level X+1
521 # } OPTIONAL, -- Cond XYZ ..... level X
522 # So we go back up while level > level of the Cond line
523 # Then we reach field0, so this is the line after
524 # We then associate that line with the condition
526 for (b=
1;text_level
[line_number
-b
]>text_level
[line_number
];b
++) {};
527 condition
[line_number
-b
+1] = $
NF ;
529 # Still, to replace -- Cond XXX with - Need M/R/N,
530 # we need to know the line associated with the condition
531 condition_reference
[line_number
] = line_number
-b
+1;
534 condition
[line_number
] =
$NF ;
536 #print "condition[" line_number "] est " condition[line_number]
539 condition
[line_number
] =
"";
544 if (add_line_after
!= "") {
545 print add_line_after
;
546 add_line_after =
"" ;
549 if (/-- Cond
[A
-Za
-z0
-9_
-]+$
/) {
550 conditions = conditions
" " $NF ;
553 else if ((in_ASN1 ==
"yes") && (direct_print ==
"yes")) {