diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/Makefile.win32 | 2 | ||||
-rw-r--r-- | src/ivychannel.h | 8 | ||||
-rw-r--r-- | src/ivyglibloop.c | 2 | ||||
-rwxr-xr-x | src/ivyglutloop.c | 2 | ||||
-rw-r--r-- | src/ivyloop.c | 4 | ||||
-rw-r--r-- | src/ivyprobe.c | 42 | ||||
-rw-r--r-- | src/ivysocket.c | 16 | ||||
-rw-r--r-- | src/ivysocket.h | 2 | ||||
-rw-r--r-- | src/ivyxtloop.c | 2 |
9 files changed, 56 insertions, 24 deletions
diff --git a/src/Makefile.win32 b/src/Makefile.win32 index 6a5e5ce..2f318f1 100755 --- a/src/Makefile.win32 +++ b/src/Makefile.win32 @@ -34,7 +34,7 @@ PCREOBJ = #CC=gcc #CFLAGS = -g -Wall -CFLAGS = -DWIN32 -nologo -GS -Zi -DDEBUG +CFLAGS = -DWIN32 -nologo -GS -Zi #-DDEBUG #LIBTOOL=ar q # linux and solaris #LIBTOOL=libtool -static -o LIBTOOL=lib -nologo /out: diff --git a/src/ivychannel.h b/src/ivychannel.h index b2c3eb2..fe1d2c7 100644 --- a/src/ivychannel.h +++ b/src/ivychannel.h @@ -25,16 +25,16 @@ extern "C" { #ifdef WIN32 #include <windows.h> -#define HANDLE SOCKET +#define IVY_HANDLE SOCKET #else -#define HANDLE int +#define IVY_HANDLE int #endif typedef struct _channel *Channel; /* callback declenche par la gestion de boucle sur evenement exception sur le canal */ typedef void (*ChannelHandleDelete)( void *data ); /* callback declenche par la gestion de boucle sur donnees pretes sur le canal */ -typedef void (*ChannelHandleRead)( Channel channel, HANDLE fd, void *data); +typedef void (*ChannelHandleRead)( Channel channel, IVY_HANDLE fd, void *data); /* fonction appele par le bus pour initialisation */ extern void IvyChannelInit(void); @@ -43,7 +43,7 @@ extern void IvyChannelStop(void); /* fonction appele par le bus pour mise en place des callback sur le canal */ extern Channel IvyChannelOpen( - HANDLE fd, + IVY_HANDLE fd, void *data, ChannelHandleDelete handle_delete, ChannelHandleRead handle_read diff --git a/src/ivyglibloop.c b/src/ivyglibloop.c index 438e22d..54608df 100644 --- a/src/ivyglibloop.c +++ b/src/ivyglibloop.c @@ -64,7 +64,7 @@ void IvyChannelStop( ) } -Channel IvyChannelOpen(HANDLE fd, void *data, +Channel IvyChannelOpen(IVY_HANDLE fd, void *data, ChannelHandleDelete handle_delete, ChannelHandleRead handle_read ) { diff --git a/src/ivyglutloop.c b/src/ivyglutloop.c index 95430e5..4c02762 100755 --- a/src/ivyglutloop.c +++ b/src/ivyglutloop.c @@ -98,7 +98,7 @@ static void IvyGlutHandleChannelDelete( int source, GLUTInputId id, void *data ) (*channel->handle_delete)(channel->data); } -Channel IvyChannelOpen(HANDLE fd, void *data, +Channel IvyChannelOpen(IVY_HANDLE fd, void *data, ChannelHandleDelete handle_delete, ChannelHandleRead handle_read ) diff --git a/src/ivyloop.c b/src/ivyloop.c index 3948605..d90fa6c 100644 --- a/src/ivyloop.c +++ b/src/ivyloop.c @@ -42,7 +42,7 @@ struct _channel { Channel next; - HANDLE fd; + IVY_HANDLE fd; void *data; int tobedeleted; ChannelHandleDelete handle_delete; @@ -88,7 +88,7 @@ ChannelDefferedDelete () } } -Channel IvyChannelOpen (HANDLE fd, void *data, +Channel IvyChannelOpen (IVY_HANDLE fd, void *data, ChannelHandleDelete handle_delete, ChannelHandleRead handle_read ) diff --git a/src/ivyprobe.c b/src/ivyprobe.c index 86ee653..aa96246 100644 --- a/src/ivyprobe.c +++ b/src/ivyprobe.c @@ -103,7 +103,8 @@ char * Chop(char *arg) return arg; } -void HandleStdin (Channel channel, HANDLE fd, void *data) +void HandleStdin (Channel channel, IVY_HANDLE fd, void *data) + { char buf[4096]; char *line; @@ -115,9 +116,13 @@ void HandleStdin (Channel channel, HANDLE fd, void *data) int err; line = fgets(buf, 4096, stdin); if (!line) { +#ifdef WIN32 +#else IvyChannelClose (channel); +#endif IvyStop(); return; + } if (*line == '.') { cmd = strtok (line, ".: \n"); @@ -225,7 +230,33 @@ void HandleStdin (Channel channel, HANDLE fd, void *data) } } } - +#ifdef WIN32 +DWORD WINAPI HandleStdinThread( LPVOID lpParam ) +{ + while( 1 ) + HandleStdin( 0,0,0); +} +void CraeteStdinThread() +{ + DWORD dwThreadId, dwThrdParam = 1; + HANDLE hThread; + + hThread = CreateThread( + NULL, // default security attributes + 0, // use default stack size + HandleStdinThread, // thread function + &dwThrdParam, // argument to thread function + 0, // use default creation flags + &dwThreadId); // returns the thread identifier + + // Check the return value for success. + + if (hThread == NULL) + { + printf( "CreateThread failed (%d)\n", GetLastError() ); + } +} +#endif void ApplicationCallback (IvyClientPtr app, void *user_data, IvyApplicationEvent event) { char *appname; @@ -335,8 +366,11 @@ int main(int argc, char *argv[]) IvyBindMsg (Callback, NULL, argv[optind]); if (wait_count == 0) -#ifndef WIN32 -/* Stdin not compatible with select , select only accept socket */ +#ifdef WIN32 + /* Stdin not compatible with select , select only accept socket */ + /* use Thread to Read StdIn */ + CraeteStdinThread(); +#else IvyChannelOpen (0, NULL, NULL, HandleStdin); #endif diff --git a/src/ivysocket.c b/src/ivysocket.c index 396ad41..22a593e 100644 --- a/src/ivysocket.c +++ b/src/ivysocket.c @@ -45,7 +45,7 @@ struct _server { Server next; - HANDLE fd; + IVY_HANDLE fd; Channel channel; unsigned short port; SocketCreate create; @@ -55,7 +55,7 @@ struct _server { struct _client { Client next; - HANDLE fd; + IVY_HANDLE fd; Channel channel; unsigned short port; struct sockaddr_in from; @@ -141,7 +141,7 @@ static void DeleteServerSocket(void *data) close (server->fd ); IVY_LIST_REMOVE (servers_list, server); } -static void HandleSocket (Channel channel, HANDLE fd, void *data) +static void HandleSocket (Channel channel, IVY_HANDLE fd, void *data) { Client client = (Client)data; char *ptr; @@ -231,11 +231,11 @@ static Client CreateClient(int handle) return client; } -static void HandleServer(Channel channel, HANDLE fd, void *data) +static void HandleServer(Channel channel, IVY_HANDLE fd, void *data) { Server server = (Server ) data; Client client; - HANDLE ns; + IVY_HANDLE ns; socklen_t addrlen; struct sockaddr_in remote2; #ifdef DEBUG @@ -264,7 +264,7 @@ Server SocketServer(unsigned short port, SocketInterpretation interpretation ) { Server server; - HANDLE fd; + IVY_HANDLE fd; int one=1; struct sockaddr_in local; socklen_t addrlen; @@ -460,7 +460,7 @@ Client SocketConnectAddr (struct in_addr * addr, unsigned short port, SocketDelete handle_delete ) { - HANDLE handle; + IVY_HANDLE handle; Client client; struct sockaddr_in remote; @@ -496,7 +496,7 @@ Client SocketBroadcastCreate ( SocketInterpretation interpretation ) { - HANDLE handle; + IVY_HANDLE handle; Client client; struct sockaddr_in local; int on = 1; diff --git a/src/ivysocket.h b/src/ivysocket.h index 69fc2c0..f5ac390 100644 --- a/src/ivysocket.h +++ b/src/ivysocket.h @@ -32,13 +32,11 @@ extern "C" { #ifdef __MINGW32__ #include <ws2tcpip.h> #endif -#define HANDLE SOCKET #define socklen_t int #ifndef IN_MULTICAST #define IN_MULTICAST(i) (((long)(i) & 0xf0000000) == 0xe0000000) #endif #else -#define HANDLE int #include <netinet/in.h> #endif #ifdef __INTERIX diff --git a/src/ivyxtloop.c b/src/ivyxtloop.c index 32094e9..0406498 100644 --- a/src/ivyxtloop.c +++ b/src/ivyxtloop.c @@ -111,7 +111,7 @@ void IvyXtChannelAppContext( XtAppContext cntx ) app = cntx; } -Channel IvyChannelOpen(HANDLE fd, void *data, +Channel IvyChannelOpen(IVY_HANDLE fd, void *data, ChannelHandleDelete handle_delete, ChannelHandleRead handle_read ) |