diff options
Diffstat (limited to 'unix/tclXtNotify.c')
-rw-r--r-- | unix/tclXtNotify.c | 97 |
1 files changed, 51 insertions, 46 deletions
diff --git a/unix/tclXtNotify.c b/unix/tclXtNotify.c index 3a8a749..a5d92d6 100644 --- a/unix/tclXtNotify.c +++ b/unix/tclXtNotify.c @@ -8,10 +8,11 @@ * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tclXtNotify.c,v 1.8 2005/11/02 23:26:50 dkf Exp $ */ +#ifndef USE_TCL_STUBS +# define USE_TCL_STUBS +#endif #include <X11/Intrinsic.h> #include "tclInt.h" @@ -76,22 +77,22 @@ static int initialized = 0; */ static int FileHandlerEventProc(Tcl_Event *evPtr, int flags); -static void FileProc(caddr_t clientData, int *source, +static void FileProc(XtPointer clientData, int *source, XtInputId *id); -void InitNotifier(void); static void NotifierExitHandler(ClientData clientData); -static void TimerProc(caddr_t clientData, XtIntervalId *id); +static void TimerProc(XtPointer clientData, XtIntervalId *id); static void CreateFileHandler(int fd, int mask, - Tcl_FileProc * proc, ClientData clientData); + Tcl_FileProc *proc, ClientData clientData); static void DeleteFileHandler(int fd); -static void SetTimer(Tcl_Time * timePtr); -static int WaitForEvent(Tcl_Time * timePtr); +static void SetTimer(const Tcl_Time * timePtr); +static int WaitForEvent(const Tcl_Time * timePtr); /* * Functions defined in this file for use by users of the Xt Notifier: */ -EXTERN XtAppContext TclSetAppContext(XtAppContext ctx); +MODULE_SCOPE void InitNotifier(void); +MODULE_SCOPE XtAppContext TclSetAppContext(XtAppContext ctx); /* *---------------------------------------------------------------------- @@ -111,8 +112,8 @@ EXTERN XtAppContext TclSetAppContext(XtAppContext ctx); */ XtAppContext -TclSetAppContext(appContext) - XtAppContext appContext; +TclSetAppContext( + XtAppContext appContext) { if (!initialized) { InitNotifier(); @@ -178,9 +179,9 @@ TclSetAppContext(appContext) */ void -InitNotifier() +InitNotifier(void) { - Tcl_NotifierProcs notifier; + Tcl_NotifierProcs np; /* * Only reinitialize if we are not in exit handling. The notifier can get @@ -192,11 +193,15 @@ InitNotifier() return; } - notifier.createFileHandlerProc = CreateFileHandler; - notifier.deleteFileHandlerProc = DeleteFileHandler; - notifier.setTimerProc = SetTimer; - notifier.waitForEventProc = WaitForEvent; - Tcl_SetNotifier(¬ifier); + np.createFileHandlerProc = CreateFileHandler; + np.deleteFileHandlerProc = DeleteFileHandler; + np.setTimerProc = SetTimer; + np.waitForEventProc = WaitForEvent; + np.initNotifierProc = Tcl_InitNotifier; + np.finalizeNotifierProc = Tcl_FinalizeNotifier; + np.alertNotifierProc = Tcl_AlertNotifier; + np.serviceModeHookProc = Tcl_ServiceModeHook; + Tcl_SetNotifier(&np); /* * DO NOT create the application context yet; doing so would prevent @@ -204,7 +209,7 @@ InitNotifier() */ initialized = 1; - memset(¬ifier, 0, sizeof(notifier)); + memset(&np, 0, sizeof(np)); Tcl_CreateExitHandler(NotifierExitHandler, NULL); } @@ -260,8 +265,8 @@ NotifierExitHandler( */ static void -SetTimer(timePtr) - Tcl_Time *timePtr; /* Timeout value, may be NULL. */ +SetTimer( + const Tcl_Time *timePtr) /* Timeout value, may be NULL. */ { long timeout; @@ -299,9 +304,9 @@ SetTimer(timePtr) */ static void -TimerProc(data, id) - caddr_t data; /* Not used. */ - XtIntervalId *id; +TimerProc( + XtPointer clientData, /* Not used. */ + XtIntervalId *id) { if (*id != notifier.currentTimeout) { return; @@ -329,15 +334,15 @@ TimerProc(data, id) */ static void -CreateFileHandler(fd, mask, proc, clientData) - int fd; /* Handle of stream to watch. */ - int mask; /* OR'ed combination of TCL_READABLE, +CreateFileHandler( + int fd, /* Handle of stream to watch. */ + int mask, /* OR'ed combination of TCL_READABLE, * TCL_WRITABLE, and TCL_EXCEPTION: indicates * conditions under which proc should be * called. */ - Tcl_FileProc *proc; /* Procedure to call for each selected + Tcl_FileProc *proc, /* Procedure to call for each selected * event. */ - ClientData clientData; /* Arbitrary data to pass to proc. */ + ClientData clientData) /* Arbitrary data to pass to proc. */ { FileHandler *filePtr; @@ -354,7 +359,7 @@ CreateFileHandler(fd, mask, proc, clientData) } } if (filePtr == NULL) { - filePtr = (FileHandler*) ckalloc(sizeof(FileHandler)); + filePtr = ckalloc(sizeof(FileHandler)); filePtr->fd = fd; filePtr->read = 0; filePtr->write = 0; @@ -374,7 +379,7 @@ CreateFileHandler(fd, mask, proc, clientData) if (mask & TCL_READABLE) { if (!(filePtr->mask & TCL_READABLE)) { filePtr->read = XtAppAddInput(notifier.appContext, fd, - XtInputReadMask, FileProc, filePtr); + INT2PTR(XtInputReadMask), FileProc, filePtr); } } else { if (filePtr->mask & TCL_READABLE) { @@ -384,7 +389,7 @@ CreateFileHandler(fd, mask, proc, clientData) if (mask & TCL_WRITABLE) { if (!(filePtr->mask & TCL_WRITABLE)) { filePtr->write = XtAppAddInput(notifier.appContext, fd, - XtInputWriteMask, FileProc, filePtr); + INT2PTR(XtInputWriteMask), FileProc, filePtr); } } else { if (filePtr->mask & TCL_WRITABLE) { @@ -394,7 +399,7 @@ CreateFileHandler(fd, mask, proc, clientData) if (mask & TCL_EXCEPTION) { if (!(filePtr->mask & TCL_EXCEPTION)) { filePtr->except = XtAppAddInput(notifier.appContext, fd, - XtInputExceptMask, FileProc, filePtr); + INT2PTR(XtInputExceptMask), FileProc, filePtr); } } else { if (filePtr->mask & TCL_EXCEPTION) { @@ -421,8 +426,8 @@ CreateFileHandler(fd, mask, proc, clientData) */ static void -DeleteFileHandler(fd) - int fd; /* Stream id for which to remove callback +DeleteFileHandler( + int fd) /* Stream id for which to remove callback * procedure. */ { FileHandler *filePtr, *prevPtr; @@ -465,7 +470,7 @@ DeleteFileHandler(fd) if (filePtr->mask & TCL_EXCEPTION) { XtRemoveInput(filePtr->except); } - ckfree((char *) filePtr); + ckfree(filePtr); } /* @@ -486,10 +491,10 @@ DeleteFileHandler(fd) */ static void -FileProc(clientData, fd, id) - caddr_t clientData; - int *fd; - XtInputId *id; +FileProc( + XtPointer clientData, + int *fd, + XtInputId *id) { FileHandler *filePtr = (FileHandler *)clientData; FileHandlerEvent *fileEvPtr; @@ -520,7 +525,7 @@ FileProc(clientData, fd, id) */ filePtr->readyMask |= mask; - fileEvPtr = (FileHandlerEvent *) ckalloc(sizeof(FileHandlerEvent)); + fileEvPtr = ckalloc(sizeof(FileHandlerEvent)); fileEvPtr->header.proc = FileHandlerEventProc; fileEvPtr->fd = filePtr->fd; Tcl_QueueEvent((Tcl_Event *) fileEvPtr, TCL_QUEUE_TAIL); @@ -555,9 +560,9 @@ FileProc(clientData, fd, id) */ static int -FileHandlerEventProc(evPtr, flags) - Tcl_Event *evPtr; /* Event to service. */ - int flags; /* Flags that indicate what events to handle, +FileHandlerEventProc( + Tcl_Event *evPtr, /* Event to service. */ + int flags) /* Flags that indicate what events to handle, * such as TCL_FILE_EVENTS. */ { FileHandler *filePtr; @@ -596,7 +601,7 @@ FileHandlerEventProc(evPtr, flags) mask = filePtr->readyMask & filePtr->mask; filePtr->readyMask = 0; if (mask != 0) { - (*filePtr->proc)(filePtr->clientData, mask); + filePtr->proc(filePtr->clientData, mask); } break; } @@ -625,7 +630,7 @@ FileHandlerEventProc(evPtr, flags) static int WaitForEvent( - Tcl_Time *timePtr) /* Maximum block time, or NULL. */ + const Tcl_Time *timePtr) /* Maximum block time, or NULL. */ { int timeout; |