--- a/src/irc_cmd.h Thu Mar 12 18:08:27 2009 +0200
+++ b/src/irc_cmd.h Thu Mar 12 18:11:44 2009 +0200
@@ -7,9 +7,8 @@
* Flexible command handlers callback lists for use with irc_lines
*/
-#include "irc_conn.h"
#include "irc_line.h"
-#include <sys/queue.h>
+#include "chain.h"
/**
* Single command -> handler mapping for lookup
@@ -19,27 +18,46 @@
const char *command;
/** The handler function */
- void (*func) (struct irc_conn *conn, const struct irc_line *line, void *arg);
+ void (*func) (const struct irc_line *line, void *arg);
};
/**
- * List item for a chain of irc_cmd_handler entries, with the context pointer
+ * @struct irc_cmd_handlers
+ *
+ * A dynamic list of irc_cmd_chain handlers
*/
-struct irc_cmd_chain {
- /** The list of handler lookup entries */
- struct irc_cmd_handler *handlers;
+typedef struct chain_list irc_cmd_handlers_t;
- /** Opaque context arg */
- void *arg;
+/**
+ * Initialize a irc_cmd_handlers list.
+ */
+void irc_cmd_init (irc_cmd_handlers_t *handlers);
- /** Linked list */
- STAILQ_ENTRY(irc_cmd_chain) node;
-};
+/**
+ * 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);
-/*
- * IRC command numerics
+/**
+ * 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);
+
+/**
+ * @group IRC command numerics
+ * @{
+ */
+
+/**
+ * 001 <nick> :Welcome to the Internet Relay Network <nick>!<user>@<host>
*/
#define IRC_RPL_WELCOME "001"
+// @}
#endif /* IRC_CMD_H */