src/irc_cmd.h
author Tero Marttila <terom@fixme.fi>
Thu, 12 Mar 2009 18:48:42 +0200
changeset 39 a4891d71aca9
parent 37 4fe4a3c4496e
child 69 6f298b6e0d5f
permissions -rw-r--r--
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
#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 */