Sync with 5.4.2
[deliverable/titan.core.git] / core / config_process.y
1 /******************************************************************************
2 * Copyright (c) 2000-2015 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 ******************************************************************************/
8 %{
9
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <string.h>
13 #include <stdarg.h>
14 #include <ctype.h>
15 #include <errno.h>
16
17 #include <openssl/bn.h>
18
19 #include "../common/config_preproc.h"
20
21 #include "Param_Types.hh"
22 #include "Integer.hh"
23 #include "Float.hh"
24 #include "Boolean.hh"
25 #include "Objid.hh"
26 #include "Verdicttype.hh"
27 #include "Bitstring.hh"
28 #include "Hexstring.hh"
29 #include "Octetstring.hh"
30 #include "Charstring.hh"
31 #include "Universal_charstring.hh"
32
33 #include "Module_list.hh"
34 #include "Port.hh"
35 #include "Runtime.hh"
36
37 #include "LoggingBits.hh"
38 #include "LoggingParam.hh"
39
40 #include "Profiler.hh"
41
42 #define YYERROR_VERBOSE
43
44 #include "config_process.lex.hh"
45
46 extern void reset_config_process_lex(const char* fname);
47 extern void config_process_close();
48 extern int config_process_get_current_line();
49 extern std::string get_cfg_process_current_file();
50
51 static int config_process_parse();
52 static void check_duplicate_option(const char *section_name,
53 const char *option_name, boolean& option_flag);
54 static void check_ignored_section(const char *section_name);
55 static void set_param(Module_Param& module_param);
56 static unsigned char char_to_hexdigit(char c);
57
58 static boolean error_flag = FALSE;
59
60 static Module_Param* parsed_module_param = NULL;
61 static char * parsing_error_messages = NULL;
62
63 /*
64 For detecting duplicate entries in the config file. Start out as FALSE,
65 set to TRUE bycheck_duplicate_option().
66 Exception: duplication of parameters that can be component specific is checked
67 by set_xxx(), these start out as TRUE.
68 */
69 static boolean file_name_set = FALSE,
70 file_mask_set = TRUE,
71 console_mask_set = TRUE,
72 timestamp_format_set = FALSE,
73 source_info_format_set = FALSE,
74 append_file_set = FALSE,
75 log_event_types_set = FALSE,
76 log_entity_name_set = FALSE,
77 begin_controlpart_command_set = FALSE,
78 end_controlpart_command_set = FALSE,
79 begin_testcase_command_set = FALSE,
80 end_testcase_command_set = FALSE,
81 log_file_size_set = TRUE,
82 log_file_number_set = TRUE,
83 log_disk_full_action_set = TRUE,
84 matching_verbosity_set = FALSE,
85 logger_plugins_set = FALSE,
86 plugin_specific_set = FALSE;
87
88 int execute_list_len = 0;
89 execute_list_item *execute_list = NULL;
90
91 string_map_t *config_defines;
92
93 %}
94
95 %union{
96 char *str_val;
97 int_val_t *int_val;
98 int int_native;
99 unsigned int uint_val;
100 double float_val;
101 boolean bool_val;
102 param_objid_t objid_val;
103 verdicttype verdict_val;
104 param_bitstring_t bitstring_val;
105 param_hexstring_t hexstring_val;
106 param_charstring_t charstring_val;
107 param_octetstring_t octetstring_val;
108 universal_char universal_char_val;
109 param_universal_charstring_t universal_charstring_val;
110 Module_Param::operation_type_t param_optype_val;
111 Vector<Module_Param*>* module_param_list;
112 Module_Param* module_param_val;
113 Module_Param_Length_Restriction* module_param_length_restriction;
114 Vector<char*>* name_vector;
115 component_id_t comp_id;
116 execute_list_item execute_item_val;
117 TTCN_Logger::emergency_logging_behaviour_t emergency_logging_behaviour_value;
118 TTCN_Logger::timestamp_format_t timestamp_value;
119 TTCN_Logger::source_info_format_t source_info_value;
120 TTCN_Logger::log_event_types_t log_event_types_value;
121 TTCN_Logger::disk_full_action_t disk_full_action_value;
122 TTCN_Logger::matching_verbosity_t matching_verbosity_value;
123 TTCN_Logger::Severity logseverity_val;
124 Logging_Bits logoptions_val;
125
126 logging_plugin_t *logging_plugins;
127 logging_param_t logging_params;
128 logging_setting_t logging_param_line;
129 }
130
131 %token ModuleParametersKeyword
132 %token LoggingKeyword
133 %token ProfilerKeyword
134 %token TestportParametersKeyword
135 %token ExecuteKeyword
136 %token ExternalCommandsKeyword
137 %token GroupsKeyword
138 %token ComponentsKeyword
139 %token MainControllerKeyword
140 %token IncludeKeyword
141 %token DefineKeyword
142
143 %token Detailed
144 %token Compact
145 %token ObjIdKeyword "objid"
146 %token CharKeyword "char"
147 %token ControlKeyword "control"
148 %token MTCKeyword "mtc"
149 %token SystemKeyword "system"
150 %token NULLKeyword "NULL"
151 %token nullKeyword "null"
152 %token OmitKeyword "omit"
153 %token ComplementKeyword "complement"
154 %token DotDot ".."
155 %token SupersetKeyword "superset"
156 %token SubsetKeyword "subset"
157 %token PatternKeyword "pattern"
158 %token PermutationKeyword "permutation"
159 %token LengthKeyword "length"
160 %token IfpresentKeyword "ifpresent"
161 %token InfinityKeyword "infinity"
162 %token AssignmentChar ":= or ="
163 %token ConcatChar "&="
164 %token LogFile "LogFile or FileName"
165 %token EmergencyLogging
166 %token EmergencyLoggingBehaviour
167 %token EmergencyLoggingMask
168 %token BufferAll
169 %token BufferMasked
170 %token FileMask
171 %token ConsoleMask
172 %token TimestampFormat
173 %token ConsoleTimestampFormat
174 %token SourceInfoFormat "LogSourceInfo or SourceInfoFormat"
175 %token AppendFile
176 %token LogEventTypes
177 %token LogEntityName
178 %token BeginControlPart
179 %token EndControlPart
180 %token BeginTestCase
181 %token EndTestCase
182 %token <str_val> Identifier
183 %token <str_val> ASN1LowerIdentifier "ASN.1 identifier beginning with a lowercase letter"
184 %token <int_val> Number MPNumber "integer value"
185 %token <float_val> Float MPFloat "float value"
186 %token <bool_val> BooleanValue "true or false"
187 %token <verdict_val> VerdictValue
188 %token <bitstring_val> Bstring "bit string value"
189 %token <hexstring_val> Hstring "hex string value"
190 %token <octetstring_val> Ostring "octet string value"
191 %token <str_val> BstringMatch "bit string template"
192 %token <str_val> HstringMatch "hex string template"
193 %token <str_val> OstringMatch "octet string template"
194 %token <charstring_val> Cstring MPCstring "charstring value"
195 %token DNSName "hostname"
196 /* a single bit */
197 %token <logseverity_val> LoggingBit
198 /* a collection of bits */
199 %token <logseverity_val> LoggingBitCollection
200 %token SubCategories
201 %token <emergency_logging_behaviour_value> EmergencyLoggingBehaviourValue "BufferAll or BufferMasked"
202 %token <timestamp_value> TimestampValue "Time, Datetime or Seconds"
203 %token <source_info_value> SourceInfoValue "None, Single or Stack"
204 %token <bool_val> YesNo "yes or no"
205 %token LocalAddress
206 %token TCPPort
207 %token KillTimer
208 %token NumHCs
209 %token UnixSocketEnabled
210 %token YesToken "yes"
211 %token NoToken "no"
212 %token LogFileSize
213 %token LogFileNumber
214 %token DiskFullAction
215 %token MatchingHints
216 %token LoggerPlugins
217 %token Error
218 %token Stop
219 %token Retry
220 %token Delete
221 %token TtcnStringParsingKeyword
222 %token DisableProfilerKeyword "DisableProfiler"
223 %token DisableCoverageKeyword "DisableCoverage"
224 %token DatabaseFileKeyword "DatabaseFile"
225 %token AggregateDataKeyword "AggregateData"
226 %token StatisticsFileKeyword "StatisticsFile"
227 %token DisableStatisticsKeyword "DisableStatistics"
228 %token StatisticsFilterKeyword "StatisticsFilter"
229 %token StartAutomaticallyKeyword "StartAutomatically"
230 %token NetLineTimesKeyword "NetLineTimes"
231 %token NetFunctionTimesKeyword "NetFunctionTimes"
232 %token <uint_val> ProfilerStatsFlag "profiler statistics filter"
233
234 %type <int_val> IntegerValue
235 %type <float_val> FloatValue
236 %type <objid_val> ObjIdValue ObjIdComponentList
237 %type <int_val> ObjIdComponent NumberForm NameAndNumberForm
238
239 %type <universal_charstring_val> UniversalCharstringValue UniversalCharstringFragment
240 %type <universal_char_val> Quadruple
241
242 %type <str_val> LoggerPluginId
243 %type <logging_plugins> LoggerPlugin LoggerPluginList
244 %type <logging_params> LoggingParam
245 %type <logging_param_line> LoggingParamLines
246 %type <str_val> LogFileName StringValue
247 /* a collection of bits */
248 %type <logoptions_val> LoggingBitmask
249 %type <logoptions_val> LoggingBitOrCollection
250 %type <source_info_value> SourceInfoSetting
251 %type <bool_val> YesNoOrBoolean
252 %type <log_event_types_value> LogEventTypesValue
253 %type <disk_full_action_value> DiskFullActionValue
254 %type <str_val> Command
255 %type <matching_verbosity_value> VerbosityValue
256 %type <comp_id> ComponentId
257 %type <str_val> TestportName ArrayRef TestportParameterName
258 TestportParameterValue
259
260 %type <execute_item_val> ExecuteItem
261
262 %type <bitstring_val> BitstringValue
263 %type <hexstring_val> HexstringValue
264 %type <octetstring_val> OctetstringValue
265
266 %type <name_vector> ParameterName ParameterNameSegment
267 %type <param_optype_val> ParamOpType
268 %type <str_val> FieldName
269 %type <module_param_val> ParameterValue SimpleParameterValue ParameterValueOrNotUsedSymbol
270 FieldValue ArrayItem IndexItem IndexItemList FieldValueList ArrayItemList CompoundValue IntegerRange FloatRange StringRange
271 ParameterExpression ParameterReference
272 %type <module_param_list> TemplateItemList
273 %type <module_param_length_restriction> LengthMatch
274 %type <str_val> PatternChunk
275 %type <int_native> IndexItemIndex LengthBound
276 %type <uint_val> ProfilerStatsFlags
277
278 %destructor { Free($$); }
279 ArrayRef
280 ASN1LowerIdentifier
281 Command
282 FieldName
283 Identifier
284 LogFileName
285 StringValue
286 TestportName
287 TestportParameterName
288 TestportParameterValue
289 PatternChunk
290 BstringMatch
291 HstringMatch
292 OstringMatch
293
294 %destructor { Free($$.components_ptr); }
295 ObjIdComponentList
296 ObjIdValue
297
298 %destructor { Free($$.bits_ptr); }
299 Bstring
300 BitstringValue
301
302 %destructor { Free($$.nibbles_ptr); }
303 Hstring
304 HexstringValue
305
306 %destructor { Free($$.octets_ptr); }
307 Ostring
308 OctetstringValue
309
310 %destructor { Free($$.chars_ptr); }
311 Cstring
312 MPCstring
313
314 %destructor { Free($$.uchars_ptr); }
315 UniversalCharstringFragment
316 UniversalCharstringValue
317
318 %destructor { if ($$.id_selector == COMPONENT_ID_NAME) Free($$.id_name); }
319 ComponentId
320
321 %destructor { Free($$.module_name); Free($$.testcase_name); }
322 ExecuteItem
323
324 %destructor { delete $$; }
325 IntegerValue
326 NameAndNumberForm
327 Number
328 MPNumber
329 NumberForm
330 ObjIdComponent
331 ParameterValue
332 SimpleParameterValue
333 ParameterValueOrNotUsedSymbol
334 ArrayItemList
335 FieldValueList
336 IndexItemList
337 CompoundValue
338 ArrayItem
339 FieldValue
340 IndexItem
341 IntegerRange
342 FloatRange
343 StringRange
344 ParameterExpression
345 ParameterReference
346
347 %destructor { delete $$; }
348 LengthMatch
349
350 %destructor { for(size_t i=0; i<$$->size(); i++) { delete $$->at(i); } delete $$; }
351 TemplateItemList
352
353 %destructor { for(size_t i=0; i<$$->size(); i++) { Free($$->at(i)); } delete $$; }
354 ParameterName
355 ParameterNameSegment
356
357 %left '&' /* to avoid shift/reduce conflicts */
358 %left '+' '-'
359 %left '*' '/'
360 %left UnarySign
361
362 %expect 1
363
364 /*
365 1 conflict:
366 When seeing a '*' token after a module parameter expression the parser cannot
367 decide whether the token is a multiplication operator (shift) or it refers to
368 all modules in the next module parameter (reduce).
369 */
370 %%
371
372 GrammarRoot:
373 ConfigFile
374 {
375 if (Ttcn_String_Parsing::happening()) {
376 config_process_error("Config file cannot be parsed as ttcn string");
377 }
378 }
379 | TtcnStringParsingKeyword ParameterValue
380 {
381 parsed_module_param = $2;
382 }
383 ;
384
385 ConfigFile:
386 /* empty */
387 | ConfigFile Section
388 ;
389
390 Section:
391 ModuleParametersSection
392 | LoggingSection
393 | ProfilerSection
394 | TestportParametersSection
395 | ExecuteSection
396 | ExternalCommandsSection
397 | GroupsSection
398 | ComponentsSection
399 | MainControllerSection
400 | IncludeSection
401 | DefineSection
402 ;
403
404 ModuleParametersSection:
405 ModuleParametersKeyword ModuleParameters
406 ;
407
408 ModuleParameters:
409 /* empty */
410 | ModuleParameters ModuleParameter optSemiColon
411 ;
412
413 ModuleParameter:
414 ParameterName ParamOpType ParameterValue
415 {
416 Module_Param* mp = $3;
417 mp->set_id(new Module_Param_Name(*$1));
418 mp->set_operation_type($2);
419 set_param(*mp);
420 delete mp;
421 delete $1;
422 }
423 ;
424
425 ParameterName:
426 ParameterNameSegment { $$ = $1; }
427 | '*' '.' ParameterNameSegment { $$ = $3; }
428 ;
429
430 ParameterNameSegment:
431 ParameterNameSegment '.' Identifier
432 {
433 $$ = $1;
434 $$->push_back($3);
435 }
436 | ParameterNameSegment IndexItemIndex
437 {
438 $$ = $1;
439 $$->push_back(mprintf("%d", $2));
440 }
441 | Identifier
442 {
443 $$ = new Vector<char*>();
444 $$->push_back($1);
445 }
446 ;
447
448 ParameterValue:
449 ParameterExpression
450 {
451 $$ = $1;
452 }
453 | ParameterExpression LengthMatch
454 {
455 $$ = $1;
456 $$->set_length_restriction($2);
457 }
458 | ParameterExpression IfpresentKeyword
459 {
460 $$ = $1;
461 $$->set_ifpresent();
462 }
463 | ParameterExpression LengthMatch IfpresentKeyword
464 {
465 $$ = $1;
466 $$->set_length_restriction($2);
467 $$->set_ifpresent();
468 }
469 ;
470
471 LengthMatch:
472 LengthKeyword '(' LengthBound ')'
473 {
474 $$ = new Module_Param_Length_Restriction();
475 $$->set_single((size_t)$3);
476 }
477 | LengthKeyword '(' LengthBound DotDot LengthBound ')'
478 {
479 if ($3>$5) {
480 config_process_error("invalid length restriction: lower bound > upper bound");
481 }
482 $$ = new Module_Param_Length_Restriction();
483 $$->set_min((size_t)$3);
484 $$->set_max((size_t)$5);
485 }
486 | LengthKeyword '(' LengthBound DotDot InfinityKeyword ')'
487 {
488 $$ = new Module_Param_Length_Restriction();
489 $$->set_min((size_t)$3);
490 }
491 ;
492
493 LengthBound:
494 ParameterExpression
495 {
496 $1->set_id(new Module_Param_CustomName(mcopystr("length bound")));
497 INTEGER tmp;
498 tmp.set_param(*$1);
499 if (!tmp.get_val().is_native()) {
500 config_process_error("bignum length restriction bound.");
501 $$ = 0;
502 } else if (tmp.get_val().is_negative()) {
503 config_process_error("negative length restriction bound.");
504 $$ = 0;
505 } else {
506 $$ = tmp;
507 }
508 delete $1;
509 }
510 ;
511
512 // one global rule for expressions in module parameters
513 // the expression's result will be calculated by set_param()
514 ParameterExpression:
515 SimpleParameterValue { $$ = $1; }
516 | ParameterReference { $$ = $1; }
517 | '(' ParameterExpression ')' { $$ = $2; }
518 | '+' ParameterExpression %prec UnarySign { $$ = $2; }
519 | '-' ParameterExpression %prec UnarySign { $$ = new Module_Param_Expression($2); }
520 | ParameterExpression '+' ParameterExpression
521 {
522 $$ = new Module_Param_Expression(Module_Param::EXPR_ADD, $1, $3);
523 }
524 | ParameterExpression '-' ParameterExpression
525 {
526 $$ = new Module_Param_Expression(Module_Param::EXPR_SUBTRACT, $1, $3);
527 }
528 | ParameterExpression '*' ParameterExpression
529 {
530 $$ = new Module_Param_Expression(Module_Param::EXPR_MULTIPLY, $1, $3);
531 }
532 | ParameterExpression '/' ParameterExpression
533 {
534 $$ = new Module_Param_Expression(Module_Param::EXPR_DIVIDE, $1, $3);
535 }
536 | ParameterExpression '&' ParameterExpression
537 {
538 $$ = new Module_Param_Expression(Module_Param::EXPR_CONCATENATE, $1, $3);
539 }
540 ;
541
542 ParameterReference:
543 // enumerated values are also treated as references by the parser,
544 // these will be sorted out later during set_param()
545 ParameterNameSegment
546 {
547 $$ = new Module_Param_Reference(new Module_Param_Name(*$1));
548 }
549 ;
550
551 SimpleParameterValue:
552 MPNumber
553 {
554 $$ = new Module_Param_Integer($1);
555 }
556 | MPFloat
557 {
558 $$ = new Module_Param_Float($1);
559 }
560 | BooleanValue
561 {
562 $$ = new Module_Param_Boolean($1);
563 }
564 | ObjIdValue
565 {
566 $$ = new Module_Param_Objid($1.n_components, $1.components_ptr);
567 }
568 | VerdictValue
569 {
570 $$ = new Module_Param_Verdict($1);
571 }
572 | BitstringValue
573 {
574 $$ = new Module_Param_Bitstring($1.n_bits, $1.bits_ptr);
575 }
576 | HexstringValue
577 {
578 $$ = new Module_Param_Hexstring($1.n_nibbles, $1.nibbles_ptr);
579 }
580 | OctetstringValue
581 {
582 $$ = new Module_Param_Octetstring($1.n_octets, $1.octets_ptr);
583 }
584 | MPCstring
585 {
586 $$ = new Module_Param_Charstring($1.n_chars, $1.chars_ptr);
587 }
588 | UniversalCharstringValue
589 {
590 $$ = new Module_Param_Universal_Charstring($1.n_uchars, $1.uchars_ptr);
591 }
592 | OmitKeyword
593 {
594 $$ = new Module_Param_Omit();
595 }
596 | NULLKeyword
597 {
598 $$ = new Module_Param_Asn_Null();
599 }
600 | nullKeyword
601 {
602 $$ = new Module_Param_Ttcn_Null();
603 }
604 | MTCKeyword
605 {
606 $$ = new Module_Param_Ttcn_mtc();
607 }
608 | SystemKeyword
609 {
610 $$ = new Module_Param_Ttcn_system();
611 }
612 | '?'
613 {
614 $$ = new Module_Param_Any();
615 }
616 | '*'
617 {
618 $$ = new Module_Param_AnyOrNone();
619 }
620 | IntegerRange
621 {
622 $$ = $1;
623 }
624 | FloatRange
625 {
626 $$ = $1;
627 }
628 | StringRange
629 {
630 $$ = $1;
631 }
632 | PatternKeyword PatternChunk
633 {
634 $$ = new Module_Param_Pattern($2);
635 }
636 | BstringMatch
637 {
638 // conversion
639 int n_chars = (int)mstrlen($1);
640 unsigned char* chars_ptr = (unsigned char*)Malloc(n_chars*sizeof(unsigned char));
641 for (int i=0; i<n_chars; i++) {
642 switch ($1[i]) {
643 case '0':
644 chars_ptr[i] = 0;
645 break;
646 case '1':
647 chars_ptr[i] = 1;
648 break;
649 case '?':
650 chars_ptr[i] = 2;
651 break;
652 case '*':
653 chars_ptr[i] = 3;
654 break;
655 default:
656 chars_ptr[i] = 0;
657 config_process_error_f("Invalid char (%c) in bitstring template", $1[i]);
658 }
659 }
660 Free($1);
661 $$ = new Module_Param_Bitstring_Template(n_chars, chars_ptr);
662 }
663 | HstringMatch
664 {
665 int n_chars = (int)mstrlen($1);
666 unsigned char* chars_ptr = (unsigned char*)Malloc(n_chars*sizeof(unsigned char));
667 for (int i=0; i<n_chars; i++) {
668 if ($1[i]=='?') chars_ptr[i] = 16;
669 else if ($1[i]=='*') chars_ptr[i] = 17;
670 else chars_ptr[i] = char_to_hexdigit($1[i]);
671 }
672 Free($1);
673 $$ = new Module_Param_Hexstring_Template(n_chars, chars_ptr);
674 }
675 | OstringMatch
676 {
677 Vector<unsigned short> octet_vec;
678 int str_len = (int)mstrlen($1);
679 for (int i=0; i<str_len; i++) {
680 unsigned short num;
681 if ($1[i]=='?') num = 256;
682 else if ($1[i]=='*') num = 257;
683 else {
684 // first digit
685 num = 16 * char_to_hexdigit($1[i]);
686 i++;
687 if (i>=str_len) config_process_error("Unexpected end of octetstring pattern");
688 // second digit
689 num += char_to_hexdigit($1[i]);
690 }
691 octet_vec.push_back(num);
692 }
693 Free($1);
694 int n_chars = (int)octet_vec.size();
695 unsigned short* chars_ptr = (unsigned short*)Malloc(n_chars*sizeof(unsigned short));
696 for (int i=0; i<n_chars; i++) chars_ptr[i] = octet_vec[i];
697 $$ = new Module_Param_Octetstring_Template(n_chars, chars_ptr);
698 }
699 | CompoundValue
700 {
701 $$ = $1;
702 }
703 ;
704
705 PatternChunk:
706 MPCstring
707 {
708 $$ = mcopystr($1.chars_ptr);
709 Free($1.chars_ptr);
710 }
711 | Quadruple
712 {
713 $$ = mprintf("\\q{%d,%d,%d,%d}", $1.uc_group, $1.uc_plane, $1.uc_row, $1.uc_cell);
714 }
715 ;
716
717 IntegerRange:
718 '(' '-' InfinityKeyword DotDot MPNumber ')'
719 {
720 $$ = new Module_Param_IntRange(NULL, $5);
721 }
722 | '(' MPNumber DotDot MPNumber ')'
723 {
724 $$ = new Module_Param_IntRange($2, $4);
725 }
726 | '(' MPNumber DotDot InfinityKeyword ')'
727 {
728 $$ = new Module_Param_IntRange($2, NULL);
729 }
730 ;
731
732 FloatRange:
733 '(' '-' InfinityKeyword DotDot MPFloat ')'
734 {
735 $$ = new Module_Param_FloatRange(0.0, false, $5, true);
736 }
737 | '(' MPFloat DotDot MPFloat ')'
738 {
739 $$ = new Module_Param_FloatRange($2, true, $4, true);
740 }
741 | '(' MPFloat DotDot InfinityKeyword ')'
742 {
743 $$ = new Module_Param_FloatRange($2, true, 0.0, false);
744 }
745 ;
746
747 StringRange:
748 '(' UniversalCharstringFragment DotDot UniversalCharstringFragment ')'
749 {
750 universal_char lower; lower.uc_group=lower.uc_plane=lower.uc_row=lower.uc_cell=0;
751 universal_char upper; upper.uc_group=upper.uc_plane=upper.uc_row=upper.uc_cell=0;
752 if ($2.n_uchars!=1) {
753 config_process_error("Lower bound of char range must be 1 character only");
754 } else if ($4.n_uchars!=1) {
755 config_process_error("Upper bound of char range must be 1 character only");
756 } else {
757 lower = *($2.uchars_ptr);
758 upper = *($4.uchars_ptr);
759 if (upper<lower) {
760 config_process_error("Lower bound is larger than upper bound in the char range");
761 lower = upper;
762 }
763 }
764 Free($2.uchars_ptr);
765 Free($4.uchars_ptr);
766 $$ = new Module_Param_StringRange(lower, upper);
767 }
768 ;
769
770 // integers outside of the [MODULE_PARAMETERS] section
771 IntegerValue:
772 Number { $$ = $1; }
773 | '(' IntegerValue ')' { $$ = $2; }
774 | '+' IntegerValue %prec UnarySign { $$ = $2; }
775 | '-' IntegerValue %prec UnarySign
776 {
777 INTEGER op1;
778 op1.set_val(*$2);
779 $$ = new int_val_t((-op1).get_val());
780 delete $2;
781 }
782 | IntegerValue '+' IntegerValue
783 {
784 INTEGER op1, op2;
785 op1.set_val(*$1);
786 op2.set_val(*$3);
787 $$ = new int_val_t((op1 + op2).get_val());
788 delete $1;
789 delete $3;
790 }
791 | IntegerValue '-' IntegerValue
792 {
793 INTEGER op1, op2;
794 op1.set_val(*$1);
795 op2.set_val(*$3);
796 $$ = new int_val_t((op1 - op2).get_val());
797 delete $1;
798 delete $3;
799 }
800 | IntegerValue '*' IntegerValue
801 {
802 INTEGER op1, op2;
803 op1.set_val(*$1);
804 op2.set_val(*$3);
805 $$ = new int_val_t((op1 * op2).get_val());
806 delete $1;
807 delete $3;
808 }
809 | IntegerValue '/' IntegerValue
810 {
811 if (*$3 == 0) {
812 config_process_error("Integer division by zero.");
813 $$ = new int_val_t((RInt)0);
814 delete $1;
815 delete $3;
816 } else {
817 INTEGER op1, op2;
818 op1.set_val(*$1);
819 op2.set_val(*$3);
820 $$ = new int_val_t((op1 / op2).get_val());
821 delete $1;
822 delete $3;
823 }
824 }
825 ;
826
827 // floats outside of the [MODULE_PARAMETERS] section
828 FloatValue:
829 Float { $$ = $1; }
830 | '(' FloatValue ')' { $$ = $2; }
831 | '+' FloatValue %prec UnarySign { $$ = $2; }
832 | '-' FloatValue %prec UnarySign { $$ = -$2; }
833 | FloatValue '+' FloatValue { $$ = $1 + $3; }
834 | FloatValue '-' FloatValue { $$ = $1 - $3; }
835 | FloatValue '*' FloatValue { $$ = $1 * $3; }
836 | FloatValue '/' FloatValue
837 {
838 if ($3 == 0.0) {
839 config_process_error("Floating point division by zero.");
840 $$ = 0.0;
841 } else $$ = $1 / $3;
842 }
843 ;
844
845 ObjIdValue:
846 ObjIdKeyword '{' ObjIdComponentList '}' { $$ = $3; }
847 ;
848
849 ObjIdComponentList:
850 ObjIdComponent
851 {
852 $$.n_components = 1;
853 $$.components_ptr = (int *)Malloc(sizeof(int));
854 $$.components_ptr[0] = $1->get_val();
855 delete $1;
856 }
857 | ObjIdComponentList ObjIdComponent
858 {
859 $$.n_components = $1.n_components + 1;
860 $$.components_ptr = (int *)Realloc($1.components_ptr,
861 $$.n_components * sizeof(int));
862 $$.components_ptr[$$.n_components - 1] = $2->get_val();
863 delete $2;
864 }
865 ;
866
867 ObjIdComponent:
868 NumberForm { $$ = $1; }
869 | NameAndNumberForm { $$ = $1; }
870 ;
871
872 NumberForm:
873 MPNumber { $$ = $1; }
874 ;
875
876 NameAndNumberForm:
877 Identifier '(' MPNumber ')'
878 {
879 Free($1);
880 $$ = $3;
881 }
882 ;
883
884 BitstringValue:
885 Bstring { $$ = $1; }
886 ;
887
888 HexstringValue:
889 Hstring { $$ = $1; }
890 ;
891
892 OctetstringValue:
893 Ostring { $$ = $1; }
894 ;
895
896 UniversalCharstringValue:
897 Quadruple
898 {
899 $$.n_uchars = 1;
900 $$.uchars_ptr = (universal_char*)Malloc(sizeof(universal_char));
901 $$.uchars_ptr[0] = $1;
902 }
903 ;
904
905 UniversalCharstringFragment:
906 MPCstring
907 {
908 $$.n_uchars = $1.n_chars;
909 $$.uchars_ptr = (universal_char*)
910 Malloc($$.n_uchars * sizeof(universal_char));
911 for (int i = 0; i < $1.n_chars; i++) {
912 $$.uchars_ptr[i].uc_group = 0;
913 $$.uchars_ptr[i].uc_plane = 0;
914 $$.uchars_ptr[i].uc_row = 0;
915 $$.uchars_ptr[i].uc_cell = $1.chars_ptr[i];
916 }
917 Free($1.chars_ptr);
918 }
919 | Quadruple
920 {
921 $$.n_uchars = 1;
922 $$.uchars_ptr = (universal_char*)Malloc(sizeof(universal_char));
923 $$.uchars_ptr[0] = $1;
924 }
925 ;
926
927 Quadruple:
928 CharKeyword '(' ParameterExpression ',' ParameterExpression ','
929 ParameterExpression ',' ParameterExpression ')'
930 {
931 $3->set_id(new Module_Param_CustomName(mcopystr("quadruple group")));
932 $5->set_id(new Module_Param_CustomName(mcopystr("quadruple plane")));
933 $7->set_id(new Module_Param_CustomName(mcopystr("quadruple row")));
934 $9->set_id(new Module_Param_CustomName(mcopystr("quadruple cell")));
935 INTEGER g, p, r, c;
936 g.set_param(*$3);
937 p.set_param(*$5);
938 r.set_param(*$7);
939 c.set_param(*$9);
940 if (g < 0 || g > 127) {
941 char *s = g.get_val().as_string();
942 config_process_error_f("The first number of quadruple (group) must be "
943 "within the range 0 .. 127 instead of %s.", s);
944 Free(s);
945 $$.uc_group = g < 0 ? 0 : 127;
946 } else {
947 $$.uc_group = g;
948 }
949 if (p < 0 || p > 255) {
950 char *s = p.get_val().as_string();
951 config_process_error_f("The second number of quadruple (plane) must be "
952 "within the range 0 .. 255 instead of %s.", s);
953 Free(s);
954 $$.uc_plane = p < 0 ? 0 : 255;
955 } else {
956 $$.uc_plane = p;
957 }
958 if (r < 0 || r > 255) {
959 char *s = r.get_val().as_string();
960 config_process_error_f("The third number of quadruple (row) must be "
961 "within the range 0 .. 255 instead of %s.", s);
962 Free(s);
963 $$.uc_row = r < 0 ? 0 : 255;
964 } else {
965 $$.uc_row = r;
966 }
967 if (c < 0 || c > 255) {
968 char *s = c.get_val().as_string();
969 config_process_error_f("The fourth number of quadruple (cell) must be "
970 "within the range 0 .. 255 instead of %s.", s);
971 Free(s);
972 $$.uc_cell = c < 0 ? 0 : 255;
973 } else {
974 $$.uc_cell = c;
975 }
976 delete $3;
977 delete $5;
978 delete $7;
979 delete $9;
980 }
981 ;
982
983 // character strings outside of the [MODULE_PARAMETERS] section
984 StringValue:
985 Cstring
986 {
987 $$ = mcopystr($1.chars_ptr);
988 Free($1.chars_ptr);
989 }
990 | StringValue '&' Cstring
991 {
992 $$ = mputstr($1, $3.chars_ptr);
993 Free($3.chars_ptr);
994 }
995 ;
996
997 CompoundValue:
998 '{' '}'
999 {
1000 $$ = new Module_Param_Value_List();
1001 }
1002 | '{' FieldValueList '}'
1003 {
1004 $$ = $2;
1005 }
1006 | '{' ArrayItemList '}'
1007 {
1008 $$ = $2;
1009 }
1010 | '{' IndexItemList '}'
1011 {
1012 $$ = $2;
1013 }
1014 | '(' ParameterValue ',' TemplateItemList ')' /* at least 2 elements to avoid shift/reduce conflicts with the ParameterExpression rule */
1015 {
1016 $$ = new Module_Param_List_Template();
1017 $2->set_id(new Module_Param_Index($$->get_size(),false));
1018 $$->add_elem($2);
1019 $$->add_list_with_implicit_ids($4);
1020 delete $4;
1021 }
1022 | ComplementKeyword '(' TemplateItemList ')'
1023 {
1024 $$ = new Module_Param_ComplementList_Template();
1025 $$->add_list_with_implicit_ids($3);
1026 delete $3;
1027 }
1028 | SupersetKeyword '(' TemplateItemList ')'
1029 {
1030 $$ = new Module_Param_Superset_Template();
1031 $$->add_list_with_implicit_ids($3);
1032 delete $3;
1033 }
1034 | SubsetKeyword '(' TemplateItemList ')'
1035 {
1036 $$ = new Module_Param_Subset_Template();
1037 $$->add_list_with_implicit_ids($3);
1038 delete $3;
1039 }
1040 ;
1041
1042 ParameterValueOrNotUsedSymbol:
1043 ParameterValue
1044 {
1045 $$ = $1;
1046 }
1047 | '-'
1048 {
1049 $$ = new Module_Param_NotUsed();
1050 }
1051 ;
1052
1053 TemplateItemList:
1054 ParameterValue
1055 {
1056 $$ = new Vector<Module_Param*>();
1057 $$->push_back($1);
1058 }
1059 | TemplateItemList ',' ParameterValue
1060 {
1061 $$ = $1;
1062 $$->push_back($3);
1063 }
1064 ;
1065
1066 FieldValueList:
1067 FieldValue
1068 {
1069 $$ = new Module_Param_Assignment_List();
1070 $$->add_elem($1);
1071 }
1072 | FieldValueList ',' FieldValue
1073 {
1074 $$ = $1;
1075 $$->add_elem($3);
1076 }
1077 ;
1078
1079 FieldValue:
1080 FieldName AssignmentChar ParameterValueOrNotUsedSymbol
1081 {
1082 $$ = $3;
1083 $$->set_id(new Module_Param_FieldName($1));
1084 }
1085 ;
1086
1087 FieldName:
1088 Identifier
1089 {
1090 $$ = $1;
1091 }
1092 | ASN1LowerIdentifier
1093 {
1094 $$ = $1;
1095 }
1096 ;
1097
1098 ArrayItemList:
1099 ArrayItem
1100 {
1101 $$ = new Module_Param_Value_List();
1102 $1->set_id(new Module_Param_Index($$->get_size(),false));
1103 $$->add_elem($1);
1104 }
1105 | ArrayItemList ',' ArrayItem
1106 {
1107 $$ = $1;
1108 $3->set_id(new Module_Param_Index($$->get_size(),false));
1109 $$->add_elem($3);
1110 }
1111 ;
1112
1113 ArrayItem:
1114 ParameterValueOrNotUsedSymbol
1115 {
1116 $$ = $1;
1117 }
1118 | PermutationKeyword '(' TemplateItemList ')'
1119 {
1120 $$ = new Module_Param_Permutation_Template();
1121 $$->add_list_with_implicit_ids($3);
1122 delete $3;
1123 }
1124 ;
1125
1126 IndexItemList:
1127 IndexItem
1128 {
1129 $$ = new Module_Param_Indexed_List();
1130 $$->add_elem($1);
1131 }
1132 | IndexItemList ',' IndexItem
1133 {
1134 $$ = $1;
1135 $$->add_elem($3);
1136 }
1137 ;
1138
1139 IndexItem:
1140 IndexItemIndex AssignmentChar ParameterValue
1141 {
1142 $$ = $3;
1143 $$->set_id(new Module_Param_Index((size_t)$1,true));
1144 }
1145 ;
1146
1147 IndexItemIndex:
1148 '[' ParameterExpression ']'
1149 {
1150 $2->set_id(new Module_Param_CustomName(mcopystr("array index")));
1151 INTEGER tmp;
1152 tmp.set_param(*$2);
1153 if (!tmp.get_val().is_native()) {
1154 config_process_error("bignum index."); // todo
1155 }
1156 if (tmp.get_val().is_negative()) {
1157 config_process_error("negative index."); // todo
1158 }
1159 $$ = tmp;
1160 delete $2;
1161 }
1162 ;
1163
1164 /*************** [LOGGING] section *********************************/
1165
1166 LoggingSection:
1167 LoggingKeyword LoggingParamList
1168 ;
1169
1170 LoggingParamList:
1171 /* empty */
1172 | LoggingParamList LoggingParamLines optSemiColon
1173 {
1174 // Centralized duplication handling for `[LOGGING]'.
1175 if ($2.logparam.log_param_selection != LP_UNKNOWN && TTCN_Logger::add_parameter($2)) {
1176 switch ($2.logparam.log_param_selection) {
1177 case LP_FILEMASK:
1178 check_duplicate_option("LOGGING", "FileMask", file_mask_set);
1179 break;
1180 case LP_CONSOLEMASK:
1181 check_duplicate_option("LOGGING", "ConsoleMask", console_mask_set);
1182 break;
1183 case LP_LOGFILESIZE:
1184 check_duplicate_option("LOGGING", "LogFileSize", log_file_size_set);
1185 break;
1186 case LP_LOGFILENUMBER:
1187 check_duplicate_option("LOGGING", "LogFileNumber", log_file_number_set);
1188 break;
1189 case LP_DISKFULLACTION:
1190 check_duplicate_option("LOGGING", "DiskFullAction", log_disk_full_action_set);
1191 break;
1192 case LP_LOGFILE:
1193 check_duplicate_option("LOGGING", "LogFile", file_name_set);
1194 break;
1195 case LP_TIMESTAMPFORMAT:
1196 check_duplicate_option("LOGGING", "TimeStampFormat", timestamp_format_set);
1197 break;
1198 case LP_SOURCEINFOFORMAT:
1199 check_duplicate_option("LOGGING", "SourceInfoFormat", source_info_format_set);
1200 break;
1201 case LP_APPENDFILE:
1202 check_duplicate_option("LOGGING", "AppendFile", append_file_set);
1203 break;
1204 case LP_LOGEVENTTYPES:
1205 check_duplicate_option("LOGGING", "LogEventTypes", log_event_types_set);
1206 break;
1207 case LP_LOGENTITYNAME:
1208 check_duplicate_option("LOGGING", "LogEntityName", log_entity_name_set);
1209 break;
1210 case LP_MATCHINGHINTS:
1211 check_duplicate_option("LOGGING", "MatchingVerbosity", matching_verbosity_set);
1212 break;
1213 case LP_PLUGIN_SPECIFIC:
1214 // It would be an overkill to check for the infinite number of custom parameters...
1215 check_duplicate_option("LOGGING", "PluginSpecific", plugin_specific_set);
1216 break;
1217 default:
1218 break;
1219 }
1220 }
1221 }
1222 ;
1223
1224 LoggingParamLines:
1225 LoggingParam
1226 {
1227 $$.component.id_selector = COMPONENT_ID_ALL;
1228 $$.component.id_name = NULL;
1229 $$.plugin_id = NULL;
1230 $$.logparam = $1;
1231 }
1232 | ComponentId '.' LoggingParam
1233 {
1234 $$.component = $1;
1235 $$.plugin_id = NULL;
1236 $$.logparam = $3;
1237 }
1238 | ComponentId '.' LoggerPluginId '.' LoggingParam
1239 {
1240 $$.component = $1;
1241 $$.plugin_id = $3;
1242 $$.logparam = $5;
1243 }
1244 | LoggerPlugins AssignmentChar '{' LoggerPluginList '}'
1245 {
1246 check_duplicate_option("LOGGING", "LoggerPlugins", logger_plugins_set);
1247 component_id_t comp;
1248 comp.id_selector = COMPONENT_ID_ALL;
1249 comp.id_name = NULL;
1250 logging_plugin_t *plugin = $4;
1251 while (plugin != NULL) {
1252 // `identifier' and `filename' are reused. Various checks and
1253 // validations must be done in the logger itself (e.g. looking for
1254 // duplicate options).
1255 TTCN_Logger::register_plugin(comp, plugin->identifier, plugin->filename);
1256 logging_plugin_t *tmp = plugin;
1257 plugin = tmp->next;
1258 Free(tmp);
1259 }
1260 $$.logparam.log_param_selection = LP_UNKNOWN;
1261 }
1262 | ComponentId '.' LoggerPlugins AssignmentChar '{' LoggerPluginList '}'
1263 {
1264 check_duplicate_option("LOGGING", "LoggerPlugins", logger_plugins_set);
1265 logging_plugin_t *plugin = $6;
1266 while (plugin != NULL) {
1267 TTCN_Logger::register_plugin($1, plugin->identifier, plugin->filename);
1268 logging_plugin_t *tmp = plugin;
1269 plugin = tmp->next;
1270 Free(tmp);
1271 }
1272 // Component names shall be duplicated in `register_plugin()'.
1273 if ($1.id_selector == COMPONENT_ID_NAME)
1274 Free($1.id_name);
1275 $$.logparam.log_param_selection = LP_UNKNOWN;
1276 }
1277 ;
1278
1279 LoggerPluginList:
1280 LoggerPlugin
1281 {
1282 $$ = $1;
1283 }
1284 | LoggerPluginList ',' LoggerPlugin
1285 {
1286 $$ = $3;
1287 $$->next = $1;
1288 }
1289 ;
1290
1291 LoggerPlugin:
1292 Identifier
1293 {
1294 $$ = (logging_plugin_t *)Malloc(sizeof(logging_plugin_t));
1295 $$->identifier = $1;
1296 $$->filename = NULL;
1297 $$->next = NULL;
1298 }
1299 | Identifier AssignmentChar StringValue
1300 {
1301 $$ = (logging_plugin_t *)Malloc(sizeof(logging_plugin_t));
1302 $$->identifier = $1;
1303 $$->filename = $3;
1304 $$->next = NULL;
1305 }
1306 ;
1307
1308 LoggerPluginId:
1309 '*' { $$ = mcopystr("*"); }
1310 | Identifier { $$ = $1; }
1311 ;
1312
1313 LoggingParam:
1314 FileMask AssignmentChar LoggingBitmask
1315 {
1316 $$.log_param_selection = LP_FILEMASK;
1317 $$.logoptions_val = $3;
1318 }
1319 | ConsoleMask AssignmentChar LoggingBitmask
1320 {
1321 $$.log_param_selection = LP_CONSOLEMASK;
1322 $$.logoptions_val = $3;
1323 }
1324 | LogFileSize AssignmentChar Number
1325 {
1326 $$.log_param_selection = LP_LOGFILESIZE;
1327 $$.int_val = (int)$3->get_val();
1328 delete $3;
1329 }
1330 | EmergencyLogging AssignmentChar Number
1331 {
1332 $$.log_param_selection = LP_EMERGENCY;
1333 $$.int_val = (int)$3->get_val();
1334 delete $3;
1335 }
1336 | EmergencyLoggingBehaviour AssignmentChar EmergencyLoggingBehaviourValue
1337 {
1338 $$.log_param_selection = LP_EMERGENCYBEHAVIOR;
1339 $$.emergency_logging_behaviour_value = $3;
1340 }
1341 | EmergencyLoggingMask AssignmentChar LoggingBitmask
1342 {
1343 $$.log_param_selection = LP_EMERGENCYMASK;
1344 $$.logoptions_val = $3;
1345 }
1346 | LogFileNumber AssignmentChar Number
1347 {
1348 $$.log_param_selection = LP_LOGFILENUMBER;
1349 $$.int_val = (int)$3->get_val();
1350 delete $3;
1351 }
1352 | DiskFullAction AssignmentChar DiskFullActionValue
1353 {
1354 $$.log_param_selection = LP_DISKFULLACTION;
1355 $$.disk_full_action_value = $3;
1356 }
1357 | LogFile AssignmentChar LogFileName
1358 {
1359 $$.log_param_selection = LP_LOGFILE;
1360 $$.str_val = $3;
1361 }
1362 | TimestampFormat AssignmentChar TimestampValue
1363 {
1364 $$.log_param_selection = LP_TIMESTAMPFORMAT;
1365 $$.timestamp_value = $3;
1366 }
1367 | ConsoleTimestampFormat AssignmentChar TimestampValue
1368 {
1369 $$.log_param_selection = LP_UNKNOWN;
1370 }
1371 | SourceInfoFormat AssignmentChar SourceInfoSetting
1372 {
1373 $$.log_param_selection = LP_SOURCEINFOFORMAT;
1374 $$.source_info_value = $3;
1375 }
1376 | AppendFile AssignmentChar YesNoOrBoolean
1377 {
1378 $$.log_param_selection = LP_APPENDFILE;
1379 $$.bool_val = $3;
1380 }
1381 | LogEventTypes AssignmentChar LogEventTypesValue
1382 {
1383 $$.log_param_selection = LP_LOGEVENTTYPES;
1384 $$.log_event_types_value = $3;
1385 }
1386 | LogEntityName AssignmentChar YesNoOrBoolean
1387 {
1388 $$.log_param_selection = LP_LOGENTITYNAME;
1389 $$.bool_val = $3;
1390 }
1391 | MatchingHints AssignmentChar VerbosityValue
1392 {
1393 $$.log_param_selection = LP_MATCHINGHINTS;
1394 $$.matching_verbosity_value = $3;
1395 }
1396 | Identifier AssignmentChar StringValue
1397 {
1398 $$.log_param_selection = LP_PLUGIN_SPECIFIC;
1399 $$.param_name = $1;
1400 $$.str_val = $3;
1401 }
1402 ;
1403
1404 VerbosityValue:
1405 Compact { $$ = TTCN_Logger::VERBOSITY_COMPACT; }
1406 | Detailed { $$ = TTCN_Logger::VERBOSITY_FULL; }
1407 ;
1408
1409 DiskFullActionValue:
1410 Error { $$.type = TTCN_Logger::DISKFULL_ERROR; }
1411 | Stop { $$.type = TTCN_Logger::DISKFULL_STOP; }
1412 | Retry
1413 {
1414 $$.type = TTCN_Logger::DISKFULL_RETRY;
1415 $$.retry_interval = 30; /* default retry interval */
1416 }
1417 | Retry '(' Number ')'
1418 {
1419 $$.type = TTCN_Logger::DISKFULL_RETRY;
1420 $$.retry_interval = (size_t)$3->get_val();
1421 delete $3;
1422 }
1423 | Delete { $$.type = TTCN_Logger::DISKFULL_DELETE; }
1424 ;
1425
1426 LogFileName:
1427 StringValue { $$ = $1; }
1428 ;
1429
1430 LoggingBitOrCollection:
1431 LoggingBit
1432 {
1433 $$.clear();
1434 $$.add_sev($1);
1435 }
1436 | LoggingBitCollection
1437 {
1438 $$.clear();
1439 switch($1)
1440 {
1441 case TTCN_Logger::ACTION_UNQUALIFIED:
1442 $$.add_sev(TTCN_Logger::ACTION_UNQUALIFIED);
1443 break;
1444 case TTCN_Logger::DEFAULTOP_UNQUALIFIED:
1445 $$.add_sev(TTCN_Logger::DEFAULTOP_ACTIVATE);
1446 $$.add_sev(TTCN_Logger::DEFAULTOP_DEACTIVATE);
1447 $$.add_sev(TTCN_Logger::DEFAULTOP_EXIT);
1448 $$.add_sev(TTCN_Logger::DEFAULTOP_UNQUALIFIED);
1449 break;
1450 case TTCN_Logger::ERROR_UNQUALIFIED:
1451 $$.add_sev(TTCN_Logger::ERROR_UNQUALIFIED);
1452 break;
1453 case TTCN_Logger::EXECUTOR_UNQUALIFIED:
1454 $$.add_sev(TTCN_Logger::EXECUTOR_RUNTIME);
1455 $$.add_sev(TTCN_Logger::EXECUTOR_CONFIGDATA);
1456 $$.add_sev(TTCN_Logger::EXECUTOR_EXTCOMMAND);
1457 $$.add_sev(TTCN_Logger::EXECUTOR_COMPONENT);
1458 $$.add_sev(TTCN_Logger::EXECUTOR_LOGOPTIONS);
1459 $$.add_sev(TTCN_Logger::EXECUTOR_UNQUALIFIED);
1460 break;
1461 case TTCN_Logger::FUNCTION_UNQUALIFIED:
1462 $$.add_sev(TTCN_Logger::FUNCTION_RND);
1463 $$.add_sev(TTCN_Logger::FUNCTION_UNQUALIFIED);
1464 break;
1465 case TTCN_Logger::PARALLEL_UNQUALIFIED:
1466 $$.add_sev(TTCN_Logger::PARALLEL_PTC);
1467 $$.add_sev(TTCN_Logger::PARALLEL_PORTCONN);
1468 $$.add_sev(TTCN_Logger::PARALLEL_PORTMAP);
1469 $$.add_sev(TTCN_Logger::PARALLEL_UNQUALIFIED);
1470 break;
1471 case TTCN_Logger::PORTEVENT_UNQUALIFIED:
1472 $$.add_sev(TTCN_Logger::PORTEVENT_PQUEUE);
1473 $$.add_sev(TTCN_Logger::PORTEVENT_MQUEUE);
1474 $$.add_sev(TTCN_Logger::PORTEVENT_STATE);
1475 $$.add_sev(TTCN_Logger::PORTEVENT_PMIN);
1476 $$.add_sev(TTCN_Logger::PORTEVENT_PMOUT);
1477 $$.add_sev(TTCN_Logger::PORTEVENT_PCIN);
1478 $$.add_sev(TTCN_Logger::PORTEVENT_PCOUT);
1479 $$.add_sev(TTCN_Logger::PORTEVENT_MMRECV);
1480 $$.add_sev(TTCN_Logger::PORTEVENT_MMSEND);
1481 $$.add_sev(TTCN_Logger::PORTEVENT_MCRECV);
1482 $$.add_sev(TTCN_Logger::PORTEVENT_MCSEND);
1483 $$.add_sev(TTCN_Logger::PORTEVENT_DUALRECV);
1484 $$.add_sev(TTCN_Logger::PORTEVENT_DUALSEND);
1485 $$.add_sev(TTCN_Logger::PORTEVENT_UNQUALIFIED);
1486 break;
1487 case TTCN_Logger::TESTCASE_UNQUALIFIED:
1488 $$.add_sev(TTCN_Logger::TESTCASE_START);
1489 $$.add_sev(TTCN_Logger::TESTCASE_FINISH);
1490 $$.add_sev(TTCN_Logger::TESTCASE_UNQUALIFIED);
1491 break;
1492 case TTCN_Logger::TIMEROP_UNQUALIFIED:
1493 $$.add_sev(TTCN_Logger::TIMEROP_READ);
1494 $$.add_sev(TTCN_Logger::TIMEROP_START);
1495 $$.add_sev(TTCN_Logger::TIMEROP_GUARD);
1496 $$.add_sev(TTCN_Logger::TIMEROP_STOP);
1497 $$.add_sev(TTCN_Logger::TIMEROP_TIMEOUT);
1498 $$.add_sev(TTCN_Logger::TIMEROP_UNQUALIFIED);
1499 break;
1500 case TTCN_Logger::USER_UNQUALIFIED:
1501 $$.add_sev(TTCN_Logger::USER_UNQUALIFIED);
1502 break;
1503 case TTCN_Logger::STATISTICS_UNQUALIFIED:
1504 $$.add_sev(TTCN_Logger::STATISTICS_VERDICT);
1505 $$.add_sev(TTCN_Logger::STATISTICS_UNQUALIFIED);
1506 break;
1507 case TTCN_Logger::VERDICTOP_UNQUALIFIED:
1508 $$.add_sev(TTCN_Logger::VERDICTOP_GETVERDICT);
1509 $$.add_sev(TTCN_Logger::VERDICTOP_SETVERDICT);
1510 $$.add_sev(TTCN_Logger::VERDICTOP_FINAL);
1511 $$.add_sev(TTCN_Logger::VERDICTOP_UNQUALIFIED);
1512 break;
1513 case TTCN_Logger::WARNING_UNQUALIFIED:
1514 $$.add_sev(TTCN_Logger::WARNING_UNQUALIFIED);
1515 break;
1516 case TTCN_Logger::MATCHING_UNQUALIFIED:
1517 $$.add_sev(TTCN_Logger::MATCHING_DONE);
1518 $$.add_sev(TTCN_Logger::MATCHING_TIMEOUT);
1519 $$.add_sev(TTCN_Logger::MATCHING_PCSUCCESS);
1520 $$.add_sev(TTCN_Logger::MATCHING_PCUNSUCC);
1521 $$.add_sev(TTCN_Logger::MATCHING_PMSUCCESS);
1522 $$.add_sev(TTCN_Logger::MATCHING_PMUNSUCC);
1523 $$.add_sev(TTCN_Logger::MATCHING_MCSUCCESS);
1524 $$.add_sev(TTCN_Logger::MATCHING_MCUNSUCC);
1525 $$.add_sev(TTCN_Logger::MATCHING_MMSUCCESS);
1526 $$.add_sev(TTCN_Logger::MATCHING_MMUNSUCC);
1527 $$.add_sev(TTCN_Logger::MATCHING_PROBLEM);
1528 $$.add_sev(TTCN_Logger::MATCHING_UNQUALIFIED);
1529 break;
1530 case TTCN_Logger::DEBUG_UNQUALIFIED:
1531 $$.add_sev(TTCN_Logger::DEBUG_ENCDEC);
1532 $$.add_sev(TTCN_Logger::DEBUG_TESTPORT);
1533 $$.add_sev(TTCN_Logger::DEBUG_USER);
1534 $$.add_sev(TTCN_Logger::DEBUG_FRAMEWORK);
1535 $$.add_sev(TTCN_Logger::DEBUG_UNQUALIFIED);
1536 break;
1537 case TTCN_Logger::LOG_ALL_IMPORTANT:
1538 $$ = Logging_Bits::log_all;
1539 break;
1540 default:
1541 /* The lexer sent something the parser doesn't understand!
1542 Parser needs to be updated.
1543 */
1544 TTCN_Logger::log_str(TTCN_Logger::ERROR_UNQUALIFIED,
1545 "Internal error: unknown logbit from lexer.");
1546 break;
1547 } // switch
1548 }
1549 ;
1550
1551 LoggingBitmask:
1552 LoggingBitOrCollection
1553 {
1554 $$ = $1;
1555 }
1556 | LoggingBitmask '|' LoggingBitOrCollection
1557 {
1558 $$ = $1;
1559 $$.merge($3);
1560 }
1561 ;
1562
1563 SourceInfoSetting:
1564 SourceInfoValue { $$ = $1; }
1565 | YesNoOrBoolean
1566 {
1567 $$ = $1 ? TTCN_Logger::SINFO_SINGLE : TTCN_Logger::SINFO_NONE;
1568 }
1569 ;
1570
1571 YesNoOrBoolean:
1572 YesNo { $$ = $1; }
1573 | BooleanValue { $$ = $1; }
1574 ;
1575
1576 LogEventTypesValue:
1577 YesNoOrBoolean { $$ = $1 ? TTCN_Logger::LOGEVENTTYPES_YES :
1578 TTCN_Logger::LOGEVENTTYPES_NO; }
1579 | SubCategories { $$ = TTCN_Logger::LOGEVENTTYPES_SUBCATEGORIES; }
1580 | Detailed { $$ = TTCN_Logger::LOGEVENTTYPES_SUBCATEGORIES; }
1581 ;
1582
1583 /*********************** [PROFILER] ********************************/
1584
1585 ProfilerSection:
1586 ProfilerKeyword ProfilerSettings
1587 ;
1588
1589 ProfilerSettings:
1590 /* empty */
1591 | ProfilerSettings ProfilerSetting optSemiColon
1592 ;
1593
1594 ProfilerSetting:
1595 DisableProfilerSetting
1596 | DisableCoverageSetting
1597 | DatabaseFileSetting
1598 | AggregateDataSetting
1599 | StatisticsFileSetting
1600 | DisableStatisticsSetting
1601 | StatisticsFilterSetting
1602 | StartAutomaticallySetting
1603 | NetLineTimesSetting
1604 | NetFunctionTimesSetting
1605 ;
1606
1607 DisableProfilerSetting:
1608 DisableProfilerKeyword AssignmentChar BooleanValue {
1609 ttcn3_prof.set_disable_profiler($3);
1610 }
1611 ;
1612
1613 DisableCoverageSetting:
1614 DisableCoverageKeyword AssignmentChar BooleanValue {
1615 ttcn3_prof.set_disable_coverage($3);
1616 }
1617 ;
1618
1619 DatabaseFileSetting:
1620 DatabaseFileKeyword AssignmentChar StringValue {
1621 ttcn3_prof.set_database_filename($3);
1622 }
1623 ;
1624
1625 AggregateDataSetting:
1626 AggregateDataKeyword AssignmentChar BooleanValue {
1627 ttcn3_prof.set_aggregate_data($3);
1628 }
1629 ;
1630
1631 StatisticsFileSetting:
1632 StatisticsFileKeyword AssignmentChar StringValue {
1633 ttcn3_prof.set_stats_filename($3);
1634 }
1635 ;
1636
1637 DisableStatisticsSetting:
1638 DisableStatisticsKeyword AssignmentChar BooleanValue {
1639 ttcn3_prof.set_disable_stats($3);
1640 }
1641 ;
1642
1643 StatisticsFilterSetting:
1644 StatisticsFilterKeyword AssignmentChar ProfilerStatsFlags {
1645 ttcn3_prof.reset_stats_flags();
1646 ttcn3_prof.add_stats_flags($3);
1647 }
1648 | StatisticsFilterKeyword ConcatChar ProfilerStatsFlags {
1649 ttcn3_prof.add_stats_flags($3);
1650 }
1651 ;
1652
1653 ProfilerStatsFlags:
1654 ProfilerStatsFlag { $$ = $1; }
1655 | ProfilerStatsFlag '&' ProfilerStatsFlags { $$ = $1 | $3; }
1656 | ProfilerStatsFlag '|' ProfilerStatsFlags { $$ = $1 | $3; }
1657 ;
1658
1659 StartAutomaticallySetting:
1660 StartAutomaticallyKeyword AssignmentChar BooleanValue {
1661 if ($3) {
1662 ttcn3_prof.start();
1663 }
1664 else {
1665 ttcn3_prof.stop();
1666 }
1667 }
1668 ;
1669
1670 NetLineTimesSetting:
1671 NetLineTimesKeyword AssignmentChar BooleanValue {
1672 TTCN3_Stack_Depth::set_net_line_times($3);
1673 }
1674 ;
1675
1676 NetFunctionTimesSetting:
1677 NetFunctionTimesKeyword AssignmentChar BooleanValue {
1678 TTCN3_Stack_Depth::set_net_func_times($3);
1679 }
1680 ;
1681
1682
1683 /**************** [TESTPORT_PARAMETERS] ****************************/
1684
1685 TestportParametersSection:
1686 TestportParametersKeyword TestportParameterList
1687 ;
1688
1689 TestportParameterList:
1690 /* empty */
1691 | TestportParameterList TestportParameter optSemiColon
1692 ;
1693
1694 TestportParameter:
1695 ComponentId '.' TestportName '.' TestportParameterName AssignmentChar
1696 TestportParameterValue
1697 {
1698 PORT::add_parameter($1, $3, $5, $7);
1699 if ($1.id_selector == COMPONENT_ID_NAME) Free($1.id_name);
1700 Free($3);
1701 Free($5);
1702 Free($7);
1703 }
1704 ;
1705
1706 ComponentId:
1707 Identifier
1708 {
1709 $$.id_selector = COMPONENT_ID_NAME;
1710 $$.id_name = $1;
1711 }
1712 | Cstring
1713 {
1714 $$.id_selector = COMPONENT_ID_NAME;
1715 $$.id_name = $1.chars_ptr;
1716 }
1717 | Number
1718 {
1719 $$.id_selector = COMPONENT_ID_COMPREF;
1720 $$.id_compref = (component)$1->get_val();
1721 delete $1;
1722 }
1723 | MTCKeyword
1724 {
1725 $$.id_selector = COMPONENT_ID_COMPREF;
1726 $$.id_compref = MTC_COMPREF;
1727 }
1728 | '*'
1729 {
1730 $$.id_selector = COMPONENT_ID_ALL;
1731 $$.id_name = NULL;
1732 }
1733 | SystemKeyword
1734 {
1735 $$.id_selector = COMPONENT_ID_SYSTEM;
1736 $$.id_name = NULL;
1737 }
1738 ;
1739
1740 TestportName:
1741 Identifier { $$ = $1; }
1742 | Identifier ArrayRef
1743 {
1744 $$ = mputstr($1, $2);
1745 Free($2);
1746 }
1747 | '*' { $$ = NULL; }
1748 ;
1749
1750 ArrayRef:
1751 '[' IntegerValue ']'
1752 {
1753 char *s = $2->as_string();
1754 $$ = memptystr();
1755 $$ = mputc ($$, '[');
1756 $$ = mputstr($$, s);
1757 $$ = mputc ($$, ']');
1758 Free(s);
1759 delete $2;
1760 }
1761 | ArrayRef '[' IntegerValue ']'
1762 {
1763 char *s = $3->as_string();
1764 $$ = mputc ($1, '[');
1765 $$ = mputstr($$, s);
1766 $$ = mputc ($$, ']');
1767 Free(s);
1768 delete $3;
1769 }
1770 ;
1771
1772 TestportParameterName:
1773 Identifier { $$ = $1; }
1774 ;
1775
1776 TestportParameterValue:
1777 StringValue { $$ = $1; }
1778 ;
1779
1780 /****************** [EXECUTE] section *************/
1781
1782 ExecuteSection:
1783 ExecuteKeyword ExecuteList
1784 {
1785 if (!TTCN_Runtime::is_single()) config_process_error("Internal error: "
1786 "the Main Controller must not send section [EXECUTE] of the "
1787 "configuration file.");
1788 }
1789 ;
1790
1791 ExecuteList:
1792 /* empty */
1793 | ExecuteList ExecuteItem optSemiColon
1794 {
1795 if (TTCN_Runtime::is_single()) {
1796 execute_list = (execute_list_item *)Realloc(
1797 execute_list, (execute_list_len + 1) *
1798 sizeof(*execute_list));
1799 execute_list[execute_list_len++] = $2;
1800 } else {
1801 Free($2.module_name);
1802 Free($2.testcase_name);
1803 }
1804 }
1805 ;
1806
1807 ExecuteItem:
1808 Identifier
1809 {
1810 $$.module_name = $1;
1811 $$.testcase_name = NULL;
1812 }
1813 | Identifier '.' ControlKeyword
1814 {
1815 $$.module_name = $1;
1816 $$.testcase_name = NULL;
1817 }
1818 | Identifier '.' Identifier
1819 {
1820 $$.module_name = $1;
1821 $$.testcase_name = $3;
1822 }
1823 | Identifier '.' '*'
1824 {
1825 $$.module_name = $1;
1826 $$.testcase_name = mcopystr("*");
1827 }
1828 ;
1829
1830 /****************** [EXTERNAL_COMMANDS] section **********************/
1831
1832 ExternalCommandsSection:
1833 ExternalCommandsKeyword ExternalCommandList
1834 ;
1835
1836 ExternalCommandList:
1837 /* empty */
1838 | ExternalCommandList ExternalCommand optSemiColon
1839 ;
1840
1841 ExternalCommand:
1842 BeginControlPart AssignmentChar Command
1843 {
1844 check_duplicate_option("EXTERNAL_COMMANDS", "BeginControlPart",
1845 begin_controlpart_command_set);
1846
1847 TTCN_Runtime::set_begin_controlpart_command($3);
1848
1849 Free($3);
1850 }
1851 | EndControlPart AssignmentChar Command
1852 {
1853 check_duplicate_option("EXTERNAL_COMMANDS", "EndControlPart",
1854 end_controlpart_command_set);
1855
1856 TTCN_Runtime::set_end_controlpart_command($3);
1857
1858 Free($3);
1859 }
1860 | BeginTestCase AssignmentChar Command
1861 {
1862 check_duplicate_option("EXTERNAL_COMMANDS", "BeginTestCase",
1863 begin_testcase_command_set);
1864
1865 TTCN_Runtime::set_begin_testcase_command($3);
1866
1867 Free($3);
1868 }
1869 | EndTestCase AssignmentChar Command
1870 {
1871 check_duplicate_option("EXTERNAL_COMMANDS", "EndTestCase",
1872 end_testcase_command_set);
1873
1874 TTCN_Runtime::set_end_testcase_command($3);
1875
1876 Free($3);
1877 }
1878 ;
1879
1880 Command:
1881 StringValue { $$ = $1; }
1882 ;
1883
1884 /***************** [GROUPS] section *******************/
1885
1886 GroupsSection:
1887 GroupsKeyword GroupList
1888 {
1889 check_ignored_section("GROUPS");
1890 }
1891 ;
1892
1893 GroupList:
1894 /* empty */
1895 | GroupList Group optSemiColon
1896 ;
1897
1898 Group:
1899 GroupName AssignmentChar GroupMembers
1900 ;
1901
1902 GroupName:
1903 Identifier { Free($1); }
1904 ;
1905
1906 GroupMembers:
1907 '*'
1908 | seqGroupMember
1909 ;
1910
1911 seqGroupMember:
1912 HostName
1913 | seqGroupMember ',' HostName
1914 ;
1915
1916 HostName:
1917 DNSName
1918 | Identifier { Free($1); }
1919 ;
1920
1921 /******************** [COMPONENTS] section *******************/
1922 ComponentsSection:
1923 ComponentsKeyword ComponentList
1924 {
1925 check_ignored_section("COMPONENTS");
1926 }
1927 ;
1928
1929 ComponentList:
1930 /* empty */
1931 | ComponentList ComponentItem optSemiColon
1932 ;
1933
1934 ComponentItem:
1935 ComponentName AssignmentChar ComponentLocation
1936 ;
1937
1938 ComponentName:
1939 Identifier { Free($1); }
1940 | '*'
1941 ;
1942
1943 ComponentLocation:
1944 Identifier { Free($1); }
1945 | DNSName
1946 ;
1947
1948 /****************** [MAIN_CONTROLLER] section *********************/
1949 MainControllerSection:
1950 MainControllerKeyword MCParameterList
1951 {
1952 check_ignored_section("MAIN_CONTROLLER");
1953 }
1954 ;
1955
1956 MCParameterList:
1957 /* empty */
1958 | MCParameterList MCParameter optSemiColon
1959 ;
1960
1961 MCParameter:
1962 LocalAddress AssignmentChar HostName { }
1963 | TCPPort AssignmentChar IntegerValue { delete $3; }
1964 | KillTimer AssignmentChar KillTimerValue { }
1965 | NumHCs AssignmentChar IntegerValue { delete $3; }
1966 | UnixSocketEnabled AssignmentChar YesToken {}
1967 | UnixSocketEnabled AssignmentChar NoToken {}
1968 | UnixSocketEnabled AssignmentChar HostName {}
1969 ;
1970
1971 KillTimerValue:
1972 FloatValue { }
1973 | IntegerValue { delete $1; }
1974 ;
1975
1976 /****************** [INCLUDE] section *********************/
1977 IncludeSection:
1978 IncludeKeyword IncludeFiles
1979 {
1980 if(!TTCN_Runtime::is_single())
1981 config_process_error
1982 ("Internal error: the Main Controller must not send section [INCLUDE]"
1983 " of the configuration file.");
1984 }
1985 ;
1986
1987 IncludeFiles:
1988 /* empty */
1989 | IncludeFiles IncludeFile
1990 ;
1991
1992 IncludeFile:
1993 Cstring { Free($1.chars_ptr); }
1994 ;
1995
1996 /****************** [DEFINE] section *********************/
1997 DefineSection:
1998 DefineKeyword
1999 {
2000 if(!TTCN_Runtime::is_single())
2001 config_process_error
2002 ("Internal error: the Main Controller must not send section [DEFINE]"
2003 " of the configuration file.");
2004 }
2005 ;
2006
2007 /*********************************************************/
2008
2009 ParamOpType:
2010 AssignmentChar
2011 {
2012 $$ = Module_Param::OT_ASSIGN;
2013 }
2014 |
2015 ConcatChar
2016 {
2017 $$ = Module_Param::OT_CONCAT;
2018 }
2019 ;
2020
2021 optSemiColon:
2022 /* empty */
2023 | ';'
2024 ;
2025
2026 %%
2027
2028 static void reset_configuration_options()
2029 {
2030 /* Section [MODULE_PARAMETERS */
2031 /** \todo reset module parameters to their default values */
2032 /* Section [LOGGING] */
2033 TTCN_Logger::close_file();
2034 TTCN_Logger::reset_configuration();
2035 file_name_set = FALSE;
2036 file_mask_set = TRUE;
2037 console_mask_set = TRUE;
2038 timestamp_format_set = FALSE;
2039 source_info_format_set = FALSE;
2040 append_file_set = FALSE;
2041 log_event_types_set = FALSE;
2042 log_entity_name_set = FALSE;
2043 /* Section [TESTPORT_PARAMETERS] */
2044 PORT::clear_parameters();
2045 /* Section [EXTERNAL_COMMANDS] */
2046
2047 TTCN_Runtime::clear_external_commands();
2048
2049 begin_controlpart_command_set = FALSE;
2050 end_controlpart_command_set = FALSE;
2051 begin_testcase_command_set = FALSE;
2052 end_testcase_command_set = FALSE;
2053 }
2054
2055 Module_Param* process_config_string2ttcn(const char* mp_str, bool is_component)
2056 {
2057 if (parsed_module_param!=NULL || parsing_error_messages!=NULL) TTCN_error("Internal error: previously parsed ttcn string was not cleared.");
2058 // add the hidden keyword
2059 std::string mp_string = (is_component) ? std::string("$#&&&(#TTCNSTRINGPARSING_COMPONENT$#&&^#% ") + mp_str
2060 : std::string("$#&&&(#TTCNSTRINGPARSING$#&&^#% ") + mp_str;
2061 struct yy_buffer_state *flex_buffer = config_process__scan_bytes(mp_string.c_str(), (int)mp_string.size());
2062 if (flex_buffer == NULL) TTCN_error("Internal error: flex buffer creation failed.");
2063 reset_config_process_lex(NULL);
2064 error_flag = FALSE;
2065 try {
2066 Ttcn_String_Parsing ttcn_string_parsing;
2067 if (config_process_parse()) error_flag = TRUE;
2068 } catch (const TC_Error& TC_error) {
2069 if (parsed_module_param!=NULL) { delete parsed_module_param; parsed_module_param = NULL; }
2070 error_flag = TRUE;
2071 }
2072 config_process_close();
2073 config_process_lex_destroy();
2074
2075 if (error_flag || parsing_error_messages!=NULL) {
2076 delete parsed_module_param;
2077 parsed_module_param = NULL;
2078 char* pem = parsing_error_messages!=NULL ? parsing_error_messages : mcopystr("Unknown parsing error");
2079 parsing_error_messages = NULL;
2080 TTCN_error_begin("%s", pem);
2081 Free(pem);
2082 TTCN_error_end();
2083 return NULL;
2084 } else {
2085 if (parsed_module_param==NULL) TTCN_error("Internal error: could not parse ttcn string.");
2086 Module_Param* ret_val = parsed_module_param;
2087 parsed_module_param = NULL;
2088 return ret_val;
2089 }
2090 }
2091
2092 boolean process_config_string(const char *config_string, int string_len)
2093 {
2094 error_flag = FALSE;
2095
2096 struct yy_buffer_state *flex_buffer =
2097 config_process__scan_bytes(config_string, string_len);
2098 if (flex_buffer == NULL) {
2099 TTCN_Logger::log_str(TTCN_Logger::ERROR_UNQUALIFIED,
2100 "Internal error: flex buffer creation failed.");
2101 return FALSE;
2102 }
2103
2104 try {
2105 reset_configuration_options();
2106 reset_config_process_lex(NULL);
2107 if (config_process_parse()) error_flag = TRUE;
2108
2109 } catch (const TC_Error& TC_error) {
2110 error_flag = TRUE;
2111 }
2112
2113 config_process_close();
2114 config_process_lex_destroy();
2115
2116 return !error_flag;
2117 }
2118
2119
2120 boolean process_config_file(const char *file_name)
2121 {
2122 error_flag = FALSE;
2123 string_chain_t *filenames=NULL;
2124
2125 reset_configuration_options();
2126
2127 if(preproc_parse_file(file_name, &filenames, &config_defines))
2128 error_flag=TRUE;
2129
2130 while(filenames) {
2131 char *fn=string_chain_cut(&filenames);
2132 reset_config_process_lex(fn);
2133 /* The lexer can modify config_process_in
2134 * when it's input buffer is changed */
2135 config_process_in = fopen(fn, "r");
2136 FILE* tmp_cfg = config_process_in;
2137 if (config_process_in != NULL) {
2138 try {
2139 if(config_process_parse()) error_flag=TRUE;
2140 } catch (const TC_Error& TC_error) {
2141 error_flag=TRUE;
2142 }
2143 fclose(tmp_cfg);
2144 config_process_close();
2145 config_process_lex_destroy();
2146 } else {
2147 TTCN_Logger::begin_event(TTCN_Logger::ERROR_UNQUALIFIED);
2148 TTCN_Logger::log_event("Cannot open configuration file: %s", fn);
2149 TTCN_Logger::OS_error();
2150 TTCN_Logger::end_event();
2151 error_flag=TRUE;
2152 }
2153 /* During parsing flex or libc may use some system calls (e.g. ioctl)
2154 * that fail with an error status. Such error codes shall be ignored in
2155 * future error messages. */
2156 errno = 0;
2157
2158 Free(fn);
2159 }
2160
2161 string_map_free(config_defines);
2162 config_defines = NULL;
2163
2164 return !error_flag;
2165 }
2166
2167 void config_process_error_f(const char *error_str, ...)
2168 {
2169 if (Ttcn_String_Parsing::happening()) {
2170 va_list p_var;
2171 va_start(p_var, error_str);
2172 char* error_msg_str = mprintf_va_list(error_str, p_var);
2173 va_end(p_var);
2174 if (parsing_error_messages!=NULL) parsing_error_messages = mputc(parsing_error_messages, '\n');
2175 parsing_error_messages = mputprintf(parsing_error_messages,
2176 "Parse error in line %d, at or before token `%s': %s", config_process_get_current_line(), config_process_text, error_msg_str);
2177 Free(error_msg_str);
2178 error_flag = TRUE;
2179 return;
2180 }
2181 TTCN_Logger::begin_event(TTCN_Logger::ERROR_UNQUALIFIED);
2182 if (!get_cfg_process_current_file().empty()) {
2183 TTCN_Logger::log_event("Parse error in configuration file `%s': in line %d, "
2184 "at or before token `%s': ",
2185 get_cfg_process_current_file().c_str(), config_process_get_current_line(),
2186 config_process_text
2187 );
2188 } else {
2189 TTCN_Logger::log_event("Parse error while reading configuration "
2190 "information: in line %d, at or before token `%s': ",
2191 config_process_get_current_line(), config_process_text);
2192 }
2193 va_list pvar;
2194 va_start(pvar, error_str);
2195 TTCN_Logger::log_event_va_list(error_str, pvar);
2196 va_end(pvar);
2197 TTCN_Logger::end_event();
2198 error_flag = TRUE;
2199 }
2200
2201 void config_process_error(const char *error_str)
2202 {
2203 config_process_error_f("%s", error_str);
2204 }
2205
2206 void config_preproc_error(const char *error_str, ...)
2207 {
2208 TTCN_Logger::begin_event(TTCN_Logger::ERROR_UNQUALIFIED);
2209 TTCN_Logger::log_event("Parse error while pre-processing configuration"
2210 " file `%s': in line %d: ",
2211 get_cfg_preproc_current_file().c_str(),
2212 config_preproc_yylineno);
2213 va_list pvar;
2214 va_start(pvar, error_str);
2215 TTCN_Logger::log_event_va_list(error_str, pvar);
2216 va_end(pvar);
2217 TTCN_Logger::end_event();
2218 error_flag = TRUE;
2219 }
2220
2221 void path_error(const char *fmt, ...)
2222 {
2223 va_list parameters;
2224 fprintf(stderr, "File error: ");
2225 va_start(parameters, fmt);
2226 vfprintf(stderr, fmt, parameters);
2227 va_end(parameters);
2228 fprintf(stderr, "\n");
2229 }
2230
2231 static void check_duplicate_option(const char *section_name,
2232 const char *option_name, boolean& option_flag)
2233 {
2234 if (option_flag) {
2235 TTCN_warning("Option `%s' was given more than once in section [%s] of the "
2236 "configuration file.", option_name, section_name);
2237 } else option_flag = TRUE;
2238 }
2239
2240 static void check_ignored_section(const char *section_name)
2241 {
2242 if (TTCN_Runtime::is_single()) TTCN_warning("Section [%s] of "
2243 "configuration file is ignored in single mode.", section_name);
2244 else config_process_error_f("Internal error: the Main Controller must not "
2245 "send section [%s] of the configuration file.", section_name);
2246 }
2247
2248 static void set_param(Module_Param& param)
2249 {
2250 try {
2251 Module_List::set_param(param);
2252 }
2253 catch (const TC_Error& TC_error) {
2254 error_flag = TRUE;
2255 }
2256 }
2257
2258 unsigned char char_to_hexdigit(char c)
2259 {
2260 if (c >= '0' && c <= '9') return c - '0';
2261 else if (c >= 'A' && c <= 'F') return c - 'A' + 10;
2262 else if (c >= 'a' && c <= 'f') return c - 'a' + 10;
2263 else {
2264 config_process_error_f("char_to_hexdigit(): invalid argument: %c", c);
2265 return 0; // to avoid warning
2266 }
2267 }
This page took 0.076484 seconds and 6 git commands to generate.