# include "jam.h"
# include "lists.h"
# include "parse.h"
# include "variable.h"
# include "rules.h"
# include "command.h"
CMD *
cmd_new( chain, rule, targets, sources, shell, exportvars )
CMD *chain;
RULE *rule;
LIST *targets;
LIST *sources;
LIST *shell;
int exportvars;
{
int len;
CMD *cmd = (CMD *)malloc( sizeof( CMD ) );
cmd->rule = rule;
cmd->shell = shell;
cmd->exportvars = exportvars;
lol_init( &cmd->args );
lol_add( &cmd->args, targets );
lol_add( &cmd->args, sources );
len = var_string( rule->actions, cmd->buf, CMDBUF, &cmd->args );
if( len < 0 )
{
printf( "fatal error: %s command block too long (max %d)\n",
rule->name, CMDBUF );
exit( EXITBAD );
}
if( !chain ) chain = cmd;
else chain->tail->next = cmd;
chain->tail = cmd;
cmd->next = 0;
return chain;
}
void
cmd_free( cmd )
CMD *cmd;
{
lol_free( &cmd->args );
list_free( cmd->shell );
free( (char *)cmd );
}