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) {
48 print indentation
"-- " field
[line
] " : " field_description
[structure
[line
]][field
[line
]][1];
50 for (i=
2;i
<=field_description_len
[structure
[line
]][field
[line
]]; i
++) {
52 print indentation
"-- " field_description
[structure
[line
]][field
[line
]][i
];
57 if (condition_description_len
[condition
[line
]] > 0) {
60 gsub(/(, )*[Nn
]eed
[MNSR
],*/, "", condition_description
[condition
[line
]][1]);
61 print indentation
"-- " field
[line
] " : " condition_description
[condition
[line
]][1];
63 for(i=
2;i
<=condition_description_len
[condition
[line
]];i
++) {
64 gsub(/(, )*[Nn
]eed
[MNSR
],*/, "", condition_description
[condition
[line
]][i
]);
65 print indentation
"--" condition_description
[condition
[line
]][i
];
70 if (condition_code
[condition
[line
]] ==
"")
71 { sub(/-- Cond
[A
-Za
-z0
-9_
-]+/, "", text
[line
]); }
73 { sub(/-- Cond
[A
-Za
-z0
-9_
-]+/, "-- Need " condition_code
[condition
[line
]], text
[line
]); }
82 if (text
[line
] ~
/-- Cond
[A
-Za
-z0
-9_
-]+/)
85 if (condition_code
[condition
[line
]] ==
"")
86 { sub(/-- Cond
[A
-Za
-z0
-9_
-]+/, "", text
[line
]); }
89 #print "Ligne " text[condition_reference[line]];
91 sub(/-- Cond
[A
-Za
-z0
-9_
-]+/, "-- Need " condition_code
[condition
[line
]], text
[line
]); }
93 #if((line>0) || (text[line] ~ /[a-zA-Z0-9-]/)) {
104 delete field_description_len
;
105 delete field_description
;
106 delete condition_description_len
;
107 delete condition_description
;
108 delete condition_code
;
109 delete condition_reference
;
111 #print "end of asn1_print"
114 function need_code
(aaa
)
116 if (aaa ~
/[Nn
]eed M
[ ,.
]/) { return "M" }
117 if (aaa ~
/[Nn
]eed N
[ ,.
]/) { return "N" }
118 if (aaa ~
/[Nn
]eed R
[ ,.
]/) { return "R" }
119 if (aaa ~
/[Nn
]eed S
[ ,.
]/) { return "S" }
127 return gsub(/{/, "", local_bbb1
) - gsub(/}/, "", local_bbb2
)
131 add_line_after
!= "" ;
134 wide_separator =
"" ;
136 wide_separator = wide_separator
"-" ;
139 ie_separator =
"-- " ;
140 for (i=
0;i
<=
70;i
++) {
141 ie_separator = ie_separator
"=" ;
146 /^
[0-9]+(\.
[0-9]+)*\t/ {
147 if (in_IE ==
"yes") { asn1_print
(); }
151 /^
[A
-Za
-z0
-9-]+ message$
/ {
152 # No need to print this
156 /^
[A
-Za
-z0
-9-]+ information element$
/ {
157 # No need to print this
171 direct_print =
"no" ;
181 if (next_line ==
"condition") {
184 if ((next_line ==
"field description") || (next_line ==
"field name")){
188 if (next_line
!= "field description") {
191 # #if (empty_line == "yes") {
195 current_condition =
"" ;
196 if (empty_line ==
"yes") { next; }
200 #print "empty_line set to yes" ;
206 # The empty_line condition is meant for what is directly printed, i.e. messages decriptions
207 # ASN.1, field descriptions and conditions descriptions are not directly printed, so
208 # this should not apply to them
212 #if ((next_line == "field description") || (next_line == "field name")){
214 #print "empty_line set to no"
219 /^
-[[:space
:]]+ParentIE
-WithEM$
/ {
223 /^
-[[:space
:]]+[A
-Za
-z0
-9-]+$
/ {
226 # if (empty_line == "yes") {
235 #if (IE_name == "PosSI-SchedulingInfo") { print "IE trouvé" ; }
242 /^
-[[:space
:]]+Multiplicity and type constraints? definitions?$
/ {
245 if (in_IE ==
"yes") {
251 # In this case, directly print ASN.1 without processing
252 direct_print =
"yes" ;
255 print "-- IE: Constants";
263 /^
-[[:space
:]]+End of
[A
-Za
-z0
-9-]+$
/ {
264 if (in_IE ==
"yes") {
272 /^
NR-InterNodeDefinitions
/ {
275 print "-- IE: NR-InterNodeDefinitions";
283 direct_print =
"yes" ;
287 /^Conditional
[Pp
]resence
/ {
291 $0 =
"Conditional presence" ;
293 separator = separator
"-" ;
296 #add_line_after = separator ;
297 next_line =
"condition" ;
298 #print "Conditional Presence"
299 #if (IE_name == "PosSI-SchedulingInfo") { print "condition trouvée" ; }
302 # Need to catch "x and y field descriptions"
304 /field descriptions$
/ {
309 separator = separator
"-" ;
312 # add_line_after = separator ;
313 next_line =
"field name" ;
317 #print "Trouvé description des champs de " $1;
322 #/^[A-Za-z0-9-]+[[:space:]]+[A-Za-z0-9-]+/ {
323 # if (next_line == "field description") {
324 # add_line_after = separator ;
325 # next_line = "field name";
329 # This is matched for any non-empty line
333 if ((in_IE ==
"yes") && (in_ASN1 ==
"no")){
335 # if we are coming from a "IE X field description" statement
336 # or we were in a field description
337 if ((next_line ==
"field name") || (next_line ==
"field description")) {
340 # If the whole line is a coma-separated list in an IE (=> field names)
341 if (/^
[A
-Za
-z0
-9-]+(, [A
-Za
-z0
-9-]+)*$
/) {
342 # Then, this is a new field, or list of fields
347 # remove leading/trailing spaces
348 sub(/^
[[:space
:]]+/, "", names
);
349 sub(/[[:space
:]]+$
/, "", names
);
351 # remove comas and duplicate spaces
352 gsub(/,/, "", names
);
353 gsub(/[[:space
:]]+/, " ", names
);
355 #print "coucou " names;
359 # this will delete any previous field_list
360 ret =
split(names
, field_list
, " ");
363 #print "split returned " ret ;
364 #for (abc in field_list)
365 #{ print "field_list contient " field_list[abc];}
369 #add_line_after = " ";
371 # Add one entry for each of the fields
372 for (ii in field_list
) {
373 num = field_description_len
[field_struct
][field_list
[ii
]] =
0;
374 #print "Trouvé description de " field_list[ii];
377 if (next_line ==
"field name") {
378 next_line =
"field description";
381 else { next_line =
"field name" ; }
386 # This is a field description
388 #if (index($0,"BAP")!=0) {
389 #print "BAP trouvé" $0 ;
391 #print "contenu " $0;
393 if ((next_line ==
"field name") || (next_line ==
"field description")) {
394 for (ii in field_list
) {
395 field_description_len
[field_struct
][field_list
[ii
]]++;
396 num = field_description_len
[field_struct
][field_list
[ii
]];
397 field_description
[field_struct
][field_list
[ii
]][num
] =
$0;
398 #print "ajouté une ligne pour " field_list[ii] "dans " field_struct;
406 else if ((in_ASN1 ==
"yes") && (direct_print ==
"yes")) {
414 # sub(/-[vr][0-9]+$/, "", $1);
416 # current_structure = $1 ;
422 if (in_IE ==
"yes") {
424 #print "$0 est " $0 " in_ASN1 est " in_ASN1;
425 if (next_line ==
"condition") {
426 #print "branche condition " $0;
427 if ($1 != "Conditional") {
428 if (index(conditions
, $1) != 0) {
429 current_condition =
$1 ;
430 condition_description_len
[current_condition
] =
1 ;
432 condition_description
[current_condition
][1] =
$0 ;
433 condition_code
[current_condition
] = need_code
($0);
436 #print "-- Condition: " $1;
438 #print "Condition " current_condition " trouvée";
442 #if ((in_ASN1 == "no") && !(/^\s*$/)) {
446 # prints first line of condition
451 #print "La description est " $0;
452 condition_description_len
[current_condition
]++;
453 condition_description
[current_condition
][condition_description_len
[current_condition
]] =
$0 ;
454 condition_code
[current_condition
] = need_code
($0);
460 #print "in_ASN1 est " in_ASN1 " ligne " $0;
461 if ((in_ASN1 ==
"no") && !
(/^\s
*$
/)) {
466 if (in_ASN1 ==
"no") {
468 # prints subsequent lines of condition or IE description
469 if ((!
(/\S
/) && (empty_line ==
"yes"))) {next}
475 if((line_number==
0) && (/^
[[:space
:]]*$
/)) { next ; }
477 text
[line_number
] =
$0;
479 if (/Multiplicity
/) {
483 #print "text[" line_number "] est " text[line_number];
484 if (/^
[A
-Za
-z0
-9-]+[[:space
:]]+:/) {
486 sub(/-[vr
][0-9]+(-IEs
)*$
/, "", $1);
488 current_structure =
$1 ;
489 text_level
[line_number
] = level
(text
[line_number
]);
495 if (/[[:space
:]]+[a
-z
][A
-Za
-z0
-9-]*/) {
496 text_level
[line_number
] = text_level
[line_number
-1] + level
(text
[line_number
]) ;
499 sub(/-[vr
][0-9]+$
/, "", $1);
500 # remove ToAddModList extension suffixes
501 sub(/ToAddModListExt
/, "ToAddModList", $1);
502 sub(/ToAddModListSizeExt
/, "ToAddModList", $1);
504 field
[line_number
] =
$1;
506 #print "field est " field[line_number];
507 structure
[line_number
] = current_structure
;
508 field_description_len
[current_structure
][$1] =
0;
513 field
[line_number
] =
"";
514 text_level
[line_number
] = text_level
[line_number
-1] + level
(text
[line_number
]) ;
517 if (/-- Cond
[A
-Za
-z0
-9_
-]+$
/) {
518 if(/}\s
*(OPTIONAL
)*,*\s
*-- Cond
[A
-Za
-z0
-9_
-]+$
/) {
521 # The condition should be placed above the field name,
522 # It is something like
523 # field0 ..... level X
524 # field1 { ..... level X+1
525 # abc ABC, ..... level X+1
526 # def DEF ..... level X+1
527 # } OPTIONAL, -- Cond XYZ ..... level X
528 # So we go back up while level > level of the Cond line
529 # Then we reach field0, so this is the line after
530 # We then associate that line with the condition
532 for (b=
1;text_level
[line_number
-b
]>text_level
[line_number
];b
++) {};
533 condition
[line_number
-b
+1] = $
NF ;
535 # Still, to replace -- Cond XXX with - Need M/R/N,
536 # we need to know the line associated with the condition
537 condition_reference
[line_number
] = line_number
-b
+1;
540 condition
[line_number
] =
$NF ;
542 #print "condition[" line_number "] est " condition[line_number]
545 condition
[line_number
] =
"";
550 if (add_line_after
!= "") {
551 print add_line_after
;
552 add_line_after =
"" ;
555 if (/-- Cond
[A
-Za
-z0
-9_
-]+$
/) {
556 conditions = conditions
" " $NF ;
559 else if ((in_ASN1 ==
"yes") && (direct_print ==
"yes")) {