jamgram: cosmetix
[k8jam.git] / src / command.c
blob5f7e38cef1d1f692666ae79b84ae70c708910e45
1 /*
2 * Copyright 1993, 1995 Christopher Seiwald.
4 * This file is part of Jam - see jam.c for Copyright information.
5 */
6 /*
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
13 #include "jam.h"
15 #include "lists.h"
16 #include "parse.h"
17 #include "variable.h"
18 #include "rules.h"
19 #include "dstrings.h"
21 #include "command.h"
25 * cmd_new() - return a new CMD or 0 if too many args
27 CMD *cmd_new (RULE *rule, LIST *targets, LIST *sources, LIST *shell, int maxline) {
28 CMD *cmd = (CMD *)malloc(sizeof(CMD));
29 dstr_init(&cmd->buf);
30 cmd->rule = rule;
31 cmd->shell = shell;
32 cmd->next = 0;
33 lol_init(&cmd->args);
34 lol_add(&cmd->args, targets);
35 lol_add(&cmd->args, sources);
36 /* we don't free targets/sources/shell if bailing */
37 if (var_string(rule->actions, &cmd->buf, &cmd->args, ' ') < 0) { cmd_free(cmd); return NULL; }
38 return cmd;
43 * cmd_free() - free a CMD
45 void cmd_free (CMD *cmd) {
46 dstr_done(&cmd->buf);
47 lol_free(&cmd->args);
48 list_free(cmd->shell);
49 free(cmd);