-#include <gnet.h>
+/*
+** 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 "nethook.h"
-void nethook_event (GConn* conn, GConnEvent* event, gpointer data)
+void
+nethook_event (HCConn* conn, HCEvent event, gpointer data)
{
+ char buffer[4096];
+ int r;
net_hook_t* hook;
hook = (net_hook_t*) data;
- switch (event->type)
+ switch (event)
{
- case GNET_CONN_CONNECT:
+ case HC_EVENT_CONNECT:
hook->connect (hook);
break;
- case GNET_CONN_READ:
- hook->read (hook, event->buffer, event->length);
- break;
- case GNET_CONN_WRITE:
- hook->write (hook);
+ case HC_EVENT_READ:
+ while ((r = hc_conn_read (conn, buffer, sizeof (buffer))) > 0)
+ hook->read (hook, buffer, r);
break;
- case GNET_CONN_CLOSE:
+ case HC_EVENT_CLOSE:
hook->close (hook);
break;
default: