diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2004-05-01 16:12:17 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2004-05-01 16:12:17 +0000 |
commit | 90cc4b0ee93696e6e6b3208cd2877ae6e786440d (patch) | |
tree | d0b0b48f8c97d72c879ad0297d46d9b4f383542f /src/modules.cpp | |
parent | f743a782e67b56c35b5b7be7ef357a2ca109c244 (diff) |
Provided modules with the ability to sync data on a netjoin
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@767 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules.cpp')
-rw-r--r-- | src/modules.cpp | 192 |
1 files changed, 180 insertions, 12 deletions
diff --git a/src/modules.cpp b/src/modules.cpp index d4d647d7e..e05ab4566 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -1,21 +1,166 @@ -/* - - -*/ - - - -#include <typeinfo> -#include <iostream> +#include "inspircd.h" +#include "inspircd_io.h" +#include "inspircd_util.h" +#include "inspircd_config.h" +#include <unistd.h> +#include <fcntl.h> +#include <sys/errno.h> +#include <sys/ioctl.h> +#include <sys/utsname.h> +#include <cstdio> +#include <time.h> +#include <string> +#ifdef GCC3 +#include <ext/hash_map> +#else +#include <hash_map> +#endif +#include <map> +#include <sstream> +#include <vector> +#include <errno.h> +#include <deque> +#include <errno.h> +#include <unistd.h> +#include <sched.h> +#include "connection.h" +#include "users.h" +#include "servers.h" +#include "ctables.h" #include "globals.h" #include "modules.h" -#include "ctables.h" -#include "inspircd_io.h" +#include "dynamic.h" #include "wildcard.h" -#include "mode.h" #include "message.h" +#include "mode.h" +#include "xline.h" #include "commands.h" +#ifdef GCC3 +#define nspace __gnu_cxx +#else +#define nspace std +#endif + +using namespace std; + +extern int MODCOUNT; +extern vector<Module*> modules; +extern vector<ircd_module*> factory; + +extern int LogLevel; +extern char ServerName[MAXBUF]; +extern char Network[MAXBUF]; +extern char ServerDesc[MAXBUF]; +extern char AdminName[MAXBUF]; +extern char AdminEmail[MAXBUF]; +extern char AdminNick[MAXBUF]; +extern char diepass[MAXBUF]; +extern char restartpass[MAXBUF]; +extern char motd[MAXBUF]; +extern char rules[MAXBUF]; +extern char list[MAXBUF]; +extern char PrefixQuit[MAXBUF]; +extern char DieValue[MAXBUF]; + +extern int debugging; +extern int WHOWAS_STALE; +extern int WHOWAS_MAX; +extern int DieDelay; +extern time_t startup_time; +extern int NetBufferSize; +extern int MaxWhoResults; +extern time_t nb_start; + +extern std::vector<int> fd_reap; +extern std::vector<std::string> module_names; + +extern char bannerBuffer[MAXBUF]; +extern int boundPortCount; +extern int portCount; +extern int UDPportCount; +extern int ports[MAXSOCKS]; +extern int defaultRoute; + +extern std::vector<long> auth_cookies; +extern std::stringstream config_f; + +extern serverrec* me[32]; + +extern FILE *log_file; + + +namespace nspace +{ + template<> struct nspace::hash<in_addr> + { + size_t operator()(const struct in_addr &a) const + { + size_t q; + memcpy(&q,&a,sizeof(size_t)); + return q; + } + }; + + template<> struct nspace::hash<string> + { + size_t operator()(const string &s) const + { + char a[MAXBUF]; + static struct hash<const char *> strhash; + strcpy(a,s.c_str()); + strlower(a); + return strhash(a); + } + }; +} + + +struct StrHashComp +{ + + bool operator()(const string& s1, const string& s2) const + { + char a[MAXBUF],b[MAXBUF]; + strcpy(a,s1.c_str()); + strcpy(b,s2.c_str()); + return (strcasecmp(a,b) == 0); + } + +}; + +struct InAddr_HashComp +{ + + bool operator()(const in_addr &s1, const in_addr &s2) const + { + size_t q; + size_t p; + + memcpy(&q,&s1,sizeof(size_t)); + memcpy(&p,&s2,sizeof(size_t)); + + return (q == p); + } + +}; + + +typedef nspace::hash_map<std::string, userrec*, nspace::hash<string>, StrHashComp> user_hash; +typedef nspace::hash_map<std::string, chanrec*, nspace::hash<string>, StrHashComp> chan_hash; +typedef nspace::hash_map<in_addr,string*, nspace::hash<in_addr>, InAddr_HashComp> address_cache; +typedef std::deque<command_t> command_table; + + +extern user_hash clientlist; +extern chan_hash chanlist; +extern user_hash whowas; +extern command_table cmdlist; +extern file_cache MOTD; +extern file_cache RULES; +extern address_cache IP; + + // class type for holding an extended mode character - internal to core class ExtMode : public classbase @@ -33,6 +178,7 @@ public: typedef std::vector<ExtMode> ExtModeList; typedef ExtModeList::iterator ExtModeListIter; + ExtModeList EMode; // returns true if an extended mode character is in use @@ -156,6 +302,9 @@ int Module::OnUserPreMessage(userrec* user,void* dest,int target_type, std::stri int Module::OnUserPreNotice(userrec* user,void* dest,int target_type, std::string text) { return 0; }; int Module::OnUserPreNick(userrec* user, std::string newnick) { return 0; }; int Module::OnAccessCheck(userrec* source,userrec* dest,chanrec* channel,int access_type) { return ACR_DEFAULT; }; +string_list Module::OnUserSync(userrec* user) { string_list empty; return empty; } +string_list Module::OnChannelSync(chanrec* chan) { string_list empty; return empty; } + // server is a wrapper class that provides methods to all of the C-style // exports in the core @@ -197,6 +346,25 @@ chanrec* Server::PartUserFromChannel(userrec* user, std::string cname, std::stri return del_channel(user,cname.c_str(),reason.c_str(),false); } +chanuserlist Server::GetUsers(chanrec* chan) +{ + chanuserlist userl; + userl.clear(); + for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++) + { + if (i->second) + { + if (has_channel(i->second,chan)) + { + if (isnick(i->second->nick)) + { + userl.push_back(i->second); + } + } + } + } + return userl; +} void Server::ChangeUserNick(userrec* user, std::string nickname) { force_nickchange(user,nickname.c_str()); |