summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cmd_kick.cpp19
-rw-r--r--src/cmd_nick.cpp7
-rw-r--r--src/cmd_quit.cpp13
-rw-r--r--src/cmd_stats.cpp4
-rw-r--r--src/cmd_whowas.cpp6
-rw-r--r--src/message.cpp18
6 files changed, 25 insertions, 42 deletions
diff --git a/src/cmd_kick.cpp b/src/cmd_kick.cpp
index 1a3138ed7..5c272112c 100644
--- a/src/cmd_kick.cpp
+++ b/src/cmd_kick.cpp
@@ -41,39 +41,32 @@ using namespace std;
void cmd_kick::Handle (char **parameters, int pcnt, userrec *user)
{
+ char reason[MAXKICK];
+
chanrec* Ptr = FindChan(parameters[0]);
userrec* u = Find(parameters[1]);
- if ((!u) || (!Ptr))
+ if (!u || !Ptr)
{
WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, u ? parameters[0] : parameters[1]);
return;
}
-
if ((IS_LOCAL(user)) && (!has_channel(user,Ptr)) && (!is_uline(user->server)))
{
WriteServ(user->fd,"442 %s %s :You're not on that channel!",user->nick, parameters[0]);
return;
}
-
- char reason[MAXBUF];
-
+
if (pcnt > 2)
{
- strlcpy(reason,parameters[2],MAXBUF);
- if (strlen(reason)>MAXKICK)
- {
- reason[MAXKICK-1] = '\0';
- }
-
+ strlcpy(reason,parameters[2],MAXKICK-1);
kick_channel(user,u,Ptr,reason);
}
else
{
- strlcpy(reason,user->nick,MAXBUF);
+ strlcpy(reason,user->nick,MAXKICK-1);
kick_channel(user,u,Ptr,reason);
}
-
}
diff --git a/src/cmd_nick.cpp b/src/cmd_nick.cpp
index 518d600f1..3f6085362 100644
--- a/src/cmd_nick.cpp
+++ b/src/cmd_nick.cpp
@@ -115,12 +115,9 @@ void cmd_nick::Handle (char **parameters, int pcnt, userrec *user)
}
else
{
- if (strlen(parameters[0]) > 1)
+ if ((*parameters[0] == ':') && (*(parameters[0]+1) != 0))
{
- if (parameters[0][0] == ':')
- {
- *parameters[0]++;
- }
+ parameters[0]++;
}
if (matches_qline(parameters[0]))
{
diff --git a/src/cmd_quit.cpp b/src/cmd_quit.cpp
index 42077e743..50166ffd9 100644
--- a/src/cmd_quit.cpp
+++ b/src/cmd_quit.cpp
@@ -72,16 +72,13 @@ void cmd_quit::Handle (char **parameters, int pcnt, userrec *user)
/* theres more to do here, but for now just close the socket */
if (pcnt == 1)
{
- if (parameters[0][0] == ':')
- {
- *parameters[0]++;
- }
+ if (*parameters[0] == ':')
+ parameters[0]++;
+
reason = parameters[0];
- if (strlen(reason)>MAXQUIT)
- {
- reason[MAXQUIT-1] = '\0';
- }
+ if (strlen(reason) > MAXQUIT)
+ reason[MAXQUIT-1] = 0;
/* We should only prefix the quit for a local user. Remote users have
* already been prefixed, where neccessary, by the upstream server.
diff --git a/src/cmd_stats.cpp b/src/cmd_stats.cpp
index d784b02f6..f6ab7d996 100644
--- a/src/cmd_stats.cpp
+++ b/src/cmd_stats.cpp
@@ -78,10 +78,10 @@ void cmd_stats::Handle (char **parameters, int pcnt, userrec *user)
{
return;
}
- if (strlen(parameters[0])>1)
+ if (parameters[0][1])
{
/* make the stats query 1 character long */
- parameters[0][1] = '\0';
+ parameters[0][1] = 0;
}
if ((*Config->OperOnlyStats) && (strchr(Config->OperOnlyStats,*parameters[0])) && (!*user->oper))
diff --git a/src/cmd_whowas.cpp b/src/cmd_whowas.cpp
index 10d0eeb7e..19898bdea 100644
--- a/src/cmd_whowas.cpp
+++ b/src/cmd_whowas.cpp
@@ -76,11 +76,11 @@ void cmd_whowas::Handle (char **parameters, int pcnt, userrec* user)
time_t rawtime = i->second->signon;
tm *timeinfo;
char b[MAXBUF];
-
+
timeinfo = localtime(&rawtime);
strlcpy(b,asctime(timeinfo),MAXBUF);
- b[strlen(b)-1] = '\0';
-
+ b[24] = 0;
+
WriteServ(user->fd,"314 %s %s %s %s * :%s",user->nick,i->second->nick,i->second->ident,i->second->dhost,i->second->fullname);
WriteServ(user->fd,"312 %s %s %s :%s",user->nick,i->second->nick, *Config->HideWhoisServer ? Config->HideWhoisServer : i->second->server,b);
WriteServ(user->fd,"369 %s %s :End of WHOWAS",user->nick,parameters[0]);
diff --git a/src/message.cpp b/src/message.cpp
index 0e9d7e8e7..3d98c500a 100644
--- a/src/message.cpp
+++ b/src/message.cpp
@@ -68,7 +68,7 @@ int common_channels(userrec *u, userrec *u2)
{
if ((u->chans[i].channel != NULL) && (u2->chans[z].channel != NULL))
{
- if ((!strcasecmp(u->chans[i].channel->name,u2->chans[z].channel->name)) && (u->chans[i].channel) && (u2->chans[z].channel) && (u->registered == 7) && (u2->registered == 7))
+ if ((u->chans[i].channel == u2->chans[z].channel) && (u->chans[i].channel) && (u2->chans[z].channel) && (u->registered == 7) && (u2->registered == 7))
{
if ((c_count(u)) && (c_count(u2)))
{
@@ -157,17 +157,13 @@ void chop(char* str)
void Blocking(int s)
{
- int flags;
- log(DEBUG,"Blocking: %d",s);
- flags = fcntl(s, F_GETFL, 0);
+ int flags = fcntl(s, F_GETFL, 0);
fcntl(s, F_SETFL, flags ^ O_NONBLOCK);
}
void NonBlocking(int s)
{
- int flags;
- log(DEBUG,"NonBlocking: %d",s);
- flags = fcntl(s, F_GETFL, 0);
+ int flags = fcntl(s, F_GETFL, 0);
fcntl(s, F_SETFL, flags | O_NONBLOCK);
}
@@ -296,7 +292,7 @@ char* cmode(userrec *user, chanrec *chan)
{
if (user->chans[i].channel)
{
- if ((!strcasecmp(user->chans[i].channel->name,chan->name)) && (chan != NULL))
+ if ((user->chans[i].channel == chan) && (chan != NULL))
{
if ((user->chans[i].uc_modes & UCMODE_OP) > 0)
{
@@ -326,7 +322,7 @@ int cflags(userrec *user, chanrec *chan)
{
if (user->chans[i].channel)
{
- if ((!strcasecmp(user->chans[i].channel->name,chan->name)) && (chan != NULL))
+ if ((user->chans[i].channel == chan) && (chan != NULL))
{
return user->chans[i].uc_modes;
}
@@ -354,7 +350,7 @@ int cstatus(userrec *user, chanrec *chan)
{
if (user->chans[i].channel)
{
- if ((!strcasecmp(user->chans[i].channel->name,chan->name)) && (chan != NULL))
+ if ((user->chans[i].channel == chan) && (chan != NULL))
{
if ((user->chans[i].uc_modes & UCMODE_OP) > 0)
{
@@ -388,7 +384,7 @@ int has_channel(userrec *u, chanrec *c)
{
if (u->chans[i].channel)
{
- if (!strcasecmp(u->chans[i].channel->name,c->name))
+ if (u->chans[i].channel == c)
{
return 1;
}