2 * Copyright 1993, 1995 Christopher Seiwald.
4 * This file is part of Jam - see jam.c for Copyright information.
7 * command.c - maintain lists of commands
9 * 01/20/00 (seiwald) - Upgraded from K&R to ANSI C
10 * 09/08/00 (seiwald) - bulletproof PIECEMEAL size computation
24 * cmd_new() - return a new CMD or 0 if too many args
26 CMD
*cmd_new (RULE
*rule
, LIST
*targets
, LIST
*sources
, LIST
*shell
, int maxline
) {
27 CMD
*cmd
= (CMD
*)malloc(sizeof(CMD
));
33 lol_add(&cmd
->args
, targets
);
34 lol_add(&cmd
->args
, sources
);
35 /* bail if the result won't fit in maxline */
36 /* we don't free targets/sources/shell if bailing */
37 if (var_string(rule
->actions
, cmd
->buf
, maxline
, &cmd
->args
) < 0) { cmd_free(cmd
); return 0; }
43 * cmd_free() - free a CMD
45 void cmd_free (CMD
*cmd
) {
47 list_free(cmd
->shell
);