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