add sock_stream_release/line_proto_release/irc_conn_release functions, and add proper cleanup to irc_net_create
#ifndef SOCK_TCP_H
#define SOCK_TCP_H
/**
* @file
*
* TCP implementation of sock_stream interface.
*/
#include "sock_internal.h"
/**
* Contains the base sock_stream struct, and the file descriptor
*/
struct sock_tcp {
/* The base struct for sock_stream_* functions */
struct sock_stream base;
/* The OS file descriptor */
int fd;
/* The IO events */
struct event *ev_read, *ev_write;
};
/**
* Get a sock_stream pointer from a sock_tcp pointer
*/
#define SOCK_TCP_BASE(sock_ptr) (&(sock_ptr)->base)
/**
* Get the sock_stream.err pointer from a sock_tcp pointer
*/
#define SOCK_TCP_ERR(sock_ptr) SOCK_ERR(SOCK_TCP_BASE(sock_ptr))
/**
* Allocate a new blank sock_tcp with a correctly initialized base
*/
err_t sock_tcp_alloc (struct sock_tcp **sock_ptr);
/**
* Initialize a blank sock_tcp with a given already-existing fd
*/
err_t sock_tcp_init_fd (struct sock_tcp *sock, int fd);
/**
* Initialize sock_tcp.ev_* to use the socket's fd with the given callback. The ev's are not activated yet.
*/
err_t sock_tcp_init_ev (struct sock_tcp *sock, void (*ev_cb) (evutil_socket_t, short, void *), void *arg);
/**
* Initialize a blank sock_tcp by connecting
*/
err_t sock_tcp_init_connect (struct sock_tcp *sock, const char *hostname, const char *service);
/**
* Set the socket's nonblock mode
*/
err_t sock_tcp_set_nonblock (struct sock_tcp *sock, int nonblock);
/**
* event_add the specified ev_* events.
*/
err_t sock_tcp_add_event (struct sock_tcp *sock, short mask);
/**
* Close a connected sock_tcp
*/
void sock_tcp_close (struct sock_tcp *sock);
/**
* Free a non-connected sock_tcp
*/
void sock_tcp_free (struct sock_tcp *sock);
#endif /* SOCK_TCP_H */