aboutsummaryrefslogtreecommitdiff
path: root/jim-eventloop.c
diff options
context:
space:
mode:
authoroharboe <oharboe>2009-10-08 10:47:23 +0000
committerSteve Bennett <steveb@workware.net.au>2010-10-15 11:02:17 +1000
commit2a219122c883585f7d62268a512b9c11f9373fee (patch)
tree73c48c6d474c5ec8930bc0665f9ae14d34e3051c /jim-eventloop.c
parente7ec2ab41cb55ee6ec624e4f9e9cdf8ab9c1b93c (diff)
downloadjimtcl-2a219122c883585f7d62268a512b9c11f9373fee.zip
jimtcl-2a219122c883585f7d62268a512b9c11f9373fee.tar.gz
jimtcl-2a219122c883585f7d62268a512b9c11f9373fee.tar.bz2
2009-10-08 Øyvind Harboe
* jim.c/h: bring in changes from OpenOCD. Warnings and some bug fixes. Copyright list updated in jim.c
Diffstat (limited to 'jim-eventloop.c')
-rw-r--r--jim-eventloop.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/jim-eventloop.c b/jim-eventloop.c
index a024a9f..2dbb47c 100644
--- a/jim-eventloop.c
+++ b/jim-eventloop.c
@@ -277,7 +277,8 @@ int Jim_ProcessEvents(Jim_Interp *interp, int flags)
while (fe != NULL) {
int fd = fileno(fe->handle);
- if (fe->mask & JIM_EVENT_READABLE) FD_SET(fd, &rfds);
+ if (fe->mask & JIM_EVENT_READABLE)
+ FD_SET(fd, &rfds);
if (fe->mask & JIM_EVENT_WRITABLE) FD_SET(fd, &wfds);
if (fe->mask & JIM_EVENT_EXCEPTION) FD_SET(fd, &efds);
if (maxfd < fd) maxfd = fd;
@@ -335,12 +336,11 @@ int Jim_ProcessEvents(Jim_Interp *interp, int flags)
{
int mask = 0;
- if ((fe->mask & JIM_EVENT_READABLE) && FD_ISSET(fd, &rfds)) {
+ if (fe->mask & JIM_EVENT_READABLE && FD_ISSET(fd, &rfds)) {
mask |= JIM_EVENT_READABLE;
- if ((fe->mask & JIM_EVENT_FEOF) && feof(fe->handle)) {
- mask |= JIM_EVENT_FEOF;
- }
- }
+ if ((fe->mask & JIM_EVENT_FEOF) && feof(fe->handle))
+ mask |= JIM_EVENT_FEOF;
+ }
if (fe->mask & JIM_EVENT_WRITABLE && FD_ISSET(fd, &wfds))
mask |= JIM_EVENT_WRITABLE;
if (fe->mask & JIM_EVENT_EXCEPTION && FD_ISSET(fd, &efds))
@@ -520,10 +520,11 @@ static int JimELAfterCommand(Jim_Interp *interp, int argc,
return JIM_OK;
}
-int Jim_eventloopInit(Jim_Interp *interp)
+int Jim_OnLoad(Jim_Interp *interp)
{
Jim_EventLoop *eventLoop;
+ Jim_InitExtension(interp);
if (Jim_PackageProvide(interp, "eventloop", "1.0", JIM_ERRMSG) != JIM_OK)
return JIM_ERR;
@@ -536,5 +537,11 @@ int Jim_eventloopInit(Jim_Interp *interp)
Jim_CreateCommand(interp, "vwait", JimELVwaitCommand, NULL, NULL);
Jim_CreateCommand(interp, "after", JimELAfterCommand, NULL, NULL);
+ /* Export events API */
+ Jim_RegisterApi(interp, "Jim_CreateFileHandler", Jim_CreateFileHandler);
+ Jim_RegisterApi(interp, "Jim_DeleteFileHandler", Jim_DeleteFileHandler);
+ Jim_RegisterApi(interp, "Jim_CreateTimeHandler", Jim_CreateTimeHandler);
+ Jim_RegisterApi(interp, "Jim_DeleteTimeHandler", Jim_DeleteTimeHandler);
+ Jim_RegisterApi(interp, "Jim_ProcessEvents", Jim_ProcessEvents);
return JIM_OK;
}