summaryrefslogtreecommitdiff
path: root/src/ivyprobe.c
diff options
context:
space:
mode:
authorfcolin2005-07-26 17:08:42 +0000
committerfcolin2005-07-26 17:08:42 +0000
commit0ca33f5bf0d079dbe61cee5a86b7ba720deef766 (patch)
tree90f923a693a5c1d85b3d889b8e2acc760ee8c9a6 /src/ivyprobe.c
parenteadd80325fe2f74a0eedf88b68cc43b2bcb0c915 (diff)
downloadivy-c-0ca33f5bf0d079dbe61cee5a86b7ba720deef766.zip
ivy-c-0ca33f5bf0d079dbe61cee5a86b7ba720deef766.tar.gz
ivy-c-0ca33f5bf0d079dbe61cee5a86b7ba720deef766.tar.bz2
ivy-c-0ca33f5bf0d079dbe61cee5a86b7ba720deef766.tar.xz
Compile Windows remove HANDLE macro conflict
make ivyprobe like Unix version with stdin thread reading
Diffstat (limited to 'src/ivyprobe.c')
-rw-r--r--src/ivyprobe.c42
1 files changed, 38 insertions, 4 deletions
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