diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-02-13 18:22:19 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-02-13 18:22:19 +0000 |
commit | bfaf7e3b27981a5144faba6d17c6e29fac735dbb (patch) | |
tree | bdec845abe8e5fcf617657f1e2473aed1a8fdec6 /src | |
parent | 0ec05c9bb346c1e20f9ab42d56eb17f03991b106 (diff) |
Commit patch from danieldg that makes a ton of stuff const-safe for latest warn-happy trigger-happy gcc4 (thanks)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8922 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
30 files changed, 49 insertions, 54 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index bb388e21e..2140a37ae 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -624,7 +624,7 @@ long Channel::KickUser(User *src, User *user, const char* reason) return this->GetUserCounter(); } -void Channel::WriteChannel(User* user, char* text, ...) +void Channel::WriteChannel(User* user, const char* text, ...) { char textbuffer[MAXBUF]; va_list argsPtr; @@ -689,7 +689,7 @@ void Channel::WriteChannelWithServ(const char* ServName, const std::string &text /* write formatted text from a source user to all users on a channel except * for the sender (for privmsg etc) */ -void Channel::WriteAllExceptSender(User* user, bool serversource, char status, char* text, ...) +void Channel::WriteAllExceptSender(User* user, bool serversource, char status, const char* text, ...) { char textbuffer[MAXBUF]; va_list argsPtr; @@ -704,7 +704,7 @@ void Channel::WriteAllExceptSender(User* user, bool serversource, char status, c this->WriteAllExceptSender(user, serversource, status, std::string(textbuffer)); } -void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList &except_list, char* text, ...) +void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const char* text, ...) { char textbuffer[MAXBUF]; va_list argsPtr; diff --git a/src/commands/cmd_modules.cpp b/src/commands/cmd_modules.cpp index 2ba91b867..7649dbc91 100644 --- a/src/commands/cmd_modules.cpp +++ b/src/commands/cmd_modules.cpp @@ -15,7 +15,7 @@ #include "wildcard.h" #include "commands/cmd_modules.h" -char* itab[] = { +const char* itab[] = { "OnUserConnect", "OnUserQuit", "OnUserDisconnect", "OnUserJoin", "OnUserPart", "OnRehash", "OnServerRaw", "OnUserPreJoin", "OnUserPreKick", "OnUserKick", "OnOper", "OnInfo", "OnWhois", "OnUserPreInvite", "OnUserInvite", "OnUserPreMessage", "OnUserPreNotice", "OnUserPreNick", "OnUserMessage", "OnUserNotice", "OnMode", diff --git a/src/commands/cmd_who.cpp b/src/commands/cmd_who.cpp index c31a3cea2..a54623672 100644 --- a/src/commands/cmd_who.cpp +++ b/src/commands/cmd_who.cpp @@ -15,7 +15,7 @@ #include "wildcard.h" #include "commands/cmd_who.h" -static char *get_first_visible_channel(User *u) +static const char *get_first_visible_channel(User *u) { UCListIter i = u->chans.begin(); if (i != u->chans.end()) diff --git a/src/configreader.cpp b/src/configreader.cpp index 9f7a59885..fe02bc2bd 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -160,7 +160,7 @@ void ServerConfig::Send005(User* user) user->WriteServ("005 %s %s", user->nick, line->c_str()); } -bool ServerConfig::CheckOnce(char* tag) +bool ServerConfig::CheckOnce(const char* tag) { int count = ConfValueEnum(this->config_data, tag); @@ -800,7 +800,7 @@ void ServerConfig::Read(bool bail, User* user, int pass) errstr.clear(); /* These tags MUST occur and must ONLY occur once in the config file */ - static char* Once[] = { "server", "admin", "files", "power", "options", NULL }; + static const char* Once[] = { "server", "admin", "files", "power", "options", NULL }; /* These tags can occur ONCE or not at all */ InitialConfig Values[] = { @@ -2124,12 +2124,7 @@ ValueItem::ValueItem(bool value) v = n.str(); } -ValueItem::ValueItem(char* value) -{ - v = value; -} - -void ValueItem::Set(char* value) +ValueItem::ValueItem(const char* value) { v = value; } diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index d412b961c..17aaa220d 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -385,7 +385,7 @@ std::string BufferedSocket::GetIP() return this->IP; } -char* BufferedSocket::Read() +const char* BufferedSocket::Read() { if (!Instance->SE->BoundsCheckFd(this)) return NULL; diff --git a/src/modules.cpp b/src/modules.cpp index 64b560d89..6b5ecb0cc 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -66,7 +66,7 @@ Module* Request::GetDest() return this->dest; } -char* Request::Send() +const char* Request::Send() { if (this->dest) { @@ -150,7 +150,7 @@ int Module::OnChangeLocalUserHost(User*, const std::string&) { return 0; } int Module::OnChangeLocalUserGECOS(User*, const std::string&) { return 0; } int Module::OnLocalTopicChange(User*, Channel*, const std::string&) { return 0; } void Module::OnEvent(Event*) { return; } -char* Module::OnRequest(Request*) { return NULL; } +const char* Module::OnRequest(Request*) { return NULL; } int Module::OnPassCompare(Extensible* ex, const std::string &password, const std::string &input, const std::string& hashtype) { return 0; } void Module::OnGlobalOper(User*) { } void Module::OnPostConnect(User*) { } diff --git a/src/modules/extra/m_httpclienttest.cpp b/src/modules/extra/m_httpclienttest.cpp index d76fcb970..382546196 100644 --- a/src/modules/extra/m_httpclienttest.cpp +++ b/src/modules/extra/m_httpclienttest.cpp @@ -59,7 +59,7 @@ public: ServerInstance->Log(DEBUG,"module not found, load it!!"); } - char* OnRequest(Request* req) + virtual const char* OnRequest(Request* req) { HTTPClientResponse* resp = (HTTPClientResponse*)req; if(!strcmp(resp->GetId(), HTTP_CLIENT_RESPONSE)) diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index 3a6f2afee..8fa717f78 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -762,7 +762,7 @@ class ModuleSQL : public Module return ++currid; } - char* OnRequest(Request* request) + virtual const char* OnRequest(Request* request) { if(strcmp(SQLREQID, request->GetId()) == 0) { diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp index 8320c9408..a77e1ac90 100644 --- a/src/modules/extra/m_pgsql.cpp +++ b/src/modules/extra/m_pgsql.cpp @@ -907,7 +907,7 @@ class ModulePgSQL : public Module ServerInstance->Timers->AddTimer(retimer); } - virtual char* OnRequest(Request* request) + virtual const char* OnRequest(Request* request) { if(strcmp(SQLREQID, request->GetId()) == 0) { diff --git a/src/modules/extra/m_sqlauth.cpp b/src/modules/extra/m_sqlauth.cpp index 2fd83c3d1..e73abe0cc 100644 --- a/src/modules/extra/m_sqlauth.cpp +++ b/src/modules/extra/m_sqlauth.cpp @@ -126,7 +126,7 @@ public: } } - virtual char* OnRequest(Request* request) + virtual const char* OnRequest(Request* request) { if(strcmp(SQLRESID, request->GetId()) == 0) { diff --git a/src/modules/extra/m_sqlite3.cpp b/src/modules/extra/m_sqlite3.cpp index 2c2d6ecf5..1e62eb971 100644 --- a/src/modules/extra/m_sqlite3.cpp +++ b/src/modules/extra/m_sqlite3.cpp @@ -613,7 +613,7 @@ class ModuleSQLite3 : public Module ReadConf(); } - virtual char* OnRequest(Request* request) + virtual const char* OnRequest(Request* request) { if(strcmp(SQLREQID, request->GetId()) == 0) { diff --git a/src/modules/extra/m_sqllog.cpp b/src/modules/extra/m_sqllog.cpp index 799744c26..7bb5ea1f1 100644 --- a/src/modules/extra/m_sqllog.cpp +++ b/src/modules/extra/m_sqllog.cpp @@ -223,7 +223,7 @@ class ModuleSQLLog : public Module ReadConfig(); } - virtual char* OnRequest(Request* request) + virtual const char* OnRequest(Request* request) { if(strcmp(SQLRESID, request->GetId()) == 0) { diff --git a/src/modules/extra/m_sqloper.cpp b/src/modules/extra/m_sqloper.cpp index 02ce959f6..22034303d 100644 --- a/src/modules/extra/m_sqloper.cpp +++ b/src/modules/extra/m_sqloper.cpp @@ -133,7 +133,7 @@ public: } } - virtual char* OnRequest(Request* request) + virtual const char* OnRequest(Request* request) { if (strcmp(SQLRESID, request->GetId()) == 0) { diff --git a/src/modules/extra/m_sqlutils.cpp b/src/modules/extra/m_sqlutils.cpp index 872b3af8e..30fcf968e 100644 --- a/src/modules/extra/m_sqlutils.cpp +++ b/src/modules/extra/m_sqlutils.cpp @@ -48,7 +48,7 @@ public: } - virtual char* OnRequest(Request* request) + virtual const char* OnRequest(Request* request) { if(strcmp(SQLUTILAU, request->GetId()) == 0) { diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index e2bf9cfac..e1f4b8451 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -297,7 +297,7 @@ class ModuleSSLGnuTLS : public Module output.append(" SSL=" + sslports); } - virtual char* OnRequest(Request* request) + virtual const char* OnRequest(Request* request) { ISHRequest* ISR = (ISHRequest*)request; if (strcmp("IS_NAME", request->GetId()) == 0) @@ -306,10 +306,10 @@ class ModuleSSLGnuTLS : public Module } else if (strcmp("IS_HOOK", request->GetId()) == 0) { - char* ret = "OK"; + const char* ret = "OK"; try { - ret = ServerInstance->Config->AddIOHook((Module*)this, (BufferedSocket*)ISR->Sock) ? (char*)"OK" : NULL; + ret = ServerInstance->Config->AddIOHook((Module*)this, (BufferedSocket*)ISR->Sock) ? "OK" : NULL; } catch (ModuleException &e) { @@ -319,15 +319,15 @@ class ModuleSSLGnuTLS : public Module } else if (strcmp("IS_UNHOOK", request->GetId()) == 0) { - return ServerInstance->Config->DelIOHook((BufferedSocket*)ISR->Sock) ? (char*)"OK" : NULL; + return ServerInstance->Config->DelIOHook((BufferedSocket*)ISR->Sock) ? "OK" : NULL; } else if (strcmp("IS_HSDONE", request->GetId()) == 0) { if (ISR->Sock->GetFd() < 0) - return (char*)"OK"; + return "OK"; issl_session* session = &sessions[ISR->Sock->GetFd()]; - return (session->status == ISSL_HANDSHAKING_READ || session->status == ISSL_HANDSHAKING_WRITE) ? NULL : (char*)"OK"; + return (session->status == ISSL_HANDSHAKING_READ || session->status == ISSL_HANDSHAKING_WRITE) ? NULL : "OK"; } else if (strcmp("IS_ATTACH", request->GetId()) == 0) { diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index faeb24410..667b2a5cd 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -343,7 +343,7 @@ class ModuleSSLOpenSSL : public Module } - virtual char* OnRequest(Request* request) + virtual const char* OnRequest(Request* request) { ISHRequest* ISR = (ISHRequest*)request; if (strcmp("IS_NAME", request->GetId()) == 0) @@ -352,10 +352,10 @@ class ModuleSSLOpenSSL : public Module } else if (strcmp("IS_HOOK", request->GetId()) == 0) { - char* ret = "OK"; + const char* ret = "OK"; try { - ret = ServerInstance->Config->AddIOHook((Module*)this, (BufferedSocket*)ISR->Sock) ? (char*)"OK" : NULL; + ret = ServerInstance->Config->AddIOHook((Module*)this, (BufferedSocket*)ISR->Sock) ? "OK" : NULL; } catch (ModuleException &e) { @@ -366,15 +366,15 @@ class ModuleSSLOpenSSL : public Module } else if (strcmp("IS_UNHOOK", request->GetId()) == 0) { - return ServerInstance->Config->DelIOHook((BufferedSocket*)ISR->Sock) ? (char*)"OK" : NULL; + return ServerInstance->Config->DelIOHook((BufferedSocket*)ISR->Sock) ? "OK" : NULL; } else if (strcmp("IS_HSDONE", request->GetId()) == 0) { if (ISR->Sock->GetFd() < 0) - return (char*)"OK"; + return "OK"; issl_session* session = &sessions[ISR->Sock->GetFd()]; - return (session->status == ISSL_HANDSHAKING) ? NULL : (char*)"OK"; + return (session->status == ISSL_HANDSHAKING) ? NULL : "OK"; } else if (strcmp("IS_ATTACH", request->GetId()) == 0) { diff --git a/src/modules/extra/m_testclient.cpp b/src/modules/extra/m_testclient.cpp index 2a110380c..fb0a093ee 100644 --- a/src/modules/extra/m_testclient.cpp +++ b/src/modules/extra/m_testclient.cpp @@ -57,7 +57,7 @@ public: } } - virtual char* OnRequest(Request* request) + virtual const char* OnRequest(Request* request) { if(strcmp(SQLRESID, request->GetId()) == 0) { diff --git a/src/modules/extra/m_ziplink.cpp b/src/modules/extra/m_ziplink.cpp index 79a4e5b08..83131fcb3 100644 --- a/src/modules/extra/m_ziplink.cpp +++ b/src/modules/extra/m_ziplink.cpp @@ -170,7 +170,7 @@ class ModuleZLib : public Module /* Handle BufferedSocketHook API requests */ - virtual char* OnRequest(Request* request) + virtual const char* OnRequest(Request* request) { ISHRequest* ISR = (ISHRequest*)request; if (strcmp("IS_NAME", request->GetId()) == 0) diff --git a/src/modules/m_banexception.cpp b/src/modules/m_banexception.cpp index 36cb4a711..6d30d6175 100644 --- a/src/modules/m_banexception.cpp +++ b/src/modules/m_banexception.cpp @@ -106,7 +106,7 @@ public: be->DoRehash(); } - virtual char* OnRequest(Request* request) + virtual const char* OnRequest(Request* request) { ListModeRequest* LM = (ListModeRequest*)request; if (strcmp("LM_CHECKLIST", request->GetId()) == 0) diff --git a/src/modules/m_http_client.cpp b/src/modules/m_http_client.cpp index 065cf4055..4cb7b2848 100644 --- a/src/modules/m_http_client.cpp +++ b/src/modules/m_http_client.cpp @@ -103,7 +103,7 @@ class ModuleHTTPClient : public Module } - char* OnRequest(Request *req) + virtual const char* OnRequest(Request *req) { HTTPClientRequest *httpreq = (HTTPClientRequest *)req; if (!strcmp(httpreq->GetId(), HTTP_CLIENT_REQUEST)) @@ -298,7 +298,7 @@ bool HTTPSocket::OnConnected() bool HTTPSocket::OnDataReady() { Instance->Log(DEBUG,"HTTPSocket::OnDataReady() for %s", url.url.c_str()); - char *sdata = this->Read(); + const char *sdata = this->Read(); if (!sdata) return false; diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp index efae473d9..56a24119f 100644 --- a/src/modules/m_httpd.cpp +++ b/src/modules/m_httpd.cpp @@ -270,7 +270,7 @@ class HttpServerSocket : public BufferedSocket virtual bool OnDataReady() { - char* data = this->Read(); + const char* data = this->Read(); /* Check that the data read is a valid pointer and it has some content */ if (!data || !*data) @@ -478,7 +478,7 @@ class ModuleHttpServer : public Module ServerInstance->Modules->Attach(eventlist, this, 1); } - char* OnRequest(Request* request) + virtual const char* OnRequest(Request* request) { claimed = true; HTTPDocument* doc = (HTTPDocument*)request->GetData(); diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp index 63ddedcb8..50d13398b 100644 --- a/src/modules/m_httpd_stats.cpp +++ b/src/modules/m_httpd_stats.cpp @@ -225,7 +225,7 @@ class ModuleHttpStats : public Module this->changed = true; } - char* OnRequest(Request* request) + const char* OnRequest(Request* request) { return NULL; } diff --git a/src/modules/m_inviteexception.cpp b/src/modules/m_inviteexception.cpp index a592f6cdd..503ceedd4 100644 --- a/src/modules/m_inviteexception.cpp +++ b/src/modules/m_inviteexception.cpp @@ -83,7 +83,7 @@ public: return 0; } - virtual char* OnRequest(Request* request) + virtual const char* OnRequest(Request* request) { ListModeRequest* LM = (ListModeRequest*)request; if (strcmp("LM_CHECKLIST", request->GetId()) == 0) diff --git a/src/modules/m_md5.cpp b/src/modules/m_md5.cpp index b88258368..8774b43f9 100644 --- a/src/modules/m_md5.cpp +++ b/src/modules/m_md5.cpp @@ -278,7 +278,7 @@ class ModuleMD5 : public Module } - virtual char* OnRequest(Request* request) + virtual const char* OnRequest(Request* request) { HashRequest* MD5 = (HashRequest*)request; diff --git a/src/modules/m_proxyscan.cpp b/src/modules/m_proxyscan.cpp index 328b92612..f65382ac1 100644 --- a/src/modules/m_proxyscan.cpp +++ b/src/modules/m_proxyscan.cpp @@ -76,7 +76,7 @@ class ProxySocket : public EventHandler int rlen; bool done; public: - ProxySocket(InspIRCd *Server, User* u, const std::string &bindip, int port, char *cstr, int mclen, char *rstr, int mrlen) + ProxySocket(InspIRCd *Server, User* u, const std::string &bindip, int port, const char *cstr, int mclen, const char *rstr, int mrlen) { user = u; ServerInstance = Server; diff --git a/src/modules/m_sha256.cpp b/src/modules/m_sha256.cpp index febfd8820..b80e3d5bb 100644 --- a/src/modules/m_sha256.cpp +++ b/src/modules/m_sha256.cpp @@ -271,7 +271,7 @@ class ModuleSHA256 : public Module } - virtual char* OnRequest(Request* request) + virtual const char* OnRequest(Request* request) { HashRequest* SHA = (HashRequest*)request; if (strcmp("KEY", request->GetId()) == 0) diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp index ddb781276..34b8e112d 100644 --- a/src/modules/m_spanningtree/treesocket1.cpp +++ b/src/modules/m_spanningtree/treesocket1.cpp @@ -258,7 +258,7 @@ void TreeSocket::Squit(TreeServer* Current, const std::string &reason) */ bool TreeSocket::OnDataReady() { - char* data = this->Read(); + const char* data = this->Read(); /* Check that the data read is a valid pointer and it has some content */ if (data && *data) { diff --git a/src/socket.cpp b/src/socket.cpp index b9e22c949..81f2a6f27 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -309,7 +309,7 @@ bool irc::sockets::MatchCIDR(const char* address, const char* cidr_mask, bool ma * It can only bind to IP addresses, if you wish to bind to hostnames * you should first resolve them using class 'Resolver'. */ -bool InspIRCd::BindSocket(int sockfd, int port, char* addr, bool dolisten) +bool InspIRCd::BindSocket(int sockfd, int port, const char* addr, bool dolisten) { /* We allocate 2 of these, because sockaddr_in6 is larger than sockaddr (ugh, hax) */ sockaddr* servaddr = new sockaddr[2]; @@ -318,7 +318,7 @@ bool InspIRCd::BindSocket(int sockfd, int port, char* addr, bool dolisten) int ret, size; if (*addr == '*') - *addr = 0; + addr = ""; #ifdef IPV6 if (*addr) diff --git a/src/usermanager.cpp b/src/usermanager.cpp index 5ee84590b..ca9736f1e 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -271,7 +271,7 @@ unsigned int UserManager::LocalUserCount() return (this->local_users.size() - this->UnregisteredUserCount()); } -void UserManager::ServerNoticeAll(char* text, ...) +void UserManager::ServerNoticeAll(const char* text, ...) { if (!text) return; @@ -292,7 +292,7 @@ void UserManager::ServerNoticeAll(char* text, ...) } } -void UserManager::ServerPrivmsgAll(char* text, ...) +void UserManager::ServerPrivmsgAll(const char* text, ...) { if (!text) return; diff --git a/src/users.cpp b/src/users.cpp index e81a3e253..404e1f5a9 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -1450,7 +1450,7 @@ bool User::ChangeIdent(const char* newident) return true; } -void User::SendAll(const char* command, char* text, ...) +void User::SendAll(const char* command, const char* text, ...) { char textbuffer[MAXBUF]; char formatbuffer[MAXBUF]; |