first in 2.5.10 series
[k8jam.git] / src / command.c
blob220a9336f4b2dc3bb514b355b120ff624df722fc
1 /*
2 * Copyright 1993, 1995 Christopher Seiwald.
4 * This file is part of Jam - see jam.c for Copyright information.
5 */
7 /*
8 * command.c - maintain lists of commands
10 * 01/20/00 (seiwald) - Upgraded from K&R to ANSI C
11 * 09/08/00 (seiwald) - bulletproof PIECEMEAL size computation
14 #include "jam.h"
16 #include "lists.h"
17 #include "parse.h"
18 #include "variable.h"
19 #include "rules.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));
30 cmd->rule = rule;
31 cmd->shell = shell;
32 cmd->next = 0;
34 lol_init(&cmd->args);
35 lol_add(&cmd->args, targets);
36 lol_add(&cmd->args, sources);
38 /* Bail if the result won't fit in maxline */
39 /* We don't free targets/sources/shell if bailing. */
40 if (var_string(rule->actions, cmd->buf, maxline, &cmd->args) < 0) {
41 cmd_free(cmd);
42 return 0;
45 return cmd;
50 * cmd_free() - free a CMD
52 void cmd_free (CMD *cmd) {
53 lol_free(&cmd->args);
54 list_free(cmd->shell);
55 free((char *)cmd);