#include "inspircd.h"
#include <stdarg.h>
-#include "configreader.h"
-#include "users.h"
-#include "modules.h"
#include "wildcard.h"
-#include "mode.h"
#include "xline.h"
#include "exitcodes.h"
void InspIRCd::Log(int level, const char* text, ...)
{
/* sanity check, just in case */
- if (!this->Config)
+ if (!this->Config || !this->Logger)
return;
/* Do this check again here so that we save pointless vsnprintf calls */
void InspIRCd::Log(int level, const std::string &text)
{
/* sanity check, just in case */
- if (!this->Config)
+ if (!this->Config || !this->Logger)
return;
/* If we were given -debug we output all messages, regardless of configured loglevel */
/* Find a user record by nickname and return a pointer to it */
userrec* InspIRCd::FindNick(const std::string &nick)
{
+ if (!nick.empty() && isdigit(*nick.begin()))
+ return FindUUID(nick);
+
user_hash::iterator iter = clientlist->find(nick);
if (iter == clientlist->end())
userrec* InspIRCd::FindNick(const char* nick)
{
+ if (isdigit(*nick))
+ return FindUUID(nick);
+
user_hash::iterator iter = clientlist->find(nick);
if (iter == clientlist->end())
return iter->second;
}
+userrec* InspIRCd::FindNickOnly(const std::string &nick)
+{
+ user_hash::iterator iter = clientlist->find(nick);
+
+ if (iter == clientlist->end())
+ return NULL;
+
+ return iter->second;
+}
+
+userrec* InspIRCd::FindNickOnly(const char* nick)
+{
+ user_hash::iterator iter = clientlist->find(nick);
+
+ if (iter == clientlist->end())
+ return NULL;
+
+ return iter->second;
+}
+
+userrec *InspIRCd::FindUUID(const std::string &uid)
+{
+ return FindUUID(uid.c_str());
+}
+
+userrec *InspIRCd::FindUUID(const char *uid)
+{
+ user_hash::iterator finduuid = uuidlist->find(uid);
+
+ if (finduuid == uuidlist->end())
+ return NULL;
+
+ return finduuid->second;
+}
+
/* find a channel record by channel name and return a pointer to it */
chanrec* InspIRCd::FindChan(const char* chan)
{
}
/* open the proper logfile */
-void InspIRCd::OpenLog(char** argv, int argc)
+bool InspIRCd::OpenLog(char** argv, int argc)
{
Config->MyDir = Config->GetFullProgDir();
if (!Config->log_file)
{
- printf("ERROR: Could not write to logfile %s: %s\n\n", Config->logpath.c_str(), strerror(errno));
- Exit(EXIT_STATUS_LOG);
+ this->Logger = NULL;
+ return false;
}
this->Logger = new FileLogger(this, Config->log_file);
+ return true;
}
void InspIRCd::CheckRoot()