diff --git a/src/host/host_parser.c b/src/host/host_parser.c index 3c7cd788a7..52cc6be122 100644 --- a/src/host/host_parser.c +++ b/src/host/host_parser.c @@ -161,7 +161,15 @@ typedef unsigned int flex_uint32_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else #define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -521,7 +529,7 @@ char *host_text; #define YY_USER_ACTION llocp->first_line = host_lineno; \ llocp->first_column = llocp->last_column; \ llocp->last_column += host_leng; -#line 525 "host_parser.c" +#line 533 "host_parser.c" #define INITIAL 0 @@ -600,7 +608,12 @@ static int input (void ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else #define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -705,7 +718,7 @@ YY_DECL /* --- Tokens --- */ -#line 709 "host_parser.c" +#line 722 "host_parser.c" if ( !(yy_init) ) { @@ -842,7 +855,7 @@ YY_RULE_SETUP #line 64 "host_parser.l" ECHO; YY_BREAK -#line 846 "host_parser.c" +#line 859 "host_parser.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1568,8 +1581,8 @@ YY_BUFFER_STATE host__scan_string (yyconst char * yystr ) /** Setup the input buffer state to scan the given bytes. The next call to host_lex() will * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * * @return the newly allocated buffer state object. */ diff --git a/src/host/host_parser.h b/src/host/host_parser.h index ba83d7fa1e..0c97ce22f1 100644 --- a/src/host/host_parser.h +++ b/src/host/host_parser.h @@ -115,7 +115,15 @@ typedef unsigned int flex_uint32_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else #define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ #endif #ifndef YY_TYPEDEF_YY_BUFFER_STATE @@ -278,7 +286,12 @@ static int yy_flex_strlen (yyconst char * ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else #define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ #endif /* Number of entries by which start-condition stack grows. */ @@ -314,6 +327,6 @@ extern int host_lex (void); #line 64 "host_parser.l" -#line 318 "host_parser.h" +#line 331 "host_parser.h" #undef host_IN_HEADER #endif /* host_HEADER_H */ diff --git a/src/template/template_parser.c b/src/template/template_parser.c index 2575c0a48c..7e2c61d35b 100644 --- a/src/template/template_parser.c +++ b/src/template/template_parser.c @@ -161,7 +161,15 @@ typedef unsigned int flex_uint32_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else #define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -551,7 +559,7 @@ char *template_text; llocp->first_column = llocp->last_column; \ llocp->last_column += template_leng; -#line 555 "template_parser.c" +#line 563 "template_parser.c" #define INITIAL 0 #define VALUE 1 @@ -631,7 +639,12 @@ static int input (void ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else #define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -738,7 +751,7 @@ YY_DECL /* ------------------------------------------------------------------------- */ /* Comments (lines with an starting #), and empty lines */ /* ------------------------------------------------------------------------- */ -#line 742 "template_parser.c" +#line 755 "template_parser.c" if ( !(yy_init) ) { @@ -917,7 +930,7 @@ YY_RULE_SETUP #line 85 "template_parser.l" ECHO; YY_BREAK -#line 921 "template_parser.c" +#line 934 "template_parser.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(VALUE): yyterminate(); @@ -1644,8 +1657,8 @@ YY_BUFFER_STATE template__scan_string (yyconst char * yystr ) /** Setup the input buffer state to scan the given bytes. The next call to template_lex() will * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * * @return the newly allocated buffer state object. */ diff --git a/src/template/template_parser.h b/src/template/template_parser.h index a8438064d7..ce7af28c0e 100644 --- a/src/template/template_parser.h +++ b/src/template/template_parser.h @@ -115,7 +115,15 @@ typedef unsigned int flex_uint32_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else #define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ #endif #ifndef YY_TYPEDEF_YY_BUFFER_STATE @@ -279,7 +287,12 @@ static int yy_flex_strlen (yyconst char * ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else #define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ #endif /* Number of entries by which start-condition stack grows. */ @@ -315,6 +328,6 @@ extern int template_lex (void); #line 85 "template_parser.l" -#line 319 "template_parser.h" +#line 332 "template_parser.h" #undef template_IN_HEADER #endif /* template_HEADER_H */ diff --git a/src/vm/VirtualMachinePool.cc b/src/vm/VirtualMachinePool.cc index 24825a2e55..7e19beee49 100644 --- a/src/vm/VirtualMachinePool.cc +++ b/src/vm/VirtualMachinePool.cc @@ -211,10 +211,11 @@ pthread_mutex_t VirtualMachinePool::lex_mutex = PTHREAD_MUTEX_INITIALIZER; extern "C" { int vm_var_parse (VirtualMachinePool * vmpool, - ostringstream * parsed, - VirtualMachine * vm, - char ** errmsg); - + VirtualMachine * vm, + int vm_id, + ostringstream * parsed, + char ** errmsg); + int vm_var_lex_destroy(); YY_BUFFER_STATE vm_var__scan_string(const char * str); @@ -233,20 +234,12 @@ int VirtualMachinePool::parse_attribute(int vm_id, YY_BUFFER_STATE str_buffer; const char * str; int rc; - VirtualMachine * vm; ostringstream oss_parsed; *error_msg = 0; pthread_mutex_lock(&lex_mutex); - vm = get(vm_id,true); - - if ( vm == 0 ) - { - goto error_vm; - } - str = attribute.c_str(); str_buffer = vm_var__scan_string(str); @@ -255,28 +248,20 @@ int VirtualMachinePool::parse_attribute(int vm_id, goto error_yy; } - rc = vm_var_parse(this,&oss_parsed,vm,error_msg); + rc = vm_var_parse(this,0,vm_id,&oss_parsed,error_msg); vm_var__delete_buffer(str_buffer); vm_var_lex_destroy(); - vm->unlock(); - pthread_mutex_unlock(&lex_mutex); parsed = oss_parsed.str(); return rc; -error_vm: - *error_msg=strdup("Could not find virtual machine!"); - goto error_common; - error_yy: *error_msg=strdup("Error setting scan buffer"); - vm->unlock(); -error_common: pthread_mutex_unlock(&lex_mutex); return -1; } diff --git a/src/vm/vm_var_parser.c b/src/vm/vm_var_parser.c index 434281936c..3df7865c26 100644 --- a/src/vm/vm_var_parser.c +++ b/src/vm/vm_var_parser.c @@ -161,7 +161,15 @@ typedef unsigned int flex_uint32_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else #define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -534,7 +542,7 @@ char *vm_var_text; llocp->first_column = llocp->last_column; \ llocp->last_column += vm_var_leng; -#line 538 "vm_var_parser.c" +#line 546 "vm_var_parser.c" #define INITIAL 0 #define VAR 1 @@ -614,7 +622,12 @@ static int input (void ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else #define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -726,7 +739,7 @@ YY_DECL /* $NUM.CONTEXT_VARIABLE */ /* ------------------------------------------------------------------------- */ -#line 730 "vm_var_parser.c" +#line 743 "vm_var_parser.c" if ( !(yy_init) ) { @@ -869,20 +882,20 @@ case 9: YY_RULE_SETUP #line 66 "vm_var_parser.l" { lvalp->val_char = '\0'; - return BLANK;} + return EOA;} YY_BREAK case 10: YY_RULE_SETUP #line 68 "vm_var_parser.l" { lvalp->val_char = *vm_var_text; BEGIN(INITIAL); - return BLANK;} + return EOA;} YY_BREAK case YY_STATE_EOF(VAR): #line 71 "vm_var_parser.l" { lvalp->val_char = '\0'; BEGIN(INITIAL); - return BLANK;} + return EOA;} YY_BREAK /* ------------------------------------------------------------------------- */ /* Just copy the string verbatim till we find a variable (starts with $) */ @@ -898,7 +911,7 @@ YY_RULE_SETUP #line 81 "vm_var_parser.l" ECHO; YY_BREAK -#line 902 "vm_var_parser.c" +#line 915 "vm_var_parser.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1624,8 +1637,8 @@ YY_BUFFER_STATE vm_var__scan_string (yyconst char * yystr ) /** Setup the input buffer state to scan the given bytes. The next call to vm_var_lex() will * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * * @return the newly allocated buffer state object. */ diff --git a/src/vm/vm_var_parser.h b/src/vm/vm_var_parser.h index d9748caf7e..0ad8ed5343 100644 --- a/src/vm/vm_var_parser.h +++ b/src/vm/vm_var_parser.h @@ -115,7 +115,15 @@ typedef unsigned int flex_uint32_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else #define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ #endif #ifndef YY_TYPEDEF_YY_BUFFER_STATE @@ -279,7 +287,12 @@ static int yy_flex_strlen (yyconst char * ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else #define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ #endif /* Number of entries by which start-condition stack grows. */ @@ -315,6 +328,6 @@ extern int vm_var_lex (void); #line 81 "vm_var_parser.l" -#line 319 "vm_var_parser.h" +#line 332 "vm_var_parser.h" #undef vm_var_IN_HEADER #endif /* vm_var_HEADER_H */ diff --git a/src/vm/vm_var_parser.l b/src/vm/vm_var_parser.l index 984a4203fd..afe32fe395 100644 --- a/src/vm/vm_var_parser.l +++ b/src/vm/vm_var_parser.l @@ -64,13 +64,13 @@ return STRING;} \$ { lvalp->val_char = '\0'; - return BLANK;} + return EOA;} . { lvalp->val_char = *yytext; BEGIN(INITIAL); - return BLANK;} + return EOA;} <> { lvalp->val_char = '\0'; BEGIN(INITIAL); - return BLANK;} + return EOA;} /* ------------------------------------------------------------------------- */ /* Just copy the string verbatim till we find a variable (starts with $) */ diff --git a/src/vm/vm_var_syntax.cc b/src/vm/vm_var_syntax.cc index 466bedbd56..c301bcaccf 100644 --- a/src/vm/vm_var_syntax.cc +++ b/src/vm/vm_var_syntax.cc @@ -78,7 +78,7 @@ COMMA = 259, OBRACKET = 260, CBRACKET = 261, - BLANK = 262, + EOA = 262, STRING = 263, RSTRING = 264, INTEGER = 265 @@ -89,7 +89,7 @@ #define COMMA 259 #define OBRACKET 260 #define CBRACKET 261 -#define BLANK 262 +#define EOA 262 #define STRING 263 #define RSTRING 264 #define INTEGER 265 @@ -121,19 +121,124 @@ extern "C" void vm_var_error( YYLTYPE * llocp, VirtualMachinePool * vmpool, - ostringstream * parsed, VirtualMachine * vm, - char ** error_msg, + int vm_id, + ostringstream * parsed, + char ** errmsg, const char * str); int vm_var_lex (YYSTYPE *lvalp, YYLTYPE *llocp); int vm_var_parse (VirtualMachinePool * vmpool, - ostringstream * parsed, VirtualMachine * vm, + int vm_id, + ostringstream * parsed, char ** errmsg); } +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void insert_single(VirtualMachinePool * vmpool, + VirtualMachine * vm, + int vm_id, + ostringstream& parsed, + const string& name) +{ + VirtualMachine * tvm = vm; + string value = ""; + + if ( vm == 0 && vmpool != 0 ) + { + tvm = vmpool->get(vm_id,true); + } + + if ( tvm == 0 ) + { + return; + } + + tvm->get_template_attribute(name.c_str(),value); + + parsed << value; + + if ( vm == 0 ) + { + tvm->unlock(); + } +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void insert_vector(VirtualMachinePool * vmpool, + VirtualMachine * vm, + int vm_id, + ostringstream& parsed, + const string& name, + const string& vname, + const string& vvar, + const string& vval) + +{ + VirtualMachine * tvm = vm; + + vector values; + const VectorAttribute * vattr = 0; + + int num; + string value = ""; + + if ( vm == 0 && vmpool != 0 ) + { + tvm = vmpool->get(vm_id,true); + } + + if ( tvm == 0 ) + { + return; + } + + if ( ( num = tvm->get_template_attribute(name.c_str(),values) ) <= 0 ) + { + goto error_name; + } + + if ( vvar.empty() ) + { + vattr = dynamic_cast(values[0]); + } + else + { + const VectorAttribute * tmp = 0; + + for (int i=0 ; i < num ; i++) + { + tmp = dynamic_cast(values[i]); + + if ( tmp && ( tmp->vector_value(vvar.c_str()) == vval )) + { + vattr = tmp; + break; + } + } + } + + if ( vattr != 0 ) + { + parsed << vattr->vector_value(vname.c_str()); + } + +error_name: + if ( vm == 0 ) + { + tvm->unlock(); + } +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + /* Enabling traces. */ @@ -156,14 +261,14 @@ int vm_var_parse (VirtualMachinePool * vmpool, #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 60 "vm_var_syntax.y" +#line 166 "vm_var_syntax.y" { char * val_str; int val_int; char val_char; } /* Line 187 of yacc.c. */ -#line 167 "vm_var_syntax.cc" +#line 272 "vm_var_syntax.cc" YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 @@ -188,7 +293,7 @@ typedef struct YYLTYPE /* Line 216 of yacc.c. */ -#line 192 "vm_var_syntax.cc" +#line 297 "vm_var_syntax.cc" #ifdef short # undef short @@ -475,7 +580,7 @@ static const yytype_int8 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { - 0, 83, 83, 84, 87, 92, 113, 148, 191 + 0, 189, 189, 190, 193, 198, 213, 231, 254 }; #endif @@ -485,7 +590,7 @@ static const yytype_uint8 yyrline[] = static const char *const yytname[] = { "$end", "error", "$undefined", "EQUAL", "COMMA", "OBRACKET", "CBRACKET", - "BLANK", "STRING", "RSTRING", "INTEGER", "$accept", "vm_string", + "EOA", "STRING", "RSTRING", "INTEGER", "$accept", "vm_string", "vm_variable", 0 }; #endif @@ -602,7 +707,7 @@ do \ } \ else \ { \ - yyerror (&yylloc, vmpool, parsed, vm, errmsg, YY_("syntax error: cannot back up")); \ + yyerror (&yylloc, vmpool, vm, vm_id, parsed, errmsg, YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (YYID (0)) @@ -682,7 +787,7 @@ do { \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ - Type, Value, Location, vmpool, parsed, vm, errmsg); \ + Type, Value, Location, vmpool, vm, vm_id, parsed, errmsg); \ YYFPRINTF (stderr, "\n"); \ } \ } while (YYID (0)) @@ -696,17 +801,18 @@ do { \ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, VirtualMachinePool * vmpool, ostringstream * parsed, VirtualMachine * vm, char ** errmsg) +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, VirtualMachinePool * vmpool, VirtualMachine * vm, int vm_id, ostringstream * parsed, char ** errmsg) #else static void -yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, vmpool, parsed, vm, errmsg) +yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, vmpool, vm, vm_id, parsed, errmsg) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; YYLTYPE const * const yylocationp; VirtualMachinePool * vmpool; - ostringstream * parsed; VirtualMachine * vm; + int vm_id; + ostringstream * parsed; char ** errmsg; #endif { @@ -714,8 +820,9 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, vmpool, parsed, return; YYUSE (yylocationp); YYUSE (vmpool); - YYUSE (parsed); YYUSE (vm); + YYUSE (vm_id); + YYUSE (parsed); YYUSE (errmsg); # ifdef YYPRINT if (yytype < YYNTOKENS) @@ -738,17 +845,18 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, vmpool, parsed, #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, VirtualMachinePool * vmpool, ostringstream * parsed, VirtualMachine * vm, char ** errmsg) +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, VirtualMachinePool * vmpool, VirtualMachine * vm, int vm_id, ostringstream * parsed, char ** errmsg) #else static void -yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, vmpool, parsed, vm, errmsg) +yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, vmpool, vm, vm_id, parsed, errmsg) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; YYLTYPE const * const yylocationp; VirtualMachinePool * vmpool; - ostringstream * parsed; VirtualMachine * vm; + int vm_id; + ostringstream * parsed; char ** errmsg; #endif { @@ -759,7 +867,7 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, vmpool, parsed, vm, er YY_LOCATION_PRINT (yyoutput, *yylocationp); YYFPRINTF (yyoutput, ": "); - yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, vmpool, parsed, vm, errmsg); + yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, vmpool, vm, vm_id, parsed, errmsg); YYFPRINTF (yyoutput, ")"); } @@ -799,16 +907,17 @@ do { \ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, VirtualMachinePool * vmpool, ostringstream * parsed, VirtualMachine * vm, char ** errmsg) +yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, VirtualMachinePool * vmpool, VirtualMachine * vm, int vm_id, ostringstream * parsed, char ** errmsg) #else static void -yy_reduce_print (yyvsp, yylsp, yyrule, vmpool, parsed, vm, errmsg) +yy_reduce_print (yyvsp, yylsp, yyrule, vmpool, vm, vm_id, parsed, errmsg) YYSTYPE *yyvsp; YYLTYPE *yylsp; int yyrule; VirtualMachinePool * vmpool; - ostringstream * parsed; VirtualMachine * vm; + int vm_id; + ostringstream * parsed; char ** errmsg; #endif { @@ -823,7 +932,7 @@ yy_reduce_print (yyvsp, yylsp, yyrule, vmpool, parsed, vm, errmsg) fprintf (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) - , &(yylsp[(yyi + 1) - (yynrhs)]) , vmpool, parsed, vm, errmsg); + , &(yylsp[(yyi + 1) - (yynrhs)]) , vmpool, vm, vm_id, parsed, errmsg); fprintf (stderr, "\n"); } } @@ -831,7 +940,7 @@ yy_reduce_print (yyvsp, yylsp, yyrule, vmpool, parsed, vm, errmsg) # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ - yy_reduce_print (yyvsp, yylsp, Rule, vmpool, parsed, vm, errmsg); \ + yy_reduce_print (yyvsp, yylsp, Rule, vmpool, vm, vm_id, parsed, errmsg); \ } while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that @@ -1082,25 +1191,27 @@ yysyntax_error (char *yyresult, int yystate, int yychar) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, VirtualMachinePool * vmpool, ostringstream * parsed, VirtualMachine * vm, char ** errmsg) +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, VirtualMachinePool * vmpool, VirtualMachine * vm, int vm_id, ostringstream * parsed, char ** errmsg) #else static void -yydestruct (yymsg, yytype, yyvaluep, yylocationp, vmpool, parsed, vm, errmsg) +yydestruct (yymsg, yytype, yyvaluep, yylocationp, vmpool, vm, vm_id, parsed, errmsg) const char *yymsg; int yytype; YYSTYPE *yyvaluep; YYLTYPE *yylocationp; VirtualMachinePool * vmpool; - ostringstream * parsed; VirtualMachine * vm; + int vm_id; + ostringstream * parsed; char ** errmsg; #endif { YYUSE (yyvaluep); YYUSE (yylocationp); YYUSE (vmpool); - YYUSE (parsed); YYUSE (vm); + YYUSE (vm_id); + YYUSE (parsed); YYUSE (errmsg); if (!yymsg) @@ -1126,7 +1237,7 @@ int yyparse (); #endif #else /* ! YYPARSE_PARAM */ #if defined __STDC__ || defined __cplusplus -int yyparse (VirtualMachinePool * vmpool, ostringstream * parsed, VirtualMachine * vm, char ** errmsg); +int yyparse (VirtualMachinePool * vmpool, VirtualMachine * vm, int vm_id, ostringstream * parsed, char ** errmsg); #else int yyparse (); #endif @@ -1155,13 +1266,14 @@ yyparse (YYPARSE_PARAM) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) int -yyparse (VirtualMachinePool * vmpool, ostringstream * parsed, VirtualMachine * vm, char ** errmsg) +yyparse (VirtualMachinePool * vmpool, VirtualMachine * vm, int vm_id, ostringstream * parsed, char ** errmsg) #else int -yyparse (vmpool, parsed, vm, errmsg) +yyparse (vmpool, vm, vm_id, parsed, errmsg) VirtualMachinePool * vmpool; - ostringstream * parsed; VirtualMachine * vm; + int vm_id; + ostringstream * parsed; char ** errmsg; #endif #endif @@ -1433,7 +1545,7 @@ yyreduce: switch (yyn) { case 4: -#line 88 "vm_var_syntax.y" +#line 194 "vm_var_syntax.y" { (*parsed) << (yyvsp[(1) - (1)].val_str); free((yyvsp[(1) - (1)].val_str)); @@ -1441,56 +1553,33 @@ yyreduce: break; case 5: -#line 93 "vm_var_syntax.y" +#line 199 "vm_var_syntax.y" { string name((yyvsp[(1) - (2)].val_str)); - string value = ""; - + VM_VAR_TO_UPPER(name); - - vm->get_template_attribute(name.c_str(),value); - - if (!value.empty()) - { - (*parsed) << value; - } - + + insert_single(vmpool,vm,vm_id,*parsed,name); + if ( (yyvsp[(2) - (2)].val_char) != '\0' ) { (*parsed) << (yyvsp[(2) - (2)].val_char); } - + free((yyvsp[(1) - (2)].val_str)); ;} break; case 6: -#line 114 "vm_var_syntax.y" +#line 214 "vm_var_syntax.y" { - vector values; - const VectorAttribute * vattr; - string value = ""; - string name((yyvsp[(1) - (5)].val_str)); string vname((yyvsp[(3) - (5)].val_str)); - + VM_VAR_TO_UPPER(name); VM_VAR_TO_UPPER(vname); - if ( vm->get_template_attribute(name,values) > 0 ) - { - vattr = dynamic_cast(values[0]); - - if (vattr) - { - value = vattr->vector_value(vname.c_str()); - } - } - - if ( !value.empty() ) - { - (*parsed) << value; - } + insert_vector(vmpool,vm,vm_id,*parsed,name,vname,"",""); if ( (yyvsp[(5) - (5)].val_char) != '\0' ) { @@ -1503,39 +1592,19 @@ yyreduce: break; case 7: -#line 149 "vm_var_syntax.y" +#line 232 "vm_var_syntax.y" { - vector values; - const VectorAttribute * vattr; - - string value = ""; - string name((yyvsp[(1) - (9)].val_str)); string vname((yyvsp[(3) - (9)].val_str)); string vvar((yyvsp[(5) - (9)].val_str)); + string vval((yyvsp[(7) - (9)].val_str)); VM_VAR_TO_UPPER(name); VM_VAR_TO_UPPER(vname); VM_VAR_TO_UPPER(vvar); - int num = vm->get_template_attribute(name,values); - - for (int i=0 ; i < num ; i++) - { - vattr = dynamic_cast(values[i]); - - if (vattr && (vattr->vector_value(vvar.c_str())== (yyvsp[(7) - (9)].val_str))) - { - value = vattr->vector_value(vname.c_str()); - break; - } - } - - if ( !value.empty() ) - { - (*parsed) << value; - } - + insert_vector(vmpool,vm,vm_id,*parsed,name,vname,vvar,vval); + if ( (yyvsp[(9) - (9)].val_char) != '\0' ) { (*parsed) << (yyvsp[(9) - (9)].val_char); @@ -1549,39 +1618,15 @@ yyreduce: break; case 8: -#line 192 "vm_var_syntax.y" +#line 255 "vm_var_syntax.y" { - string name((yyvsp[(2) - (3)].val_str)); - string value = ""; - - VirtualMachine * tvm; - vector values; - const VectorAttribute * vattr; - - tvm = vmpool->get((yyvsp[(1) - (3)].val_int),true); - - if ( tvm != 0 ) - { - VM_VAR_TO_UPPER(name); - - if ( tvm->get_template_attribute("CONTEXT",values) > 0 ) - { - vattr=dynamic_cast (values[0]); - - if (vattr) - { - value = vattr->vector_value(name.c_str()); - } - } - - tvm->unlock(); - } - - if ( !value.empty() ) - { - (*parsed) << value; - } + string name("CONTEXT"); + string vname((yyvsp[(2) - (3)].val_str)); + VM_VAR_TO_UPPER(vname); + + insert_vector(vmpool,0,(yyvsp[(1) - (3)].val_int),*parsed,name,vname,"",""); + if ( (yyvsp[(3) - (3)].val_char) != '\0' ) { (*parsed) << (yyvsp[(3) - (3)].val_char); @@ -1593,7 +1638,7 @@ yyreduce: /* Line 1267 of yacc.c. */ -#line 1597 "vm_var_syntax.cc" +#line 1642 "vm_var_syntax.cc" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -1629,7 +1674,7 @@ yyerrlab: { ++yynerrs; #if ! YYERROR_VERBOSE - yyerror (&yylloc, vmpool, parsed, vm, errmsg, YY_("syntax error")); + yyerror (&yylloc, vmpool, vm, vm_id, parsed, errmsg, YY_("syntax error")); #else { YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); @@ -1653,11 +1698,11 @@ yyerrlab: if (0 < yysize && yysize <= yymsg_alloc) { (void) yysyntax_error (yymsg, yystate, yychar); - yyerror (&yylloc, vmpool, parsed, vm, errmsg, yymsg); + yyerror (&yylloc, vmpool, vm, vm_id, parsed, errmsg, yymsg); } else { - yyerror (&yylloc, vmpool, parsed, vm, errmsg, YY_("syntax error")); + yyerror (&yylloc, vmpool, vm, vm_id, parsed, errmsg, YY_("syntax error")); if (yysize != 0) goto yyexhaustedlab; } @@ -1681,7 +1726,7 @@ yyerrlab: else { yydestruct ("Error: discarding", - yytoken, &yylval, &yylloc, vmpool, parsed, vm, errmsg); + yytoken, &yylval, &yylloc, vmpool, vm, vm_id, parsed, errmsg); yychar = YYEMPTY; } } @@ -1738,7 +1783,7 @@ yyerrlab1: yyerror_range[0] = *yylsp; yydestruct ("Error: popping", - yystos[yystate], yyvsp, yylsp, vmpool, parsed, vm, errmsg); + yystos[yystate], yyvsp, yylsp, vmpool, vm, vm_id, parsed, errmsg); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -1781,7 +1826,7 @@ yyabortlab: | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: - yyerror (&yylloc, vmpool, parsed, vm, errmsg, YY_("memory exhausted")); + yyerror (&yylloc, vmpool, vm, vm_id, parsed, errmsg, YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif @@ -1789,7 +1834,7 @@ yyexhaustedlab: yyreturn: if (yychar != YYEOF && yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval, &yylloc, vmpool, parsed, vm, errmsg); + yytoken, &yylval, &yylloc, vmpool, vm, vm_id, parsed, errmsg); /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); @@ -1797,7 +1842,7 @@ yyreturn: while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp, yylsp, vmpool, parsed, vm, errmsg); + yystos[*yyssp], yyvsp, yylsp, vmpool, vm, vm_id, parsed, errmsg); YYPOPSTACK (1); } #ifndef yyoverflow @@ -1813,14 +1858,15 @@ yyreturn: } -#line 232 "vm_var_syntax.y" +#line 271 "vm_var_syntax.y" extern "C" void vm_var_error( YYLTYPE * llocp, VirtualMachinePool * vmpool, - ostringstream * parsed, VirtualMachine * vm, + int vm_id, + ostringstream * parsed, char ** error_msg, const char * str) { @@ -1829,7 +1875,7 @@ extern "C" void vm_var_error( length = strlen(str)+ 64; *error_msg = (char *) malloc(sizeof(char)*length); - + string nil = ""; if (*error_msg != 0) { snprintf(*error_msg, diff --git a/src/vm/vm_var_syntax.h b/src/vm/vm_var_syntax.h index 1df550f932..7045b74adc 100644 --- a/src/vm/vm_var_syntax.h +++ b/src/vm/vm_var_syntax.h @@ -43,7 +43,7 @@ COMMA = 259, OBRACKET = 260, CBRACKET = 261, - BLANK = 262, + EOA = 262, STRING = 263, RSTRING = 264, INTEGER = 265 @@ -54,7 +54,7 @@ #define COMMA 259 #define OBRACKET 260 #define CBRACKET 261 -#define BLANK 262 +#define EOA 262 #define STRING 263 #define RSTRING 264 #define INTEGER 265 @@ -64,7 +64,7 @@ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 60 "vm_var_syntax.y" +#line 166 "vm_var_syntax.y" { char * val_str; int val_int; diff --git a/src/vm/vm_var_syntax.y b/src/vm/vm_var_syntax.y index 58f96d10ed..89da7d8564 100644 --- a/src/vm/vm_var_syntax.y +++ b/src/vm/vm_var_syntax.y @@ -37,24 +37,130 @@ extern "C" void vm_var_error( YYLTYPE * llocp, VirtualMachinePool * vmpool, - ostringstream * parsed, VirtualMachine * vm, - char ** error_msg, + int vm_id, + ostringstream * parsed, + char ** errmsg, const char * str); int vm_var_lex (YYSTYPE *lvalp, YYLTYPE *llocp); int vm_var_parse (VirtualMachinePool * vmpool, - ostringstream * parsed, VirtualMachine * vm, + int vm_id, + ostringstream * parsed, char ** errmsg); } +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void insert_single(VirtualMachinePool * vmpool, + VirtualMachine * vm, + int vm_id, + ostringstream& parsed, + const string& name) +{ + VirtualMachine * tvm = vm; + string value = ""; + + if ( vm == 0 && vmpool != 0 ) + { + tvm = vmpool->get(vm_id,true); + } + + if ( tvm == 0 ) + { + return; + } + + tvm->get_template_attribute(name.c_str(),value); + + parsed << value; + + if ( vm == 0 ) + { + tvm->unlock(); + } +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void insert_vector(VirtualMachinePool * vmpool, + VirtualMachine * vm, + int vm_id, + ostringstream& parsed, + const string& name, + const string& vname, + const string& vvar, + const string& vval) + +{ + VirtualMachine * tvm = vm; + + vector values; + const VectorAttribute * vattr = 0; + + int num; + string value = ""; + + if ( vm == 0 && vmpool != 0 ) + { + tvm = vmpool->get(vm_id,true); + } + + if ( tvm == 0 ) + { + return; + } + + if ( ( num = tvm->get_template_attribute(name.c_str(),values) ) <= 0 ) + { + goto error_name; + } + + if ( vvar.empty() ) + { + vattr = dynamic_cast(values[0]); + } + else + { + const VectorAttribute * tmp = 0; + + for (int i=0 ; i < num ; i++) + { + tmp = dynamic_cast(values[i]); + + if ( tmp && ( tmp->vector_value(vvar.c_str()) == vval )) + { + vattr = tmp; + break; + } + } + } + + if ( vattr != 0 ) + { + parsed << vattr->vector_value(vname.c_str()); + } + +error_name: + if ( vm == 0 ) + { + tvm->unlock(); + } +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + %} %parse-param {VirtualMachinePool * vmpool} -%parse-param {ostringstream * parsed} %parse-param {VirtualMachine * vm} +%parse-param {int vm_id} +%parse-param {ostringstream * parsed} %parse-param {char ** errmsg} %union { @@ -71,7 +177,7 @@ int vm_var_parse (VirtualMachinePool * vmpool, %token EQUAL COMMA OBRACKET CBRACKET -%token BLANK +%token EOA %token STRING %token RSTRING %token INTEGER @@ -89,53 +195,30 @@ vm_variable:RSTRING (*parsed) << $1; free($1); } - | STRING BLANK + | STRING EOA { string name($1); - string value = ""; - + VM_VAR_TO_UPPER(name); - - vm->get_template_attribute(name.c_str(),value); - - if (!value.empty()) - { - (*parsed) << value; - } - + + insert_single(vmpool,vm,vm_id,*parsed,name); + if ( $2 != '\0' ) { (*parsed) << $2; } - + free($1); } - | STRING OBRACKET STRING CBRACKET BLANK + | STRING OBRACKET STRING CBRACKET EOA { - vector values; - const VectorAttribute * vattr; - string value = ""; - string name($1); string vname($3); - + VM_VAR_TO_UPPER(name); VM_VAR_TO_UPPER(vname); - if ( vm->get_template_attribute(name,values) > 0 ) - { - vattr = dynamic_cast(values[0]); - - if (vattr) - { - value = vattr->vector_value(vname.c_str()); - } - } - - if ( !value.empty() ) - { - (*parsed) << value; - } + insert_vector(vmpool,vm,vm_id,*parsed,name,vname,"",""); if ( $5 != '\0' ) { @@ -145,39 +228,19 @@ vm_variable:RSTRING free($1); free($3); } - | STRING OBRACKET STRING COMMA STRING EQUAL STRING CBRACKET BLANK + | STRING OBRACKET STRING COMMA STRING EQUAL STRING CBRACKET EOA { - vector values; - const VectorAttribute * vattr; - - string value = ""; - string name($1); string vname($3); string vvar($5); + string vval($7); VM_VAR_TO_UPPER(name); VM_VAR_TO_UPPER(vname); VM_VAR_TO_UPPER(vvar); - int num = vm->get_template_attribute(name,values); - - for (int i=0 ; i < num ; i++) - { - vattr = dynamic_cast(values[i]); - - if (vattr && (vattr->vector_value(vvar.c_str())== $7)) - { - value = vattr->vector_value(vname.c_str()); - break; - } - } - - if ( !value.empty() ) - { - (*parsed) << value; - } - + insert_vector(vmpool,vm,vm_id,*parsed,name,vname,vvar,vval); + if ( $9 != '\0' ) { (*parsed) << $9; @@ -188,39 +251,15 @@ vm_variable:RSTRING free($5); free($7); } - | INTEGER STRING BLANK + | INTEGER STRING EOA { - string name($2); - string value = ""; - - VirtualMachine * tvm; - vector values; - const VectorAttribute * vattr; - - tvm = vmpool->get($1,true); - - if ( tvm != 0 ) - { - VM_VAR_TO_UPPER(name); - - if ( tvm->get_template_attribute("CONTEXT",values) > 0 ) - { - vattr=dynamic_cast (values[0]); - - if (vattr) - { - value = vattr->vector_value(name.c_str()); - } - } - - tvm->unlock(); - } - - if ( !value.empty() ) - { - (*parsed) << value; - } + string name("CONTEXT"); + string vname($2); + VM_VAR_TO_UPPER(vname); + + insert_vector(vmpool,0,$1,*parsed,name,vname,"",""); + if ( $3 != '\0' ) { (*parsed) << $3; @@ -234,8 +273,9 @@ vm_variable:RSTRING extern "C" void vm_var_error( YYLTYPE * llocp, VirtualMachinePool * vmpool, - ostringstream * parsed, VirtualMachine * vm, + int vm_id, + ostringstream * parsed, char ** error_msg, const char * str) { @@ -244,7 +284,7 @@ extern "C" void vm_var_error( length = strlen(str)+ 64; *error_msg = (char *) malloc(sizeof(char)*length); - + string nil = ""; if (*error_msg != 0) { snprintf(*error_msg,