terom@25: #ifndef IRC_NET_H terom@25: #define IRC_NET_H terom@25: terom@25: /** terom@25: * @file terom@25: * terom@25: * Support for IRC networks. This is similar to an IRC connection, but we keep track of channel state, and handle terom@25: * reconnects. terom@25: */ terom@25: #include "error.h" terom@25: #include "irc_conn.h" terom@26: #include "irc_chan.h" terom@26: #include terom@25: terom@25: /** terom@25: * Configuration info for an IRC network terom@25: */ terom@25: struct irc_net_info { terom@25: /** The name of the network */ terom@25: const char *network; terom@25: terom@25: /** The hostname to connect to */ terom@25: const char *hostname; terom@25: terom@25: /** Service name (port) */ terom@25: const char *service; terom@25: terom@25: /** SSL? */ terom@25: bool use_ssl; terom@25: terom@25: /** Protocol registration info */ terom@25: struct irc_conn_config register_info; terom@25: }; terom@25: terom@25: /** terom@25: * IRC Network state terom@25: */ terom@25: struct irc_net { terom@25: /* The current connection */ terom@25: struct irc_conn *conn; terom@25: terom@26: /** The list of IRC channel states */ terom@26: TAILQ_HEAD(irc_net_chan_list, irc_chan) channels; terom@25: }; terom@25: terom@25: /** terom@25: * Create a new IRC network state, using the given network info to connect/register. terom@25: * terom@25: * Errors are returned via *err, also returning the error code. terom@26: * terom@26: * @param net the new irc_net struct is returned via this pointer terom@26: * @param info network informated, used to connect and register terom@26: * @param err used to return extended error information terom@25: */ terom@25: err_t irc_net_create (struct irc_net **net, const struct irc_net_info *info, struct error_info *err); terom@25: terom@26: /** terom@26: * Create a new irc_chan, add it to our channel list, and send the JOIN request. terom@26: */ terom@26: struct irc_chan* irc_net_add_chan (struct irc_net *net, const struct irc_chan_info *info); terom@26: terom@26: /** terom@26: * Look up an existing irc_chan by name, returning NULL if not found. terom@26: * terom@26: * @param net the network state terom@26: * @param channel the channel name terom@26: */ terom@26: struct irc_chan* irc_net_get_chan (struct irc_net *net, const char *channel); terom@26: terom@25: #endif