/* shell.h -- The data structures used by the shell */ #include "config.h" #include "general.h" #include "variables.h" #include "quit.h" #ifdef SYSV #define MAXPATHLEN 1024 #endif extern int EOF_Reached; #define NO_PIPE -1 #define REDIRECT_BOTH -2 #define IS_DESCRIPTOR -1 #define NO_VARIABLE -1 /* A bunch of stuff for flow of control using setjmp () and longjmp (). */ #include extern jmp_buf top_level, catch; #define NOT_JUMPED 0 /* Not returning from a longjmp. */ #define FORCE_EOF 1 /* We want to stop parsing. */ #define DISCARD 2 /* Discard current command. */ #define EXITPROG 3 /* Unconditionally exit the program now. */ /* Values that can be returned by execute_command (). */ #define EXECUTION_FAILURE 1 #define EXECUTION_SUCCESS 0 /* The list of characters that are quoted in double-quotes with a backslash. Other characters following a backslash cause nothing special to happen. */ #define slashify_in_quotes "\\`\"$" /* All structs which contain a `next' field should have that field as the first field in the struct. This means that functions can be written to handle the general case for linked lists. */ typedef struct g_list { struct g_list *next; } GENERIC_LIST; /* Instructions describing what kind of thing to do for a redirection. */ enum r_instruction { r_output_direction, r_input_direction, r_inputa_direction, r_appending_to, r_reading_until, r_duplicating, r_deblank_reading_until, r_close_this, r_err_and_out }; /* Command Types: */ enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_connection, cm_function_def, cm_until, cm_group }; /* A structure which represents a word. */ typedef struct word_desc { char *word; /* Zero terminated string. */ int dollar_present; /* Non-zero means dollar sign present. */ int quoted; /* Non-zero means single, double, or back quote or backslash is present. */ int assignment; /* Non-zero means that this word contains an assignment. */ } WORD_DESC; /* A linked list of words. */ typedef struct word_list { struct word_list *next; WORD_DESC *word; } WORD_LIST; /* **************************************************************** */ /* */ /* Shell Command Structs */ /* */ /* **************************************************************** */ /* What a redirection descriptor looks like. If FLAGS is IS_DESCRIPTOR, then we use REDIRECTEE.DEST, else we use the file specified. */ typedef struct redirect { struct redirect *next; /* Next element, or NULL. */ int redirector; /* Descriptor to be redirected. */ int flags; /* Flag value for `open'. */ enum r_instruction instruction; /* What to do with the information. */ union { int dest; /* Place to redirect REDIRECTOR to, or ... */ WORD_DESC *filename; /* filename to redirect to. */ } redirectee; char *here_doc_eof; /* The word that appeared in <