// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301, USA.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#include <iostream>
+#include <string>
+
#include <cstdio>
#include <csignal>
#include <cstdlib>
-#include <getopt.h>
+
#include <dirent.h>
+#include <getopt.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <iostream>
-#include <string>
-
#ifdef USESCRIPTS
#include "Interp.H"
#endif
#include "Bot.H"
+#include "Parser.H"
+#include "UserList.H"
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' }
};
" 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"
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)
case 'D':
debug = true;
break;
+ case 'S':
+ script_debug = true;
+ break;
default:
print_short_help (argv[0]);
std::exit(1);
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
// 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;