From aa21503f06e3a32945c003ce4193a766ea58642b Mon Sep 17 00:00:00 2001 From: om Date: Sun, 9 Apr 2006 11:51:24 +0000 Subject: Shuffle some more includes around, const reference a few functions in inspircd.* git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3854 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/inspircd.h | 49 +++++++++++++++---------------------------------- include/socket.h | 4 ++++ src/helperfuncs.cpp | 1 + src/inspircd.cpp | 42 +++++++++++++++++++----------------------- 4 files changed, 39 insertions(+), 57 deletions(-) diff --git a/include/inspircd.h b/include/inspircd.h index bd180328d..c13c4dd7f 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -17,28 +17,9 @@ #ifndef __INSPIRCD_H__ #define __INSPIRCD_H__ -#include "inspircd_config.h" #include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef _LINUX_C_LIB_VERSION -#include -#include -#include -#endif - -#include -#include -#include #include - +#include "inspircd_config.h" #include "users.h" #include "channels.h" #include "socket.h" @@ -46,17 +27,18 @@ #include "socketengine.h" #include "command_parse.h" -// some misc defines +/* Some misc defines */ #define ERROR -1 #define MAXCOMMAND 32 -// crucial defines +/* Crucial defines */ #define ETIREDGERBILS EAGAIN -// This define is used in place of strcmp when we -// want to check if a char* string contains only one -// letter. Pretty fast, its just two compares and an -// addition. +/* This define is used in place of strcmp when we + * want to check if a char* string contains only one + * letter. Pretty fast, its just two compares and an + * addition. + */ #define IS_SINGLE(x,y) ( (*x == y) && (*(x+1) == 0) ) template inline std::string ConvToStr(const T &in) @@ -66,7 +48,6 @@ template inline std::string ConvToStr(const T &in) return tmp.str(); } - class serverstats { public: @@ -94,14 +75,14 @@ class serverstats class InspIRCd { - private: char MODERR[MAXBUF]; - void erase_factory(int j); - void erase_module(int j); + bool expire_run; + + void erase_factory(int j); + void erase_module(int j); void BuildISupport(); void MoveTo(std::string modulename,int slot); - bool expire_run; public: time_t startup_time; @@ -134,8 +115,8 @@ bool DaemonSeed(); void WritePID(const std::string &filename); /* userrec optimization stuff */ -void AddServerName(std::string servername); -const char* FindServerNamePtr(std::string servername); -bool FindServerName(std::string servername); +void AddServerName(const std::string &servername); +const char* FindServerNamePtr(const std::string &servername); +bool FindServerName(const std::string &servername); #endif diff --git a/include/socket.h b/include/socket.h index e62a2dc41..60347506d 100644 --- a/include/socket.h +++ b/include/socket.h @@ -19,14 +19,18 @@ /* This is where we'll define wrappers for socket IO stuff, for neat winsock compatability */ +#include #include #include #include #include +#include #include #include #include #include +#include +#include #include "inspircd_config.h" /* macros to the relevant system address description structs */ diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 3a0f39c6d..6412175b1 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include diff --git a/src/inspircd.cpp b/src/inspircd.cpp index fd164000a..5e437365b 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -16,12 +16,14 @@ /* Now with added unF! ;) */ +#include #include "inspircd_config.h" #include "inspircd.h" #include "configreader.h" #include #include #include +#include #include #include #include @@ -60,8 +62,8 @@ InspIRCd* ServerInstance; int WHOWAS_STALE = 48; // default WHOWAS Entries last 2 days before they go 'stale' int WHOWAS_MAX = 100; // default 100 people maximum in the WHOWAS list -extern std::vector modules; -extern std::vector factory; +extern ModuleList modules; +extern FactoryList factory; std::vector module_sockets; std::vector local_users; @@ -94,36 +96,30 @@ chan_hash chanlist; servernamelist servernames; char lowermap[255]; -void AddServerName(std::string servername) +void AddServerName(const std::string &servername) { log(DEBUG,"Adding server name: %s",servername.c_str()); - for (servernamelist::iterator a = servernames.begin(); a < servernames.end(); a++) - { - if (*a == servername) - return; - } - servernames.push_back(servername); + + if(find(servernames.begin(), servernames.end(), servername) == servernames.end()) + servernames.push_back(servername); /* Wasn't already there. */ } -const char* FindServerNamePtr(std::string servername) +const char* FindServerNamePtr(const std::string &servername) { - for (servernamelist::iterator a = servernames.begin(); a < servernames.end(); a++) - { - if (*a == servername) - return a->c_str(); + servernamelist::iterator iter = find(servernames.begin(), servernames.end(), servername); + + if(iter == servernames.end()) + { + AddServerName(servername); + iter = --servernames.end(); } - AddServerName(servername); - return FindServerNamePtr(servername); + + return iter->c_str(); } -bool FindServerName(std::string servername) +bool FindServerName(const std::string &servername) { - for (servernamelist::iterator a = servernames.begin(); a < servernames.end(); a++) - { - if (*a == servername) - return true; - } - return false; + return (find(servernames.begin(), servernames.end(), servername) != servernames.end()); } void Exit(int status) -- cgit v1.2.3