m_stats: use macros to clean up generating the stats table

This commit is contained in:
Elizabeth Myers 2016-04-07 03:27:50 -05:00
parent 999c42bad8
commit 95b0324658

View file

@ -131,6 +131,9 @@ static void stats_ziplinks(struct Client *);
static void stats_comm(struct Client *);
static void stats_capability(struct Client *);
#define HANDLER_NORM(fn, oper, admin) { { .handler = fn }, false, oper, admin }
#define HANDLER_PARV(fn, oper, admin) { { .handler_parv = fn }, true, oper, admin }
/* This table contains the possible stats items, in order:
* stats letter, function to call, operonly? adminonly? --fl_
*
@ -139,54 +142,54 @@ static void stats_capability(struct Client *);
* --Elizafox
*/
static struct stats_cmd stats_cmd_table[256] = {
/* letter handler/handler_parv parv oper admin */
['a'] = { { stats_dns_servers }, false, true, true, },
['A'] = { { stats_dns_servers }, false, true, true, },
['b'] = { { stats_delay }, false, true, true, },
['B'] = { { stats_hash }, false, true, true, },
['c'] = { { stats_connect }, false, false, false, },
['C'] = { { stats_capability }, false, true, false, },
['d'] = { { stats_tdeny }, false, true, false, },
['D'] = { { stats_deny }, false, true, false, },
['e'] = { { stats_exempt }, false, true, false, },
['E'] = { { stats_events }, false, true, true, },
['f'] = { { stats_comm }, false, true, true, },
['F'] = { { stats_comm }, false, true, true, },
['g'] = { { stats_prop_klines }, false, true, false, },
['h'] = { { stats_hubleaf }, false, false, false, },
['H'] = { { stats_hubleaf }, false, false, false, },
['i'] = { { stats_auth }, false, false, false, },
['I'] = { { stats_auth }, false, false, false, },
['k'] = { { stats_tklines }, false, false, false, },
['K'] = { { stats_klines }, false, false, false, },
['l'] = { { .handler_parv = stats_ltrace }, true, false, false, },
['L'] = { { .handler_parv = stats_ltrace }, true, false, false, },
['m'] = { { stats_messages }, false, false, false, },
['M'] = { { stats_messages }, false, false, false, },
['n'] = { { stats_dnsbl }, false, false, false, },
['o'] = { { stats_oper }, false, false, false, },
['O'] = { { stats_privset }, false, true, false, },
['p'] = { { stats_operedup }, false, false, false, },
['P'] = { { stats_ports }, false, false, false, },
['q'] = { { stats_tresv }, false, true, false, },
['Q'] = { { stats_resv }, false, true, false, },
['r'] = { { stats_usage }, false, true, false, },
['R'] = { { stats_usage }, false, true, false, },
['s'] = { { stats_ssld }, false, true, true, },
['S'] = { { stats_ssld }, false, true, true, },
['t'] = { { stats_tstats }, false, true, false, },
['T'] = { { stats_tstats }, false, true, false, },
['u'] = { { stats_uptime }, false, false, false, },
['U'] = { { stats_shared }, false, true, false, },
['v'] = { { stats_servers }, false, false, false, },
['V'] = { { stats_servers }, false, false, false, },
['x'] = { { stats_tgecos }, false, true, false, },
['X'] = { { stats_gecos }, false, true, false, },
['y'] = { { stats_class }, false, false, false, },
['Y'] = { { stats_class }, false, false, false, },
['z'] = { { stats_memory }, false, true, false, },
['Z'] = { { stats_ziplinks }, false, true, false, },
['?'] = { { stats_servlinks }, false, false, false, },
/* letter handler oper admin */
['a'] = HANDLER_NORM(stats_dns_servers, true, true),
['A'] = HANDLER_NORM(stats_dns_servers, true, true),
['b'] = HANDLER_NORM(stats_delay, true, true),
['B'] = HANDLER_NORM(stats_hash, true, true),
['c'] = HANDLER_NORM(stats_connect, false, false),
['C'] = HANDLER_NORM(stats_capability, true, false),
['d'] = HANDLER_NORM(stats_tdeny, true, false),
['D'] = HANDLER_NORM(stats_deny, true, false),
['e'] = HANDLER_NORM(stats_exempt, true, false),
['E'] = HANDLER_NORM(stats_events, true, true),
['f'] = HANDLER_NORM(stats_comm, true, true),
['F'] = HANDLER_NORM(stats_comm, true, true),
['g'] = HANDLER_NORM(stats_prop_klines, true, false),
['h'] = HANDLER_NORM(stats_hubleaf, false, false),
['H'] = HANDLER_NORM(stats_hubleaf, false, false),
['i'] = HANDLER_NORM(stats_auth, false, false),
['I'] = HANDLER_NORM(stats_auth, false, false),
['k'] = HANDLER_NORM(stats_tklines, false, false),
['K'] = HANDLER_NORM(stats_klines, false, false),
['l'] = HANDLER_PARV(stats_ltrace, false, false),
['L'] = HANDLER_PARV(stats_ltrace, false, false),
['m'] = HANDLER_NORM(stats_messages, false, false),
['M'] = HANDLER_NORM(stats_messages, false, false),
['n'] = HANDLER_NORM(stats_dnsbl, false, false),
['o'] = HANDLER_NORM(stats_oper, false, false),
['O'] = HANDLER_NORM(stats_privset, true, false),
['p'] = HANDLER_NORM(stats_operedup, false, false),
['P'] = HANDLER_NORM(stats_ports, false, false),
['q'] = HANDLER_NORM(stats_tresv, true, false),
['Q'] = HANDLER_NORM(stats_resv, true, false),
['r'] = HANDLER_NORM(stats_usage, true, false),
['R'] = HANDLER_NORM(stats_usage, true, false),
['s'] = HANDLER_NORM(stats_ssld, true, true),
['S'] = HANDLER_NORM(stats_ssld, true, true),
['t'] = HANDLER_NORM(stats_tstats, true, false),
['T'] = HANDLER_NORM(stats_tstats, true, false),
['u'] = HANDLER_NORM(stats_uptime, false, false),
['U'] = HANDLER_NORM(stats_shared, true, false),
['v'] = HANDLER_NORM(stats_servers, false, false),
['V'] = HANDLER_NORM(stats_servers, false, false),
['x'] = HANDLER_NORM(stats_tgecos, true, false),
['X'] = HANDLER_NORM(stats_gecos, true, false),
['y'] = HANDLER_NORM(stats_class, false, false),
['Y'] = HANDLER_NORM(stats_class, false, false),
['z'] = HANDLER_NORM(stats_memory, true, false),
['Z'] = HANDLER_NORM(stats_ziplinks, true, false),
['?'] = HANDLER_NORM(stats_servlinks, false, false),
};
/*