00001 /* 00002 * Copyright 1994 Christopher Seiwald. 00003 * 00004 * This file is part of Jam - see jam.c for Copyright information. 00005 */ 00006 00007 /* 00008 * command.h - the CMD structure and routines to manipulate them 00009 * 00010 * Both ACTION and CMD contain a rule, targets, and sources. An 00011 * ACTION describes a rule to be applied to the given targets and 00012 * sources; a CMD is what actually gets executed by the shell. The 00013 * differences are due to: 00014 * 00015 * ACTIONS must be combined if 'actions together' is given. 00016 * ACTIONS must be split if 'actions piecemeal' is given. 00017 * ACTIONS must have current sources omitted for 'actions updated'. 00018 * 00019 * The CMD datatype holds a single command that is to be executed 00020 * against a target, and they can chain together to represent the 00021 * full collection of commands used to update a target. 00022 * 00023 * Structures: 00024 * 00025 * CMD - an action, ready to be formatted into a buffer and executed 00026 * 00027 * External routines: 00028 * 00029 * cmd_new() - return a new CMD or 0 if too many args 00030 * cmd_free() - delete CMD and its parts 00031 * cmd_next() - walk the CMD chain 00032 */ 00033 00034 /* 00035 * CMD - an action, ready to be formatted into a buffer and executed 00036 */ 00037 00038 typedef struct _cmd CMD; 00039 00040 struct _cmd 00041 { 00042 CMD *next; 00043 CMD *tail; /* valid on in head */ 00044 RULE *rule; /* rule->actions contains shell script */ 00045 LIST *shell; /* $(SHELL) value */ 00046 LOL args; /* LISTs for $(<), $(>) */ 00047 char buf[ MAXLINE ]; /* actual commands */ 00048 } ; 00049 00050 CMD *cmd_new( 00051 RULE *rule, /* rule (referenced) */ 00052 LIST *targets, /* $(<) (freed) */ 00053 LIST *sources, /* $(>) (freed) */ 00054 LIST *shell, /* $(SHELL) (freed) */ 00055 int maxline ); /* max line length */ 00056 00057 void cmd_free( CMD *cmd ); 00058 00059 # define cmd_next( c ) ((c)->next)