X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=nethook.c;h=838099012e732d2bc966361ab3904f3940c1a898;hb=2f6f433ac65fb6f4208a3ac8519cf53941745cc4;hp=1630d926bc4f1350eaecacf1f4205522e0ab1328;hpb=92d273cbba6ec73c80b77270910b83dfe3bbfab5;p=cascardo%2Frnetproxy.git diff --git a/nethook.c b/nethook.c index 1630d92..8380990 100644 --- a/nethook.c +++ b/nethook.c @@ -1,22 +1,41 @@ -#include +/* +** Copyright (C) 2006 Thadeu Lima de Souza Cascardo +** +** 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: