From b64640f991932bda111e97dd1eb28553e5202b9e Mon Sep 17 00:00:00 2001 From: fcolin Date: Fri, 12 Mar 2004 09:37:05 +0000 Subject: compile avec MINGW sous WIN32 --- src/Test.tcl | 2 +- src/ivyloop.c | 1 + src/ivyprobe.c | 7 +++++++ src/ivysocket.c | 3 +++ src/ivytcl.c | 41 ++++++++++++++++++++++++++++------------- 5 files changed, 40 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/Test.tcl b/src/Test.tcl index aad5cd4..052b3bb 100755 --- a/src/Test.tcl +++ b/src/Test.tcl @@ -9,7 +9,7 @@ proc msgCB {str} { puts "TCL:Message:$str" } Ivy::init TESTTCL "TESTTCL Ready" conCB discCB -Ivy::start 143.196.53.255:2011 +Ivy::start "" Ivy::bind "(.*)" msgCB Ivy::applist Ivy::send test diff --git a/src/ivyloop.c b/src/ivyloop.c index 2ba0608..c3022ab 100644 --- a/src/ivyloop.c +++ b/src/ivyloop.c @@ -179,6 +179,7 @@ void IvyMainLoop(void(*hook)(void)) exset = open_fds; ready = select(64, &rdset, 0, &exset, TimerGetSmallestTimeout()); if (ready < 0 && (errno != EINTR)) { + fprintf (stderr, "select error %d\n",errno); perror("select"); return; } diff --git a/src/ivyprobe.c b/src/ivyprobe.c index 99cb5cc..a5a477b 100644 --- a/src/ivyprobe.c +++ b/src/ivyprobe.c @@ -33,6 +33,10 @@ #include #ifdef WIN32 #include +#ifdef __MINGW32__ +#include +#include +#endif #else #include #include @@ -309,8 +313,11 @@ int main(int argc, char *argv[]) IvyGlutChannelSetUp (0, NULL, NULL, HandleStdin); #endif #ifdef IVYMAINLOOP +#ifndef WIN32 +/* Stdin not compatible with select , select only accept socket */ IvyChannelSetUp (0, NULL, NULL, HandleStdin); #endif +#endif IvyStart (bus); diff --git a/src/ivysocket.c b/src/ivysocket.c index 409a66f..234f4c9 100644 --- a/src/ivysocket.c +++ b/src/ivysocket.c @@ -214,6 +214,9 @@ Server SocketServer(unsigned short port, if (setsockopt(fd,SOL_SOCKET,SO_REUSEADDR,(char*)&one,sizeof(one)) < 0) { +#ifdef WIN32 + fprintf(stderr," setsockopt %d\n",WSAGetLastError()); +#endif perror ("*** set socket option SO_REUSEADDR ***"); exit(0); } diff --git a/src/ivytcl.c b/src/ivytcl.c index bdb2a55..68f02f4 100755 --- a/src/ivytcl.c +++ b/src/ivytcl.c @@ -31,7 +31,8 @@ struct _channel { HANDLE fd; void *data; - ChannelHandleDelete handle_delete; + Tcl_Channel tcl_channel; + ChannelHandleDelete handle_delete; ChannelHandleRead handle_read; }; @@ -43,28 +44,30 @@ ChannelInit channel_init = IvyTclChannelInit; ChannelSetUp channel_setup = IvyTclChannelSetUp; ChannelClose channel_close = IvyTclChannelClose; +#ifdef WIN32 +WSADATA WsaData; +#endif + void IvyTclChannelInit(void) { - +#ifdef WIN32 + int error; +#endif if ( channel_initialized ) return; /* pour eviter les plantages quand les autres applis font core-dump */ #ifndef WIN32 signal( SIGPIPE, SIG_IGN); #endif +#ifdef WIN32 + error = WSAStartup (0x0101, &WsaData); + if (error == SOCKET_ERROR) { + printf ("WSAStartup failed.\n"); + } +#endif channel_initialized = 1; } - -void IvyTclChannelClose( Channel channel ) -{ - - if ( channel->handle_delete ) - (*channel->handle_delete)( channel->data ); - Tcl_DeleteFileHandler(channel->fd); - ckfree((char *) channel); -} - static void IvyHandleFd(ClientData cd, int mask) @@ -79,6 +82,17 @@ IvyHandleFd(ClientData cd, (*channel->handle_delete)(channel->data); } } + +void IvyTclChannelClose( Channel channel ) +{ + + if ( channel->handle_delete ) + (*channel->handle_delete)( channel->data ); + Tcl_DeleteChannelHandler(channel->tcl_channel, IvyHandleFd, (ClientData) channel); + ckfree((char *) channel); +} + + Channel IvyTclChannelSetUp(HANDLE fd, void *data, ChannelHandleDelete handle_delete, ChannelHandleRead handle_read @@ -99,7 +113,8 @@ Channel IvyTclChannelSetUp(HANDLE fd, void *data, channel->fd = fd; /*printf("Create handle fd %d\n", fd);*/ - Tcl_CreateFileHandler(fd, TCL_READABLE|TCL_EXCEPTION, IvyHandleFd, (ClientData) channel); + channel->tcl_channel = Tcl_MakeTcpClientChannel((void*)fd); + Tcl_CreateChannelHandler(channel->tcl_channel, TCL_READABLE|TCL_EXCEPTION, IvyHandleFd, (ClientData) channel); return channel; } -- cgit v1.1