X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fhelperfuncs.cpp;h=3efa58bba44150c111d2e109ab5f14d6cb6f39e6;hb=3f4349f54ad8b7fee75fc1256e12d4eda9de5744;hp=4605092a1e6f01b777d24435adaefd4752d07d91;hpb=73977e660f8bcb53c3f7363835d94d3bb7ad021a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 4605092a1..3efa58bba 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -24,9 +24,15 @@ /* $Core */ +#ifdef _WIN32 +#define _CRT_RAND_S +#include +#endif + #include "inspircd.h" #include "xline.h" #include "exitcodes.h" +#include std::string InspIRCd::GetServerDescription(const std::string& servername) { @@ -190,6 +196,33 @@ bool InspIRCd::IsValidMask(const std::string &mask) return true; } +void InspIRCd::StripColor(std::string &sentence) +{ + /* refactor this completely due to SQUIT bug since the old code would strip last char and replace with \0 --peavey */ + int seq = 0; + + for (std::string::iterator i = sentence.begin(); i != sentence.end();) + { + if (*i == 3) + seq = 1; + else if (seq && (( ((*i >= '0') && (*i <= '9')) || (*i == ',') ) )) + { + seq++; + if ( (seq <= 4) && (*i == ',') ) + seq = 1; + else if (seq > 3) + seq = 0; + } + else + seq = 0; + + if (seq || ((*i == 2) || (*i == 15) || (*i == 22) || (*i == 21) || (*i == 31))) + i = sentence.erase(i); + else + ++i; + } +} + /* true for valid channel name, false else */ bool IsChannelHandler::Call(const char *chname, size_t max) { @@ -311,12 +344,14 @@ bool InspIRCd::OpenLog(char**, int) void InspIRCd::CheckRoot() { +#ifndef _WIN32 if (geteuid() == 0) { - printf("WARNING!!! You are running an irc server as ROOT!!! DO NOT DO THIS!!!\n\n"); - this->Logs->Log("STARTUP",DEFAULT,"Cant start as root"); + std::cout << "ERROR: You are running an irc server as root! DO NOT DO THIS!" << std::endl << std::endl; + this->Logs->Log("STARTUP",DEFAULT,"Can't start as root"); Exit(EXIT_STATUS_ROOT); } +#endif } void InspIRCd::SendWhoisLine(User* user, User* dest, int numeric, const std::string &text) @@ -451,7 +486,17 @@ unsigned long InspIRCd::GenRandomInt(unsigned long max) void GenRandomHandler::Call(char *output, size_t max) { for(unsigned int i=0; i < max; i++) +#ifdef _WIN32 + { + unsigned int uTemp; + if(rand_s(&uTemp) != 0) + output[i] = rand(); + else + output[i] = uTemp; + } +#else output[i] = random(); +#endif } ModResult OnCheckExemptionHandler::Call(User* user, Channel* chan, const std::string& restriction)