Module: ngircd.git Branch: master Commit: 9f236c4b9155f3d4f1c7f1bf3b22e8a106e29df3 URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=9f236...
Author: Federico G. Schwindt fgsch@lodoss.net Date: Thu Nov 7 13:20:08 2013 +0000
Introduce a macro to define the command list
This will pave the way to other changes and simplifies the entries somewhat.
---
src/ngircd/parse.c | 125 +++++++++++++++++++++++++++------------------------- 1 file changed, 64 insertions(+), 61 deletions(-)
diff --git a/src/ngircd/parse.c b/src/ngircd/parse.c index 5295440..ae6f4d2 100644 --- a/src/ngircd/parse.c +++ b/src/ngircd/parse.c @@ -60,78 +60,81 @@ struct _NUMERIC {
static COMMAND My_Commands[] = { - { "ADMIN", IRC_ADMIN, CLIENT_USER|CLIENT_SERVER, 0, 1, 0, 0, 0 }, - { "AWAY", IRC_AWAY, CLIENT_USER, 0, 1, 0, 0, 0 }, - { "CAP", IRC_CAP, CLIENT_ANY, 1, 2, 0, 0, 0 }, - { "CONNECT", IRC_CONNECT, CLIENT_USER|CLIENT_SERVER, 0, -1, 0, 0, 0 }, +#define _CMD(name, func, type, min, max) \ + { (name), (func), (type), (min), (max), 0, 0, 0 } + _CMD("ADMIN", IRC_ADMIN, CLIENT_USER|CLIENT_SERVER, 0, 1), + _CMD("AWAY", IRC_AWAY, CLIENT_USER, 0, 1), + _CMD("CAP", IRC_CAP, CLIENT_ANY, 1, 2), + _CMD("CONNECT", IRC_CONNECT, CLIENT_USER|CLIENT_SERVER, 0, -1), #ifdef STRICT_RFC - { "DIE", IRC_DIE, CLIENT_USER, 0, 0, 0, 0, 0 }, + _CMD("DIE", IRC_DIE, CLIENT_USER, 0, 0), #else - { "DIE", IRC_DIE, CLIENT_USER, 0, 1, 0, 0, 0 }, + _CMD("DIE", IRC_DIE, CLIENT_USER, 0, 1), #endif - { "DISCONNECT", IRC_DISCONNECT, CLIENT_USER, 1, 1, 0, 0, 0 }, - { "ERROR", IRC_ERROR, CLIENT_ANY, 0, -1, 0, 0, 0 }, - { "GLINE", IRC_xLINE, CLIENT_USER|CLIENT_SERVER, 0, -1, 0, 0, 0 }, - { "HELP", IRC_HELP, CLIENT_USER, 0, 1, 0, 0, 0 }, - { "INFO", IRC_INFO, CLIENT_USER|CLIENT_SERVER, 0, 1, 0, 0, 0 }, - { "INVITE", IRC_INVITE, CLIENT_USER|CLIENT_SERVER, 2, 2, 0, 0, 0 }, - { "ISON", IRC_ISON, CLIENT_USER, 1, -1, 0, 0, 0 }, - { "JOIN", IRC_JOIN, CLIENT_USER|CLIENT_SERVER, 1, 2, 0, 0, 0 }, - { "KICK", IRC_KICK, CLIENT_USER|CLIENT_SERVER, 2, 3, 0, 0, 0 }, - { "KILL", IRC_KILL, CLIENT_USER|CLIENT_SERVER, 2, 2, 0, 0, 0 }, - { "KLINE", IRC_xLINE, CLIENT_USER|CLIENT_SERVER, 0, -1, 0, 0, 0 }, - { "LINKS", IRC_LINKS, CLIENT_USER|CLIENT_SERVER, 0, 2, 0, 0, 0 }, - { "LIST", IRC_LIST, CLIENT_USER|CLIENT_SERVER, 0, 2, 0, 0, 0 }, - { "LUSERS", IRC_LUSERS, CLIENT_USER|CLIENT_SERVER, 0, 2, 0, 0, 0 }, - { "METADATA", IRC_METADATA, CLIENT_SERVER, 3, 3, 0, 0, 0 }, - { "MODE", IRC_MODE, CLIENT_USER|CLIENT_SERVER, 1, -1, 0, 0, 0 }, - { "MOTD", IRC_MOTD, CLIENT_USER|CLIENT_SERVER, 0, 1, 0, 0, 0 }, - { "NAMES", IRC_NAMES, CLIENT_USER|CLIENT_SERVER, 0, 2, 0, 0, 0 }, - { "NICK", IRC_NICK, CLIENT_ANY, 0, -1, 0, 0, 0 }, - { "NJOIN", IRC_NJOIN, CLIENT_SERVER, 2, 2, 0, 0, 0 }, - { "NOTICE", IRC_NOTICE, CLIENT_ANY, 0, -1, 0, 0, 0 }, - { "OPER", IRC_OPER, CLIENT_USER, 2, 2, 0, 0, 0 }, - { "PART", IRC_PART, CLIENT_USER|CLIENT_SERVER, 1, 2, 0, 0, 0 }, - { "PASS", IRC_PASS, CLIENT_ANY, 0, -1, 0, 0, 0 }, - { "PING", IRC_PING, CLIENT_USER|CLIENT_SERVER, 0, -1, 0, 0, 0 }, - { "PONG", IRC_PONG, CLIENT_ANY, 0, -1, 0, 0, 0 }, - { "PRIVMSG", IRC_PRIVMSG, CLIENT_USER|CLIENT_SERVER, 0, 2, 0, 0, 0 }, - { "QUIT", IRC_QUIT, CLIENT_ANY, 0, 1, 0, 0, 0 }, - { "REHASH", IRC_REHASH, CLIENT_USER, 0, 0, 0, 0, 0 }, - { "RESTART", IRC_RESTART, CLIENT_USER, 0, 0, 0, 0, 0 }, - { "SERVER", IRC_SERVER, CLIENT_ANY, 0, -1, 0, 0, 0 }, - { "SERVICE", IRC_SERVICE, CLIENT_ANY, 6, 6, 0, 0, 0 }, - { "SERVLIST", IRC_SERVLIST, CLIENT_USER, 0, 2, 0, 0, 0 }, - { "SQUERY", IRC_SQUERY, CLIENT_USER|CLIENT_SERVER, 0, 2, 0, 0, 0 }, - { "SQUIT", IRC_SQUIT, CLIENT_USER|CLIENT_SERVER, 2, 2, 0, 0, 0 }, - { "STATS", IRC_STATS, CLIENT_USER|CLIENT_SERVER, 0, 2, 0, 0, 0 }, - { "SVSNICK", IRC_SVSNICK, CLIENT_SERVER, 2, 2, 0, 0, 0 }, - { "SUMMON", IRC_SUMMON, CLIENT_USER|CLIENT_SERVER, 0, -1, 0, 0, 0 }, - { "TIME", IRC_TIME, CLIENT_USER|CLIENT_SERVER, 0, 1, 0, 0, 0 }, - { "TOPIC", IRC_TOPIC, CLIENT_USER|CLIENT_SERVER, 1, 2, 0, 0, 0 }, - { "TRACE", IRC_TRACE, CLIENT_USER|CLIENT_SERVER, 0, 1, 0, 0, 0 }, - { "USER", IRC_USER, CLIENT_ANY, 0, -1, 0, 0, 0 }, - { "USERHOST", IRC_USERHOST, CLIENT_USER, 1, -1, 0, 0, 0 }, - { "USERS", IRC_USERS, CLIENT_USER|CLIENT_SERVER, 0, -1, 0, 0, 0 }, - { "VERSION", IRC_VERSION, CLIENT_USER|CLIENT_SERVER, 0, 1, 0, 0, 0 }, - { "WALLOPS", IRC_WALLOPS, CLIENT_USER|CLIENT_SERVER, 1, 1, 0, 0, 0 }, - { "WEBIRC", IRC_WEBIRC, CLIENT_UNKNOWN, 4, 4, 0, 0, 0 }, - { "WHO", IRC_WHO, CLIENT_USER, 0, 2, 0, 0, 0 }, - { "WHOIS", IRC_WHOIS, CLIENT_USER|CLIENT_SERVER, 0, -1, 0, 0, 0 }, - { "WHOWAS", IRC_WHOWAS, CLIENT_USER|CLIENT_SERVER, 0, -1, 0, 0, 0 }, + _CMD("DISCONNECT", IRC_DISCONNECT, CLIENT_USER, 1, 1), + _CMD("ERROR", IRC_ERROR, CLIENT_ANY, 0, -1), + _CMD("GLINE", IRC_xLINE, CLIENT_USER|CLIENT_SERVER, 0, -1), + _CMD("HELP", IRC_HELP, CLIENT_USER, 0, 1), + _CMD("INFO", IRC_INFO, CLIENT_USER|CLIENT_SERVER, 0, 1), + _CMD("INVITE", IRC_INVITE, CLIENT_USER|CLIENT_SERVER, 2, 2), + _CMD("ISON", IRC_ISON, CLIENT_USER, 1, -1), + _CMD("JOIN", IRC_JOIN, CLIENT_USER|CLIENT_SERVER, 1, 2), + _CMD("KICK", IRC_KICK, CLIENT_USER|CLIENT_SERVER, 2, 3), + _CMD("KILL", IRC_KILL, CLIENT_USER|CLIENT_SERVER, 2, 2), + _CMD("KLINE", IRC_xLINE, CLIENT_USER|CLIENT_SERVER, 0, -1), + _CMD("LINKS", IRC_LINKS, CLIENT_USER|CLIENT_SERVER, 0, 2), + _CMD("LIST", IRC_LIST, CLIENT_USER|CLIENT_SERVER, 0, 2), + _CMD("LUSERS", IRC_LUSERS, CLIENT_USER|CLIENT_SERVER, 0, 2), + _CMD("METADATA", IRC_METADATA, CLIENT_SERVER, 3, 3), + _CMD("MODE", IRC_MODE, CLIENT_USER|CLIENT_SERVER, 1, -1), + _CMD("MOTD", IRC_MOTD, CLIENT_USER|CLIENT_SERVER, 0, 1), + _CMD("NAMES", IRC_NAMES, CLIENT_USER|CLIENT_SERVER, 0, 2), + _CMD("NICK", IRC_NICK, CLIENT_ANY, 0, -1), + _CMD("NJOIN", IRC_NJOIN, CLIENT_SERVER, 2, 2), + _CMD("NOTICE", IRC_NOTICE, CLIENT_ANY, 0, -1), + _CMD("OPER", IRC_OPER, CLIENT_USER, 2, 2), + _CMD("PART", IRC_PART, CLIENT_USER|CLIENT_SERVER, 1, 2), + _CMD("PASS", IRC_PASS, CLIENT_ANY, 0, -1), + _CMD("PING", IRC_PING, CLIENT_USER|CLIENT_SERVER, 0, -1), + _CMD("PONG", IRC_PONG, CLIENT_ANY, 0, -1), + _CMD("PRIVMSG", IRC_PRIVMSG, CLIENT_USER|CLIENT_SERVER, 0, 2), + _CMD("QUIT", IRC_QUIT, CLIENT_ANY, 0, 1), + _CMD("REHASH", IRC_REHASH, CLIENT_USER, 0, 0), + _CMD("RESTART", IRC_RESTART, CLIENT_USER, 0, 0), + _CMD("SERVER", IRC_SERVER, CLIENT_ANY, 0, -1), + _CMD("SERVICE", IRC_SERVICE, CLIENT_ANY, 6, 6), + _CMD("SERVLIST", IRC_SERVLIST, CLIENT_USER, 0, 2), + _CMD("SQUERY", IRC_SQUERY, CLIENT_USER|CLIENT_SERVER, 0, 2), + _CMD("SQUIT", IRC_SQUIT, CLIENT_USER|CLIENT_SERVER, 2, 2), + _CMD("STATS", IRC_STATS, CLIENT_USER|CLIENT_SERVER, 0, 2), + _CMD("SVSNICK", IRC_SVSNICK, CLIENT_SERVER, 2, 2), + _CMD("SUMMON", IRC_SUMMON, CLIENT_USER|CLIENT_SERVER, 0, -1), + _CMD("TIME", IRC_TIME, CLIENT_USER|CLIENT_SERVER, 0, 1), + _CMD("TOPIC", IRC_TOPIC, CLIENT_USER|CLIENT_SERVER, 1, 2), + _CMD("TRACE", IRC_TRACE, CLIENT_USER|CLIENT_SERVER, 0, 1), + _CMD("USER", IRC_USER, CLIENT_ANY, 0, -1), + _CMD("USERHOST", IRC_USERHOST, CLIENT_USER, 1, -1), + _CMD("USERS", IRC_USERS, CLIENT_USER|CLIENT_SERVER, 0, -1), + _CMD("VERSION", IRC_VERSION, CLIENT_USER|CLIENT_SERVER, 0, 1), + _CMD("WALLOPS", IRC_WALLOPS, CLIENT_USER|CLIENT_SERVER, 1, 1), + _CMD("WEBIRC", IRC_WEBIRC, CLIENT_UNKNOWN, 4, 4), + _CMD("WHO", IRC_WHO, CLIENT_USER, 0, 2), + _CMD("WHOIS", IRC_WHOIS, CLIENT_USER|CLIENT_SERVER, 0, -1), + _CMD("WHOWAS", IRC_WHOWAS, CLIENT_USER|CLIENT_SERVER, 0, -1),
#ifdef IRCPLUS - { "CHANINFO", IRC_CHANINFO, CLIENT_SERVER, 0, -1, 0, 0, 0 }, + _CMD("CHANINFO", IRC_CHANINFO, CLIENT_SERVER, 0, -1), # ifdef ICONV - { "CHARCONV", IRC_CHARCONV, CLIENT_USER, 1, 1, 0, 0, 0 }, + _CMD("CHARCONV", IRC_CHARCONV, CLIENT_USER, 1, 1), # endif #endif
#ifndef STRICT_RFC - { "GET", IRC_QUIT_HTTP, CLIENT_UNKNOWN, 0, -1, 0, 0, 0 }, - { "POST", IRC_QUIT_HTTP, CLIENT_UNKNOWN, 0, -1, 0, 0, 0 }, + _CMD("GET", IRC_QUIT_HTTP, CLIENT_UNKNOWN, 0, -1), + _CMD("POST", IRC_QUIT_HTTP, CLIENT_UNKNOWN, 0, -1), #endif - { NULL, NULL, 0x0, 0, 0, 0, 0, 0 } /* End-Mark */ + _CMD(NULL, NULL, 0, 0, 0) /* End-Mark */ +#undef _CMD };
static void Init_Request PARAMS(( REQUEST *Req ));