diff options
Diffstat (limited to 'src/main.cc')
| -rw-r--r-- | src/main.cc | 102 |
1 files changed, 4 insertions, 98 deletions
diff --git a/src/main.cc b/src/main.cc index d7719b2..f983590 100644 --- a/src/main.cc +++ b/src/main.cc @@ -11,52 +11,24 @@ #include <vector> #include <string> -#include "util/io.h" -#include "job.h" -#include "parse.h" -#include "handler.h" -#include "ground.h" -#include "eval.h" -#include "path.h" -#include "util/string.h" +#include "all.h" #include "test.h" using namespace std; using namespace ov4; - - /* Global variables */ char prompt[] = "$ "; /* command line prompt (DO NOT CHANGE) */ char sbuf[MAXLINE]; /* for composing sprintf messages */ - - -int builtin_cmd(char *c_str); - - - -void usage(void); -void unix_error(char *msg); -void app_error(char *msg); -typedef void handler_t(int); -handler_t *Signal(int signum, handler_t *handler); - -// built-in commands -void builtin_command_quit(); - /* * main - The shell's main routine */ int main(int argc, char **argv) { - cout << "\ -You are using ccshell. \n\ -This is free software; see the source for copying conditions. \ -There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. \n\ -Published under GNU AFFERO GENERAL PUBLIC LICENSE (AGPL) Version 3." << endl; + init(); //test(argv); - init(); + char c; char cmdline[MAXLINE]; int emit_prompt = 1; /* emit prompt (default) */ @@ -84,10 +56,7 @@ Published under GNU AFFERO GENERAL PUBLIC LICENSE (AGPL) Version 3." << endl; /* Install the signal handlers */ - /* These are the ones you will need to implement */ - Signal(SIGINT, sigint_handler); /* ctrl-c */ - Signal(SIGTSTP, sigtstp_handler); /* ctrl-z */ - Signal(SIGCHLD, sigchld_handler); /* Terminated or stopped child */ + /* This one provides a clean way to kill the shell */ Signal(SIGQUIT, sigquit_handler); @@ -119,66 +88,3 @@ Published under GNU AFFERO GENERAL PUBLIC LICENSE (AGPL) Version 3." << endl; exit(0); /* control never reaches here */ } - - - - - - - - - -/*********************** - * Other helper routines - ***********************/ - -/* - * usage - print a help message - */ -void usage(void) -{ - printf("Usage: shell [-hvp]\n"); - printf(" -h print this message\n"); - printf(" -v print additional diagnostic information\n"); - printf(" -p do not emit a command prompt\n"); - exit(1); -} - -/* - * unix_error - unix-style error routine - */ -void unix_error(char *msg) -{ - fprintf(stdout, "%s: %s\n", msg, strerror(errno)); - exit(1); -} - -/* - * app_error - application-style error routine - */ -void app_error(char *msg) -{ - fprintf(stdout, "%s\n", msg); - exit(1); -} - -/* - * Signal - wrapper for the sigaction function - */ -handler_t *Signal(int signum, handler_t *handler) -{ - struct sigaction action, old_action; - - action.sa_handler = handler; - sigemptyset(&action.sa_mask); /* block sigs of type being handled */ - action.sa_flags = SA_RESTART; /* restart syscalls if possible */ - - if (sigaction(signum, &action, &old_action) < 0) - unix_error("Signal error"); - return (old_action.sa_handler); -} - - - - - |
