Really remove unused files for popproxy
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Wed, 1 Jul 2009 21:53:39 +0000 (18:53 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Wed, 1 Jul 2009 21:53:39 +0000 (18:53 -0300)
iksemel_extra.c [deleted file]
iksemel_extra.h [deleted file]
jabber.c [deleted file]
jabber.h [deleted file]
jabber_server.c [deleted file]
proto_detect.c [deleted file]
proto_detect.h [deleted file]

diff --git a/iksemel_extra.c b/iksemel_extra.c
deleted file mode 100644 (file)
index 99f3937..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
-** Copyright (C) 2006 Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
-**  
-** 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 "iksemel_extra.h"
-#include <glib.h>
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-struct _iks_extra_stream_t
-{
-  iksStreamHook* hook;
-  void* data;
-  iks* node;
-  int top;
-};
-
-void iks_extra_insert_attrib (iks* node, char** atts)
-{
-  if (atts == NULL)
-    return;
-  while (*atts)
-    {
-      iks_insert_attrib (node, atts[0], atts[1]);
-      atts += 2;
-    }
-}
-
-int tagHook (void* user_data, char* name, char** atts, int type)
-{
-  struct _iks_extra_stream_t* pdata;
-  pdata = (struct _iks_extra_stream_t*) user_data;
-  switch (type)
-    {
-    case IKS_OPEN:
-      if (pdata->top == FALSE || g_str_equal (name, "stream:stream"))
-       {
-         pdata->top = TRUE;
-         pdata->node = iks_new (name);
-         iks_extra_insert_attrib (pdata->node, atts);
-         pdata->hook (pdata->data, IKS_NODE_START, pdata->node);
-         pdata->node = NULL;
-       }
-      else if (pdata->node == NULL)
-       {
-         pdata->node = iks_new (name);
-         iks_extra_insert_attrib (pdata->node, atts);
-       }
-      else
-       {
-         pdata->node = iks_insert (pdata->node, name);
-         iks_extra_insert_attrib (pdata->node, atts);
-       }
-      break;
-    case IKS_CLOSE:
-      if (pdata->node == NULL)
-       {
-         pdata->node = iks_new (name);
-         pdata->hook (pdata->data, IKS_NODE_STOP, pdata->node);
-         pdata->node = NULL;
-         pdata->top = FALSE;
-       }
-      else if (iks_parent (pdata->node) == NULL)
-       {
-         pdata->hook (pdata->data, IKS_NODE_NORMAL, pdata->node);
-         pdata->node = NULL;
-       }
-      else
-       {
-         pdata->node = iks_parent (pdata->node);
-       }
-      break;
-    case IKS_SINGLE:
-      if (pdata->top == FALSE)
-       {
-         return -IKS_OK;
-       }
-      else if (pdata->node == NULL)
-       {
-         pdata->node = iks_new (name);
-         iks_extra_insert_attrib (pdata->node, atts);
-         pdata->hook (pdata->data, IKS_NODE_NORMAL, pdata->node);
-         pdata->node = NULL;
-       }
-      else
-       {
-         pdata->node = iks_insert (pdata->node, name);
-         iks_extra_insert_attrib (pdata->node, atts);
-         pdata->node = iks_parent (pdata->node);
-       }
-      break;
-    default:
-      break;
-    }
-  return IKS_OK;
-}
-
-int dataHook (void* user_data, char* data, size_t len)
-{
-  struct _iks_extra_stream_t* pdata;
-  pdata = (struct _iks_extra_stream_t*) user_data;
-  iks_insert_cdata (pdata->node, data, len);
-  return IKS_OK;
-}
-
-void deleteHook (void* user_data)
-{
-  iks_free (user_data);
-}
-
-iksparser* iks_extra_stream_new (void* data, iksStreamHook* hook)
-{
-  iksparser* parser;
-  struct _iks_extra_stream_t* pdata;
-  pdata = iks_malloc (sizeof (struct _iks_extra_stream_t));
-  pdata->hook = hook;
-  pdata->data = data;
-  pdata->node = NULL;
-  pdata->top = FALSE;
-  parser = iks_sax_extend (iks_stack_new (256, 0),
-                          pdata, tagHook, dataHook, deleteHook);
-  return parser;
-}
diff --git a/iksemel_extra.h b/iksemel_extra.h
deleted file mode 100644 (file)
index eaf1482..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-** Copyright (C) 2006 Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
-**  
-** 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.
-**  
-*/
-
-#ifndef IKSEMEL_EXTRA_H
-#define IKSEMEL_EXTRA_H
-
-#include <iksemel.h>
-
-iksparser* iks_extra_stream_new (void*, iksStreamHook*);
-
-#endif
diff --git a/jabber.c b/jabber.c
deleted file mode 100644 (file)
index 61ed23c..0000000
--- a/jabber.c
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
-** Copyright (C) 2006 Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
-**  
-** 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 <gnet.h>
-#include <glib.h>
-#include <iksemel.h>
-#include <gsasl.h>
-#include "iksemel_extra.h"
-#include "jabber.h"
-
-jabber_data_t* jabber_data_new (gpointer hook, gpointer parser)
-{
-  jabber_data_t *data;
-  data = g_slice_new0 (jabber_data_t);
-  data->parser = iks_extra_stream_new (hook, parser);
-  gsasl_init (&(data->ctx));
-  return data;
-}
-
-void jabber_data_destroy (gpointer data)
-{
-  jabber_data_t *jdata = (jabber_data_t*) data;
-  if (jdata->parser)
-    iks_parser_delete (jdata->parser);
-  if (jdata->client)
-    gsasl_finish (jdata->client);
-  if (jdata->server)
-    gsasl_finish (jdata->server);
-  if (jdata->ctx)
-    gsasl_done (jdata->ctx);
-  g_slice_free (jabber_data_t, jdata);
-}
-
-static void jabber_connect (net_hook_t* hook)
-{
-}
-
-static void jabber_close (net_hook_t* hook)
-{
-  if (hook->peer)
-    {
-      hook->peer->peer = NULL;
-      gnet_conn_disconnect (hook->peer->conn);
-    }
-  gnet_conn_delete (hook->conn);
-  jabber_data_destroy (hook->data);
-  g_slice_free (net_hook_t, hook);
-}
-
-static void jabber_write (net_hook_t* hook)
-{
-}
-
-static void jabber_read (net_hook_t* hook, gchar* buffer, size_t len)
-{
-  jabber_data_t *jdata = (jabber_data_t*) hook->data;
-  iks_parse (jdata->parser, buffer, len, FALSE);
-}
-
-void jabber_error (net_hook_t* hook)
-{
-  g_message ("Error in jabber client connection.");
-}
-
-GString* jabber_new_start (iks* node)
-{
-  GString* buffer;
-  buffer = g_string_sized_new (256);
-  g_string_append (buffer, iks_string (iks_stack (node), node));
-  g_string_erase (buffer, buffer->len - 2, 1);
-  return buffer;
-}
-
-void jabber_connect_server (net_hook_t* hook, char* server, iks* node)
-{
-  net_hook_t* server_hook;
-  GString* buffer;
-  g_message ("Received new stream.");
-  if (hook->peer == NULL)
-    {
-      server_hook = jabber_server_hook_new (hook, server);
-      hook->peer = server_hook;
-      g_message ("Trying to connect to server %s.", server);
-      gnet_conn_connect (hook->peer->conn);
-      gnet_conn_read (hook->peer->conn);
-    }
-  buffer = jabber_new_start (node);
-  gnet_conn_write (hook->peer->conn, buffer->str, buffer->len);
-  g_string_free (buffer, TRUE);
-}
-
-void
-jabber_sasl_plain_filter (iks *node)
-{
-  if (g_str_equal (iks_name (node), "auth") &&
-      g_str_equal (iks_find_attrib (node, "xmlns"),
-                                   "urn:ietf:params:xml:ns:xmpp-sasl"))
-    {
-      char *b64;
-      char *uname;
-      gsize uname_len;
-      b64 = iks_cdata (iks_child (node));
-      uname = g_base64_decode (b64, &uname_len);
-      g_message ("User trying authentication as %s", uname);
-      g_free (uname);
-    }
-}
-
-void jabber_send (net_hook_t* hook, iks* node)
-{
-  GString* buffer;
-  jabber_sasl_plain_filter (node);
-  buffer = g_string_new (iks_string (iks_stack (node), node));
-  gnet_conn_write (hook->peer->conn, buffer->str, buffer->len);
-  g_string_free (buffer, TRUE);
-}
-
-int jabber_parser (gpointer data, int type, iks* node)
-{
-  net_hook_t* hook;
-  char* server;
-  hook = (net_hook_t*) data;
-  switch (type)
-    {
-    case IKS_NODE_START:
-      server = iks_find_attrib (node, "to");
-      if (server == NULL)
-       {
-         jabber_error (hook);
-       }
-      jabber_connect_server (hook, server, node);
-      iks_delete (node);
-      break;
-    case IKS_NODE_NORMAL:
-      jabber_send (hook, node);
-      iks_delete (node);
-      break;
-    case IKS_NODE_STOP:
-      gnet_conn_write (hook->peer->conn, "</stream:stream>", 16);
-      break;
-    case IKS_NODE_ERROR:
-      break;
-    }
-  return IKS_OK;
-}
-
-net_hook_t* jabber_hook_new (GConn* conn)
-{
-  net_hook_t* hook;
-  hook = g_slice_new (net_hook_t);
-  hook->conn = conn;
-  hook->peer = NULL;
-  hook->server = FALSE;
-  hook->connect = jabber_connect;
-  hook->close = jabber_close;
-  hook->write = jabber_write;
-  hook->read = jabber_read;
-  hook->data = jabber_data_new (hook, jabber_parser);
-  gnet_conn_set_callback (hook->conn, nethook_event, hook);
-  return hook;
-}
-
-void jabber_destroy (net_hook_t* hook)
-{
-  g_slice_free (net_hook_t, hook);
-}
diff --git a/jabber.h b/jabber.h
deleted file mode 100644 (file)
index 7de6098..0000000
--- a/jabber.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-** Copyright (C) 2006 Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
-**  
-** 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.
-**  
-*/
-
-#ifndef JABBER_H
-#define JABBER_H
-
-#include <gnet.h>
-#include <iksemel.h>
-#include <gsasl.h>
-#include "nethook.h"
-
-typedef struct _jabber_data_t jabber_data_t;
-
-struct _jabber_data_t
-{
-  iksparser *parser;
-  Gsasl *ctx;
-  Gsasl_session *client;
-  Gsasl_session *server;
-};
-
-jabber_data_t* jabber_data_new (gpointer, gpointer);
-void jabber_data_destroy (gpointer);
-
-net_hook_t* jabber_hook_new (GConn *conn);
-void jabber_hook_destroy (net_hook_t*);
-net_hook_t* jabber_server_hook_new (net_hook_t*, char*);
-GString* jabber_new_start (iks* node);
-
-#endif
diff --git a/jabber_server.c b/jabber_server.c
deleted file mode 100644 (file)
index f3cef49..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
-** Copyright (C) 2006 Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
-**  
-** 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 <gnet.h>
-#include <glib.h>
-#include <iksemel.h>
-#include "iksemel_extra.h"
-#include "jabber.h"
-
-static void jabber_server_connect (net_hook_t* hook)
-{
-  g_message ("Connected to jabber server.");
-}
-
-static void jabber_server_close (net_hook_t* hook)
-{
-  if (hook->peer)
-    {
-      hook->peer->peer = NULL;
-      gnet_conn_disconnect (hook->peer->conn);
-    }
-  gnet_conn_delete (hook->conn);
-  jabber_data_destroy (hook->data);
-  g_slice_free (net_hook_t, hook);
-  g_message ("Server disconnected.");
-}
-
-static void jabber_server_write (net_hook_t* hook)
-{
-}
-
-static void jabber_server_read (net_hook_t* hook, gchar* buffer, size_t len)
-{
-  jabber_data_t *jdata = (jabber_data_t*) hook->data;
-  iks_parse (jdata->parser, buffer, len, FALSE);
-}
-
-void jabber_server_tls_filter (iks* node)
-{
-  iks* tls;
-  if (g_str_equal (iks_name (node), "stream:features"))
-    {
-      tls = iks_find (node, "starttls");
-      if (tls)
-       iks_hide (tls);
-    }
-}
-
-void jabber_server_sasl_filter (iks* node)
-{
-  iks* sasl;
-  GString* mechs = NULL;
-  gboolean plain = FALSE;
-  if (g_str_equal (iks_name (node), "stream:features"))
-    {
-      sasl = iks_find (node, "mechanisms");
-      if (sasl && g_str_equal (iks_find_attrib (sasl, "xmlns"),
-                              "urn:ietf:params:xml:ns:xmpp-sasl"))
-       {
-         mechs = g_string_sized_new (256);
-         iks* mech;
-         for (mech = iks_child (sasl); mech != NULL; mech = iks_next (mech))
-           {
-             char* mech_name;
-             mech_name = iks_cdata (iks_child (mech));
-             if (g_str_equal (mech_name, "PLAIN"))
-               plain = TRUE;
-             mechs = g_string_append (mechs, mech_name);
-             mechs = g_string_append_c (mechs, ' ');
-           }
-         g_debug ("Mechanisms supported by server: %s", mechs->str);
-         g_string_free (mechs, TRUE);
-         if (plain)
-           {
-             for (mech = iks_child (sasl); mech != NULL; mech = iks_next (mech))
-               {
-                 char* mech_name;
-                 mech_name = iks_cdata (iks_child (mech));
-                 if (!g_str_equal (mech_name, "PLAIN"))
-                   iks_hide (mech);
-               }
-           }
-       }
-    }
-}
-
-int jabber_server_parser (gpointer data, int type, iks* node)
-{
-  net_hook_t* hook;
-  GString* buffer;
-  hook = (net_hook_t*) data;
-  switch (type)
-    {
-    case IKS_NODE_START:
-      buffer = jabber_new_start (node);
-      gnet_conn_write (hook->peer->conn, buffer->str, buffer->len);
-      g_string_free (buffer, TRUE);
-      iks_delete (node);
-      break;
-    case IKS_NODE_NORMAL:
-      jabber_server_tls_filter (node);
-      jabber_server_sasl_filter (node);
-      buffer = g_string_new (iks_string (iks_stack (node), node));
-      gnet_conn_write (hook->peer->conn, buffer->str, buffer->len);
-      g_string_free (buffer, TRUE);
-      iks_delete (node);
-      break;
-    case IKS_NODE_STOP:
-      gnet_conn_write (hook->peer->conn, "</stream:stream>", 16);
-      break;
-    case IKS_NODE_ERROR:
-      g_debug ("Parse error!!");
-      break;
-    }
-  return IKS_OK;
-}
-
-net_hook_t* jabber_server_hook_new (net_hook_t* client_hook, char* server)
-{
-  net_hook_t* hook;
-  hook = g_slice_new (net_hook_t);
-  hook->conn = gnet_conn_new (server, 5222, nethook_event, hook);
-  hook->peer = client_hook;
-  hook->server = TRUE;
-  hook->connect = jabber_server_connect;
-  hook->close = jabber_server_close;
-  hook->write = jabber_server_write;
-  hook->read = jabber_server_read;
-  hook->data = jabber_data_new (hook, jabber_server_parser);
-  return hook;
-}
diff --git a/proto_detect.c b/proto_detect.c
deleted file mode 100644 (file)
index f325dfe..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
-** Copyright (C) 2006 Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
-**  
-** 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 <gnet.h>
-#include <glib.h>
-#include "proto_detect.h"
-
-static void proto_connect (net_hook_t* hook)
-{
-}
-
-static void proto_close (net_hook_t* hook)
-{
-}
-
-static void proto_write (net_hook_t* hook)
-{
-}
-
-static void proto_read (net_hook_t* hook, gchar* buffer, size_t len)
-{
-  net_hook_t* new_hook;
-  GString* str;
-  str = (GString*) hook->data;
-  g_string_append_len (str, buffer, len);
-  if (str->len >= 7)
-    {
-      if (!strncmp (str->str, "<stream", 7) ||
-         !strncmp (str->str, "<?xml ", 6))
-       {
-         /* Connection is a Jabber client */
-         g_debug ("Connection from %s is a Jabber client.",
-                  hook->conn->hostname);
-         new_hook = jabber_hook_new (hook->conn);
-         new_hook->read (new_hook, str->str, str->len);
-         proto_detect_destroy (hook);
-       }
-      else
-       {
-         g_debug ("Unrecognized protocol from %s.",
-                  hook->conn->hostname);
-         gnet_conn_disconnect (hook->conn);
-         gnet_conn_unref (hook->conn);
-         proto_detect_destroy (hook);
-       }
-    }
-}
-
-net_hook_t* proto_detect_new (GConn* conn)
-{
-  net_hook_t* hook;
-  hook = g_slice_new (net_hook_t);
-  hook->conn = conn;
-  hook->peer = NULL;
-  hook->server = FALSE;
-  hook->connect = proto_connect;
-  hook->close = proto_close;
-  hook->write = proto_write;
-  hook->read = proto_read;
-  hook->data = g_string_sized_new (128);
-  gnet_conn_set_callback (hook->conn, nethook_event, hook);
-  return hook;
-}
-
-void proto_detect_destroy (net_hook_t* hook)
-{
-  if (hook->data != NULL)
-    {
-      g_string_free (hook->data, TRUE);
-    }
-  g_slice_free (net_hook_t, hook);
-}
diff --git a/proto_detect.h b/proto_detect.h
deleted file mode 100644 (file)
index 8d2f765..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
-** Copyright (C) 2006 Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
-**  
-** 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.
-**  
-*/
-
-#ifndef PROTO_DETECT_H
-#define PROTO_DETECT_H
-
-#include <gnet.h>
-#include "nethook.h"
-
-net_hook_t* proto_detect_new (GConn *conn);
-void proto_detect_destroy (net_hook_t*);
-
-#endif