*/
#include <stdarg.h>
-#include "inspircd_config.h"
#include "configreader.h"
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/errno.h>
-#include <signal.h>
-#include <time.h>
-#include <string>
-#include <sstream>
-#ifdef HAS_EXECINFO
-#include <execinfo.h>
-#endif
-#include "connection.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
#include "modules.h"
-#include "dynamic.h"
#include "wildcard.h"
#include "mode.h"
#include "xline.h"
-#include "commands.h"
-#include "inspstring.h"
-
-#include "hashcomp.h"
-#include "typedefs.h"
#include "inspircd.h"
static char TIMESTR[26];
if (Config->log_file && Config->writelog)
{
- fprintf(Config->log_file,"%s %s\n",TIMESTR,text.c_str());
- fflush(Config->log_file);
+ std::string out = std::string(TIMESTR) + " " + text.c_str() + "\n";
+ this->Logger->WriteLogLine(out);
}
if (Config->nofork)
int modelen;
va_list argsPtr;
- if ((!text) || (!modes) || (!flags))
+ if (!text || !modes || !flags)
{
this->Log(DEFAULT,"*** BUG *** WriteMode was given an invalid parameter");
return;
va_end(argsPtr);
modelen = strlen(modes);
- for (std::vector<userrec*>::const_iterator i = local_users.begin(); i != local_users.end(); i++)
+ if (flags == WM_AND)
{
- userrec* t = (userrec*)(*i);
- bool send_to_user = false;
-
- if (flags == WM_AND)
+ for (std::vector<userrec*>::const_iterator i = local_users.begin(); i != local_users.end(); i++)
{
- send_to_user = true;
+ userrec* t = *i;
+ bool send_to_user = true;
for (int n = 0; n < modelen; n++)
{
break;
}
}
+ if (send_to_user)
+ t->WriteServ("NOTICE %s :%s",t->nick,textbuffer);
}
- else if (flags == WM_OR)
+ }
+ else
+ if (flags == WM_OR)
+ {
+ for (std::vector<userrec*>::const_iterator i = local_users.begin(); i != local_users.end(); i++)
{
- send_to_user = false;
+ userrec* t = *i;
+ bool send_to_user = false;
for (int n = 0; n < modelen; n++)
{
break;
}
}
- }
-
- if (send_to_user)
- {
- t->WriteServ("NOTICE %s :%s",t->nick,textbuffer);
+ if (send_to_user)
+ t->WriteServ("NOTICE %s :%s",t->nick,textbuffer);
}
}
}
return true;
}
+bool InspIRCd::IsNick(const char* n)
+{
+ if (!n || !*n)
+ return false;
+
+ int p = 0;
+ for (char* i = (char*)n; *i; i++, p++)
+ {
+ if ((*i >= 'A') && (*i <= '}'))
+ {
+ /* "A"-"}" can occur anywhere in a nickname */
+ continue;
+ }
+
+ if ((((*i >= '0') && (*i <= '9')) || (*i == '-')) && (i > n))
+ {
+ /* "0"-"9", "-" can occur anywhere BUT the first char of a nickname */
+ continue;
+ }
+
+ /* invalid character! abort */
+ return false;
+ }
+
+ /* too long? or not -- pointer arithmetic rocks */
+ return (p < NICKMAX - 1);
+}
+
void InspIRCd::OpenLog(char** argv, int argc)
{
if (!*this->LogFileName)
printf("ERROR: Could not write to logfile %s, bailing!\n\n",Config->logpath.c_str());
Exit(ERROR);
}
+
+ this->Logger = new FileLogger(this, Config->log_file);
return;
}
printf("ERROR: Could not write to logfile %s, bailing!\n\n",Config->logpath.c_str());
Exit(ERROR);
}
+
+ this->Logger = new FileLogger(this, Config->log_file);
}
void InspIRCd::CheckRoot()