#include <stdarg.h>
#include "inspircd_config.h"
-#include "inspircd.h"
#include "configreader.h"
#include <unistd.h>
#include <fcntl.h>
#include "helperfuncs.h"
#include "hashcomp.h"
#include "typedefs.h"
+#include "inspircd.h"
extern int MODCOUNT;
extern ModuleList modules;
extern time_t TIME;
extern char lowermap[255];
extern std::vector<userrec*> all_opers;
-extern user_hash clientlist;
-extern chan_hash chanlist;
char LOG_FILE[MAXBUF];
-extern std::vector<userrec*> local_users;
-
static char TIMESTR[26];
static time_t LAST = 0;
}
}
-void ServerNoticeAll(char* text, ...)
+void InspIRCd::ServerNoticeAll(char* text, ...)
{
if (!text)
return;
}
}
-void ServerPrivmsgAll(char* text, ...)
+void InspIRCd::ServerPrivmsgAll(char* text, ...)
{
if (!text)
return;
}
}
-void WriteMode(const char* modes, int flags, const char* text, ...)
+void InspIRCd::WriteMode(const char* modes, int flags, const char* text, ...)
{
char textbuffer[MAXBUF];
int modelen;
}
}
-void NoticeAll(userrec *source, bool local_only, char* text, ...)
-{
- char textbuffer[MAXBUF];
- char formatbuffer[MAXBUF];
- va_list argsPtr;
-
- if ((!text) || (!source))
- {
- log(DEFAULT,"*** BUG *** NoticeAll was given an invalid parameter");
- return;
- }
-
- va_start(argsPtr, text);
- vsnprintf(textbuffer, MAXBUF, text, argsPtr);
- va_end(argsPtr);
-
- snprintf(formatbuffer,MAXBUF,"NOTICE $* :%s",textbuffer);
-
- for (std::vector<userrec*>::const_iterator i = local_users.begin(); i != local_users.end(); i++)
- {
- userrec* t = *i;
- t->WriteFrom(source,std::string(formatbuffer));
- }
-}
-
-
/* convert a string to lowercase. Note following special circumstances
* taken from RFC 1459. Many "official" server branches still hold to this
* rule so i will too;
userrec* Find(const std::string &nick)
{
- user_hash::iterator iter = clientlist.find(nick);
+ user_hash::iterator iter = ServerInstance->clientlist.find(nick);
- if (iter == clientlist.end())
+ if (iter == ServerInstance->clientlist.end())
/* Couldn't find it */
return NULL;
if (!nick)
return NULL;
- iter = clientlist.find(nick);
+ iter = ServerInstance->clientlist.find(nick);
- if (iter == clientlist.end())
+ if (iter == ServerInstance->clientlist.end())
return NULL;
return iter->second;
return NULL;
}
- iter = chanlist.find(chan);
+ iter = ServerInstance->chanlist.find(chan);
- if (iter == chanlist.end())
+ if (iter == ServerInstance->chanlist.end())
/* Couldn't find it */
return NULL;
for (std::vector<chanrec*>::iterator n = to_delete.begin(); n != to_delete.end(); n++)
{
chanrec* thischan = (chanrec*)*n;
- chan_hash::iterator i2 = chanlist.find(thischan->name);
- if (i2 != chanlist.end())
+ chan_hash::iterator i2 = ServerInstance->chanlist.find(thischan->name);
+ if (i2 != ServerInstance->chanlist.end())
{
FOREACH_MOD(I_OnChannelDelete,OnChannelDelete(i2->second));
DELETE(i2->second);
- chanlist.erase(i2);
+ ServerInstance->chanlist.erase(i2);
}
}
return count;
}
-int usercount(chanrec *c)
-{
- return (c ? c->GetUserCounter() : 0);
-}
-
-
/* looks up a users password for their connection class (<ALLOW>/<DENY> tags)
* NOTE: If the <ALLOW> or <DENY> tag specifies an ip, and this user resolves,
* then their ip will be taken as 'priority' anyway, so for example,
* sends out an error notice to all connected clients (not to be used
* lightly!)
*/
-void send_error(char *s)
+void InspIRCd::SendError(const char *s)
{
- log(DEBUG,"send_error: %s",s);
-
- for (std::vector<userrec*>::const_iterator i = local_users.begin(); i != local_users.end(); i++)
+ for (std::vector<userrec*>::const_iterator i = this->local_users.begin(); i != this->local_users.end(); i++)
{
userrec* t = (userrec*)(*i);
if (t->registered == REG_ALL)
#else
log(DEFAULT,"You do not have execinfo.h so i could not backtrace -- on FreeBSD, please install the libexecinfo port.");
#endif
- send_error("Somebody screwed up... Whoops. IRC Server terminating.");
+ ServerInstance->SendError("Somebody screwed up... Whoops. IRC Server terminating.");
signal(SIGSEGV, SIG_DFL);
if (raise(SIGSEGV) == -1)
{
}
// this function counts all users connected, wether they are registered or NOT.
-int usercnt(void)
+int InspIRCd::usercnt()
{
return clientlist.size();
}
// this counts only registered users, so that the percentages in /MAP don't mess up when users are sitting in an unregistered state
-int registered_usercount(void)
+int InspIRCd::registered_usercount()
{
int c = 0;
return c;
}
-int usercount_invisible(void)
+int InspIRCd::usercount_invisible()
{
int c = 0;
return c;
}
-int usercount_opers(void)
+int InspIRCd::usercount_opers()
{
int c = 0;
return c;
}
-int usercount_unknown(void)
+int InspIRCd::usercount_unknown()
{
int c = 0;
return c;
}
-long chancount(void)
+long InspIRCd::chancount()
{
return chanlist.size();
}
-long local_count()
+long InspIRCd::local_count()
{
int c = 0;