#ifndef _MSH_H #define _MSH_H #include #include #include #include #include "mystring.h" #include "list.h" class cmd { public: int parseerr; // 0 = No errors, 1 = Unparsed, >1 = Error int background; // 0 = waitpid, 1 = don't wait List args; // Parsed argument list // args[0] is the command to execute cmd *pipefrom; // The command piping into this one cmd *pipeto; // The command this one pipes into int stdin_redir_type; // 0 = none, 1 = < String stdin_redir; // Name of the file to direct from int stdout_redir_type; // 0 = none, 1 = >, 2 = >> (append) String stdout_redir; // Name of the file to direct to cmd(void) {parseerr=1;pipefrom=pipeto=0;stdin_redir_type=stdout_redir_type=background=0;} void reset() { cmd *c = pipeto; while(c) { pipeto = c->pipeto; delete c; c = pipeto; } parseerr=1; background=0; args.clear(); pipefrom=0; pipeto=0; stdin_redir_type=0; stdout_redir_type=0; } // Parsing void parse(char *str, cmd *from); void addarg(const char *s); // Execution void cmdexec(); void doexec(); int is_internal(String command); void do_internal(); void do_exit(); void do_which(); char *findpath(const char *file); void do_chdir(); void do_kill(); void do_setenv(); void do_mkdir(); int is_plusx(const char *file); char **buildargv(); }; char *getcommand(); static void errhandler(int sig); #endif