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
This commit is contained in:
brain 2008-02-13 18:22:19 +00:00
parent 0ec05c9bb3
commit bfaf7e3b27
38 changed files with 68 additions and 75 deletions

View File

@ -371,7 +371,7 @@ class CoreExport Channel : public Extensible
* @param text A printf-style format string which builds the output line without prefix
* @param ... Zero or more POD types
*/
void WriteChannel(User* user, char* text, ...);
void WriteChannel(User* user, const char* text, ...);
/** Write to a channel, from a user, using std::string for text
* @param user User whos details to prefix the line with
@ -401,7 +401,7 @@ class CoreExport Channel : public Extensible
* @param text A printf-style format string which builds the output line without prefix
* @param ... Zero or more POD type
*/
void WriteAllExceptSender(User* user, bool serversource, char status, char* text, ...);
void WriteAllExceptSender(User* user, bool serversource, char status, const char* text, ...);
/** Write to all users on a channel except a list of users, using va_args for text
* @param user User whos details to prefix the line with, and to omit from receipt of the message
@ -412,7 +412,7 @@ class CoreExport Channel : public Extensible
* @param text A printf-style format string which builds the output line without prefix
* @param ... Zero or more POD type
*/
void WriteAllExcept(User* user, bool serversource, char status, CUList &except_list, char* text, ...);
void WriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const char* text, ...);
/** Write to all users on a channel except a specific user, using std::string for text.
* Internally, this calls WriteAllExcept().

View File

@ -68,10 +68,8 @@ class ValueItem
/** Initialize with a bool */
ValueItem(bool value);
/** Initialize with a char pointer */
ValueItem(char* value);
ValueItem(const char* value);
/** Change value to a char pointer */
void Set(char* value);
/** Change value to a const char pointer */
void Set(const char* val);
/** Change value to an int */
void Set(int value);
@ -166,11 +164,11 @@ typedef bool (*MultiNotify)(ServerConfig* conf, const char*);
struct InitialConfig
{
/** Tag name */
char* tag;
const char* tag;
/** Value name */
char* value;
const char* value;
/** Default, if not defined */
char* default_value;
const char* default_value;
/** Value containers */
ValueContainerBase* val;
/** Data types */
@ -187,9 +185,9 @@ struct MultiConfig
/** Tag name */
const char* tag;
/** One or more items within tag */
char* items[18];
const char* items[18];
/** One or more defaults for items within tags */
char* items_default[18];
const char* items_default[18];
/** One or more data types */
int datatype[18];
/** Initialization function */
@ -240,7 +238,7 @@ class CoreExport ServerConfig : public Extensible
/** Check that there is only one of each configuration item
*/
bool CheckOnce(char* tag);
bool CheckOnce(const char* tag);
public:

View File

@ -23,7 +23,7 @@ class CoreExport DLLManager
/** The last error string, or NULL
*/
char *err;
const char *err;
public:
/** This constructor loads the module using dlopen()
@ -44,7 +44,7 @@ class CoreExport DLLManager
/** Get the last error from dlopen() or dlsym().
* @return The last error string, or NULL if no error has occured.
*/
char* LastError()
const char* LastError()
{
return err;
}

View File

@ -478,7 +478,7 @@ class CoreExport InspIRCd : public classbase
* @param addr The address to bind to (IP only)
* @return True if the port was bound successfully
*/
bool BindSocket(int sockfd, int port, char* addr, bool dolisten = true);
bool BindSocket(int sockfd, int port, const char* addr, bool dolisten = true);
/** Adds a server name to the list of servers we've seen
* @param The servername to add

View File

@ -318,7 +318,7 @@ class CoreExport BufferedSocket : public EventHandler
* into a char* array which can be up to
* 16 kilobytes in length.
*/
virtual char* Read();
virtual const char* Read();
/**
* Returns the IP address associated with

View File

@ -335,7 +335,7 @@ class CoreExport Request : public ModuleMessage
* sent the request to. It is up to your module to know what this data is and
* how to deal with it.
*/
char* Send();
const char* Send();
};
@ -1195,7 +1195,7 @@ class CoreExport Module : public Extensible
* may be able to use for pre-determined purposes (e.g. the results of an SQL query, etc).
* @param request The Request class being received
*/
virtual char* OnRequest(Request* request);
virtual const char* OnRequest(Request* request);
/** Called whenever a password check is to be made. Replaces the old OldOperCompare API.
* The password field (from the config file) is in 'password' and is to be compared against

View File

@ -138,13 +138,13 @@ class CoreExport UserManager : public classbase
* @param text The text format string to send
* @param ... The format arguments
*/
void ServerNoticeAll(char* text, ...);
void ServerNoticeAll(const char* text, ...);
/** Send a server message (PRIVMSG) to all local users
* @param text The text format string to send
* @param ... The format arguments
*/
void ServerPrivmsgAll(char* text, ...);
void ServerPrivmsgAll(const char* text, ...);
/** Send text to all users with a specific set of modes
* @param modes The modes to check against, without a +, e.g. 'og'

View File

@ -1033,7 +1033,7 @@ class CoreExport User : public connection
* @param text The text format string to send
* @param ... Format arguments
*/
void SendAll(const char* command, char* text, ...);
void SendAll(const char* command, const char* text, ...);
/** Compile a channel list for this user, and send it to the user 'source'
* Used internally by WHOIS

View File

@ -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;

View File

@ -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",

View File

@ -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())

View File

@ -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;
}

View File

@ -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;

View File

@ -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*) { }

View File

@ -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))

View File

@ -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)
{

View File

@ -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)
{

View File

@ -126,7 +126,7 @@ public:
}
}
virtual char* OnRequest(Request* request)
virtual const char* OnRequest(Request* request)
{
if(strcmp(SQLRESID, request->GetId()) == 0)
{

View File

@ -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)
{

View File

@ -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)
{

View File

@ -133,7 +133,7 @@ public:
}
}
virtual char* OnRequest(Request* request)
virtual const char* OnRequest(Request* request)
{
if (strcmp(SQLRESID, request->GetId()) == 0)
{

View File

@ -48,7 +48,7 @@ public:
}
virtual char* OnRequest(Request* request)
virtual const char* OnRequest(Request* request)
{
if(strcmp(SQLUTILAU, request->GetId()) == 0)
{

View File

@ -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)
{

View File

@ -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)
{

View File

@ -57,7 +57,7 @@ public:
}
}
virtual char* OnRequest(Request* request)
virtual const char* OnRequest(Request* request)
{
if(strcmp(SQLRESID, request->GetId()) == 0)
{

View File

@ -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)

View File

@ -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)

View File

@ -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;

View File

@ -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();

View File

@ -225,7 +225,7 @@ class ModuleHttpStats : public Module
this->changed = true;
}
char* OnRequest(Request* request)
const char* OnRequest(Request* request)
{
return NULL;
}

View File

@ -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)

View File

@ -278,7 +278,7 @@ class ModuleMD5 : public Module
}
virtual char* OnRequest(Request* request)
virtual const char* OnRequest(Request* request)
{
HashRequest* MD5 = (HashRequest*)request;

View File

@ -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;

View File

@ -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)

View File

@ -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)
{

View File

@ -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)

View File

@ -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;

View File

@ -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];