#include "numeric.h"
#include "send.h"
#include "packet.h"
+#include "s_assert.h"
static const char alias_desc[] = "Provides the system for services aliases";
static int _modinit(void);
static void _moddeinit(void);
-static int reload_aliases(hook_data *);
+static void reload_aliases(void *);
static void m_alias(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
mapi_hfn_list_av1 alias_hfnlist[] = {
- { "rehash", (hookfn)reload_aliases },
+ { "rehash", reload_aliases },
{ NULL, NULL },
};
RB_DICTIONARY_FOREACH(alias, &iter, alias_dict)
{
- struct Message *message = rb_malloc(sizeof(struct Message));
+ struct Message *message = rb_malloc(sizeof(*message) + strlen(alias->name) + 1);
+ char *cmd = (char*)message + sizeof(*message);
- message->cmd = alias->name;
+ /* copy the alias name as it will be freed early on a rehash */
+ strcpy(cmd, alias->name);
+ message->cmd = cmd;
memcpy(message->handlers, alias_msgtab, sizeof(alias_msgtab));
mod_add_cmd(message);
destroy_aliases();
}
-static int
-reload_aliases(hook_data *data)
+static void
+reload_aliases(void *data)
{
destroy_aliases(); /* Clear old aliases */
create_aliases();
- return 0;
}
/* The below was mostly taken from the old do_alias */
return;
}
- else if(parc < 2)
- {
- sendto_one(client_p, form_str(ERR_NEEDMOREPARAMS),
- me.name,
- EmptyString(client_p->name) ? "*" : client_p->name,
- msgbuf->cmd);
- return;
- }
if(!IsFloodDone(client_p) && client_p->localClient->receiveM > 20)
flood_endgrace(client_p);
return;
}
+ msgbuf_reconstruct_tail(msgbuf, 1);
if(EmptyString(parv[1]))
{
sendto_one(client_p, form_str(ERR_NOTEXTTOSEND), me.name, target_p->name);