#ifndef IRC_CMD_H
#define IRC_CMD_H
/**
* @file
*
* Flexible command handlers callback lists for use with irc_lines
*/
#include "irc_line.h"
#include "chain.h"
/**
* Single command -> handler mapping for lookup
*/
struct irc_cmd_handler {
/** The command name to match */
const char *command;
/** The handler function */
void (*func) (const struct irc_line *line, void *arg);
};
/**
* @struct irc_cmd_handlers
*
* A dynamic list of irc_cmd_chain handlers
*/
typedef struct chain_list irc_cmd_handlers_t;
/**
* Initialize a irc_cmd_handlers list.
*/
void irc_cmd_init (irc_cmd_handlers_t *handlers);
/**
* Add an irc_cmd_chain to the irc_cmd_handlers list for the given handlers/arg
*/
err_t irc_cmd_add (irc_cmd_handlers_t *handlers, const struct irc_cmd_handler *list, void *arg);
/**
* Trigger irc_cmd_chain callbacks for the given irc_line
*/
void irc_cmd_invoke (irc_cmd_handlers_t *handlers, const struct irc_line *line);
/**
* Cleanup an irc_cmd_handlers list
*/
void irc_cmd_free (irc_cmd_handlers_t *handlers);
#endif /* IRC_CMD_H */