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 ******************************************************************************/
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];
329 yylval.int_val = NULL;
330 BN_dec2bn(&yylval.int_val, *yytext == '+' ? yytext + 1 : yytext);
335 yylval.float_val = atof(yytext);
339 {BITSTRING} RETURN(Bstring);
341 {BITSTRINGMATCH} RETURN(BstringMatch);
344 config_read_error("Invalid bitstring value.");
348 {HEXSTRING} RETURN(Hstring);
350 {HEXSTRINGMATCH} RETURN(HstringMatch);
353 config_read_error("Invalid hexstring value.");
357 {OCTETSTRING} RETURN(Ostring);
359 {OCTETSTRINGMATCH} RETURN(OstringMatch);
362 config_read_error("Invalid octetstring value.");
366 {BINSTRING_BAD} config_read_error("Invalid string value.");
368 ' config_read_error("Unmatched ' character.");
371 yylval.str_val = mcopystrn(yytext, yyleng);
375 /* Section-wide keywords */
377 <SC_MODULE_PARAMETERS>
379 NULL RETURN(NULLKeyword);
380 null RETURN(nullKeyword);
381 char RETURN(CharKeyword);
382 objid RETURN(ObjIdKeyword);
383 omit RETURN(OmitKeyword);
388 error RETURN(VerdictValue);
389 complement RETURN(ComplementKeyword);
390 "\.\." RETURN(DotDot);
391 superset RETURN(SupersetKeyword);
392 subset RETURN(SubsetKeyword);
393 pattern RETURN(PatternKeyword);
394 permutation RETURN(PermutationKeyword);
395 length RETURN(LengthKeyword);
396 ifpresent RETURN(IfpresentKeyword);
397 infinity RETURN(InfinityKeyword);
400 <SC_MODULE_PARAMETERS,SC_LOGGING,SC_PROFILER>
403 false RETURN(BooleanValue);
406 <SC_MODULE_PARAMETERS,SC_LOGGING,SC_TESTPORT_PARAMETERS>
408 mtc RETURN(MTCKeyword);
409 system RETURN(SystemKeyword);
415 [Ll]og[Ff]ile RETURN(LogFile);
417 [Ee]mergency[Ll]ogging RETURN(EmergencyLogging);
419 [Ee]mergency[Ll]ogging[Bb]ehaviour RETURN(EmergencyLoggingBehaviour);
422 [Bb]uffer[Ma]asked RETURN(EmergencyLoggingBehaviourValue);
424 [Ee]mergency[Ll]ogging[Mm]ask RETURN(EmergencyLoggingMask);
427 [Ff]ile[Mm]ask RETURN(FileMask);
429 [Cc]onsole[Mm]ask RETURN(ConsoleMask);
431 [Tt]ime[Ss]tamp[Ff]ormat RETURN(TimestampFormat);
432 [Cc]onsole[Tt]ime[Ss]tamp[Ff]ormat RETURN(ConsoleTimestampFormat);
434 [Ll]og[Ss]ource[Ii]nfo |
435 [Ss]ource[Ii]nfo[Ff]ormat RETURN(SourceInfoFormat);
437 [Aa]ppend[Ff]ile RETURN(AppendFile);
439 [Ll]og[Ee]vent[Tt]ypes RETURN(LogEventTypes);
441 [Ll]og[Ee]ntity[Nn]ame RETURN(LogEntityName);
443 [Ll]og[Ff]ile[Ss]ize RETURN(LogFileSize);
445 [Ll]og[Ff]ile[Nn]umber RETURN(LogFileNumber);
447 [Dd]isk[Ff]ull[Aa]ction RETURN(DiskFullAction);
449 [Mm]atching[Hh]ints RETURN(MatchingHints);
451 [Ll]ogger[Pp]lugins RETURN(LoggerPlugins);
453 LOG_NOTHING RETURN(LoggingBit);
470 LOG_ALL RETURN(LoggingBitCollection);
477 DEFAULTOP_DEACTIVATE |
479 DEFAULTOP_UNQUALIFIED |
482 EXECUTOR_CONFIGDATA |
483 EXECUTOR_EXTCOMMAND |
484 EXECUTOR_LOGOPTIONS |
486 EXECUTOR_UNQUALIFIED |
488 FUNCTION_UNQUALIFIED |
500 MATCHING_UNQUALIFIED |
504 PARALLEL_UNQUALIFIED |
518 PORTEVENT_UNQUALIFIED |
519 STATISTICS_UNQUALIFIED |
523 TESTCASE_UNQUALIFIED |
529 TIMEROP_UNQUALIFIED |
532 VERDICTOP_GETVERDICT |
533 VERDICTOP_SETVERDICT |
534 VERDICTOP_UNQUALIFIED |
535 WARNING_UNQUALIFIED RETURN(LoggingBit);
537 [Tt][Ii][Mm][Ee] {yylval.ts_val=TSF_TIME; RETURN(TimestampValue);}
538 [Dd][Aa][Tt][Ee][Tt][Ii][Mm][Ee] {yylval.ts_val=TSF_DATE_TIME; RETURN(TimestampValue);}
539 [Ss][Ee][Cc][Oo][Nn][Dd][Ss] {yylval.ts_val=TSF_SEC; RETURN(TimestampValue);}
542 [Ss][Ii][Nn][Gg][Ll][Ee] |
543 [Ss][Tt][Aa][Cc][Kk] RETURN(SourceInfoValue);
546 [Nn][Oo] RETURN(YesNo);
548 [Dd]etailed RETURN(Detailed);
549 [Cc]ompact RETURN(Compact);
550 [Ss]ub[Cc]ategories RETURN(SubCategories);
552 [Ee]rror RETURN(Error);
554 [Ss]top RETURN(Stop);
556 [Rr]etry RETURN(Re_try);
558 [Dd]elete RETURN(Delete);
563 [Dd]isable[Pp]rofiler return DisableProfilerKeyword;
564 [Dd]isable[Cc]overage return DisableCoverageKeyword;
565 [Dd]ata[Bb]ase[Ff]ile return DatabaseFileKeyword;
566 [Aa]ggregate[Dd]ata return AggregateDataKeyword;
567 [Ss]tatistics[Ff]ile return StatisticsFileKeyword;
568 [Dd]isable[Ss]tatistics return DisableStatisticsKeyword;
571 <SC_EXECUTE>control RETURN(ControlKeyword);
573 <SC_EXTERNAL_COMMANDS>
575 [Bb]egin[Cc]ontrol[Pp]art RETURN(BeginControlPart);
576 [Ee]nd[Cc]ontrol[Pp]art RETURN(EndControlPart);
577 [Bb]egin[Tt]est[Cc]ase RETURN(BeginTestCase);
578 [Ee]nd[Tt]est[Cc]ase RETURN(EndTestCase);
583 [Ll]ocal[Aa]ddress RETURN(LocalAddress);
584 [Tt][Cc][Pp][Pp]ort RETURN(TCPPort);
585 [Kk]ill[Tt]imer RETURN(KillTimer);
586 [Nn]um[Hh][Cc]s RETURN(NumHCs);
587 [Uu]nix[Ss]ockets[Ee]nabled RETURN(UnixSocketEnabled);
588 [Yy][Ee][Ss] RETURN(YesToken);
589 [Nn][Oo] RETURN(NoToken);
597 case SC_MAIN_CONTROLLER:
598 yylval.str_val = (char*)Malloc(yyleng + 1);
599 memcpy(yylval.str_val, yytext, yyleng + 1);
602 yylval.str_val = NULL;
607 <SC_MODULE_PARAMETERS>{ASN1LOWERIDENTIFIER} {
608 char *ttcn3_id = (char*)Malloc(yyleng + 1);
609 for (int i = 0; i < yyleng; i++) {
610 if (yytext[i] == '-') ttcn3_id[i] = '_';
611 else ttcn3_id[i] = yytext[i];
613 ttcn3_id[yyleng] = '\0';
614 config_read_warning("`%s' is not a valid TTCN-3 identifier. Did you mean "
615 "`%s'?", yytext, ttcn3_id);
616 cfg->config_read_buffer = mputprintf(cfg->config_read_buffer, "%s ", ttcn3_id);
618 return ASN1LowerIdentifier;
621 <SC_GROUPS,SC_COMPONENTS,SC_MAIN_CONTROLLER>{DNSNAME}|{IPV6} {
622 yylval.str_val = (char*)Malloc(yyleng + 1);
623 for (int i = 0; i < yyleng; i++) yylval.str_val[i] = tolower(yytext[i]);
624 yylval.str_val[yyleng] = '\0';
629 char *macroname = get_macro_id_from_ref(yytext);
631 const char *macrovalue =
632 string_map_get_bykey(config_defines, macroname, ¯olen);
634 if (macrovalue != NULL) {
635 if (!strcmp(macrovalue, "true")) bool_val = TRUE;
636 else if (!strcmp(macrovalue, "false")) bool_val = FALSE;
638 config_read_error("Macro `%s' cannot be interpreted as boolean value: "
639 "`%s'", macroname, macrovalue);
643 config_read_error("No macro or environmental variable defined with name "
648 if (whether_update_buffer()) cfg->config_read_buffer =
649 mputprintf(cfg->config_read_buffer, "%s ", bool_val ? "true" : "false");
654 char *macroname = get_macro_id_from_ref(yytext);
656 BIGNUM *BN_0 = BN_new();
657 BN_set_word(BN_0, 0);
658 const char *macrovalue =
659 string_map_get_bykey(config_defines, macroname, ¯olen);
660 if (macrovalue != NULL) {
661 if (string_is_int(macrovalue, macrolen)) {
662 yylval.int_val = NULL;
663 BN_dec2bn(&yylval.int_val,
664 *macrovalue == '+' ? macrovalue + 1 : macrovalue);
666 config_read_error("Macro `%s' cannot be interpreted as integer value: "
667 "`%s'", macroname, macrovalue);
668 yylval.int_val = BN_dup(BN_0);
671 config_read_error("No macro or environmental variable defined with name "
673 yylval.int_val = BN_dup(BN_0);
677 char *int_val_str = BN_bn2dec(yylval.int_val);
678 if (whether_update_buffer())
679 cfg->config_read_buffer = mputprintf(cfg->config_read_buffer, "%s ", int_val_str);
680 OPENSSL_free(int_val_str);
685 char *macroname = get_macro_id_from_ref(yytext);
687 const char *macrovalue =
688 string_map_get_bykey(config_defines, macroname, ¯olen);
689 if (macrovalue != NULL) {
690 if (string_is_float(macrovalue, macrolen))
691 yylval.float_val = atof(macrovalue);
693 config_read_error("Macro `%s' cannot be interpreted as float value: "
694 "`%s'", macroname, macrovalue);
695 yylval.float_val = 0.0;
698 config_read_error("No macro or environmental variable defined"
699 " with name `%s'", macroname);
700 yylval.float_val = 0.0;
703 if (whether_update_buffer()) cfg->config_read_buffer =
704 mputprintf(cfg->config_read_buffer, "%f ", yylval.float_val);
709 char *macroname = get_macro_id_from_ref(yytext);
711 const char *macrovalue =
712 string_map_get_bykey(config_defines, macroname, ¯olen);
713 boolean is_asn = FALSE;
714 if (macrovalue != NULL) {
715 if (string_is_id(macrovalue, macrolen)) {
716 yylval.str_val = mcopystr(macrovalue);
717 for (size_t i = 0; i < macrolen; i++) {
718 if (yylval.str_val[i] == '-') {
720 yylval.str_val[i] = '_';
723 if (is_asn) config_read_warning("`%s' is not a valid TTCN-3 identifier. "
724 "Did you mean `%s'?", macrovalue, yylval.str_val);
725 if (whether_update_buffer()) cfg->config_read_buffer =
726 mputprintf(cfg->config_read_buffer, "%s ", yylval.str_val);
728 config_read_error("Macro `%s' cannot be interpreted as identifier: `%s'",
729 macroname, macrovalue);
730 yylval.str_val = NULL;
733 config_read_error("No macro or environmental variable defined with name "
735 yylval.str_val = NULL;
743 if (yytext[1] == '{') macroname = get_macro_id_from_ref(yytext);
744 else macroname = mcopystr(yytext + 1);
746 const char *macrovalue = string_map_get_bykey
747 (config_defines, macroname, ¯olen);
748 if (macrovalue == NULL) {
749 config_read_error("No macro or environmental variable defined with "
750 "name `%s'", macroname);
751 yylval.str_val = memptystr();
756 if (macrolen > 0 && macrovalue[0] == '{') { // structured
757 main_buffer = YY_CURRENT_BUFFER;
758 expansion_buffer = yy_scan_string(macrovalue);
759 yy_switch_to_buffer(expansion_buffer);
762 if (whether_update_buffer()) {
763 cfg->config_read_buffer=mputc(cfg->config_read_buffer, '"');
764 for (size_t i = 0; i < macrolen; i++) {
765 switch (macrovalue[i]) {
767 cfg->config_read_buffer = mputstr(cfg->config_read_buffer, "\\\"");
770 cfg->config_read_buffer = mputstr(cfg->config_read_buffer, "\\\\");
773 cfg->config_read_buffer = mputstr(cfg->config_read_buffer, "\\000");
776 cfg->config_read_buffer = mputc(cfg->config_read_buffer, macrovalue[i]);
779 cfg->config_read_buffer=mputstr(cfg->config_read_buffer, "\" ");
782 yylval.str_val = mcopystr(macrovalue);
788 char *macroname = get_macro_id_from_ref(yytext);
790 const char *macrovalue =
791 string_map_get_bykey(config_defines, macroname, ¯olen);
792 if (macrovalue != NULL) {
793 if (string_is_bstr(macrovalue, macrolen)) {
794 if (whether_update_buffer()) cfg->config_read_buffer =
795 mputprintf(cfg->config_read_buffer, "'%s'B ", macrovalue);
796 } else config_read_error("Macro `%s' cannot be interpreted as bitstring "
797 "value: `%s'", macroname, macrovalue);
798 } else config_read_error("No macro or environmental variable defined with "
799 "name `%s'", macroname);
805 char *macroname = get_macro_id_from_ref(yytext);
807 const char *macrovalue =
808 string_map_get_bykey(config_defines, macroname, ¯olen);
809 if (macrovalue != NULL) {
810 if (string_is_hstr(macrovalue, macrolen)) {
811 if (whether_update_buffer()) cfg->config_read_buffer =
812 mputprintf(cfg->config_read_buffer, "'%s'H ", macrovalue);
813 } else config_read_error("Macro `%s' cannot be interpreted as hexstring "
814 "value: `%s'", macroname, macrovalue);
815 } else config_read_error("No macro or environmental variable defined with "
816 "name `%s'", macroname);
822 char *macroname = get_macro_id_from_ref(yytext);
824 const char *macrovalue =
825 string_map_get_bykey(config_defines, macroname, ¯olen);
826 if (macrovalue != NULL) {
827 if (string_is_ostr(macrovalue, macrolen)) {
828 if (whether_update_buffer()) cfg->config_read_buffer =
829 mputprintf(cfg->config_read_buffer, "'%s'O ", macrovalue);
830 } else config_read_error("Macro `%s' cannot be interpreted as octetstring "
831 "value: `%s'", macroname, macrovalue);
832 } else config_read_error("No macro or environmental variable defined with "
833 "name `%s'", macroname);
839 char *macroname = get_macro_id_from_ref(yytext);
841 const char *macrovalue =
842 string_map_get_bykey(config_defines, macroname, ¯olen);
843 if (macrovalue != NULL) {
844 if (whether_update_buffer()) {
845 cfg->config_read_buffer = mputc(cfg->config_read_buffer, '\'');
846 for (size_t i = 0; i < macrolen; i++) {
847 cfg->config_read_buffer = mputprintf(cfg->config_read_buffer, "%02X",
850 cfg->config_read_buffer = mputstr(cfg->config_read_buffer, "'O ");
852 } else config_read_error("No macro or environmental variable defined with "
853 "name `%s'", macroname);
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_hostname(macrovalue, macrolen)) {
865 if (whether_update_buffer()) {
866 for (size_t i = 0; i < macrolen; i++) {
867 cfg->config_read_buffer =
868 mputc(cfg->config_read_buffer, tolower(macrovalue[i]));
870 yylval.str_val = NULL;
872 yylval.str_val = (char*)Malloc(macrolen + 1);
873 for (size_t i = 0; i < macrolen; i++)
874 yylval.str_val[i] = tolower(macrovalue[i]);
875 yylval.str_val[macrolen] = '\0';
878 config_read_error("Macro `%s' cannot be interpreted as host name: "
879 "`%s'", macroname, macrovalue);
880 yylval.str_val = NULL;
883 config_read_error("No macro or environmental variable defined with "
884 "name `%s'", macroname);
885 yylval.str_val = NULL;
891 ":="|"=" RETURN(AssignmentChar);
892 "&=" RETURN(ConcatChar);
897 if (expansion_buffer) {
898 yy_switch_to_buffer(main_buffer);
899 yy_delete_buffer(expansion_buffer);
900 expansion_buffer = NULL;
902 if (YY_START == SC_blockcomment) {
903 config_read_error("Unterminated block "
904 "comment (missing */ at the end of file).");
907 if (include_chain->size() > 1) {
908 yy_delete_buffer(YY_CURRENT_BUFFER);
909 fclose(include_chain->back().fp);
910 include_chain->pop_back();
911 yy_switch_to_buffer(include_chain->back().buffer_state);
912 yylineno = include_chain->back().line_number;
913 BEGIN(SC_ORDERED_INCLUDE);
923 static void update_buffer()
925 if (whether_update_buffer()) {
926 cfg->config_read_buffer = mputstr(cfg->config_read_buffer, yytext);
927 cfg->config_read_buffer = mputc (cfg->config_read_buffer, ' ');
931 static boolean whether_update_buffer()
934 case SC_MODULE_PARAMETERS:
936 case SC_TESTPORT_PARAMETERS:
937 case SC_EXTERNAL_COMMANDS:
944 void config_read_reset(const char* current_filename_) {
945 if (!include_chain) {
946 include_chain = new std::deque<IncludeElem<YY_BUFFER_STATE> >();
949 include_chain->clear();
950 include_chain->push_back(
951 IncludeElem<YY_BUFFER_STATE>(std::string(current_filename_), config_read_in));
954 void config_read_close() {
955 delete include_chain;
956 include_chain = NULL;