mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-02 09:47:00 +03:00
Blocking-free version of the VirtualMachine Attribute parser
git-svn-id: http://svn.opennebula.org/one/trunk@439 3034c82b-c49b-4eb3-8279-a7acafdc01c0
This commit is contained in:
parent
16772ef79d
commit
eb38f51eb6
@ -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.
|
||||
*/
|
||||
|
@ -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 */
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -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 */
|
||||
|
@ -64,13 +64,13 @@
|
||||
return STRING;}
|
||||
|
||||
<VAR>\$ { lvalp->val_char = '\0';
|
||||
return BLANK;}
|
||||
return EOA;}
|
||||
<VAR>. { lvalp->val_char = *yytext;
|
||||
BEGIN(INITIAL);
|
||||
return BLANK;}
|
||||
return EOA;}
|
||||
<VAR><<EOF>> { lvalp->val_char = '\0';
|
||||
BEGIN(INITIAL);
|
||||
return BLANK;}
|
||||
return EOA;}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Just copy the string verbatim till we find a variable (starts with $) */
|
||||
|
@ -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<const Attribute*> 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<const VectorAttribute *>(values[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
const VectorAttribute * tmp = 0;
|
||||
|
||||
for (int i=0 ; i < num ; i++)
|
||||
{
|
||||
tmp = dynamic_cast<const VectorAttribute *>(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<const Attribute*> 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<const VectorAttribute *>(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<const Attribute*> 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<const VectorAttribute *>(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<const Attribute*> 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<const VectorAttribute *> (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,
|
||||
|
@ -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;
|
||||
|
@ -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<const Attribute*> 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<const VectorAttribute *>(values[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
const VectorAttribute * tmp = 0;
|
||||
|
||||
for (int i=0 ; i < num ; i++)
|
||||
{
|
||||
tmp = dynamic_cast<const VectorAttribute *>(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 <val_char> BLANK
|
||||
%token <val_char> EOA
|
||||
%token <val_str> STRING
|
||||
%token <val_str> RSTRING
|
||||
%token <val_int> 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<const Attribute*> 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<const VectorAttribute *>(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<const Attribute*> 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<const VectorAttribute *>(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<const Attribute*> 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<const VectorAttribute *> (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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user