diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-12-14 13:11:19 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-12-14 13:11:19 +0000 |
commit | 0f979321b66dd31def3ee900a4b135222ac7f2ba (patch) | |
tree | 644173f4172daad8d925f23ca7415f9712273071 /src | |
parent | 7a17273ec03afb3f5caa0e4b6fe3473cf09711d4 (diff) |
Added config_f to serverconfig, UNTESTED
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2402 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/commands.cpp | 50 | ||||
-rw-r--r-- | src/helperfuncs.cpp | 7 | ||||
-rw-r--r-- | src/inspircd.cpp | 97 | ||||
-rw-r--r-- | src/modules.cpp | 1 | ||||
-rw-r--r-- | src/userprocess.cpp | 6 | ||||
-rw-r--r-- | src/users.cpp | 14 | ||||
-rw-r--r-- | src/xline.cpp | 27 |
7 files changed, 94 insertions, 108 deletions
diff --git a/src/commands.cpp b/src/commands.cpp index cea3fe9e3..9c16a58ad 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -77,8 +77,6 @@ extern std::vector<std::string> module_names; extern int boundPortCount; extern int portCount; extern int ports[MAXSOCKS]; -extern std::stringstream config_f; - extern ClassVector Classes; const long duration_m = 60; @@ -91,8 +89,6 @@ extern user_hash clientlist; extern chan_hash chanlist; extern whowas_hash whowas; extern command_table cmdlist; -extern file_cache MOTD; -extern file_cache RULES; extern address_cache IP; extern std::vector<userrec*> all_opers; @@ -1352,9 +1348,9 @@ void handle_stats(char **parameters, int pcnt, userrec *user) if (*parameters[0] == 'U') { char ulined[MAXBUF]; - for (int i = 0; i < ConfValueEnum("uline",&config_f); i++) + for (int i = 0; i < ConfValueEnum("uline",&Config->config_f); i++) { - ConfValue("uline","server",i,ulined,&config_f); + ConfValue("uline","server",i,ulined,&Config->config_f); WriteServ(user->fd,"248 %s U %s",user->nick,ulined); } } @@ -1422,7 +1418,7 @@ void handle_stats(char **parameters, int pcnt, userrec *user) WriteServ(user->fd,"249 %s :Users(HASH_MAP) %d (%d bytes, %d buckets)",user->nick,clientlist.size(),clientlist.size()*sizeof(userrec),clientlist.bucket_count()); WriteServ(user->fd,"249 %s :Channels(HASH_MAP) %d (%d bytes, %d buckets)",user->nick,chanlist.size(),chanlist.size()*sizeof(chanrec),chanlist.bucket_count()); WriteServ(user->fd,"249 %s :Commands(VECTOR) %d (%d bytes)",user->nick,cmdlist.size(),cmdlist.size()*sizeof(command_t)); - WriteServ(user->fd,"249 %s :MOTD(VECTOR) %d, RULES(VECTOR) %d",user->nick,MOTD.size(),RULES.size()); + WriteServ(user->fd,"249 %s :MOTD(VECTOR) %d, RULES(VECTOR) %d",user->nick,Config->MOTD.size(),Config->RULES.size()); WriteServ(user->fd,"249 %s :address_cache(HASH_MAP) %d (%d buckets)",user->nick,IP.size(),IP.bucket_count()); WriteServ(user->fd,"249 %s :Modules(VECTOR) %d (%d)",user->nick,modules.size(),modules.size()*sizeof(Module)); WriteServ(user->fd,"249 %s :ClassFactories(VECTOR) %d (%d)",user->nick,factory.size(),factory.size()*sizeof(ircd_module)); @@ -1450,14 +1446,14 @@ void handle_stats(char **parameters, int pcnt, userrec *user) /* stats o */ if (*parameters[0] == 'o') { - for (int i = 0; i < ConfValueEnum("oper",&config_f); i++) + for (int i = 0; i < ConfValueEnum("oper",&Config->config_f); i++) { char LoginName[MAXBUF]; char HostName[MAXBUF]; char OperType[MAXBUF]; - ConfValue("oper","name",i,LoginName,&config_f); - ConfValue("oper","host",i,HostName,&config_f); - ConfValue("oper","type",i,OperType,&config_f); + ConfValue("oper","name",i,LoginName,&Config->config_f); + ConfValue("oper","host",i,HostName,&Config->config_f); + ConfValue("oper","type",i,OperType,&Config->config_f); WriteServ(user->fd,"243 %s O %s * %s %s 0",user->nick,HostName,LoginName,OperType); } } @@ -1538,9 +1534,9 @@ bool is_uline(const char* server) if (!(*server)) return true; - for (int i = 0; i < ConfValueEnum("uline",&config_f); i++) + for (int i = 0; i < ConfValueEnum("uline",&Config->config_f); i++) { - ConfValue("uline","server",i,ServName,&config_f); + ConfValue("uline","server",i,ServName,&Config->config_f); if (!strcasecmp(server,ServName)) { return true; @@ -1575,23 +1571,23 @@ void handle_oper(char **parameters, int pcnt, userrec *user) snprintf(TheHost,MAXBUF,"%s@%s",user->ident,user->host); - for (int i = 0; i < ConfValueEnum("oper",&config_f); i++) + for (int i = 0; i < ConfValueEnum("oper",&Config->config_f); i++) { - ConfValue("oper","name",i,LoginName,&config_f); - ConfValue("oper","password",i,Password,&config_f); - ConfValue("oper","type",i,OperType,&config_f); - ConfValue("oper","host",i,HostName,&config_f); + ConfValue("oper","name",i,LoginName,&Config->config_f); + ConfValue("oper","password",i,Password,&Config->config_f); + ConfValue("oper","type",i,OperType,&Config->config_f); + ConfValue("oper","host",i,HostName,&Config->config_f); if ((!strcmp(LoginName,parameters[0])) && (!operstrcmp(Password,parameters[1])) && (match(TheHost,HostName))) { fail2 = true; - for (j =0; j < ConfValueEnum("type",&config_f); j++) + for (j =0; j < ConfValueEnum("type",&Config->config_f); j++) { - ConfValue("type","name",j,TypeName,&config_f); + ConfValue("type","name",j,TypeName,&Config->config_f); if (!strcmp(TypeName,OperType)) { /* found this oper's opertype */ - ConfValue("type","host",j,HostName,&config_f); + ConfValue("type","host",j,HostName,&Config->config_f); if (*HostName) ChangeDisplayedHost(user,HostName); strlcpy(user->oper,TypeName,NICKMAX); @@ -1822,8 +1818,8 @@ bool host_matches_everyone(std::string mask, userrec* user) char insanemasks[MAXBUF]; char buffer[MAXBUF]; char itrigger[MAXBUF]; - ConfValue("insane","hostmasks",0,insanemasks,&config_f); - ConfValue("insane","trigger",0,itrigger,&config_f); + ConfValue("insane","hostmasks",0,insanemasks,&Config->config_f); + ConfValue("insane","trigger",0,itrigger,&Config->config_f); if (*itrigger == 0) strlcpy(itrigger,"95.5",MAXBUF); if ((*insanemasks == 'y') || (*insanemasks == 't') || (*insanemasks == '1')) @@ -1850,8 +1846,8 @@ bool ip_matches_everyone(std::string ip, userrec* user) { char insanemasks[MAXBUF]; char itrigger[MAXBUF]; - ConfValue("insane","ipmasks",0,insanemasks,&config_f); - ConfValue("insane","trigger",0,itrigger,&config_f); + ConfValue("insane","ipmasks",0,insanemasks,&Config->config_f); + ConfValue("insane","trigger",0,itrigger,&Config->config_f); if (*itrigger == 0) strlcpy(itrigger,"95.5",MAXBUF); if ((*insanemasks == 'y') || (*insanemasks == 't') || (*insanemasks == '1')) @@ -1875,8 +1871,8 @@ bool nick_matches_everyone(std::string nick, userrec* user) { char insanemasks[MAXBUF]; char itrigger[MAXBUF]; - ConfValue("insane","nickmasks",0,insanemasks,&config_f); - ConfValue("insane","trigger",0,itrigger,&config_f); + ConfValue("insane","nickmasks",0,insanemasks,&Config->config_f); + ConfValue("insane","trigger",0,itrigger,&Config->config_f); if (*itrigger == 0) strlcpy(itrigger,"95.5",MAXBUF); if ((*insanemasks == 'y') || (*insanemasks == 't') || (*insanemasks == '1')) diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index eed15dc7b..3a508e9d6 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -56,7 +56,6 @@ extern ServerConfig *Config; extern time_t TIME; extern char lowermap[255]; -extern std::stringstream config_f; static char list[MAXBUF]; extern userrec* fd_ref_table[65536]; @@ -772,12 +771,12 @@ chanrec* FindChan(const char* chan) long GetMaxBans(char* name) { char CM[MAXBUF]; - for (int count = 0; count < ConfValueEnum("banlist",&config_f); count++) + for (int count = 0; count < ConfValueEnum("banlist",&Config->config_f); count++) { - ConfValue("banlist","chan",count,CM,&config_f); + ConfValue("banlist","chan",count,CM,&Config->config_f); if (match(name,CM)) { - ConfValue("banlist","limit",count,CM,&config_f); + ConfValue("banlist","limit",count,CM,&Config->config_f); return atoi(CM); } } diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 5d92f2226..2321aebf5 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -99,8 +99,6 @@ user_hash clientlist; chan_hash chanlist; whowas_hash whowas; command_table cmdlist; -file_cache MOTD; -file_cache RULES; address_cache IP; ClassVector Classes; @@ -111,14 +109,12 @@ int portCount = 0, ports[MAXSOCKS]; /* prototypes */ -int has_channel(userrec *u, chanrec *c); +/*int has_channel(userrec *u, chanrec *c); int usercount(chanrec *c); int usercount_i(chanrec *c); char* Passwd(userrec *user); bool IsDenied(userrec *user); -void AddWhoWas(userrec* u); - -std::stringstream config_f(stringstream::in | stringstream::out); +void AddWhoWas(userrec* u);*/ std::vector<userrec*> all_opers; @@ -221,7 +217,7 @@ void ReadConfig(bool bail, userrec* user) std::stringstream errstr; include_stack.clear(); - if (!LoadConf(CONFIG_FILE,&config_f,&errstr)) + if (!LoadConf(CONFIG_FILE,&Config->config_f,&errstr)) { errstr.seekg(0); log(DEFAULT,"There were errors in your configuration:\n%s",errstr.str().c_str()); @@ -255,31 +251,31 @@ void ReadConfig(bool bail, userrec* user) } } - ConfValue("server","name",0,Config->ServerName,&config_f); - ConfValue("server","description",0,Config->ServerDesc,&config_f); - ConfValue("server","network",0,Config->Network,&config_f); - ConfValue("admin","name",0,Config->AdminName,&config_f); - ConfValue("admin","email",0,Config->AdminEmail,&config_f); - ConfValue("admin","nick",0,Config->AdminNick,&config_f); - ConfValue("files","motd",0,Config->motd,&config_f); - ConfValue("files","rules",0,Config->rules,&config_f); - ConfValue("power","diepass",0,Config->diepass,&config_f); - ConfValue("power","pause",0,pauseval,&config_f); - ConfValue("power","restartpass",0,Config->restartpass,&config_f); - ConfValue("options","prefixquit",0,Config->PrefixQuit,&config_f); - ConfValue("die","value",0,Config->DieValue,&config_f); - ConfValue("options","loglevel",0,dbg,&config_f); - ConfValue("options","netbuffersize",0,NB,&config_f); - ConfValue("options","maxwho",0,MW,&config_f); - ConfValue("options","allowhalfop",0,AH,&config_f); - ConfValue("options","allowprotect",0,AP,&config_f); - ConfValue("options","allowfounder",0,AF,&config_f); - ConfValue("dns","server",0,Config->DNSServer,&config_f); - ConfValue("dns","timeout",0,DNT,&config_f); - ConfValue("options","moduledir",0,Config->ModPath,&config_f); - ConfValue("disabled","commands",0,Config->DisabledCommands,&config_f); - ConfValue("options","somaxconn",0,MCON,&config_f); - ConfValue("options","softlimit",0,SLIMT,&config_f); + ConfValue("server","name",0,Config->ServerName,&Config->config_f); + ConfValue("server","description",0,Config->ServerDesc,&Config->config_f); + ConfValue("server","network",0,Config->Network,&Config->config_f); + ConfValue("admin","name",0,Config->AdminName,&Config->config_f); + ConfValue("admin","email",0,Config->AdminEmail,&Config->config_f); + ConfValue("admin","nick",0,Config->AdminNick,&Config->config_f); + ConfValue("files","motd",0,Config->motd,&Config->config_f); + ConfValue("files","rules",0,Config->rules,&Config->config_f); + ConfValue("power","diepass",0,Config->diepass,&Config->config_f); + ConfValue("power","pause",0,pauseval,&Config->config_f); + ConfValue("power","restartpass",0,Config->restartpass,&Config->config_f); + ConfValue("options","prefixquit",0,Config->PrefixQuit,&Config->config_f); + ConfValue("die","value",0,Config->DieValue,&Config->config_f); + ConfValue("options","loglevel",0,dbg,&Config->config_f); + ConfValue("options","netbuffersize",0,NB,&Config->config_f); + ConfValue("options","maxwho",0,MW,&Config->config_f); + ConfValue("options","allowhalfop",0,AH,&Config->config_f); + ConfValue("options","allowprotect",0,AP,&Config->config_f); + ConfValue("options","allowfounder",0,AF,&Config->config_f); + ConfValue("dns","server",0,Config->DNSServer,&Config->config_f); + ConfValue("dns","timeout",0,DNT,&Config->config_f); + ConfValue("options","moduledir",0,Config->ModPath,&Config->config_f); + ConfValue("disabled","commands",0,Config->DisabledCommands,&Config->config_f); + ConfValue("options","somaxconn",0,MCON,&Config->config_f); + ConfValue("options","softlimit",0,SLIMT,&Config->config_f); Config->SoftLimit = atoi(SLIMT); if ((Config->SoftLimit < 1) || (Config->SoftLimit > MAXCLIENTS)) @@ -332,22 +328,22 @@ void ReadConfig(bool bail, userrec* user) readfile(RULES,Config->rules); log(DEFAULT,"Reading connect classes..."); Classes.clear(); - for (int i = 0; i < ConfValueEnum("connect",&config_f); i++) + for (int i = 0; i < ConfValueEnum("connect",&Config->config_f); i++) { strcpy(Value,""); - ConfValue("connect","allow",i,Value,&config_f); - ConfValue("connect","timeout",i,timeout,&config_f); - ConfValue("connect","flood",i,flood,&config_f); - ConfValue("connect","pingfreq",i,pfreq,&config_f); - ConfValue("connect","threshold",i,thold,&config_f); - ConfValue("connect","sendq",i,sqmax,&config_f); - ConfValue("connect","recvq",i,rqmax,&config_f); + ConfValue("connect","allow",i,Value,&Config->config_f); + ConfValue("connect","timeout",i,timeout,&Config->config_f); + ConfValue("connect","flood",i,flood,&Config->config_f); + ConfValue("connect","pingfreq",i,pfreq,&Config->config_f); + ConfValue("connect","threshold",i,thold,&Config->config_f); + ConfValue("connect","sendq",i,sqmax,&Config->config_f); + ConfValue("connect","recvq",i,rqmax,&Config->config_f); if (Value[0]) { strlcpy(c.host,Value,MAXBUF); c.type = CC_ALLOW; strlcpy(Value,"",MAXBUF); - ConfValue("connect","password",i,Value,&config_f); + ConfValue("connect","password",i,Value,&Config->config_f); strlcpy(c.pass,Value,MAXBUF); c.registration_timeout = 90; // default is 2 minutes c.pingtime = 120; @@ -380,7 +376,7 @@ void ReadConfig(bool bail, userrec* user) } else { - ConfValue("connect","deny",i,Value,&config_f); + ConfValue("connect","deny",i,Value,&Config->config_f); strlcpy(c.host,Value,MAXBUF); c.type = CC_DENY; Classes.push_back(c); @@ -407,9 +403,9 @@ void ReadConfig(bool bail, userrec* user) } // get the new module names - for (int count2 = 0; count2 < ConfValueEnum("module",&config_f); count2++) + for (int count2 = 0; count2 < ConfValueEnum("module",&Config->config_f); count2++) { - ConfValue("module","name",count2,Value,&config_f); + ConfValue("module","name",count2,Value,&Config->config_f); new_module_names.push_back(Value); } @@ -2164,11 +2160,11 @@ int BindPorts() { char configToken[MAXBUF], Addr[MAXBUF], Type[MAXBUF]; int clientportcount = 0; - for (int count = 0; count < ConfValueEnum("bind",&config_f); count++) + for (int count = 0; count < ConfValueEnum("bind",&Config->config_f); count++) { - ConfValue("bind","port",count,configToken,&config_f); - ConfValue("bind","address",count,Addr,&config_f); - ConfValue("bind","type",count,Type,&config_f); + ConfValue("bind","port",count,configToken,&Config->config_f); + ConfValue("bind","address",count,Addr,&Config->config_f); + ConfValue("bind","type",count,Type,&Config->config_f); if (strcmp(Type,"servers")) { // modules handle server bind types now, @@ -2237,8 +2233,7 @@ int InspIRCd(char** argv, int argc) printf("\n"); startup_time = time(NULL); - char PID[MAXBUF]; - ConfValue("pid","file",0,PID,&config_f); + ConfValue("pid","file",0,Config->PID,&Config->config_f); // write once here, to try it out and make sure its ok WritePID(PID); @@ -2272,7 +2267,7 @@ int InspIRCd(char** argv, int argc) for (int count = 0; count < portCount; count++) SE->AddFd(openSockfd[count],true,X_LISTEN); - WritePID(PID); + WritePID(Config->PID); /* main loop, this never returns */ for (;;) diff --git a/src/modules.cpp b/src/modules.cpp index 736042c33..96e9bdea5 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -69,7 +69,6 @@ extern int ports[MAXSOCKS]; class Server; -extern std::stringstream config_f; extern userrec* fd_ref_table[65536]; extern user_hash clientlist; diff --git a/src/userprocess.cpp b/src/userprocess.cpp index 86a03cca1..055dc2075 100644 --- a/src/userprocess.cpp +++ b/src/userprocess.cpp @@ -82,8 +82,6 @@ extern user_hash clientlist; extern chan_hash chanlist; extern whowas_hash whowas; -extern std::stringstream config_f; - void ProcessUser(userrec* cu) { int result = EAGAIN; @@ -378,9 +376,9 @@ void LoadAllModules() /* We must load the modules AFTER initializing the socket engine, now */ MODCOUNT = -1; char configToken[MAXBUF]; - for (int count = 0; count < ConfValueEnum("module",&config_f); count++) + for (int count = 0; count < ConfValueEnum("module",&Config->config_f); count++) { - ConfValue("module","name",count,configToken,&config_f); + ConfValue("module","name",count,configToken,&Config->config_f); printf("Loading module... \033[1;32m%s\033[0m\n",configToken); if (!LoadModule(configToken)) { diff --git a/src/users.cpp b/src/users.cpp index f1dc57794..6d4195f45 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -30,9 +30,7 @@ using namespace std; #include "commands.h" #include "helperfuncs.h" -extern std::stringstream config_f; extern ServerConfig* Config; - extern time_t TIME; userrec::userrec() @@ -162,21 +160,21 @@ bool userrec::HasPermission(char* command) // are they even an oper at all? if (strchr(this->modes,'o')) { - for (int j =0; j < ConfValueEnum("type",&config_f); j++) + for (int j =0; j < ConfValueEnum("type",&Config->config_f); j++) { - ConfValue("type","name",j,TypeName,&config_f); + ConfValue("type","name",j,TypeName,&Config->config_f); if (!strcmp(TypeName,this->oper)) { - ConfValue("type","classes",j,Classes,&config_f); + ConfValue("type","classes",j,Classes,&Config->config_f); char* myclass = strtok_r(Classes," ",&savept); while (myclass) { - for (int k =0; k < ConfValueEnum("class",&config_f); k++) + for (int k =0; k < ConfValueEnum("class",&Config->config_f); k++) { - ConfValue("class","name",k,ClassName,&config_f); + ConfValue("class","name",k,ClassName,&Config->config_f); if (!strcmp(ClassName,myclass)) { - ConfValue("class","commands",k,CommandList,&config_f); + ConfValue("class","commands",k,CommandList,&Config->config_f); mycmd = strtok_r(CommandList," ",&savept2); while (mycmd) { diff --git a/src/xline.cpp b/src/xline.cpp index 32d35dace..d08383f8c 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -48,11 +48,12 @@ using namespace std; #include "hashcomp.h" #include "typedefs.h" +extern ServerConfig *Config; + extern int MODCOUNT; extern std::vector<Module*> modules; extern std::vector<ircd_module*> factory; extern ServerConfig* Config; -extern std::stringstream config_f; extern user_hash clientlist; /* Version two, now with optimized expiry! @@ -112,33 +113,33 @@ void read_xline_defaults() char host[MAXBUF]; char reason[MAXBUF]; - for (int i = 0; i < ConfValueEnum("badip",&config_f); i++) + for (int i = 0; i < ConfValueEnum("badip",&Config->config_f); i++) { - ConfValue("badip","ipmask",i,ipmask,&config_f); - ConfValue("badip","reason",i,reason,&config_f); + ConfValue("badip","ipmask",i,ipmask,&Config->config_f); + ConfValue("badip","reason",i,reason,&Config->config_f); add_zline(0,"<Config>",reason,ipmask); log(DEBUG,"Read Z line (badip tag): ipmask=%s reason=%s",ipmask,reason); } - for (int i = 0; i < ConfValueEnum("badnick",&config_f); i++) + for (int i = 0; i < ConfValueEnum("badnick",&Config->config_f); i++) { - ConfValue("badnick","nick",i,nick,&config_f); - ConfValue("badnick","reason",i,reason,&config_f); + ConfValue("badnick","nick",i,nick,&Config->config_f); + ConfValue("badnick","reason",i,reason,&Config->config_f); add_qline(0,"<Config>",reason,nick); log(DEBUG,"Read Q line (badnick tag): nick=%s reason=%s",nick,reason); } - for (int i = 0; i < ConfValueEnum("badhost",&config_f); i++) + for (int i = 0; i < ConfValueEnum("badhost",&Config->config_f); i++) { - ConfValue("badhost","host",i,host,&config_f); - ConfValue("badhost","reason",i,reason,&config_f); + ConfValue("badhost","host",i,host,&Config->config_f); + ConfValue("badhost","reason",i,reason,&Config->config_f); add_kline(0,"<Config>",reason,host); log(DEBUG,"Read K line (badhost tag): host=%s reason=%s",host,reason); } - for (int i = 0; i < ConfValueEnum("exception",&config_f); i++) + for (int i = 0; i < ConfValueEnum("exception",&Config->config_f); i++) { - ConfValue("exception","host",i,host,&config_f); - ConfValue("exception","reason",i,reason,&config_f); + ConfValue("exception","host",i,host,&Config->config_f); + ConfValue("exception","reason",i,reason,&Config->config_f); add_eline(0,"<Config>",reason,host); log(DEBUG,"Read E line (exception tag): host=%s reason=%s",host,reason); } |