1/*
2 * Copyright 1994 Christopher Seiwald.
3 *
4 * This file is part of Jam - see jam.c for Copyright information.
5 */
6
7/*
8 * command.h - the CMD structure and routines to manipulate them
9 *
10 * Both ACTION and CMD contain a rule, targets, and sources.  An
11 * ACTION describes a rule to be applied to the given targets and
12 * sources; a CMD is what actually gets executed by the shell.  The
13 * differences are due to:
14 *
15 *	ACTIONS must be combined if 'actions together' is given.
16 *	ACTIONS must be split if 'actions piecemeal' is given.
17 *	ACTIONS must have current sources omitted for 'actions updated'.
18 *
19 * The CMD datatype holds a single command that is to be executed
20 * against a target, and they can chain together to represent the
21 * full collection of commands used to update a target.
22 *
23 * Structures:
24 *
25 * 	CMD - an action, ready to be formatted into a buffer and executed
26 *
27 * External routines:
28 *
29 * 	cmd_new() - return a new CMD or 0 if too many args
30 *	cmd_free() - delete CMD and its parts
31 *	cmd_next() - walk the CMD chain
32 */
33
34/*
35 * CMD - an action, ready to be formatted into a buffer and executed
36 */
37
38typedef struct _cmd CMD;
39
40struct _cmd
41{
42	CMD	*next;
43	CMD	*tail;		/* valid on in head */
44	RULE	*rule;		/* rule->actions contains shell script */
45	LIST	*shell;		/* $(SHELL) value */
46	LOL	args;		/* LISTs for $(<), $(>) */
47	char	buf[ MAXLINE ];	/* actual commands */
48} ;
49
50CMD *cmd_new(
51	RULE	*rule,		/* rule (referenced) */
52	LIST	*targets,	/* $(<) (freed) */
53	LIST	*sources,	/* $(>) (freed) */
54	LIST	*shell,		/* $(SHELL) (freed) */
55	int	maxline );	/* max line length */
56
57void cmd_free( CMD *cmd );
58
59# define cmd_next( c ) ((c)->next)
60