tcltest: do a better job of cleanup up after tests
[jimtcl.git] / jim-eventloop.h
blob545ef4d7ef9fced8ddbdac6e8d28a04a1bbd8cba
1 /* Jim - A small embeddable Tcl interpreter
3 * Copyright 2005 Salvatore Sanfilippo <antirez@invece.org>
4 * Copyright 2005 Clemens Hintze <c.hintze@gmx.net>
5 * Copyright 2005 patthoyts - Pat Thoyts <patthoyts@users.sf.net>
6 * Copyright 2008 oharboe - Øyvind Harboe - oyvind.harboe@zylin.com
7 * Copyright 2008 Andrew Lunn <andrew@lunn.ch>
8 * Copyright 2008 Duane Ellis <openocd@duaneellis.com>
9 * Copyright 2008 Uwe Klein <uklein@klein-messgeraete.de>
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above
18 * copyright notice, this list of conditions and the following
19 * disclaimer in the documentation and/or other materials
20 * provided with the distribution.
22 * THIS SOFTWARE IS PROVIDED BY THE JIM TCL PROJECT ``AS IS'' AND ANY
23 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * JIM TCL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 * The views and conclusions contained in the software and documentation
36 * are those of the authors and should not be interpreted as representing
37 * official policies, either expressed or implied, of the Jim Tcl Project.
38 **/
40 /* ------ USAGE -------
41 * See jim-aio.c as an example of an event provider.
44 #ifndef __JIM_EVENTLOOP_H__
45 #define __JIM_EVENTLOOP_H__
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
51 #include <stdio.h>
53 typedef int Jim_FileProc(Jim_Interp *interp, void *clientData, int mask);
54 typedef int Jim_SignalProc(Jim_Interp *interp, void *clientData, void *msg);
55 typedef void Jim_TimeProc(Jim_Interp *interp, void *clientData);
56 typedef void Jim_EventFinalizerProc(Jim_Interp *interp, void *clientData);
58 /* File event structure */
59 #define JIM_EVENT_READABLE 1
60 #define JIM_EVENT_WRITABLE 2
61 #define JIM_EVENT_EXCEPTION 4
63 JIM_EXPORT void Jim_CreateFileHandler (Jim_Interp *interp,
64 int fd, int mask,
65 Jim_FileProc *proc, void *clientData,
66 Jim_EventFinalizerProc *finalizerProc);
67 JIM_EXPORT void Jim_DeleteFileHandler (Jim_Interp *interp,
68 int fd, int mask);
69 JIM_EXPORT jim_wide Jim_CreateTimeHandler (Jim_Interp *interp,
70 jim_wide milliseconds,
71 Jim_TimeProc *proc, void *clientData,
72 Jim_EventFinalizerProc *finalizerProc);
73 JIM_EXPORT jim_wide Jim_DeleteTimeHandler (Jim_Interp *interp, jim_wide id);
75 #define JIM_FILE_EVENTS 1
76 #define JIM_TIME_EVENTS 2
77 #define JIM_ALL_EVENTS (JIM_FILE_EVENTS|JIM_TIME_EVENTS)
78 #define JIM_DONT_WAIT 4
80 JIM_EXPORT int Jim_ProcessEvents (Jim_Interp *interp, int flags);
81 JIM_EXPORT int Jim_EvalObjBackground (Jim_Interp *interp, Jim_Obj *scriptObjPtr);
83 int Jim_eventloopInit(Jim_Interp *interp);
85 #ifdef __cplusplus
87 #endif
89 #endif /* __JIM_EVENTLOOP_H__ */