Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add include/numerics.h, contains/will contain an enum for numerics. W…

…ork in progress.

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10006 e03df62e-2008-0410-955e-edbf42e46eb7
  • Loading branch information...
commit 95538518b3d672ffd9ad46a91293a8b2d4b35220 1 parent 33f80ef
@rburchell rburchell authored
Showing with 51 additions and 9 deletions.
  1. +1 −0  include/inspircd.h
  2. +41 −0 include/numerics.h
  3. +9 −9 src/channels.cpp
View
1  include/inspircd.h
@@ -40,6 +40,7 @@
#include <climits>
#include "inspircd_config.h"
+#include "numerics.h"
#include "uid.h"
#include "users.h"
#include "channels.h"
View
41 include/numerics.h
@@ -0,0 +1,41 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * InspIRCd: (C) 2002-2008 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+/*
+ * This file is aimed providing a string that is easier to use than using the numeric
+ * directly.
+ *
+ * Thanks to Darom, jackmcbarn and Brain for suggesting and discussing this.
+ *
+ * Please note that the list may not be exhaustive, it'll be done when I have
+ * nothing better to do with my time. -- w00t (jul 13, 2008)
+ */
+
+enum Numerics
+{
+ /*
+ * Reply range of numerics.
+ */
+ RPL_TOPIC = 332,
+ RPL_TOPICTIME = 333,
+
+
+ /*
+ * Error range of numerics.
+ */
+ ERR_TOOMANYCHANNELS = 405,
+ ERR_BADCHANNELKEY = 475,
+ ERR_INVITEONLYCHAN = 473,
+ ERR_CHANNELISFULL = 471,
+ ERR_BANNEDFROMCHAN = 474
+};
View
18 src/channels.cpp
@@ -229,7 +229,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool
{
if (user->chans.size() >= user->GetMaxChans())
{
- user->WriteNumeric(405, "%s %s :You are on too many channels",user->nick.c_str(), cn);
+ user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn);
return NULL;
}
}
@@ -239,7 +239,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool
{
if (user->chans.size() >= Instance->Config->OperMaxChans)
{
- user->WriteNumeric(405, "%s %s :You are on too many channels",user->nick.c_str(), cn);
+ user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn);
return NULL;
}
}
@@ -247,7 +247,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool
{
if (user->chans.size() >= Instance->Config->MaxChans)
{
- user->WriteNumeric(405, "%s %s :You are on too many channels",user->nick.c_str(), cn);
+ user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn);
return NULL;
}
}
@@ -310,7 +310,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool
{
if ((!key) || Ptr->key == key)
{
- user->WriteNumeric(475, "%s %s :Cannot join channel (Incorrect channel key)",user->nick.c_str(), Ptr->name.c_str());
+ user->WriteNumeric(ERR_BADCHANNELKEY, "%s %s :Cannot join channel (Incorrect channel key)",user->nick.c_str(), Ptr->name.c_str());
return NULL;
}
}
@@ -323,7 +323,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool
{
if (!user->IsInvited(Ptr->name.c_str()))
{
- user->WriteNumeric(473, "%s %s :Cannot join channel (Invite only)",user->nick.c_str(), Ptr->name.c_str());
+ user->WriteNumeric(ERR_INVITEONLYCHAN, "%s %s :Cannot join channel (Invite only)",user->nick.c_str(), Ptr->name.c_str());
return NULL;
}
}
@@ -337,7 +337,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool
{
if (Ptr->GetUserCounter() >= Ptr->limit)
{
- user->WriteNumeric(471, "%s %s :Cannot join channel (Channel is full)",user->nick.c_str(), Ptr->name.c_str());
+ user->WriteNumeric(ERR_CHANNELISFULL, "%s %s :Cannot join channel (Channel is full)",user->nick.c_str(), Ptr->name.c_str());
return NULL;
}
}
@@ -346,7 +346,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool
{
if (Ptr->IsBanned(user))
{
- user->WriteNumeric(474, "%s %s :Cannot join channel (You're banned)",user->nick.c_str(), Ptr->name.c_str());
+ user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s %s :Cannot join channel (You're banned)",user->nick.c_str(), Ptr->name.c_str());
return NULL;
}
}
@@ -416,8 +416,8 @@ Channel* Channel::ForceChan(InspIRCd* Instance, Channel* Ptr, User* user, const
{
if (Ptr->topicset)
{
- user->WriteNumeric(332, "%s %s :%s", user->nick.c_str(), Ptr->name.c_str(), Ptr->topic.c_str());
- user->WriteNumeric(333, "%s %s %s %lu", user->nick.c_str(), Ptr->name.c_str(), Ptr->setby.c_str(), (unsigned long)Ptr->topicset);
+ user->WriteNumeric(RPL_TOPIC, "%s %s :%s", user->nick.c_str(), Ptr->name.c_str(), Ptr->topic.c_str());
+ user->WriteNumeric(RPL_TOPICTIME, "%s %s %s %lu", user->nick.c_str(), Ptr->name.c_str(), Ptr->setby.c_str(), (unsigned long)Ptr->topicset);
}
Ptr->UserList(user);
}
Please sign in to comment.
Something went wrong with that request. Please try again.