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
"=" ;
141 if (in_IE ==
"yes") { asn1_print
(); }
164 if (next_line ==
"condition") {
167 if ((next_line ==
"field description") || (next_line ==
"field name")){
172 # #if (empty_line == "yes") {
176 current_condition =
"" ;
177 if (empty_line ==
"yes") { next; }
181 #print "empty_line set to yes" ;
187 # The empty_line condition is meant for what is directly printed, i.e. messages decriptions
188 # ASN.1, field descriptions and conditions descriptions are not directly printed, so
189 # this should not apply to them
193 #if ((next_line == "field description") || (next_line == "field name")){
195 #print "empty_line set to no"
200 /^–
[[:space
:]]+ParentIE
-WithEM$
/ {
204 /^–
[[:space
:]]+[A
-Za
-z0
-9-]+$
/ {
207 # if (empty_line == "yes") {
216 #if (IE_name == "PosSI-SchedulingInfo") { print "IE trouvé" ; }
223 /^Conditional
[Pp
]resence
/ {
227 $0 =
"Conditional presence" ;
228 for(i=
0;i
<=
140;i
++) {
229 separator = separator
"-" ;
232 #add_line_after = separator ;
233 next_line =
"condition" ;
234 #print "Conditional Presence"
235 #if (IE_name == "PosSI-SchedulingInfo") { print "condition trouvée" ; }
238 # Need to catch "x and y field descriptions"
240 /field descriptions$
/ {
244 for(i=
0;i
<=
140;i
++) {
245 separator = separator
"-" ;
248 # add_line_after = separator ;
249 next_line =
"field name" ;
253 #print "Trouvé description des champs de " $1;
258 #/^[A-Za-z0-9-]+[[:space:]]+[A-Za-z0-9-]+/ {
259 # if (next_line == "field description") {
260 # add_line_after = separator ;
261 # next_line = "field name";
265 # This is matched for any non-empty line
269 if ((in_IE ==
"yes") && (in_ASN1 ==
"no")){
271 # if we are coming from a "IE X field description" statement
272 # or we were in a field description
273 if ((next_line ==
"field name") || (next_line ==
"field description")) {
276 # If the whole line is a coma-separated list in an IE (=> field names)
277 if (/^
[A
-Za
-z0
-9-]+(, [A
-Za
-z0
-9-]+)*$
/) {
278 # Then, this is a new field, or list of fields
283 # remove leading/trailing spaces
284 sub(/^
[[:space
:]]+/, "", names
);
285 sub(/[[:space
:]]+$
/, "", names
);
287 # remove comas and duplicate spaces
288 gsub(/,/, "", names
);
289 gsub(/[[:space
:]]+/, " ", names
);
291 #print "coucou " names;
295 # this will delete any previous field_list
296 ret =
split(names
, field_list
, " ");
299 #print "split returned " ret ;
300 #for (abc in field_list)
301 #{ print "field_list contient " field_list[abc];}
305 #add_line_after = " ";
307 # Add one entry for each of the fields
308 for (ii in field_list
) {
309 num = field_description_len
[field_struct
][field_list
[ii
]] =
0;
310 #print "Trouvé description de " field_list[ii];
313 if (next_line ==
"field name") {
314 next_line =
"field description";
317 else { next_line =
"field name" ; }
322 # This is a field description
324 #if (index($0,"BAP")!=0) {
325 #print "BAP trouvé" $0 ;
327 #print "contenu " $0;
329 if ((next_line ==
"field name") || (next_line ==
"field description")) {
330 for (ii in field_list
) {
331 field_description_len
[field_struct
][field_list
[ii
]]++;
332 num = field_description_len
[field_struct
][field_list
[ii
]];
333 field_description
[field_struct
][field_list
[ii
]][num
] =
$0;
334 #print "ajouté une ligne pour " field_list[ii] "dans " field_struct;
345 # sub(/-[vr][0-9]+$/, "", $1);
347 # current_structure = $1 ;
353 if (in_IE ==
"yes") {
355 #print "$0 est " $0 " in_ASN1 est " in_ASN1;
356 if (next_line ==
"condition") {
357 #print "branche condition " $0;
358 if ($1 != "Conditional") {
359 if (index(conditions
, $1) != 0) {
360 current_condition =
$1 ;
361 condition_description_len
[current_condition
] =
1 ;
363 condition_description
[current_condition
][1] =
$0 ;
364 condition_code
[current_condition
] = need_code
($0);
367 #print "-- Condition: " $1;
369 #print "Condition " current_condition " trouvée";
373 #if ((in_ASN1 == "no") && !(/^\s*$/)) {
377 # prints first line of condition
382 #print "La description est " $0;
383 condition_description_len
[current_condition
]++;
384 condition_description
[current_condition
][condition_description_len
[current_condition
]] =
$0 ;
385 condition_code
[current_condition
] = need_code
($0);
391 #print "in_ASN1 est " in_ASN1 " ligne " $0;
392 if ((in_ASN1 ==
"no") && !
(/^\s
*$
/)) {
397 if (in_ASN1 ==
"no") {
399 # prints subsequent lines of condition or IE description
400 if ((!
(/\S
/) && (empty_line ==
"yes"))) {next}
406 if((line_number==
0) && (/^
[[:space
:]]*$
/)) { next ; }
408 text
[line_number
] =
$0;
410 #print "text[" line_number "] est " text[line_number];
411 if (/^
[A
-Za
-z0
-9-]+[[:space
:]]+:/) {
413 sub(/-[vr
][0-9]+(-IEs
)*$
/, "", $1);
415 current_structure =
$1 ;
416 text_level
[line_number
] = level
(text
[line_number
]);
422 if (/[[:space
:]]+[a
-z
][A
-Za
-z0
-9-]*/) {
423 text_level
[line_number
] = text_level
[line_number
-1] + level
(text
[line_number
]) ;
426 sub(/-[vr
][0-9]+$
/, "", $1);
427 # remove ToAddModList extension suffixes
428 sub(/ToAddModListExt
/, "ToAddModList", $1);
429 sub(/ToAddModListSizeExt
/, "ToAddModList", $1);
431 field
[line_number
] =
$1;
433 #print "field est " field[line_number];
434 structure
[line_number
] = current_structure
;
435 field_description_len
[current_structure
][$1] =
0;
440 field
[line_number
] =
"";
441 text_level
[line_number
] = text_level
[line_number
-1] + level
(text
[line_number
]) ;
444 if (/-- Cond
[A
-Za
-z0
-9_
-]+$
/) {
445 if(/}\s
*(OPTIONAL
)*,*\s
*-- Cond
[A
-Za
-z0
-9_
-]+$
/) {
448 # The condition should be placed above the field name,
449 # It is something like
450 # field0 ..... level X
451 # field1 { ..... level X+1
452 # abc ABC, ..... level X+1
453 # def DEF ..... level X+1
454 # } OPTIONAL, -- Cond XYZ ..... level X
455 # So we go back up while level > level of the Cond line
456 # Then we reach field0, so this is the line after
457 # We then associate that line with the condition
459 for (b=
1;text_level
[line_number
-b
]>text_level
[line_number
];b
++) {};
460 condition
[line_number
-b
+1] = $
NF ;
462 # Still, to replace -- Cond XXX with - Need M/R/N,
463 # we need to know the line associated with the condition
464 condition_reference
[line_number
] = line_number
-b
+1;
467 condition
[line_number
] =
$NF ;
469 #print "condition[" line_number "] est " condition[line_number]
472 condition
[line_number
] =
"";
477 if (add_line_after
!= "") {
478 print add_line_after
;
479 add_line_after =
"" ;
482 if (/-- Cond
[A
-Za
-z0
-9_
-]+$
/) {
483 conditions = conditions
" " $NF ;