/* $Id: main.c,v 1.25 2004/04/04 04:02:32 jmuelmen Exp $ */ /* main initializes all the subsystems and then transfers control to the * shell */ #include "shell.h" #include "scheduler.h" #include "threads.h" #include "instinit.h" #include #include #include int surf_init (); int turbodog_init(); #define STRLEN 1024 char histfile[STRLEN]; static char ambush_rev[] = "AMBuSh 0.2.1"; static char ambush_tag[] = "$Name: $"; int main (int argc, char **argv) { pthread_t shell_thr, queue_thr, if_thr, at_thr, sched_thr; printf("%s, %s\n", ambush_rev, ambush_tag); /* do initialization stuff here */ atbuf_init(); schedbuf_init(); ifbuf_init(); parsebuf_init(); queue_init(); set_atomic(0); set_sequential(NULL); /* instruments need initialization too */ /* if (powersupply_init()) */ /* return 1; */ /* first load the configuration file */ load_config(); /* then initialize the surf system */ surf_init(); /* after the surf system is initialized, we can initialize the log files */ log_init(); turbodog_init(); /* read the history file */ snprintf(histfile, STRLEN, "%s/.ambush/history", getenv("HOME")); histfile[STRLEN - 1] = 0; /* if we don't find the history, it's not a big deal. */ if (read_history(histfile)) perror("Reading history"); /* now run shell, queue */ pthread_create(&shell_thr, NULL, shell, NULL); pthread_create(&queue_thr, NULL, queue, NULL); pthread_create(&if_thr, NULL, ifbuf, NULL); pthread_create(&at_thr, NULL, atbuf, NULL); pthread_create(&sched_thr, NULL, schedbuf, NULL); pthread_join(shell_thr, NULL); pthread_join(queue_thr, NULL); pthread_join(if_thr, NULL); pthread_join(at_thr, NULL); pthread_join(sched_thr, NULL); return 0; }