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 ******************************************************************************/
10 %option never-interactive
22 #include <openssl/crypto.h>
23 #include <openssl/bn.h>
25 #include "../../common/cfg_process_utils.hh"
26 #include "../../common/Path2.hh"
27 #include "../../common/config_preproc.h"
29 #include "../../common/memory.h"
30 #include "../mctr/config_data.h"
31 #include "../../core/Types.h"
32 #include "config_read.tab.hh"
34 //#include "../../common/dbgnew.hh"
36 extern string_map_t *config_defines;
38 #define yylval config_read_lval
40 /* This buffer stores the state of the main buffer
41 while the macro expansion is happening. */
42 static 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. */
46 static YY_BUFFER_STATE expansion_buffer = NULL;
48 static void update_buffer();
49 static boolean whether_update_buffer();
51 #define RETURN(x) do {update_buffer(); return (x);} while(0)
53 void config_read_warning(const char *warning_str, ...);
54 extern void config_read_error(const char *error_str, ...);
55 extern config_data *cfg;
57 static std::deque<IncludeElem<YY_BUFFER_STATE> >* include_chain = NULL;
59 std::string get_cfg_read_current_file() {
60 if (include_chain && !include_chain->empty()) {
61 return include_chain->back().get_full_path();
71 LINECOMMENT ("//"|"#")[^\r\n]*{NEWLINE}
73 NUMBER 0|([1-9][0-9]*)
75 FLOAT [+-]?({NUMBER}\.[0-9]+)|((({NUMBER}(\.[0-9]+)?)|(\.[0-9]+))[Ee][+-]?{NUMBER})
80 BITSTRINGMATCH '{BINMATCH}*'B
81 BITSTRING_BAD '[^']*'B
85 HEXMATCH [0-9A-Fa-f\?\*]
86 HEXSTRINGMATCH '{HEXMATCH}*'H
87 HEXSTRING_BAD '[^']*'H
91 OCTMATCH {HEX}{HEX}|\?|\*
92 OCTETSTRINGMATCH '{OCTMATCH}*'O
93 OCTETSTRING_BAD '[^']*'O
97 TTCN3IDENTIFIER [A-Za-z][A-Za-z0-9_]*
98 ASN1LOWERIDENTIFIER [a-z](-?[A-Za-z0-9]+)*
100 MACRORVALUE ([0-9A-Za-z._-]+)|{IPV6}
101 MACRO_CSTR \${TTCN3IDENTIFIER}|\$"{"{WS}{TTCN3IDENTIFIER}{WS}(","{WS}charstring{WS})?"}"
102 MACRO_BOOL \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}boolean{WS}"}"
103 MACRO_FLOAT \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}float{WS}"}"
104 MACRO_ID \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}identifier{WS}"}"
105 MACRO_INT \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}integer{WS}"}"
106 MACRO_BSTR \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}bitstring{WS}"}"
107 MACRO_HSTR \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}hexstring{WS}"}"
108 MACRO_OSTR \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}octetstring{WS}"}"
109 MACRO_BINARY \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}binaryoctet{WS}"}"
110 MACRO_HOSTNAME \$"{"{WS}{TTCN3IDENTIFIER}{WS}","{WS}hostname{WS}"}"
112 CHAR [^\\\"]|\\([\\\'\"\?abfnrtv]|{NEWLINE}|[0-7]{1,3}|x{HEX}{1,2})|\"\"
113 CHARSTRING \"{CHAR}*\"
115 HOSTNAME [A-Za-z0-9]([A-Za-z0-9_\-]*[A-Za-z0-9])?
116 DNSNAME {HOSTNAME}(\.{HOSTNAME})*\.?
118 /* Example: fe80::c002:37ff:fe6c:0%fastethernet0/0 */
119 IPV6 [0-9A-Fa-f:.]+(%[0-9A-Za-z]+)?
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
124 %s SC_COMPONENTS SC_EXTERNAL_COMMANDS SC_MAIN_CONTROLLER SC_INCLUDE SC_PROFILER
127 int comment_caller = INITIAL;
131 /* Eat up comments and whitespaces */
134 comment_caller = YY_START;
135 BEGIN(SC_blockcomment);
139 "*/" BEGIN(comment_caller);
143 {LINECOMMENT}|{WHITESPACE}|{NEWLINE}
145 /* Section delimiters */
147 <*>"["{WS}MODULE_PARAMETERS{WS}"]" {
148 if (YY_START!=SC_blockcomment) {
149 BEGIN(SC_MODULE_PARAMETERS);
150 RETURN(ModuleParametersKeyword);
154 <*>"["{WS}LOGGING{WS}"]" {
155 if (YY_START!=SC_blockcomment) {
157 RETURN(LoggingKeyword);
161 <*>"["{WS}PROFILER{WS}"]" {
162 if (YY_START!=SC_blockcomment) {
164 RETURN(ProfilerKeyword);
168 <*>"["{WS}TESTPORT_PARAMETERS{WS}"]" {
169 if (YY_START!=SC_blockcomment) {
170 BEGIN(SC_TESTPORT_PARAMETERS);
171 RETURN(TestportParametersKeyword);
175 <*>"["{WS}EXECUTE{WS}"]" {
176 if (YY_START!=SC_blockcomment) {
178 RETURN(ExecuteKeyword);
182 <*>"["{WS}EXTERNAL_COMMANDS{WS}"]" {
183 if (YY_START!=SC_blockcomment) {
184 BEGIN(SC_EXTERNAL_COMMANDS);
185 RETURN(ExternalCommandsKeyword);
189 <*>"["{WS}GROUPS{WS}"]" {
190 if (YY_START!=SC_blockcomment) {
192 RETURN(GroupsKeyword);
196 <*>"["{WS}COMPONENTS{WS}"]" {
197 if (YY_START!=SC_blockcomment) {
198 BEGIN(SC_COMPONENTS);
199 RETURN(ComponentsKeyword);
203 <*>"["{WS}MAIN_CONTROLLER{WS}"]" {
204 if (YY_START!=SC_blockcomment) {
205 BEGIN(SC_MAIN_CONTROLLER);
206 RETURN(MainControllerKeyword);
210 <*>"["{WS}INCLUDE{WS}"]" {
211 if (YY_START!=SC_blockcomment) {
213 RETURN(IncludeKeyword);
217 <*>"["{WS}ORDERED_INCLUDE{WS}"]" {
218 if (YY_START!=SC_blockcomment) {
219 BEGIN(SC_ORDERED_INCLUDE);
224 <*>"["{WS}DEFINE{WS}"]" {
225 if (YY_START!=SC_blockcomment) {
227 RETURN(DefineKeyword);
231 /* Rules for SC_DEFINE must precede everything else */
236 comment_caller = SC_DEFINE;
237 BEGIN(SC_blockcomment);
240 {CHARSTRING} /* eats string */
244 {NEWLINE} /* this is not in . */
248 . /* eats unnecessary things */
252 <SC_ORDERED_INCLUDE>{
255 comment_caller = YY_START;
256 BEGIN(SC_blockcomment);
259 \" { BEGIN(SC_CSTRING); }
263 {NEWLINE} /* this is not in . */
267 . /* eat unnecessary chars */
277 std::string error_msg = switch_lexer(include_chain, cstring,
278 YY_CURRENT_BUFFER, yy_create_buffer, yy_switch_to_buffer, yylineno,
280 if (error_msg.empty()) {
283 config_read_error(error_msg.c_str());
287 } /* end of string */
289 \\[\\'"?] cstring += yytext[1]; /* backslash-quoted \ or " or ' or ? */
290 \\{NEWLINE} yylineno++;
301 sscanf(yytext + 1, "%o", &c);
302 if (c <= 255) cstring += c;
303 else config_read_error("Invalid octal character code in string literal");
308 sscanf(yytext + 2, "%x", &c);
312 \\(x[^\\\"]|.) config_read_error("Invalid excape sequence in string literal.");
315 cstring.append(yytext, yyleng);
320 cstring += yytext[0];
326 <SC_PROFILER>{HEX}+ {
327 /* numeric statistics filter (check this before checking NUMBERs) */
328 RETURN(ProfilerStatsFlag);
335 yylval.int_val = NULL;
336 BN_dec2bn(&yylval.int_val, *yytext == '+' ? yytext + 1 : yytext);
337 if (YY_START == SC_MODULE_PARAMETERS) {
344 yylval.float_val = atof(yytext);
345 if (YY_START == SC_MODULE_PARAMETERS) {
351 {BITSTRING} RETURN(Bstring);
353 {BITSTRINGMATCH} RETURN(BstringMatch);
356 config_read_error("Invalid bitstring value.");
360 {HEXSTRING} RETURN(Hstring);
362 {HEXSTRINGMATCH} RETURN(HstringMatch);
365 config_read_error("Invalid hexstring value.");
369 {OCTETSTRING} RETURN(Ostring);
371 {OCTETSTRINGMATCH} RETURN(OstringMatch);
374 config_read_error("Invalid octetstring value.");
378 {BINSTRING_BAD} config_read_error("Invalid string value.");
380 ' config_read_error("Unmatched ' character.");
383 yylval.str_val = mcopystrn(yytext, yyleng);
384 if (YY_START == SC_MODULE_PARAMETERS) {
390 /* Section-wide keywords */
392 <SC_MODULE_PARAMETERS>
394 NULL RETURN(NULLKeyword);
395 null RETURN(nullKeyword);
396 char RETURN(CharKeyword);
397 objid RETURN(ObjIdKeyword);
398 omit RETURN(OmitKeyword);
403 error RETURN(VerdictValue);
404 complement RETURN(ComplementKeyword);
405 "\.\." RETURN(DotDot);
406 superset RETURN(SupersetKeyword);
407 subset RETURN(SubsetKeyword);
408 pattern RETURN(PatternKeyword);
409 permutation RETURN(PermutationKeyword);
410 length RETURN(LengthKeyword);
411 ifpresent RETURN(IfpresentKeyword);
412 infinity RETURN(InfinityKeyword);
415 <SC_MODULE_PARAMETERS,SC_LOGGING,SC_PROFILER>
418 false RETURN(BooleanValue);
421 <SC_MODULE_PARAMETERS,SC_LOGGING,SC_TESTPORT_PARAMETERS>
423 mtc RETURN(MTCKeyword);
424 system RETURN(SystemKeyword);
430 [Ll]og[Ff]ile RETURN(LogFile);
432 [Ee]mergency[Ll]ogging RETURN(EmergencyLogging);
434 [Ee]mergency[Ll]ogging[Bb]ehaviour RETURN(EmergencyLoggingBehaviour);
437 [Bb]uffer[Ma]asked RETURN(EmergencyLoggingBehaviourValue);
439 [Ee]mergency[Ll]ogging[Mm]ask RETURN(EmergencyLoggingMask);
442 [Ff]ile[Mm]ask RETURN(FileMask);
444 [Cc]onsole[Mm]ask RETURN(ConsoleMask);
446 [Tt]ime[Ss]tamp[Ff]ormat RETURN(TimestampFormat);
447 [Cc]onsole[Tt]ime[Ss]tamp[Ff]ormat RETURN(ConsoleTimestampFormat);
449 [Ll]og[Ss]ource[Ii]nfo |
450 [Ss]ource[Ii]nfo[Ff]ormat RETURN(SourceInfoFormat);
452 [Aa]ppend[Ff]ile RETURN(AppendFile);
454 [Ll]og[Ee]vent[Tt]ypes RETURN(LogEventTypes);
456 [Ll]og[Ee]ntity[Nn]ame RETURN(LogEntityName);
458 [Ll]og[Ff]ile[Ss]ize RETURN(LogFileSize);
460 [Ll]og[Ff]ile[Nn]umber RETURN(LogFileNumber);
462 [Dd]isk[Ff]ull[Aa]ction RETURN(DiskFullAction);
464 [Mm]atching[Hh]ints RETURN(MatchingHints);
466 [Ll]ogger[Pp]lugins RETURN(LoggerPlugins);
468 LOG_NOTHING RETURN(LoggingBit);
485 LOG_ALL RETURN(LoggingBitCollection);
492 DEFAULTOP_DEACTIVATE |
494 DEFAULTOP_UNQUALIFIED |
497 EXECUTOR_CONFIGDATA |
498 EXECUTOR_EXTCOMMAND |
499 EXECUTOR_LOGOPTIONS |
501 EXECUTOR_UNQUALIFIED |
503 FUNCTION_UNQUALIFIED |
515 MATCHING_UNQUALIFIED |
519 PARALLEL_UNQUALIFIED |
533 PORTEVENT_UNQUALIFIED |
534 STATISTICS_UNQUALIFIED |
538 TESTCASE_UNQUALIFIED |
544 TIMEROP_UNQUALIFIED |
547 VERDICTOP_GETVERDICT |
548 VERDICTOP_SETVERDICT |
549 VERDICTOP_UNQUALIFIED |
550 WARNING_UNQUALIFIED RETURN(LoggingBit);
552 [Tt][Ii][Mm][Ee] {yylval.ts_val=TSF_TIME; RETURN(TimestampValue);}
553 [Dd][Aa][Tt][Ee][Tt][Ii][Mm][Ee] {yylval.ts_val=TSF_DATE_TIME; RETURN(TimestampValue);}
554 [Ss][Ee][Cc][Oo][Nn][Dd][Ss] {yylval.ts_val=TSF_SEC; RETURN(TimestampValue);}
557 [Ss][Ii][Nn][Gg][Ll][Ee] |
558 [Ss][Tt][Aa][Cc][Kk] RETURN(SourceInfoValue);
561 [Nn][Oo] RETURN(YesNo);
563 [Dd]etailed RETURN(Detailed);
564 [Cc]ompact RETURN(Compact);
565 [Ss]ub[Cc]ategories RETURN(SubCategories);
567 [Ee]rror RETURN(Error);
569 [Ss]top RETURN(Stop);
571 [Rr]etry RETURN(Re_try);
573 [Dd]elete RETURN(Delete);
578 [Dd]isable[Pp]rofiler RETURN(DisableProfilerKeyword);
579 [Dd]isable[Cc]overage RETURN(DisableCoverageKeyword);
580 [Dd]ata[Bb]ase[Ff]ile RETURN(DatabaseFileKeyword);
581 [Aa]ggregate[Dd]ata RETURN(AggregateDataKeyword);
582 [Ss]tatistics[Ff]ile RETURN(StatisticsFileKeyword);
583 [Dd]isable[Ss]tatistics RETURN(DisableStatisticsKeyword);
584 [Ss]tatistics[Ff]ilter RETURN(StatisticsFilterKeyword);
585 [Ss]tart[Aa]utomatically RETURN(StartAutomaticallyKeyword);
586 [Nn]et[Ll]ine[Tt]imes RETURN(NetLineTimesKeyword);
587 [Nn]et[Ff]unction[Tt]imes RETURN(NetFunctionTimesKeyword);
589 /* statistics filters */
590 [Nn]umber[Oo]f[Ll]ines |
591 [Ll]ine[Dd]ata[Rr]aw |
592 [Ff]unc[Dd]ata[Rr]aw |
593 [Ll]ine[Aa]vg[Rr]aw |
594 [Ff]unc[Aa]vg[Rr]aw |
595 [Ll]ine[Tt]imes[Ss]orted[Bb]y[Mm]od |
596 [Ff]unc[Tt]imes[Ss]orted[Bb]y[Mm]od |
597 [Ll]ine[Tt]imes[Ss]orted[Tt]otal |
598 [Ff]unc[Tt]imes[Ss]orted[Tt]otal |
599 [Ll]ine[Cc]ount[Ss]orted[Bb]y[Mm]od |
600 [Ff]unc[Cc]ount[Ss]orted[Bb]y[Mm]od |
601 [Ll]ine[Cc]ount[Ss]orted[Tt]otal |
602 [Ff]unc[Cc]ount[Ss]orted[Tt]otal |
603 [Ll]ine[Aa]vg[Ss]orted[Bb]y[Mm]od |
604 [Ff]unc[Aa]vg[Ss]orted[Bb]y[Mm]od |
605 [Ll]ine[Aa]vg[Ss]orted[Tt]otal |
606 [Ff]unc[Aa]vg[Ss]orted[Tt]otal |
607 [Tt]op10[Ll]ine[Tt]imes |
608 [Tt]op10[Ff]unc[Tt]imes |
609 [Tt]op10[Ll]ine[Cc]ount |
610 [Tt]op10[Ff]unc[Cc]ount |
611 [Tt]op10[Ll]ine[Aa]vg |
612 [Tt]op10[Ff]unc[Aa]vg |
615 [Aa]ll[Rr]aw[Dd]ata |
616 [Ll]ine[Dd]ata[Ss]orted[Bb]y[Mm]od |
617 [Ff]unc[Dd]ata[Ss]orted[Bb]y[Mm]od |
618 [Ll]ine[Dd]ata[Ss]orted[Tt]otal |
619 [Ff]unc[Dd]ata[Ss]orted[Tt]otal |
620 [Ll]ine[Dd]ata[Ss]orted |
621 [Ff]unc[Dd]ata[Ss]orted |
622 [Aa]ll[Dd]ata[Ss]orted |
623 [Tt]op10[Ll]ine[Dd]ata |
624 [Tt]op10[Ff]unc[Dd]ata |
625 [Tt]op10[Aa]ll[Dd]ata |
627 [Aa]ll RETURN(ProfilerStatsFlag);
630 <SC_EXECUTE>control RETURN(ControlKeyword);
632 <SC_EXTERNAL_COMMANDS>
634 [Bb]egin[Cc]ontrol[Pp]art RETURN(BeginControlPart);
635 [Ee]nd[Cc]ontrol[Pp]art RETURN(EndControlPart);
636 [Bb]egin[Tt]est[Cc]ase RETURN(BeginTestCase);
637 [Ee]nd[Tt]est[Cc]ase RETURN(EndTestCase);
642 [Ll]ocal[Aa]ddress RETURN(LocalAddress);
643 [Tt][Cc][Pp][Pp]ort RETURN(TCPPort);
644 [Kk]ill[Tt]imer RETURN(KillTimer);
645 [Nn]um[Hh][Cc]s RETURN(NumHCs);
646 [Uu]nix[Ss]ockets[Ee]nabled RETURN(UnixSocketEnabled);
647 [Yy][Ee][Ss] RETURN(YesToken);
648 [Nn][Oo] RETURN(NoToken);
656 case SC_MAIN_CONTROLLER:
657 yylval.str_val = (char*)Malloc(yyleng + 1);
658 memcpy(yylval.str_val, yytext, yyleng + 1);
661 yylval.str_val = NULL;
666 <SC_MODULE_PARAMETERS>{ASN1LOWERIDENTIFIER} {
667 char *ttcn3_id = (char*)Malloc(yyleng + 1);
668 for (size_t i = 0; i < yyleng; i++) {
669 if (yytext[i] == '-') ttcn3_id[i] = '_';
670 else ttcn3_id[i] = yytext[i];
672 ttcn3_id[yyleng] = '\0';
673 config_read_warning("`%s' is not a valid TTCN-3 identifier. Did you mean "
674 "`%s'?", yytext, ttcn3_id);
675 cfg->config_read_buffer = mputprintf(cfg->config_read_buffer, "%s ", ttcn3_id);
677 return ASN1LowerIdentifier;
680 <SC_GROUPS,SC_COMPONENTS,SC_MAIN_CONTROLLER>{DNSNAME}|{IPV6} {
681 yylval.str_val = (char*)Malloc(yyleng + 1);
682 for (size_t i = 0; i < yyleng; i++) yylval.str_val[i] = tolower(yytext[i]);
683 yylval.str_val[yyleng] = '\0';
688 char *macroname = get_macro_id_from_ref(yytext);
690 const char *macrovalue =
691 string_map_get_bykey(config_defines, macroname, ¯olen);
693 if (macrovalue != NULL) {
694 if (!strcmp(macrovalue, "true")) bool_val = TRUE;
695 else if (!strcmp(macrovalue, "false")) bool_val = FALSE;
697 config_read_error("Macro `%s' cannot be interpreted as boolean value: "
698 "`%s'", macroname, macrovalue);
702 config_read_error("No macro or environmental variable defined with name "
707 if (whether_update_buffer()) cfg->config_read_buffer =
708 mputprintf(cfg->config_read_buffer, "%s ", bool_val ? "true" : "false");
713 char *macroname = get_macro_id_from_ref(yytext);
715 BIGNUM *BN_0 = BN_new();
716 BN_set_word(BN_0, 0);
717 const char *macrovalue =
718 string_map_get_bykey(config_defines, macroname, ¯olen);
719 if (macrovalue != NULL) {
720 if (string_is_int(macrovalue, macrolen)) {
721 yylval.int_val = NULL;
722 BN_dec2bn(&yylval.int_val,
723 *macrovalue == '+' ? macrovalue + 1 : macrovalue);
725 config_read_error("Macro `%s' cannot be interpreted as integer value: "
726 "`%s'", macroname, macrovalue);
727 yylval.int_val = BN_dup(BN_0);
730 config_read_error("No macro or environmental variable defined with name "
732 yylval.int_val = BN_dup(BN_0);
736 char *int_val_str = BN_bn2dec(yylval.int_val);
737 if (whether_update_buffer())
738 cfg->config_read_buffer = mputprintf(cfg->config_read_buffer, "%s ", int_val_str);
739 OPENSSL_free(int_val_str);
740 if (YY_START == SC_MODULE_PARAMETERS) {
747 char *macroname = get_macro_id_from_ref(yytext);
749 const char *macrovalue =
750 string_map_get_bykey(config_defines, macroname, ¯olen);
751 if (macrovalue != NULL) {
752 if (string_is_float(macrovalue, macrolen))
753 yylval.float_val = atof(macrovalue);
755 config_read_error("Macro `%s' cannot be interpreted as float value: "
756 "`%s'", macroname, macrovalue);
757 yylval.float_val = 0.0;
760 config_read_error("No macro or environmental variable defined"
761 " with name `%s'", macroname);
762 yylval.float_val = 0.0;
765 if (whether_update_buffer()) cfg->config_read_buffer =
766 mputprintf(cfg->config_read_buffer, "%f ", yylval.float_val);
767 if (YY_START == SC_MODULE_PARAMETERS) {
774 char *macroname = get_macro_id_from_ref(yytext);
776 const char *macrovalue =
777 string_map_get_bykey(config_defines, macroname, ¯olen);
778 boolean is_asn = FALSE;
779 if (macrovalue != NULL) {
780 if (string_is_id(macrovalue, macrolen)) {
781 yylval.str_val = mcopystr(macrovalue);
782 for (size_t i = 0; i < macrolen; i++) {
783 if (yylval.str_val[i] == '-') {
785 yylval.str_val[i] = '_';
788 if (is_asn) config_read_warning("`%s' is not a valid TTCN-3 identifier. "
789 "Did you mean `%s'?", macrovalue, yylval.str_val);
790 if (whether_update_buffer()) cfg->config_read_buffer =
791 mputprintf(cfg->config_read_buffer, "%s ", yylval.str_val);
793 config_read_error("Macro `%s' cannot be interpreted as identifier: `%s'",
794 macroname, macrovalue);
795 yylval.str_val = NULL;
798 config_read_error("No macro or environmental variable defined with name "
800 yylval.str_val = NULL;
808 if (yytext[1] == '{') macroname = get_macro_id_from_ref(yytext);
809 else macroname = mcopystr(yytext + 1);
811 const char *macrovalue = string_map_get_bykey
812 (config_defines, macroname, ¯olen);
813 if (macrovalue == NULL) {
814 config_read_error("No macro or environmental variable defined with "
815 "name `%s'", macroname);
816 yylval.str_val = memptystr();
818 if (YY_START == SC_MODULE_PARAMETERS) {
824 if (macrolen > 0 && macrovalue[0] == '{') { // structured
825 main_buffer = YY_CURRENT_BUFFER;
826 expansion_buffer = yy_scan_string(macrovalue);
827 yy_switch_to_buffer(expansion_buffer);
830 if (whether_update_buffer()) {
831 cfg->config_read_buffer=mputc(cfg->config_read_buffer, '"');
832 for (size_t i = 0; i < macrolen; i++) {
833 switch (macrovalue[i]) {
835 cfg->config_read_buffer = mputstr(cfg->config_read_buffer, "\\\"");
838 cfg->config_read_buffer = mputstr(cfg->config_read_buffer, "\\\\");
841 cfg->config_read_buffer = mputstr(cfg->config_read_buffer, "\\000");
844 cfg->config_read_buffer = mputc(cfg->config_read_buffer, macrovalue[i]);
847 cfg->config_read_buffer=mputstr(cfg->config_read_buffer, "\" ");
850 yylval.str_val = mcopystr(macrovalue);
851 if (YY_START == SC_MODULE_PARAMETERS) {
859 char *macroname = get_macro_id_from_ref(yytext);
861 const char *macrovalue =
862 string_map_get_bykey(config_defines, macroname, ¯olen);
863 if (macrovalue != NULL) {
864 if (string_is_bstr(macrovalue, macrolen)) {
865 if (whether_update_buffer()) cfg->config_read_buffer =
866 mputprintf(cfg->config_read_buffer, "'%s'B ", macrovalue);
867 } else config_read_error("Macro `%s' cannot be interpreted as bitstring "
868 "value: `%s'", macroname, macrovalue);
869 } else config_read_error("No macro or environmental variable defined with "
870 "name `%s'", macroname);
876 char *macroname = get_macro_id_from_ref(yytext);
878 const char *macrovalue =
879 string_map_get_bykey(config_defines, macroname, ¯olen);
880 if (macrovalue != NULL) {
881 if (string_is_hstr(macrovalue, macrolen)) {
882 if (whether_update_buffer()) cfg->config_read_buffer =
883 mputprintf(cfg->config_read_buffer, "'%s'H ", macrovalue);
884 } else config_read_error("Macro `%s' cannot be interpreted as hexstring "
885 "value: `%s'", macroname, macrovalue);
886 } else config_read_error("No macro or environmental variable defined with "
887 "name `%s'", macroname);
893 char *macroname = get_macro_id_from_ref(yytext);
895 const char *macrovalue =
896 string_map_get_bykey(config_defines, macroname, ¯olen);
897 if (macrovalue != NULL) {
898 if (string_is_ostr(macrovalue, macrolen)) {
899 if (whether_update_buffer()) cfg->config_read_buffer =
900 mputprintf(cfg->config_read_buffer, "'%s'O ", macrovalue);
901 } else config_read_error("Macro `%s' cannot be interpreted as octetstring "
902 "value: `%s'", macroname, macrovalue);
903 } else config_read_error("No macro or environmental variable defined with "
904 "name `%s'", macroname);
910 char *macroname = get_macro_id_from_ref(yytext);
912 const char *macrovalue =
913 string_map_get_bykey(config_defines, macroname, ¯olen);
914 if (macrovalue != NULL) {
915 if (whether_update_buffer()) {
916 cfg->config_read_buffer = mputc(cfg->config_read_buffer, '\'');
917 for (size_t i = 0; i < macrolen; i++) {
918 cfg->config_read_buffer = mputprintf(cfg->config_read_buffer, "%02X",
921 cfg->config_read_buffer = mputstr(cfg->config_read_buffer, "'O ");
923 } else config_read_error("No macro or environmental variable defined with "
924 "name `%s'", macroname);
930 char *macroname = get_macro_id_from_ref(yytext);
932 const char *macrovalue =
933 string_map_get_bykey(config_defines, macroname, ¯olen);
934 if (macrovalue != NULL) {
935 if (string_is_hostname(macrovalue, macrolen)) {
936 if (whether_update_buffer()) {
937 for (size_t i = 0; i < macrolen; i++) {
938 cfg->config_read_buffer =
939 mputc(cfg->config_read_buffer, tolower(macrovalue[i]));
941 yylval.str_val = NULL;
943 yylval.str_val = (char*)Malloc(macrolen + 1);
944 for (size_t i = 0; i < macrolen; i++)
945 yylval.str_val[i] = tolower(macrovalue[i]);
946 yylval.str_val[macrolen] = '\0';
949 config_read_error("Macro `%s' cannot be interpreted as host name: "
950 "`%s'", macroname, macrovalue);
951 yylval.str_val = NULL;
954 config_read_error("No macro or environmental variable defined with "
955 "name `%s'", macroname);
956 yylval.str_val = NULL;
962 ":="|"=" RETURN(AssignmentChar);
963 "&=" RETURN(ConcatChar);
968 if (expansion_buffer) {
969 yy_switch_to_buffer(main_buffer);
970 yy_delete_buffer(expansion_buffer);
971 expansion_buffer = NULL;
973 if (YY_START == SC_blockcomment) {
974 config_read_error("Unterminated block "
975 "comment (missing */ at the end of file).");
978 if (include_chain->size() > 1) {
979 yy_delete_buffer(YY_CURRENT_BUFFER);
980 fclose(include_chain->back().fp);
981 include_chain->pop_back();
982 yy_switch_to_buffer(include_chain->back().buffer_state);
983 yylineno = include_chain->back().line_number;
984 BEGIN(SC_ORDERED_INCLUDE);
994 static void update_buffer()
996 if (whether_update_buffer()) {
997 cfg->config_read_buffer = mputstr(cfg->config_read_buffer, yytext);
998 cfg->config_read_buffer = mputc (cfg->config_read_buffer, ' ');
1002 static boolean whether_update_buffer()
1005 case SC_MODULE_PARAMETERS:
1007 case SC_TESTPORT_PARAMETERS:
1008 case SC_EXTERNAL_COMMANDS:
1016 void config_read_reset(const char* current_filename_) {
1017 if (!include_chain) {
1018 include_chain = new std::deque<IncludeElem<YY_BUFFER_STATE> >();
1021 include_chain->clear();
1022 include_chain->push_back(
1023 IncludeElem<YY_BUFFER_STATE>(std::string(current_filename_), config_read_in));
1026 void config_read_close() {
1027 delete include_chain;
1028 include_chain = NULL;