src/irc_conn.h
changeset 18 dedf137b504f
child 20 d9c4c2980a0d
equal deleted inserted replaced
17:5001564ac5fc 18:dedf137b504f
       
     1 #ifndef IRC_CONN_H
       
     2 #define IRC_CONN_H
       
     3 
       
     4 /*
       
     5  * Per-connection IRC setup and state/protocol handling.
       
     6  */
       
     7 
       
     8 #include "sock.h"
       
     9 #include "line_proto.h"
       
    10 #include "irc_line.h"
       
    11 #include "error.h"
       
    12 
       
    13 /*
       
    14  * A connection to an IRC server.
       
    15  */
       
    16 struct irc_conn {
       
    17     /* We are a line-based protocol */
       
    18     struct line_proto *lp;
       
    19 };
       
    20 
       
    21 // XXX: this should probably be slightly reworked
       
    22 struct irc_conn_config {
       
    23     /* Nickname to use on that server */
       
    24     const char *nickname;
       
    25 
       
    26     /* Username to supply */
       
    27     const char *username;
       
    28 
       
    29     /* Realname to supply */
       
    30     const char *realname;
       
    31 };
       
    32 
       
    33 /*
       
    34  * Create a new irc_conn using the given sock_stream, which should be connected to an IRC server. The parameters given
       
    35  * in \a config will be used to identify with the IRC server.
       
    36  *
       
    37  * On success, the resulting irc_conn is returned via *conn with SUCCESS. Otherwise, -ERR_* and error info is returned
       
    38  * via *err.
       
    39  */
       
    40 err_t irc_conn_create (struct irc_conn **conn, struct sock_stream *sock, const struct irc_conn_config *config, struct error_info *err);
       
    41 
       
    42 /*
       
    43  * Send an IRC message directly
       
    44  */
       
    45 err_t irc_conn_send (struct irc_conn *conn, const struct irc_line *line);
       
    46 
       
    47 /*
       
    48  * Send a NICK message
       
    49  */
       
    50 err_t irc_conn_NICK (struct irc_conn *conn, const char *nickname);
       
    51 
       
    52 /*
       
    53  * Send a USER message
       
    54  */
       
    55 err_t irc_conn_USER (struct irc_conn *conn, const char *username, const char *realname);
       
    56 
       
    57 
       
    58 #endif /* IRC_CONN_H */