src/irc_conn.h
author Tero Marttila <terom@fixme.fi>
Sat, 28 Feb 2009 22:47:39 +0200
changeset 18 dedf137b504f
child 20 d9c4c2980a0d
permissions -rw-r--r--
add initial irc_conn code that can register
#ifndef IRC_CONN_H
#define IRC_CONN_H

/*
 * Per-connection IRC setup and state/protocol handling.
 */

#include "sock.h"
#include "line_proto.h"
#include "irc_line.h"
#include "error.h"

/*
 * A connection to an IRC server.
 */
struct irc_conn {
    /* We are a line-based protocol */
    struct line_proto *lp;
};

// XXX: this should probably be slightly reworked
struct irc_conn_config {
    /* Nickname to use on that server */
    const char *nickname;

    /* Username to supply */
    const char *username;

    /* Realname to supply */
    const char *realname;
};

/*
 * Create a new irc_conn using the given sock_stream, which should be connected to an IRC server. The parameters given
 * in \a config will be used to identify with the IRC server.
 *
 * On success, the resulting irc_conn is returned via *conn with SUCCESS. Otherwise, -ERR_* and error info is returned
 * via *err.
 */
err_t irc_conn_create (struct irc_conn **conn, struct sock_stream *sock, const struct irc_conn_config *config, struct error_info *err);

/*
 * Send an IRC message directly
 */
err_t irc_conn_send (struct irc_conn *conn, const struct irc_line *line);

/*
 * Send a NICK message
 */
err_t irc_conn_NICK (struct irc_conn *conn, const char *nickname);

/*
 * Send a USER message
 */
err_t irc_conn_USER (struct irc_conn *conn, const char *username, const char *realname);


#endif /* IRC_CONN_H */