static void call_action_rule ( TARGET * target, int status, timing_info const * time, char const * executed_command, char const * command_output ) { LIST * action_rule; pushsettings( root_module(), target->settings ); action_rule = var_get( root_module(), constant_ACTION_RULE ); popsettings( root_module(), target->settings ); if ( !list_empty( action_rule ) ) { /* rule action-rule ( args * : target : command status start end user system : output ? ) */ /* Prepare the argument list. */ FRAME frame[ 1 ]; OBJECT * rulename = list_front( action_rule ); frame_init( frame ); /* args * :: $(__ACTION_RULE__[2-]) */ lol_add( frame->args, list_copy_range( action_rule, list_next( list_begin( action_rule ) ), list_end( action_rule ) ) ); /* target :: the name of the target */ lol_add( frame->args, list_new( object_copy( target->name ) ) ); /* command status start end user system :: info about the action command */ lol_add( frame->args, list_push_back( list_push_back( list_push_back( list_push_back( list_push_back( list_new( object_new( executed_command ) ), outf_int( status ) ), outf_time( &time->start ) ), outf_time( &time->end ) ), outf_double( time->user ) ), outf_double( time->system ) ) ); /* output ? :: the output of the action command */ if ( command_output ) lol_add( frame->args, list_new( object_new( command_output ) ) ); else lol_add( frame->args, L0 ); /* Call the rule. */ evaluate_rule( bindrule( rulename, root_module() ), rulename, frame ); /* Clean up. */ frame_free( frame ); } }
/* Look up the __ACTION_RULE__ variable on the given target, and if * non-empty, invoke the rule it names, passing the given info, * timing_info, executed command and command output */ static void call_action_rule(TARGET* target, int status, timing_info* time, char *executed_command, char *command_output) { LIST* action_rule; pushsettings(target->settings); action_rule = var_get( "__ACTION_RULE__" ); popsettings(target->settings); if (action_rule) { /* rule action-rule ( args * : target : command status start end user system : output ? ) */ /* Prepare the argument list */ FRAME frame[1]; frame_init( frame ); /* args * :: $(__ACTION_RULE__[2-]) */ lol_add( frame->args, list_copy( L0, action_rule->next ) ); /* target :: the name of the target */ lol_add( frame->args, list_new( L0, target->name ) ); /* command status start end user system :: info about the action command */ lol_add( frame->args, list_new( list_new( list_new( list_new( list_new( list_new( L0, newstr(executed_command) ), outf_int(status) ), outf_time(time->start) ), outf_time(time->end) ), outf_double(time->user) ), outf_double(time->system) ) ); /* output ? :: the output of the action command */ if (command_output) lol_add(frame->args, list_new(L0, newstr(command_output))); else lol_add(frame->args, L0); /* Call the rule. */ evaluate_rule( action_rule->string, frame ); /* Clean up */ frame_free( frame ); } }
/* Look up the __TIMING_RULE__ variable on the given target, and if * non-empty, invoke the rule it names, passing the given * timing_info */ static void call_timing_rule(TARGET* target, timing_info* time) { LIST* timing_rule; pushsettings(target->settings); timing_rule = var_get( "__TIMING_RULE__" ); popsettings(target->settings); if (timing_rule) { /* rule timing-rule ( args * : target : start end user system ) */ /* Prepare the argument list */ FRAME frame[1]; frame_init( frame ); /* args * :: $(__TIMING_RULE__[2-]) */ lol_add( frame->args, list_copy( L0, timing_rule->next ) ); /* target :: the name of the target */ lol_add( frame->args, list_new( L0, target->name ) ); /* start end user system :: info about the action command */ lol_add( frame->args, list_new( list_new( list_new( list_new( L0, outf_time(time->start) ), outf_time(time->end) ), outf_double(time->user) ), outf_double(time->system) ) ); /* Call the rule. */ evaluate_rule( timing_rule->string, frame ); /* Clean up */ frame_free( frame ); } }
static void call_timing_rule( TARGET * target, timing_info const * const time ) { LIST * timing_rule; pushsettings( root_module(), target->settings ); timing_rule = var_get( root_module(), constant_TIMING_RULE ); popsettings( root_module(), target->settings ); if ( !list_empty( timing_rule ) ) { /* rule timing-rule ( args * : target : start end user system ) */ /* Prepare the argument list. */ FRAME frame[ 1 ]; OBJECT * rulename = list_front( timing_rule ); frame_init( frame ); /* args * :: $(__TIMING_RULE__[2-]) */ lol_add( frame->args, list_copy_range( timing_rule, list_next( list_begin( timing_rule ) ), list_end( timing_rule ) ) ); /* target :: the name of the target */ lol_add( frame->args, list_new( object_copy( target->name ) ) ); /* start end user system :: info about the action command */ lol_add( frame->args, list_push_back( list_push_back( list_push_back( list_new( outf_time( &time->start ) ), outf_time( &time->end ) ), outf_double( time->user ) ), outf_double( time->system ) ) ); /* Call the rule. */ evaluate_rule( bindrule( rulename , root_module() ), rulename, frame ); /* Clean up. */ frame_free( frame ); } }