From: Florian Westphal Date: Sat, 11 Apr 2009 23:09:42 +0000 (+0200) Subject: add const qualifier to pointers where possible X-Git-Tag: rel-14-1~15 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git;a=commitdiff_plain;h=ea041b8838714707dca4500f63e2b40344b506c2 add const qualifier to pointers where possible --- diff --git a/src/ngircd/channel.c b/src/ngircd/channel.c index 0a1ba455..6f850724 100644 --- a/src/ngircd/channel.c +++ b/src/ngircd/channel.c @@ -198,7 +198,7 @@ Channel_Exit( void ) * Add_Client(). */ GLOBAL bool -Channel_Join( CLIENT *Client, char *Name ) +Channel_Join( CLIENT *Client, const char *Name ) { CHANNEL *chan; @@ -325,7 +325,7 @@ Channel_Kick(CLIENT *Peer, CLIENT *Target, CLIENT *Origin, const char *Name, GLOBAL void -Channel_Quit( CLIENT *Client, char *Reason ) +Channel_Quit( CLIENT *Client, const char *Reason ) { CHANNEL *c, *next_c; @@ -731,7 +731,7 @@ Channel_SetTopic(CHANNEL *Chan, CLIENT *Client, const char *Topic) GLOBAL void -Channel_SetModes( CHANNEL *Chan, char *Modes ) +Channel_SetModes( CHANNEL *Chan, const char *Modes ) { assert( Chan != NULL ); assert( Modes != NULL ); @@ -1042,7 +1042,7 @@ Channel_ShowInvites( CLIENT *Client, CHANNEL *Channel ) * Log a message to the local &SERVER channel, if it exists. */ GLOBAL void -Channel_LogServer(char *msg) +Channel_LogServer(const char *msg) { CHANNEL *sc; CLIENT *c; diff --git a/src/ngircd/channel.h b/src/ngircd/channel.h index b41cced2..46e7e13a 100644 --- a/src/ngircd/channel.h +++ b/src/ngircd/channel.h @@ -62,10 +62,10 @@ GLOBAL void Channel_Init PARAMS(( void )); GLOBAL void Channel_InitPredefined PARAMS(( void )); GLOBAL void Channel_Exit PARAMS(( void )); -GLOBAL bool Channel_Join PARAMS(( CLIENT *Client, char *Name )); +GLOBAL bool Channel_Join PARAMS(( CLIENT *Client, const char *Name )); GLOBAL bool Channel_Part PARAMS(( CLIENT *Client, CLIENT *Origin, const char *Name, const char *Reason )); -GLOBAL void Channel_Quit PARAMS(( CLIENT *Client, char *Reason )); +GLOBAL void Channel_Quit PARAMS(( CLIENT *Client, const char *Reason )); GLOBAL void Channel_Kick PARAMS((CLIENT *Peer, CLIENT *Target, CLIENT *Origin, const char *Name, const char *Reason)); @@ -81,7 +81,7 @@ GLOBAL char *Channel_Key PARAMS(( CHANNEL *Chan )); GLOBAL unsigned long Channel_MaxUsers PARAMS(( CHANNEL *Chan )); GLOBAL void Channel_SetTopic PARAMS(( CHANNEL *Chan, CLIENT *Client, const char *Topic )); -GLOBAL void Channel_SetModes PARAMS(( CHANNEL *Chan, char *Modes )); +GLOBAL void Channel_SetModes PARAMS(( CHANNEL *Chan, const char *Modes )); GLOBAL void Channel_SetKey PARAMS(( CHANNEL *Chan, const char *Key )); GLOBAL void Channel_SetMaxUsers PARAMS(( CHANNEL *Chan, unsigned long Count )); @@ -126,7 +126,7 @@ GLOBAL bool Channel_AddBan PARAMS((CHANNEL *c, const char *Mask )); GLOBAL bool Channel_ShowBans PARAMS((CLIENT *client, CHANNEL *c)); GLOBAL bool Channel_ShowInvites PARAMS((CLIENT *client, CHANNEL *c)); -GLOBAL void Channel_LogServer PARAMS((char *msg)); +GLOBAL void Channel_LogServer PARAMS((const char *msg)); GLOBAL bool Channel_CheckKey PARAMS((CHANNEL *Chan, CLIENT *Client, const char *Key)); diff --git a/src/ngircd/client.c b/src/ngircd/client.c index fbe130a1..076a0cb4 100644 --- a/src/ngircd/client.c +++ b/src/ngircd/client.c @@ -64,12 +64,12 @@ static void Generate_MyToken PARAMS(( CLIENT *Client )); static void Adjust_Counters PARAMS(( CLIENT *Client )); static CLIENT *Init_New_Client PARAMS((CONN_ID Idx, CLIENT *Introducer, - CLIENT *TopServer, int Type, char *ID, - char *User, char *Hostname, char *Info, - int Hops, int Token, char *Modes, + CLIENT *TopServer, int Type, const char *ID, + const char *User, const char *Hostname, const char *Info, + int Hops, int Token, const char *Modes, bool Idented)); -static void Destroy_UserOrService PARAMS((CLIENT *Client, char *Txt, char *FwdMsg, +static void Destroy_UserOrService PARAMS((CLIENT *Client,const char *Txt, const char *FwdMsg, bool SendQuit)); @@ -142,7 +142,7 @@ Client_ThisServer( void ) * @return New CLIENT structure. */ GLOBAL CLIENT * -Client_NewLocal(CONN_ID Idx, char *Hostname, int Type, bool Idented) +Client_NewLocal(CONN_ID Idx, const char *Hostname, int Type, bool Idented) { return Init_New_Client(Idx, This_Server, NULL, Type, NULL, NULL, Hostname, NULL, 0, 0, NULL, Idented); @@ -154,8 +154,8 @@ Client_NewLocal(CONN_ID Idx, char *Hostname, int Type, bool Idented) * @return New CLIENT structure. */ GLOBAL CLIENT * -Client_NewRemoteServer(CLIENT *Introducer, char *Hostname, CLIENT *TopServer, - int Hops, int Token, char *Info, bool Idented) +Client_NewRemoteServer(CLIENT *Introducer, const char *Hostname, CLIENT *TopServer, + int Hops, int Token, const char *Info, bool Idented) { return Init_New_Client(NONE, Introducer, TopServer, CLIENT_SERVER, Hostname, NULL, Hostname, Info, Hops, Token, NULL, Idented); @@ -167,8 +167,8 @@ Client_NewRemoteServer(CLIENT *Introducer, char *Hostname, CLIENT *TopServer, * @return New CLIENT structure. */ GLOBAL CLIENT * -Client_NewRemoteUser(CLIENT *Introducer, char *Nick, int Hops, char *User, - char *Hostname, int Token, char *Modes, char *Info, bool Idented) +Client_NewRemoteUser(CLIENT *Introducer, const char *Nick, int Hops, const char *User, + const char *Hostname, int Token, const char *Modes, const char *Info, bool Idented) { return Init_New_Client(NONE, Introducer, NULL, CLIENT_USER, Nick, User, Hostname, Info, Hops, Token, Modes, Idented); @@ -182,8 +182,8 @@ Client_NewRemoteUser(CLIENT *Introducer, char *Nick, int Hops, char *User, */ static CLIENT * Init_New_Client(CONN_ID Idx, CLIENT *Introducer, CLIENT *TopServer, - int Type, char *ID, char *User, char *Hostname, char *Info, int Hops, - int Token, char *Modes, bool Idented) + int Type, const char *ID, const char *User, const char *Hostname, const char *Info, int Hops, + int Token, const char *Modes, bool Idented) { CLIENT *client; @@ -224,12 +224,13 @@ Init_New_Client(CONN_ID Idx, CLIENT *Introducer, CLIENT *TopServer, GLOBAL void -Client_Destroy( CLIENT *Client, char *LogMsg, char *FwdMsg, bool SendQuit ) +Client_Destroy( CLIENT *Client, const char *LogMsg, const char *FwdMsg, bool SendQuit ) { /* Client entfernen. */ CLIENT *last, *c; - char msg[LINE_LEN], *txt; + char msg[LINE_LEN]; + const char *txt; assert( Client != NULL ); @@ -302,7 +303,7 @@ Client_Destroy( CLIENT *Client, char *LogMsg, char *FwdMsg, bool SendQuit ) GLOBAL void -Client_SetHostname( CLIENT *Client, char *Hostname ) +Client_SetHostname( CLIENT *Client, const char *Hostname ) { /* Hostname eines Clients setzen */ @@ -314,7 +315,7 @@ Client_SetHostname( CLIENT *Client, char *Hostname ) GLOBAL void -Client_SetID( CLIENT *Client, char *ID ) +Client_SetID( CLIENT *Client, const char *ID ) { /* Hostname eines Clients setzen, Hash-Wert berechnen */ @@ -329,7 +330,7 @@ Client_SetID( CLIENT *Client, char *ID ) GLOBAL void -Client_SetUser( CLIENT *Client, char *User, bool Idented ) +Client_SetUser( CLIENT *Client, const char *User, bool Idented ) { /* Username eines Clients setzen */ @@ -346,7 +347,7 @@ Client_SetUser( CLIENT *Client, char *User, bool Idented ) GLOBAL void -Client_SetInfo( CLIENT *Client, char *Info ) +Client_SetInfo( CLIENT *Client, const char *Info ) { /* Hostname eines Clients setzen */ @@ -358,7 +359,7 @@ Client_SetInfo( CLIENT *Client, char *Info ) GLOBAL void -Client_SetModes( CLIENT *Client, char *Modes ) +Client_SetModes( CLIENT *Client, const char *Modes ) { /* Modes eines Clients setzen */ @@ -370,7 +371,7 @@ Client_SetModes( CLIENT *Client, char *Modes ) GLOBAL void -Client_SetFlags( CLIENT *Client, char *Flags ) +Client_SetFlags( CLIENT *Client, const char *Flags ) { /* Flags eines Clients setzen */ @@ -382,7 +383,7 @@ Client_SetFlags( CLIENT *Client, char *Flags ) GLOBAL void -Client_SetPassword( CLIENT *Client, char *Pwd ) +Client_SetPassword( CLIENT *Client, const char *Pwd ) { /* Von einem Client geliefertes Passwort */ @@ -394,7 +395,7 @@ Client_SetPassword( CLIENT *Client, char *Pwd ) GLOBAL void -Client_SetAway( CLIENT *Client, char *Txt ) +Client_SetAway( CLIENT *Client, const char *Txt ) { /* Set AWAY reason of client */ @@ -1137,7 +1138,7 @@ Client_TypeText(CLIENT *Client) * Destroy user or service client. */ static void -Destroy_UserOrService(CLIENT *Client, char *Txt, char *FwdMsg, bool SendQuit) +Destroy_UserOrService(CLIENT *Client, const char *Txt, const char *FwdMsg, bool SendQuit) { if(Client->conn_id != NONE) { /* Local (directly connected) client */ diff --git a/src/ngircd/client.h b/src/ngircd/client.h index 6fcf7b64..10649174 100644 --- a/src/ngircd/client.h +++ b/src/ngircd/client.h @@ -72,11 +72,11 @@ typedef struct _WHOWAS GLOBAL void Client_Init PARAMS(( void )); GLOBAL void Client_Exit PARAMS(( void )); -GLOBAL CLIENT *Client_NewLocal PARAMS(( CONN_ID Idx, char *Hostname, int Type, bool Idented )); -GLOBAL CLIENT *Client_NewRemoteServer PARAMS(( CLIENT *Introducer, char *Hostname, CLIENT *TopServer, int Hops, int Token, char *Info, bool Idented )); -GLOBAL CLIENT *Client_NewRemoteUser PARAMS(( CLIENT *Introducer, char *Nick, int Hops, char *User, char *Hostname, int Token, char *Modes, char *Info, bool Idented )); +GLOBAL CLIENT *Client_NewLocal PARAMS(( CONN_ID Idx, const char *Hostname, int Type, bool Idented )); +GLOBAL CLIENT *Client_NewRemoteServer PARAMS(( CLIENT *Introducer, const char *Hostname, CLIENT *TopServer, int Hops, int Token, const char *Info, bool Idented )); +GLOBAL CLIENT *Client_NewRemoteUser PARAMS(( CLIENT *Introducer, const char *Nick, int Hops, const char *User, const char *Hostname, int Token, const char *Modes, const char *Info, bool Idented )); -GLOBAL void Client_Destroy PARAMS(( CLIENT *Client, char *LogMsg, char *FwdMsg, bool SendQuit )); +GLOBAL void Client_Destroy PARAMS(( CLIENT *Client, const char *LogMsg, const char *FwdMsg, bool SendQuit )); GLOBAL CLIENT *Client_ThisServer PARAMS(( void )); @@ -108,19 +108,19 @@ GLOBAL time_t Client_StartTime PARAMS(( CLIENT *Client )); GLOBAL bool Client_HasMode PARAMS(( CLIENT *Client, char Mode )); -GLOBAL void Client_SetHostname PARAMS(( CLIENT *Client, char *Hostname )); -GLOBAL void Client_SetID PARAMS(( CLIENT *Client, char *Nick )); -GLOBAL void Client_SetUser PARAMS(( CLIENT *Client, char *User, bool Idented )); -GLOBAL void Client_SetInfo PARAMS(( CLIENT *Client, char *Info )); -GLOBAL void Client_SetPassword PARAMS(( CLIENT *Client, char *Pwd )); +GLOBAL void Client_SetHostname PARAMS(( CLIENT *Client, const char *Hostname )); +GLOBAL void Client_SetID PARAMS(( CLIENT *Client, const char *Nick )); +GLOBAL void Client_SetUser PARAMS(( CLIENT *Client, const char *User, bool Idented )); +GLOBAL void Client_SetInfo PARAMS(( CLIENT *Client, const char *Info )); +GLOBAL void Client_SetPassword PARAMS(( CLIENT *Client, const char *Pwd )); GLOBAL void Client_SetType PARAMS(( CLIENT *Client, int Type )); GLOBAL void Client_SetHops PARAMS(( CLIENT *Client, int Hops )); GLOBAL void Client_SetToken PARAMS(( CLIENT *Client, int Token )); GLOBAL void Client_SetOperByMe PARAMS(( CLIENT *Client, bool OperByMe )); -GLOBAL void Client_SetModes PARAMS(( CLIENT *Client, char *Modes )); -GLOBAL void Client_SetFlags PARAMS(( CLIENT *Client, char *Flags )); +GLOBAL void Client_SetModes PARAMS(( CLIENT *Client, const char *Modes )); +GLOBAL void Client_SetFlags PARAMS(( CLIENT *Client, const char *Flags )); GLOBAL void Client_SetIntroducer PARAMS(( CLIENT *Client, CLIENT *Introducer )); -GLOBAL void Client_SetAway PARAMS(( CLIENT *Client, char *Txt )); +GLOBAL void Client_SetAway PARAMS(( CLIENT *Client, const char *Txt )); GLOBAL bool Client_ModeAdd PARAMS(( CLIENT *Client, char Mode )); GLOBAL bool Client_ModeDel PARAMS(( CLIENT *Client, char Mode )); diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c index 71f5760b..a3c9afec 100644 --- a/src/ngircd/conf.c +++ b/src/ngircd/conf.c @@ -387,7 +387,7 @@ Conf_GetServer( CONN_ID Idx ) GLOBAL bool -Conf_EnableServer( char *Name, UINT16 Port ) +Conf_EnableServer( const char *Name, UINT16 Port ) { /* Enable specified server and adjust port */ @@ -426,7 +426,7 @@ Conf_EnablePassiveServer(const char *Name) GLOBAL bool -Conf_DisableServer( char *Name ) +Conf_DisableServer( const char *Name ) { /* Enable specified server and adjust port */ @@ -447,7 +447,7 @@ Conf_DisableServer( char *Name ) GLOBAL bool -Conf_AddServer( char *Name, UINT16 Port, char *Host, char *MyPwd, char *PeerPwd ) +Conf_AddServer( const char *Name, UINT16 Port, const char *Host, const char *MyPwd, const char *PeerPwd ) { /* Add new server to configuration */ @@ -481,7 +481,7 @@ Conf_AddServer( char *Name, UINT16 Port, char *Host, char *MyPwd, char *PeerPwd * Check if the given nick name is an service */ GLOBAL bool -Conf_IsService(int ConfServer, char *Nick) +Conf_IsService(int ConfServer, const char *Nick) { return MatchCaseInsensitive(Conf_Server[ConfServer].svs_mask, Nick); } /* Conf_IsService */ diff --git a/src/ngircd/conf.h b/src/ngircd/conf.h index 4695b25a..9bdecdee 100644 --- a/src/ngircd/conf.h +++ b/src/ngircd/conf.h @@ -180,12 +180,12 @@ GLOBAL void Conf_UnsetServer PARAMS(( CONN_ID Idx )); GLOBAL void Conf_SetServer PARAMS(( int ConfServer, CONN_ID Idx )); GLOBAL int Conf_GetServer PARAMS(( CONN_ID Idx )); -GLOBAL bool Conf_EnableServer PARAMS(( char *Name, UINT16 Port )); +GLOBAL bool Conf_EnableServer PARAMS(( const char *Name, UINT16 Port )); GLOBAL bool Conf_EnablePassiveServer PARAMS((const char *Name)); -GLOBAL bool Conf_DisableServer PARAMS(( char *Name )); -GLOBAL bool Conf_AddServer PARAMS(( char *Name, UINT16 Port, char *Host, char *MyPwd, char *PeerPwd )); +GLOBAL bool Conf_DisableServer PARAMS(( const char *Name )); +GLOBAL bool Conf_AddServer PARAMS(( const char *Name, UINT16 Port, const char *Host, const char *MyPwd, const char *PeerPwd )); -GLOBAL bool Conf_IsService PARAMS((int ConfServer, char *Nick)); +GLOBAL bool Conf_IsService PARAMS((int ConfServer, const char *Nick)); #endif diff --git a/src/ngircd/conn-zip.c b/src/ngircd/conn-zip.c index 826383b0..d7722235 100644 --- a/src/ngircd/conn-zip.c +++ b/src/ngircd/conn-zip.c @@ -93,7 +93,7 @@ Zip_InitConn( CONN_ID Idx ) * @param Len Length of the data to add. * @return true on success, false otherwise. */ GLOBAL bool -Zip_Buffer( CONN_ID Idx, char *Data, size_t Len ) +Zip_Buffer( CONN_ID Idx, const char *Data, size_t Len ) { size_t buflen; diff --git a/src/ngircd/conn-zip.h b/src/ngircd/conn-zip.h index 6458a4e2..08abb50c 100644 --- a/src/ngircd/conn-zip.h +++ b/src/ngircd/conn-zip.h @@ -22,7 +22,7 @@ GLOBAL bool Zip_InitConn PARAMS(( CONN_ID Idx )); -GLOBAL bool Zip_Buffer PARAMS(( CONN_ID Idx, char *Data, size_t Len )); +GLOBAL bool Zip_Buffer PARAMS(( CONN_ID Idx, const char *Data, size_t Len )); GLOBAL bool Zip_Flush PARAMS(( CONN_ID Idx )); GLOBAL bool Unzip_Buffer PARAMS(( CONN_ID Idx )); diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c index 5b525112..c27cebf9 100644 --- a/src/ngircd/conn.c +++ b/src/ngircd/conn.c @@ -886,13 +886,13 @@ Conn_Write( CONN_ID Idx, char *Data, size_t Len ) GLOBAL void -Conn_Close( CONN_ID Idx, char *LogMsg, char *FwdMsg, bool InformClient ) +Conn_Close( CONN_ID Idx, const char *LogMsg, const char *FwdMsg, bool InformClient ) { /* Close connection. Open pipes of asyncronous resolver * sub-processes are closed down. */ CLIENT *c; - char *txt; + const char *txt; double in_k, out_k; UINT16 port; #ifdef ZLIB diff --git a/src/ngircd/conn.h b/src/ngircd/conn.h index 450d3d10..28bbda35 100644 --- a/src/ngircd/conn.h +++ b/src/ngircd/conn.h @@ -108,7 +108,7 @@ GLOBAL void Conn_Handler PARAMS(( void )); GLOBAL bool Conn_WriteStr PARAMS(( CONN_ID Idx, char *Format, ... )); -GLOBAL void Conn_Close PARAMS(( CONN_ID Idx, char *LogMsg, char *FwdMsg, bool InformClient )); +GLOBAL void Conn_Close PARAMS(( CONN_ID Idx, const char *LogMsg, const char *FwdMsg, bool InformClient )); GLOBAL void Conn_SyncServerStruct PARAMS(( void ));