+++ /dev/null
-/*
-** 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
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-**
-*/
-
-#include <glib.h>
-#include <gnet.h>
-#include <stdio.h>
-#include <unistd.h>
-#include "log.h"
-#include "nethook.h"
-#include "proto_detect.h"
-
-#define CONFFILE SYSCONFDIR "/improxy.conf"
-
-void new_client (GServer* server, GConn* conn, gpointer data)
-{
- net_hook_t* hook;
- if (conn == NULL)
- {
- g_critical ("Server has received an error event.");
- return;
- }
- g_message ("Received connection from %s.", conn->hostname);
- hook = proto_detect_new (conn);
- gnet_conn_read (conn);
-}
-
-static gchar* configfile;
-
-static GOptionEntry opt_entries[] =
- {
- { "config-file", 'c', 0, G_OPTION_ARG_FILENAME, &configfile,
- "Configuration file location", "file" },
- { NULL }
- };
-
-int main (int argc, char** argv)
-{
-
- GOptionContext* opt_ctx;
- GKeyFile *keyfile;
- GInetAddr* inetaddr;
- gchar* conf_address;
- gint port;
-
- gnet_init ();
- im_log_init ();
-
- configfile = CONFFILE;
- opt_ctx = g_option_context_new ("");
- g_option_context_add_main_entries (opt_ctx, opt_entries, NULL);
- if (!g_option_context_parse (opt_ctx, &argc, &argv, NULL))
- {
- g_log (NULL, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL,
- "Could not parse command line options.");
- }
- g_option_context_free (opt_ctx);
-
- keyfile = g_key_file_new ();
-
- g_key_file_load_from_file (keyfile, configfile, G_KEY_FILE_NONE, NULL);
-
- conf_address = g_key_file_get_string (keyfile, "global", "address", NULL);
- port = g_key_file_get_integer (keyfile, "global", "port", NULL);
-
- g_message ("Listen address is %s:%d.", conf_address, port);
-
- inetaddr = gnet_inetaddr_new_nonblock (conf_address, port);
- gnet_server_new (inetaddr, port, new_client, NULL);
-
- daemon (0, 0);
-
- g_main_loop_run (g_main_loop_new (g_main_context_default (), TRUE));
-
- return 0;
-
-}
--- /dev/null
+/*
+** 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
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+*/
+
+#include <glib.h>
+#include <gnet.h>
+#include <stdio.h>
+#include <unistd.h>
+#include "log.h"
+#include "nethook.h"
+#include "proto_detect.h"
+
+#define CONFFILE SYSCONFDIR "/improxy.conf"
+
+void new_client (GServer* server, GConn* conn, gpointer data)
+{
+ net_hook_t* hook;
+ if (conn == NULL)
+ {
+ g_critical ("Server has received an error event.");
+ return;
+ }
+ g_message ("Received connection from %s.", conn->hostname);
+ hook = proto_detect_new (conn);
+ gnet_conn_read (conn);
+}
+
+static gchar* configfile;
+
+static GOptionEntry opt_entries[] =
+ {
+ { "config-file", 'c', 0, G_OPTION_ARG_FILENAME, &configfile,
+ "Configuration file location", "file" },
+ { NULL }
+ };
+
+int main (int argc, char** argv)
+{
+
+ GOptionContext* opt_ctx;
+ GKeyFile *keyfile;
+ GInetAddr* inetaddr;
+ gchar* conf_address;
+ gint port;
+
+ gnet_init ();
+ im_log_init ();
+
+ configfile = CONFFILE;
+ opt_ctx = g_option_context_new ("");
+ g_option_context_add_main_entries (opt_ctx, opt_entries, NULL);
+ if (!g_option_context_parse (opt_ctx, &argc, &argv, NULL))
+ {
+ g_log (NULL, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL,
+ "Could not parse command line options.");
+ }
+ g_option_context_free (opt_ctx);
+
+ keyfile = g_key_file_new ();
+
+ g_key_file_load_from_file (keyfile, configfile, G_KEY_FILE_NONE, NULL);
+
+ conf_address = g_key_file_get_string (keyfile, "global", "address", NULL);
+ port = g_key_file_get_integer (keyfile, "global", "port", NULL);
+
+ g_message ("Listen address is %s:%d.", conf_address, port);
+
+ inetaddr = gnet_inetaddr_new_nonblock (conf_address, port);
+ gnet_server_new (inetaddr, port, new_client, NULL);
+
+ daemon (0, 0);
+
+ g_main_loop_run (g_main_loop_new (g_main_context_default (), TRUE));
+
+ return 0;
+
+}