diff options
author | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2010-03-24 00:46:53 +0000 |
---|---|---|
committer | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2010-03-24 00:46:53 +0000 |
commit | 3ffd9179262242acc01ed93b749aa55a938cf381 (patch) | |
tree | f199314aa20920c5136206755786413ba5e809c0 /src | |
parent | 14fc57d24b5b3ed622d0603011d33b06780ca071 (diff) |
Rewrote arg parsing system, changed lots of std::string*s to std::string&, made --config arg, and made Anope print out a few lines of information when starting
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2833 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src')
-rw-r--r-- | src/botserv.c | 2 | ||||
-rw-r--r-- | src/channels.c | 24 | ||||
-rw-r--r-- | src/chanserv.c | 16 | ||||
-rw-r--r-- | src/config.c | 11 | ||||
-rw-r--r-- | src/core/cs_getkey.c | 2 | ||||
-rw-r--r-- | src/core/db_plain.cpp | 2 | ||||
-rw-r--r-- | src/init.c | 382 | ||||
-rw-r--r-- | src/log.c | 23 | ||||
-rw-r--r-- | src/main.c | 18 | ||||
-rw-r--r-- | src/regchannel.cpp | 6 |
10 files changed, 213 insertions, 273 deletions
diff --git a/src/botserv.c b/src/botserv.c index 24321f559..5d4173d20 100644 --- a/src/botserv.c +++ b/src/botserv.c @@ -631,7 +631,7 @@ void bot_join(ChannelInfo * ci) std::string Limit; int limit = 0; - if (ci->c->GetParam(CMODE_LIMIT, &Limit)) + if (ci->c->GetParam(CMODE_LIMIT, Limit)) { limit = atoi(Limit.c_str()); } diff --git a/src/channels.c b/src/channels.c index 4d9ec807b..5ea729d44 100644 --- a/src/channels.c +++ b/src/channels.c @@ -396,7 +396,7 @@ void Channel::SetModeInternal(ChannelMode *cm, const std::string ¶m, bool En { /* Get the current param set on the channel and send it with the mode */ std::string cparam; - if (GetParam(cmp->Name, &cparam)) + if (GetParam(cmp->Name, cparam)) RemoveMode(NULL, cm, cparam); } else @@ -411,9 +411,9 @@ void Channel::SetModeInternal(ChannelMode *cm, const std::string ¶m, bool En ChannelModeParam *cmp = dynamic_cast<ChannelModeParam *>(cm); std::string cparam, ciparam; /* Get the param currently set on this channel */ - GetParam(cmp->Name, &cparam); + GetParam(cmp->Name, cparam); /* Get the param set in mlock */ - ci->GetParam(cmp->Name, &ciparam); + ci->GetParam(cmp->Name, ciparam); /* We have the wrong param set */ if (cparam.empty() || ciparam.empty() || cparam != ciparam) @@ -539,7 +539,7 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const std::string ¶m, bool { std::string cparam; /* Get the param stored in mlock for this mode */ - if (ci->GetParam(cm->Name, &cparam)) + if (ci->GetParam(cm->Name, cparam)) SetMode(NULL, cm, cparam); } } @@ -648,15 +648,15 @@ void Channel::RemoveMode(BotInfo *bi, char Mode, const std::string ¶m, bool * @param Target a string to put the param into * @return true on success */ -const bool Channel::GetParam(ChannelModeName Name, std::string *Target) +const bool Channel::GetParam(ChannelModeName Name, std::string &Target) { std::map<ChannelModeName, std::string>::iterator it = Params.find(Name); - (*Target).clear(); + Target.clear(); if (it != Params.end()) { - *Target = it->second; + Target = it->second; return true; } @@ -705,7 +705,7 @@ void Channel::ClearModes(BotInfo *bi) if (!cmp->MinusNoArg) { std::string buf; - if (this->GetParam(cmp->Name, &buf)) + if (this->GetParam(cmp->Name, buf)) this->RemoveMode(NULL, cm, buf); } else @@ -1001,7 +1001,7 @@ char *chan_get_modes(Channel * chan, int complete, int plus) if (plus || !cmp->MinusNoArg) { - chan->GetParam(cmp->Name, ¶m); + chan->GetParam(cmp->Name, param); if (!param.empty()) { @@ -1104,11 +1104,11 @@ void get_channel_stats(long *nrec, long *memuse) mem += sizeof(*chan); if (chan->topic) mem += strlen(chan->topic) + 1; - if (chan->GetParam(CMODE_KEY, &buf)) + if (chan->GetParam(CMODE_KEY, buf)) mem += buf.length() + 1; - if (chan->GetParam(CMODE_FLOOD, &buf)) + if (chan->GetParam(CMODE_FLOOD, buf)) mem += buf.length() + 1; - if (chan->GetParam(CMODE_REDIRECT, &buf)) + if (chan->GetParam(CMODE_REDIRECT, buf)) mem += buf.length() + 1; mem += get_memuse(chan->bans); if (ModeManager::FindChannelModeByName(CMODE_EXCEPT)) diff --git a/src/chanserv.c b/src/chanserv.c index fd69ec8d0..b144df6f3 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -210,7 +210,7 @@ char *get_mlock_modes(ChannelInfo * ci, int complete) { cmp = dynamic_cast<ChannelModeParam *>(cm); - ci->GetParam(cmp->Name, ¶m); + ci->GetParam(cmp->Name, param); if (!param.empty()) { @@ -252,13 +252,13 @@ void get_chanserv_stats(long *nrec, long *memuse) mem += ci->GetAccessCount() * sizeof(ChanAccess); mem += ci->GetAkickCount() * sizeof(AutoKick); - if (ci->GetParam(CMODE_KEY, ¶m)) + if (ci->GetParam(CMODE_KEY, param)) mem += param.length() + 1; - if (ci->GetParam(CMODE_FLOOD, ¶m)) + if (ci->GetParam(CMODE_FLOOD, param)) mem += param.length() + 1; - if (ci->GetParam(CMODE_REDIRECT, ¶m)) + if (ci->GetParam(CMODE_REDIRECT, param)) mem += param.length() + 1; if (ci->last_topic) @@ -379,7 +379,7 @@ void check_modes(Channel *c) /* Add the eventual parameter and modify the Channel structure */ if (cm->Type == MODE_PARAM) { - if (ci->GetParam(cmp->Name, ¶m)) + if (ci->GetParam(cmp->Name, param)) c->SetMode(NULL, cm, param); } else @@ -388,8 +388,8 @@ void check_modes(Channel *c) /* If this is a param mode and its mlocked, check to ensure it is set and set to the correct value */ else if (cm->Type == MODE_PARAM && ci->HasMLock(cm->Name, true)) { - c->GetParam(cm->Name, ¶m); - ci->GetParam(cm->Name, &ciparam); + c->GetParam(cm->Name, param); + ci->GetParam(cm->Name, ciparam); /* If the channel doesnt have the mode, or it does and it isn't set correctly */ if (!c->HasMode(cm->Name) || (!param.empty() && !ciparam.empty() && param != ciparam)) @@ -413,7 +413,7 @@ void check_modes(Channel *c) if (!cmp->MinusNoArg) { - if (c->GetParam(cmp->Name, ¶m)) + if (c->GetParam(cmp->Name, param)) c->RemoveMode(NULL, cm, param); } } diff --git a/src/config.c b/src/config.c index 162d81b07..70505c8c6 100644 --- a/src/config.c +++ b/src/config.c @@ -18,6 +18,7 @@ /*************************************************************************/ +std::string services_conf = "services.conf"; // Services configuration file name ServerConfig Config; static std::string Modules; @@ -785,7 +786,7 @@ int ServerConfig::Read(bool bail) // Load and parse the config file, if there are any errors then explode // Make a copy here so if it fails then we can carry on running with an unaffected config newconfig.clear(); - if (LoadConf(newconfig, SERVICES_CONF, errstr)) + if (LoadConf(newconfig, services_conf, errstr)) // If we succeeded, set the config to the new one config_data = newconfig; else @@ -1478,16 +1479,16 @@ void error(int linenum, const char *message, ...) va_end(args); if (linenum) - Alog() << SERVICES_CONF << ":" << linenum << ": " << buf; + Alog() << services_conf << ":" << linenum << ": " << buf; else - Alog() << SERVICES_CONF << ": " << buf; + Alog() << services_conf << ": " << buf; if (!nofork && isatty(2)) { if (linenum) - fprintf(stderr, "%s:%d: %s\n", SERVICES_CONF, linenum, buf); + fprintf(stderr, "%s:%d: %s\n", services_conf.c_str(), linenum, buf); else - fprintf(stderr, "%s: %s\n", SERVICES_CONF, buf); + fprintf(stderr, "%s: %s\n", services_conf.c_str(), buf); } } diff --git a/src/core/cs_getkey.c b/src/core/cs_getkey.c index 3fd53351f..85c901412 100644 --- a/src/core/cs_getkey.c +++ b/src/core/cs_getkey.c @@ -36,7 +36,7 @@ class CommandCSGetKey : public Command return MOD_CONT; } - if (!ci->c || !ci->c->GetParam(CMODE_KEY, &key)) + if (!ci->c || !ci->c->GetParam(CMODE_KEY, key)) { notice_lang(Config.s_ChanServ, u, CHAN_GETKEY_NOKEY, chan); return MOD_CONT; diff --git a/src/core/db_plain.cpp b/src/core/db_plain.cpp index 89fc8d469..10e21359c 100644 --- a/src/core/db_plain.cpp +++ b/src/core/db_plain.cpp @@ -1039,7 +1039,7 @@ class DBPlain : public Module } std::string Param; for (j = 0; ChannelModes[j].Value != -1; ++j) - if (ci->GetParam(ChannelModes[j].Value, &Param)) + if (ci->GetParam(ChannelModes[j].Value, Param)) db << "MD MLP " << ChannelModes[j].Name << " " << Param; if (!ci->memos.memos.empty()) { diff --git a/src/init.c b/src/init.c index 659e9be11..5a819dcfe 100644 --- a/src/init.c +++ b/src/init.c @@ -79,230 +79,67 @@ static int set_group() /*************************************************************************/ -/* Parse command-line options for the "-dir" option only. Return 0 if all - * went well or -1 for a syntax error. - */ - -/* XXX this could fail if we have "-some-option-taking-an-argument -dir" */ +/* Vector of pairs of command line arguments and their params */ +static std::vector<std::pair<std::string, std::string> > CommandLineArguments; -static int parse_dir_options(int ac, char **av) +/** Called on startup to organize our starting arguments in a better way + * and check for errors + * @param ac number of args + * @param av args + */ +static void ParseCommandLineArguments(int ac, char **av) { - int i; - char *s; - - for (i = 1; i < ac; i++) { - s = av[i]; - if (*s == '-') { - s++; - if (strcmp(s, "dir") == 0) { - if (++i >= ac) { - fprintf(stderr, "-dir requires a parameter\n"); - return -1; - } - services_dir = av[i]; - } else if (strcmp(s, "log") == 0) { - if (++i >= ac) { - fprintf(stderr, "-log requires a parameter\n"); - return -1; - } - log_filename = av[i]; - } else if (strcmp(s, "debug") == 0) { - ++debug; - } else if (strcmp(s, "nofork") == 0) { - nofork = 1; - } else if (strcmp(s, "support") == 0) { - nofork = 1; - ++debug; - nothird = 1; - } else if (strcmp(s, "version") == 0) { - fprintf(stdout, "Anope-%s %s -- %s\n", version_number, - version_flags, version_build); - exit(EXIT_SUCCESS); - } + for (int i = 1; i < ac; ++i) + { + std::string option = av[i]; + std::string param = ""; + while (!option.empty() && option[0] == '-') + option.erase(option.begin()); + size_t t = option.find('='); + if (t != std::string::npos) + { + param = option.substr(t + 1); + option.erase(t); } + + if (option.empty()) + continue; + + CommandLineArguments.push_back(std::make_pair(option, param)); } - return 0; } -/*************************************************************************/ - -/* Parse command-line options. Return 0 if all went well, -1 for an error - * with an option, or 1 for -help. +/** Check if an argument was given on startup + * @param name The argument name + * @param shortname A shorter name, eg --debug and -d + * @return true if name/shortname was found, false if not */ +bool GetCommandLineArgument(const std::string &name, char shortname) +{ + std::string Unused; + return GetCommandLineArgument(name, shortname, Unused); +} -static int parse_options(int ac, char **av) +/** Check if an argument was given on startup and its parameter + * @param name The argument name + * @param shortname A shorter name, eg --debug and -d + * @param param A string to put the param, if any, of the argument + * @return true if name/shortname was found, false if not + */ +bool GetCommandLineArgument(const std::string &name, char shortname, std::string ¶m) { - int i; - char *s, *t; - - for (i = 1; i < ac; i++) { - s = av[i]; - if (*s == '-') { - s++; - if (strcmp(s, "remote") == 0) { - if (++i >= ac) { - fprintf(stderr, "-remote requires hostname[:port]\n"); - return -1; - } - s = av[i]; - t = strchr(s, ':'); - if (t) { - int portnum; - *t++ = 0; - portnum = atoi(t); - if ((portnum > 0) && (portnum < 65535)) - /*RemotePort = portnum*/; // Needs fixing to handle the Uplinks list - else { - fprintf(stderr, - "-remote: Port numbers must be in the range 1..65535. Using default.\n"); - return -1; - } - } - /*RemoteServer = s*/; // Needs fixing to handle the Uplinks list - } else if (strcmp(s, "local") == 0) { - if (++i >= ac) { - fprintf(stderr, - "-local requires hostname or [hostname]:[port]\n"); - return -1; - } - s = av[i]; - t = strchr(s, ':'); - if (t) { - int portnum; - *t++ = 0; - portnum = atoi(t); - if ((portnum >= 0) && (portnum < 65535)) - Config.LocalPort = portnum; - else { - fprintf(stderr, - "-local: Port numbers must be in the range 1..65535 or 0. Using default.\n"); - return -1; - } - } - Config.LocalHost = s; - } else if (strcmp(s, "name") == 0) { - if (++i >= ac) { - fprintf(stderr, "-name requires a parameter\n"); - return -1; - } - Config.ServerName = av[i]; - } else if (strcmp(s, "desc") == 0) { - if (++i >= ac) { - fprintf(stderr, "-desc requires a parameter\n"); - return -1; - } - Config.ServerDesc = av[i]; - } else if (strcmp(s, "user") == 0) { - if (++i >= ac) { - fprintf(stderr, "-user requires a parameter\n"); - return -1; - } - Config.ServiceUser = av[i]; - } else if (strcmp(s, "host") == 0) { - if (++i >= ac) { - fprintf(stderr, "-host requires a parameter\n"); - return -1; - } - Config.ServiceHost = av[i]; - } else if (strcmp(s, "dir") == 0) { - /* Handled by parse_dir_options() */ - i++; /* Skip parameter */ - } else if (strcmp(s, "log") == 0) { - /* Handled by parse_dir_options(), too */ - i++; /* Skip parameter */ - } else if (strcmp(s, "update") == 0) { - if (++i >= ac) { - fprintf(stderr, "-update requires a parameter\n"); - return -1; - } - s = av[i]; - if (atoi(s) <= 0) { - fprintf(stderr, - "-update: number of seconds must be positive"); - return -1; - } else - Config.UpdateTimeout = atol(s); - } else if (strcmp(s, "expire") == 0) { - if (++i >= ac) { - fprintf(stderr, "-expire requires a parameter\n"); - return -1; - } - s = av[i]; - if (atoi(s) <= 0) { - fprintf(stderr, - "-expire: number of seconds must be positive\n"); - return -1; - } else - Config.ExpireTimeout = atol(s); - } else if (strcmp(s, "debug") == 0) { - /* Handled by parse_dir_options() */ - } else if (strcmp(s, "readonly") == 0) { - readonly = 1; - } else if (strcmp(s, "nofork") == 0) { - /* Handled by parse_dir_options() */ - } else if (strcmp(s, "logchan") == 0) { - if (!Config.LogChannel) { - fprintf(stderr, - "-logchan: Config.LogChannel must be defined in services.conf\n"); - } else { /* Config.LogChannel */ - - LogChan = true; - } - } else if (strcmp(s, "forceload") == 0) { - forceload = 1; - } else if (strcmp(s, "nothird") == 0) { - nothird = 1; - } else if (strcmp(s, "protocoldebug") == 0) { - protocoldebug = 1; - } else if (strcmp(s, "support") == 0) { - /* Handled by parse_dir_options() */ - } else if (!strcmp(s, "noexpire")) { - noexpire = 1; - } else if (!strcmp(s, "help")) { - fprintf(stdout, "Anope-%s %s -- %s\n", version_number, - version_flags, version_build); - fprintf(stdout, - "Anope IRC Services (http://www.anope.org)\n"); - fprintf(stdout, "Usage ./" SERVICES_BIN " [options] ...\n"); - fprintf(stdout, - "-remote -remote hostname[:port]\n"); - fprintf(stdout, "-local -local hostname[:port]\n"); - fprintf(stdout, "-name -name servername\n"); - fprintf(stdout, "-desc -desc serverdesc\n"); - fprintf(stdout, "-user -user serviceuser\n"); - fprintf(stdout, "-host -host servicehost\n"); - fprintf(stdout, - "-update -update updatetime(secs)\n"); - fprintf(stdout, - "-expire -expire expiretime(secs)\n"); - fprintf(stdout, "-debug -debug\n"); - fprintf(stdout, "-nofork -nofork\n"); - fprintf(stdout, "-logchan -logchan channelname\n"); - fprintf(stdout, "-forceload -forceload\n"); - fprintf(stdout, "-nothird -nothird\n"); - fprintf(stdout, "-support -support\n"); - fprintf(stdout, "-readonly -readonly\n"); - fprintf(stdout, "-noexpire -noexpire\n"); - fprintf(stdout, "-version -version\n"); - fprintf(stdout, "-help -help\n"); - fprintf(stdout, "-log -log logfilename\n"); - fprintf(stdout, - "-dir -dir servicesdirectory\n\n"); - fprintf(stdout, - "Further support is available from http://www.anope.org\n"); - fprintf(stdout, - "Or visit US on IRC at irc.anope.org #anope\n"); - exit(EXIT_SUCCESS); - } else { - fprintf(stderr, "Unknown option -%s\n", s); - return -1; - } - } else { - fprintf(stderr, "Non-option arguments not allowed\n"); - return -1; + param.clear(); + + for (std::vector<std::pair<std::string, std::string> >::iterator it = CommandLineArguments.begin(); it != CommandLineArguments.end(); ++it) + { + if (it->first == name || it->first[0] == shortname) + { + param = it->second; + return true; } } - return 0; + + return false; } /*************************************************************************/ @@ -353,8 +190,116 @@ int init_primary(int ac, char **av) if (set_group() < 0) return -1; - /* Parse command line for -dir and -version options. */ - parse_dir_options(ac, av); + /* Parse command line arguments */ + ParseCommandLineArguments(ac, av); + + if (GetCommandLineArgument("version", 'v')) + { + Alog(LOG_TERMINAL) << "Anope-" << version_number << version_flags << " -- " << version_build; + return -1; + } + + if (GetCommandLineArgument("help", 'h')) + { + Alog(LOG_TERMINAL) << "Anope-" << version_number << version_flags << " -- " << version_build; + Alog(LOG_TERMINAL) << "Anope IRC Services (http://www.anope.org)"; + Alog(LOG_TERMINAL) << "Usage ./" << SERVICES_BIN << " [options] ..."; + Alog(LOG_TERMINAL) << "-c, --config=filename.conf"; + Alog(LOG_TERMINAL) << "-d, --debug[=level]"; + Alog(LOG_TERMINAL) << " --dir=services_directory"; + Alog(LOG_TERMINAL) << "-h, --help"; + Alog(LOG_TERMINAL) << " --log=log_filename"; + Alog(LOG_TERMINAL) << "-e, --noexpire"; + Alog(LOG_TERMINAL) << "-n, --nofork"; + Alog(LOG_TERMINAL) << " --nothird"; + Alog(LOG_TERMINAL) << " --protocoldebug"; + Alog(LOG_TERMINAL) << "-r, --readonly"; + Alog(LOG_TERMINAL) << "-s, --support"; + Alog(LOG_TERMINAL) << "-v, --version"; + Alog(LOG_TERMINAL) << ""; + Alog(LOG_TERMINAL) << "Further support is available from http://www.anope.org"; + Alog(LOG_TERMINAL) << "Or visit us on IRC at irc.anope.org #anope"; + return -1; + } + + if (GetCommandLineArgument("nofork", 'n')) + { + nofork = 1; + } + + if (GetCommandLineArgument("support", 's')) + { + nofork = nothird = 1; + ++debug; + } + + if (GetCommandLineArgument("readonly", 'r')) + { + readonly = 1; + } + + if (GetCommandLineArgument("nothird")) + { + nothird = 1; + } + + if (GetCommandLineArgument("noexpire", 'e')) + { + noexpire = 1; + } + + if (GetCommandLineArgument("protocoldebug")) + { + protocoldebug = 1; + } + + std::string Arg; + if (GetCommandLineArgument("debug", 'd', Arg)) + { + if (!Arg.empty()) + { + int level = atoi(Arg.c_str()); + if (level > 0) + debug = level; + else + { + Alog(LOG_TERMINAL) << "Invalid option given to --debug"; + return -1; + } + } + else + ++debug; + } + + if (GetCommandLineArgument("config", 'c', Arg)) + { + if (Arg.empty()) + { + Alog(LOG_TERMINAL) << "The --config option requires a file name"; + return -1; + } + services_conf = Arg; + } + + if (GetCommandLineArgument("dir", 0, Arg)) + { + if (Arg.empty()) + { + Alog(LOG_TERMINAL) << "The --dir option requires a directory name"; + return -1; + } + services_dir = Arg; + } + + if (GetCommandLineArgument("log", 0, Arg)) + { + if (Arg.empty()) + { + Alog(LOG_TERMINAL) << "The --log option requires a file name"; + return -1; + } + log_filename = Arg; + } /* Chdir to Services data directory. */ if (chdir(services_dir.c_str()) < 0) { @@ -367,7 +312,7 @@ int init_primary(int ac, char **av) openlog_errno = errno; if (started_from_term) { fprintf(stderr, "Warning: unable to open log file %s: %s\n", - log_filename, strerror(errno)); + log_filename.c_str(), strerror(errno)); } else { openlog_failed = 1; } @@ -402,15 +347,13 @@ int init_secondary(int ac, char **av) /* Add Core MSG handles */ moduleAddMsgs(); - /* Parse all remaining command-line options. */ - parse_options(ac, av); - #ifndef _WIN32 if (!nofork) { if ((i = fork()) < 0) { perror("fork()"); return -1; } else if (i != 0) { + Alog(LOG_TERMINAL) << "PID " << i; exit(0); } if (started_from_term) { @@ -444,6 +387,7 @@ int init_secondary(int ac, char **av) } if (!nofork) { + Alog(LOG_TERMINAL) << "PID " << GetCurrentProcessId(); Alog() << "Launching Anope into the background"; FreeConsole(); } @@ -34,7 +34,7 @@ static int get_logname(char *name, int count, struct tm *tm) /* fix bug 577 */ strftime(timestamp, sizeof(timestamp), "%Y%m%d", tm); - snprintf(name, count, "logs/%s.%s", log_filename, timestamp); + snprintf(name, count, "logs/%s.%s", log_filename.c_str(), timestamp); curday = tm->tm_yday; return 1; @@ -255,21 +255,15 @@ void fatal_perror(const char *fmt, ...) exit(1); } -Alog::Alog(LogLevel val) +Alog::Alog(LogLevel val) : Level(val) { - if (val > debug) - logit = false; - else - { - logit = true; - if (val >= LOG_DEBUG) - buf << "Debug: "; - } + if (Level >= LOG_DEBUG) + buf << "Debug: "; } Alog::~Alog() { - if (!logit) + if (Level >= LOG_DEBUG && (Level - LOG_DEBUG + 1) > debug) return; char *tbuf; @@ -282,9 +276,10 @@ Alog::~Alog() if (logfile) { fprintf(logfile, "%s %s\n", tbuf, buf.str().c_str()); } - if (nofork) { - fprintf(stderr, "%s %s\n", tbuf, buf.str().c_str()); - } + if (nofork) + std::cout << tbuf << " " << buf.str() << std::endl; + else if (Level == LOG_TERMINAL) // XXX dont use this yet unless you know we're at terminal and not daemonized + std::cout << buf.str() << std::endl; if (Config.LogChannel && LogChan && !debug && findchan(Config.LogChannel)) { ircdproto->SendPrivmsg(findbot(Config.s_GlobalNoticer), Config.LogChannel, "%s", buf.str().c_str()); } diff --git a/src/main.c b/src/main.c index cd3625607..28f1fd51d 100644 --- a/src/main.c +++ b/src/main.c @@ -44,7 +44,7 @@ std::string services_dir; /* -dir dirname */ std::string services_bin; /* Binary as specified by the user */ std::string orig_cwd; /* Original current working directory */ -const char *log_filename = LOG_FILENAME; /* -log filename */ +std::string log_filename = LOG_FILENAME; /* -log filename */ int debug = 0; /* -debug */ int readonly = 0; /* -readonly */ bool LogChan = false; /* -logchan */ @@ -90,7 +90,7 @@ const char version_number_dotted[] = VERSION_STRING_DOTTED; const char version_build[] = "build #" BUILD ", compiled " __DATE__ " " __TIME__; /* the space is needed cause if you build with nothing it will complain */ -const char version_flags[] = " " VER_OS VER_MODULE; +const char version_flags[] = " " VER_OS; /******** Local variables! ********/ @@ -371,7 +371,6 @@ std::string GetFullProgDir(char *argv0) int main(int ac, char **av, char **envp) { int i; - char *progname; my_av = av; my_envp = envp; @@ -412,12 +411,13 @@ int main(int ac, char **av, char **envp) /* General initialization first */ if ((i = init_primary(ac, av)) != 0) return i; - - /* Find program name. */ - if ((progname = strrchr(av[0], '/')) != NULL) - progname++; - else - progname = av[0]; + + Alog(LOG_TERMINAL) << "Anope " << version_number << ", " << version_build; +#ifdef _WIN32 + Alog(LOG_TERMINAL) << "Using configuration file " << services_dir << "\\" << services_conf; +#else + Alog(LOG_TERMINAL) << "Using configuration file " << services_dir << "/" << services_conf; +#endif /* Initialization stuff. */ if ((i = init_secondary(ac, av)) != 0) diff --git a/src/regchannel.cpp b/src/regchannel.cpp index 6070441a2..706746422 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -510,15 +510,15 @@ const size_t ChannelInfo::GetMLockCount(bool status) const * @param Target a string to put the param into * @return true on success */ -const bool ChannelInfo::GetParam(ChannelModeName Name, std::string *Target) +const bool ChannelInfo::GetParam(ChannelModeName Name, std::string &Target) { std::map<ChannelModeName, std::string>::iterator it = Params.find(Name); - (*Target).clear(); + Target.clear(); if (it != Params.end()) { - *Target = it->second; + Target = it->second; return true; } |