X-Git-Url: https://git.hcoop.net/clinton/bobotpp.git/blobdiff_plain/0316e2c1fb71c53b1299badab997a6f24fefa39e..815a1816c8a1ee14b28c776bf92c172b1fcdf13a:/source/Main.C diff --git a/source/Main.C b/source/Main.C index c79624a..8e187fe 100644 --- a/source/Main.C +++ b/source/Main.C @@ -14,29 +14,33 @@ // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +// 02110-1301, USA. #ifdef HAVE_CONFIG_H #include "config.h" #endif +#include +#include + #include #include #include -#include + #include +#include #include #include #include -#include -#include - #ifdef USESCRIPTS #include "Interp.H" #endif #include "Bot.H" +#include "Parser.H" +#include "UserList.H" namespace { @@ -52,6 +56,9 @@ namespace { "config", required_argument, 0, 'c'}, { "sys-config", required_argument, 0, 's'}, { "user-config", required_argument, 0, 'u'}, +#ifdef USESCRIPTS + { "debug-scripts", no_argument, 0, 'S' }, +#endif { "debug", no_argument, 0, 'D' } }; @@ -116,6 +123,9 @@ namespace " dir is not found.\n" "[--debug][-D] Makes Bobot++ print debugging info and run in\n" " the foreground" +#ifdef USESCRIPTS + "\n[--debug-scripts][-S] Turns on Guile debugging evaluator" +#endif << std::endl << std::endl << "The default configuration is read from\n" @@ -137,13 +147,14 @@ namespace std::string (getenv ("HOME")) + "/.bobotpp/config/"; String user_subdir = "default"; bool debug = false; + bool script_debug = false; std::signal(SIGPIPE, SIG_IGN); std::signal(SIGALRM, SIG_IGN); std::signal(SIGHUP, sig_hup); // We parse the command line options - while ((opt = getopt_long (argc,argv,"vhbf:d:c:D", bot_options, 0)) + while ((opt = getopt_long (argc,argv,"vhbf:d:c:DS", bot_options, 0)) != -1) { switch (opt) @@ -178,6 +189,9 @@ namespace case 'D': debug = true; break; + case 'S': + script_debug = true; + break; default: print_short_help (argv[0]); std::exit(1); @@ -186,9 +200,9 @@ namespace DIR * temp; - if (! (temp = opendir (String(getenv ("HOME")) + "/.bobotpp/logs"))) + if (! (temp = opendir ((String(getenv ("HOME")) + "/.bobotpp/logs").c_str ()))) { - mkdir (String(getenv ("HOME")) + "/.bobotpp/logs", + mkdir ((String(getenv ("HOME")) + "/.bobotpp/logs").c_str (), S_IRWXU); } else @@ -222,25 +236,32 @@ namespace // initialize the Parser Parser::init (); - if (!debug) { - if (background) - switch (fork()) { - case -1: - std::cout << "Could not run in the background. Exiting...\n"; - perror("fork"); - exit(1); - case 0: + if (!debug) + { + if (background) + switch (fork()) + { + case -1: + std::cout << "Could not run in the background. Exiting...\n"; + perror("fork"); + exit(1); + case 0: break; - default: - std::cout << "Running in the background...\n"; - exit(0); - } - } + default: + std::cout << "Running in the background...\n"; + exit(0); + } + } #ifdef USESCRIPTS Interp::Startup(); + if (debug || script_debug) + { + scm_c_eval_string("(debug-enable 'debug)" + "(debug-enable 'backtrace)" + "(read-enable 'positions)"); + } #endif - b = new Bot(configFile, debug); b->run(); delete b;