From badadc427a99e5483402c21bf5b7ae64722930e9 Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 19 May 2007 17:22:43 +0000 Subject: Visual studio's ability to translate tabs to four spaces as default frustrates and peplexes tabnazi cat. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7047 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/cmd_stats.cpp | 12 ++++---- src/cmd_whowas.cpp | 2 +- src/dns.cpp | 12 ++++---- src/hashcomp.cpp | 10 +++---- src/inspircd.cpp | 24 +++++++-------- src/inspsocket.cpp | 6 ++-- src/inspstring.cpp | 87 +++++++++++++++++++++++++++--------------------------- src/snomasks.cpp | 2 +- src/socket.cpp | 12 ++++---- src/users.cpp | 6 ++-- 10 files changed, 86 insertions(+), 87 deletions(-) (limited to 'src') diff --git a/src/cmd_stats.cpp b/src/cmd_stats.cpp index 55b7e68eb..1059745c6 100644 --- a/src/cmd_stats.cpp +++ b/src/cmd_stats.cpp @@ -174,16 +174,16 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, userrec* user, case 'z': { #ifndef WIN32 - rusage R; + rusage R; results.push_back(sn+" 240 "+user->nick+" :InspIRCd(CLASS) "+ConvToStr(sizeof(InspIRCd))+" bytes"); results.push_back(sn+" 249 "+user->nick+" :Users(HASH_MAP) "+ConvToStr(ServerInstance->clientlist->size())+" ("+ConvToStr(ServerInstance->clientlist->size()*sizeof(userrec))+" bytes, "+ConvToStr(ServerInstance->clientlist->bucket_count())+" buckets)"); results.push_back(sn+" 249 "+user->nick+" :Channels(HASH_MAP) "+ConvToStr(ServerInstance->chanlist->size())+" ("+ConvToStr(ServerInstance->chanlist->size()*sizeof(chanrec))+" bytes, "+ConvToStr(ServerInstance->chanlist->bucket_count())+" buckets)"); results.push_back(sn+" 249 "+user->nick+" :Commands(VECTOR) "+ConvToStr(ServerInstance->Parser->cmdlist.size())+" ("+ConvToStr(ServerInstance->Parser->cmdlist.size()*sizeof(command_t))+" bytes)"); #else - results.push_back(sn+" 240 "+user->nick+" :InspIRCd(CLASS) "+ConvToStr(sizeof(InspIRCd))+" bytes"); - results.push_back(sn+" 249 "+user->nick+" :Users(HASH_MAP) "+ConvToStr(ServerInstance->clientlist->size())+" ("+ConvToStr(ServerInstance->clientlist->size()*sizeof(userrec))+" bytes)"); - results.push_back(sn+" 249 "+user->nick+" :Channels(HASH_MAP) "+ConvToStr(ServerInstance->chanlist->size())+" ("+ConvToStr(ServerInstance->chanlist->size()*sizeof(chanrec))+" bytes)"); - results.push_back(sn+" 249 "+user->nick+" :Commands(VECTOR) "+ConvToStr(ServerInstance->Parser->cmdlist.size())+" ("+ConvToStr(ServerInstance->Parser->cmdlist.size()*sizeof(command_t))+" bytes)"); + results.push_back(sn+" 240 "+user->nick+" :InspIRCd(CLASS) "+ConvToStr(sizeof(InspIRCd))+" bytes"); + results.push_back(sn+" 249 "+user->nick+" :Users(HASH_MAP) "+ConvToStr(ServerInstance->clientlist->size())+" ("+ConvToStr(ServerInstance->clientlist->size()*sizeof(userrec))+" bytes)"); + results.push_back(sn+" 249 "+user->nick+" :Channels(HASH_MAP) "+ConvToStr(ServerInstance->chanlist->size())+" ("+ConvToStr(ServerInstance->chanlist->size()*sizeof(chanrec))+" bytes)"); + results.push_back(sn+" 249 "+user->nick+" :Commands(VECTOR) "+ConvToStr(ServerInstance->Parser->cmdlist.size())+" ("+ConvToStr(ServerInstance->Parser->cmdlist.size()*sizeof(command_t))+" bytes)"); #endif if (!ServerInstance->Config->WhoWasGroupSize == 0 && !ServerInstance->Config->WhoWasMaxGroups == 0) { @@ -208,7 +208,7 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, userrec* user, results.push_back(sn+" 249 "+user->nick+" :ClassFactories(VECTOR) "+ConvToStr(ServerInstance->factory.size())+" ("+ConvToStr(ServerInstance->factory.size()*sizeof(ircd_module))+" bytes)"); #ifndef WIN32 - if (!getrusage(0,&R)) /* RUSAGE_SELF */ + if (!getrusage(0,&R)) /* RUSAGE_SELF */ { results.push_back(sn+" 249 "+user->nick+" :Total allocation: "+ConvToStr(R.ru_maxrss)+"K"); results.push_back(sn+" 249 "+user->nick+" :Signals: "+ConvToStr(R.ru_nsignals)); diff --git a/src/cmd_whowas.cpp b/src/cmd_whowas.cpp index 4bf6df8ca..2030667a9 100644 --- a/src/cmd_whowas.cpp +++ b/src/cmd_whowas.cpp @@ -38,7 +38,7 @@ CmdResult cmd_whowas::Handle (const char** parameters, int pcnt, userrec* user) user->WriteServ("421 %s %s :This command has been disabled.",user->nick,command.c_str()); return CMD_FAILURE; } - + whowas_users::iterator i = whowas.find(parameters[0]); if (i == whowas.end()) diff --git a/src/dns.cpp b/src/dns.cpp index df79eba24..49cfa3f1f 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -1161,12 +1161,12 @@ unsigned long DNS::PRNG() val += (s->statsConnects ^ (unsigned long)s->statsSent ^ (unsigned long)s->statsRecv) - ServerInstance->Config->ports.size(); return val; #else - unsigned long val = 0; - serverstats* s = ServerInstance->stats; - val = (time(NULL) ^ GetCurrentProcessId() ^ GetCurrentThreadId() ^ (this->currid++)) ^ s->statsAccept + time(NULL); - val = val + s->statsCollisions ^ s->statsDnsGood - s->statsDnsBad; - val += (s->statsConnects ^ (unsigned long)s->statsSent ^ (unsigned long)s->statsRecv); - return val; + unsigned long val = 0; + serverstats* s = ServerInstance->stats; + val = (time(NULL) ^ GetCurrentProcessId() ^ GetCurrentThreadId() ^ (this->currid++)) ^ s->statsAccept + time(NULL); + val = val + s->statsCollisions ^ s->statsDnsGood - s->statsDnsBad; + val += (s->statsConnects ^ (unsigned long)s->statsSent ^ (unsigned long)s->statsRecv); + return val; #endif } diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index a0394b0f9..3ab91531f 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -138,15 +138,15 @@ int irc::irc_char_traits::compare(const char* str1, const char* str2, size_t n) for(unsigned int i = 0; i < n; i++) { if(lowermap[(unsigned char)*str1] > lowermap[(unsigned char)*str2]) - return 1; + return 1; if(lowermap[(unsigned char)*str1] < lowermap[(unsigned char)*str2]) - return -1; + return -1; if(*str1 == 0 || *str2 == 0) - return 0; + return 0; - str1++; + str1++; str2++; } return 0; @@ -484,7 +484,7 @@ irc::dynamicbitmask::~dynamicbitmask() /* Tidy up the entire used memory on delete */ delete[] bits; } - + irc::bitfield irc::dynamicbitmask::Allocate() { /* Yeah, this isnt too efficient, however a module or the core diff --git a/src/inspircd.cpp b/src/inspircd.cpp index ade05f3ef..d09092e69 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -93,7 +93,7 @@ bool InspIRCd::FindServerName(const std::string &servername) for(; itr != servernames.end(); ++itr) if(**itr == servername) return true; - return false; + return false; } void InspIRCd::Exit(int status) @@ -403,8 +403,8 @@ InspIRCd::InspIRCd(int argc, char** argv) { "debug", no_argument, &do_debug, 1 }, { "nolog", no_argument, &do_nolog, 1 }, { "runasroot", no_argument, &do_root, 1 }, - { "version", no_argument, &do_version, 1 }, - { "service", no_argument, &is_service, 1 }, + { "version", no_argument, &do_version, 1 }, + { "service", no_argument, &is_service, 1 }, { 0, 0, 0, 0 } }; @@ -497,7 +497,7 @@ InspIRCd::InspIRCd(int argc, char** argv) } - /* Because of limitations in kqueue on freebsd, we must fork BEFORE we + /* Because of limitations in kqueue on freebsd, we must fork BEFORE we * initialize the socket engine. */ SocketEngineFactory* SEF = new SocketEngineFactory(); @@ -634,8 +634,8 @@ void InspIRCd::EraseModule(int j) { if (v2 == j) { - Config->module_names.erase(v); - break; + Config->module_names.erase(v); + break; } v2++; } @@ -810,8 +810,8 @@ bool InspIRCd::LoadModule(const char* filename) { int n_match = 0; DIR* library = opendir(Config->ModPath); - if (library) - { + if (library) + { /* Try and locate and load all modules matching the pattern */ dirent* entry = NULL; while ((entry = readdir(library))) @@ -898,7 +898,7 @@ bool InspIRCd::LoadModule(const char* filename) } else { - this->Log(DEFAULT,"Unable to load %s",modfile); + this->Log(DEFAULT,"Unable to load %s",modfile); snprintf(MODERR,MAXBUF,"Factory function failed: Probably missing init_module() entrypoint."); return false; } @@ -950,7 +950,7 @@ bool InspIRCd::LoadModule(const char* filename) void InspIRCd::DoOneIteration(bool process_module_sockets) { #ifndef WIN32 - static rusage ru; + static rusage ru; #endif /* time() seems to be a pretty expensive syscall, so avoid calling it too much. @@ -1154,9 +1154,9 @@ void FileLogger::Close() if (log) { /* Burlex: Windows assumes nonblocking on FILE* pointers anyway, and also "file" fd's aren't the same - as socket fd's. */ + * as socket fd's. */ #ifndef WIN32 - int flags = fcntl(fileno(log), F_GETFL, 0); + int flags = fcntl(fileno(log), F_GETFL, 0); fcntl(fileno(log), F_SETFL, flags ^ O_NONBLOCK); #endif if (buffer.size()) diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index 43eaec04a..be2d99a62 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -339,8 +339,8 @@ bool InspSocket::DoConnect() int flags = fcntl(this->fd, F_GETFL, 0); fcntl(this->fd, F_SETFL, flags | O_NONBLOCK); #else - unsigned long flags = 0; - ioctlsocket(this->fd, FIONBIO, &flags); + unsigned long flags = 0; + ioctlsocket(this->fd, FIONBIO, &flags); #endif if (connect(this->fd, (sockaddr*)addr, size) == -1) { @@ -525,7 +525,7 @@ bool InspSocket::FlushWriteBuffer() #ifndef WIN32 int result = write(this->fd,outbuffer[0].c_str(),outbuffer[0].length()); #else - int result = send(this->fd,outbuffer[0].c_str(),outbuffer[0].length(), 0); + int result = send(this->fd,outbuffer[0].c_str(),outbuffer[0].length(), 0); #endif if (result > 0) { diff --git a/src/inspstring.cpp b/src/inspstring.cpp index f5f607609..98e7228d5 100644 --- a/src/inspstring.cpp +++ b/src/inspstring.cpp @@ -43,60 +43,59 @@ #ifndef HAS_STRLCPY CoreExport size_t strlcat(char *dst, const char *src, size_t siz) { - char *d = dst; - const char *s = src; - size_t n = siz, dlen; + char *d = dst; + const char *s = src; + size_t n = siz, dlen; - while (n-- != 0 && *d != '\0') - d++; + while (n-- != 0 && *d != '\0') + d++; - dlen = d - dst; - n = siz - dlen; + dlen = d - dst; + n = siz - dlen; - if (n == 0) - return(dlen + strlen(s)); + if (n == 0) + return(dlen + strlen(s)); - while (*s != '\0') - { - if (n != 1) - { - *d++ = *s; - n--; - } + while (*s != '\0') + { + if (n != 1) + { + *d++ = *s; + n--; + } - s++; - } + s++; + } - *d = '\0'; - return(dlen + (s - src)); /* count does not include NUL */ + *d = '\0'; + return(dlen + (s - src)); /* count does not include NUL */ } CoreExport size_t strlcpy(char *dst, const char *src, size_t siz) { - char *d = dst; - const char *s = src; - size_t n = siz; - - /* Copy as many bytes as will fit */ - if (n != 0 && --n != 0) - { - do - { - if ((*d++ = *s++) == 0) - break; - } while (--n != 0); - } - - /* Not enough room in dst, add NUL and traverse rest of src */ - if (n == 0) - { - if (siz != 0) - *d = '\0'; /* NUL-terminate dst */ - while (*s++) - ; - } - - return(s - src - 1); /* count does not include NUL */ + char *d = dst; + const char *s = src; + size_t n = siz; + + /* Copy as many bytes as will fit */ + if (n != 0 && --n != 0) + { + do + { + if ((*d++ = *s++) == 0) + break; + } while (--n != 0); + } + + /* Not enough room in dst, add NUL and traverse rest of src */ + if (n == 0) + { + if (siz != 0) + *d = '\0'; /* NUL-terminate dst */ + while (*s++); + } + + return(s - src - 1); /* count does not include NUL */ } #endif diff --git a/src/snomasks.cpp b/src/snomasks.cpp index 5ddfb3e1e..200acb236 100644 --- a/src/snomasks.cpp +++ b/src/snomasks.cpp @@ -68,7 +68,7 @@ void SnomaskManager::WriteToSnoMask(char letter, const std::string &text) void SnomaskManager::WriteToSnoMask(char letter, const char* text, ...) { - char textbuffer[MAXBUF]; + char textbuffer[MAXBUF]; va_list argsPtr; va_start(argsPtr, text); diff --git a/src/socket.cpp b/src/socket.cpp index 5882a1c0f..399b71cfa 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -304,22 +304,22 @@ bool irc::sockets::MatchCIDR(const char* address, const char* cidr_mask, bool ma void irc::sockets::Blocking(int s) { #ifndef WIN32 - int flags = fcntl(s, F_GETFL, 0); + int flags = fcntl(s, F_GETFL, 0); fcntl(s, F_SETFL, flags ^ O_NONBLOCK); #else - unsigned long opt = 0; - ioctlsocket(s, FIONBIO, &opt); + unsigned long opt = 0; + ioctlsocket(s, FIONBIO, &opt); #endif } void irc::sockets::NonBlocking(int s) { #ifndef WIN32 - int flags = fcntl(s, F_GETFL, 0); + int flags = fcntl(s, F_GETFL, 0); fcntl(s, F_SETFL, flags | O_NONBLOCK); #else - unsigned long opt = 1; - ioctlsocket(s, FIONBIO, &opt); + unsigned long opt = 1; + ioctlsocket(s, FIONBIO, &opt); #endif } diff --git a/src/users.cpp b/src/users.cpp index e79d27c8b..2cec79a95 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -476,7 +476,7 @@ int userrec::ReadData(void* buffer, size_t size) #ifndef WIN32 return read(this->fd, buffer, size); #else - return recv(this->fd, (char*)buffer, size, 0); + return recv(this->fd, (char*)buffer, size, 0); #endif } else @@ -719,9 +719,9 @@ void userrec::FlushWriteBuf() { int old_sendq_length = sendq.length(); #ifndef WIN32 - int n_sent = write(this->fd, this->sendq.data(), this->sendq.length()); + int n_sent = write(this->fd, this->sendq.data(), this->sendq.length()); #else - int n_sent = send(this->fd, (const char*)this->sendq.data(), this->sendq.length(), 0); + int n_sent = send(this->fd, (const char*)this->sendq.data(), this->sendq.length(), 0); #endif if (n_sent == -1) { -- cgit v1.2.3