diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2017-02-07 21:53:22 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2017-02-07 21:53:22 (GMT) |
commit | 2b3a37b49186e8d1f3f32b82580b3bfae2f64347 (patch) | |
tree | 4dac7862539bb013a5ab15432c7d873211b14123 /tcliis/xim.C | |
parent | 026014ff39f47fde838e65ef7d96548809099230 (diff) | |
download | blt-2b3a37b49186e8d1f3f32b82580b3bfae2f64347.zip blt-2b3a37b49186e8d1f3f32b82580b3bfae2f64347.tar.gz blt-2b3a37b49186e8d1f3f32b82580b3bfae2f64347.tar.bz2 |
add iis support to win port
Diffstat (limited to 'tcliis/xim.C')
-rw-r--r-- | tcliis/xim.C | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/tcliis/xim.C b/tcliis/xim.C index bdbd557..ecbeeed 100644 --- a/tcliis/xim.C +++ b/tcliis/xim.C @@ -9,9 +9,11 @@ #include <sstream> using namespace std; +#include <math.h> + #include <tcl.h> -#ifdef __WIN32__ +#ifdef __WIN32 #include <Winsock2.h> #endif @@ -28,8 +30,15 @@ void iisIO(ClientData data, int mask) if (IISDebug) cerr << "iisIO() " << fd << ' ' << mask << endl; - if ((fd < MAXCHANNEL) && iis->func[fd]) { - (*iis->func[fd])(iis->chan[fd], &fd, NULL); + int idx; +#ifdef __WIN32 + idx = fmod(fd,MAXCHANNEL); +#else + idx = fd; +#endif + + if ((idx < MAXCHANNEL) && iis->func[idx]) { + (*iis->func[idx])(iis->chan[idx], &fd, NULL); } else cerr << "Error: IIS iisIO problems" << endl; @@ -41,21 +50,28 @@ int xim_addInput(XimDataPtr xim, int fd, void (*func)(IoChan*, int*, void*), IoChanPtr chan) { if (IISDebug) - cerr << "xim_addInput() " << fd << ' ' << func << ' ' << chan << endl; + cerr << "xim_addInput() " << fd << ' ' << chan << endl; + + int idx; +#ifdef __WIN32 + idx = fmod(fd,MAXCHANNEL); +#else + idx = fd; +#endif - iis->func[fd] = func; - iis->chan[fd] = chan; -#ifndef __WIN32__ + iis->func[idx] = func; + iis->chan[idx] = chan; +#ifndef __WIN32 Tcl_CreateFileHandler(fd, TCL_READABLE, (void (*)(ClientData,int))iisIO, (ClientData)long(fd)); #else Tcl_CreateEventSource(setupProc, checkProc, (ClientData)long(fd)); #endif - return fd; + return idx; } -#ifdef __WIN32__ +#ifdef __WIN32 void setupProc(void* fd, int flags) { Tcl_Time blockTime = {0,1000}; @@ -88,7 +104,7 @@ void xim_removeInput(XimDataPtr xim, int fd) if (fd < MAXCHANNEL) { iis->func[fd] = NULL; iis->chan[fd] = NULL; -#ifndef __WIN32__ +#ifndef __WIN32 Tcl_DeleteFileHandler(fd); #endif } |