Implement server port support and update copyright year and style.
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Fri, 3 Jul 2009 04:59:54 +0000 (01:59 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Fri, 3 Jul 2009 04:59:54 +0000 (01:59 -0300)
null.c
null.h
popproxy.c

diff --git a/null.c b/null.c
index 2e3e265..9aa94de 100644 (file)
--- a/null.c
+++ b/null.c
 #include <glib.h>
 #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,22 @@ 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_thook;
+  net_hook_t *hook;
   int fd;
   HCConn *conn;
   hook = g_slice_new (net_hook_t);
@@ -60,15 +65,16 @@ static net_hook_t* null_server_hook_new (net_hook_t* client_hook, char *server)
   hook->data = NULL;
   conn = hc_conn_new (NULL, NULL);
   hook->conn = hc_conn_new (nethook_event, hook);
-  fd = hc_tcp_connect (server, "995");
+  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_thook;
+  net_hook_t *hook;
   hook = g_slice_new (net_hook_t);
   hook->conn = conn;
   hook->peer = NULL;
@@ -77,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);
 }
diff --git a/null.h b/null.h
index e48a5eb..df848a8 100644 (file)
--- a/null.h
+++ b/null.h
@@ -1,5 +1,6 @@
 /*
 ** Copyright (C) 2006 Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
+** Copyright (C) 2009 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -23,7 +24,7 @@
 #include "nethook.h"
 #include "hcconn.h"
 
-net_hook_t* null_hook_new (HCConn*, char*);
-void null_destroy (net_hook_t*);
+net_hook_t * null_hook_new (HCConn *, char *, char *);
+void null_destroy (net_hook_t *);
 
 #endif
index 4161b92..78403ba 100644 (file)
@@ -41,10 +41,11 @@ struct pop_address
   char *port;
 };
 
-void new_client (int fd, struct sockaddr* addr, socklen_t saddr, gpointer data)
+static void
+new_client (int fd, struct sockaddr *addr, socklen_t saddr, gpointer data)
 {
   HCConn *conn;
-  net_hook_thook;
+  net_hook_t *hook;
   struct pop_address *address = data;
   if (fd < 0)
     {
@@ -55,11 +56,11 @@ void new_client (int fd, struct sockaddr* addr, socklen_t saddr, gpointer data)
              inet_ntoa (((struct sockaddr_in *) addr)->sin_addr));
   conn = hc_conn_new (NULL, NULL);
   hc_conn_set_driver_channel (conn, fd);
-  hook = null_hook_new (conn, address->server);
+  hook = null_hook_new (conn, address->server, address->port);
   pop_hook_new (hook);
 }
 
-static gcharconfigfile;
+static gchar *configfile;
 
 static GOptionEntry opt_entries[] =
   {
@@ -68,15 +69,15 @@ static GOptionEntry opt_entries[] =
     { NULL }
   };
 
-int main (int argc, char** argv)
+int main (int argc, char **argv)
 {
 
-  GOptionContextopt_ctx;
+  GOptionContext *opt_ctx;
   GKeyFile *keyfile;
   GError *error;
   int server_fd;
-  gcharconf_address;
-  gcharport;
+  gchar *conf_address;
+  gchar *port;
   gchar *server_address;
   gchar *server_port;
   struct pop_address pop_address;
@@ -94,7 +95,7 @@ int main (int argc, char** argv)
     }
   g_option_context_free (opt_ctx);
   
-  keyfile =  g_key_file_new ();
+  keyfile = g_key_file_new ();
 
   error = NULL;
   if (g_key_file_load_from_file (keyfile, configfile,