diff options
author | om <om@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-07-01 14:40:53 +0000 |
---|---|---|
committer | om <om@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-07-01 14:40:53 +0000 |
commit | 903dbea2b1c4072fcd4538bf67feaf1cf968bac9 (patch) | |
tree | a15a535ccb5b5a05f03d58c439f893c96e81b685 | |
parent | 3cf1ae04704b4f1706daa1077b90fd14d1e72cef (diff) |
Change WriteChannelWithServ and it's _NoFormat to take a const char* servername rather than char* - although it doesn't seem to be used :<
Lose some more casts in m_spanningtree, unneeded because of above changes
Make xline_set_creation_time() take const char* rather than char* for it's first parameter, lose more casts in spanningtree because of this
Make do_whois take a const char* rather chan char* nick, lose yet more casts
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4095 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/commands/cmd_whois.h | 2 | ||||
-rw-r--r-- | include/helperfuncs.h | 4 | ||||
-rw-r--r-- | include/xline.h | 8 | ||||
-rw-r--r-- | src/cmd_whois.cpp | 2 | ||||
-rw-r--r-- | src/helperfuncs.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree.cpp | 35 | ||||
-rw-r--r-- | src/xline.cpp | 8 |
7 files changed, 30 insertions, 33 deletions
diff --git a/include/commands/cmd_whois.h b/include/commands/cmd_whois.h index 5e62e64a3..75abc6053 100644 --- a/include/commands/cmd_whois.h +++ b/include/commands/cmd_whois.h @@ -28,7 +28,7 @@ #include "users.h" #include "channels.h" -void do_whois(userrec* user, userrec* dest,unsigned long signon, unsigned long idle, char* nick); +void do_whois(userrec* user, userrec* dest,unsigned long signon, unsigned long idle, const char* nick); class cmd_whois : public command_t { diff --git a/include/helperfuncs.h b/include/helperfuncs.h index 5eb6e22d8..2fa47bffe 100644 --- a/include/helperfuncs.h +++ b/include/helperfuncs.h @@ -54,7 +54,7 @@ void WriteFrom(int sock, userrec *user,char* text, ...); void WriteTo(userrec *source, userrec *dest,char *data, ...); void WriteChannel(chanrec* Ptr, userrec* user, char* text, ...); void WriteChannelLocal(chanrec* Ptr, userrec* user, char* text, ...); -void WriteChannelWithServ(char* ServName, chanrec* Ptr, char* text, ...); +void WriteChannelWithServ(const char* ServName, chanrec* Ptr, const char* text, ...); void ChanExceptSender(chanrec* Ptr, userrec* user, char status, char* text, ...); void WriteCommon(userrec *u, char* text, ...); void WriteCommonExcept(userrec *u, char* text, ...); @@ -66,7 +66,7 @@ void WriteFrom_NoFormat(int sock, userrec *user,const char* text); void WriteTo_NoFormat(userrec *source, userrec *dest,const char *data); void WriteChannel_NoFormat(chanrec* Ptr, userrec* user, const char* text); void WriteChannelLocal_NoFormat(chanrec* Ptr, userrec* user, const char* text); -void WriteChannelWithServ_NoFormat(char* ServName, chanrec* Ptr, const char* text); +void WriteChannelWithServ_NoFormat(const char* ServName, chanrec* Ptr, const char* text); void ChanExceptSender_NoFormat(chanrec* Ptr, userrec* user, char status, const char* text); void WriteCommon_NoFormat(userrec *u, const char* text); void WriteCommonExcept_NoFormat(userrec *u, const char* text); diff --git a/include/xline.h b/include/xline.h index a6c708f9a..15ae609d2 100644 --- a/include/xline.h +++ b/include/xline.h @@ -158,10 +158,10 @@ void stats_q(userrec* user); void stats_z(userrec* user); void stats_e(userrec* user); -void gline_set_creation_time(char* host, time_t create_time); -void qline_set_creation_time(char* nick, time_t create_time); -void zline_set_creation_time(char* ip, time_t create_time); -void eline_set_creation_time(char* host, time_t create_time); +void gline_set_creation_time(const char* host, time_t create_time); +void qline_set_creation_time(const char* nick, time_t create_time); +void zline_set_creation_time(const char* ip, time_t create_time); +void eline_set_creation_time(const char* host, time_t create_time); bool zline_make_global(const char* ipaddr); bool qline_make_global(const char* nickname); diff --git a/src/cmd_whois.cpp b/src/cmd_whois.cpp index 4ef1e0373..4caf0b783 100644 --- a/src/cmd_whois.cpp +++ b/src/cmd_whois.cpp @@ -30,7 +30,7 @@ extern ModuleList modules; extern FactoryList factory; extern time_t TIME; -void do_whois(userrec* user, userrec* dest,unsigned long signon, unsigned long idle, char* nick) +void do_whois(userrec* user, userrec* dest,unsigned long signon, unsigned long idle, const char* nick) { // bug found by phidjit - were able to whois an incomplete connection if it had sent a NICK or USER if (dest->registered == 7) diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index a30a669ae..6250b6285 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -547,7 +547,7 @@ void WriteChannelLocal_NoFormat(chanrec* Ptr, userrec* user, const char* text) -void WriteChannelWithServ(char* ServName, chanrec* Ptr, char* text, ...) +void WriteChannelWithServ(const char* ServName, chanrec* Ptr, const char* text, ...) { char textbuffer[MAXBUF]; va_list argsPtr; @@ -572,7 +572,7 @@ void WriteChannelWithServ(char* ServName, chanrec* Ptr, char* text, ...) } } -void WriteChannelWithServ_NoFormat(char* ServName, chanrec* Ptr, const char* text) +void WriteChannelWithServ_NoFormat(const char* ServName, chanrec* Ptr, const char* text) { CUList *ulist; diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index efedb2b8c..b88083c3f 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -965,7 +965,7 @@ class TreeSocket : public InspSocket userrec* user = Srv->FindNick(source); if (!user) { - WriteChannelWithServ((char*)source.c_str(), c, "TOPIC %s :%s", c->name, c->topic); + WriteChannelWithServ(source.c_str(), c, "TOPIC %s :%s", c->name, c->topic); } else { @@ -1030,7 +1030,7 @@ class TreeSocket : public InspSocket for (unsigned int usernum = 2; usernum < params.size(); usernum++) { /* process one channel at a time, applying modes. */ - char* usr = (char*)params[usernum].c_str(); + char* usr = const_cast<char*>(params[usernum].c_str()); /* Safety check just to make sure someones not sent us an FJOIN full of spaces * (is this even possible?) */ if (usr && *usr) @@ -1197,7 +1197,7 @@ class TreeSocket : public InspSocket } inet_aton(params[6].c_str(),&clientlist[tempnick]->ip4); - WriteOpers("*** Client connecting at %s: %s!%s@%s [%s]",clientlist[tempnick]->server,clientlist[tempnick]->nick,clientlist[tempnick]->ident,clientlist[tempnick]->host,(char*)inet_ntoa(clientlist[tempnick]->ip4)); + WriteOpers("*** Client connecting at %s: %s!%s@%s [%s]",clientlist[tempnick]->server,clientlist[tempnick]->nick,clientlist[tempnick]->ident,clientlist[tempnick]->host, inet_ntoa(clientlist[tempnick]->ip4)); params[7] = ":" + params[7]; DoOneToAllButSender(source,"NICK",params,source); @@ -1391,7 +1391,7 @@ class TreeSocket : public InspSocket { if (u->second->registered == 7) { - snprintf(data,MAXBUF,":%s NICK %lu %s %s %s %s +%s %s :%s",u->second->server,(unsigned long)u->second->age,u->second->nick,u->second->host,u->second->dhost,u->second->ident,u->second->modes,(char*)inet_ntoa(u->second->ip4),u->second->fullname); + snprintf(data,MAXBUF,":%s NICK %lu %s %s %s %s +%s %s :%s",u->second->server,(unsigned long)u->second->age,u->second->nick,u->second->host,u->second->dhost,u->second->ident,u->second->modes,inet_ntoa(u->second->ip4),u->second->fullname); this->WriteLine(data); if (*u->second->oper) { @@ -1773,19 +1773,19 @@ class TreeSocket : public InspSocket { case 'Z': propogate = add_zline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str()); - zline_set_creation_time((char*)params[1].c_str(), atoi(params[3].c_str())); + zline_set_creation_time(params[1].c_str(), atoi(params[3].c_str())); break; case 'Q': propogate = add_qline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str()); - qline_set_creation_time((char*)params[1].c_str(), atoi(params[3].c_str())); + qline_set_creation_time(params[1].c_str(), atoi(params[3].c_str())); break; case 'E': propogate = add_eline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str()); - eline_set_creation_time((char*)params[1].c_str(), atoi(params[3].c_str())); + eline_set_creation_time(params[1].c_str(), atoi(params[3].c_str())); break; case 'G': propogate = add_gline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str()); - gline_set_creation_time((char*)params[1].c_str(), atoi(params[3].c_str())); + gline_set_creation_time(params[1].c_str(), atoi(params[3].c_str())); break; case 'K': propogate = add_kline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str()); @@ -1884,7 +1884,7 @@ class TreeSocket : public InspSocket unsigned long signon = atoi(params[1].c_str()); unsigned long idle = atoi(params[2].c_str()); if ((who_to_send_to) && (who_to_send_to->fd > -1)) - do_whois(who_to_send_to,u,signon,idle,(char*)nick_whoised.c_str()); + do_whois(who_to_send_to,u,signon,idle,nick_whoised.c_str()); } else { @@ -2213,19 +2213,16 @@ class TreeSocket : public InspSocket bool ProcessLine(std::string line) { - char* l = (char*)line.c_str(); - for (char* x = l; *x; x++) - { - if ((*x == '\r') || (*x == '\n')) - *x = 0; - } - if (!*l) + if (!*line.c_str()) return true; - - log(DEBUG,"IN: %s",l); + + line = line.substr(0, line.find_first_of("\r\n")); + + log(DEBUG,"IN: %s", line.c_str()); std::deque<std::string> params; - this->Split(l,true,params); + + this->Split(line.c_str(),true,params); irc::string command = ""; std::string prefix = ""; if (((params[0].c_str())[0] == ':') && (params.size() > 1)) diff --git a/src/xline.cpp b/src/xline.cpp index 0443a4f17..4cc4c4238 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -466,7 +466,7 @@ char* matches_exception(const char* host) } -void gline_set_creation_time(char* host, time_t create_time) +void gline_set_creation_time(const char* host, time_t create_time) { for (std::vector<GLine>::iterator i = glines.begin(); i != glines.end(); i++) { @@ -487,7 +487,7 @@ void gline_set_creation_time(char* host, time_t create_time) return ; } -void eline_set_creation_time(char* host, time_t create_time) +void eline_set_creation_time(const char* host, time_t create_time) { for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++) { @@ -508,7 +508,7 @@ void eline_set_creation_time(char* host, time_t create_time) return; } -void qline_set_creation_time(char* nick, time_t create_time) +void qline_set_creation_time(const char* nick, time_t create_time) { for (std::vector<QLine>::iterator i = qlines.begin(); i != qlines.end(); i++) { @@ -529,7 +529,7 @@ void qline_set_creation_time(char* nick, time_t create_time) return; } -void zline_set_creation_time(char* ip, time_t create_time) +void zline_set_creation_time(const char* ip, time_t create_time) { for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++) { |