diff --git a/include/ircd/parse.h b/include/ircd/parse.h index d225faf5e..58c3774e0 100644 --- a/include/ircd/parse.h +++ b/include/ircd/parse.h @@ -26,6 +26,8 @@ #define INCLUDED_parse_h_h #include +#include +#include struct Message; struct Client; @@ -34,12 +36,11 @@ struct MsgBuf; extern void parse(struct Client *, char *, char *); extern void handle_encap(struct MsgBuf *, struct Client *, struct Client *, const char *, int, const char *parv[]); -extern void clear_hash_parse(void); extern void mod_add_cmd(struct Message *msg); extern void mod_del_cmd(struct Message *msg); extern char *reconstruct_parv(int parc, const char *parv[]); extern rb_dictionary *alias_dict; -extern rb_dictionary *cmd_dict; +extern std::map cmd_dict; #endif /* INCLUDED_parse_h_h */ diff --git a/ircd/ircd.cc b/ircd/ircd.cc index 3fa162b2d..1f4f05e50 100644 --- a/ircd/ircd.cc +++ b/ircd/ircd.cc @@ -668,7 +668,6 @@ charybdis_main(int argc, char * const argv[]) init_hash(); clear_scache_hash_table(); /* server cache name table */ init_host_hash(); - clear_hash_parse(); init_client(); init_hook(); init_channels(); diff --git a/ircd/parse.cc b/ircd/parse.cc index bed288ae5..ad9648911 100644 --- a/ircd/parse.cc +++ b/ircd/parse.cc @@ -41,8 +41,8 @@ #include #include -rb_dictionary *cmd_dict = NULL; rb_dictionary *alias_dict = NULL; +std::map cmd_dict; static void cancel_clients(struct Client *, struct Client *); static void remove_unknown(struct Client *, const char *, char *); @@ -131,7 +131,7 @@ parse(struct Client *client_p, char *pbuffer, char *bufend) } else { - mptr = (Message *)rb_dictionary_retrieve(cmd_dict, msgbuf.cmd); + mptr = cmd_dict[msgbuf.cmd]; /* no command or its encap only, error */ if(!mptr || !mptr->cmd) @@ -250,8 +250,7 @@ handle_encap(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *so struct MessageEntry ehandler; MessageHandler handler = 0; - mptr = (Message *)rb_dictionary_retrieve(cmd_dict, command); - + mptr = cmd_dict[command]; if(mptr == NULL || mptr->cmd == NULL) return; @@ -265,20 +264,6 @@ handle_encap(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *so (*handler) (msgbuf_p, client_p, source_p, parc, parv); } -/* - * clear_hash_parse() - * - * inputs - - * output - NONE - * side effects - MUST MUST be called at startup ONCE before - * any other keyword hash routine is used. - */ -void -clear_hash_parse() -{ - cmd_dict = rb_dictionary_create("command", reinterpret_cast(rb_strcasecmp)); -} - /* mod_add_cmd * * inputs - command name @@ -295,7 +280,8 @@ mod_add_cmd(struct Message *msg) if(msg == NULL) return; - if (rb_dictionary_find(cmd_dict, msg->cmd) != NULL) { + if (cmd_dict[msg->cmd] != NULL) + { s_assert(0); return; } @@ -304,7 +290,7 @@ mod_add_cmd(struct Message *msg) msg->rcount = 0; msg->bytes = 0; - rb_dictionary_add(cmd_dict, msg->cmd, msg); + cmd_dict[msg->cmd] = msg; } /* mod_del_cmd @@ -320,8 +306,7 @@ mod_del_cmd(struct Message *msg) if(msg == NULL) return; - if (rb_dictionary_delete(cmd_dict, msg->cmd) == NULL) - s_assert(0); + cmd_dict.erase(msg->cmd); } /* cancel_clients() diff --git a/modules/m_stats.cc b/modules/m_stats.cc index 023131054..f21870cc7 100644 --- a/modules/m_stats.cc +++ b/modules/m_stats.cc @@ -762,14 +762,11 @@ stats_klines(struct Client *source_p) static void stats_messages(struct Client *source_p) { - rb_dictionary_iter iter; - struct alias_entry *amsg; - - void *elem; - RB_DICTIONARY_FOREACH(elem, &iter, cmd_dict) + for (auto it = cmd_dict.begin(); it != cmd_dict.end(); it++) { - const auto msg(reinterpret_cast(elem)); + const auto msg = it->second; s_assert(msg->cmd != NULL); + sendto_one_numeric(source_p, RPL_STATSCOMMANDS, form_str(RPL_STATSCOMMANDS), msg->cmd, msg->count,