Update README.linux
[deliverable/titan.core.git] / mctr2 / cli / config_read.l
CommitLineData
970ed795
EL
1/******************************************************************************
2 * Copyright (c) 2000-2014 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%option yylineno
9%option noyywrap
10%option never-interactive
11%option nounput
12
13%{
14
15#include <string.h>
16#include <ctype.h>
17#include <stdlib.h>
18
19#include <deque>
20#include <string>
21
22#include <openssl/crypto.h>
23#include <openssl/bn.h>
24
25#include "../../common/cfg_process_utils.hh"
26#include "../../common/Path2.hh"
27#include "../../common/config_preproc.h"
28
29#include "../../common/memory.h"
30#include "../mctr/config_data.h"
31#include "../../core/Types.h"
32#include "config_read.tab.hh"
33
34//#include "../../common/dbgnew.hh"
35
36extern string_map_t *config_defines;
37
38#define yylval config_read_lval
39
40/* This buffer stores the state of the main buffer
41 while the macro expansion is happening. */
42static YY_BUFFER_STATE main_buffer = NULL;
43/* This buffer is active while the expansion of
44 a reference to a structured macro definition is happening.
45 Otherwise its value is NULL. */
46static YY_BUFFER_STATE expansion_buffer = NULL;
47
48static void update_buffer();
49static boolean whether_update_buffer();
50
51#define RETURN(x) do {update_buffer(); return (x);} while(0)
52
53void config_read_warning(const char *warning_str, ...);
54extern void config_read_error(const char *error_str, ...);
55extern config_data *cfg;
56
57static std::deque<IncludeElem<YY_BUFFER_STATE> >* include_chain = NULL;
58
59std::string get_cfg_read_current_file() {
60 if (include_chain && !include_chain->empty()) {
61 return include_chain->back().get_full_path();
62 }
63 return std::string();
64}
65
66%}
67
68WHITESPACE [ \t]
69WS {WHITESPACE}*
70NEWLINE \r|\n|\r\n
71LINECOMMENT ("//"|"#")[^\r\n]*{NEWLINE}
72
73NUMBER 0|([1-9][0-9]*)
74
75FLOAT [+-]?({NUMBER}\.[0-9]+)|((({NUMBER}(\.[0-9]+)?)|(\.[0-9]+))[Ee][+-]?{NUMBER})
76
77BIN 0|1
78BITSTRING '{BIN}*'B
79BINMATCH 0|1|\?|\*
80BITSTRINGMATCH '{BINMATCH}*'B
81BITSTRING_BAD '[^']*'B
82
83HEX [0-9A-Fa-f]
84HEXSTRING '{HEX}*'H
85HEXMATCH [0-9A-Fa-f\?\*]
86HEXSTRINGMATCH '{HEXMATCH}*'H
87HEXSTRING_BAD '[^']*'H
88
89OCT {HEX}{HEX}
90OCTETSTRING '{OCT}*'O
91OCTMATCH {HEX}{HEX}|\?|\*
92OCTETSTRINGMATCH '{OCTMATCH}*'O
93OCTETSTRING_BAD '[^']*'O
94
95BINSTRING_BAD '[^']*'
96
97TTCN3IDENTIFIER [A-Za-z][A-Za-z0-9_]*
98ASN1LOWERIDENTIFIER [a-z](-?[A-Za-z0-9]+)*
99
100MACRORVALUE ([0-9A-Za-z._-]+)|{IPV6}
101MACRO_CSTR \${TTCN3IDENTIFIER}|\$"{"{WS}{TTCN3IDENTIFIER}{WS}(","{WS}charstring{WS})?"}"
102MACRO_BOOL \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}boolean{WS}"}"
103MACRO_FLOAT \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}float{WS}"}"
104MACRO_ID \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}identifier{WS}"}"
105MACRO_INT \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}integer{WS}"}"
106MACRO_BSTR \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}bitstring{WS}"}"
107MACRO_HSTR \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}hexstring{WS}"}"
108MACRO_OSTR \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}octetstring{WS}"}"
109MACRO_BINARY \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}binaryoctet{WS}"}"
110MACRO_HOSTNAME \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}hostname{WS}"}"
111
112CHAR [^\\\"]|\\([\\\'\"\?abfnrtv]|{NEWLINE}|[0-7]{1,3}|x{HEX}{1,2})|\"\"
113CHARSTRING \"{CHAR}*\"
114
115HOSTNAME [A-Za-z0-9]([A-Za-z0-9_\-]*[A-Za-z0-9])?
116DNSNAME {HOSTNAME}(\.{HOSTNAME})*\.?
117
118/* Example: fe80::c002:37ff:fe6c:0%fastethernet0/0 */
119IPV6 [0-9A-Fa-f:.]+(%[0-9A-Za-z]+)?
120
121
122%x SC_blockcomment SC_DEFINE SC_CSTRING SC_ORDERED_INCLUDE
123%s SC_MODULE_PARAMETERS SC_LOGGING SC_TESTPORT_PARAMETERS SC_EXECUTE SC_GROUPS
af710487 124%s SC_COMPONENTS SC_EXTERNAL_COMMANDS SC_MAIN_CONTROLLER SC_INCLUDE SC_PROFILER
970ed795
EL
125
126%%
127 int comment_caller = INITIAL;
128
129 std::string cstring;
130
131 /* Eat up comments and whitespaces */
132
133"/*" {
134 comment_caller = YY_START;
135 BEGIN(SC_blockcomment);
136 }
137<SC_blockcomment>
138{
139"*/" BEGIN(comment_caller);
140.|\n
141}
142
143{LINECOMMENT}|{WHITESPACE}|{NEWLINE}
144
145 /* Section delimiters */
146
147<*>"["{WS}MODULE_PARAMETERS{WS}"]" {
148 if (YY_START!=SC_blockcomment) {
149 BEGIN(SC_MODULE_PARAMETERS);
150 RETURN(ModuleParametersKeyword);
151 }
152}
153
154<*>"["{WS}LOGGING{WS}"]" {
155 if (YY_START!=SC_blockcomment) {
156 BEGIN(SC_LOGGING);
157 RETURN(LoggingKeyword);
158 }
159}
160
af710487 161<*>"["{WS}PROFILER{WS}"]" {
162 if (YY_START!=SC_blockcomment) {
163 BEGIN(SC_PROFILER);
164 RETURN(ProfilerKeyword);
165 }
166}
167
970ed795
EL
168<*>"["{WS}TESTPORT_PARAMETERS{WS}"]" {
169 if (YY_START!=SC_blockcomment) {
170 BEGIN(SC_TESTPORT_PARAMETERS);
171 RETURN(TestportParametersKeyword);
172 }
173}
174
175<*>"["{WS}EXECUTE{WS}"]" {
176 if (YY_START!=SC_blockcomment) {
177 BEGIN(SC_EXECUTE);
178 RETURN(ExecuteKeyword);
179 }
180}
181
182<*>"["{WS}EXTERNAL_COMMANDS{WS}"]" {
183 if (YY_START!=SC_blockcomment) {
184 BEGIN(SC_EXTERNAL_COMMANDS);
185 RETURN(ExternalCommandsKeyword);
186 }
187}
188
189<*>"["{WS}GROUPS{WS}"]" {
190 if (YY_START!=SC_blockcomment) {
191 BEGIN(SC_GROUPS);
192 RETURN(GroupsKeyword);
193 }
194}
195
196<*>"["{WS}COMPONENTS{WS}"]" {
197 if (YY_START!=SC_blockcomment) {
198 BEGIN(SC_COMPONENTS);
199 RETURN(ComponentsKeyword);
200 }
201}
202
203<*>"["{WS}MAIN_CONTROLLER{WS}"]" {
204 if (YY_START!=SC_blockcomment) {
205 BEGIN(SC_MAIN_CONTROLLER);
206 RETURN(MainControllerKeyword);
207 }
208}
209
210<*>"["{WS}INCLUDE{WS}"]" {
211 if (YY_START!=SC_blockcomment) {
212 BEGIN(SC_INCLUDE);
213 RETURN(IncludeKeyword);
214 }
215}
216
217<*>"["{WS}ORDERED_INCLUDE{WS}"]" {
218 if (YY_START!=SC_blockcomment) {
219 BEGIN(SC_ORDERED_INCLUDE);
220 }
221}
222
223
224<*>"["{WS}DEFINE{WS}"]" {
225 if (YY_START!=SC_blockcomment) {
226 BEGIN(SC_DEFINE);
227 RETURN(DefineKeyword);
228 }
229}
230
231 /* Rules for SC_DEFINE must precede everything else */
232
233<SC_DEFINE>{
234
235"/*" {
236 comment_caller = SC_DEFINE;
237 BEGIN(SC_blockcomment);
238}
239
240{CHARSTRING} /* eats string */
241
242{LINECOMMENT}
243
244{NEWLINE} /* this is not in . */
245
246\\\"
247
248. /* eats unnecessary things */
249
250}
251
252<SC_ORDERED_INCLUDE>{
253
254"/*" {
255 comment_caller = YY_START;
256 BEGIN(SC_blockcomment);
257 }
258
259\" { BEGIN(SC_CSTRING); }
260
261{LINECOMMENT}
262
263{NEWLINE} /* this is not in . */
264
265\\\"
266
267. /* eat unnecessary chars */
268
269}
270
271
272<SC_CSTRING>{
273
274\"\" cstring += '"';
275
276\" {
277 std::string error_msg = switch_lexer(include_chain, cstring,
278 YY_CURRENT_BUFFER, yy_create_buffer, yy_switch_to_buffer, yylineno,
279 YY_BUF_SIZE);
280 if (error_msg.empty()) {
281 BEGIN(INITIAL);
282 } else {
283 config_read_error(error_msg.c_str());
284 }
285
286 cstring.clear();
287} /* end of string */
288
289\\[\\'"?] cstring += yytext[1]; /* backslash-quoted \ or " or ' or ? */
290\\{NEWLINE} yylineno++;
291\\a cstring += '\a';
292\\b cstring += '\b';
293\\f cstring += '\f';
294\\n cstring += '\n';
295\\r cstring += '\r';
296\\t cstring += '\t';
297\\v cstring += '\v';
298
299\\[0-7]{1,3} {
300 unsigned int c;
301 sscanf(yytext + 1, "%o", &c);
302 if (c <= 255) cstring += c;
303 else config_read_error("Invalid octal character code in string literal");
304}
305
306\\x{HEX}{1,2} {
307 unsigned int c;
308 sscanf(yytext + 2, "%x", &c);
309 cstring += c;
310}
311
312\\(x[^\\\"]|.) config_read_error("Invalid excape sequence in string literal.");
313
314{NEWLINE} {
315 cstring.append(yytext, yyleng);
316 yylineno++;
317}
318
319. {
320 cstring += yytext[0];
321}
322}
323 /* SC_cstring */
324
325
a38c6d4c 326<SC_PROFILER>{HEX}+ {
327 /* numeric statistics filter (check this before checking NUMBERs) */
328 RETURN(ProfilerStatsFlag);
329}
330
331
970ed795
EL
332 /* Values */
333
334{NUMBER} {
335 yylval.int_val = NULL;
336 BN_dec2bn(&yylval.int_val, *yytext == '+' ? yytext + 1 : yytext);
337 RETURN(Number);
338}
339
340{FLOAT} {
341 yylval.float_val = atof(yytext);
342 RETURN(Float);
343}
344
345{BITSTRING} RETURN(Bstring);
346
347{BITSTRINGMATCH} RETURN(BstringMatch);
348
349{BITSTRING_BAD} {
350 config_read_error("Invalid bitstring value.");
351 RETURN(Bstring);
352}
353
354{HEXSTRING} RETURN(Hstring);
355
356{HEXSTRINGMATCH} RETURN(HstringMatch);
357
358{HEXSTRING_BAD} {
359 config_read_error("Invalid hexstring value.");
360 RETURN(Hstring);
361}
362
363{OCTETSTRING} RETURN(Ostring);
364
365{OCTETSTRINGMATCH} RETURN(OstringMatch);
366
367{OCTETSTRING_BAD} {
368 config_read_error("Invalid octetstring value.");
369 RETURN(Ostring);
370}
371
372{BINSTRING_BAD} config_read_error("Invalid string value.");
373
374' config_read_error("Unmatched ' character.");
375
376{CHARSTRING} {
377 yylval.str_val = mcopystrn(yytext, yyleng);
378 RETURN(Cstring);
379}
380
381 /* Section-wide keywords */
382
383<SC_MODULE_PARAMETERS>
384{
385NULL RETURN(NULLKeyword);
386null RETURN(nullKeyword);
387char RETURN(CharKeyword);
388objid RETURN(ObjIdKeyword);
389omit RETURN(OmitKeyword);
390none |
391pass |
392inconc |
393fail |
394error RETURN(VerdictValue);
395complement RETURN(ComplementKeyword);
396"\.\." RETURN(DotDot);
397superset RETURN(SupersetKeyword);
398subset RETURN(SubsetKeyword);
399pattern RETURN(PatternKeyword);
400permutation RETURN(PermutationKeyword);
401length RETURN(LengthKeyword);
402ifpresent RETURN(IfpresentKeyword);
403infinity RETURN(InfinityKeyword);
404}
405
af710487 406<SC_MODULE_PARAMETERS,SC_LOGGING,SC_PROFILER>
970ed795
EL
407{
408true |
409false RETURN(BooleanValue);
410}
411
412<SC_MODULE_PARAMETERS,SC_LOGGING,SC_TESTPORT_PARAMETERS>
413{
414mtc RETURN(MTCKeyword);
415system RETURN(SystemKeyword);
416}
417
418<SC_LOGGING>
419{
420[Ff]ile[Nn]ame |
421[Ll]og[Ff]ile RETURN(LogFile);
422
423[Ee]mergency[Ll]ogging RETURN(EmergencyLogging);
424
425[Ee]mergency[Ll]ogging[Bb]ehaviour RETURN(EmergencyLoggingBehaviour);
426
427[Bb]uffer[Aa]ll |
428[Bb]uffer[Ma]asked RETURN(EmergencyLoggingBehaviourValue);
429
430[Ee]mergency[Ll]ogging[Mm]ask RETURN(EmergencyLoggingMask);
431
432
433[Ff]ile[Mm]ask RETURN(FileMask);
434
435[Cc]onsole[Mm]ask RETURN(ConsoleMask);
436
437[Tt]ime[Ss]tamp[Ff]ormat RETURN(TimestampFormat);
438[Cc]onsole[Tt]ime[Ss]tamp[Ff]ormat RETURN(ConsoleTimestampFormat);
439
440[Ll]og[Ss]ource[Ii]nfo |
441[Ss]ource[Ii]nfo[Ff]ormat RETURN(SourceInfoFormat);
442
443[Aa]ppend[Ff]ile RETURN(AppendFile);
444
445[Ll]og[Ee]vent[Tt]ypes RETURN(LogEventTypes);
446
447[Ll]og[Ee]ntity[Nn]ame RETURN(LogEntityName);
448
449[Ll]og[Ff]ile[Ss]ize RETURN(LogFileSize);
450
451[Ll]og[Ff]ile[Nn]umber RETURN(LogFileNumber);
452
453[Dd]isk[Ff]ull[Aa]ction RETURN(DiskFullAction);
454
455[Mm]atching[Hh]ints RETURN(MatchingHints);
456
457[Ll]ogger[Pp]lugins RETURN(LoggerPlugins);
458
459LOG_NOTHING RETURN(LoggingBit);
460
461(TTCN_)?ACTION |
462(TTCN_)?DEBUG |
463(TTCN_)?DEFAULTOP |
464(TTCN_)?ERROR |
465(TTCN_)?EXECUTOR |
466(TTCN_)?FUNCTION |
467(TTCN_)?MATCHING |
468(TTCN_)?PARALLEL |
469(TTCN_)?PORTEVENT |
470(TTCN_)?STATISTICS |
471(TTCN_)?TESTCASE |
472(TTCN_)?TIMEROP |
473(TTCN_)?USER |
474(TTCN_)?VERDICTOP |
475(TTCN_)?WARNING |
476LOG_ALL RETURN(LoggingBitCollection);
477
478ACTION_UNQUALIFIED |
479DEBUG_ENCDEC |
480DEBUG_TESTPORT |
481DEBUG_UNQUALIFIED |
482DEFAULTOP_ACTIVATE |
483DEFAULTOP_DEACTIVATE |
484DEFAULTOP_EXIT |
485DEFAULTOP_UNQUALIFIED |
486ERROR_UNQUALIFIED |
487EXECUTOR_COMPONENT |
488EXECUTOR_CONFIGDATA |
489EXECUTOR_EXTCOMMAND |
490EXECUTOR_LOGOPTIONS |
491EXECUTOR_RUNTIME |
492EXECUTOR_UNQUALIFIED |
493FUNCTION_RND |
494FUNCTION_UNQUALIFIED |
495MATCHING_DONE |
496MATCHING_MCSUCCESS |
497MATCHING_MCUNSUCC |
498MATCHING_MMSUCCESS |
499MATCHING_MMUNSUCC |
500MATCHING_PCSUCCESS |
501MATCHING_PCUNSUCC |
502MATCHING_PMSUCCESS |
503MATCHING_PMUNSUCC |
504MATCHING_PROBLEM |
505MATCHING_TIMEOUT |
506MATCHING_UNQUALIFIED |
507PARALLEL_PORTCONN |
508PARALLEL_PORTMAP |
509PARALLEL_PTC |
510PARALLEL_UNQUALIFIED |
511PORTEVENT_DUALRECV |
512PORTEVENT_DUALSEND |
513PORTEVENT_MCRECV |
514PORTEVENT_MCSEND |
515PORTEVENT_MMRECV |
516PORTEVENT_MMSEND |
517PORTEVENT_MQUEUE |
518PORTEVENT_PCIN |
519PORTEVENT_PCOUT |
520PORTEVENT_PMIN |
521PORTEVENT_PMOUT |
522PORTEVENT_PQUEUE |
523PORTEVENT_STATE |
524PORTEVENT_UNQUALIFIED |
525STATISTICS_UNQUALIFIED |
526STATISTICS_VERDICT |
527TESTCASE_FINISH |
528TESTCASE_START |
529TESTCASE_UNQUALIFIED |
530TIMEROP_GUARD |
531TIMEROP_READ |
532TIMEROP_START |
533TIMEROP_STOP |
534TIMEROP_TIMEOUT |
535TIMEROP_UNQUALIFIED |
536USER_UNQUALIFIED |
537VERDICTOP_FINAL |
538VERDICTOP_GETVERDICT |
539VERDICTOP_SETVERDICT |
540VERDICTOP_UNQUALIFIED |
541WARNING_UNQUALIFIED RETURN(LoggingBit);
542
543[Tt][Ii][Mm][Ee] {yylval.ts_val=TSF_TIME; RETURN(TimestampValue);}
544[Dd][Aa][Tt][Ee][Tt][Ii][Mm][Ee] {yylval.ts_val=TSF_DATE_TIME; RETURN(TimestampValue);}
545[Ss][Ee][Cc][Oo][Nn][Dd][Ss] {yylval.ts_val=TSF_SEC; RETURN(TimestampValue);}
546
547[Nn][Oo][Nn][Ee] |
548[Ss][Ii][Nn][Gg][Ll][Ee] |
549[Ss][Tt][Aa][Cc][Kk] RETURN(SourceInfoValue);
550
551[Yy][Ee][Ss] |
552[Nn][Oo] RETURN(YesNo);
553
554[Dd]etailed RETURN(Detailed);
555[Cc]ompact RETURN(Compact);
556[Ss]ub[Cc]ategories RETURN(SubCategories);
557
558[Ee]rror RETURN(Error);
559
560[Ss]top RETURN(Stop);
561
562[Rr]etry RETURN(Re_try);
563
564[Dd]elete RETURN(Delete);
565}
566
af710487 567<SC_PROFILER>
568{
a38c6d4c 569 [Dd]isable[Pp]rofiler RETURN(DisableProfilerKeyword);
570 [Dd]isable[Cc]overage RETURN(DisableCoverageKeyword);
571 [Dd]ata[Bb]ase[Ff]ile RETURN(DatabaseFileKeyword);
572 [Aa]ggregate[Dd]ata RETURN(AggregateDataKeyword);
573 [Ss]tatistics[Ff]ile RETURN(StatisticsFileKeyword);
574 [Dd]isable[Ss]tatistics RETURN(DisableStatisticsKeyword);
575 [Ss]tatistics[Ff]ilter RETURN(StatisticsFilterKeyword);
576 [Ss]tart[Aa]utomatically RETURN(StartAutomaticallyKeyword);
577 [Nn]et[Ll]ine[Tt]imes RETURN(NetLineTimesKeyword);
578 [Nn]et[Ff]unction[Tt]imes RETURN(NetFunctionTimesKeyword);
579
580 /* statistics filters */
581 [Nn]umber[Oo]f[Ll]ines |
582 [Ll]ine[Dd]ata[Rr]aw |
583 [Ff]unc[Dd]ata[Rr]aw |
584 [Ll]ine[Aa]vg[Rr]aw |
585 [Ff]unc[Aa]vg[Rr]aw |
586 [Ll]ine[Tt]imes[Ss]orted[Bb]y[Mm]od |
587 [Ff]unc[Tt]imes[Ss]orted[Bb]y[Mm]od |
588 [Ll]ine[Tt]imes[Ss]orted[Tt]otal |
589 [Ff]unc[Tt]imes[Ss]orted[Tt]otal |
590 [Ll]ine[Cc]ount[Ss]orted[Bb]y[Mm]od |
591 [Ff]unc[Cc]ount[Ss]orted[Bb]y[Mm]od |
592 [Ll]ine[Cc]ount[Ss]orted[Tt]otal |
593 [Ff]unc[Cc]ount[Ss]orted[Tt]otal |
594 [Ll]ine[Aa]vg[Ss]orted[Bb]y[Mm]od |
595 [Ff]unc[Aa]vg[Ss]orted[Bb]y[Mm]od |
596 [Ll]ine[Aa]vg[Ss]orted[Tt]otal |
597 [Ff]unc[Aa]vg[Ss]orted[Tt]otal |
598 [Tt]op10[Ll]ine[Tt]imes |
599 [Tt]op10[Ff]unc[Tt]imes |
600 [Tt]op10[Ll]ine[Cc]ount |
601 [Tt]op10[Ff]unc[Cc]ount |
602 [Tt]op10[Ll]ine[Aa]vg |
603 [Tt]op10[Ff]unc[Aa]vg |
604 [Uu]nused[Ll]ines |
605 [Uu]nused[Ff]unc |
606 [Aa]ll[Rr]aw[Dd]ata |
607 [Ll]ine[Dd]ata[Ss]orted[Bb]y[Mm]od |
608 [Ff]unc[Dd]ata[Ss]orted[Bb]y[Mm]od |
609 [Ll]ine[Dd]ata[Ss]orted[Tt]otal |
610 [Ff]unc[Dd]ata[Ss]orted[Tt]otal |
611 [Ll]ine[Dd]ata[Ss]orted |
612 [Ff]unc[Dd]ata[Ss]orted |
613 [Aa]ll[Dd]ata[Ss]orted |
614 [Tt]op10[Ll]ine[Dd]ata |
615 [Tt]op10[Ff]unc[Dd]ata |
616 [Tt]op10[Aa]ll[Dd]ata |
617 [Uu]nused[Dd]ata |
618 [Aa]ll RETURN(ProfilerStatsFlag);
af710487 619}
620
970ed795
EL
621<SC_EXECUTE>control RETURN(ControlKeyword);
622
623<SC_EXTERNAL_COMMANDS>
624{
625[Bb]egin[Cc]ontrol[Pp]art RETURN(BeginControlPart);
626[Ee]nd[Cc]ontrol[Pp]art RETURN(EndControlPart);
627[Bb]egin[Tt]est[Cc]ase RETURN(BeginTestCase);
628[Ee]nd[Tt]est[Cc]ase RETURN(EndTestCase);
629}
630
631<SC_MAIN_CONTROLLER>
632{
633[Ll]ocal[Aa]ddress RETURN(LocalAddress);
634[Tt][Cc][Pp][Pp]ort RETURN(TCPPort);
635[Kk]ill[Tt]imer RETURN(KillTimer);
636[Nn]um[Hh][Cc]s RETURN(NumHCs);
637[Uu]nix[Ss]ockets[Ee]nabled RETURN(UnixSocketEnabled);
638[Yy][Ee][Ss] RETURN(YesToken);
639[Nn][Oo] RETURN(NoToken);
640}
641
642{TTCN3IDENTIFIER} {
643 switch (YY_START) {
644 case SC_GROUPS:
645 case SC_COMPONENTS:
646 case SC_EXECUTE:
647 case SC_MAIN_CONTROLLER:
648 yylval.str_val = (char*)Malloc(yyleng + 1);
649 memcpy(yylval.str_val, yytext, yyleng + 1);
650 break;
651 default:
652 yylval.str_val = NULL;
653 }
654 RETURN(Identifier);
655}
656
657<SC_MODULE_PARAMETERS>{ASN1LOWERIDENTIFIER} {
658 char *ttcn3_id = (char*)Malloc(yyleng + 1);
659 for (int i = 0; i < yyleng; i++) {
660 if (yytext[i] == '-') ttcn3_id[i] = '_';
661 else ttcn3_id[i] = yytext[i];
662 }
663 ttcn3_id[yyleng] = '\0';
664 config_read_warning("`%s' is not a valid TTCN-3 identifier. Did you mean "
665 "`%s'?", yytext, ttcn3_id);
666 cfg->config_read_buffer = mputprintf(cfg->config_read_buffer, "%s ", ttcn3_id);
667 Free(ttcn3_id);
668 return ASN1LowerIdentifier;
669}
670
671<SC_GROUPS,SC_COMPONENTS,SC_MAIN_CONTROLLER>{DNSNAME}|{IPV6} {
672 yylval.str_val = (char*)Malloc(yyleng + 1);
673 for (int i = 0; i < yyleng; i++) yylval.str_val[i] = tolower(yytext[i]);
674 yylval.str_val[yyleng] = '\0';
675 RETURN(DNSName);
676}
677
678{MACRO_BOOL} {
679 char *macroname = get_macro_id_from_ref(yytext);
680 size_t macrolen;
681 const char *macrovalue =
682 string_map_get_bykey(config_defines, macroname, &macrolen);
683 boolean bool_val;
684 if (macrovalue != NULL) {
685 if (!strcmp(macrovalue, "true")) bool_val = TRUE;
686 else if (!strcmp(macrovalue, "false")) bool_val = FALSE;
687 else {
688 config_read_error("Macro `%s' cannot be interpreted as boolean value: "
689 "`%s'", macroname, macrovalue);
690 bool_val = FALSE;
691 }
692 } else {
693 config_read_error("No macro or environmental variable defined with name "
694 "`%s'", macroname);
695 bool_val = FALSE;
696 }
697 Free(macroname);
698 if (whether_update_buffer()) cfg->config_read_buffer =
699 mputprintf(cfg->config_read_buffer, "%s ", bool_val ? "true" : "false");
700 return BooleanValue;
701}
702
703{MACRO_INT} {
704 char *macroname = get_macro_id_from_ref(yytext);
705 size_t macrolen = 0;
706 BIGNUM *BN_0 = BN_new();
707 BN_set_word(BN_0, 0);
708 const char *macrovalue =
709 string_map_get_bykey(config_defines, macroname, &macrolen);
710 if (macrovalue != NULL) {
711 if (string_is_int(macrovalue, macrolen)) {
712 yylval.int_val = NULL;
713 BN_dec2bn(&yylval.int_val,
714 *macrovalue == '+' ? macrovalue + 1 : macrovalue);
715 } else {
716 config_read_error("Macro `%s' cannot be interpreted as integer value: "
717 "`%s'", macroname, macrovalue);
718 yylval.int_val = BN_dup(BN_0);
719 }
720 } else {
721 config_read_error("No macro or environmental variable defined with name "
722 "`%s'", macroname);
723 yylval.int_val = BN_dup(BN_0);
724 }
725 BN_free(BN_0);
726 Free(macroname);
727 char *int_val_str = BN_bn2dec(yylval.int_val);
728 if (whether_update_buffer())
729 cfg->config_read_buffer = mputprintf(cfg->config_read_buffer, "%s ", int_val_str);
730 OPENSSL_free(int_val_str);
731 return Number;
732}
733
734{MACRO_FLOAT} {
735 char *macroname = get_macro_id_from_ref(yytext);
736 size_t macrolen;
737 const char *macrovalue =
738 string_map_get_bykey(config_defines, macroname, &macrolen);
739 if (macrovalue != NULL) {
740 if (string_is_float(macrovalue, macrolen))
741 yylval.float_val = atof(macrovalue);
742 else {
743 config_read_error("Macro `%s' cannot be interpreted as float value: "
744 "`%s'", macroname, macrovalue);
745 yylval.float_val = 0.0;
746 }
747 } else {
748 config_read_error("No macro or environmental variable defined"
749 " with name `%s'", macroname);
750 yylval.float_val = 0.0;
751 }
752 Free(macroname);
753 if (whether_update_buffer()) cfg->config_read_buffer =
754 mputprintf(cfg->config_read_buffer, "%f ", yylval.float_val);
755 return Float;
756}
757
758{MACRO_ID} {
759 char *macroname = get_macro_id_from_ref(yytext);
760 size_t macrolen;
761 const char *macrovalue =
762 string_map_get_bykey(config_defines, macroname, &macrolen);
763 boolean is_asn = FALSE;
764 if (macrovalue != NULL) {
765 if (string_is_id(macrovalue, macrolen)) {
766 yylval.str_val = mcopystr(macrovalue);
767 for (size_t i = 0; i < macrolen; i++) {
768 if (yylval.str_val[i] == '-') {
769 is_asn = TRUE;
770 yylval.str_val[i] = '_';
771 }
772 }
773 if (is_asn) config_read_warning("`%s' is not a valid TTCN-3 identifier. "
774 "Did you mean `%s'?", macrovalue, yylval.str_val);
775 if (whether_update_buffer()) cfg->config_read_buffer =
776 mputprintf(cfg->config_read_buffer, "%s ", yylval.str_val);
777 } else {
778 config_read_error("Macro `%s' cannot be interpreted as identifier: `%s'",
779 macroname, macrovalue);
780 yylval.str_val = NULL;
781 }
782 } else {
783 config_read_error("No macro or environmental variable defined with name "
784 "`%s'", macroname);
785 yylval.str_val = NULL;
786 }
787 Free(macroname);
788 return Identifier;
789}
790
791{MACRO_CSTR} {
792 char *macroname;
793 if (yytext[1] == '{') macroname = get_macro_id_from_ref(yytext);
794 else macroname = mcopystr(yytext + 1);
795 size_t macrolen;
796 const char *macrovalue = string_map_get_bykey
797 (config_defines, macroname, &macrolen);
798 if (macrovalue == NULL) {
799 config_read_error("No macro or environmental variable defined with "
800 "name `%s'", macroname);
801 yylval.str_val = memptystr();
802 Free(macroname);
803 return Cstring;
804 }
805
806 if (macrolen > 0 && macrovalue[0] == '{') { // structured
807 main_buffer = YY_CURRENT_BUFFER;
808 expansion_buffer = yy_scan_string(macrovalue);
809 yy_switch_to_buffer(expansion_buffer);
810 Free(macroname);
811 } else {
812 if (whether_update_buffer()) {
813 cfg->config_read_buffer=mputc(cfg->config_read_buffer, '"');
814 for (size_t i = 0; i < macrolen; i++) {
815 switch (macrovalue[i]) {
816 case '"':
817 cfg->config_read_buffer = mputstr(cfg->config_read_buffer, "\\\"");
818 break;
819 case '\\':
820 cfg->config_read_buffer = mputstr(cfg->config_read_buffer, "\\\\");
821 break;
822 case '\0':
823 cfg->config_read_buffer = mputstr(cfg->config_read_buffer, "\\000");
824 break;
825 default:
826 cfg->config_read_buffer = mputc(cfg->config_read_buffer, macrovalue[i]);
827 } /* switch */
828 } /* for */
829 cfg->config_read_buffer=mputstr(cfg->config_read_buffer, "\" ");
830 }
831 Free(macroname);
832 yylval.str_val = mcopystr(macrovalue);
833 return Cstring;
834 }
835}
836
837{MACRO_BSTR} {
838 char *macroname = get_macro_id_from_ref(yytext);
839 size_t macrolen;
840 const char *macrovalue =
841 string_map_get_bykey(config_defines, macroname, &macrolen);
842 if (macrovalue != NULL) {
843 if (string_is_bstr(macrovalue, macrolen)) {
844 if (whether_update_buffer()) cfg->config_read_buffer =
845 mputprintf(cfg->config_read_buffer, "'%s'B ", macrovalue);
846 } else config_read_error("Macro `%s' cannot be interpreted as bitstring "
847 "value: `%s'", macroname, macrovalue);
848 } else config_read_error("No macro or environmental variable defined with "
849 "name `%s'", macroname);
850 Free(macroname);
851 return Bstring;
852}
853
854{MACRO_HSTR} {
855 char *macroname = get_macro_id_from_ref(yytext);
856 size_t macrolen;
857 const char *macrovalue =
858 string_map_get_bykey(config_defines, macroname, &macrolen);
859 if (macrovalue != NULL) {
860 if (string_is_hstr(macrovalue, macrolen)) {
861 if (whether_update_buffer()) cfg->config_read_buffer =
862 mputprintf(cfg->config_read_buffer, "'%s'H ", macrovalue);
863 } else config_read_error("Macro `%s' cannot be interpreted as hexstring "
864 "value: `%s'", macroname, macrovalue);
865 } else config_read_error("No macro or environmental variable defined with "
866 "name `%s'", macroname);
867 Free(macroname);
868 return Hstring;
869}
870
871{MACRO_OSTR} {
872 char *macroname = get_macro_id_from_ref(yytext);
873 size_t macrolen;
874 const char *macrovalue =
875 string_map_get_bykey(config_defines, macroname, &macrolen);
876 if (macrovalue != NULL) {
877 if (string_is_ostr(macrovalue, macrolen)) {
878 if (whether_update_buffer()) cfg->config_read_buffer =
879 mputprintf(cfg->config_read_buffer, "'%s'O ", macrovalue);
880 } else config_read_error("Macro `%s' cannot be interpreted as octetstring "
881 "value: `%s'", macroname, macrovalue);
882 } else config_read_error("No macro or environmental variable defined with "
883 "name `%s'", macroname);
884 Free(macroname);
885 return Ostring;
886}
887
888{MACRO_BINARY} {
889 char *macroname = get_macro_id_from_ref(yytext);
890 size_t macrolen;
891 const char *macrovalue =
892 string_map_get_bykey(config_defines, macroname, &macrolen);
893 if (macrovalue != NULL) {
894 if (whether_update_buffer()) {
895 cfg->config_read_buffer = mputc(cfg->config_read_buffer, '\'');
896 for (size_t i = 0; i < macrolen; i++) {
897 cfg->config_read_buffer = mputprintf(cfg->config_read_buffer, "%02X",
898 macrovalue[i]);
899 }
900 cfg->config_read_buffer = mputstr(cfg->config_read_buffer, "'O ");
901 }
902 } else config_read_error("No macro or environmental variable defined with "
903 "name `%s'", macroname);
904 Free(macroname);
905 return Ostring;
906}
907
908{MACRO_HOSTNAME} {
909 char *macroname = get_macro_id_from_ref(yytext);
910 size_t macrolen;
911 const char *macrovalue =
912 string_map_get_bykey(config_defines, macroname, &macrolen);
913 if (macrovalue != NULL) {
914 if (string_is_hostname(macrovalue, macrolen)) {
915 if (whether_update_buffer()) {
916 for (size_t i = 0; i < macrolen; i++) {
917 cfg->config_read_buffer =
918 mputc(cfg->config_read_buffer, tolower(macrovalue[i]));
919 }
920 yylval.str_val = NULL;
921 } else {
922 yylval.str_val = (char*)Malloc(macrolen + 1);
923 for (size_t i = 0; i < macrolen; i++)
924 yylval.str_val[i] = tolower(macrovalue[i]);
925 yylval.str_val[macrolen] = '\0';
926 }
927 } else {
928 config_read_error("Macro `%s' cannot be interpreted as host name: "
929 "`%s'", macroname, macrovalue);
930 yylval.str_val = NULL;
931 }
932 } else {
933 config_read_error("No macro or environmental variable defined with "
934 "name `%s'", macroname);
935 yylval.str_val = NULL;
936 }
937 Free(macroname);
938 return DNSName;
939}
940
941":="|"=" RETURN(AssignmentChar);
942"&=" RETURN(ConcatChar);
943
944. RETURN(yytext[0]);
945
946<*><<EOF>> {
947 if (expansion_buffer) {
948 yy_switch_to_buffer(main_buffer);
949 yy_delete_buffer(expansion_buffer);
950 expansion_buffer = NULL;
951 } else {
952 if (YY_START == SC_blockcomment) {
953 config_read_error("Unterminated block "
954 "comment (missing */ at the end of file).");
955 return EOF;
956 } else {
957 if (include_chain->size() > 1) {
958 yy_delete_buffer(YY_CURRENT_BUFFER);
959 fclose(include_chain->back().fp);
960 include_chain->pop_back();
961 yy_switch_to_buffer(include_chain->back().buffer_state);
962 yylineno = include_chain->back().line_number;
963 BEGIN(SC_ORDERED_INCLUDE);
964 } else {
965 return EOF;
966 }
967 }
968 }
969}
970
971%%
972
973static void update_buffer()
974{
975 if (whether_update_buffer()) {
976 cfg->config_read_buffer = mputstr(cfg->config_read_buffer, yytext);
977 cfg->config_read_buffer = mputc (cfg->config_read_buffer, ' ');
978 }
979}
980
981static boolean whether_update_buffer()
982{
983 switch (YY_START) {
984 case SC_MODULE_PARAMETERS:
985 case SC_LOGGING:
986 case SC_TESTPORT_PARAMETERS:
987 case SC_EXTERNAL_COMMANDS:
a38c6d4c 988 case SC_PROFILER:
970ed795
EL
989 return TRUE;
990 default:
991 return FALSE;
992 } /* switch */
993}
994
995void config_read_reset(const char* current_filename_) {
996 if (!include_chain) {
997 include_chain = new std::deque<IncludeElem<YY_BUFFER_STATE> >();
998 }
999
1000 include_chain->clear();
1001 include_chain->push_back(
1002 IncludeElem<YY_BUFFER_STATE>(std::string(current_filename_), config_read_in));
1003}
1004
1005void config_read_close() {
1006 delete include_chain;
1007 include_chain = NULL;
1008}
1009
This page took 0.084201 seconds and 5 git commands to generate.