From 1e48ff652b95379376044b0a7187e1c75fb76d42 Mon Sep 17 00:00:00 2001 From: fcolin Date: Fri, 21 Apr 2006 16:34:15 +0000 Subject: cleanup sur channel et main loop --- src/ivy.c | 6 ++++++ src/ivychannel.h | 4 +++- src/ivyglibloop.c | 12 +++++------- src/ivyglibloop.h | 23 +---------------------- src/ivyglutloop.c | 13 ++++--------- src/ivyglutloop.h | 21 --------------------- src/ivyloop.c | 2 +- src/ivyprobe.c | 4 ++-- src/ivytcl.c | 13 +++++-------- src/ivyxtloop.c | 12 ++++-------- src/ivyxtloop.h | 24 ------------------------ 11 files changed, 31 insertions(+), 103 deletions(-) diff --git a/src/ivy.c b/src/ivy.c index b78d227..157cf08 100644 --- a/src/ivy.c +++ b/src/ivy.c @@ -551,6 +551,12 @@ void IvySetFilter( int argc, const char **argv) IvyBindingSetFilter( argc, argv ); } +void IvyStop (void) +{ + IvyChannelStop(); +} + + void IvyStart (const char* bus) { diff --git a/src/ivychannel.h b/src/ivychannel.h index 31a17aa..ce6ecd3 100644 --- a/src/ivychannel.h +++ b/src/ivychannel.h @@ -38,7 +38,9 @@ typedef void (*ChannelHandleRead)( Channel channel, HANDLE fd, void *data); /* fonction appele par le bus pour initialisation */ extern void IvyChannelInit(void); - + +extern void IvyChannelStop (void); + /* fonction appele par le bus pour mise en place des callback sur le canal */ extern Channel IvyChannelAdd( HANDLE fd, diff --git a/src/ivyglibloop.c b/src/ivyglibloop.c index aea3c54..c4976b1 100644 --- a/src/ivyglibloop.c +++ b/src/ivyglibloop.c @@ -27,6 +27,7 @@ #include #include "ivydebug.h" +#include "ivychannel.h" #include "ivyglibloop.h" struct _channel { @@ -39,9 +40,6 @@ struct _channel { static int channel_initialized = 0; -ChannelInit channel_init = IvyGlibChannelInit; -ChannelSetUp channel_setup = IvyGlibChannelSetUp; -ChannelClose channel_close = IvyGlibChannelClose; static gboolean IvyGlibHandleChannelRead(GIOChannel *source, GIOCondition condition, @@ -52,7 +50,7 @@ static gboolean IvyGlibHandleChannelDelete(GIOChannel *source, gpointer data); -void IvyGlibChannelInit(void) { +void IvyChannelInit(void) { if ( channel_initialized ) return; /* fixes bug when another app coredumps */ #ifndef WIN32 @@ -63,7 +61,7 @@ void IvyGlibChannelInit(void) { -Channel IvyGlibChannelSetUp(HANDLE fd, void *data, +Channel IvyChannelAdd(HANDLE fd, void *data, ChannelHandleDelete handle_delete, ChannelHandleRead handle_read ) { @@ -88,7 +86,7 @@ Channel IvyGlibChannelSetUp(HANDLE fd, void *data, -void IvyGlibChannelClose( Channel channel ) { +void IvyChannelRemove( Channel channel ) { if ( channel->handle_delete ) (*channel->handle_delete)( channel->data ); g_source_remove( channel->id_read ); @@ -116,7 +114,7 @@ static gboolean IvyGlibHandleChannelDelete(GIOChannel *source, void -IvyStop () +IvyChannelStop () { /* To be implemented */ } diff --git a/src/ivyglibloop.h b/src/ivyglibloop.h index 6941069..e06a923 100644 --- a/src/ivyglibloop.h +++ b/src/ivyglibloop.h @@ -21,28 +21,7 @@ extern "C" { #endif -#define ANYPORT 0 - -#ifdef WIN32 -#include -#define HANDLE SOCKET -#else -#define HANDLE int -#endif - -#include "ivychannel.h" - -extern void IvyGlibChannelInit(void); - -extern Channel IvyGlibChannelSetUp( - HANDLE fd, - void *data, - ChannelHandleDelete handle_delete, - ChannelHandleRead handle_read - ); - -extern void IvyGlibChannelClose( Channel channel ); - +/* Nothnig special */ #ifdef __cplusplus } #endif diff --git a/src/ivyglutloop.c b/src/ivyglutloop.c index 372c268..b383d8f 100755 --- a/src/ivyglutloop.c +++ b/src/ivyglutloop.c @@ -54,12 +54,7 @@ struct _channel { static int channel_initialized = 0; -ChannelInit channel_init = IvyGlutChannelInit; -ChannelSetUp channel_setup = IvyGlutChannelSetUp; -ChannelClose channel_close = IvyGlutChannelClose; - - -void IvyGlutChannelInit(void) +void IvyChannelInit(void) { if ( channel_initialized ) return; @@ -71,7 +66,7 @@ void IvyGlutChannelInit(void) channel_initialized = 1; } -void IvyGlutChannelClose( Channel channel ) +void IvyChannelRemove( Channel channel ) { if ( channel->handle_delete ) @@ -95,7 +90,7 @@ static void IvyGlutHandleChannelDelete( int source, GLUTInputId id, void *data ) (*channel->handle_delete)(channel->data); } -Channel IvyGlutChannelSetUp(HANDLE fd, void *data, +Channel IvyChannelAdd(HANDLE fd, void *data, ChannelHandleDelete handle_delete, ChannelHandleRead handle_read ) @@ -121,7 +116,7 @@ Channel IvyGlutChannelSetUp(HANDLE fd, void *data, void -IvyStop () +IvyChannelStop () { /* To be implemented */ } diff --git a/src/ivyglutloop.h b/src/ivyglutloop.h index 0819a93..9374390 100755 --- a/src/ivyglutloop.h +++ b/src/ivyglutloop.h @@ -26,27 +26,6 @@ extern "C" { /* general Handle */ -#define ANYPORT 0 - -#ifdef WIN32 -#include -#define HANDLE SOCKET -#else -#define HANDLE int -#endif - -#include "ivychannel.h" - -extern void IvyGlutChannelInit(void); - -extern Channel IvyGlutChannelSetUp( - HANDLE fd, - void *data, - ChannelHandleDelete handle_delete, - ChannelHandleRead handle_read -); - -extern void IvyGlutChannelClose( Channel channel ); #ifdef __cplusplus } diff --git a/src/ivyloop.c b/src/ivyloop.c index cc79176..46f8fba 100644 --- a/src/ivyloop.c +++ b/src/ivyloop.c @@ -153,7 +153,7 @@ void IvyChannelInit (void) channel_initialized = 1; } -void IvyStop (void) +void IvyChannelStop (void) { MainLoop = 0; } diff --git a/src/ivyprobe.c b/src/ivyprobe.c index 58f55e3..0ef674a 100644 --- a/src/ivyprobe.c +++ b/src/ivyprobe.c @@ -230,7 +230,7 @@ void ApplicationCallback (IvyClientPtr app, void *user_data, IvyApplicationEvent #ifndef WIN32 /* Stdin not compatible with select , select only accept socket */ if (app_count == wait_count) - IvyChannelSetUp (0, NULL, NULL, HandleStdin); + IvyChannelAdd (0, NULL, NULL, HandleStdin); #endif break; @@ -322,7 +322,7 @@ int main(int argc, char *argv[]) if (wait_count == 0) #ifndef WIN32 /* Stdin not compatible with select , select only accept socket */ - IvyChannelSetUp (0, NULL, NULL, HandleStdin); + IvyChannelAdd (0, NULL, NULL, HandleStdin); #endif IvyStart (bus); diff --git a/src/ivytcl.c b/src/ivytcl.c index 74ed129..a43821a 100755 --- a/src/ivytcl.c +++ b/src/ivytcl.c @@ -29,6 +29,7 @@ #include "ivytcl.h" #include "ivysocket.h" +#include "ivychannel.h" #include "ivy.h" #include "timer.h" @@ -38,10 +39,6 @@ // mais il y a des problemes sur les socket server // Il n'y a pas de Tcl_MakeTCPserver -ChannelInit channel_init = IvyTclChannelInit; -ChannelSetUp channel_setup = IvyTclChannelSetUp; -ChannelClose channel_close = IvyTclChannelClose; - struct _channel { HANDLE fd; void *data; @@ -59,7 +56,7 @@ static int channel_initialized = 0; WSADATA WsaData; #endif -void IvyTclChannelInit(void) +void IvyChannelInit(void) { #ifdef WIN32 int error; @@ -93,7 +90,7 @@ IvyHandleFd(ClientData cd, } } -void IvyTclChannelClose( Channel channel ) +void IvyChannelRemove( Channel channel ) { if ( channel->handle_delete ) @@ -103,7 +100,7 @@ void IvyTclChannelClose( Channel channel ) } -Channel IvyTclChannelSetUp(HANDLE fd, void *data, +Channel IvyChannelAdd(HANDLE fd, void *data, ChannelHandleDelete handle_delete, ChannelHandleRead handle_read ) @@ -138,7 +135,7 @@ void IvyIdleProc(ClientData clientData) #endif void -TclIvyStop () +IvyChannelStop () { /* To be implemented */ #ifndef TCL_CHANNEL_INTEGRATION diff --git a/src/ivyxtloop.c b/src/ivyxtloop.c index b09ccee..6613307 100644 --- a/src/ivyxtloop.c +++ b/src/ivyxtloop.c @@ -57,12 +57,8 @@ static int channel_initialized = 0; static XtAppContext app = NULL; -ChannelInit channel_init = IvyXtChannelInit; -ChannelSetUp channel_setup = IvyXtChannelSetUp; -ChannelClose channel_close = IvyXtChannelClose; - -void IvyXtChannelInit(void) +void IvyChannelInit(void) { if ( channel_initialized ) return; @@ -80,7 +76,7 @@ void IvyXtChannelInit(void) channel_initialized = 1; } -void IvyXtChannelClose( Channel channel ) +void IvyChannelRemove( Channel channel ) { if ( channel->handle_delete ) @@ -110,7 +106,7 @@ void IvyXtChannelAppContext( XtAppContext cntx ) app = cntx; } -Channel IvyXtChannelSetUp(HANDLE fd, void *data, +Channel IvyChannelAdd(HANDLE fd, void *data, ChannelHandleDelete handle_delete, ChannelHandleRead handle_read ) @@ -136,7 +132,7 @@ Channel IvyXtChannelSetUp(HANDLE fd, void *data, void -IvyStop () +IvyChannelStop () { /* To be implemented */ } diff --git a/src/ivyxtloop.h b/src/ivyxtloop.h index c482675..0087274 100644 --- a/src/ivyxtloop.h +++ b/src/ivyxtloop.h @@ -24,30 +24,6 @@ extern "C" { #include -/* general Handle */ - -#define ANYPORT 0 - -#ifdef WIN32 -#include -#define HANDLE SOCKET -#else -#define HANDLE int -#endif - -#include "ivychannel.h" - -extern void IvyXtChannelInit(void); - -extern Channel IvyXtChannelSetUp( - HANDLE fd, - void *data, - ChannelHandleDelete handle_delete, - ChannelHandleRead handle_read -); - -extern void IvyXtChannelClose( Channel channel ); - extern void IvyXtChannelAppContext( XtAppContext cntx ); #ifdef __cplusplus -- cgit v1.1