terom@26: #ifndef IRC_CHAN_H terom@26: #define IRC_CHAN_H terom@26: terom@26: /** terom@26: * @file terom@26: * terom@26: * Support for IRC channels, including tracking their state and actions on them. terom@26: */ terom@26: struct irc_chan_info; terom@26: struct irc_chan; terom@26: terom@26: #include "irc_net.h" terom@26: #include "error.h" terom@26: #include terom@26: terom@26: /** terom@26: * IRC channel info, as required to create an irc_chan terom@26: */ terom@26: struct irc_chan_info { terom@26: /** Channel name, with the [#&!] prefix */ terom@26: const char *channel; terom@26: terom@26: }; terom@26: terom@26: /** terom@26: * General IRC channel states terom@26: */ terom@26: enum irc_chan_state { terom@26: /** Initialized, but idle */ terom@26: IRC_CHAN_INIT, terom@26: terom@26: /** JOIN request sent */ terom@26: IRC_CHAN_JOINING, terom@26: terom@26: /** Currently joined to the channel */ terom@26: IRC_CHAN_JOINED, terom@26: }; terom@26: terom@26: /** terom@26: * IRC channel state terom@26: */ terom@26: struct irc_chan { terom@26: /** The irc_net.channels list */ terom@26: TAILQ_ENTRY(irc_chan) node; terom@26: terom@26: /* The network we're on */ terom@26: struct irc_net *net; terom@26: terom@26: /** Our identifying info */ terom@26: struct irc_chan_info info; terom@26: terom@26: /** Current state */ terom@26: enum irc_chan_state state; terom@26: }; terom@26: terom@26: /** terom@26: * Return the channel's name terom@26: */ terom@26: const char* irc_chan_name (struct irc_chan *chan); terom@26: terom@26: /** terom@26: * Build/initialize a new irc_chan struct. This does not have any external side-effects. terom@26: * terom@26: * The channel will be in the IRC_CHAN_INIT state after this. terom@26: * terom@26: * @param chan_ptr the new irc_chan is returned via this pointer terom@26: * @param net the irc_net this channel is on terom@26: * @param info the channel's identifying information terom@26: * @param err error codes are returned via this terom@26: */ terom@26: err_t irc_chan_create (struct irc_chan **chan_ptr, struct irc_net *net, const struct irc_chan_info *info, struct error_info *err); terom@26: terom@26: /** terom@26: * Send the initial JOIN message. terom@26: * terom@26: * The channel must be in the IRC_CHAN_INIT state, and will transition to the IRC_CHAN_JOINING state. terom@26: * terom@26: * @param chan the channel to JOIN terom@26: */ terom@26: err_t irc_chan_join (struct irc_chan *chan); terom@26: terom@26: #endif