X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=null.c;h=9aa94defecc216b48c8c2758ade0c684843e1123;hb=2f6f433ac65fb6f4208a3ac8519cf53941745cc4;hp=64cb074663f4e96c81c538b2f16cf62d7a448bb6;hpb=873a90517d2fa0538a7ce07c139a53f4cc42a61c;p=cascardo%2Frnetproxy.git diff --git a/null.c b/null.c index 64cb074..9aa94de 100644 --- a/null.c +++ b/null.c @@ -21,11 +21,13 @@ #include #include "null.h" -static void null_connect (net_hook_t* hook) +static void +null_connect (net_hook_t *hook) { } -static void null_close (net_hook_t* hook) +static void +null_close (net_hook_t *hook) { if (hook->peer) { @@ -36,19 +38,24 @@ static void null_close (net_hook_t* hook) g_slice_free (net_hook_t, hook); } -static void null_read (net_hook_t* hook, gchar* buffer, size_t len) +static void +null_read (net_hook_t *hook, gchar *buffer, size_t len) { hc_conn_write (hook->peer->conn, buffer, len); } -static void null_error (net_hook_t* hook) +static void +null_error (net_hook_t *hook) { g_message ("Error in POP3 client connection."); } -static net_hook_t* null_server_hook_new (net_hook_t* client_hook, char *server) +static net_hook_t * +null_server_hook_new (net_hook_t *client_hook, char *server, char *port) { - net_hook_t* hook; + net_hook_t *hook; + int fd; + HCConn *conn; hook = g_slice_new (net_hook_t); hook->peer = client_hook; hook->server = TRUE; @@ -56,13 +63,18 @@ static net_hook_t* null_server_hook_new (net_hook_t* client_hook, char *server) hook->close = null_close; hook->read = null_read; hook->data = NULL; - hook->conn = hc_conn_new (hc_tcp_connect (server, "110"), nethook_event, hook); + conn = hc_conn_new (NULL, NULL); + hook->conn = hc_conn_new (nethook_event, hook); + fd = hc_tcp_connect (server, port); + hc_conn_set_driver_channel (conn, fd); + hc_conn_set_driver_ssl (hook->conn, conn); return hook; } -net_hook_t* null_hook_new (HCConn* conn, char *server) +net_hook_t * +null_hook_new (HCConn *conn, char *server, char *port) { - net_hook_t* hook; + net_hook_t *hook; hook = g_slice_new (net_hook_t); hook->conn = conn; hook->peer = NULL; @@ -71,12 +83,13 @@ net_hook_t* null_hook_new (HCConn* conn, char *server) hook->close = null_close; hook->read = null_read; hook->data = server; - hook->peer = null_server_hook_new (hook, server); + hook->peer = null_server_hook_new (hook, server, port); hc_conn_set_callback (hook->conn, nethook_event, hook); return hook; } -void null_destroy (net_hook_t* hook) +void +null_destroy (net_hook_t *hook) { g_slice_free (net_hook_t, hook); }