summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/account.h69
-rw-r--r--include/bots.h26
-rw-r--r--include/extern.h15
-rw-r--r--include/modules.h21
-rw-r--r--include/regchannel.h49
-rw-r--r--include/services.h412
-rw-r--r--src/bots.cpp30
-rw-r--r--src/botserv.c62
-rw-r--r--src/channels.c47
-rw-r--r--src/chanserv.c97
-rw-r--r--src/command.cpp16
-rw-r--r--src/commands.c4
-rw-r--r--src/config.c83
-rw-r--r--src/core/bs_assign.c4
-rw-r--r--src/core/bs_badwords.c2
-rw-r--r--src/core/bs_botlist.c4
-rw-r--r--src/core/bs_info.c34
-rw-r--r--src/core/bs_kick.c32
-rw-r--r--src/core/bs_set.c28
-rw-r--r--src/core/cs_access.c10
-rw-r--r--src/core/cs_akick.c61
-rw-r--r--src/core/cs_ban.c6
-rw-r--r--src/core/cs_drop.c10
-rw-r--r--src/core/cs_forbid.c2
-rw-r--r--src/core/cs_info.c37
-rw-r--r--src/core/cs_kick.c6
-rw-r--r--src/core/cs_list.c26
-rw-r--r--src/core/cs_modes.c25
-rw-r--r--src/core/cs_set.c88
-rw-r--r--src/core/cs_suspend.c8
-rw-r--r--src/core/cs_xop.c4
-rw-r--r--src/core/hs_del.c2
-rw-r--r--src/core/hs_delall.c2
-rw-r--r--src/core/hs_set.c2
-rw-r--r--src/core/hs_setall.c2
-rw-r--r--src/core/ms_cancel.c2
-rw-r--r--src/core/ms_check.c4
-rw-r--r--src/core/ms_info.c28
-rw-r--r--src/core/ms_list.c6
-rw-r--r--src/core/ms_read.c6
-rw-r--r--src/core/ms_set.c31
-rw-r--r--src/core/ns_access.c8
-rw-r--r--src/core/ns_alist.c8
-rw-r--r--src/core/ns_drop.c2
-rw-r--r--src/core/ns_forbid.c2
-rw-r--r--src/core/ns_getpass.c2
-rw-r--r--src/core/ns_ghost.c6
-rw-r--r--src/core/ns_group.c11
-rw-r--r--src/core/ns_identify.c6
-rw-r--r--src/core/ns_info.c20
-rw-r--r--src/core/ns_list.c38
-rw-r--r--src/core/ns_logout.c2
-rw-r--r--src/core/ns_recover.c6
-rw-r--r--src/core/ns_register.c5
-rw-r--r--src/core/ns_release.c8
-rw-r--r--src/core/ns_saset.c50
-rw-r--r--src/core/ns_sendpass.c2
-rw-r--r--src/core/ns_set.c46
-rw-r--r--src/core/ns_suspend.c14
-rw-r--r--src/core/os_jupe.c2
-rw-r--r--src/core/os_svsnick.c2
-rw-r--r--src/language.c2
-rw-r--r--src/memoserv.c28
-rw-r--r--src/messages.c5
-rw-r--r--src/modules/cs_appendtopic.c2
-rw-r--r--src/modules/cs_enforce.c21
-rw-r--r--src/modules/ns_noop_convert.c2
-rw-r--r--src/nickalias.cpp1
-rw-r--r--src/nickcore.cpp7
-rw-r--r--src/nickserv.c64
-rw-r--r--src/operserv.c2
-rw-r--r--src/protocol.cpp2
-rw-r--r--src/regchannel.cpp19
-rw-r--r--src/send.c2
-rw-r--r--src/servers.c35
-rw-r--r--src/users.c18
76 files changed, 994 insertions, 859 deletions
diff --git a/include/account.h b/include/account.h
index 09db33955..075b15e9e 100644
--- a/include/account.h
+++ b/include/account.h
@@ -1,6 +1,69 @@
/* NickServ nickname structures. */
+/** Flags set on NickAliases
+ */
+enum NickNameFlag
+{
+ NS_BEGIN,
+
+ /* Nick may not be registered or used */
+ NS_FORBIDDEN,
+ /* Nick never expires */
+ NS_NO_EXPIRE,
+ /* Nick is being held after a kill */
+ NS_KILL_HELD,
+ /* SVSNICK has been sent but nick has not yet changed.
+ * An enforcer will be introduced when it does change. */
+ NS_GUESTED,
+
+ NS_END
+};
+
+/** Flags set on NickCores
+ */
+enum NickCoreFlag
+{
+ NI_BEGIN,
+
+ /* Kill others who take this nick */
+ NI_KILLPROTECT,
+ /* Dont recognize unless IDENTIFIED */
+ NI_SECURE,
+ /* Use PRIVMSG instead of NOTICE */
+ NI_MSG,
+ /* Don't allow user to change memo limit */
+ NI_MEMO_HARDMAX,
+ /* Notify of memos at signon and un-away */
+ NI_MEMO_SIGNON,
+ /* Notify of new memos when sent */
+ NI_MEMO_RECEIVE,
+ /* Don't show in LIST to non-servadmins */
+ NI_PRIVATE,
+ /* Don't show email in INFO */
+ NI_HIDE_EMAIL,
+ /* Don't show last seen address in INFO */
+ NI_HIDE_MASK,
+ /* Don't show last quit message in INFO */
+ NI_HIDE_QUIT,
+ /* Kill in 20 seconds instead of in 60 */
+ NI_KILL_QUICK,
+ /* Kill immediatly */
+ NI_KILL_IMMED,
+ /* User gets email on memo */
+ NI_MEMO_MAIL,
+ /* Don't show services access status */
+ NI_HIDE_STATUS,
+ /* Nickname is suspended */
+ NI_SUSPENDED,
+ /* Autoop nickname in channels */
+ NI_AUTOOP,
+ /* Nick won't expire */
+ NI_NOEXPIRE,
+
+ NI_END
+};
+
/** XXX: this really needs to die with fire and be merged with metadata into NickCore or something.
*/
class NickRequest
@@ -24,7 +87,7 @@ class NickRequest
class NickCore;
-class CoreExport NickAlias : public Extensible
+class CoreExport NickAlias : public Extensible, public Flags<NickNameFlag>
{
public:
NickAlias();
@@ -36,11 +99,10 @@ class CoreExport NickAlias : public Extensible
char *last_usermask; /* Last usermask */
time_t time_registered; /* When the nick was registered */
time_t last_seen; /* When it was seen online for the last time */
- uint16 status; /* See NS_* below */
NickCore *nc; /* I'm an alias of this */
};
-class CoreExport NickCore : public Extensible
+class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag>
{
public:
NickCore();
@@ -53,7 +115,6 @@ class CoreExport NickCore : public Extensible
char *greet; /* Greet associated to the nick */
uint32 icq; /* ICQ # associated to the nick */
char *url; /* URL associated to the nick */
- uint32 flags; /* See NI_* below */
uint16 language; /* Language selected by nickname owner (LANG_*) */
std::vector<std::string> access; /* Access list, vector of strings */
MemoInfo memos;
diff --git a/include/bots.h b/include/bots.h
index 38ad5534d..80ac08c1f 100644
--- a/include/bots.h
+++ b/include/bots.h
@@ -9,10 +9,33 @@
*
*/
+/** Flags settable on a bot
+ */
+enum BotFlag
+{
+ BI_BEGIN,
+
+ /* This bot can only be assigned by IRCops */
+ BI_PRIVATE,
+ /* The following flags are used to determin what bot really is what.
+ * Since you *could* have ChanServ really named BotServ or something stupid,
+ * this keeps track of them and allows them to be renamed in the config
+ * at any time, even if they already exist in the database
+ */
+ BI_CHANSERV,
+ BI_BOTSERV,
+ BI_HOSTSERV,
+ BI_OPERSERV,
+ BI_MEMOSERV,
+ BI_NICKSERV,
+ BI_GLOBAL,
+
+ BI_END
+};
struct CommandHash;
-class CoreExport BotInfo
+class CoreExport BotInfo : public Extensible, public Flags<BotFlag>
{
public:
BotInfo *next, *prev;
@@ -22,7 +45,6 @@ class CoreExport BotInfo
char *user; /* Its user name */
char *host; /* Its hostname */
char *real; /* Its real name */
- int16 flags; /* Bot flags -- see BI_* below */
time_t created; /* Birth date ;) */
int16 chancount; /* Number of channels that use the bot. */
/* Dynamic data */
diff --git a/include/extern.h b/include/extern.h
index 821bc2190..21a4987ff 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -123,7 +123,7 @@ E Entry *elist_find_mask(EList *list, const char *mask);
E long get_memuse(EList *list);
-#define whosends(ci) ((!(ci) || !((ci)->botflags & BS_SYMBIOSIS) || !(ci)->bi || !(ci)->c || (ci)->c->usercount < BSMinUsers) ? findbot(s_ChanServ) : (ci)->bi)
+#define whosends(ci) ((!(ci) || !((ci)->botflags.HasFlag(BS_SYMBIOSIS)) || !(ci)->bi || !(ci)->c || (ci)->c->usercount < BSMinUsers) ? findbot(s_ChanServ) : (ci)->bi)
/**** chanserv.c ****/
@@ -257,7 +257,7 @@ E bool RestrictMail;
E time_t MailDelay;
E bool DontQuoteAddresses;
-E int NSDefFlags;
+E Flags<NickCoreFlag> NSDefFlags;
E unsigned NSDefLanguage;
E time_t NSRegDelay;
E time_t NSResendDelay;
@@ -280,7 +280,7 @@ E bool NSEmailReg;
E bool NSModeOnID;
E bool NSAddAccessOnReg;
-E int CSDefFlags;
+E Flags<ChannelInfoFlag> CSDefFlags;
E unsigned CSMaxReg;
E time_t CSExpire;
E int CSDefBantype;
@@ -298,7 +298,7 @@ E time_t MSSendDelay;
E bool MSNotifyAll;
E unsigned MSMemoReceipt;
-E int BSDefFlags;
+E Flags<BotServFlag> BSDefFlags;
E time_t BSKeepData;
E unsigned BSMinUsers;
E unsigned BSBadWordsMax;
@@ -720,14 +720,13 @@ E Server *serv_uplink;
E uint32 uplink_capab;
E CapabInfo capab_info[];
-E Server *first_server(int flags);
-E Server *next_server(int flags);
+E Server *first_server(ServerFlag flag);
+E Server *next_server(ServerFlag flag);
E int is_ulined(const char *server);
E int is_sync(Server *server);
-E Server *new_server(Server * uplink, const char *name, const char *desc,
- uint16 flags, const char *suid);
+E Server *new_server(Server * uplink, const char *name, const char *desc, ServerFlag flag, const char *suid);
E Server *findserver(Server *s, const char *name);
diff --git a/include/modules.h b/include/modules.h
index bd128a3bc..d5fddcc44 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -217,7 +217,7 @@ struct ModuleLang_ {
char **argv;
};
-enum CommandFlags
+enum CommandFlag
{
CFLAG_ALLOW_UNREGISTERED = 1,
CFLAG_ALLOW_FORBIDDEN = 2,
@@ -229,9 +229,8 @@ enum CommandFlags
/** Every services command is a class, inheriting from Command.
*/
-class CoreExport Command
+class CoreExport Command : public Flags<CommandFlag>
{
- int flags;
public:
size_t MaxParams;
size_t MinParams;
@@ -264,22 +263,6 @@ class CoreExport Command
*/
virtual void OnSyntaxError(User *u);
- /** Set a certain flag on this command.
- * @param flag The CommandFlag to set on this command.
- */
- void SetFlag(CommandFlags flag);
-
- /** Remove a certain flag from this command.
- * @param flag The CommandFlag to unset.
- */
- void UnsetFlag(CommandFlags flag);
-
- /** Check whether a certain flag is set on this command.
- * @param flag The CommandFlag to check.
- * @return bool True if the flag is set, false else.
- */
- bool HasFlag(CommandFlags flag) const;
-
/** Set which command permission (e.g. chanserv/forbid) is required for this command.
* @param reststr The permission required to successfully execute this command
*/
diff --git a/include/regchannel.h b/include/regchannel.h
index 73a0666ab..710437374 100644
--- a/include/regchannel.h
+++ b/include/regchannel.h
@@ -9,7 +9,51 @@
*
*/
-class CoreExport ChannelInfo : public Extensible
+/** Flags used for the ChannelInfo class
+ */
+enum ChannelInfoFlag
+{
+ CI_BEGIN,
+
+ /* ChanServ is currently holding the channel */
+ CI_INHABIT,
+ /* Retain the topic even after the channel is emptied */
+ CI_KEEPTOPIC,
+ /* Don't allow non-authorized users to be opped */
+ CI_SECUREOPS,
+ /* Hide channel from ChanServ LIST command */
+ CI_PRIVATE,
+ /* Topic can only be changed by SET TOPIC */
+ CI_TOPICLOCK,
+ /* Only users on the access list may join */
+ CI_RESTRICTED,
+ /* Don't allow ChanServ and BotServ commands to do bad things to users with higher access levels */
+ CI_PEACE,
+ /* Don't allow any privileges unless a user is IDENTIFIED with NickServ */
+ CI_SECURE,
+ /* Don't allow the channel to be registered or used */
+ CI_FORBIDDEN,
+ /* Channel does not expire */
+ CI_NO_EXPIRE,
+ /* Channel memo limit may not be changed */
+ CI_MEMO_HARDMAX,
+ /* Send notice to channel on use of OP/DEOP */
+ CI_OPNOTICE,
+ /* Stricter control of channel founder status */
+ CI_SECUREFOUNDER,
+ /* Sign kicks with the user who did the kick */
+ CI_SIGNKICK,
+ /* Sign kicks if level is < than the one defined by the SIGNKIGK level */
+ CI_SIGNKICK_LEVEL,
+ /* Uses XOP */
+ CI_XOP,
+ /* Channel is suspended */
+ CI_SUSPENDED,
+
+ CI_END
+};
+
+class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag>
{
private:
std::map<ChannelModeName, std::string> Params; /* Map of parameters by mode name */
@@ -36,7 +80,6 @@ class CoreExport ChannelInfo : public Extensible
char last_topic_setter[NICKMAX]; /* Who set the last topic */
time_t last_topic_time; /* When the last topic was set */
- uint32 flags; /* See below */
char *forbidby;
char *forbidreason;
@@ -53,7 +96,7 @@ class CoreExport ChannelInfo : public Extensible
/* For BotServ */
BotInfo *bi; /* Bot used on this channel */
- uint32 botflags; /* BS_* below */
+ Flags<BotServFlag> botflags;
int16 *ttb; /* Times to ban for each kicker */
uint16 bwcount;
diff --git a/include/services.h b/include/services.h
index 738c4b283..1680d4d1a 100644
--- a/include/services.h
+++ b/include/services.h
@@ -418,18 +418,65 @@ class CoreExport Extensible
};
+/** Class with the ability to keep flags on items, they should extend from this
+ * where T is an enum.
+ */
+template <class T>
+class CoreExport Flags
+{
+ protected:
+ std::bitset<128> Flag_Values;
+
+ public:
+ /** Add a flag to this item
+ * @param Value The flag
+ */
+ void SetFlag(T Value)
+ {
+ Flag_Values[(size_t)Value] = true;
+ }
+
+ /** Remove a flag from this item
+ * @param Value The flag
+ */
+ void UnsetFlag(T Value)
+ {
+ Flag_Values[(size_t)Value] = false;
+ }
+
+ /** Check if this item has a flag
+ * @param Value The flag
+ * @return true or false
+ */
+ const bool HasFlag(T Value) const
+ {
+ return Flag_Values[(size_t)Value];
+ }
+
+ /** Check how many flags are set
+ * @return The number of flags set
+ */
+ const size_t FlagCount() const
+ {
+ return Flag_Values.count();
+ }
+
+ /** Unset all of the flags
+ */
+ void ClearFlags()
+ {
+ Flag_Values.reset();
+ }
+};
+
/*************************************************************************/
/* forward declarations, mostly used by older code */
class User;
class ChannelInfo;
class Channel;
+class EList;
-typedef struct server_ Server;
-typedef struct c_elist EList;
-typedef struct c_elist_entry Entry;
-typedef struct memo_ Memo;
-typedef struct badword_ BadWord;
typedef struct bandata_ BanData;
typedef struct userdata_ UserData;
typedef struct mailinfo_ MailInfo;
@@ -584,12 +631,24 @@ struct ircdcapab_ {
/*************************************************************************/
+/** Memo Flags
+ */
+enum MemoFlag
+{
+ /* Memo is unread */
+ MF_UNREAD,
+ /* SEnder requests a receipt */
+ MF_RECEIPT,
+ /* Memo is a notification of receipt */
+ MF_NOTIFYS
+};
+
/* Memo info structures. Since both nicknames and channels can have memos,
* we encapsulate memo data in a MemoList to make it easier to handle. */
-
-struct memo_ {
+class CoreExport Memo : public Flags<MemoFlag>
+{
+ public:
uint32 number; /* Index number -- not necessarily array position! */
- uint16 flags;
time_t time; /* When it was sent */
char sender[NICKMAX];
char *text;
@@ -636,7 +695,8 @@ enum AccessLevel
* wouldn't get very far. ;) ) */
/* Access levels for users. */
-struct ChanAccess {
+struct ChanAccess
+{
uint16 in_use; /* 1 if this entry is in use, else 0 */
int16 level;
NickCore *nc; /* Guaranteed to be non-NULL if in use, NULL if not */
@@ -644,11 +704,22 @@ struct ChanAccess {
std::string creator;
};
-/* AutoKick data. */
-struct AutoKick
+/** Flags for auto kick
+ */
+enum AutoKickFlag
{
- uint16 flags;
+ /* This auto kick entry is in use */
+ AK_USED,
+ /* Is by nick core, not mask */
+ AK_ISNICK,
+ /* This entry is stuck */
+ AK_STUCK
+};
+/* AutoKick data. */
+class CoreExport AutoKick : public Flags<AutoKickFlag>
+{
+ public:
/* Only one of these can be in use */
std::string mask;
NickCore *nc;
@@ -658,63 +729,28 @@ struct AutoKick
time_t addtime;
};
-#define AK_USED 0x0001
-#define AK_ISNICK 0x0002
-#define AK_STUCK 0x0004
+/** Flags for badwords
+ */
+enum BadWordType
+{
+ /* Always kicks if the word is said */
+ BW_ANY,
+ /* User must way the entire word */
+ BW_SINGLE,
+ /* The word has to start with the badword */
+ BW_START,
+ /* The word has to end with the badword */
+ BW_END
+};
/* Structure used to contain bad words. */
-
-struct badword_ {
+struct BadWord
+{
uint16 in_use;
char *word;
- uint16 type; /* BW_* below */
+ BadWordType type;
};
-#define BW_ANY 0
-#define BW_SINGLE 1
-#define BW_START 2
-#define BW_END 3
-
-#include "regchannel.h"
-
-/* Retain topic even after last person leaves channel */
-#define CI_KEEPTOPIC 0x00000001
-/* Don't allow non-authorized users to be opped */
-#define CI_SECUREOPS 0x00000002
-/* Hide channel from ChanServ LIST command */
-#define CI_PRIVATE 0x00000004
-/* Topic can only be changed by SET TOPIC */
-#define CI_TOPICLOCK 0x00000008
-/* Those not allowed ops are kickbanned */
-#define CI_RESTRICTED 0x00000010
-/* Don't allow ChanServ and BotServ commands to do bad things to bigger levels */
-#define CI_PEACE 0x00000020
-/* Don't allow any privileges unless a user is IDENTIFY'd with NickServ */
-#define CI_SECURE 0x00000040
-/* Don't allow the channel to be registered or used */
-#define CI_FORBIDDEN 0x00000080
-/* Channel password is encrypted */
-#define CI_ENCRYPTEDPW 0x00000100
-/* Channel does not expire */
-#define CI_NO_EXPIRE 0x00000200
-/* Channel memo limit may not be changed */
-#define CI_MEMO_HARDMAX 0x00000400
-/* Send notice to channel on use of OP/DEOP */
-#define CI_OPNOTICE 0x00000800
-/* Stricter control of channel founder status */
-#define CI_SECUREFOUNDER 0x00001000
-/* Always sign kicks */
-#define CI_SIGNKICK 0x00002000
-/* Sign kicks if level is < than the one defined by the SIGNKICK level */
-#define CI_SIGNKICK_LEVEL 0x00004000
-/* Use the xOP lists */
-#define CI_XOP 0x00008000
-/* Channel is suspended */
-#define CI_SUSPENDED 0x00010000
-
-/* TEMPORARY - ChanServ is on the channel. */
-#define CI_INHABIT 0x80000000
-
/* Indices for cmd_access[]: */
#define CA_INVITE 0
#define CA_AKICK 1
@@ -759,22 +795,37 @@ struct badword_ {
#define CA_SIZE 39
/* BotServ SET flags */
-#define BS_DONTKICKOPS 0x00000001
-#define BS_DONTKICKVOICES 0x00000002
-#define BS_FANTASY 0x00000004
-#define BS_SYMBIOSIS 0x00000008
-#define BS_GREET 0x00000010
-#define BS_NOBOT 0x00000020
-
-/* BotServ Kickers flags */
-#define BS_KICK_BOLDS 0x80000000
-#define BS_KICK_COLORS 0x40000000
-#define BS_KICK_REVERSES 0x20000000
-#define BS_KICK_UNDERLINES 0x10000000
-#define BS_KICK_BADWORDS 0x08000000
-#define BS_KICK_CAPS 0x04000000
-#define BS_KICK_FLOOD 0x02000000
-#define BS_KICK_REPEAT 0x01000000
+enum BotServFlag
+{
+ /* BotServ won't kick ops */
+ BS_DONTKICKOPS,
+ /* BotServ won't kick voices */
+ BS_DONTKICKVOICES,
+ /* BotServ bot accepts fantasy commands */
+ BS_FANTASY,
+ /* BotServ bot sets modes etc instead of ChanServ */
+ BS_SYMBIOSIS,
+ /* BotServ should show greets */
+ BS_GREET,
+ /* BotServ bots are not allowed to be in this channel */
+ BS_NOBOT,
+ /* BotServ kicks for bolds */
+ BS_KICK_BOLDS,
+ /* BotServ kicks for colors */
+ BS_KICK_COLORS,
+ /* BOtServ kicks for reverses */
+ BS_KICK_REVERSES,
+ /* BotServ kicks for underlines */
+ BS_KICK_UNDERLINES,
+ /* BotServ kicks for badwords */
+ BS_KICK_BADWORDS,
+ /* BotServ kicks for caps */
+ BS_KICK_CAPS,
+ /* BotServ kicks for flood */
+ BS_KICK_FLOOD,
+ /* BotServ kicks for repeating */
+ BS_KICK_REPEAT
+};
/* Indices for TTB (Times To Ban) */
#define TTB_BOLDS 0
@@ -787,6 +838,8 @@ struct badword_ {
#define TTB_REPEAT 7
#define TTB_SIZE 8
+#include "regchannel.h"
+
/*************************************************************************/
typedef struct {
@@ -805,13 +858,30 @@ typedef enum {
SSYNC_DONE = 1 /* We're in sync */
} SyncState;
-struct server_ {
+/** Flags set on servers
+ */
+enum ServerFlag
+{
+ SERVER_START,
+
+ /* This server is me */
+ SERVER_ISME,
+ /* This server was juped */
+ SERVER_JUPED,
+ /* This server is the current uplink */
+ SERVER_ISUPLINK,
+
+ SERVER_END
+};
+
+class CoreExport Server : public Flags<ServerFlag>
+{
+ public:
Server *next, *prev;
char *name; /* Server name */
uint16 hops; /* Hops between services and server */
char *desc; /* Server description */
- uint16 flags; /* Some info flags, as defined below */
char *suid; /* Server Univeral ID */
SyncState sync; /* Server sync state (see above) */
@@ -819,10 +889,6 @@ struct server_ {
Server *uplink; /* Server which pretends to be the uplink */
};
-#define SERVER_ISME 0x0001
-#define SERVER_JUPED 0x0002
-#define SERVER_ISUPLINK 0x0004
-
/*************************************************************************/
#define CUS_OP 0x0001
@@ -866,16 +932,6 @@ struct userdata_ {
int16 times;
};
-/* Channelban type flags */
-#define ENTRYTYPE_NONE 0x00000000
-#define ENTRYTYPE_CIDR4 0x00000001
-#define ENTRYTYPE_NICK_WILD 0x00000004
-#define ENTRYTYPE_NICK 0x00000008
-#define ENTRYTYPE_USER_WILD 0x00000010
-#define ENTRYTYPE_USER 0x00000020
-#define ENTRYTYPE_HOST_WILD 0x00000040
-#define ENTRYTYPE_HOST 0x00000080
-
struct c_userlist {
struct c_userlist *next, *prev;
User *user;
@@ -998,19 +1054,35 @@ class CoreExport Channel : public Extensible
const bool HasParam(ChannelModeName Name);
};
-struct c_elist {
- Entry *entries;
- int32 count;
+/** Channelban type flags
+ */
+enum EntryType
+{
+ ENTRYTYPE_NONE,
+ ENTRYTYPE_CIDR4,
+ ENTRYTYPE_NICK_WILD,
+ ENTRYTYPE_NICK,
+ ENTRYTYPE_USER_WILD,
+ ENTRYTYPE_USER,
+ ENTRYTYPE_HOST_WILD,
+ ENTRYTYPE_HOST
};
-struct c_elist_entry {
+class CoreExport Entry : public Flags<EntryType>
+{
+ public:
Entry *next, *prev;
- uint32 type;
uint32 cidr_ip; /* IP mask for CIDR matching */
uint32 cidr_mask; /* Netmask for CIDR matching */
char *nick, *user, *host, *mask;
};
+struct EList
+{
+ Entry *entries;
+ int32 count;
+};
+
/*************************************************************************/
/* Ignorance list data. */
@@ -1469,62 +1541,10 @@ enum DefconLevel
DEFCON_SILENT_OPER_ONLY,
DEFCON_AKILL_NEW_CLIENTS,
DEFCON_NO_NEW_MEMOS
-
};
/*************************************************************************/
-/* Memo Flags */
-#define MF_UNREAD 0x0001 /* Memo has not yet been read */
-#define MF_RECEIPT 0x0002 /* Sender requested receipt */
-#define MF_NOTIFYS 0x0004 /* Memo is a notification of receitp */
-
-/* Nickname status flags: */
-#define NS_FORBIDDEN 0x0002 /* Nick may not be registered or used */
-#define NS_NO_EXPIRE 0x0004 /* Nick never expires */
-//#define NS_IDENTIFIED 0x8000 /* User has IDENTIFY'd */
-//#define NS_RECOGNIZED 0x4000 /* ON_ACCESS true && SECURE flag not set */
-//#define NS_ON_ACCESS 0x2000 /* User comes from a known address */
-#define NS_KILL_HELD 0x1000 /* Nick is being held after a kill */
-#define NS_GUESTED 0x0100 /* SVSNICK has been sent but nick has not
- * yet changed. An enforcer will be
- * introduced when it does change. */
-#define NS_MASTER 0x0200 /* Was a master nick; used to import old databases */
-#define NS_TRANSGROUP 0xC000 /* Status flags that can be passed to a nick of the
- same group during nick change */
-#define NS_TEMPORARY 0xFF00 /* All temporary status flags */
-/* These two are not used anymore */
-#define NS_OLD_ENCRYPTEDPW 0x0001 /* Nickname password is encrypted */
-
-
-
-
-/* Nickname setting flags: */
-#define NI_KILLPROTECT 0x00000001 /* Kill others who take this nick */
-#define NI_SECURE 0x00000002 /* Don't recognize unless IDENTIFY'd */
-#define NI_MSG 0x00000004 /* Use PRIVMSGs instead of NOTICEs */
-#define NI_MEMO_HARDMAX 0x00000008 /* Don't allow user to change memo limit */
-#define NI_MEMO_SIGNON 0x00000010 /* Notify of memos at signon and un-away */
-#define NI_MEMO_RECEIVE 0x00000020 /* Notify of new memos when sent */
-#define NI_PRIVATE 0x00000040 /* Don't show in LIST to non-servadmins */
-#define NI_HIDE_EMAIL 0x00000080 /* Don't show E-mail in INFO */
-#define NI_HIDE_MASK 0x00000100 /* Don't show last seen address in INFO */
-#define NI_HIDE_QUIT 0x00000200 /* Don't show last quit message in INFO */
-#define NI_KILL_QUICK 0x00000400 /* Kill in 20 seconds instead of 60 */
-#define NI_KILL_IMMED 0x00000800 /* Kill immediately instead of in 60 sec */
-//#define NI_SERVICES_OPER 0x00001000 /* No longer used */
-//#define NI_SERVICES_ADMIN 0x00002000 /* No longer used */
-#define NI_ENCRYPTEDPW 0x00004000 /* Nickname password is encrypted */
-//#define NI_SERVICES_ROOT 0x00008000 /* No longer used */
-#define NI_MEMO_MAIL 0x00010000 /* User gets email on memo */
-#define NI_HIDE_STATUS 0x00020000 /* Don't show services access status */
-#define NI_SUSPENDED 0x00040000 /* Nickname is suspended */
-#define NI_AUTOOP 0x00080000 /* Autoop nickname in channels */
-#define NI_NOEXPIRE 0x00100000 /* nicks in this group won't expire */
-
-// Old NS_FORBIDDEN, very fucking temporary.
-#define NI_FORBIDDEN 0x80000000
-
/* Languages. Never insert anything in the middle of this list, or
* everybody will start getting the wrong language! If you want to change
* the order the languages are displayed in for NickServ HELP SET LANGUAGE,
@@ -1553,54 +1573,54 @@ enum DefconLevel
#define DEF_LANGUAGE LANG_EN_US
-#define BI_PRIVATE 0x0001
-#define BI_CHANSERV 0x0002
-#define BI_BOTSERV 0x0004
-#define BI_HOSTSERV 0x0008
-#define BI_OPERSERV 0x0010
-#define BI_MEMOSERV 0x0020
-#define BI_NICKSERV 0x0040
-#define BI_GLOBAL 0x0080
-
/*************************************************************************/
-/* CAPAB stuffs */
-typedef struct capabinfo_ CapabInfo;
-struct capabinfo_ {
- const char *token;
- uint32 flag;
+/* Types of capab
+ */
+enum CapabType
+{
+ CAPAB_BEGIN,
+
+ CAPAB_NOQUIT,
+ CAPAB_TSMODE,
+ CAPAB_UNCONNECT,
+ CAPAB_NICKIP,
+ CAPAB_NSJOIN,
+ CAPAB_ZIP,
+ CAPAB_BURST,
+ CAPAB_TS3,
+ CAPAB_TS5,
+ CAPAB_DKEY,
+ CAPAB_DOZIP,
+ CAPAB_DODKEY,
+ CAPAB_QS,
+ CAPAB_SCS,
+ CAPAB_PT4,
+ CAPAB_UID,
+ CAPAB_KNOCK,
+ CAPAB_CLIENT,
+ CAPAB_IPV6,
+ CAPAB_SSJ5,
+ CAPAB_SN2,
+ CAPAB_VHOST,
+ CAPAB_TOKEN,
+ CAPAB_SSJ3,
+ CAPAB_NICK2,
+ CAPAB_VL,
+ CAPAB_TLKEXT,
+ CAPAB_CHANMODE,
+ CAPAB_SJB64,
+ CAPAB_NICKCHARS,
+
+ CAPAB_END
};
-#define CAPAB_NOQUIT 0x00000001
-#define CAPAB_TSMODE 0x00000002
-#define CAPAB_UNCONNECT 0x00000004
-#define CAPAB_NICKIP 0x00000008
-#define CAPAB_NSJOIN 0x00000010
-#define CAPAB_ZIP 0x00000020
-#define CAPAB_BURST 0x00000040
-#define CAPAB_TS3 0x00000080
-#define CAPAB_TS5 0x00000100
-#define CAPAB_DKEY 0x00000200
-#define CAPAB_DOZIP 0x00000400
-#define CAPAB_DODKEY 0x00000800
-#define CAPAB_QS 0x00001000
-#define CAPAB_SCS 0x00002000
-#define CAPAB_PT4 0x00004000
-#define CAPAB_UID 0x00008000
-#define CAPAB_KNOCK 0x00010000
-#define CAPAB_CLIENT 0x00020000
-#define CAPAB_IPV6 0x00040000
-#define CAPAB_SSJ5 0x00080000
-#define CAPAB_SN2 0x00100000
-#define CAPAB_VHOST 0x00200000
-#define CAPAB_TOKEN 0x00400000
-#define CAPAB_SSJ3 0x00800000
-#define CAPAB_NICK2 0x01000000
-#define CAPAB_VL 0x02000000
-#define CAPAB_TLKEXT 0x04000000
-#define CAPAB_CHANMODE 0x08000000
-#define CAPAB_SJB64 0x10000000
-#define CAPAB_NICKCHARS 0x20000000
+/* CAPAB stuffs */
+struct CapabInfo
+{
+ const char *token;
+ CapabType flag;
+};
/*************************************************************************/
diff --git a/src/bots.cpp b/src/bots.cpp
index 4cb4556f2..8a4198b74 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -19,23 +19,22 @@ BotInfo::BotInfo(const char *nnick)
this->uid = ts6_uid_retrieve(); // XXX is this safe? has ts6 been setup yet?
nbots++;
this->cmdTable = NULL;
- this->flags = 0;
this->chancount = 0;
if (s_ChanServ && !stricmp(s_ChanServ, nnick))
- this->flags |= BI_CHANSERV;
+ this->SetFlag(BI_CHANSERV);
else if (s_BotServ && !stricmp(s_BotServ, nnick))
- this->flags |= BI_BOTSERV;
+ this->SetFlag(BI_BOTSERV);
else if (s_HostServ && !stricmp(s_HostServ, nnick))
- this->flags |= BI_HOSTSERV;
+ this->SetFlag(BI_HOSTSERV);
else if (s_OperServ && !stricmp(s_OperServ, nnick))
- this->flags |= BI_OPERSERV;
+ this->SetFlag(BI_OPERSERV);
else if (s_MemoServ && !stricmp(s_MemoServ, nnick))
- this->flags |= BI_MEMOSERV;
+ this->SetFlag(BI_MEMOSERV);
else if (s_NickServ && !stricmp(s_NickServ, nnick))
- this->flags |= BI_NICKSERV;
+ this->SetFlag(BI_NICKSERV);
else if (s_GlobalNoticer && !stricmp(s_GlobalNoticer, nnick))
- this->flags |= BI_GLOBAL;
+ this->SetFlag(BI_GLOBAL);
FOREACH_MOD(I_OnBotPreLoad, OnBotPreLoad(this));
@@ -57,23 +56,22 @@ BotInfo::BotInfo(const char *nnick, const char *nuser, const char *nhost, const
this->uid = ts6_uid_retrieve(); // XXX is this safe? has ts6 been setup yet?
nbots++;
this->cmdTable = NULL;
- this->flags = 0;
this->chancount = 0;
if (s_ChanServ && !stricmp(s_ChanServ, nnick))
- this->flags |= BI_CHANSERV;
+ this->SetFlag(BI_CHANSERV);
else if (s_BotServ && !stricmp(s_BotServ, nnick))
- this->flags |= BI_BOTSERV;
+ this->SetFlag(BI_BOTSERV);
else if (s_HostServ && !stricmp(s_HostServ, nnick))
- this->flags |= BI_HOSTSERV;
+ this->SetFlag(BI_HOSTSERV);
else if (s_OperServ && !stricmp(s_OperServ, nnick))
- this->flags |= BI_OPERSERV;
+ this->SetFlag(BI_OPERSERV);
else if (s_MemoServ && !stricmp(s_MemoServ, nnick))
- this->flags |= BI_MEMOSERV;
+ this->SetFlag(BI_MEMOSERV);
else if (s_NickServ && !stricmp(s_NickServ, nnick))
- this->flags |= BI_NICKSERV;
+ this->SetFlag(BI_NICKSERV);
else if (s_GlobalNoticer && !stricmp(s_GlobalNoticer, nnick))
- this->flags |= BI_GLOBAL;
+ this->SetFlag(BI_GLOBAL);
FOREACH_MOD(I_OnBotPreLoad, OnBotPreLoad(this));
diff --git a/src/botserv.c b/src/botserv.c
index c160c496b..c9e1f3ed7 100644
--- a/src/botserv.c
+++ b/src/botserv.c
@@ -168,44 +168,44 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf)
*/
/* We first retrieve the user status on the channel if needed */
- if (ci->botflags & (BS_DONTKICKOPS | BS_DONTKICKVOICES))
+ if (ci->botflags.HasFlag(BS_DONTKICKOPS) || ci->botflags.HasFlag(BS_DONTKICKVOICES))
cstatus = chan_get_user_status(ci->c, u);
if (buf && !check_access(u, ci, CA_NOKICK) &&
- (!(ci->botflags & BS_DONTKICKOPS)
+ (!ci->botflags.HasFlag(BS_DONTKICKOPS)
|| !(cstatus & (CUS_HALFOP | CUS_OP | CUS_OWNER | CUS_PROTECT)))
+ && (!ci->botflags.HasFlag(BS_DONTKICKVOICES) || !(cstatus & CUS_VOICE))) {
- && (!(ci->botflags & BS_DONTKICKVOICES) || !(cstatus & CUS_VOICE))) {
/* Bolds kicker */
- if ((ci->botflags & BS_KICK_BOLDS) && strchr(buf, 2)) {
+ if (ci->botflags.HasFlag(BS_KICK_BOLDS) && strchr(buf, 2)) {
check_ban(ci, u, TTB_BOLDS);
bot_kick(ci, u, BOT_REASON_BOLD);
return;
}
/* Color kicker */
- if ((ci->botflags & BS_KICK_COLORS) && strchr(buf, 3)) {
+ if (ci->botflags.HasFlag(BS_KICK_COLORS) && strchr(buf, 3)) {
check_ban(ci, u, TTB_COLORS);
bot_kick(ci, u, BOT_REASON_COLOR);
return;
}
/* Reverses kicker */
- if ((ci->botflags & BS_KICK_REVERSES) && strchr(buf, 22)) {
+ if (ci->botflags.HasFlag(BS_KICK_REVERSES) && strchr(buf, 22)) {
check_ban(ci, u, TTB_REVERSES);
bot_kick(ci, u, BOT_REASON_REVERSE);
return;
}
/* Underlines kicker */
- if ((ci->botflags & BS_KICK_UNDERLINES) && strchr(buf, 31)) {
+ if (ci->botflags.HasFlag(BS_KICK_UNDERLINES) && strchr(buf, 31)) {
check_ban(ci, u, TTB_UNDERLINES);
bot_kick(ci, u, BOT_REASON_UNDERLINE);
return;
}
/* Caps kicker */
- if ((ci->botflags & BS_KICK_CAPS)
+ if (ci->botflags.HasFlag(BS_KICK_CAPS)
&& ((c = strlen(buf)) >= ci->capsmin)) {
int i = 0;
int l = 0;
@@ -231,7 +231,7 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf)
}
/* Bad words kicker */
- if (ci->botflags & BS_KICK_BADWORDS) {
+ if (ci->botflags.HasFlag(BS_KICK_BADWORDS)) {
int i;
int mustkick = 0;
char *nbuf;
@@ -364,7 +364,7 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf)
}
/* Flood kicker */
- if (ci->botflags & BS_KICK_FLOOD) {
+ if (ci->botflags.HasFlag(BS_KICK_FLOOD)) {
time_t now = time(NULL);
ud = get_user_data(ci->c, u);
@@ -386,7 +386,7 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf)
}
/* Repeat kicker */
- if (ci->botflags & BS_KICK_REPEAT) {
+ if (ci->botflags.HasFlag(BS_KICK_REPEAT)) {
ud = get_user_data(ci->c, u);
if (!ud) {
return;
@@ -417,7 +417,7 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf)
/* Fantaisist commands */
- if (buf && (ci->botflags & BS_FANTASY) && *buf == *BSFantasyCharacter && !was_action) {
+ if (buf && ci->botflags.HasFlag(BS_FANTASY) && *buf == *BSFantasyCharacter && !was_action) {
cmd = strtok(buf, " ");
if (cmd && (cmd[0] == *BSFantasyCharacter)) {
@@ -454,8 +454,9 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf)
FOREACH_MOD(I_OnBotFantasy, OnBotFantasy(cmd, u, ci, params));
}
else
+ {
FOREACH_MOD(I_OnBotNoFantasyAccess, OnBotNoFantasyAccess(cmd, u, ci, params));
-
+ }
}
}
}
@@ -502,7 +503,7 @@ void load_bs_dbase()
SAFE(read_string(&bi->real, f));
if (ver >= 10) {
SAFE(read_int16(&tmp16, f));
- bi->flags |= tmp16;
+ //bi->flags |= tmp16;
}
SAFE(read_int32(&tmp32, f));
bi->created = tmp32;
@@ -513,19 +514,19 @@ void load_bs_dbase()
* changed in the config and different from database
* names
*/
- if (s_ChanServ && bi->flags & BI_CHANSERV && strcmp(bi->nick, s_ChanServ))
+ if (s_ChanServ && bi->HasFlag(BI_CHANSERV) && strcmp(bi->nick, s_ChanServ))
bi->ChangeNick(s_ChanServ);
- else if (s_BotServ && bi->flags & BI_BOTSERV && strcmp(bi->nick, s_BotServ))
+ else if (s_BotServ && bi->HasFlag(BI_BOTSERV) && strcmp(bi->nick, s_BotServ))
bi->ChangeNick(s_BotServ);
- else if (s_HostServ && bi->flags & BI_HOSTSERV && strcmp(bi->nick, s_HostServ))
+ else if (s_HostServ && bi->HasFlag(BI_HOSTSERV) && strcmp(bi->nick, s_HostServ))
bi->ChangeNick(s_HostServ);
- else if (s_OperServ && bi->flags & BI_OPERSERV && strcmp(bi->nick, s_OperServ))
+ else if (s_OperServ && bi->HasFlag(BI_OPERSERV) && strcmp(bi->nick, s_OperServ))
bi->ChangeNick(s_OperServ);
- else if (s_MemoServ && bi->flags & BI_MEMOSERV && strcmp(bi->nick, s_MemoServ))
+ else if (s_MemoServ && bi->HasFlag(BI_MEMOSERV) && strcmp(bi->nick, s_MemoServ))
bi->ChangeNick(s_MemoServ);
- else if (s_NickServ && bi->flags & BI_NICKSERV && strcmp(bi->nick, s_NickServ))
+ else if (s_NickServ && bi->HasFlag(BI_NICKSERV) && strcmp(bi->nick, s_NickServ))
bi->ChangeNick(s_NickServ);
- else if (s_GlobalNoticer && bi->flags & BI_GLOBAL && strcmp(bi->nick, s_GlobalNoticer))
+ else if (s_GlobalNoticer && bi->HasFlag(BI_GLOBAL) && strcmp(bi->nick, s_GlobalNoticer))
bi->ChangeNick(s_GlobalNoticer);
}
@@ -566,7 +567,8 @@ void save_bs_dbase()
SAFE(write_string(bi->user, f));
SAFE(write_string(bi->host, f));
SAFE(write_string(bi->real, f));
- SAFE(write_int16(bi->flags, f));
+ //SAFE(write_int16(bi->flags, f));
+ SAFE(write_int16(0, f));
SAFE(write_int32(bi->created, f));
SAFE(write_int16(bi->chancount, f));
}
@@ -893,8 +895,7 @@ void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick,
}
}
- if ((ci->flags & CI_PEACE) && stricmp(requester->nick, nick)
- && (get_access(u, ci) >= get_access(requester, ci)))
+ if (ci->HasFlag(CI_PEACE) && stricmp(requester->nick, nick) && (get_access(u, ci) >= get_access(requester, ci)))
return;
if (ModeManager::FindChannelModeByName(CMODE_EXCEPT))
@@ -937,9 +938,7 @@ void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick,
}
/* Check if we need to do a signkick or not -GD */
- if ((ci->flags & CI_SIGNKICK)
- || ((ci->flags & CI_SIGNKICK_LEVEL)
- && !check_access(requester, ci, CA_SIGNKICK)))
+ if ((ci->HasFlag(CI_SIGNKICK) || ci->HasFlag(CI_SIGNKICK_LEVEL)) && !check_access(requester, ci, CA_SIGNKICK))
ircdproto->SendKick(ci->bi, kav[0], kav[1], "%s (%s)", kav[2],
requester->nick);
else
@@ -971,8 +970,7 @@ void bot_raw_kick(User * requester, ChannelInfo * ci, char *nick,
}
}
- if ((ci->flags & CI_PEACE) && stricmp(requester->nick, nick)
- && (get_access(u, ci) >= get_access(requester, ci)))
+ if (ci->HasFlag(CI_PEACE) && stricmp(requester->nick, nick) && (get_access(u, ci) >= get_access(requester, ci)))
return;
av[0] = ci->name;
@@ -986,9 +984,7 @@ void bot_raw_kick(User * requester, ChannelInfo * ci, char *nick,
av[2] = reason;
}
- if ((ci->flags & CI_SIGNKICK)
- || ((ci->flags & CI_SIGNKICK_LEVEL)
- && !check_access(requester, ci, CA_SIGNKICK)))
+ if (ci->HasFlag(CI_SIGNKICK) || ((ci->HasFlag(CI_SIGNKICK_LEVEL)) && !check_access(requester, ci, CA_SIGNKICK)))
ircdproto->SendKick(ci->bi, av[0], av[1], "%s (%s)", av[2],
requester->nick);
else
@@ -1025,7 +1021,7 @@ void bot_raw_mode(User * requester, ChannelInfo * ci, const char *mode,
}
}
- if (*mode == '-' && (ci->flags & CI_PEACE)
+ if (*mode == '-' && ci->HasFlag(CI_PEACE)
&& stricmp(requester->nick, nick)
&& (get_access(u, ci) >= get_access(requester, ci)))
return;
diff --git a/src/channels.c b/src/channels.c
index 8556179ea..9bd3abdc3 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -625,7 +625,7 @@ void chan_set_modes(const char *source, Channel *chan, int ac, const char **av,
{
if (check < 2)
chan_set_correct_modes(user, chan, 0);
- else if ((chan->ci->flags) && (chan->ci->flags & CI_SECUREOPS))
+ else if (chan->ci->HasFlag(CI_SECUREOPS))
{
/* Fixing bug #1006 oringinally caused by fixing #922
* we must check for secureops here, not in chan_set_correct_modes
@@ -1509,7 +1509,7 @@ void do_cmode(const char *source, int ac, const char **av)
if (!chan) {
if (debug) {
ci = cs_findchan(av[0]);
- if (!(ci && (ci->flags & CI_FORBIDDEN)))
+ if (!(ci && (ci->HasFlag(CI_FORBIDDEN))))
alog("debug: MODE %s for nonexistent channel %s",
merge_args(ac - 1, av + 1), av[0]);
}
@@ -1635,7 +1635,7 @@ void chan_set_correct_modes(User * user, Channel * c, int give_modes)
if (!c || !(ci = c->ci))
return;
- if ((ci->flags & CI_FORBIDDEN) || (*(c->name) == '+'))
+ if ((ci->HasFlag(CI_FORBIDDEN)) || (*(c->name) == '+'))
return;
status = chan_get_user_status(c, user);
@@ -1649,7 +1649,7 @@ void chan_set_correct_modes(User * user, Channel * c, int give_modes)
* to receive modes. I wonder who added that... *looks at Rob* ;) -GD
*/
if (give_modes && (get_ignore(user->nick) == NULL)
- && (!user->nc || !(user->nc->flags & NI_AUTOOP))) {
+ && (!user->nc || !user->nc->HasFlag(NI_AUTOOP))) {
if (owner && (IsFounder(user, ci) || check_access(user, ci, CA_AUTOOWNER)))
add_modes |= CUS_OWNER;
else if (admin && check_access(user, ci, CA_AUTOPROTECT))
@@ -1668,7 +1668,7 @@ void chan_set_correct_modes(User * user, Channel * c, int give_modes)
* Unless the channel has just been created. -heinz
* Or the user matches CA_AUTODEOP... -GD
*/
- if (((ci->flags & CI_SECUREOPS) || (c->usercount == 1)
+ if (((ci->HasFlag(CI_SECUREOPS)) || (c->usercount == 1)
|| check_access(user, ci, CA_AUTODEOP))
&& !is_ulined(user->server->name)) {
if (owner && (status & CUS_OWNER) && !IsFounder(user, ci))
@@ -1823,7 +1823,7 @@ void chan_adduser2(User * user, Channel * c)
if (s_BotServ && c->ci && c->ci->bi) {
if (c->usercount == BSMinUsers)
bot_join(c->ci);
- if (c->usercount >= BSMinUsers && (c->ci->botflags & BS_GREET)
+ if (c->usercount >= BSMinUsers && (c->ci->botflags.HasFlag(BS_GREET))
&& user->nc && user->nc->greet
&& check_access(user, c->ci, CA_GREET)) {
/* Only display the greet if the main uplink we're connected
@@ -2071,7 +2071,7 @@ Entry *entry_create(char *mask)
uint32 ip, cidr;
entry = new Entry;
- entry->type = ENTRYTYPE_NONE;
+ entry->SetFlag(ENTRYTYPE_NONE);
entry->prev = NULL;
entry->next = NULL;
entry->nick = NULL;
@@ -2113,18 +2113,18 @@ Entry *entry_create(char *mask)
entry->nick = sstrdup(nick);
/* Check if we have a wildcard user */
if (str_is_wildcard(nick))
- entry->type |= ENTRYTYPE_NICK_WILD;
+ entry->SetFlag(ENTRYTYPE_NICK_WILD);
else
- entry->type |= ENTRYTYPE_NICK;
+ entry->SetFlag(ENTRYTYPE_NICK);
}
if (user) {
entry->user = sstrdup(user);
/* Check if we have a wildcard user */
if (str_is_wildcard(user))
- entry->type |= ENTRYTYPE_USER_WILD;
+ entry->SetFlag(ENTRYTYPE_USER_WILD);
else
- entry->type |= ENTRYTYPE_USER;
+ entry->SetFlag(ENTRYTYPE_USER);
}
/* Only check the host if it's not a pure wildcard */
@@ -2132,7 +2132,7 @@ Entry *entry_create(char *mask)
if (ircd->cidrchanbei && str_is_cidr(host, &ip, &cidr, &cidrhost)) {
entry->cidr_ip = ip;
entry->cidr_mask = cidr;
- entry->type |= ENTRYTYPE_CIDR4;
+ entry->SetFlag(ENTRYTYPE_CIDR4);
host = cidrhost;
} else if (ircd->cidrchanbei && strchr(host, '/')) {
/* Most IRCd's don't enforce sane bans therefore it is not
@@ -2143,13 +2143,14 @@ Entry *entry_create(char *mask)
* str_is_cidr() as this expects a standard cidr.
* Add it to the internal list (so it is included in for example clear)
* but do not use if during matching.. ~ Viper */
- entry->type = ENTRYTYPE_NONE;
+ entry->ClearFlags();
+ entry->SetFlag(ENTRYTYPE_NONE);
} else {
entry->host = sstrdup(host);
if (str_is_wildcard(host))
- entry->type |= ENTRYTYPE_HOST_WILD;
+ entry->SetFlag(ENTRYTYPE_HOST_WILD);
else
- entry->type |= ENTRYTYPE_HOST;
+ entry->SetFlag(ENTRYTYPE_HOST);
}
}
delete [] mask;
@@ -2246,28 +2247,28 @@ EList *list_create()
int entry_match(Entry * e, const char *nick, const char *user, const char *host, uint32 ip)
{
/* If we don't get an entry, or it s an invalid one, no match ~ Viper */
- if (!e || e->type == ENTRYTYPE_NONE)
+ if (!e || !e->FlagCount())
return 0;
- if (ircd->cidrchanbei && (e->type & ENTRYTYPE_CIDR4) &&
+ if (ircd->cidrchanbei && (e->HasFlag(ENTRYTYPE_CIDR4)) &&
(!ip || (ip && ((ip & e->cidr_mask) != e->cidr_ip))))
return 0;
- if ((e->type & ENTRYTYPE_NICK)
+ if ((e->HasFlag(ENTRYTYPE_NICK))
&& (!nick || stricmp(e->nick, nick) != 0))
return 0;
- if ((e->type & ENTRYTYPE_USER)
+ if ((e->HasFlag(ENTRYTYPE_USER))
&& (!user || stricmp(e->user, user) != 0))
return 0;
- if ((e->type & ENTRYTYPE_HOST)
+ if ((e->HasFlag(ENTRYTYPE_HOST))
&& (!user || stricmp(e->host, host) != 0))
return 0;
- if ((e->type & ENTRYTYPE_NICK_WILD)
+ if ((e->HasFlag(ENTRYTYPE_NICK_WILD))
&& !Anope::Match(nick, e->nick, false))
return 0;
- if ((e->type & ENTRYTYPE_USER_WILD)
+ if ((e->HasFlag(ENTRYTYPE_USER_WILD))
&& !Anope::Match(user, e->user, false))
return 0;
- if ((e->type & ENTRYTYPE_HOST_WILD)
+ if ((e->HasFlag(ENTRYTYPE_HOST_WILD))
&& !Anope::Match(host, e->host, false))
return 0;
diff --git a/src/chanserv.c b/src/chanserv.c
index 340ab045c..c52cd9d07 100644
--- a/src/chanserv.c
+++ b/src/chanserv.c
@@ -134,7 +134,7 @@ class ChanServTimer : public Timer
ChannelInfo *ci = cs_findchan(channel.c_str());
if (ci)
- ci->flags &= ~CI_INHABIT;
+ ci->UnsetFlag(CI_INHABIT);
ircdproto->SendPart(findbot(s_ChanServ), channel.c_str(), NULL);
}
@@ -394,13 +394,14 @@ void load_cs_dbase()
SAFE(read = read_buffer(ci->last_topic_setter, f));
SAFE(read_int32(&tmp32, f));
ci->last_topic_time = tmp32;
- SAFE(read_int32(&ci->flags, f));
+ //SAFE(read_int32(&ci->flags, f));
+ SAFE(read_int32(&tmp32, f));
/* Leaveops cleanup */
- if (ver <= 13 && (ci->flags & 0x00000020))
- ci->flags &= ~0x00000020;
+// if (ver <= 13 && (ci->HasFlag()0x00000020))
+// ci->UnsetFlag()0x00000020;
/* Temporary flags cleanup */
- ci->flags &= ~CI_INHABIT;
+ ci->UnsetFlag(CI_INHABIT);
SAFE(read_string(&ci->forbidby, f));
SAFE(read_string(&ci->forbidreason, f));
@@ -517,7 +518,8 @@ void load_cs_dbase()
ci->memos.memos[j] = new Memo;
Memo *memo = ci->memos.memos[j];
SAFE(read_int32(&memo->number, f));
- SAFE(read_int16(&memo->flags, f));
+ //SAFE(read_int16(&memo->flags, f));
+ SAFE(read_int16(&tmp16, f));
SAFE(read_int32(&tmp32, f));
memo->time = tmp32;
SAFE(read = read_buffer(memo->sender, f));
@@ -540,7 +542,7 @@ void load_cs_dbase()
ci->bi = NULL;
SAFE(read_int32(&tmp32, f));
- ci->botflags = tmp32;
+ //ci->botflags = tmp32;
SAFE(read_int16(&tmp16, f));
n_ttb = tmp16;
ci->ttb = new int16[2 * TTB_SIZE];
@@ -569,7 +571,9 @@ void load_cs_dbase()
SAFE(read_int16(&ci->badwords[j].in_use, f));
if (ci->badwords[j].in_use) {
SAFE(read_string(&ci->badwords[j].word, f));
- SAFE(read_int16(&ci->badwords[j].type, f));
+ //SAFE(read_int16(&ci->badwords[j].type, f));
+ SAFE(read_int16(&tmp16, f));
+ ci->badwords[j].type = BW_ANY; // for now
}
}
} else {
@@ -589,7 +593,7 @@ void load_cs_dbase()
ChannelInfo *next;
for (ci = chanlists[i]; ci; ci = next) {
next = ci->next;
- if (!(ci->flags & CI_FORBIDDEN) && !ci->founder) {
+ if (!(ci->HasFlag(CI_FORBIDDEN)) && !ci->founder) {
alog("%s: database load: Deleting founderless channel %s",
s_ChanServ, ci->name);
delchan(ci);
@@ -655,7 +659,8 @@ void save_cs_dbase()
SAFE(write_string(ci->last_topic, f));
SAFE(written = write_buffer(ci->last_topic_setter, f));
SAFE(write_int32(ci->last_topic_time, f));
- SAFE(write_int32(ci->flags, f));
+ //SAFE(write_int32(ci->flags, f));
+ SAFE(write_int32(0, f));
SAFE(write_string(ci->forbidby, f));
SAFE(write_string(ci->forbidreason, f));
SAFE(write_int16(ci->bantype, f));
@@ -681,8 +686,9 @@ void save_cs_dbase()
for (j = 0; j < ci->GetAkickCount(); ++j)
{
AutoKick *akick = ci->GetAkick(j);
- SAFE(write_int16(akick->flags, f));
- if (akick->flags & AK_ISNICK)
+ //SAFE(write_int16(akick->flags, f));
+ SAFE(write_int16(0, f));
+ if (akick->HasFlag(AK_ISNICK))
SAFE(write_string(akick->nc->display, f));
else
SAFE(write_string(akick->mask.c_str(), f));
@@ -714,7 +720,8 @@ void save_cs_dbase()
for (j = 0; j < ci->memos.memos.size(); j++) {
Memo *memo = ci->memos.memos[j];
SAFE(write_int32(memo->number, f));
- SAFE(write_int16(memo->flags, f));
+ SAFE(write_int16(0, f));
+ //SAFE(write_int16(memo->flags, f));
SAFE(write_int32(memo->time, f));
SAFE(written = write_buffer(memo->sender, f));
SAFE(write_string(memo->text, f));
@@ -727,7 +734,8 @@ void save_cs_dbase()
else
SAFE(write_string(NULL, f));
- SAFE(write_int32(ci->botflags, f));
+ //SAFE(write_int32(ci->botflags, f));
+ SAFE(write_int32(0, f));
tmp16 = TTB_SIZE;
SAFE(write_int16(tmp16, f));
@@ -914,7 +922,7 @@ int check_valid_admin(User * user, Channel * chan, int servermode)
return 0;
/* They will be kicked; no need to deop, no need to update our internal struct too */
- if (chan->ci->flags & CI_FORBIDDEN)
+ if (chan->ci->HasFlag(CI_FORBIDDEN))
return 0;
if (servermode && !check_access(user, chan->ci, CA_AUTOPROTECT)) {
@@ -946,7 +954,7 @@ int check_valid_op(User * user, Channel * chan, int servermode)
return 1;
/* They will be kicked; no need to deop, no need to update our internal struct too */
- if (chan->ci->flags & CI_FORBIDDEN)
+ if (chan->ci->HasFlag(CI_FORBIDDEN))
return 0;
owner = ModeManager::FindChannelModeByName(CMODE_OWNER);
@@ -1029,10 +1037,10 @@ int check_should_op(User * user, char *chan)
{
ChannelInfo *ci = cs_findchan(chan);
- if (!ci || (ci->flags & CI_FORBIDDEN) || *chan == '+')
+ if (!ci || (ci->HasFlag(CI_FORBIDDEN)) || *chan == '+')
return 0;
- if ((ci->flags & CI_SECURE) && !nick_identified(user))
+ if ((ci->HasFlag(CI_SECURE)) && !nick_identified(user))
return 0;
if (check_access(user, ci, CA_AUTOOP)) {
@@ -1052,10 +1060,10 @@ int check_should_voice(User * user, char *chan)
{
ChannelInfo *ci = cs_findchan(chan);
- if (!ci || (ci->flags & CI_FORBIDDEN) || *chan == '+')
+ if (!ci || (ci->HasFlag(CI_FORBIDDEN)) || *chan == '+')
return 0;
- if ((ci->flags & CI_SECURE) && !nick_identified(user))
+ if ((ci->HasFlag(CI_SECURE)) && !nick_identified(user))
return 0;
if (check_access(user, ci, CA_AUTOVOICE)) {
@@ -1072,7 +1080,7 @@ int check_should_halfop(User * user, char *chan)
{
ChannelInfo *ci = cs_findchan(chan);
- if (!ci || (ci->flags & CI_FORBIDDEN) || *chan == '+')
+ if (!ci || (ci->HasFlag(CI_FORBIDDEN)) || *chan == '+')
return 0;
if (check_access(user, ci, CA_AUTOHALFOP)) {
@@ -1090,11 +1098,11 @@ int check_should_owner(User * user, char *chan)
ChannelInfo *ci = cs_findchan(chan);
ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_OWNER);
- if (!ci || (ci->flags & CI_FORBIDDEN) || *chan == '+')
+ if (!ci || (ci->HasFlag(CI_FORBIDDEN)) || *chan == '+')
return 0;
- if (((ci->flags & CI_SECUREFOUNDER) && IsRealFounder(user, ci))
- || (!(ci->flags & CI_SECUREFOUNDER) && IsFounder(user, ci))) {
+ if (((ci->HasFlag(CI_SECUREFOUNDER)) && IsRealFounder(user, ci))
+ || (!(ci->HasFlag(CI_SECUREFOUNDER)) && IsFounder(user, ci))) {
ircdproto->SendMode(whosends(ci), chan, "+o%s %s %s", cm->ModeChar, user->nick,
user->nick);
return 1;
@@ -1110,7 +1118,7 @@ int check_should_protect(User * user, char *chan)
ChannelInfo *ci = cs_findchan(chan);
ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_PROTECT);
- if (!ci || (ci->flags & CI_FORBIDDEN) || *chan == '+')
+ if (!ci || (ci->HasFlag(CI_FORBIDDEN)) || *chan == '+')
return 0;
if (check_access(user, ci, CA_AUTOPROTECT)) {
@@ -1157,7 +1165,7 @@ int check_kick(User * user, const char *chan, time_t chants)
return 0;
}
- if (ci->flags & CI_SUSPENDED || ci->flags & CI_FORBIDDEN)
+ if (ci->HasFlag(CI_SUSPENDED) || ci->HasFlag(CI_FORBIDDEN))
{
if (is_oper(user))
return 0;
@@ -1188,16 +1196,16 @@ int check_kick(User * user, const char *chan, time_t chants)
{
akick = ci->GetAkick(j);
- if (!(akick->flags & AK_USED))
+ if (!akick->HasFlag(AK_USED))
continue;
- if ((akick->flags & AK_ISNICK && akick->nc == nc)
- || (!(akick->flags & AK_ISNICK)
+ if ((akick->HasFlag(AK_ISNICK) && akick->nc == nc)
+ || (!akick->HasFlag(AK_ISNICK)
&& match_usermask(akick->mask.c_str(), user)))
{
if (debug >= 2)
- alog("debug: %s matched akick %s", user->nick, (akick->flags & AK_ISNICK) ? akick->nc->display : akick->mask.c_str());
- if (akick->flags & AK_ISNICK)
+ alog("debug: %s matched akick %s", user->nick, akick->HasFlag(AK_ISNICK) ? akick->nc->display : akick->mask.c_str());
+ if (akick->HasFlag(AK_ISNICK))
get_idealban(ci, user, mask, sizeof(mask));
else
strlcpy(mask, akick->mask.c_str(), sizeof(mask));
@@ -1226,7 +1234,7 @@ int check_kick(User * user, const char *chan, time_t chants)
* JOIN would not). */
/* Don't check for CI_INHABIT before for the Channel record cos else
* c may be NULL even if it exists */
- if ((!(c = findchan(chan)) || c->usercount == 0) && !(ci->flags & CI_INHABIT))
+ if ((!(c = findchan(chan)) || c->usercount == 0) && !ci->HasFlag(CI_INHABIT))
{
ircdproto->SendJoin(findbot(s_ChanServ), chan, (c ? c->creation_time : chants));
/*
@@ -1238,7 +1246,7 @@ int check_kick(User * user, const char *chan, time_t chants)
}
t = new ChanServTimer(CSInhabit, chan);
- ci->flags |= CI_INHABIT;
+ ci->SetFlag(CI_INHABIT);
}
if (c) {
@@ -1306,7 +1314,7 @@ void restore_topic(const char *chan)
return;
/* We can be sure that the topic will be in sync when we return -GD */
c->topic_sync = 1;
- if (!(ci->flags & CI_KEEPTOPIC)) {
+ if (!(ci->HasFlag(CI_KEEPTOPIC))) {
/* We need to reset the topic here, since it's currently empty and
* should be updated with a TOPIC from the IRCd soon. -GD
*/
@@ -1356,7 +1364,7 @@ int check_topiclock(Channel * c, time_t topic_time)
return 0;
}
- if (!(ci = c->ci) || !(ci->flags & CI_TOPICLOCK))
+ if (!(ci = c->ci) || !(ci->HasFlag(CI_TOPICLOCK)))
return 0;
if (c->topic)
@@ -1421,9 +1429,7 @@ void expire_chans()
for (i = 0; i < 256; i++) {
for (ci = chanlists[i]; ci; ci = next) {
next = ci->next;
- if (!ci->c && now - ci->last_used >= CSExpire
- && !(ci->
- flags & (CI_FORBIDDEN | CI_NO_EXPIRE | CI_SUSPENDED)))
+ if (!ci->c && now - ci->last_used >= CSExpire && !ci->HasFlag(CI_FORBIDDEN) && !ci->HasFlag(CI_NO_EXPIRE) && !ci->HasFlag(CI_SUSPENDED))
{
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnPreChanExpire, OnPreChanExpire(ci));
@@ -1500,7 +1506,7 @@ void cs_remove_nick(const NickCore * nc)
for (j = ci->GetAkickCount(); j > 0; --j)
{
akick = ci->GetAkick(j - 1);
- if ((akick->flags & AK_USED) && (akick->flags & AK_ISNICK) && akick->nc == nc)
+ if (akick->HasFlag(AK_USED) && akick->HasFlag(AK_ISNICK) && akick->nc == nc)
ci->EraseAkick(akick);
}
}
@@ -1560,7 +1566,7 @@ int check_access(User * user, ChannelInfo * ci, int what)
if (level >= ACCESS_FOUNDER)
return (what == CA_AUTODEOP || what == CA_NOJOIN) ? 0 : 1;
/* Hacks to make flags work */
- if (what == CA_AUTODEOP && (ci->flags & CI_SECUREOPS) && level == 0)
+ if (what == CA_AUTODEOP && (ci->HasFlag(CI_SECUREOPS)) && level == 0)
return 1;
if (limit == ACCESS_INVALID)
return 0;
@@ -1785,7 +1791,7 @@ bool IsFounder(User *user, ChannelInfo *ci)
}
/* If they're QOP+ and theyre identified or theyre recognized and the channel isn't secure */
- if (access && access->level >= ACCESS_QOP && (user->nc || (user->IsRecognized() && !(ci->flags & CI_SECURE))))
+ if (access && access->level >= ACCESS_QOP && (user->nc || (user->IsRecognized() && !(ci->HasFlag(CI_SECURE)))))
return true;
return false;
@@ -1843,7 +1849,7 @@ int get_access(User *user, ChannelInfo *ci)
NickAlias *na = findnick(user->nick);
if (na)
access = ci->GetAccess(na->nc);
- if (access && user->IsRecognized() && !(ci->flags & CI_SECURE))
+ if (access && user->IsRecognized() && !(ci->HasFlag(CI_SECURE)))
return access->level;
}
@@ -1860,7 +1866,7 @@ void update_cs_lastseen(User * user, ChannelInfo * ci)
return;
if (IsFounder(user, ci) || nick_identified(user)
- || (user->IsRecognized() && !(ci->flags & CI_SECURE)))
+ || (user->IsRecognized() && !ci->HasFlag(CI_SECURE)))
if ((access = ci->GetAccess(user->nc)))
access->last_seen = time(NULL);
}
@@ -1977,7 +1983,7 @@ AutoKick *is_stuck(ChannelInfo * ci, const char *mask)
{
AutoKick *akick = ci->GetAkick(i);
- if (!(akick->flags & AK_USED) || (akick->flags & AK_ISNICK) || !(akick->flags & AK_STUCK))
+ if (!akick->HasFlag(AK_USED) || akick->HasFlag(AK_ISNICK) || !akick->HasFlag(AK_STUCK))
continue;
if (Anope::Match(akick->mask, mask, false))
@@ -2038,8 +2044,7 @@ void stick_all(ChannelInfo * ci)
{
AutoKick *akick = ci->GetAkick(i);
- if (!(akick->flags & AK_USED) || (akick->flags & AK_ISNICK)
- || !(akick->flags & AK_STUCK))
+ if (!akick->HasFlag(AK_USED) || (akick->HasFlag(AK_ISNICK) || !akick->HasFlag(AK_STUCK)))
continue;
av[0] = "+b";
diff --git a/src/command.cpp b/src/command.cpp
index fa5b21a2a..41e9045e5 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -13,7 +13,6 @@
Command::Command(const std::string &sname, size_t min_params, size_t max_params, const std::string &spermission) : MaxParams(max_params), MinParams(min_params), name(sname), permission(spermission)
{
- this->flags = 0;
this->core = 0;
this->mod_name = NULL;
this->service = NULL;
@@ -36,21 +35,6 @@ bool Command::OnHelp(User *u, const ci::string &subcommand) { return false; }
void Command::OnSyntaxError(User *u) { }
-void Command::SetFlag(CommandFlags flag)
-{
- this->flags |= flag;
-}
-
-void Command::UnsetFlag(CommandFlags flag)
-{
- this->flags &= ~flag;
-}
-
-bool Command::HasFlag(CommandFlags flag) const
-{
- return this->flags & flag;
-}
-
void Command::SetPermission(const std::string &reststr)
{
this->permission = reststr;
diff --git a/src/commands.c b/src/commands.c
index 9247307a3..d8fcf5589 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -123,14 +123,14 @@ void mod_run_cmd(char *service, User * u, CommandHash * cmdTable[], const char *
{
if ((ci = cs_findchan(params[0].c_str())))
{
- if ((ci->flags & CI_FORBIDDEN) && (!c->HasFlag(CFLAG_ALLOW_FORBIDDEN)))
+ if ((ci->HasFlag(CI_FORBIDDEN)) && (!c->HasFlag(CFLAG_ALLOW_FORBIDDEN)))
{
notice_lang(service, u, CHAN_X_FORBIDDEN, ci->name);
alog("Access denied for user %s with service %s and command %s because of FORBIDDEN channel %s",
u->nick, service, cmd, ci->name);
return;
}
- else if ((ci->flags & CI_SUSPENDED) && (!c->HasFlag(CFLAG_ALLOW_SUSPENDED)))
+ else if ((ci->HasFlag(CI_SUSPENDED)) && (!c->HasFlag(CFLAG_ALLOW_SUSPENDED)))
{
notice_lang(service, u, CHAN_X_FORBIDDEN, ci->name);
alog("Access denied for user %s with service %s and command %s because of SUSPENDED channel %s",
diff --git a/src/config.c b/src/config.c
index 070fcfb6d..03f1fde24 100644
--- a/src/config.c
+++ b/src/config.c
@@ -95,7 +95,7 @@ static std::string NSDefaults;
char *NSGuestNickPrefix;
bool NSAllowKillImmed;
bool NSNoGroupChange;
-int NSDefFlags;
+Flags<NickCoreFlag> NSDefFlags;
unsigned NSDefLanguage;
time_t NSRegDelay;
time_t NSResendDelay;
@@ -117,7 +117,7 @@ bool NSModeOnID;
bool NSAddAccessOnReg;
static std::string CSDefaults;
-int CSDefFlags;
+Flags<ChannelInfoFlag> CSDefFlags;
unsigned CSMaxReg;
time_t CSExpire;
int CSDefBantype;
@@ -135,7 +135,7 @@ bool MSNotifyAll;
unsigned MSMemoReceipt;
static std::string BSDefaults;
-int BSDefFlags;
+Flags<BotServFlag> BSDefFlags;
time_t BSKeepData;
unsigned BSMinUsers;
unsigned BSBadWordsMax;
@@ -1785,29 +1785,34 @@ int read_config(int reload)
}
}
- NSDefFlags = 0;
- if (NSDefaults.empty()) NSDefFlags = NI_SECURE | NI_MEMO_SIGNON | NI_MEMO_RECEIVE;
+ if (NSDefaults.empty())
+ {
+ NSDefFlags.SetFlag(NI_SECURE);
+ NSDefFlags.SetFlag(NI_MEMO_SIGNON);
+ NSDefFlags.SetFlag(NI_MEMO_RECEIVE);
+ }
else if (NSDefaults != "none") {
bool hadAutoop = false;
spacesepstream options(NSDefaults);
std::string option;
- while (options.GetToken(option)) {
- if (option == "kill") NSDefFlags |= NI_KILLPROTECT;
- else if (option == "killquick") NSDefFlags |= NI_KILL_QUICK;
- else if (option == "secure") NSDefFlags |= NI_SECURE;
- else if (option == "private") NSDefFlags |= NI_PRIVATE;
+ while (options.GetToken(option))
+ {
+ if (option == "kill") NSDefFlags.SetFlag(NI_KILLPROTECT);
+ else if (option == "killquick") NSDefFlags.SetFlag(NI_KILL_QUICK);
+ else if (option == "secure") NSDefFlags.SetFlag(NI_SECURE);
+ else if (option == "private") NSDefFlags.SetFlag(NI_PRIVATE);
else if (option == "msg") {
if (!UsePrivmsg) alog("msg in <nickserv:defaults> can only be used when UsePrivmsg is set");
- else NSDefFlags |= NI_MSG;
+ else NSDefFlags.SetFlag(NI_MSG);
}
- else if (option == "hideemail") NSDefFlags |= NI_HIDE_EMAIL;
- else if (option == "hideusermask") NSDefFlags |= NI_HIDE_MASK;
- else if (option == "hidequit") NSDefFlags |= NI_HIDE_QUIT;
- else if (option == "memosignon") NSDefFlags |= NI_MEMO_SIGNON;
- else if (option == "memoreceive") NSDefFlags |= NI_MEMO_RECEIVE;
+ else if (option == "hideemail") NSDefFlags.SetFlag(NI_HIDE_EMAIL);
+ else if (option == "hideusermask") NSDefFlags.SetFlag(NI_HIDE_MASK);
+ else if (option == "hidequit") NSDefFlags.SetFlag(NI_HIDE_QUIT);
+ else if (option == "memosignon") NSDefFlags.SetFlag(NI_MEMO_SIGNON);
+ else if (option == "memoreceive") NSDefFlags.SetFlag(NI_MEMO_RECEIVE);
else if (option == "autoop") hadAutoop = true;
}
- if (!hadAutoop) NSDefFlags |= NI_AUTOOP;
+ if (!hadAutoop) NSDefFlags.SetFlag(NI_AUTOOP);
}
if (reload) {
@@ -1820,37 +1825,41 @@ int read_config(int reload)
retval = 0;
}
- CSDefFlags = 0;
- if (CSDefaults.empty()) CSDefFlags = CI_KEEPTOPIC | CI_SECURE | CI_SECUREFOUNDER | CI_SIGNKICK;
+ if (CSDefaults.empty())
+ {
+ CSDefFlags.SetFlag(CI_KEEPTOPIC);
+ CSDefFlags.SetFlag(CI_SECURE);
+ CSDefFlags.SetFlag(CI_SECUREFOUNDER);
+ CSDefFlags.SetFlag(CI_SIGNKICK);
+ }
else if (CSDefaults != "none") {
spacesepstream options(CSDefaults);
std::string option;
while (options.GetToken(option)) {
- if (option == "keeptopic") CSDefFlags |= CI_KEEPTOPIC;
- else if (option == "topiclock") CSDefFlags |= CI_TOPICLOCK;
- else if (option == "private") CSDefFlags |= CI_PRIVATE;
- else if (option == "restricted") CSDefFlags |= CI_RESTRICTED;
- else if (option == "secure") CSDefFlags |= CI_SECURE;
- else if (option == "secureops") CSDefFlags |= CI_SECUREOPS;
- else if (option == "securefounder") CSDefFlags |= CI_SECUREFOUNDER;
- else if (option == "signkick") CSDefFlags |= CI_SIGNKICK;
- else if (option == "signkicklevel") CSDefFlags |= CI_SIGNKICK_LEVEL;
- else if (option == "opnotice") CSDefFlags |= CI_OPNOTICE;
- else if (option == "xop") CSDefFlags |= CI_XOP;
- else if (option == "peace") CSDefFlags |= CI_PEACE;
+ if (option == "keeptopic") CSDefFlags.SetFlag(CI_KEEPTOPIC);
+ else if (option == "topiclock") CSDefFlags.SetFlag(CI_TOPICLOCK);
+ else if (option == "private") CSDefFlags.SetFlag(CI_PRIVATE);
+ else if (option == "restricted") CSDefFlags.SetFlag(CI_RESTRICTED);
+ else if (option == "secure") CSDefFlags.SetFlag(CI_SECURE);
+ else if (option == "secureops") CSDefFlags.SetFlag(CI_SECUREOPS);
+ else if (option == "securefounder") CSDefFlags.SetFlag(CI_SECUREFOUNDER);
+ else if (option == "signkick") CSDefFlags.SetFlag(CI_SIGNKICK);
+ else if (option == "signkicklevel") CSDefFlags.SetFlag(CI_SIGNKICK_LEVEL);
+ else if (option == "opnotice") CSDefFlags.SetFlag(CI_OPNOTICE);
+ else if (option == "xop") CSDefFlags.SetFlag(CI_XOP);
+ else if (option == "peace") CSDefFlags.SetFlag(CI_PEACE);
}
}
- BSDefFlags = 0;
if (!BSDefaults.empty()) {
spacesepstream options(BSDefaults);
std::string option;
while (options.GetToken(option)) {
- if (option == "dontkickops") BSDefFlags |= BS_DONTKICKOPS;
- else if (option == "dontkickvoices") BSDefFlags |= BS_DONTKICKVOICES;
- else if (option == "greet") BSDefFlags |= BS_GREET;
- else if (option == "fantasy") BSDefFlags |= BS_FANTASY;
- else if (option == "symbiosis") BSDefFlags |= BS_SYMBIOSIS;
+ if (option == "dontkickops") BSDefFlags.SetFlag(BS_DONTKICKOPS);
+ else if (option == "dontkickvoices") BSDefFlags.SetFlag(BS_DONTKICKVOICES);
+ else if (option == "greet") BSDefFlags.SetFlag(BS_GREET);
+ else if (option == "fantasy") BSDefFlags.SetFlag(BS_FANTASY);
+ else if (option == "symbiosis") BSDefFlags.SetFlag(BS_SYMBIOSIS);
}
}
diff --git a/src/core/bs_assign.c b/src/core/bs_assign.c
index 1ca280c4c..e6d619095 100644
--- a/src/core/bs_assign.c
+++ b/src/core/bs_assign.c
@@ -43,13 +43,13 @@ class CommandBSAssign : public Command
ci = cs_findchan(chan);
- if ((ci->botflags & BS_NOBOT) || (!check_access(u, ci, CA_ASSIGN) && !u->nc->HasPriv("botserv/administration")))
+ if (ci->botflags.HasFlag(BS_NOBOT) || (!check_access(u, ci, CA_ASSIGN) && !u->nc->HasPriv("botserv/administration")))
{
notice_lang(s_BotServ, u, ACCESS_DENIED);
return MOD_CONT;
}
- if (bi->flags & BI_PRIVATE && !u->nc->HasCommand("botserv/assign/private"))
+ if (bi->HasFlag(BI_PRIVATE) && !u->nc->HasCommand("botserv/assign/private"))
{
notice_lang(s_BotServ, u, ACCESS_DENIED);
return MOD_CONT;
diff --git a/src/core/bs_badwords.c b/src/core/bs_badwords.c
index 8c07fb36a..405dbf2a6 100644
--- a/src/core/bs_badwords.c
+++ b/src/core/bs_badwords.c
@@ -57,7 +57,7 @@ class CommandBSBadwords : public Command
CommandReturn DoAdd(User *u, ChannelInfo *ci, const char *word)
{
char *opt, *pos;
- int type = BW_ANY;
+ BadWordType type = BW_ANY;
unsigned i = 0;
BadWord *bw;
diff --git a/src/core/bs_botlist.c b/src/core/bs_botlist.c
index 79902a752..c29ce19ee 100644
--- a/src/core/bs_botlist.c
+++ b/src/core/bs_botlist.c
@@ -34,7 +34,7 @@ class CommandBSBotList : public Command
for (i = 0; i < 256; i++) {
for (bi = botlists[i]; bi; bi = bi->next) {
- if (!(bi->flags & BI_PRIVATE)) {
+ if (!(bi->HasFlag(BI_PRIVATE))) {
if (!count)
notice_lang(s_BotServ, u, BOT_BOTLIST_HEADER);
count++;
@@ -48,7 +48,7 @@ class CommandBSBotList : public Command
for (i = 0; i < 256; i++) {
for (bi = botlists[i]; bi; bi = bi->next) {
- if (bi->flags & BI_PRIVATE) {
+ if (bi->HasFlag(BI_PRIVATE)) {
u->SendMessage(s_BotServ, " %-15s (%s@%s)", bi->nick, bi->user, bi->host);
count++;
}
diff --git a/src/core/bs_info.c b/src/core/bs_info.c
index 64d999768..0ea8a5791 100644
--- a/src/core/bs_info.c
+++ b/src/core/bs_info.c
@@ -72,11 +72,7 @@ class CommandBSInfo : public Command
tm = localtime(&bi->created);
strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm);
notice_lang(s_BotServ, u, BOT_INFO_BOT_CREATED, buf);
- notice_lang(s_BotServ, u, BOT_INFO_BOT_OPTIONS,
- getstring(u,
- (bi->
- flags & BI_PRIVATE) ? BOT_INFO_OPT_PRIVATE :
- BOT_INFO_OPT_NONE));
+ notice_lang(s_BotServ, u, BOT_INFO_BOT_OPTIONS, getstring(u, (bi->HasFlag(BI_PRIVATE) ? BOT_INFO_OPT_PRIVATE : BOT_INFO_OPT_NONE)));
notice_lang(s_BotServ, u, BOT_INFO_BOT_USAGE, bi->chancount);
if (u->nc->HasPriv("botserv/administration"))
@@ -96,7 +92,7 @@ class CommandBSInfo : public Command
else
notice_lang(s_BotServ, u, BOT_INFO_CHAN_BOT_NONE);
- if (ci->botflags & BS_KICK_BADWORDS) {
+ if (ci->botflags.HasFlag(BS_KICK_BADWORDS)) {
if (ci->ttb[TTB_BADWORDS])
notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS_BAN,
getstring(u, BOT_INFO_ACTIVE),
@@ -107,7 +103,7 @@ class CommandBSInfo : public Command
} else
notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS,
getstring(u, BOT_INFO_INACTIVE));
- if (ci->botflags & BS_KICK_BOLDS) {
+ if (ci->botflags.HasFlag(BS_KICK_BOLDS)) {
if (ci->ttb[TTB_BOLDS])
notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS_BAN,
getstring(u, BOT_INFO_ACTIVE),
@@ -118,7 +114,7 @@ class CommandBSInfo : public Command
} else
notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS,
getstring(u, BOT_INFO_INACTIVE));
- if (ci->botflags & BS_KICK_CAPS) {
+ if (ci->botflags.HasFlag(BS_KICK_CAPS)) {
if (ci->ttb[TTB_CAPS])
notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_BAN,
getstring(u, BOT_INFO_ACTIVE),
@@ -131,7 +127,7 @@ class CommandBSInfo : public Command
} else
notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_OFF,
getstring(u, BOT_INFO_INACTIVE));
- if (ci->botflags & BS_KICK_COLORS) {
+ if (ci->botflags.HasFlag(BS_KICK_COLORS)) {
if (ci->ttb[TTB_COLORS])
notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS_BAN,
getstring(u, BOT_INFO_ACTIVE),
@@ -142,7 +138,7 @@ class CommandBSInfo : public Command
} else
notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS,
getstring(u, BOT_INFO_INACTIVE));
- if (ci->botflags & BS_KICK_FLOOD) {
+ if (ci->botflags.HasFlag(BS_KICK_FLOOD)) {
if (ci->ttb[TTB_FLOOD])
notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_BAN,
getstring(u, BOT_INFO_ACTIVE),
@@ -155,7 +151,7 @@ class CommandBSInfo : public Command
} else
notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_OFF,
getstring(u, BOT_INFO_INACTIVE));
- if (ci->botflags & BS_KICK_REPEAT) {
+ if (ci->botflags.HasFlag(BS_KICK_REPEAT)) {
if (ci->ttb[TTB_REPEAT])
notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_BAN,
getstring(u, BOT_INFO_ACTIVE),
@@ -167,7 +163,7 @@ class CommandBSInfo : public Command
} else
notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_OFF,
getstring(u, BOT_INFO_INACTIVE));
- if (ci->botflags & BS_KICK_REVERSES) {
+ if (ci->botflags.HasFlag(BS_KICK_REVERSES)) {
if (ci->ttb[TTB_REVERSES])
notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES_BAN,
getstring(u, BOT_INFO_ACTIVE),
@@ -178,7 +174,7 @@ class CommandBSInfo : public Command
} else
notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES,
getstring(u, BOT_INFO_INACTIVE));
- if (ci->botflags & BS_KICK_UNDERLINES) {
+ if (ci->botflags.HasFlag(BS_KICK_UNDERLINES)) {
if (ci->ttb[TTB_UNDERLINES])
notice_lang(s_BotServ, u,
BOT_INFO_CHAN_KICK_UNDERLINES_BAN,
@@ -193,36 +189,36 @@ class CommandBSInfo : public Command
end = buf;
*end = 0;
- if (ci->botflags & BS_DONTKICKOPS) {
+ if (ci->botflags.HasFlag(BS_DONTKICKOPS)) {
end += snprintf(end, sizeof(buf) - (end - buf), "%s",
getstring(u, BOT_INFO_OPT_DONTKICKOPS));
need_comma = 1;
}
- if (ci->botflags & BS_DONTKICKVOICES) {
+ if (ci->botflags.HasFlag(BS_DONTKICKVOICES)) {
end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
need_comma ? commastr : "",
getstring(u, BOT_INFO_OPT_DONTKICKVOICES));
need_comma = 1;
}
- if (ci->botflags & BS_FANTASY) {
+ if (ci->botflags.HasFlag(BS_FANTASY)) {
end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
need_comma ? commastr : "",
getstring(u, BOT_INFO_OPT_FANTASY));
need_comma = 1;
}
- if (ci->botflags & BS_GREET) {
+ if (ci->botflags.HasFlag(BS_GREET)) {
end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
need_comma ? commastr : "",
getstring(u, BOT_INFO_OPT_GREET));
need_comma = 1;
}
- if (ci->botflags & BS_NOBOT) {
+ if (ci->botflags.HasFlag(BS_NOBOT)) {
end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
need_comma ? commastr : "",
getstring(u, BOT_INFO_OPT_NOBOT));
need_comma = 1;
}
- if (ci->botflags & BS_SYMBIOSIS) {
+ if (ci->botflags.HasFlag(BS_SYMBIOSIS)) {
end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
need_comma ? commastr : "",
getstring(u, BOT_INFO_OPT_SYMBIOSIS));
diff --git a/src/core/bs_kick.c b/src/core/bs_kick.c
index bd03ff006..0ce210019 100644
--- a/src/core/bs_kick.c
+++ b/src/core/bs_kick.c
@@ -65,14 +65,14 @@ class CommandBSKick : public Command
} else {
ci->ttb[TTB_BADWORDS] = 0;
}
- ci->botflags |= BS_KICK_BADWORDS;
+ ci->botflags.SetFlag(BS_KICK_BADWORDS);
if (ci->ttb[TTB_BADWORDS])
notice_lang(s_BotServ, u, BOT_KICK_BADWORDS_ON_BAN,
ci->ttb[TTB_BADWORDS]);
else
notice_lang(s_BotServ, u, BOT_KICK_BADWORDS_ON);
} else {
- ci->botflags &= ~BS_KICK_BADWORDS;
+ ci->botflags.UnsetFlag(BS_KICK_BADWORDS);
notice_lang(s_BotServ, u, BOT_KICK_BADWORDS_OFF);
}
} else if (option == "BOLDS") {
@@ -91,14 +91,14 @@ class CommandBSKick : public Command
}
} else
ci->ttb[TTB_BOLDS] = 0;
- ci->botflags |= BS_KICK_BOLDS;
+ ci->botflags.SetFlag(BS_KICK_BOLDS);
if (ci->ttb[TTB_BOLDS])
notice_lang(s_BotServ, u, BOT_KICK_BOLDS_ON_BAN,
ci->ttb[TTB_BOLDS]);
else
notice_lang(s_BotServ, u, BOT_KICK_BOLDS_ON);
} else {
- ci->botflags &= ~BS_KICK_BOLDS;
+ ci->botflags.UnsetFlag(BS_KICK_BOLDS);
notice_lang(s_BotServ, u, BOT_KICK_BOLDS_OFF);
}
} else if (option == "CAPS") {
@@ -135,7 +135,7 @@ class CommandBSKick : public Command
if (ci->capspercent < 1 || ci->capspercent > 100)
ci->capspercent = 25;
- ci->botflags |= BS_KICK_CAPS;
+ ci->botflags.SetFlag(BS_KICK_CAPS);
if (ci->ttb[TTB_CAPS])
notice_lang(s_BotServ, u, BOT_KICK_CAPS_ON_BAN,
ci->capsmin, ci->capspercent,
@@ -144,7 +144,7 @@ class CommandBSKick : public Command
notice_lang(s_BotServ, u, BOT_KICK_CAPS_ON,
ci->capsmin, ci->capspercent);
} else {
- ci->botflags &= ~BS_KICK_CAPS;
+ ci->botflags.UnsetFlag(BS_KICK_CAPS);
notice_lang(s_BotServ, u, BOT_KICK_CAPS_OFF);
}
} else if (option == "COLORS") {
@@ -163,14 +163,14 @@ class CommandBSKick : public Command
}
} else
ci->ttb[TTB_COLORS] = 0;
- ci->botflags |= BS_KICK_COLORS;
+ ci->botflags.SetFlag(BS_KICK_COLORS);
if (ci->ttb[TTB_COLORS])
notice_lang(s_BotServ, u, BOT_KICK_COLORS_ON_BAN,
ci->ttb[TTB_COLORS]);
else
notice_lang(s_BotServ, u, BOT_KICK_COLORS_ON);
} else {
- ci->botflags &= ~BS_KICK_COLORS;
+ ci->botflags.UnsetFlag(BS_KICK_COLORS);
notice_lang(s_BotServ, u, BOT_KICK_COLORS_OFF);
}
} else if (option == "FLOOD") {
@@ -207,7 +207,7 @@ class CommandBSKick : public Command
if (ci->floodsecs < 1 || ci->floodsecs > BSKeepData)
ci->floodsecs = 10;
- ci->botflags |= BS_KICK_FLOOD;
+ ci->botflags.SetFlag(BS_KICK_FLOOD);
if (ci->ttb[TTB_FLOOD])
notice_lang(s_BotServ, u, BOT_KICK_FLOOD_ON_BAN,
ci->floodlines, ci->floodsecs,
@@ -216,7 +216,7 @@ class CommandBSKick : public Command
notice_lang(s_BotServ, u, BOT_KICK_FLOOD_ON,
ci->floodlines, ci->floodsecs);
} else {
- ci->botflags &= ~BS_KICK_FLOOD;
+ ci->botflags.UnsetFlag(BS_KICK_FLOOD);
notice_lang(s_BotServ, u, BOT_KICK_FLOOD_OFF);
}
} else if (option == "REPEAT") {
@@ -245,7 +245,7 @@ class CommandBSKick : public Command
if (ci->repeattimes < 2)
ci->repeattimes = 3;
- ci->botflags |= BS_KICK_REPEAT;
+ ci->botflags.SetFlag(BS_KICK_REPEAT);
if (ci->ttb[TTB_REPEAT])
notice_lang(s_BotServ, u, BOT_KICK_REPEAT_ON_BAN,
ci->repeattimes, ci->ttb[TTB_REPEAT]);
@@ -253,7 +253,7 @@ class CommandBSKick : public Command
notice_lang(s_BotServ, u, BOT_KICK_REPEAT_ON,
ci->repeattimes);
} else {
- ci->botflags &= ~BS_KICK_REPEAT;
+ ci->botflags.UnsetFlag(BS_KICK_REPEAT);
notice_lang(s_BotServ, u, BOT_KICK_REPEAT_OFF);
}
} else if (option == "REVERSES") {
@@ -273,14 +273,14 @@ class CommandBSKick : public Command
}
} else
ci->ttb[TTB_REVERSES] = 0;
- ci->botflags |= BS_KICK_REVERSES;
+ ci->botflags.SetFlag(BS_KICK_REVERSES);
if (ci->ttb[TTB_REVERSES])
notice_lang(s_BotServ, u, BOT_KICK_REVERSES_ON_BAN,
ci->ttb[TTB_REVERSES]);
else
notice_lang(s_BotServ, u, BOT_KICK_REVERSES_ON);
} else {
- ci->botflags &= ~BS_KICK_REVERSES;
+ ci->botflags.UnsetFlag(BS_KICK_REVERSES);
notice_lang(s_BotServ, u, BOT_KICK_REVERSES_OFF);
}
} else if (option == "UNDERLINES") {
@@ -300,14 +300,14 @@ class CommandBSKick : public Command
}
} else
ci->ttb[TTB_UNDERLINES] = 0;
- ci->botflags |= BS_KICK_UNDERLINES;
+ ci->botflags.SetFlag(BS_KICK_UNDERLINES);
if (ci->ttb[TTB_UNDERLINES])
notice_lang(s_BotServ, u, BOT_KICK_UNDERLINES_ON_BAN,
ci->ttb[TTB_UNDERLINES]);
else
notice_lang(s_BotServ, u, BOT_KICK_UNDERLINES_ON);
} else {
- ci->botflags &= ~BS_KICK_UNDERLINES;
+ ci->botflags.UnsetFlag(BS_KICK_UNDERLINES);
notice_lang(s_BotServ, u, BOT_KICK_UNDERLINES_OFF);
}
} else
diff --git a/src/core/bs_set.c b/src/core/bs_set.c
index 7c5366003..d5d40abd5 100644
--- a/src/core/bs_set.c
+++ b/src/core/bs_set.c
@@ -48,12 +48,12 @@ class CommandBSSet : public Command
if (value == "ON")
{
- bi->flags |= BI_PRIVATE;
+ bi->SetFlag(BI_PRIVATE);
notice_lang(s_BotServ, u, BOT_SET_PRIVATE_ON, bi->nick);
}
else if (value == "OFF")
{
- bi->flags &= ~BI_PRIVATE;
+ bi->UnsetFlag(BI_PRIVATE);
notice_lang(s_BotServ, u, BOT_SET_PRIVATE_OFF, bi->nick);
}
else
@@ -68,11 +68,11 @@ class CommandBSSet : public Command
else {
if (option == "DONTKICKOPS") {
if (value == "ON") {
- ci->botflags |= BS_DONTKICKOPS;
+ ci->botflags.SetFlag(BS_DONTKICKOPS);
notice_lang(s_BotServ, u, BOT_SET_DONTKICKOPS_ON,
ci->name);
} else if (value == "OFF") {
- ci->botflags &= ~BS_DONTKICKOPS;
+ ci->botflags.UnsetFlag(BS_DONTKICKOPS);
notice_lang(s_BotServ, u, BOT_SET_DONTKICKOPS_OFF,
ci->name);
} else {
@@ -81,11 +81,11 @@ class CommandBSSet : public Command
}
} else if (option == "DONTKICKVOICES") {
if (value == "ON") {
- ci->botflags |= BS_DONTKICKVOICES;
+ ci->botflags.SetFlag(BS_DONTKICKVOICES);
notice_lang(s_BotServ, u, BOT_SET_DONTKICKVOICES_ON,
ci->name);
} else if (value == "OFF") {
- ci->botflags &= ~BS_DONTKICKVOICES;
+ ci->botflags.UnsetFlag(BS_DONTKICKVOICES);
notice_lang(s_BotServ, u, BOT_SET_DONTKICKVOICES_OFF,
ci->name);
} else {
@@ -94,10 +94,10 @@ class CommandBSSet : public Command
}
} else if (option == "FANTASY") {
if (value == "ON") {
- ci->botflags |= BS_FANTASY;
+ ci->botflags.SetFlag(BS_FANTASY);
notice_lang(s_BotServ, u, BOT_SET_FANTASY_ON, ci->name);
} else if (value == "OFF") {
- ci->botflags &= ~BS_FANTASY;
+ ci->botflags.UnsetFlag(BS_FANTASY);
notice_lang(s_BotServ, u, BOT_SET_FANTASY_OFF, ci->name);
} else {
syntax_error(s_BotServ, u, "SET FANTASY",
@@ -105,10 +105,10 @@ class CommandBSSet : public Command
}
} else if (option == "GREET") {
if (value == "ON") {
- ci->botflags |= BS_GREET;
+ ci->botflags.SetFlag(BS_GREET);
notice_lang(s_BotServ, u, BOT_SET_GREET_ON, ci->name);
} else if (value == "OFF") {
- ci->botflags &= ~BS_GREET;
+ ci->botflags.UnsetFlag(BS_GREET);
notice_lang(s_BotServ, u, BOT_SET_GREET_OFF, ci->name);
} else {
syntax_error(s_BotServ, u, "SET GREET",
@@ -116,12 +116,12 @@ class CommandBSSet : public Command
}
} else if (u->nc->HasCommand("botserv/set/nobot") && option == "NOBOT") {
if (value == "ON") {
- ci->botflags |= BS_NOBOT;
+ ci->botflags.SetFlag(BS_NOBOT);
if (ci->bi)
ci->bi->UnAssign(u, ci);
notice_lang(s_BotServ, u, BOT_SET_NOBOT_ON, ci->name);
} else if (value == "OFF") {
- ci->botflags &= ~BS_NOBOT;
+ ci->botflags.UnsetFlag(BS_NOBOT);
notice_lang(s_BotServ, u, BOT_SET_NOBOT_OFF, ci->name);
} else {
syntax_error(s_BotServ, u, "SET NOBOT",
@@ -129,10 +129,10 @@ class CommandBSSet : public Command
}
} else if (option == "SYMBIOSIS") {
if (value == "ON") {
- ci->botflags |= BS_SYMBIOSIS;
+ ci->botflags.SetFlag(BS_SYMBIOSIS);
notice_lang(s_BotServ, u, BOT_SET_SYMBIOSIS_ON, ci->name);
} else if (value == "OFF") {
- ci->botflags &= ~BS_SYMBIOSIS;
+ ci->botflags.UnsetFlag(BS_SYMBIOSIS);
notice_lang(s_BotServ, u, BOT_SET_SYMBIOSIS_OFF, ci->name);
} else {
syntax_error(s_BotServ, u, "SET SYMBIOSIS",
diff --git a/src/core/cs_access.c b/src/core/cs_access.c
index cd8ccb0cf..11fc323e7 100644
--- a/src/core/cs_access.c
+++ b/src/core/cs_access.c
@@ -61,7 +61,7 @@ static int access_list(User * u, int index, ChannelInfo * ci, int *sent_header)
*sent_header = 1;
}
- if (ci->flags & CI_XOP)
+ if (ci->HasFlag(CI_XOP))
{
xop = get_xop_level(access->level);
notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_XOP_FORMAT, index + 1, xop, access->nc->display);
@@ -107,7 +107,7 @@ static int access_view(User *u, int index, ChannelInfo *ci, int *sent_header)
strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_DATE_TIME_FORMAT, &tm);
}
- if (ci->flags & CI_XOP)
+ if (ci->HasFlag(CI_XOP))
{
xop = get_xop_level(access->level);
notice_lang(s_ChanServ, u, CHAN_ACCESS_VIEW_XOP_FORMAT, index + 1, xop, access->nc->display, access->creator.c_str(), timebuf);
@@ -155,7 +155,7 @@ class CommandCSAccess : public Command
if (is_list || cmd == "CLEAR" ? 0 : (cmd == "DEL" ? (!nick || s) : !s))
this->OnSyntaxError(u);
/* We still allow LIST in xOP mode, but not others */
- else if ((ci->flags & CI_XOP) && !is_list)
+ else if ((ci->HasFlag(CI_XOP)) && !is_list)
{
if (ModeManager::FindChannelModeByName(CMODE_HALFOP))
notice_lang(s_ChanServ, u, CHAN_ACCESS_XOP_HOP, s_ChanServ);
@@ -202,7 +202,7 @@ class CommandCSAccess : public Command
notice_lang(s_ChanServ, u, CHAN_ACCESS_NICKS_ONLY);
return MOD_CONT;
}
- if (na->status & NS_FORBIDDEN)
+ if (na->HasFlag(NS_FORBIDDEN));
{
notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, nick);
return MOD_CONT;
@@ -446,7 +446,7 @@ class CommandCSLevels : public Command
*/
if (cmd == "SET" ? !s : (cmd.substr(0, 3) == "DIS" ? (!what || s) : !!what))
this->OnSyntaxError(u);
- else if (ci->flags & CI_XOP)
+ else if (ci->HasFlag(CI_XOP))
notice_lang(s_ChanServ, u, CHAN_LEVELS_XOP);
else if (!IsFounder(u, ci) && !u->nc->HasPriv("chanserv/access/modify"))
notice_lang(s_ChanServ, u, ACCESS_DENIED);
diff --git a/src/core/cs_akick.c b/src/core/cs_akick.c
index c93c3a0aa..078cd0e2e 100644
--- a/src/core/cs_akick.c
+++ b/src/core/cs_akick.c
@@ -65,7 +65,7 @@ int akick_list(User * u, int index, ChannelInfo * ci, int *sent_header)
{
AutoKick *akick = ci->GetAkick(index);
- if (!(akick->flags & AK_USED))
+ if (!(akick->HasFlag(AK_USED)))
return 0;
if (!*sent_header) {
notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_HEADER, ci->name);
@@ -73,7 +73,7 @@ int akick_list(User * u, int index, ChannelInfo * ci, int *sent_header)
}
notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_FORMAT, index + 1,
- ((akick->flags & AK_ISNICK) ? akick->nc->
+ ((akick->HasFlag(AK_ISNICK)) ? akick->nc->
display : akick->mask.c_str()),
(!akick->reason.empty() ? akick->
reason.c_str() : getstring(u, NO_REASON)));
@@ -95,7 +95,7 @@ int akick_view(User * u, int index, ChannelInfo * ci, int *sent_header)
char timebuf[64];
struct tm tm;
- if (!(akick->flags & AK_USED))
+ if (!(akick->HasFlag(AK_USED)))
return 0;
if (!*sent_header) {
notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_HEADER, ci->name);
@@ -110,17 +110,10 @@ int akick_view(User * u, int index, ChannelInfo * ci, int *sent_header)
snprintf(timebuf, sizeof(timebuf), "%s", getstring(u, UNKNOWN));
}
- notice_lang(s_ChanServ, u,
- ((akick->
- flags & AK_STUCK) ? CHAN_AKICK_VIEW_FORMAT_STUCK :
- CHAN_AKICK_VIEW_FORMAT), index + 1,
- ((akick->flags & AK_ISNICK) ? akick->nc->
- display : akick->mask.c_str()),
- !akick->creator.empty() ? akick->creator.c_str() : getstring(u,
- UNKNOWN),
- timebuf,
- (!akick->reason.empty() ? akick->
- reason.c_str() : getstring(u, NO_REASON)));
+ notice_lang(s_ChanServ, u, (akick->HasFlag(AK_STUCK) ? CHAN_AKICK_VIEW_FORMAT_STUCK : CHAN_AKICK_VIEW_FORMAT), index + 1,
+ ((akick->HasFlag(AK_ISNICK)) ? akick->nc->display : akick->mask.c_str()),
+ !akick->creator.empty() ? akick->creator.c_str() : getstring(u, UNKNOWN), timebuf,
+ (!akick->reason.empty() ? akick->reason.c_str() : getstring(u, NO_REASON)));
return 1;
}
@@ -167,7 +160,7 @@ class CommandCSAKick : public Command
}
else
{
- if (na->status & NS_FORBIDDEN)
+ if (na->HasFlag(NS_FORBIDDEN))
{
notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, mask.c_str());
return;
@@ -188,7 +181,7 @@ class CommandCSAKick : public Command
/* Check whether target nick has equal/higher access
* or whether the mask matches a user with higher/equal access - Viper */
- if ((ci->flags & CI_PEACE) && nc)
+ if ((ci->HasFlag(CI_PEACE)) && nc)
{
if ((nc == ci->founder) || (get_access_nc(nc, ci) >= get_access(u, ci)))
{
@@ -196,7 +189,7 @@ class CommandCSAKick : public Command
return;
}
}
- else if ((ci->flags & CI_PEACE))
+ else if ((ci->HasFlag(CI_PEACE)))
{
char buf[BUFSIZE];
/* Match against all currently online users with equal or
@@ -223,7 +216,7 @@ class CommandCSAKick : public Command
{
for (NickAlias *na2 = nalists[i]; na2; na2 = na2->next)
{
- if (na2->status & NS_FORBIDDEN)
+ if (na2->HasFlag(NS_FORBIDDEN))
continue;
if (na2->nc && ((na2->nc == ci->founder) || (get_access_nc(na2->nc, ci) >= get_access(u, ci))))
@@ -242,11 +235,11 @@ class CommandCSAKick : public Command
for (unsigned j = 0; j < ci->GetAkickCount(); ++j)
{
akick = ci->GetAkick(j);
- if (!(akick->flags & AK_USED))
+ if (!(akick->HasFlag(AK_USED)))
continue;
- if ((akick->flags & AK_ISNICK) ? akick->nc == nc : akick->mask == mask)
+ if ((akick->HasFlag(AK_ISNICK)) ? akick->nc == nc : akick->mask == mask)
{
- notice_lang(s_ChanServ, u, CHAN_AKICK_ALREADY_EXISTS, (akick->flags & AK_ISNICK) ? akick->nc->display : akick->mask.c_str(), ci->name);
+ notice_lang(s_ChanServ, u, CHAN_AKICK_ALREADY_EXISTS, (akick->HasFlag(AK_ISNICK)) ? akick->nc->display : akick->mask.c_str(), ci->name);
return;
}
}
@@ -291,7 +284,7 @@ class CommandCSAKick : public Command
{
akick = ci->GetAkick(i);
- if (!(akick->flags & AK_USED) || (akick->flags & AK_ISNICK))
+ if (!akick->HasFlag(AK_USED) || akick->HasFlag(AK_ISNICK))
continue;
if (akick->mask == mask)
break;
@@ -303,7 +296,7 @@ class CommandCSAKick : public Command
return;
}
- akick->flags |= AK_STUCK;
+ akick->SetFlag(AK_STUCK);
notice_lang(s_ChanServ, u, CHAN_AKICK_STUCK, akick->mask.c_str(), ci->name);
if (ci->c)
@@ -331,7 +324,7 @@ class CommandCSAKick : public Command
{
akick = ci->GetAkick(i);
- if (!(akick->flags & AK_USED) || (akick->flags & AK_ISNICK))
+ if (!akick->HasFlag(AK_USED) || akick->HasFlag(AK_ISNICK))
continue;
if (akick->mask == mask)
break;
@@ -343,7 +336,7 @@ class CommandCSAKick : public Command
return;
}
- akick->flags &= ~AK_STUCK;
+ akick->UnsetFlag(AK_STUCK);
notice_lang(s_ChanServ, u, CHAN_AKICK_UNSTUCK, akick->mask.c_str(), ci->name);
}
@@ -387,10 +380,10 @@ class CommandCSAKick : public Command
{
akick = ci->GetAkick(i);
- if (!(akick->flags & AK_USED))
+ if (!(akick->HasFlag(AK_USED)))
continue;
- if (((akick->flags & AK_ISNICK) && akick->nc == nc)
- || (!(akick->flags & AK_ISNICK)
+ if (((akick->HasFlag(AK_ISNICK)) && akick->nc == nc)
+ || (!(akick->HasFlag(AK_ISNICK))
&& akick->mask == mask))
break;
}
@@ -428,13 +421,13 @@ class CommandCSAKick : public Command
{
akick = ci->GetAkick(i);
- if (!(akick->flags & AK_USED))
+ if (!(akick->HasFlag(AK_USED)))
continue;
if (!mask.empty())
{
- if (!(akick->flags & AK_ISNICK) && !Anope::Match(akick->mask.c_str(), mask.c_str(), false))
+ if (!(akick->HasFlag(AK_ISNICK)) && !Anope::Match(akick->mask.c_str(), mask.c_str(), false))
continue;
- if ((akick->flags & AK_ISNICK) && !Anope::Match(akick->nc->display, mask.c_str(), false))
+ if ((akick->HasFlag(AK_ISNICK)) && !Anope::Match(akick->nc->display, mask.c_str(), false))
continue;
}
akick_list(u, i, ci, &sent_header);
@@ -467,13 +460,13 @@ class CommandCSAKick : public Command
{
akick = ci->GetAkick(i);
- if (!(akick->flags & AK_USED))
+ if (!(akick->HasFlag(AK_USED)))
continue;
if (!mask.empty())
{
- if (!(akick->flags & AK_ISNICK) && !Anope::Match(akick->mask.c_str(), mask.c_str(), false))
+ if (!(akick->HasFlag(AK_ISNICK)) && !Anope::Match(akick->mask.c_str(), mask.c_str(), false))
continue;
- if ((akick->flags & AK_ISNICK) && !Anope::Match(akick->nc->display, mask.c_str(), false))
+ if ((akick->HasFlag(AK_ISNICK)) && !Anope::Match(akick->nc->display, mask.c_str(), false))
continue;
}
akick_view(u, i, ci, &sent_header);
diff --git a/src/core/cs_ban.c b/src/core/cs_ban.c
index 9901479ae..b6873ba89 100644
--- a/src/core/cs_ban.c
+++ b/src/core/cs_ban.c
@@ -55,7 +55,7 @@ class CommandCSBan : public Command
} else if (!is_same ? !check_access(u, ci, CA_BAN) :
!check_access(u, ci, CA_BANME)) {
notice_lang(s_ChanServ, u, ACCESS_DENIED);
- } else if (!is_same && (ci->flags & CI_PEACE)
+ } else if (!is_same && (ci->HasFlag(CI_PEACE))
&& (get_access(u2, ci) >= get_access(u, ci))) {
notice_lang(s_ChanServ, u, ACCESS_DENIED);
/*
@@ -80,8 +80,8 @@ class CommandCSBan : public Command
if (!is_on_chan(c, u2))
return MOD_CONT;
- if ((ci->flags & CI_SIGNKICK)
- || ((ci->flags & CI_SIGNKICK_LEVEL)
+ if ((ci->HasFlag(CI_SIGNKICK))
+ || ((ci->HasFlag(CI_SIGNKICK_LEVEL))
&& !check_access(u, ci, CA_SIGNKICK)))
ircdproto->SendKick(whosends(ci), ci->name, target, "%s (%s)",
reason, u->nick);
diff --git a/src/core/cs_drop.c b/src/core/cs_drop.c
index 3a5ca45a7..74d799af8 100644
--- a/src/core/cs_drop.c
+++ b/src/core/cs_drop.c
@@ -37,19 +37,19 @@ class CommandCSDrop : public Command
ci = cs_findchan(chan);
- if ((ci->flags & CI_FORBIDDEN) && !u->nc->HasCommand("chanserv/drop"))
+ if ((ci->HasFlag(CI_FORBIDDEN)) && !u->nc->HasCommand("chanserv/drop"))
{
notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
return MOD_CONT;
}
- if ((ci->flags & CI_SUSPENDED) && !u->nc->HasCommand("chanserv/drop"))
+ if ((ci->HasFlag(CI_SUSPENDED)) && !u->nc->HasCommand("chanserv/drop"))
{
notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
return MOD_CONT;
}
- if ((ci->flags & CI_SECUREFOUNDER ? !IsRealFounder(u, ci) : !IsFounder(u, ci)) && !u->nc->HasCommand("chanserv/drop"))
+ if ((ci->HasFlag(CI_SECUREFOUNDER) ? !IsRealFounder(u, ci) : !IsFounder(u, ci)) && !u->nc->HasCommand("chanserv/drop"))
{
notice_lang(s_ChanServ, u, ACCESS_DENIED);
return MOD_CONT;
@@ -66,7 +66,7 @@ class CommandCSDrop : public Command
}
}
- if (ircd->chansqline && (ci->flags & CI_FORBIDDEN))
+ if (ircd->chansqline && (ci->HasFlag(CI_FORBIDDEN)))
{
ircdproto->SendSQLineDel(ci->name);
}
@@ -81,7 +81,7 @@ class CommandCSDrop : public Command
* drop the channel before issuing the wallops.
*/
if (WallDrop) {
- if ((level < ACCESS_FOUNDER) || (!IsRealFounder(u, ci) && ci->flags & CI_SECUREFOUNDER))
+ if ((level < ACCESS_FOUNDER) || (!IsRealFounder(u, ci) && ci->HasFlag(CI_SECUREFOUNDER)))
ircdproto->SendGlobops(s_ChanServ, "\2%s\2 used DROP on channel \2%s\2", u->nick, chan);
}
diff --git a/src/core/cs_forbid.c b/src/core/cs_forbid.c
index edc0ef37d..ccfc1f5bd 100644
--- a/src/core/cs_forbid.c
+++ b/src/core/cs_forbid.c
@@ -60,7 +60,7 @@ class CommandCSForbid : public Command
return MOD_CONT;
}
- ci->flags |= CI_FORBIDDEN;
+ ci->SetFlag(CI_FORBIDDEN);
ci->forbidby = sstrdup(u->nick);
if (reason)
ci->forbidreason = sstrdup(reason);
diff --git a/src/core/cs_info.c b/src/core/cs_info.c
index 8a13b73a2..5271764b9 100644
--- a/src/core/cs_info.c
+++ b/src/core/cs_info.c
@@ -16,10 +16,10 @@
#include "module.h"
class CommandCSInfo : public Command
-{ // cannot be const, as it is modified.
- void CheckOptStr(std::string &buf, int opt, const std::string &str, ChannelInfo *ci, NickCore *nc)
+{
+ void CheckOptStr(std::string &buf, ChannelInfoFlag opt, const std::string &str, ChannelInfo *ci, NickCore *nc)
{
- if (ci->flags & opt)
+ if (ci->HasFlag(opt))
{
const char *commastr = getstring(nc, COMMA_SPACE);
if (!buf.empty())
@@ -51,7 +51,7 @@ class CommandCSInfo : public Command
ci = cs_findchan(chan);
- if (ci->flags & CI_FORBIDDEN)
+ if (ci->HasFlag(CI_FORBIDDEN))
{
if (is_oper(u) && ci->forbidby)
notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN_OPER, chan,
@@ -104,23 +104,26 @@ class CommandCSInfo : public Command
notice_lang(s_ChanServ, u, CHAN_INFO_BANTYPE, ci->bantype);
std::string optbuf;
- CheckOptStr(optbuf, CI_KEEPTOPIC, getstring(u, CHAN_INFO_OPT_KEEPTOPIC), ci, u->nc);
- CheckOptStr(optbuf, CI_OPNOTICE, getstring(u, CHAN_INFO_OPT_OPNOTICE), ci, u->nc);
- CheckOptStr(optbuf, CI_PEACE, getstring(u, CHAN_INFO_OPT_PEACE), ci, u->nc);
- CheckOptStr(optbuf, CI_PRIVATE, getstring(u, CHAN_INFO_OPT_PRIVATE), ci, u->nc);
- CheckOptStr(optbuf, CI_RESTRICTED, getstring(u, CHAN_INFO_OPT_RESTRICTED), ci, u->nc);
- CheckOptStr(optbuf, CI_SECURE, getstring(u, CHAN_INFO_OPT_SECURE), ci, u->nc);
- CheckOptStr(optbuf, CI_SECUREFOUNDER, getstring(u, CHAN_INFO_OPT_SECUREFOUNDER), ci, u->nc);
- CheckOptStr(optbuf, CI_SECUREOPS, getstring(u, CHAN_INFO_OPT_SECUREOPS), ci, u->nc);
- CheckOptStr(optbuf, CI_SIGNKICK | CI_SIGNKICK_LEVEL, getstring(u, CHAN_INFO_OPT_SIGNKICK), ci, u->nc);
- CheckOptStr(optbuf, CI_TOPICLOCK, getstring(u, CHAN_INFO_OPT_TOPICLOCK), ci, u->nc);
- CheckOptStr(optbuf, CI_XOP, getstring(u, CHAN_INFO_OPT_XOP), ci, u->nc);
+ CheckOptStr(optbuf, CI_KEEPTOPIC, getstring(u, CHAN_INFO_OPT_KEEPTOPIC), ci, u->nc);
+ CheckOptStr(optbuf, CI_OPNOTICE, getstring(u, CHAN_INFO_OPT_OPNOTICE), ci, u->nc);
+ CheckOptStr(optbuf, CI_PEACE, getstring(u, CHAN_INFO_OPT_PEACE), ci, u->nc);
+ CheckOptStr(optbuf, CI_PRIVATE, getstring(u, CHAN_INFO_OPT_PRIVATE), ci, u->nc);
+ CheckOptStr(optbuf, CI_RESTRICTED, getstring(u, CHAN_INFO_OPT_RESTRICTED), ci, u->nc);
+ CheckOptStr(optbuf, CI_SECURE, getstring(u, CHAN_INFO_OPT_SECURE), ci, u->nc);
+ CheckOptStr(optbuf, CI_SECUREFOUNDER, getstring(u, CHAN_INFO_OPT_SECUREFOUNDER), ci, u->nc);
+ CheckOptStr(optbuf, CI_SECUREOPS, getstring(u, CHAN_INFO_OPT_SECUREOPS), ci, u->nc);
+ if (ci->HasFlag(CI_SIGNKICK))
+ CheckOptStr(optbuf, CI_SIGNKICK, getstring(u, CHAN_INFO_OPT_SIGNKICK), ci, u->nc);
+ else
+ CheckOptStr(optbuf, CI_SIGNKICK_LEVEL, getstring(u, CHAN_INFO_OPT_SIGNKICK), ci, u->nc);
+ CheckOptStr(optbuf, CI_TOPICLOCK, getstring(u, CHAN_INFO_OPT_TOPICLOCK), ci, u->nc);
+ CheckOptStr(optbuf, CI_XOP, getstring(u, CHAN_INFO_OPT_XOP), ci, u->nc);
notice_lang(s_ChanServ, u, CHAN_INFO_OPTIONS, optbuf.empty() ? getstring(u, CHAN_INFO_OPT_NONE) : optbuf.c_str());
notice_lang(s_ChanServ, u, CHAN_INFO_MODE_LOCK, get_mlock_modes(ci, 1));
// XXX: we could just as easily (and tidily) merge this in with the flags display above.
- if (ci->flags & CI_NO_EXPIRE)
+ if (ci->HasFlag(CI_NO_EXPIRE))
{
notice_lang(s_ChanServ, u, CHAN_INFO_NO_EXPIRE);
}
@@ -135,7 +138,7 @@ class CommandCSInfo : public Command
}
}
}
- if (ci->flags & CI_SUSPENDED)
+ if (ci->HasFlag(CI_SUSPENDED))
{
notice_lang(s_ChanServ, u, CHAN_X_SUSPENDED, ci->forbidby, (ci->forbidreason ? ci->forbidreason : getstring(u, NO_REASON)));
}
diff --git a/src/core/cs_kick.c b/src/core/cs_kick.c
index 8ebe2f06b..960cfea9d 100644
--- a/src/core/cs_kick.c
+++ b/src/core/cs_kick.c
@@ -58,7 +58,7 @@ class CommandCSKick : public Command
} else if (!is_same ? !check_access(u, ci, CA_KICK) :
!check_access(u, ci, CA_KICKME)) {
notice_lang(s_ChanServ, u, ACCESS_DENIED);
- } else if (!is_same && (ci->flags & CI_PEACE)
+ } else if (!is_same && (ci->HasFlag(CI_PEACE))
&& (get_access(u2, ci) >= get_access(u, ci))) {
notice_lang(s_ChanServ, u, ACCESS_DENIED);
} else if (is_protected(u2)) {
@@ -66,8 +66,8 @@ class CommandCSKick : public Command
} else {
const char *av[3];
- if ((ci->flags & CI_SIGNKICK)
- || ((ci->flags & CI_SIGNKICK_LEVEL)
+ if ((ci->HasFlag(CI_SIGNKICK))
+ || ((ci->HasFlag(CI_SIGNKICK_LEVEL))
&& !check_access(u, ci, CA_SIGNKICK)))
ircdproto->SendKick(whosends(ci), ci->name, target, "%s (%s)",
reason, u->nick);
diff --git a/src/core/cs_list.c b/src/core/cs_list.c
index c6d2f8225..087d0c664 100644
--- a/src/core/cs_list.c
+++ b/src/core/cs_list.c
@@ -36,7 +36,9 @@ public:
int count = 0, from = 0, to = 0, tofree = 0;
char *tmp = NULL;
char *s = NULL;
- int32 matchflags = 0;
+ bool forbidden, suspended, channoexpire;
+
+ forbidden = suspended = noexpire = false;
if (!(!CSListOpersOnly || (is_oper(u))))
{
@@ -98,11 +100,11 @@ public:
{
ci::string keyword_ci = keyword.c_str();
if (keyword_ci == "FORBIDDEN")
- matchflags |= CI_FORBIDDEN;
+ forbidden = true;
if (keyword_ci == "SUSPENDED")
- matchflags |= CI_SUSPENDED;
+ suspended = true;
if (keyword_ci == "NOEXPIRE")
- matchflags |= CI_NO_EXPIRE;
+ channoexpire = true;
}
}
@@ -116,10 +118,14 @@ public:
{
for (ci = chanlists[i]; ci; ci = ci->next)
{
- if (!is_servadmin && ((ci->flags & CI_PRIVATE)
- || (ci->flags & CI_FORBIDDEN) || (ci->flags & CI_SUSPENDED)))
+ if (!is_servadmin && ((ci->HasFlag(CI_PRIVATE))
+ || (ci->HasFlag(CI_FORBIDDEN)) || (ci->HasFlag(CI_SUSPENDED))))
+ continue;
+ if (forbidden && !ci->HasFlag(CI_FORBIDDEN))
+ continue;
+ else if (suspended && !ci->HasFlag(CI_SUSPENDED))
continue;
- if ((matchflags != 0) && !(ci->flags & matchflags))
+ else if (channoexpire && !ci->HasFlag(CI_NO_EXPIRE))
continue;
if ((stricmp(pattern, ci->name) == 0)
@@ -132,15 +138,15 @@ public:
&& (++nchans <= CSListMax))
{
char noexpire_char = ' ';
- if (is_servadmin && (ci->flags & CI_NO_EXPIRE))
+ if (is_servadmin && (ci->HasFlag(CI_NO_EXPIRE)))
noexpire_char = '!';
- if (ci->flags & CI_FORBIDDEN)
+ if (ci->HasFlag(CI_FORBIDDEN))
{
snprintf(buf, sizeof(buf),
"%-20s [Forbidden]", ci->name);
}
- else if (ci->flags & CI_SUSPENDED)
+ else if (ci->HasFlag(CI_SUSPENDED))
{
snprintf(buf, sizeof(buf),
"%-20s [Suspended]", ci->name);
diff --git a/src/core/cs_modes.c b/src/core/cs_modes.c
index 8c45e328f..88b3770c7 100644
--- a/src/core/cs_modes.c
+++ b/src/core/cs_modes.c
@@ -26,7 +26,7 @@
* @param name The name, eg "OP" or "HALFOP"
* @param notice Flag required on a channel to send a notice
*/
-static CommandReturn do_util(User *u, ChannelMode *cm, const char *chan, const char *nick, bool set, int level, int levelself, const std::string &name, int32 notice)
+static CommandReturn do_util(User *u, ChannelMode *cm, const char *chan, const char *nick, bool set, int level, int levelself, const std::string &name, ChannelInfoFlag notice)
{
const char *av[2];
Channel *c = findchan(chan);
@@ -36,9 +36,8 @@ static CommandReturn do_util(User *u, ChannelMode *cm, const char *chan, const c
int is_same;
- if (!nick) {
+ if (!nick)
nick = u->nick;
- }
is_same = (nick == u->nick) ? 1 : (stricmp(nick, u->nick) == 0);
@@ -53,7 +52,7 @@ static CommandReturn do_util(User *u, ChannelMode *cm, const char *chan, const c
notice_lang(s_ChanServ, u, NICK_X_NOT_ON_CHAN, u2->nick, c->name);
else if (is_same ? !check_access(u, ci, levelself) : !check_access(u, ci, level))
notice_lang(s_ChanServ, u, ACCESS_DENIED);
- else if (!set && !is_same && (ci->flags & CI_PEACE) && (get_access(u2, ci) >= get_access(u, ci)))
+ else if (!set && !is_same && (ci->HasFlag(CI_PEACE)) && (get_access(u2, ci) >= get_access(u, ci)))
notice_lang(s_ChanServ, u, ACCESS_DENIED);
else if (!set && is_protected(u2) && !is_same)
notice_lang(s_ChanServ, u, ACCESS_DENIED);
@@ -68,7 +67,7 @@ static CommandReturn do_util(User *u, ChannelMode *cm, const char *chan, const c
chan_set_modes(s_ChanServ, c, 2, av, 3);
- if (notice && ci->flags & notice)
+ if (notice && ci->HasFlag(notice))
ircdproto->SendMessage(whosends(ci), c->name, "%s command used for %s by %s",
name.c_str(), u2->nick, u->nick);
}
@@ -141,7 +140,7 @@ class CommandCSVoice : public Command
{
ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_VOICE);
- return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), true, CA_VOICE, CA_VOICEME, "VOICE", 0);
+ return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), true, CA_VOICE, CA_VOICEME, "VOICE", CI_BEGIN);
}
bool OnHelp(User *u, const ci::string &subcommand)
@@ -168,7 +167,7 @@ class CommandCSDeVoice : public Command
{
ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_VOICE);
- return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), false, CA_VOICE, CA_VOICEME, "DEVOICE", 0);
+ return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), false, CA_VOICE, CA_VOICEME, "DEVOICE", CI_BEGIN);
}
bool OnHelp(User *u, const ci::string &subcommand)
@@ -200,7 +199,7 @@ class CommandCSHalfOp : public Command
return MOD_CONT;
}
- return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), true, CA_HALFOP, CA_HALFOPME, "HALFOP", 0);
+ return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), true, CA_HALFOP, CA_HALFOPME, "HALFOP", CI_BEGIN);
}
bool OnHelp(User *u, const ci::string &subcommand)
@@ -233,7 +232,7 @@ class CommandCSDeHalfOp : public Command
}
- return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), false, CA_HALFOP, CA_HALFOPME, "DEHALFOP", 0);
+ return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), false, CA_HALFOP, CA_HALFOPME, "DEHALFOP", CI_BEGIN);
}
bool OnHelp(User *u, const ci::string &subcommand)
@@ -265,7 +264,7 @@ class CommandCSProtect : public Command
return MOD_CONT;
}
- return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), true, CA_PROTECT, CA_PROTECTME, "PROTECT", 0);
+ return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), true, CA_PROTECT, CA_PROTECTME, "PROTECT", CI_BEGIN);
}
bool OnHelp(User *u, const ci::string &subcommand)
@@ -296,7 +295,7 @@ class CommandCSDeProtect : public Command
return MOD_CONT;
}
- return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), false, CA_PROTECT, CA_PROTECTME, "DEPROTECT", 0);
+ return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), false, CA_PROTECT, CA_PROTECTME, "DEPROTECT", CI_BEGIN);
}
bool OnHelp(User *u, const ci::string &subcommand)
@@ -327,7 +326,7 @@ class CommandCSOwner : public Command
return MOD_CONT;
}
- return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), true, CA_OWNER, CA_OWNERME, "OWNER", 0);
+ return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), true, CA_OWNER, CA_OWNERME, "OWNER", CI_BEGIN);
}
bool OnHelp(User *u, const ci::string &subcommand)
@@ -358,7 +357,7 @@ class CommandCSDeOwner : public Command
return MOD_CONT;
}
- return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), false, CA_OWNER, CA_OWNERME, "DEOWNER", 0);
+ return do_util(u, cm, (params.size() > 0 ? params[0].c_str() : NULL), (params.size() > 1 ? params[1].c_str() : NULL), false, CA_OWNER, CA_OWNERME, "DEOWNER", CI_BEGIN);
}
bool OnHelp(User *u, const ci::string &subcommand)
diff --git a/src/core/cs_set.c b/src/core/cs_set.c
index d04969f9f..e556c7a49 100644
--- a/src/core/cs_set.c
+++ b/src/core/cs_set.c
@@ -27,7 +27,7 @@ class CommandCSSet : public Command
if (!na) {
notice_lang(s_ChanServ, u, NICK_X_NOT_REGISTERED, param);
return MOD_CONT;
- } else if (na->status & NS_FORBIDDEN) {
+ } else if (na->HasFlag(NS_FORBIDDEN)) {
notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, param);
return MOD_CONT;
}
@@ -66,7 +66,7 @@ class CommandCSSet : public Command
notice_lang(s_ChanServ, u, NICK_X_NOT_REGISTERED, param);
return MOD_CONT;
}
- if (na->status & NS_FORBIDDEN) {
+ if (na->HasFlag(NS_FORBIDDEN)) {
notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, param);
return MOD_CONT;
}
@@ -283,10 +283,10 @@ class CommandCSSet : public Command
CommandReturn DoSetKeepTopic(User * u, ChannelInfo * ci, const char *param)
{
if (stricmp(param, "ON") == 0) {
- ci->flags |= CI_KEEPTOPIC;
+ ci->SetFlag(CI_KEEPTOPIC);
notice_lang(s_ChanServ, u, CHAN_SET_KEEPTOPIC_ON, ci->name);
} else if (stricmp(param, "OFF") == 0) {
- ci->flags &= ~CI_KEEPTOPIC;
+ ci->UnsetFlag(CI_KEEPTOPIC);
notice_lang(s_ChanServ, u, CHAN_SET_KEEPTOPIC_OFF, ci->name);
} else {
syntax_error(s_ChanServ, u, "SET KEEPTOPIC",
@@ -298,10 +298,10 @@ class CommandCSSet : public Command
CommandReturn DoSetTopicLock(User * u, ChannelInfo * ci, const char *param)
{
if (stricmp(param, "ON") == 0) {
- ci->flags |= CI_TOPICLOCK;
+ ci->SetFlag(CI_TOPICLOCK);
notice_lang(s_ChanServ, u, CHAN_SET_TOPICLOCK_ON, ci->name);
} else if (stricmp(param, "OFF") == 0) {
- ci->flags &= ~CI_TOPICLOCK;
+ ci->UnsetFlag(CI_TOPICLOCK);
notice_lang(s_ChanServ, u, CHAN_SET_TOPICLOCK_OFF, ci->name);
} else {
syntax_error(s_ChanServ, u, "SET TOPICLOCK",
@@ -313,10 +313,10 @@ class CommandCSSet : public Command
CommandReturn DoSetPrivate(User * u, ChannelInfo * ci, const char *param)
{
if (stricmp(param, "ON") == 0) {
- ci->flags |= CI_PRIVATE;
+ ci->SetFlag(CI_PRIVATE);
notice_lang(s_ChanServ, u, CHAN_SET_PRIVATE_ON, ci->name);
} else if (stricmp(param, "OFF") == 0) {
- ci->flags &= ~CI_PRIVATE;
+ ci->UnsetFlag(CI_PRIVATE);
notice_lang(s_ChanServ, u, CHAN_SET_PRIVATE_OFF, ci->name);
} else {
syntax_error(s_ChanServ, u, "SET PRIVATE",
@@ -328,10 +328,10 @@ class CommandCSSet : public Command
CommandReturn DoSetSecureOps(User * u, ChannelInfo * ci, const char *param)
{
if (stricmp(param, "ON") == 0) {
- ci->flags |= CI_SECUREOPS;
+ ci->SetFlag(CI_SECUREOPS);
notice_lang(s_ChanServ, u, CHAN_SET_SECUREOPS_ON, ci->name);
} else if (stricmp(param, "OFF") == 0) {
- ci->flags &= ~CI_SECUREOPS;
+ ci->UnsetFlag(CI_SECUREOPS);
notice_lang(s_ChanServ, u, CHAN_SET_SECUREOPS_OFF, ci->name);
} else {
syntax_error(s_ChanServ, u, "SET SECUREOPS",
@@ -343,10 +343,10 @@ class CommandCSSet : public Command
CommandReturn DoSetSecureFounder(User * u, ChannelInfo * ci, const char *param)
{
if (stricmp(param, "ON") == 0) {
- ci->flags |= CI_SECUREFOUNDER;
+ ci->SetFlag(CI_SECUREFOUNDER);
notice_lang(s_ChanServ, u, CHAN_SET_SECUREFOUNDER_ON, ci->name);
} else if (stricmp(param, "OFF") == 0) {
- ci->flags &= ~CI_SECUREFOUNDER;
+ ci->UnsetFlag(CI_SECUREFOUNDER);
notice_lang(s_ChanServ, u, CHAN_SET_SECUREFOUNDER_OFF, ci->name);
} else {
syntax_error(s_ChanServ, u, "SET SECUREFOUNDER",
@@ -358,12 +358,12 @@ class CommandCSSet : public Command
CommandReturn DoSetRestricted(User * u, ChannelInfo * ci, const char *param)
{
if (stricmp(param, "ON") == 0) {
- ci->flags |= CI_RESTRICTED;
+ ci->SetFlag(CI_RESTRICTED);
if (ci->levels[CA_NOJOIN] < 0)
ci->levels[CA_NOJOIN] = 0;
notice_lang(s_ChanServ, u, CHAN_SET_RESTRICTED_ON, ci->name);
} else if (stricmp(param, "OFF") == 0) {
- ci->flags &= ~CI_RESTRICTED;
+ ci->UnsetFlag(CI_RESTRICTED);
if (ci->levels[CA_NOJOIN] >= 0)
ci->levels[CA_NOJOIN] = -2;
notice_lang(s_ChanServ, u, CHAN_SET_RESTRICTED_OFF, ci->name);
@@ -377,10 +377,10 @@ class CommandCSSet : public Command
CommandReturn DoSetSecure(User * u, ChannelInfo * ci, const char *param)
{
if (stricmp(param, "ON") == 0) {
- ci->flags |= CI_SECURE;
+ ci->SetFlag(CI_SECURE);
notice_lang(s_ChanServ, u, CHAN_SET_SECURE_ON, ci->name);
} else if (stricmp(param, "OFF") == 0) {
- ci->flags &= ~CI_SECURE;
+ ci->UnsetFlag(CI_SECURE);
notice_lang(s_ChanServ, u, CHAN_SET_SECURE_OFF, ci->name);
} else {
syntax_error(s_ChanServ, u, "SET SECURE", CHAN_SET_SECURE_SYNTAX);
@@ -391,15 +391,16 @@ class CommandCSSet : public Command
CommandReturn DoSetSignKick(User * u, ChannelInfo * ci, const char *param)
{
if (stricmp(param, "ON") == 0) {
- ci->flags |= CI_SIGNKICK;
- ci->flags &= ~CI_SIGNKICK_LEVEL;
+ ci->SetFlag(CI_SIGNKICK);
+ ci->UnsetFlag(CI_SIGNKICK_LEVEL);
notice_lang(s_ChanServ, u, CHAN_SET_SIGNKICK_ON, ci->name);
} else if (stricmp(param, "LEVEL") == 0) {
- ci->flags |= CI_SIGNKICK_LEVEL;
- ci->flags &= ~CI_SIGNKICK;
+ ci->SetFlag(CI_SIGNKICK_LEVEL);
+ ci->UnsetFlag(CI_SIGNKICK);
notice_lang(s_ChanServ, u, CHAN_SET_SIGNKICK_LEVEL, ci->name);
} else if (stricmp(param, "OFF") == 0) {
- ci->flags &= ~(CI_SIGNKICK | CI_SIGNKICK_LEVEL);
+ ci->UnsetFlag(CI_SIGNKICK);
+ ci->UnsetFlag(CI_SIGNKICK_LEVEL);
notice_lang(s_ChanServ, u, CHAN_SET_SIGNKICK_OFF, ci->name);
} else {
syntax_error(s_ChanServ, u, "SET SIGNKICK",
@@ -411,10 +412,10 @@ class CommandCSSet : public Command
CommandReturn DoSetOpNotice(User * u, ChannelInfo * ci, const char *param)
{
if (stricmp(param, "ON") == 0) {
- ci->flags |= CI_OPNOTICE;
+ ci->SetFlag(CI_OPNOTICE);
notice_lang(s_ChanServ, u, CHAN_SET_OPNOTICE_ON, ci->name);
} else if (stricmp(param, "OFF") == 0) {
- ci->flags &= ~CI_OPNOTICE;
+ ci->UnsetFlag(CI_OPNOTICE);
notice_lang(s_ChanServ, u, CHAN_SET_OPNOTICE_OFF, ci->name);
} else {
syntax_error(s_ChanServ, u, "SET OPNOTICE",
@@ -428,7 +429,7 @@ class CommandCSSet : public Command
CommandReturn DoSetXOP(User * u, ChannelInfo * ci, const char *param)
{
if (stricmp(param, "ON") == 0) {
- if (!(ci->flags & CI_XOP)) {
+ if (!(ci->HasFlag(CI_XOP))) {
ChanAccess *access;
for (unsigned i = 0; i < ci->GetAccessCount(); i++) {
@@ -463,14 +464,14 @@ class CommandCSSet : public Command
ci->CleanAccess();
reset_levels(ci);
- ci->flags |= CI_XOP;
+ ci->SetFlag(CI_XOP);
}
alog("%s: %s!%s@%s enabled XOP for %s", s_ChanServ, u->nick,
u->GetIdent().c_str(), u->host, ci->name);
notice_lang(s_ChanServ, u, CHAN_SET_XOP_ON, ci->name);
} else if (stricmp(param, "OFF") == 0) {
- ci->flags &= ~CI_XOP;
+ ci->UnsetFlag(CI_XOP);
alog("%s: %s!%s@%s disabled XOP for %s", s_ChanServ, u->nick,
u->GetIdent().c_str(), u->host, ci->name);
@@ -486,10 +487,10 @@ class CommandCSSet : public Command
CommandReturn DoSetPeace(User * u, ChannelInfo * ci, const char *param)
{
if (stricmp(param, "ON") == 0) {
- ci->flags |= CI_PEACE;
+ ci->SetFlag(CI_PEACE);
notice_lang(s_ChanServ, u, CHAN_SET_PEACE_ON, ci->name);
} else if (stricmp(param, "OFF") == 0) {
- ci->flags &= ~CI_PEACE;
+ ci->UnsetFlag(CI_PEACE);
notice_lang(s_ChanServ, u, CHAN_SET_PEACE_OFF, ci->name);
} else {
syntax_error(s_ChanServ, u, "SET PEACE", CHAN_SET_PEACE_SYNTAX);
@@ -505,10 +506,10 @@ class CommandCSSet : public Command
return MOD_CONT;
}
if (stricmp(param, "ON") == 0) {
- ci->flags |= CI_NO_EXPIRE;
+ ci->SetFlag(CI_NO_EXPIRE);
notice_lang(s_ChanServ, u, CHAN_SET_NOEXPIRE_ON, ci->name);
} else if (stricmp(param, "OFF") == 0) {
- ci->flags &= ~CI_NO_EXPIRE;
+ ci->UnsetFlag(CI_NO_EXPIRE);
notice_lang(s_ChanServ, u, CHAN_SET_NOEXPIRE_OFF, ci->name);
} else {
syntax_error(s_ChanServ, u, "SET NOEXPIRE",
@@ -540,25 +541,15 @@ class CommandCSSet : public Command
else if (!is_servadmin && !check_access(u, ci, CA_SET))
notice_lang(s_ChanServ, u, ACCESS_DENIED);
else if (cmd == "FOUNDER") {
- if (!is_servadmin
- && (ci->
- flags & CI_SECUREFOUNDER ? !IsRealFounder(u,
- ci) :
- !IsFounder(u, ci))) {
+ if (!is_servadmin && (ci->HasFlag(CI_SECUREFOUNDER) ? !IsRealFounder(u, ci) : !IsFounder(u, ci)))
notice_lang(s_ChanServ, u, ACCESS_DENIED);
- } else {
+ else
DoSetFounder(u, ci, param);
- }
} else if (cmd == "SUCCESSOR") {
- if (!is_servadmin
- && (ci->
- flags & CI_SECUREFOUNDER ? !IsRealFounder(u,
- ci) :
- !IsFounder(u, ci))) {
+ if (!is_servadmin && (ci->HasFlag(CI_SECUREFOUNDER) ? !IsRealFounder(u, ci) : !IsFounder(u, ci)))
notice_lang(s_ChanServ, u, ACCESS_DENIED);
- } else {
+ else
DoSetSuccessor(u, ci, param);
- }
} else if (cmd == "DESC") {
DoSetDesc(u, ci, param);
} else if (cmd == "URL") {
@@ -582,15 +573,10 @@ class CommandCSSet : public Command
} else if (cmd == "SECUREOPS") {
DoSetSecureOps(u, ci, param);
} else if (cmd == "SECUREFOUNDER") {
- if (!is_servadmin
- && (ci->
- flags & CI_SECUREFOUNDER ? !IsRealFounder(u,
- ci) :
- !IsFounder(u, ci))) {
+ if (!is_servadmin && (ci->HasFlag(CI_SECUREFOUNDER) ? !IsRealFounder(u, ci) : !IsFounder(u, ci)))
notice_lang(s_ChanServ, u, ACCESS_DENIED);
- } else {
+ else
DoSetSecureFounder(u, ci, param);
- }
} else if (cmd == "RESTRICTED") {
DoSetRestricted(u, ci, param);
} else if (cmd == "SECURE") {
diff --git a/src/core/cs_suspend.c b/src/core/cs_suspend.c
index ccc722bb3..dd6511a47 100644
--- a/src/core/cs_suspend.c
+++ b/src/core/cs_suspend.c
@@ -44,7 +44,7 @@ class CommandCSSuspend : public Command
}
/* You should not SUSPEND a FORBIDEN channel */
- if (ci->flags & CI_FORBIDDEN)
+ if (ci->HasFlag(CI_FORBIDDEN))
{
notice_lang(s_ChanServ, u, CHAN_MAY_NOT_BE_REGISTERED, chan);
return MOD_CONT;
@@ -55,7 +55,7 @@ class CommandCSSuspend : public Command
if (ci)
{
- ci->flags |= CI_SUSPENDED;
+ ci->SetFlag(CI_SUSPENDED);
ci->forbidby = sstrdup(u->nick);
if (reason)
ci->forbidreason = sstrdup(reason);
@@ -130,7 +130,7 @@ class CommandCSUnSuspend : public Command
notice_lang(s_ChanServ, u, READ_ONLY_MODE);
/* Only UNSUSPEND already suspended channels */
- if (!(ci->flags & CI_SUSPENDED))
+ if (!(ci->HasFlag(CI_SUSPENDED)))
{
notice_lang(s_ChanServ, u, CHAN_UNSUSPEND_FAILED, chan);
return MOD_CONT;
@@ -138,7 +138,7 @@ class CommandCSUnSuspend : public Command
if (ci)
{
- ci->flags &= ~CI_SUSPENDED;
+ ci->UnsetFlag(CI_SUSPENDED);
if (ci->forbidreason)
{
delete [] ci->forbidreason;
diff --git a/src/core/cs_xop.c b/src/core/cs_xop.c
index e79cb6515..52bf1e4f1 100644
--- a/src/core/cs_xop.c
+++ b/src/core/cs_xop.c
@@ -150,7 +150,7 @@ class XOPBase : public Command
notice_lang(s_ChanServ, u, messages[XOP_NICKS_ONLY]);
return MOD_CONT;
}
- else if (na->status & NS_FORBIDDEN)
+ else if (na->HasFlag(NS_FORBIDDEN))
{
notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, na->nick);
return MOD_CONT;
@@ -380,7 +380,7 @@ class XOPBase : public Command
ChannelInfo *ci = cs_findchan(chan);
- if (!(ci->flags & CI_XOP))
+ if (!(ci->HasFlag(CI_XOP)))
notice_lang(s_ChanServ, u, CHAN_XOP_ACCESS, s_ChanServ);
else if (cmd == "ADD")
return this->DoAdd(u, params, ci, level, messages);
diff --git a/src/core/hs_del.c b/src/core/hs_del.c
index 2b36f6a89..0781dc8f6 100644
--- a/src/core/hs_del.c
+++ b/src/core/hs_del.c
@@ -28,7 +28,7 @@ class CommandHSDel : public Command
const char *nick = params[0].c_str();
if ((na = findnick(nick)))
{
- if (na->status & NS_FORBIDDEN)
+ if (na->HasFlag(NS_FORBIDDEN))
{
notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick);
return MOD_CONT;
diff --git a/src/core/hs_delall.c b/src/core/hs_delall.c
index 678852cf6..714f23eef 100644
--- a/src/core/hs_delall.c
+++ b/src/core/hs_delall.c
@@ -30,7 +30,7 @@ class CommandHSDelAll : public Command
NickCore *nc;
if ((na = findnick(nick)))
{
- if (na->status & NS_FORBIDDEN)
+ if (na->HasFlag(NS_FORBIDDEN))
{
notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick);
return MOD_CONT;
diff --git a/src/core/hs_set.c b/src/core/hs_set.c
index 26b6a1146..f9a3d80f1 100644
--- a/src/core/hs_set.c
+++ b/src/core/hs_set.c
@@ -107,7 +107,7 @@ class CommandHSSet : public Command
if ((na = findnick(nick)))
{
- if (na->status & NS_FORBIDDEN)
+ if (na->HasFlag(NS_FORBIDDEN))
{
notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick);
if (vIdent)
diff --git a/src/core/hs_setall.c b/src/core/hs_setall.c
index e8a9c7dab..8343eb0f9 100644
--- a/src/core/hs_setall.c
+++ b/src/core/hs_setall.c
@@ -109,7 +109,7 @@ class CommandHSSetAll : public Command
if ((na = findnick(nick)))
{
- if (na->status & NS_FORBIDDEN)
+ if (na->HasFlag(NS_FORBIDDEN))
{
notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick);
if (vIdent) {
diff --git a/src/core/ms_cancel.c b/src/core/ms_cancel.c
index 94e18262b..e01fef169 100644
--- a/src/core/ms_cancel.c
+++ b/src/core/ms_cancel.c
@@ -46,7 +46,7 @@ class CommandMSCancel : public Command
for (i = mi->memos.size() - 1; i >= 0; --i)
{
- if ((mi->memos[i]->flags & MF_UNREAD) && !stricmp(mi->memos[i]->sender, u->nc->display) && (!(mi->memos[i]->flags & MF_NOTIFYS)))
+ if ((mi->memos[i]->HasFlag(MF_UNREAD)) && !stricmp(mi->memos[i]->sender, u->nc->display) && !mi->memos[i]->HasFlag(MF_NOTIFYS))
{
delmemo(mi, mi->memos[i]->number);
notice_lang(s_MemoServ, u, MEMO_CANCELLED, name);
diff --git a/src/core/ms_check.c b/src/core/ms_check.c
index ac48dac6d..2d3f2ce12 100644
--- a/src/core/ms_check.c
+++ b/src/core/ms_check.c
@@ -42,7 +42,7 @@ class CommandMSCheck : public Command
return MOD_CONT;
}
- if ((na->status & NS_FORBIDDEN))
+ if ((na->HasFlag(NS_FORBIDDEN)))
{
notice_lang(s_MemoServ, u, NICK_X_FORBIDDEN, recipient);
return MOD_CONT;
@@ -62,7 +62,7 @@ class CommandMSCheck : public Command
tm = localtime(&mi->memos[i]->time);
strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_DATE_TIME_FORMAT, tm);
- if (mi->memos[i]->flags & MF_UNREAD)
+ if (mi->memos[i]->HasFlag(MF_UNREAD))
notice_lang(s_MemoServ, u, MEMO_CHECK_NOT_READ, na->nick, timebuf);
else
notice_lang(s_MemoServ, u, MEMO_CHECK_READ, na->nick, timebuf);
diff --git a/src/core/ms_info.c b/src/core/ms_info.c
index a0077e09b..76e605478 100644
--- a/src/core/ms_info.c
+++ b/src/core/ms_info.c
@@ -38,13 +38,13 @@ class CommandMSInfo : public Command
notice_lang(s_MemoServ, u, NICK_X_NOT_REGISTERED, name);
return MOD_CONT;
}
- else if (na->status & NS_FORBIDDEN)
+ else if (na->HasFlag(NS_FORBIDDEN))
{
notice_lang(s_MemoServ, u, NICK_X_FORBIDDEN, name);
return MOD_CONT;
}
mi = &na->nc->memos;
- hardmax = na->nc->flags & NI_MEMO_HARDMAX ? 1 : 0;
+ hardmax = na->nc->HasFlag(NI_MEMO_HARDMAX) ? 1 : 0;
}
else if (name && *name == '#')
{
@@ -59,7 +59,7 @@ class CommandMSInfo : public Command
return MOD_CONT;
}
mi = &ci->memos;
- hardmax = ci->flags & CI_MEMO_HARDMAX ? 1 : 0;
+ hardmax = ci->HasFlag(CI_MEMO_HARDMAX) ? 1 : 0;
}
else if (name) /* It's not a chan and we aren't services admin */
{
@@ -69,7 +69,7 @@ class CommandMSInfo : public Command
else
{
mi = &u->nc->memos;
- hardmax = u->nc->flags & NI_MEMO_HARDMAX ? 1 : 0;
+ hardmax = u->nc->HasFlag(NI_MEMO_HARDMAX) ? 1 : 0;
}
if (name && (ci || na->nc != u->nc))
@@ -78,7 +78,7 @@ class CommandMSInfo : public Command
notice_lang(s_MemoServ, u, MEMO_INFO_X_NO_MEMOS, name);
else if (mi->memos.size() == 1)
{
- if (mi->memos[0]->flags & MF_UNREAD)
+ if (mi->memos[0]->HasFlag(MF_UNREAD))
notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMO_UNREAD, name);
else
notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMO, name);
@@ -88,7 +88,7 @@ class CommandMSInfo : public Command
int count = 0, i;
for (i = 0; i < mi->memos.size(); ++i)
{
- if (mi->memos[i]->flags & MF_UNREAD)
+ if (mi->memos[i]->HasFlag(MF_UNREAD))
++count;
}
if (count == mi->memos.size())
@@ -121,11 +121,11 @@ class CommandMSInfo : public Command
to rewrite the whole thing (it pisses me off). */
if (na)
{
- if ((na->nc->flags & NI_MEMO_RECEIVE) && (na->nc->flags & NI_MEMO_SIGNON))
+ if (na->nc->HasFlag(NI_MEMO_RECEIVE) && na->nc->HasFlag(NI_MEMO_SIGNON))
notice_lang(s_MemoServ, u, MEMO_INFO_X_NOTIFY_ON, name);
- else if (na->nc->flags & NI_MEMO_RECEIVE)
+ else if (na->nc->HasFlag(NI_MEMO_RECEIVE))
notice_lang(s_MemoServ, u, MEMO_INFO_X_NOTIFY_RECEIVE, name);
- else if (na->nc->flags & NI_MEMO_SIGNON)
+ else if (na->nc->HasFlag(NI_MEMO_SIGNON))
notice_lang(s_MemoServ, u, MEMO_INFO_X_NOTIFY_SIGNON, name);
else
notice_lang(s_MemoServ, u, MEMO_INFO_X_NOTIFY_OFF, name);
@@ -137,7 +137,7 @@ class CommandMSInfo : public Command
notice_lang(s_MemoServ, u, MEMO_INFO_NO_MEMOS);
else if (mi->memos.size() == 1)
{
- if (mi->memos[0]->flags & MF_UNREAD)
+ if (mi->memos[0]->HasFlag(MF_UNREAD))
notice_lang(s_MemoServ, u, MEMO_INFO_MEMO_UNREAD);
else
notice_lang(s_MemoServ, u, MEMO_INFO_MEMO);
@@ -147,7 +147,7 @@ class CommandMSInfo : public Command
int count = 0, i;
for (i = 0; i < mi->memos.size(); ++i)
{
- if (mi->memos[i]->flags & MF_UNREAD)
+ if (mi->memos[i]->HasFlag(MF_UNREAD))
++count;
}
if (count == mi->memos.size())
@@ -178,11 +178,11 @@ class CommandMSInfo : public Command
notice_lang(s_MemoServ, u, MEMO_INFO_NO_LIMIT);
/* Ripped too. But differently because of a seg fault (loughs) */
- if ((u->nc->flags & NI_MEMO_RECEIVE) && (u->nc->flags & NI_MEMO_SIGNON))
+ if (u->nc->HasFlag(NI_MEMO_RECEIVE) && u->nc->HasFlag(NI_MEMO_SIGNON))
notice_lang(s_MemoServ, u, MEMO_INFO_NOTIFY_ON);
- else if (u->nc->flags & NI_MEMO_RECEIVE)
+ else if (u->nc->HasFlag(NI_MEMO_RECEIVE))
notice_lang(s_MemoServ, u, MEMO_INFO_NOTIFY_RECEIVE);
- else if (u->nc->flags & NI_MEMO_SIGNON)
+ else if (u->nc->HasFlag(NI_MEMO_SIGNON))
notice_lang(s_MemoServ, u, MEMO_INFO_NOTIFY_SIGNON);
else
notice_lang(s_MemoServ, u, MEMO_INFO_NOTIFY_OFF);
diff --git a/src/core/ms_list.c b/src/core/ms_list.c
index 950982ffc..bcd5e90a8 100644
--- a/src/core/ms_list.c
+++ b/src/core/ms_list.c
@@ -73,7 +73,7 @@ class CommandMSList : public Command
{
for (i = 0; i < mi->memos.size(); ++i)
{
- if (mi->memos[i]->flags & MF_UNREAD)
+ if (mi->memos[i]->HasFlag(MF_UNREAD))
break;
}
if (i == mi->memos.size())
@@ -87,7 +87,7 @@ class CommandMSList : public Command
}
for (i = 0; i < mi->memos.size(); ++i)
{
- if (!param.empty() && !(mi->memos[i]->flags & MF_UNREAD))
+ if (!param.empty() && !(mi->memos[i]->HasFlag(MF_UNREAD)))
continue;
list_memo(u, i, mi, &sent_header, !param.empty(), chan.c_str());
}
@@ -178,7 +178,7 @@ int list_memo(User *u, int index, MemoInfo *mi, int *sent_header, int newi, cons
tm = *localtime(&m->time);
strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_DATE_TIME_FORMAT, &tm);
timebuf[sizeof(timebuf) - 1] = 0; /* just in case */
- notice_lang(s_MemoServ, u, MEMO_LIST_FORMAT, (m->flags & MF_UNREAD) ? '*' : ' ', m->number, m->sender, timebuf);
+ notice_lang(s_MemoServ, u, MEMO_LIST_FORMAT, (m->HasFlag(MF_UNREAD)) ? '*' : ' ', m->number, m->sender, timebuf);
return 1;
}
diff --git a/src/core/ms_read.c b/src/core/ms_read.c
index 80af467d9..7e54d6629 100644
--- a/src/core/ms_read.c
+++ b/src/core/ms_read.c
@@ -72,7 +72,7 @@ class CommandMSRead : public Command
int readcount = 0;
for (i = 0; i < mi->memos.size(); ++i)
{
- if (mi->memos[i]->flags & MF_UNREAD)
+ if (mi->memos[i]->HasFlag(MF_UNREAD))
{
read_memo(u, i, mi, chan.c_str());
++readcount;
@@ -180,10 +180,10 @@ int read_memo(User *u, int index, MemoInfo *mi, const char *chan)
else
notice_lang(s_MemoServ, u, MEMO_HEADER, m->number, m->sender, timebuf, s_MemoServ, m->number);
notice_lang(s_MemoServ, u, MEMO_TEXT, m->text);
- m->flags &= ~MF_UNREAD;
+ m->UnsetFlag(MF_UNREAD);
/* Check if a receipt notification was requested */
- if (m->flags & MF_RECEIPT)
+ if (m->HasFlag(MF_RECEIPT))
rsend_notify(u, m, chan);
return 1;
diff --git a/src/core/ms_set.c b/src/core/ms_set.c
index e941a7f3a..3ebb3b354 100644
--- a/src/core/ms_set.c
+++ b/src/core/ms_set.c
@@ -24,26 +24,27 @@ class CommandMSSet : public Command
if (param == "ON")
{
- u->nc->flags |= NI_MEMO_SIGNON | NI_MEMO_RECEIVE;
+ u->nc->SetFlag(NI_MEMO_SIGNON);
+ u->nc->SetFlag(NI_MEMO_RECEIVE);
notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_ON, s_MemoServ);
}
else if (param == "LOGON")
{
- u->nc->flags |= NI_MEMO_SIGNON;
- u->nc->flags &= ~NI_MEMO_RECEIVE;
+ u->nc->SetFlag(NI_MEMO_SIGNON);
+ u->nc->UnsetFlag(NI_MEMO_RECEIVE);
notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_LOGON, s_MemoServ);
}
else if (param == "NEW")
{
- u->nc->flags &= ~NI_MEMO_SIGNON;
- u->nc->flags |= NI_MEMO_RECEIVE;
+ u->nc->UnsetFlag(NI_MEMO_SIGNON);
+ u->nc->SetFlag(NI_MEMO_RECEIVE);
notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_NEW, s_MemoServ);
}
else if (param == "MAIL")
{
if (u->nc->email)
{
- u->nc->flags |= NI_MEMO_MAIL;
+ u->nc->SetFlag(NI_MEMO_MAIL);
notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_MAIL);
}
else
@@ -51,12 +52,14 @@ class CommandMSSet : public Command
}
else if (param == "NOMAIL")
{
- u->nc->flags &= ~NI_MEMO_MAIL;
+ u->nc->UnsetFlag(NI_MEMO_MAIL);
notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_NOMAIL);
}
else if (param == "OFF")
{
- u->nc->flags &= ~(NI_MEMO_SIGNON | NI_MEMO_RECEIVE | NI_MEMO_MAIL);
+ u->nc->UnsetFlag(NI_MEMO_SIGNON);
+ u->nc->UnsetFlag(NI_MEMO_RECEIVE);
+ u->nc->UnsetFlag(NI_MEMO_MAIL);
notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_OFF, s_MemoServ);
}
else
@@ -122,16 +125,16 @@ class CommandMSSet : public Command
if (!chan.empty())
{
if (!p2.empty())
- ci->flags |= CI_MEMO_HARDMAX;
+ ci->SetFlag(CI_MEMO_HARDMAX);
else
- ci->flags &= ~CI_MEMO_HARDMAX;
+ ci->UnsetFlag(CI_MEMO_HARDMAX);
}
else
{
if (!p2.empty())
- nc->flags |= NI_MEMO_HARDMAX;
+ nc->SetFlag(NI_MEMO_HARDMAX);
else
- nc->flags &= ~NI_MEMO_HARDMAX;
+ nc->UnsetFlag(NI_MEMO_HARDMAX);
}
limit = atoi(p1.c_str());
if (limit < 0 || limit > 32767)
@@ -148,12 +151,12 @@ class CommandMSSet : public Command
syntax_error(s_MemoServ, u, "SET LIMIT", MEMO_SET_LIMIT_SYNTAX);
return MOD_CONT;
}
- if (!chan.empty() && (ci->flags & CI_MEMO_HARDMAX))
+ if (!chan.empty() && (ci->HasFlag(CI_MEMO_HARDMAX)))
{
notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_FORBIDDEN, chan.c_str());
return MOD_CONT;
}
- else if (chan.empty() && (nc->flags & NI_MEMO_HARDMAX))
+ else if (chan.empty() && (nc->HasFlag(NI_MEMO_HARDMAX)))
{
notice_lang(s_MemoServ, u, MEMO_SET_YOUR_LIMIT_FORBIDDEN);
return MOD_CONT;
diff --git a/src/core/ns_access.c b/src/core/ns_access.c
index ecc918ef0..0d9d1bdcb 100644
--- a/src/core/ns_access.c
+++ b/src/core/ns_access.c
@@ -30,14 +30,14 @@ class CommandNSAccess : public Command
}
/* reinstate when forbidden is moved to a group flag
- if (na->status & NS_FORBIDDEN)
+ if (na->HasFlag(NS_FORBIDDEN))
{
notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
return MOD_CONT;
}
*/
- if (nc->flags & NI_SUSPENDED)
+ if (nc->HasFlag(NI_SUSPENDED))
{
notice_lang(s_NickServ, u, NICK_X_SUSPENDED, nc->display);
return MOD_CONT;
@@ -143,10 +143,10 @@ class CommandNSAccess : public Command
}
/*
- else if (na->status & NS_FORBIDDEN)
+ else if (na->HasFlag(NS_FORBIDDEN))
notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
*/
- else if (u->nc->flags & NI_SUSPENDED)
+ else if (u->nc->HasFlag(NI_SUSPENDED))
notice_lang(s_NickServ, u, NICK_X_SUSPENDED, u->nc->display);
else if (cmd == "ADD")
return this->DoAdd(u, u->nc, mask);
diff --git a/src/core/ns_alist.c b/src/core/ns_alist.c
index 628b45c42..f1fc883f9 100644
--- a/src/core/ns_alist.c
+++ b/src/core/ns_alist.c
@@ -83,7 +83,7 @@ class CommandNSAList : public Command
if (!na)
notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
- else if (na->status & NS_FORBIDDEN)
+ else if (na->HasFlag(NS_FORBIDDEN))
notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
else if (min_level <= ACCESS_INVALID || min_level > ACCESS_FOUNDER)
notice_lang(s_NickServ, u, CHAN_ACCESS_LEVEL_RANGE, ACCESS_INVALID + 1, ACCESS_FOUNDER - 1);
@@ -109,16 +109,16 @@ class CommandNSAList : public Command
++match_count;
- if ((ci->flags & CI_XOP) || level == ACCESS_FOUNDER)
+ if ((ci->HasFlag(CI_XOP)) || level == ACCESS_FOUNDER)
{
const char *xop;
xop = get_xop_level(level);
- notice_lang(s_NickServ, u, NICK_ALIST_XOP_FORMAT, match_count, ci->flags & CI_NO_EXPIRE ? '!' : ' ', ci->name, xop, ci->desc ? ci->desc : "");
+ notice_lang(s_NickServ, u, NICK_ALIST_XOP_FORMAT, match_count, ci->HasFlag(CI_NO_EXPIRE) ? '!' : ' ', ci->name, xop, ci->desc ? ci->desc : "");
}
else
- notice_lang(s_NickServ, u, NICK_ALIST_ACCESS_FORMAT, match_count, ci->flags & CI_NO_EXPIRE ? '!' : ' ', ci->name, level, ci->desc ? ci->desc : "");
+ notice_lang(s_NickServ, u, NICK_ALIST_ACCESS_FORMAT, match_count, ci->HasFlag(CI_NO_EXPIRE) ? '!' : ' ', ci->name, level, ci->desc ? ci->desc : "");
}
}
}
diff --git a/src/core/ns_drop.c b/src/core/ns_drop.c
index af51a9bb7..ac17164e7 100644
--- a/src/core/ns_drop.c
+++ b/src/core/ns_drop.c
@@ -69,7 +69,7 @@ class CommandNSDrop : public Command
if (readonly)
notice_lang(s_NickServ, u, READ_ONLY_MODE);
- if (ircd->sqline && (na->status & NS_FORBIDDEN))
+ if (ircd->sqline && (na->HasFlag(NS_FORBIDDEN)))
ircdproto->SendSQLineDel(na->nick);
alog("%s: %s!%s@%s dropped nickname %s (group %s) (e-mail: %s)", s_NickServ, u->nick, u->GetIdent().c_str(), u->host, na->nick, na->nc->display, na->nc->email ? na->nc->email : "none");
diff --git a/src/core/ns_forbid.c b/src/core/ns_forbid.c
index 7e48e767a..5b1232970 100644
--- a/src/core/ns_forbid.c
+++ b/src/core/ns_forbid.c
@@ -55,7 +55,7 @@ class CommandNSForbid : public Command
na = makenick(nick);
if (na)
{
- na->status |= NS_FORBIDDEN;
+ na->SetFlag(NS_FORBIDDEN);
na->last_usermask = sstrdup(u->nick);
if (reason)
na->last_realname = sstrdup(reason);
diff --git a/src/core/ns_getpass.c b/src/core/ns_getpass.c
index 55ff571bf..6cb01c89e 100644
--- a/src/core/ns_getpass.c
+++ b/src/core/ns_getpass.c
@@ -41,7 +41,7 @@ class CommandNSGetPass : public Command
else
notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
}
- else if (na->status & NS_FORBIDDEN)
+ else if (na->HasFlag(NS_FORBIDDEN))
notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
else if (NSSecureAdmins && na->nc->IsServicesOper())
notice_lang(s_NickServ, u, ACCESS_DENIED);
diff --git a/src/core/ns_ghost.c b/src/core/ns_ghost.c
index 19a4c909c..439d3f667 100644
--- a/src/core/ns_ghost.c
+++ b/src/core/ns_ghost.c
@@ -33,9 +33,9 @@ class CommandNSGhost : public Command
notice_lang(s_NickServ, u, NICK_X_NOT_IN_USE, nick);
else if (!na)
notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
- else if (na->status & NS_FORBIDDEN)
+ else if (na->HasFlag(NS_FORBIDDEN))
notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
- else if (na->nc->flags & NI_SUSPENDED)
+ else if (na->nc->HasFlag(NI_SUSPENDED))
notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick);
else if (!stricmp(nick, u->nick))
notice_lang(s_NickServ, u, NICK_NO_GHOST_SELF);
@@ -61,7 +61,7 @@ class CommandNSGhost : public Command
}
else
{
- if (u->nc == na->nc || (!(na->nc->flags & NI_SECURE) && is_on_access(u, na->nc)))
+ if (u->nc == na->nc || (!(na->nc->HasFlag(NI_SECURE)) && is_on_access(u, na->nc)))
{
char buf[NICKMAX + 32];
snprintf(buf, sizeof(buf), "GHOST command used by %s", u->nick);
diff --git a/src/core/ns_group.c b/src/core/ns_group.c
index 47499bd75..5d4bc3bec 100644
--- a/src/core/ns_group.c
+++ b/src/core/ns_group.c
@@ -68,17 +68,17 @@ class CommandNSGroup : public Command
notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
else if (time(NULL) < u->lastnickreg + NSRegDelay)
notice_lang(s_NickServ, u, NICK_GROUP_PLEASE_WAIT, (NSRegDelay + u->lastnickreg) - time(NULL));
- else if (u->nc && (u->nc->flags & NI_SUSPENDED))
+ else if (u->nc && (u->nc->HasFlag(NI_SUSPENDED)))
{
alog("%s: %s!%s@%s tried to use GROUP from SUSPENDED nick %s", s_NickServ, u->nick, u->GetIdent().c_str(), u->host, target->nick);
notice_lang(s_NickServ, u, NICK_X_SUSPENDED, u->nick);
}
- else if (target && (target->nc->flags & NI_SUSPENDED))
+ else if (target && (target->nc->HasFlag(NI_SUSPENDED)))
{
alog("%s: %s!%s@%s tried to use GROUP from SUSPENDED nick %s", s_NickServ, u->nick, u->GetIdent().c_str(), u->host, target->nick);
notice_lang(s_NickServ, u, NICK_X_SUSPENDED, target->nick);
}
- else if (target->status & NS_FORBIDDEN)
+ else if (target->HasFlag(NS_FORBIDDEN))
notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, nick);
else if (u->nc && (target->nc == u->nc))
notice_lang(s_NickServ, u, NICK_GROUP_SAME, target->nick);
@@ -168,7 +168,7 @@ class CommandNSGList : public Command
notice_lang(s_NickServ, u, ACCESS_DENIED, s_NickServ);
else if (nick && (!findnick(nick) || !(nc = findnick(nick)->nc)))
notice_lang(s_NickServ, u, !nick ? NICK_NOT_REGISTERED : NICK_X_NOT_REGISTERED, nick);
-/* else if (na->status & NS_FORBIDDEN)
+/* else if (na->HasFlag(NS_FORBIDDEN))
notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);*/
else
{
@@ -183,7 +183,7 @@ class CommandNSGList : public Command
NickAlias *na2 = static_cast<NickAlias *>(nc->aliases.list[i]);
if (na2->nc == nc)
{
- if (!(wont_expire = na2->status & NS_NO_EXPIRE))
+ if (!(wont_expire = na2->HasFlag(NS_NO_EXPIRE)))
{
expt = na2->last_seen + NSExpire;
tm = localtime(&expt);
@@ -237,7 +237,6 @@ NickAlias *makealias(const char *nick, NickCore *nc)
na = new NickAlias;
na->nick = sstrdup(nick);
na->nc = nc;
- na->status = 0;
slist_add(&nc->aliases, na);
alpha_insert_alias(na);
return na;
diff --git a/src/core/ns_identify.c b/src/core/ns_identify.c
index 9ae7f3a35..bd2359ab0 100644
--- a/src/core/ns_identify.c
+++ b/src/core/ns_identify.c
@@ -40,9 +40,9 @@ class CommandNSIdentify : public Command
else
notice_lang(s_NickServ, u, NICK_NOT_REGISTERED);
}
- else if (na->status & NS_FORBIDDEN)
+ else if (na->HasFlag(NS_FORBIDDEN))
notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
- else if (na->nc->flags & NI_SUSPENDED)
+ else if (na->nc->HasFlag(NI_SUSPENDED))
notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick);
/* You can now identify for other nicks without logging out first,
* however you can not identify again for the group you're already
@@ -94,7 +94,7 @@ class CommandNSIdentify : public Command
check_memos(u);
/* Clear any timers */
- if (na->nc->flags & NI_KILLPROTECT)
+ if (na->nc->HasFlag(NI_KILLPROTECT))
del_ns_timeout(na, TO_COLLIDE);
}
return MOD_CONT;
diff --git a/src/core/ns_info.c b/src/core/ns_info.c
index 3e241b787..fe7b2e00c 100644
--- a/src/core/ns_info.c
+++ b/src/core/ns_info.c
@@ -19,9 +19,9 @@ class CommandNSInfo : public Command
{
private:
// cannot be const, as it is modified
- void CheckOptStr(std::string &buf, int opt, const std::string &str, NickCore *nc, bool reverse_logic = false)
+ void CheckOptStr(std::string &buf, NickCoreFlag opt, const std::string &str, NickCore *nc, bool reverse_logic = false)
{
- if (reverse_logic ? !(nc->flags & opt) : (nc->flags & opt))
+ if (reverse_logic ? !nc->HasFlag(opt) : nc->HasFlag(opt))
{
const char *commastr = getstring(nc, COMMA_SPACE);
if (!buf.empty())
@@ -69,7 +69,7 @@ class CommandNSInfo : public Command
else
notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
}
- else if (na->status & NS_FORBIDDEN)
+ else if (na->HasFlag(NS_FORBIDDEN))
{
if (is_oper(u) && na->last_usermask)
notice_lang(s_NickServ, u, NICK_X_FORBIDDEN_OPER, nick, na->last_usermask, na->last_realname ? na->last_realname : getstring(u, NO_REASON));
@@ -97,7 +97,7 @@ class CommandNSInfo : public Command
if (na->nc->IsServicesOper())
{
- if (show_hidden || (!(na->nc->flags & NI_HIDE_STATUS)))
+ if (show_hidden || (!(na->nc->HasFlag(NI_HIDE_STATUS))))
{
notice_lang(s_NickServ, u, NICK_INFO_SERVICES_OPERTYPE, na->nick, na->nc->ot->GetName().c_str());
@@ -106,13 +106,13 @@ class CommandNSInfo : public Command
if (nick_online)
{
- if (show_hidden || !(na->nc->flags & NI_HIDE_MASK))
+ if (show_hidden || !(na->nc->HasFlag(NI_HIDE_MASK)))
notice_lang(s_NickServ, u, NICK_INFO_ADDRESS_ONLINE, na->last_usermask);
else
notice_lang(s_NickServ, u, NICK_INFO_ADDRESS_ONLINE_NOHOST, na->nick);
}
else {
- if (show_hidden || !(na->nc->flags & NI_HIDE_MASK))
+ if (show_hidden || !(na->nc->HasFlag(NI_HIDE_MASK)))
notice_lang(s_NickServ, u, NICK_INFO_ADDRESS, na->last_usermask);
}
@@ -127,12 +127,12 @@ class CommandNSInfo : public Command
notice_lang(s_NickServ, u, NICK_INFO_LAST_SEEN, buf);
}
- if (na->last_quit && (show_hidden || !(na->nc->flags & NI_HIDE_QUIT)))
+ if (na->last_quit && (show_hidden || !(na->nc->HasFlag(NI_HIDE_QUIT))))
notice_lang(s_NickServ, u, NICK_INFO_LAST_QUIT, na->last_quit);
if (na->nc->url)
notice_lang(s_NickServ, u, NICK_INFO_URL, na->nc->url);
- if (na->nc->email && (show_hidden || !(na->nc->flags & NI_HIDE_EMAIL)))
+ if (na->nc->email && (show_hidden || !(na->nc->HasFlag(NI_HIDE_EMAIL))))
notice_lang(s_NickServ, u, NICK_INFO_EMAIL, na->nc->email);
if (na->nc->icq)
notice_lang(s_NickServ, u, NICK_INFO_ICQ, na->nc->icq);
@@ -164,7 +164,7 @@ class CommandNSInfo : public Command
notice_lang(s_NickServ, u, NICK_INFO_OPTIONS, optbuf.empty() ? getstring(u, NICK_INFO_OPT_NONE) : optbuf.c_str());
- if (na->nc->flags & NI_SUSPENDED)
+ if (na->nc->HasFlag(NI_SUSPENDED))
{
if (na->last_quit)
notice_lang(s_NickServ, u, NICK_INFO_SUSPENDED, na->last_quit);
@@ -172,7 +172,7 @@ class CommandNSInfo : public Command
notice_lang(s_NickServ, u, NICK_INFO_SUSPENDED_NO_REASON);
}
- if (na->status & NS_NO_EXPIRE)
+ if (na->HasFlag(NS_NO_EXPIRE))
notice_lang(s_NickServ, u, NICK_INFO_NO_EXPIRE);
else
{
diff --git a/src/core/ns_list.c b/src/core/ns_list.c
index f32a3460f..0c964366d 100644
--- a/src/core/ns_list.c
+++ b/src/core/ns_list.c
@@ -44,14 +44,14 @@ class CommandNSList : public Command
unsigned nnicks, i;
char buf[BUFSIZE];
bool is_servadmin = u->nc->IsServicesOper();
- int16 matchflags = 0;
NickRequest *nr = NULL;
- int nronly = 0;
- int susp_keyword = 0;
char noexpire_char = ' ';
int count = 0, from = 0, to = 0, tofree = 0;
char *tmp = NULL;
char *s = NULL;
+ bool suspended, nsnoexpire, forbidden, unconfirmed;
+
+ suspended = nsnoexpire = forbidden = unconfirmed = false;
if (NSListOpersOnly && !is_oper(u)) /* reverse the help logic */
{
@@ -109,52 +109,54 @@ class CommandNSList : public Command
{
ci::string keyword_ci = keyword.c_str();
if (keyword_ci == "FORBIDDEN")
- matchflags |= NS_FORBIDDEN;
+ forbidden = true;
if (keyword_ci == "NOEXPIRE")
- matchflags |= NS_NO_EXPIRE;
+ nsnoexpire = true;
if (keyword_ci == "SUSPENDED")
- susp_keyword = 1;
+ suspended = true;
if (keyword_ci == "UNCONFIRMED")
- nronly = 1;
+ unconfirmed = true;
}
}
mync = u->nc;
notice_lang(s_NickServ, u, NICK_LIST_HEADER, pattern);
- if (!nronly)
+ if (!unconfirmed)
{
for (i = 0; i < 1024; ++i)
{
for (na = nalists[i]; na; na = na->next)
{
/* Don't show private and forbidden nicks to non-services admins. */
- if ((na->status & NS_FORBIDDEN) && !is_servadmin)
+ if ((na->HasFlag(NS_FORBIDDEN)) && !is_servadmin)
+ continue;
+ if ((na->nc->HasFlag(NI_PRIVATE)) && !is_servadmin && na->nc != mync)
continue;
- if ((na->nc->flags & NI_PRIVATE) && !is_servadmin && na->nc != mync)
+ if (forbidden && !na->HasFlag(NS_FORBIDDEN))
continue;
- if (matchflags && !(na->status & matchflags) && !susp_keyword)
+ else if (nsnoexpire && !na->HasFlag(NS_NO_EXPIRE))
continue;
- else if (susp_keyword && !(na->nc->flags & NI_SUSPENDED))
+ else if (suspended && !na->nc->HasFlag(NI_SUSPENDED))
continue;
/* We no longer compare the pattern against the output buffer.
* Instead we build a nice nick!user@host buffer to compare.
* The output is then generated separately. -TheShadow */
- snprintf(buf, sizeof(buf), "%s!%s", na->nick, na->last_usermask && !(na->status & NS_FORBIDDEN) ? na->last_usermask : "*@*");
+ snprintf(buf, sizeof(buf), "%s!%s", na->nick, na->last_usermask && !(na->HasFlag(NS_FORBIDDEN)) ? na->last_usermask : "*@*");
if (!stricmp(pattern, na->nick) || Anope::Match(buf, pattern, false))
{
if (((count + 1 >= from && count + 1 <= to) || (!from && !to)) && ++nnicks <= NSListMax)
{
- if (is_servadmin && (na->status & NS_NO_EXPIRE))
+ if (is_servadmin && (na->HasFlag(NS_NO_EXPIRE)))
noexpire_char = '!';
else
noexpire_char = ' ';
- if ((na->nc->flags & NI_HIDE_MASK) && !is_servadmin && na->nc != mync)
+ if ((na->nc->HasFlag(NI_HIDE_MASK)) && !is_servadmin && na->nc != mync)
snprintf(buf, sizeof(buf), "%-20s [Hostname Hidden]", na->nick);
- else if (na->status & NS_FORBIDDEN)
+ else if (na->HasFlag(NS_FORBIDDEN))
snprintf(buf, sizeof(buf), "%-20s [Forbidden]", na->nick);
- else if (na->nc->flags & NI_SUSPENDED)
+ else if (na->nc->HasFlag(NI_SUSPENDED))
snprintf(buf, sizeof(buf), "%-20s [Suspended]", na->nick);
else
snprintf(buf, sizeof(buf), "%-20s %s", na->nick, na->last_usermask);
@@ -166,7 +168,7 @@ class CommandNSList : public Command
}
}
- if (nronly || (is_servadmin && !matchflags))
+ if (unconfirmed || is_servadmin)
{
noexpire_char = ' ';
for (i = 0; i < 1024; ++i)
diff --git a/src/core/ns_logout.c b/src/core/ns_logout.c
index a4d051e47..a4716be8f 100644
--- a/src/core/ns_logout.c
+++ b/src/core/ns_logout.c
@@ -61,7 +61,7 @@ class CommandNSLogout : public Command
notice_lang(s_NickServ, u, NICK_LOGOUT_SUCCEEDED);
/* Clear any timers again */
- if (na && u->nc->flags & NI_KILLPROTECT)
+ if (na && u->nc->HasFlag(NI_KILLPROTECT))
del_ns_timeout(na, TO_COLLIDE);
ircdproto->SendAccountLogout(u2, u2->nc);
diff --git a/src/core/ns_recover.c b/src/core/ns_recover.c
index 45bacf206..a0b486fb2 100644
--- a/src/core/ns_recover.c
+++ b/src/core/ns_recover.c
@@ -34,9 +34,9 @@ class CommandNSRecover : public Command
notice_lang(s_NickServ, u, NICK_X_NOT_IN_USE, nick);
else if (!(na = findnick(u2->nick)))
notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
- else if (na->status & NS_FORBIDDEN)
+ else if (na->HasFlag(NS_FORBIDDEN))
notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
- else if (na->nc->flags & NI_SUSPENDED)
+ else if (na->nc->HasFlag(NI_SUSPENDED))
notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick);
else if (!stricmp(nick, u->nick))
notice_lang(s_NickServ, u, NICK_NO_RECOVER_SELF);
@@ -68,7 +68,7 @@ class CommandNSRecover : public Command
}
else
{
- if (u->nc == na->nc || (!(na->nc->flags & NI_SECURE) && is_on_access(u, na->nc)))
+ if (u->nc == na->nc || (!(na->nc->HasFlag(NI_SECURE)) && is_on_access(u, na->nc)))
{
char relstr[192];
diff --git a/src/core/ns_register.c b/src/core/ns_register.c
index f0d4c693f..e2ef9f02d 100644
--- a/src/core/ns_register.c
+++ b/src/core/ns_register.c
@@ -38,8 +38,6 @@ class CommandNSConfirm : public Command
memcpy(na->nc->pass, nr->password, PASSMAX);
- na->nc->flags |= NSDefFlags;
-
na->nc->memos.memomax = MSMaxMemos;
if (force)
@@ -251,7 +249,7 @@ class CommandNSRegister : public CommandNSConfirm
else if ((na = findnick(u->nick)))
{
/* i.e. there's already such a nick regged */
- if (na->status & NS_FORBIDDEN)
+ if (na->HasFlag(NS_FORBIDDEN))
{
alog("%s: %s@%s tried to register FORBIDden nick %s", s_NickServ, u->GetIdent().c_str(), u->host, u->nick);
notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, u->nick);
@@ -415,7 +413,6 @@ NickAlias *makenick(const char *nick)
na = new NickAlias;
na->nick = sstrdup(nick);
na->nc = nc;
- na->status = 0;
slist_add(&nc->aliases, na);
alpha_insert_alias(na);
return na;
diff --git a/src/core/ns_release.c b/src/core/ns_release.c
index 75a508aa3..b1c040007 100644
--- a/src/core/ns_release.c
+++ b/src/core/ns_release.c
@@ -31,11 +31,11 @@ class CommandNSRelease : public Command
if (!(na = findnick(nick)))
notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
- else if (na->status & NS_FORBIDDEN)
+ else if (na->HasFlag(NS_FORBIDDEN))
notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
- else if (na->nc->flags & NI_SUSPENDED)
+ else if (na->nc->HasFlag(NI_SUSPENDED))
notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick);
- else if (!(na->status & NS_KILL_HELD))
+ else if (!(na->HasFlag(NS_KILL_HELD)))
notice_lang(s_NickServ, u, NICK_RELEASE_NOT_HELD, nick);
else if (pass)
{
@@ -57,7 +57,7 @@ class CommandNSRelease : public Command
}
else
{
- if (u->nc == na->nc || (!(na->nc->flags & NI_SECURE) && is_on_access(u, na->nc)))
+ if (u->nc == na->nc || (!(na->nc->HasFlag(NI_SECURE)) && is_on_access(u, na->nc)))
{
release(na, 0);
notice_lang(s_NickServ, u, NICK_RELEASED);
diff --git a/src/core/ns_saset.c b/src/core/ns_saset.c
index 83b91c0b9..9ad4424f4 100644
--- a/src/core/ns_saset.c
+++ b/src/core/ns_saset.c
@@ -219,22 +219,25 @@ private:
if (param == "ON")
{
- nc->flags |= NI_KILLPROTECT;
- nc->flags &= ~(NI_KILL_QUICK | NI_KILL_IMMED);
+ nc->SetFlag(NI_KILLPROTECT);
+ nc->UnsetFlag(NI_KILL_QUICK);
+ nc->UnsetFlag(NI_KILL_IMMED);
notice_lang(s_NickServ, u, NICK_SASET_KILL_ON, nc->display);
}
else if (param == "QUICK")
{
- nc->flags |= NI_KILLPROTECT | NI_KILL_QUICK;
- nc->flags &= ~NI_KILL_IMMED;
+ nc->SetFlag(NI_KILLPROTECT);
+ nc->SetFlag(NI_KILL_QUICK);
+ nc->UnsetFlag(NI_KILL_IMMED);
notice_lang(s_NickServ, u, NICK_SASET_KILL_QUICK, nc->display);
}
else if (param == "IMMED")
{
if (NSAllowKillImmed)
{
- nc->flags |= NI_KILLPROTECT | NI_KILL_IMMED;
- nc->flags &= ~NI_KILL_QUICK;
+ nc->SetFlag(NI_KILLPROTECT);
+ nc->SetFlag(NI_KILL_IMMED);
+ nc->UnsetFlag(NI_KILL_QUICK);
notice_lang(s_NickServ, u, NICK_SASET_KILL_IMMED, nc->display);
}
else
@@ -242,7 +245,9 @@ private:
}
else if (param == "OFF")
{
- nc->flags &= ~(NI_KILLPROTECT | NI_KILL_QUICK | NI_KILL_IMMED);
+ nc->UnsetFlag(NI_KILLPROTECT);
+ nc->UnsetFlag(NI_KILL_QUICK);
+ nc->UnsetFlag(NI_KILL_IMMED);
notice_lang(s_NickServ, u, NICK_SASET_KILL_OFF, nc->display);
}
else
@@ -262,12 +267,12 @@ private:
if (param == "ON")
{
- nc->flags |= NI_SECURE;
+ nc->SetFlag(NI_SECURE);
notice_lang(s_NickServ, u, NICK_SASET_SECURE_ON, nc->display);
}
else if (param == "OFF")
{
- nc->flags &= ~NI_SECURE;
+ nc->UnsetFlag(NI_SECURE);
notice_lang(s_NickServ, u, NICK_SASET_SECURE_OFF, nc->display);
}
else
@@ -287,12 +292,12 @@ private:
if (param == "ON")
{
- nc->flags |= NI_PRIVATE;
+ nc->SetFlag(NI_PRIVATE);
notice_lang(s_NickServ, u, NICK_SASET_PRIVATE_ON, nc->display);
}
else if (param == "OFF")
{
- nc->flags &= ~NI_PRIVATE;
+ nc->UnsetFlag(NI_PRIVATE);
notice_lang(s_NickServ, u, NICK_SASET_PRIVATE_OFF, nc->display);
}
else
@@ -318,12 +323,12 @@ private:
if (param == "ON")
{
- nc->flags |= NI_MSG;
+ nc->SetFlag(NI_MSG);
notice_lang(s_NickServ, u, NICK_SASET_MSG_ON, nc->display);
}
else if (param == "OFF")
{
- nc->flags &= ~NI_MSG;
+ nc->UnsetFlag(NI_MSG);
notice_lang(s_NickServ, u, NICK_SASET_MSG_OFF, nc->display);
}
else
@@ -341,7 +346,8 @@ private:
return MOD_CONT;
}
- int flag, onmsg, offmsg;
+ int onmsg, offmsg;
+ NickCoreFlag flag;
if (param == "EMAIL")
{
@@ -378,12 +384,12 @@ private:
syntax_error(s_NickServ, u, "SASET HIDE", NICK_SASET_HIDE_SYNTAX);
else if (param == "ON")
{
- nc->flags |= flag;
+ nc->SetFlag(flag);
notice_lang(s_NickServ, u, onmsg, nc->display, s_NickServ);
}
else if (param == "OFF")
{
- nc->flags &= ~flag;
+ nc->UnsetFlag(flag);
notice_lang(s_NickServ, u, offmsg, nc->display, s_NickServ);
}
else
@@ -403,12 +409,12 @@ private:
if (param == "ON")
{
- na->status |= NS_NO_EXPIRE;
+ na->SetFlag(NS_NO_EXPIRE);
notice_lang(s_NickServ, u, NICK_SASET_NOEXPIRE_ON, na->nick);
}
else if (param == "OFF")
{
- na->status &= ~NS_NO_EXPIRE;
+ na->UnsetFlag(NS_NO_EXPIRE);
notice_lang(s_NickServ, u, NICK_SASET_NOEXPIRE_OFF, na->nick);
}
else
@@ -428,12 +434,12 @@ private:
if (param == "ON")
{
- nc->flags &= ~NI_AUTOOP;
+ nc->UnsetFlag(NI_AUTOOP);
notice_lang(s_NickServ, u, NICK_SASET_AUTOOP_ON, nc->display);
}
else if (param == "OFF")
{
- nc->flags |= NI_AUTOOP;
+ nc->SetFlag(NI_AUTOOP);
notice_lang(s_NickServ, u, NICK_SASET_AUTOOP_OFF, nc->display);
}
else
@@ -493,9 +499,9 @@ public:
return MOD_CONT;
}
- if (na->status & NS_FORBIDDEN)
+ if (na->HasFlag(NS_FORBIDDEN))
notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
- else if (na->nc->flags & NI_SUSPENDED)
+ else if (na->nc->HasFlag(NI_SUSPENDED))
notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick);
else if (cmd == "DISPLAY")
return this->DoSetDisplay(u, params, na->nc);
diff --git a/src/core/ns_sendpass.c b/src/core/ns_sendpass.c
index e8b91f919..6eb2ec71a 100644
--- a/src/core/ns_sendpass.c
+++ b/src/core/ns_sendpass.c
@@ -31,7 +31,7 @@ class CommandNSSendPass : public Command
notice_lang(s_NickServ, u, ACCESS_DENIED);
else if (!(na = findnick(nick)))
notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
- else if (na->status & NS_FORBIDDEN)
+ else if (na->HasFlag(NS_FORBIDDEN))
notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
else
{
diff --git a/src/core/ns_set.c b/src/core/ns_set.c
index 6b3e39d5b..1521ff90d 100644
--- a/src/core/ns_set.c
+++ b/src/core/ns_set.c
@@ -237,22 +237,25 @@ class CommandNSSet : public Command
if (param == "ON")
{
- nc->flags |= NI_KILLPROTECT;
- nc->flags &= ~(NI_KILL_QUICK | NI_KILL_IMMED);
+ nc->SetFlag(NI_KILLPROTECT);
+ nc->UnsetFlag(NI_KILL_QUICK);
+ nc->UnsetFlag(NI_KILL_IMMED);
notice_lang(s_NickServ, u, NICK_SET_KILL_ON);
}
else if (param == "QUICK")
{
- nc->flags |= NI_KILLPROTECT | NI_KILL_QUICK;
- nc->flags &= ~NI_KILL_IMMED;
+ nc->SetFlag(NI_KILLPROTECT);
+ nc->SetFlag(NI_KILL_QUICK);
+ nc->UnsetFlag(NI_KILL_IMMED);
notice_lang(s_NickServ, u, NICK_SET_KILL_QUICK);
}
else if (param == "IMMED")
{
if (NSAllowKillImmed)
{
- nc->flags |= NI_KILLPROTECT | NI_KILL_IMMED;
- nc->flags &= ~NI_KILL_QUICK;
+ nc->SetFlag(NI_KILLPROTECT);
+ nc->SetFlag(NI_KILL_IMMED);
+ nc->UnsetFlag(NI_KILL_QUICK);
notice_lang(s_NickServ, u, NICK_SET_KILL_IMMED);
}
else
@@ -260,7 +263,9 @@ class CommandNSSet : public Command
}
else if (param == "OFF")
{
- nc->flags &= ~(NI_KILLPROTECT | NI_KILL_QUICK | NI_KILL_IMMED);
+ nc->UnsetFlag(NI_KILLPROTECT);
+ nc->UnsetFlag(NI_KILL_QUICK);
+ nc->UnsetFlag(NI_KILL_IMMED);
notice_lang(s_NickServ, u, NICK_SET_KILL_OFF);
}
else
@@ -280,12 +285,12 @@ class CommandNSSet : public Command
if (param == "ON")
{
- nc->flags |= NI_SECURE;
+ nc->SetFlag(NI_SECURE);
notice_lang(s_NickServ, u, NICK_SET_SECURE_ON);
}
else if (param == "OFF")
{
- nc->flags &= ~NI_SECURE;
+ nc->UnsetFlag(NI_SECURE);
notice_lang(s_NickServ, u, NICK_SET_SECURE_OFF);
}
else
@@ -305,12 +310,12 @@ class CommandNSSet : public Command
if (param == "ON")
{
- nc->flags |= NI_PRIVATE;
+ nc->SetFlag(NI_PRIVATE);
notice_lang(s_NickServ, u, NICK_SET_PRIVATE_ON);
}
else if (param == "OFF")
{
- nc->flags &= ~NI_PRIVATE;
+ nc->UnsetFlag(NI_PRIVATE);
notice_lang(s_NickServ, u, NICK_SET_PRIVATE_OFF);
}
else
@@ -336,12 +341,12 @@ class CommandNSSet : public Command
if (param == "ON")
{
- nc->flags |= NI_MSG;
+ nc->SetFlag(NI_MSG);
notice_lang(s_NickServ, u, NICK_SET_MSG_ON);
}
else if (param == "OFF")
{
- nc->flags &= ~NI_MSG;
+ nc->UnsetFlag(NI_MSG);
notice_lang(s_NickServ, u, NICK_SET_MSG_OFF);
}
else
@@ -359,7 +364,8 @@ class CommandNSSet : public Command
return MOD_CONT;
}
- int flag, onmsg, offmsg;
+ int onmsg, offmsg;
+ NickCoreFlag flag;
if (param == "EMAIL")
{
@@ -396,12 +402,12 @@ class CommandNSSet : public Command
syntax_error(s_NickServ, u, "SET HIDE", NICK_SET_HIDE_SYNTAX);
else if (param == "ON")
{
- nc->flags |= flag;
+ nc->SetFlag(flag);
notice_lang(s_NickServ, u, onmsg, s_NickServ);
}
else if (param == "OFF")
{
- nc->flags &= ~flag;
+ nc->UnsetFlag(flag);
notice_lang(s_NickServ, u, offmsg, s_NickServ);
}
else
@@ -426,12 +432,12 @@ class CommandNSSet : public Command
**/
if (param == "ON")
{
- nc->flags &= ~NI_AUTOOP;
+ nc->UnsetFlag(NI_AUTOOP);
notice_lang(s_NickServ, u, NICK_SET_AUTOOP_ON);
}
else if (param == "OFF")
{
- nc->flags |= NI_AUTOOP;
+ nc->SetFlag(NI_AUTOOP);
notice_lang(s_NickServ, u, NICK_SET_AUTOOP_OFF);
}
else
@@ -455,10 +461,10 @@ class CommandNSSet : public Command
}
/*
- if (na->status & NS_FORBIDDEN)
+ if (na->HasFlag(NS_FORBIDDEN))
notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
*/
- if (u->nc->flags & NI_SUSPENDED)
+ if (u->nc->HasFlag(NI_SUSPENDED))
notice_lang(s_NickServ, u, NICK_X_SUSPENDED, u->nc->display);
else if (cmd == "DISPLAY")
return this->DoSetDisplay(u, params, u->nc);
diff --git a/src/core/ns_suspend.c b/src/core/ns_suspend.c
index 0b1adcf2e..b7394ff25 100644
--- a/src/core/ns_suspend.c
+++ b/src/core/ns_suspend.c
@@ -42,7 +42,7 @@ class CommandNSSuspend : public Command
return MOD_CONT;
}
- if (na->status & NS_FORBIDDEN)
+ if (na->HasFlag(NS_FORBIDDEN))
{
notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
return MOD_CONT;
@@ -56,9 +56,11 @@ class CommandNSSuspend : public Command
if (na)
{
- na->nc->flags |= NI_SUSPENDED;
- na->nc->flags |= NI_SECURE;
- na->nc->flags &= ~(NI_KILLPROTECT | NI_KILL_QUICK | NI_KILL_IMMED);
+ na->nc->SetFlag(NI_SUSPENDED);
+ na->nc->SetFlag(NI_SECURE);
+ na->nc->UnsetFlag(NI_KILLPROTECT);
+ na->nc->UnsetFlag(NI_KILL_QUICK);
+ na->nc->UnsetFlag(NI_KILL_IMMED);
for (i = 0; i < na->nc->aliases.count; ++i)
{
@@ -128,7 +130,7 @@ class CommandNSUnSuspend : public Command
return MOD_CONT;
}
- if (na->status & NS_FORBIDDEN)
+ if (na->HasFlag(NS_FORBIDDEN))
{
notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
return MOD_CONT;
@@ -142,7 +144,7 @@ class CommandNSUnSuspend : public Command
if (na)
{
- na->nc->flags &= ~NI_SUSPENDED;
+ na->nc->UnsetFlag(NI_SUSPENDED);
if (WallForbid)
ircdproto->SendGlobops(s_NickServ, "\2%s\2 used UNSUSPEND on \2%s\2", u->nick, nick);
diff --git a/src/core/os_jupe.c b/src/core/os_jupe.c
index f3910dfff..43dc1f89b 100644
--- a/src/core/os_jupe.c
+++ b/src/core/os_jupe.c
@@ -30,7 +30,7 @@ class CommandOSJupe : public Command
if (!isValidHost(jserver, 3))
notice_lang(s_OperServ, u, OPER_JUPE_HOST_ERROR);
- else if (server && ((server->flags & SERVER_ISME) || (server->flags & SERVER_ISUPLINK)))
+ else if (server && (server->HasFlag(SERVER_ISME) || server->HasFlag(SERVER_ISUPLINK)))
notice_lang(s_OperServ, u, OPER_JUPE_INVALID_SERVER);
else {
char rbuf[256];
diff --git a/src/core/os_svsnick.c b/src/core/os_svsnick.c
index a80eff44d..19718a6e4 100644
--- a/src/core/os_svsnick.c
+++ b/src/core/os_svsnick.c
@@ -58,7 +58,7 @@ class CommandOSSVSNick : public Command
notice_lang(s_OperServ, u, NICK_X_NOT_IN_USE, nick);
else if (finduser(newnick))
notice_lang(s_OperServ, u, NICK_X_IN_USE, newnick);
- else if ((na = findnick(newnick)) && (na->status & NS_FORBIDDEN))
+ else if ((na = findnick(newnick)) && (na->HasFlag(NS_FORBIDDEN)))
notice_lang(s_OperServ, u, NICK_X_FORBIDDEN, newnick);
else
{
diff --git a/src/language.c b/src/language.c
index 13df53807..d8adc96c5 100644
--- a/src/language.c
+++ b/src/language.c
@@ -312,7 +312,7 @@ const char *getstring(NickAlias *na, int index)
int langidx = NSDefLanguage;
// If they are registered (na->nc), and NOT forbidden
- if (na && na->nc && !(na->status & NS_FORBIDDEN))
+ if (na && na->nc && !na->HasFlag(NS_FORBIDDEN))
langidx = na->nc->language; // set language to their nickcore's language
return langtexts[langidx][index];
diff --git a/src/memoserv.c b/src/memoserv.c
index 6358ad6ef..f1bbda347 100644
--- a/src/memoserv.c
+++ b/src/memoserv.c
@@ -91,23 +91,23 @@ void check_memos(User * u)
}
if (!(nc = u->nc) || !u->IsRecognized() ||
- !(nc->flags & NI_MEMO_SIGNON)) {
+ !(nc->HasFlag(NI_MEMO_SIGNON))) {
return;
}
for (i = 0; i < nc->memos.memos.size(); i++) {
- if (nc->memos.memos[i]->flags & MF_UNREAD)
+ if (nc->memos.memos[i]->HasFlag(MF_UNREAD))
newcnt++;
}
if (newcnt > 0) {
notice_lang(s_MemoServ, u,
newcnt == 1 ? MEMO_HAVE_NEW_MEMO : MEMO_HAVE_NEW_MEMOS,
newcnt);
- if (newcnt == 1 && (nc->memos.memos[i - 1]->flags & MF_UNREAD)) {
+ if (newcnt == 1 && (nc->memos.memos[i - 1]->HasFlag(MF_UNREAD))) {
notice_lang(s_MemoServ, u, MEMO_TYPE_READ_LAST, s_MemoServ);
} else if (newcnt == 1) {
for (i = 0; i < nc->memos.memos.size(); i++) {
- if (nc->memos.memos[i]->flags & MF_UNREAD)
+ if (nc->memos.memos[i]->HasFlag(MF_UNREAD))
break;
}
notice_lang(s_MemoServ, u, MEMO_TYPE_READ_NUM, s_MemoServ,
@@ -144,7 +144,7 @@ MemoInfo *getmemoinfo(const char *name, int *ischan, int *isforbid)
*ischan = 1;
ci = cs_findchan(name);
if (ci) {
- if (!(ci->flags & CI_FORBIDDEN)) {
+ if (!(ci->HasFlag(CI_FORBIDDEN))) {
*isforbid = 0;
return &ci->memos;
} else {
@@ -161,7 +161,7 @@ MemoInfo *getmemoinfo(const char *name, int *ischan, int *isforbid)
*ischan = 0;
na = findnick(name);
if (na) {
- if (!(na->status & NS_FORBIDDEN)) {
+ if (!na->HasFlag(NS_FORBIDDEN)) {
*isforbid = 0;
return &na->nc->memos;
} else {
@@ -261,14 +261,14 @@ void memo_send(User * u, const char *name, const char *text, int z)
}
m->time = time(NULL);
m->text = sstrdup(text);
- m->flags = MF_UNREAD;
+ m->SetFlag(MF_UNREAD);
/* Set notify sent flag - DrStein */
if (z == 2) {
- m->flags |= MF_NOTIFYS;
+ m->SetFlag(MF_NOTIFYS);
}
/* Set receipt request flag */
if (z == 3)
- m->flags |= MF_RECEIPT;
+ m->SetFlag(MF_RECEIPT);
if (z == 0 || z == 3)
notice_lang(s_MemoServ, u, MEMO_SENT, name);
if (!ischan) {
@@ -276,7 +276,7 @@ void memo_send(User * u, const char *name, const char *text, int z)
NickCore *nc = (findnick(name))->nc;
if (MSNotifyAll) {
- if ((nc->flags & NI_MEMO_RECEIVE)
+ if ((nc->HasFlag(NI_MEMO_RECEIVE))
&& get_ignore(name) == NULL) {
int i;
@@ -289,14 +289,14 @@ void memo_send(User * u, const char *name, const char *text, int z)
}
} else {
if ((u = finduser(name)) && nick_identified(u)
- && (nc->flags & NI_MEMO_RECEIVE))
+ && (nc->HasFlag(NI_MEMO_RECEIVE)))
notice_lang(s_MemoServ, u, MEMO_NEW_MEMO_ARRIVED,
source, s_MemoServ, m->number);
} /* if (flags & MEMO_RECEIVE) */
}
/* if (MSNotifyAll) */
/* let's get out the mail if set in the nickcore - certus */
- if (nc->flags & NI_MEMO_MAIL)
+ if (nc->HasFlag(NI_MEMO_MAIL))
new_memo_mail(nc, m);
} else {
struct c_userlist *cu, *next;
@@ -307,7 +307,7 @@ void memo_send(User * u, const char *name, const char *text, int z)
next = cu->next;
if (check_access(cu->user, c->ci, CA_MEMO)) {
if (cu->user->nc
- && (cu->user->nc->flags & NI_MEMO_RECEIVE)
+ && (cu->user->nc->HasFlag(NI_MEMO_RECEIVE))
&& get_ignore(cu->user->nick) == NULL) {
notice_lang(s_MemoServ, cu->user,
MEMO_NEW_X_MEMO_ARRIVED,
@@ -422,7 +422,7 @@ void rsend_notify(User * u, Memo * m, const char *chan)
}
/* Remove receipt flag from the original memo */
- m->flags &= ~MF_RECEIPT;
+ m->UnsetFlag(MF_RECEIPT);
return;
}
diff --git a/src/messages.c b/src/messages.c
index 9977de75e..67377a0da 100644
--- a/src/messages.c
+++ b/src/messages.c
@@ -130,7 +130,7 @@ int m_privmsg(const char *source, const char *receiver, const char *msg)
if (*receiver == '#') {
if (s_BotServ && (ci = cs_findchan(receiver))) {
/* Some paranoia checks */
- if (!(ci->flags & CI_FORBIDDEN) && ci->c && ci->bi) {
+ if (!ci->HasFlag(CI_FORBIDDEN) && ci->c && ci->bi) {
botchanmsgs(u, ci, const_cast<char *>(msg)); // XXX Unsafe cast, this needs reviewing -- CyberBotX
}
}
@@ -313,8 +313,7 @@ int m_whois(const char *source, const char *who)
ircdproto->SendNumeric(ServerName, 317, source, "%s %ld %ld :seconds idle, signon time", bi->nick, time(NULL) - bi->lastmsg, start_time);
ircdproto->SendNumeric(ServerName, 318, source, "%s :End of /WHOIS list.", who);
return MOD_CONT;
- } else if (!ircd->svshold && (na = findnick(who))
- && (na->status & NS_KILL_HELD)) {
+ } else if (!ircd->svshold && (na = findnick(who)) && na->HasFlag(NS_KILL_HELD)) {
/* We have a nick enforcer client here that we need to respond to.
* We can't just say it doesn't exist here, even tho it does for
* other servers :) -GD
diff --git a/src/modules/cs_appendtopic.c b/src/modules/cs_appendtopic.c
index 5eda7bce6..c67b68b4e 100644
--- a/src/modules/cs_appendtopic.c
+++ b/src/modules/cs_appendtopic.c
@@ -70,8 +70,6 @@ class CommandCSAppendTopic : public Command
if (!c)
notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
- else if (ci->flags & CI_FORBIDDEN)
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name);
else if (!check_access(u, ci, CA_TOPIC))
notice_lang(s_ChanServ, u, ACCESS_DENIED);
else
diff --git a/src/modules/cs_enforce.c b/src/modules/cs_enforce.c
index 65807c6e4..47b90db45 100644
--- a/src/modules/cs_enforce.c
+++ b/src/modules/cs_enforce.c
@@ -39,9 +39,9 @@ class CommandCSEnforce : public Command
if (!(ci = c->ci))
return;
- if (ci->flags & CI_SECUREOPS)
+ if (ci->HasFlag(CI_SECUREOPS))
this->DoSecureOps(c);
- if (ci->flags & CI_RESTRICTED)
+ if (ci->HasFlag(CI_RESTRICTED))
this->DoRestricted(c);
}
@@ -56,7 +56,7 @@ class CommandCSEnforce : public Command
struct c_userlist *user;
struct c_userlist *next;
ChannelInfo *ci;
- uint32 flags;
+ bool hadsecureops = false;
if (!(ci = c->ci))
return;
@@ -69,8 +69,11 @@ class CommandCSEnforce : public Command
* part of the code. This way we can enforce SECUREOPS even
* if it's off.
*/
- flags = ci->flags;
- ci->flags |= CI_SECUREOPS;
+ if (!ci->HasFlag(CI_SECUREOPS))
+ {
+ ci->SetFlag(CI_SECUREOPS);
+ hadsecureops = true;
+ }
user = c->users;
do
@@ -80,7 +83,11 @@ class CommandCSEnforce : public Command
user = next;
} while (user);
- ci->flags = flags;
+ if (hadsecureops)
+ {
+ ci->UnsetFlag(CI_SECUREOPS);
+ }
+
}
void DoRestricted(Channel *c)
@@ -187,8 +194,6 @@ class CommandCSEnforce : public Command
if (!c)
notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
- else if (ci->flags & CI_FORBIDDEN)
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name);
else if (!check_access(u, ci, CA_AKICK))
notice_lang(s_ChanServ, u, ACCESS_DENIED);
else
diff --git a/src/modules/ns_noop_convert.c b/src/modules/ns_noop_convert.c
index ae0127b97..004693e35 100644
--- a/src/modules/ns_noop_convert.c
+++ b/src/modules/ns_noop_convert.c
@@ -112,7 +112,7 @@ int mLoadData()
/* Take the \n from the end of the line */
name[len - 1] = '\0';
if ((na = findnick(name))) {
- na->nc->flags |= NI_AUTOOP;
+ na->nc->SetFlag(NI_AUTOOP);
}
delete [] name;
}
diff --git a/src/nickalias.cpp b/src/nickalias.cpp
index a8ae405c0..314d808e4 100644
--- a/src/nickalias.cpp
+++ b/src/nickalias.cpp
@@ -5,7 +5,6 @@ NickAlias::NickAlias()
next = prev = NULL;
nick = last_quit = last_realname = last_usermask = NULL;
time_registered = last_seen = 0;
- status = 0;
nc = NULL;
}
diff --git a/src/nickcore.cpp b/src/nickcore.cpp
index f195c233a..f772b0732 100644
--- a/src/nickcore.cpp
+++ b/src/nickcore.cpp
@@ -7,9 +7,14 @@ NickCore::NickCore()
display = email = greet = url = NULL;
ot = NULL;
pass[0] = '\0';
- icq = flags = 0;
+ icq = 0;
language = channelcount = 0;
lastmail = 0;
+
+ /* Set default nick core flags */
+ for (size_t t = NI_BEGIN + 1; t != NI_END; ++t)
+ if (NSDefFlags.HasFlag((NickCoreFlag)t))
+ SetFlag((NickCoreFlag)t);
}
bool NickCore::HasCommand(const std::string &cmdstr) const
diff --git a/src/nickserv.c b/src/nickserv.c
index 39fe54706..ed3541227 100644
--- a/src/nickserv.c
+++ b/src/nickserv.c
@@ -130,7 +130,7 @@ class NickServRelease : public Timer
else
ircdproto->SendQuit(na->nick, NULL);
}
- na->status &= ~NS_KILL_HELD;
+ na->UnsetFlag(NS_KILL_HELD);
}
static void ClearTimers(NickAlias *na, bool dorelease = false)
@@ -381,9 +381,10 @@ void load_ns_dbase()
SAFE(read_int32(&nc->icq, f));
SAFE(read_string(&nc->url, f));
- SAFE(read_int32(&nc->flags, f));
+ //SAFE(read_int32(&nc->flags, f));
+ SAFE(read_int32(&tmp32, f));
if (!NSAllowKillImmed)
- nc->flags &= ~NI_KILL_IMMED;
+ nc->UnsetFlag(NI_KILL_IMMED);
SAFE(read_int16(&nc->language, f));
uint16 accesscount;
@@ -413,7 +414,8 @@ void load_ns_dbase()
nc->memos.memos[j] = new Memo;
Memo *memo = nc->memos.memos[j];
SAFE(read_int32(&memo->number, f));
- SAFE(read_int16(&memo->flags, f));
+ //SAFE(read_int16(&memo->flags, f));
+ SAFE(read_int16(&tmp16, f));
SAFE(read_int32(&tmp32, f));
memo->time = tmp32;
SAFE(read_buffer(memo->sender, f));
@@ -448,8 +450,9 @@ void load_ns_dbase()
na->time_registered = tmp32;
SAFE(read_int32(&tmp32, f));
na->last_seen = tmp32;
- SAFE(read_int16(&na->status, f));
- na->status &= ~NS_TEMPORARY;
+ //SAFE(read_int16(&na->status, f));
+ SAFE(read_int16(&tmp16, f));
+ //na->UnsetFlag(NS_TEMPORARY);
SAFE(read_string(&s, f));
na->nc = findcore(s);
@@ -457,7 +460,7 @@ void load_ns_dbase()
slist_add(&na->nc->aliases, na);
- if (!(na->status & NS_FORBIDDEN))
+ if (!na->HasFlag(NS_FORBIDDEN))
{
if (!na->last_usermask)
na->last_usermask = sstrdup("");
@@ -540,7 +543,8 @@ void save_ns_dbase()
SAFE(write_int32(nc->icq, f));
SAFE(write_string(nc->url, f));
- SAFE(write_int32(nc->flags, f));
+ //SAFE(write_int32(nc->flags, f));
+ SAFE(write_int32(0, f));
SAFE(write_int16(nc->language, f));
SAFE(write_int16(nc->access.size(), f));
@@ -556,7 +560,8 @@ void save_ns_dbase()
{
Memo *memo = nc->memos.memos[j];
SAFE(write_int32(memo->number, f));
- SAFE(write_int16(memo->flags, f));
+ //SAFE(write_int16(memo->flags, f));
+ SAFE(write_int16(0, f));
SAFE(write_int32(memo->time, f));
SAFE(write_buffer(memo->sender, f));
SAFE(write_string(memo->text, f));
@@ -586,7 +591,8 @@ void save_ns_dbase()
SAFE(write_int32(na->time_registered, f));
SAFE(write_int32(na->last_seen, f));
- SAFE(write_int16(na->status, f));
+ //SAFE(write_int16(na->status, f));
+ SAFE(write_int16(0, f));
SAFE(write_string(na->nc->display, f));
@@ -651,21 +657,21 @@ int validate_user(User * u)
if (!(na = findnick(u->nick)))
return 0;
- if (na->status & NS_FORBIDDEN)
+ if (na->HasFlag(NS_FORBIDDEN))
{
notice_lang(s_NickServ, u, NICK_MAY_NOT_BE_USED);
collide(na, 0);
return 0;
}
- if (na->nc->flags & NI_SUSPENDED)
+ if (na->nc->HasFlag(NI_SUSPENDED))
{
notice_lang(s_NickServ, u, NICK_X_SUSPENDED, u->nick);
collide(na, 0);
return 0;
}
- if (!(na->nc->flags & NI_SECURE) && u->IsRecognized())
+ if (!na->nc->HasFlag(NI_SECURE) && u->IsRecognized())
{
na->last_seen = time(NULL);
if (na->last_usermask)
@@ -678,22 +684,22 @@ int validate_user(User * u)
return 1;
}
- if (u->IsRecognized() || !(na->nc->flags & NI_KILL_IMMED))
+ if (u->IsRecognized() || !na->nc->HasFlag(NI_KILL_IMMED))
{
- if (na->nc->flags & NI_SECURE)
+ if (na->nc->HasFlag(NI_SECURE))
notice_lang(s_NickServ, u, NICK_IS_SECURE, s_NickServ);
else
notice_lang(s_NickServ, u, NICK_IS_REGISTERED, s_NickServ);
}
- if ((na->nc->flags & NI_KILLPROTECT) && !u->IsRecognized())
+ if (na->nc->HasFlag(NI_KILLPROTECT) && !u->IsRecognized())
{
- if (na->nc->flags & NI_KILL_IMMED)
+ if (na->nc->HasFlag(NI_KILL_IMMED))
{
notice_lang(s_NickServ, u, FORCENICKCHANGE_NOW);
collide(na, 0);
}
- else if (na->nc->flags & NI_KILL_QUICK)
+ else if (na->nc->HasFlag(NI_KILL_QUICK))
{
notice_lang(s_NickServ, u, FORCENICKCHANGE_IN_20_SECONDS);
t = new NickServCollide(na, 20);
@@ -721,7 +727,7 @@ void cancel_user(User * u)
if (na)
{
- if (na->status & NS_GUESTED)
+ if (na->HasFlag(NS_GUESTED))
{
if (ircd->svshold)
{
@@ -738,14 +744,12 @@ void cancel_user(User * u)
{
ircdproto->SendSVSKill(s_NickServ, u->nick, "Please do not use a registered nickname without identifying");
}
- na->status &= ~NS_TEMPORARY;
- na->status |= NS_KILL_HELD;
- }
- else
- {
- na->status &= ~NS_TEMPORARY;
+ na->SetFlag(NS_KILL_HELD);
}
+ na->UnsetFlag(NS_KILL_HELD);
+ na->UnsetFlag(NS_GUESTED);
+
NickServCollide::ClearTimers(na);
}
}
@@ -784,7 +788,7 @@ void expire_nicks()
next = na->next;
User *u = finduser(na->nick);
- if (u && ((na->nc->flags & NI_SECURE) ? nick_identified(u) : u->IsRecognized()))
+ if (u && (na->nc->HasFlag(NI_SECURE) ? nick_identified(u) : u->IsRecognized()))
{
if (debug >= 2)
alog("debug: NickServ: updating last seen time for %s",
@@ -794,8 +798,8 @@ void expire_nicks()
}
if (NSExpire && now - na->last_seen >= NSExpire
- && !(na->status & (NS_FORBIDDEN | NS_NO_EXPIRE))
- && !(na->nc->flags & (NI_SUSPENDED)))
+ && !na->HasFlag(NS_FORBIDDEN) && !na->HasFlag(NS_NO_EXPIRE)
+ && !na->nc->HasFlag(NI_SUSPENDED))
{
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnPreNickExpire, OnPreNickExpire(na));
@@ -1320,7 +1324,7 @@ void collide(NickAlias * na, int from_timeout)
while (finduser(guestnick));
notice_lang(s_NickServ, finduser(na->nick), FORCENICKCHANGE_CHANGING, guestnick);
ircdproto->SendForceNickChange(na->nick, guestnick, time(NULL));
- na->status |= NS_GUESTED;
+ na->SetFlag(NS_GUESTED);
}
else
{
@@ -1345,7 +1349,7 @@ void release(NickAlias * na, int from_timeout)
{
ircdproto->SendQuit(na->nick, NULL);
}
- na->status &= ~NS_KILL_HELD;
+ na->UnsetFlag(NS_KILL_HELD);
}
/*************************************************************************/
diff --git a/src/operserv.c b/src/operserv.c
index 3848e960f..0c78ea707 100644
--- a/src/operserv.c
+++ b/src/operserv.c
@@ -323,7 +323,7 @@ Server *server_global(Server * s, char *msg)
while (s) {
/* Do not send the notice to ourselves our juped servers */
- if (!(s->flags & (SERVER_ISME | SERVER_JUPED)))
+ if (!s->HasFlag(SERVER_ISME) && !s->HasFlag(SERVER_JUPED))
notice_server(s_GlobalNoticer, s, "%s", msg);
if (s->links) {
diff --git a/src/protocol.cpp b/src/protocol.cpp
index 4f8603368..26fc18779 100644
--- a/src/protocol.cpp
+++ b/src/protocol.cpp
@@ -2,7 +2,7 @@
void IRCDProto::SendMessageInternal(BotInfo *bi, const char *dest, const char *buf)
{
- if (NSDefFlags & NI_MSG)
+ if (NSDefFlags.HasFlag(NI_MSG))
SendPrivmsgInternal(bi, dest, buf);
else
SendNoticeInternal(bi, dest, buf);
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index 8e8ca825d..96e2d6046 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -35,10 +35,20 @@ ChannelInfo::ChannelInfo()
/* If ircd doesn't exist, this is from DB load and mlock is set later */
if (ircd)
mlock_on = ircd->DefMLock;
- flags = CSDefFlags;
+
+ size_t t;
+ /* Set default channel flags */
+ for (t = CI_BEGIN + 1; t != CI_END - 1; ++t)
+ if (CSDefFlags.HasFlag((ChannelInfoFlag)t))
+ this->SetFlag((ChannelInfoFlag)t);
+
+ /* Set default bot flags */
+ for (t = BI_BEGIN + 1; t != BI_END; ++t)
+ if (BSDefFlags.HasFlag((BotServFlag)t))
+ this->botflags.SetFlag((BotServFlag)t);
+
bantype = CSDefBantype;
memos.memomax = MSMaxMemos;
- botflags = BSDefFlags;
last_used = time_registered = time(NULL);
}
@@ -161,7 +171,8 @@ AutoKick *ChannelInfo::AddAkick(const std::string &user, NickCore *akicknc, cons
return NULL;
AutoKick *autokick = new AutoKick();
- autokick->flags = AK_USED | AK_ISNICK;
+ autokick->SetFlag(AK_USED);
+ autokick->SetFlag(AK_ISNICK);
autokick->nc = akicknc;
autokick->reason = reason;
autokick->creator = user;
@@ -182,7 +193,7 @@ AutoKick *ChannelInfo::AddAkick(const std::string &user, const std::string &mask
{
AutoKick *autokick = new AutoKick();
autokick->mask = mask;
- autokick->flags = AK_USED;
+ autokick->SetFlag(AK_USED);
autokick->reason = reason;
autokick->creator = user;
autokick->addtime = t;
diff --git a/src/send.c b/src/send.c
index 4f05d11ad..6ac67f748 100644
--- a/src/send.c
+++ b/src/send.c
@@ -98,7 +98,7 @@ void notice_server(char *source, Server * s, const char *fmt, ...)
va_start(args, fmt);
vsnprintf(buf, BUFSIZE - 1, fmt, args);
- if (NSDefFlags & NI_MSG) {
+ if (NSDefFlags.HasFlag(NI_MSG)) {
ircdproto->SendGlobalPrivmsg(findbot(source), s->name, buf);
} else {
ircdproto->SendGlobalNotice(findbot(source), s->name, buf);
diff --git a/src/servers.c b/src/servers.c
index fa44740cc..4af9c62bc 100644
--- a/src/servers.c
+++ b/src/servers.c
@@ -53,23 +53,22 @@ CapabInfo capab_info[] = {
{"SJB64", CAPAB_SJB64},
{"CHANMODES", CAPAB_CHANMODE},
{"NICKCHARS", CAPAB_NICKCHARS},
- {NULL, 0}
+ {NULL, CAPAB_END}
};
/*************************************************************************/
/**
* Return the first server in the server struct
- * @param flags Server Flags, see services.h
+ * @param flag Server Flag, see services.h
* @return Server Struct
*/
-Server *first_server(int flags)
+Server *first_server(ServerFlag flag)
{
server_cur = servlist;
- if (flags > -1) {
- while (server_cur && (server_cur->flags != flags))
- server_cur = next_server(flags);
- }
+
+ while (server_cur && !server_cur->HasFlag(flag))
+ server_cur = next_server(flag);
return server_cur;
}
@@ -80,7 +79,7 @@ Server *first_server(int flags)
* @param flags Server Flags, see services.h
* @return Server Struct
*/
-Server *next_server(int flags)
+Server *next_server(ServerFlag flag)
{
if (!server_cur)
return NULL;
@@ -99,7 +98,7 @@ Server *next_server(int flags)
}
} while (server_cur);
}
- } while (server_cur && ((flags > -1) && (server_cur->flags != flags)));
+ } while (server_cur && !server_cur->HasFlag(flag));
return server_cur;
}
@@ -119,7 +118,7 @@ Server *next_server(int flags)
* @return Server Struct
*/
Server *new_server(Server * server_uplink, const char *name, const char *desc,
- uint16 flags, const char *suid)
+ ServerFlag flag, const char *suid)
{
Server *serv;
@@ -130,7 +129,8 @@ Server *new_server(Server * server_uplink, const char *name, const char *desc,
name = "";
serv->name = sstrdup(name);
serv->desc = sstrdup(desc);
- serv->flags = flags;
+ if (flag != SERVER_START)
+ serv->SetFlag(flag);
serv->uplink = server_uplink;
if (suid) {
serv->suid = sstrdup(suid);
@@ -157,7 +157,7 @@ Server *new_server(Server * server_uplink, const char *name, const char *desc,
}
/* Check if this is our uplink server */
- if ((server_uplink == me_server) && !(flags & SERVER_JUPED))
+ if ((server_uplink == me_server) && flag != SERVER_JUPED)
{
// XXX: Apparantly we set ourselves as serv_uplink before we (really) set the uplink when we recieve SERVER. This is wrong and ugly.
if (serv_uplink != NULL)
@@ -172,7 +172,7 @@ Server *new_server(Server * server_uplink, const char *name, const char *desc,
}
}
serv_uplink = serv;
- serv->flags |= SERVER_ISUPLINK;
+ serv->SetFlag(SERVER_ISUPLINK);
}
return serv;
@@ -217,8 +217,8 @@ static void delete_server(Server * serv, const char *quitreason)
unext = nextuser();
if (u->server == serv)
{
- if ((na = findnick(u->nick)) && !(na->status & NS_FORBIDDEN)
- && (!(na->nc->flags & NI_SUSPENDED))
+ if ((na = findnick(u->nick)) && !na->HasFlag(NS_FORBIDDEN)
+ && (!na->nc->HasFlag(NI_SUSPENDED))
&& (u->IsRecognized() || nick_identified(u))) {
na->last_seen = time(NULL);
if (na->last_quit)
@@ -413,7 +413,7 @@ void do_server(const char *source, const char *servername, const char *hops,
throw CoreException("Recieved a server from a nonexistant uplink?");
/* Create a server structure. */
- newserver = new_server(s, servername, descript, 0, numeric);
+ newserver = new_server(s, servername, descript, SERVER_START, numeric);
/* Announce services being online. */
if (GlobalOnCycle && GlobalOnCycleUP)
@@ -454,7 +454,8 @@ void do_squit(const char *source, int ac, const char **av)
/* If this is a juped server, send a nice global to inform the online
* opers that we received it.
*/
- if (s->flags & SERVER_JUPED) {
+ if (s->HasFlag(SERVER_JUPED))
+ {
snprintf(buf, BUFSIZE, "Received SQUIT for juped server %s",
s->name);
ircdproto->SendGlobops(s_OperServ, buf);
diff --git a/src/users.c b/src/users.c
index 08c1b12c1..bdbb552d3 100644
--- a/src/users.c
+++ b/src/users.c
@@ -210,7 +210,7 @@ void User::SetRealname(const std::string &srealname)
this->realname = sstrdup(srealname.c_str());
NickAlias *na = findnick(this->nick);
- if (na && (nick_identified(this) || (!this->nc || (this->nc && !(this->nc->flags & NI_SECURE) && IsRecognized()))))
+ if (na && (nick_identified(this) || !this->nc || !this->nc->HasFlag(NI_SECURE) && IsRecognized()))
{
if (na->last_realname)
delete [] na->last_realname;
@@ -325,7 +325,7 @@ void User::SendMessage(const char *source, const std::string &msg)
* - The user is registered and has set /ns set msg on
*/
if (UsePrivmsg &&
- ((!this->nc && NSDefFlags & NI_MSG) || (this->nc && this->nc->flags & NI_MSG)))
+ ((!this->nc && NSDefFlags.HasFlag(NI_MSG)) || (this->nc && this->nc->HasFlag(NI_MSG))))
{
ircdproto->SendPrivmsg(findbot(source), this->nick, "%s", msg.c_str());
}
@@ -390,7 +390,7 @@ void User::UpdateHost()
{
NickAlias *na = findnick(this->nick);
- if (nick_identified(this) || (na && !(na->nc->flags & NI_SECURE) && IsRecognized()))
+ if (nick_identified(this) || (na && !na->nc->HasFlag(NI_SECURE) && IsRecognized()))
{
if (na->last_usermask)
delete [] na->last_usermask;
@@ -611,7 +611,6 @@ User *do_nick(const char *source, const char *nick, const char *username, const
char *tmp = NULL;
NickAlias *old_na; /* Old nick rec */
int nc_changed = 1; /* Did nick core change? */
- int status = 0; /* Status to apply */
char *logrealname;
std::string oldnick; /* stores the old nick of the user, so we can pass it to OnUserNickChange */
@@ -758,7 +757,6 @@ User *do_nick(const char *source, const char *nick, const char *username, const
if (old_na) {
if (user->IsRecognized())
old_na->last_seen = time(NULL);
- status = old_na->status & NS_TRANSGROUP;
cancel_user(user);
}
@@ -773,9 +771,6 @@ User *do_nick(const char *source, const char *nick, const char *username, const
{
NickAlias *tmpcore = findnick(user->nick);
- if (tmpcore)
- tmpcore->status |= status;
-
/* If the new nick isnt registerd or its registerd and not yours */
if (!tmpcore || (old_na && tmpcore->nc != old_na->nc))
{
@@ -881,8 +876,8 @@ void do_quit(const char *source, int ac, const char **av)
if (debug) {
alog("debug: %s quits", source);
}
- if ((na = findnick(user->nick)) && (!(na->status & NS_FORBIDDEN))
- && (!(na->nc->flags & NI_SUSPENDED)) && (user->IsRecognized() || nick_identified(user))) {
+ if ((na = findnick(user->nick)) && !na->HasFlag(NS_FORBIDDEN)
+ && !na->nc->HasFlag(NI_SUSPENDED) && (user->IsRecognized() || nick_identified(user))) {
na->last_seen = time(NULL);
if (na->last_quit)
delete [] na->last_quit;
@@ -917,8 +912,7 @@ void do_kill(const char *nick, const char *msg)
if (debug) {
alog("debug: %s killed", nick);
}
- if ((na = findnick(user->nick)) && (!(na->status & NS_FORBIDDEN))
- && (!(na->nc->flags & NI_SUSPENDED)) && (user->IsRecognized() || nick_identified(user))) {
+ if ((na = findnick(user->nick)) && !na->HasFlag(NS_FORBIDDEN) && !na->nc->HasFlag(NI_SUSPENDED) && (user->IsRecognized() || nick_identified(user))) {
na->last_seen = time(NULL);
if (na->last_quit)
delete [] na->last_quit;