/* parse.h -- Hui Dai September 2003 for cs170 */ #ifndef _PARSE_H_ #define _PARSE_H_ #define LINEMAX 2048 /* expected maximum characters per input line */ #define PARSEDLINE (LINEMAX*2) /* the following are return codes for the parse() function */ #define SUCCESS 0 /* there are no mistakes */ #define EOF_REACHED -1 /* AKA ctrl-D */ #define EMPTYLINE -2 /* no non-white space detected in input */ #define BADSYMBOL -4 /* unrecognized special symbols */ #define BADPLACEMENT -8 /* the line does not parse correctly */ #define MALLOCFAILED -16 /* this should not happen */ /* command structure */ typedef struct command_struct { struct command_struct * prevCmd; struct command_struct * nextCmd; char * file; char ** argv; char * in_redir; char * out_redir; int appending; /* flag, non-zero = append, zero = truncate */ int background; /* whether the line terminates with an & */ } CMD; int parse(CMD **); /* returns an error code, CMD ** outParameter */ int cmd_free(CMD *); #endif