diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/os_news.c | 88 | ||||
-rw-r--r-- | src/core/os_noop.c | 2 |
2 files changed, 87 insertions, 3 deletions
diff --git a/src/core/os_news.c b/src/core/os_news.c index ef1d30b02..ed3841c93 100644 --- a/src/core/os_news.c +++ b/src/core/os_news.c @@ -15,12 +15,94 @@ #include "module.h" + +/* List of messages for each news type. This simplifies message sending. */ + +#define MSG_SYNTAX 0 +#define MSG_LIST_HEADER 1 +#define MSG_LIST_ENTRY 2 +#define MSG_LIST_NONE 3 +#define MSG_ADD_SYNTAX 4 +#define MSG_ADD_FULL 5 +#define MSG_ADDED 6 +#define MSG_DEL_SYNTAX 7 +#define MSG_DEL_NOT_FOUND 8 +#define MSG_DELETED 9 +#define MSG_DEL_NONE 10 +#define MSG_DELETED_ALL 11 +#define MSG_MAX 11 + + void myOperServHelp(User *u); int reload_config(int argc, char **argv); +struct newsmsgs { + int16 type; + const char *name; + int msgs[MSG_MAX + 1]; +}; + +struct newsmsgs msgarray[] = { + {NEWS_LOGON, "LOGON", + {NEWS_LOGON_SYNTAX, + NEWS_LOGON_LIST_HEADER, + NEWS_LOGON_LIST_ENTRY, + NEWS_LOGON_LIST_NONE, + NEWS_LOGON_ADD_SYNTAX, + NEWS_LOGON_ADD_FULL, + NEWS_LOGON_ADDED, + NEWS_LOGON_DEL_SYNTAX, + NEWS_LOGON_DEL_NOT_FOUND, + NEWS_LOGON_DELETED, + NEWS_LOGON_DEL_NONE, + NEWS_LOGON_DELETED_ALL} + }, + {NEWS_OPER, "OPER", + {NEWS_OPER_SYNTAX, + NEWS_OPER_LIST_HEADER, + NEWS_OPER_LIST_ENTRY, + NEWS_OPER_LIST_NONE, + NEWS_OPER_ADD_SYNTAX, + NEWS_OPER_ADD_FULL, + NEWS_OPER_ADDED, + NEWS_OPER_DEL_SYNTAX, + NEWS_OPER_DEL_NOT_FOUND, + NEWS_OPER_DELETED, + NEWS_OPER_DEL_NONE, + NEWS_OPER_DELETED_ALL} + }, + {NEWS_RANDOM, "RANDOM", + {NEWS_RANDOM_SYNTAX, + NEWS_RANDOM_LIST_HEADER, + NEWS_RANDOM_LIST_ENTRY, + NEWS_RANDOM_LIST_NONE, + NEWS_RANDOM_ADD_SYNTAX, + NEWS_RANDOM_ADD_FULL, + NEWS_RANDOM_ADDED, + NEWS_RANDOM_DEL_SYNTAX, + NEWS_RANDOM_DEL_NOT_FOUND, + NEWS_RANDOM_DELETED, + NEWS_RANDOM_DEL_NONE, + NEWS_RANDOM_DELETED_ALL} + } +}; + +static int *findmsgs(int16 type, const char **type_name) +{ + int i; + for (i = 0; i < lenof(msgarray); i++) { + if (msgarray[i].type == type) { + if (type_name) + *type_name = msgarray[i].name; + return msgarray[i].msgs; + } + } + return NULL; +} + class NewsBase : public Command { - private: + protected: CommandReturn DoList(User *u, std::vector<std::string> ¶ms, short type, int *msgs) { int i, count = 0; @@ -124,7 +206,7 @@ class NewsBase : public Command if (!msgs) { alog("news: Invalid type to do_news()"); - return; + return MOD_CONT; } if (!stricmp(cmd, "LIST")) @@ -145,6 +227,8 @@ class NewsBase : public Command } else this->OnSyntaxError(u); + + return MOD_CONT; } public: NewsBase(const std::string &newstype) : Command(newstype, 1, 2) diff --git a/src/core/os_noop.c b/src/core/os_noop.c index 6fe172529..e28db7a89 100644 --- a/src/core/os_noop.c +++ b/src/core/os_noop.c @@ -74,7 +74,7 @@ class CommandOSNOOP : public Command { syntax_error(s_OperServ, u, "NOOP", OPER_NOOP_SYNTAX); } -} +}; class OSNOOP : public Module { |