Mercurial > cabal
diff sources/core.cpp @ 2:19227b0b7cc1
.h => .hpp for the headers
added year 2008 to copyright notes
renamed some functions for better meaning
prepared parser module for rewriting
added showHelp() function
some code clean up
| author | Vlad Glagolev <enqlave@gmail.com> |
|---|---|
| date | Mon, 21 Jan 2008 01:14:10 +0300 |
| parents | bafff9de2a76 |
| children | a7051ac7118b |
line wrap: on
line diff
--- a/sources/core.cpp Sun Jan 20 19:32:59 2008 +0300 +++ b/sources/core.cpp Mon Jan 21 01:14:10 2008 +0300 @@ -2,7 +2,7 @@ * * -- CABAL -- core module * - * Copyright (c) 2007 Vlad Glagolev <enqlave@gmail.com> + * Copyright (c) 2007-2008 Vlad Glagolev <enqlave@gmail.com> * All rights reserved. * * Permission to use, copy, modify, and distribute this software for any @@ -18,15 +18,15 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "core.h" +#include "core.hpp" Connection *C; -Core::Core() - : - pid(PID), +Core::Core(): commander(COMMANDER) { + pid = PID; + cout << "CORE: initializing...\n"; debug = true; @@ -46,12 +46,12 @@ servers = 0; - remove (pid); + remove(pid); cout << "CORE: shutdown complete\n"; } -void Core::commandParse(int argc, char *argv[]) +void Core::parseCommandLine(int argc, char **argv) { for (int e = 1; e < argc; e++) { while (1) { @@ -59,8 +59,10 @@ if (!argv[++e]) shut ("missing configuration file"); - cfg = argv[e]; + config = argv[e]; break; + } else if (!strcmp(argv[e], "-h") || !strcmp(argv[e], "--help")) { + showHelp(); } else if (!strcmp(argv[e], "-d") || !strcmp(argv[e], "--daemon")) { debug = false; break; @@ -70,18 +72,18 @@ } } -void Core::configParse() +void Core::parseConfig() { servers = -1; - C = 0; + C = false; - ifstream config(cfg, ios::in); + ifstream sysconfig(config, ios::in); - if (!config) + if (!sysconfig) shut ("unable to open configuration file"); else { - cout << "CORE: parsing configuration file: " << cfg << endl; + cout << "CORE: parsing configuration file: " << config << endl; if (servers + 1 < MAX_SERVERS) { connections[++servers] = new Connection(); @@ -90,16 +92,16 @@ else cout << "Error: maximum connections exceed\n"; // TEST - C->hosts = C->hostAdd (C->hosts, "irc.enqlave.net", 6667, 0); + C->hosts = C->addHost(C->hosts, "irc.enqlave.net", 6667, 0); // TEST } servers++; - config.close(); + sysconfig.close(); } -void Core::pidCheck() +void Core::checkPID() { ifstream procid(pid, ios::in); @@ -115,7 +117,7 @@ procid.close(); } -void Core::pidWrite() +void Core::writePID() { ofstream procid(pid, ios::out);
