2 // Copyright (c) 1997, 1998 Etienne BERNARD
3 // Copyright (C) 2002 Clinton Ebadi
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
40 b->userList->addUserFirst("bidon", "bidon", 0, 0, false, 0, "");
45 void printUsage(char *name)
47 std::cout << "Usage: " << name << " [-h] [-b] [-f file] [-d dir] [-D]\n"
48 " -h Shows this help.\n"
49 " -b Do not run in background.\n"
50 " -f file Use file as config file.\n"
51 " -d dir Use dir as current dir.\n"
52 " -c config Use config as config\n"
53 " -s config Use config as config (only search sysdir)\n"
54 " -u config Use config as config (only search userdir)\n"
55 " -D Debug mode (input/output printing and no background mode.\n";
58 static void real_main(void* DONOTUSE, int argc, char **argv)
60 // FIXME: User directory
63 bool background = true;
64 String configFile = "bot.conf";
65 String cmd_directory = "";
66 String sys_directory = "/etc/bobotpp/";
67 String sys_subdir = "default";
68 String user_directory = String(getenv ("HOME")) + "/.bobotpp/config/";
69 String user_subdir = "default";
72 std::signal(SIGPIPE, SIG_IGN);
73 std::signal(SIGALRM, SIG_IGN);
74 std::signal(SIGHUP, sig_hup);
76 // We parse the command line options
77 while ((opt = getopt(argc,argv,"hbf:d:c:D")) != EOF)
80 printUsage(argv[0]); exit(0);
88 cmd_directory = optarg;
104 printUsage(argv[0]); exit(1);
107 if (!cmd_directory.length ())
109 if (chdir(user_directory + user_subdir) < 0)
110 if (chdir(sys_directory + sys_subdir) < 0)
112 std::cerr << "Dirs don't exist! Exiting\n";
113 std::exit (2); // no execution
117 if (chdir(cmd_directory) < 0)
119 std::perror("Error: ");
120 std::cerr << "Exiting...\n";
124 std::cout << COPYRIGHT_STRING <<
125 "\n"PACKAGE" comes with ABSOLUTELY NO WARRANTY\n"
126 "This is free software, and you are welcome to redistribute it\n"
127 "under certain conditions; See the COPYING file for details.\n";
133 std::cout << "Could not run in the background. Exiting...\n";
139 std::cout << "Running in the background...\n";
148 b = new Bot(configFile, debug);
157 int main(int argc, char **argv) {
159 scm_boot_guile (argc, argv, real_main, 0);
161 real_main(0, argc, argv);