2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
10 # define WIN32_LEAN_AND_MEAN
11 # include <winsock2.h>
12 # undef WIN32_LEAN_AND_MEAN
13 # ifndef USER_TIMER_MINIMUM
14 # define USER_TIMER_MINIMUM 0x0a
26 #include <sys/types.h>
41 # include <sys/param.h>
53 #include "ecore_private.h"
56 struct _Ecore_Fd_Handler
61 Ecore_Fd_Handler_Flags flags;
62 int (*func) (void *data, Ecore_Fd_Handler *fd_handler);
64 int (*buf_func) (void *data, Ecore_Fd_Handler *fd_handler);
66 void (*prep_func) (void *data, Ecore_Fd_Handler *fd_handler);
69 Eina_Bool read_active : 1;
70 Eina_Bool write_active : 1;
71 Eina_Bool error_active : 1;
72 Eina_Bool delete_me : 1;
76 struct _Ecore_Win32_Handler
81 int (*func) (void *data, Ecore_Win32_Handler *win32_handler);
84 Eina_Bool delete_me : 1;
89 static int _ecore_main_select(double timeout);
90 static void _ecore_main_fd_handlers_cleanup(void);
92 static void _ecore_main_fd_handlers_bads_rem(void);
94 static void _ecore_main_fd_handlers_call(void);
95 static int _ecore_main_fd_handlers_buf_call(void);
96 static void _ecore_main_loop_iterate_internal(int once_only);
99 static int _ecore_main_win32_select(int nfds, fd_set *readfds, fd_set *writefds,
100 fd_set *exceptfds, struct timeval *timeout);
101 static void _ecore_main_win32_handlers_cleanup(void);
104 static int in_main_loop = 0;
105 static int do_quit = 0;
106 static Ecore_Fd_Handler *fd_handlers = NULL;
107 static Ecore_Fd_Handler *fd_handler_current = NULL;
108 static int fd_handlers_delete_me = 0;
110 static Ecore_Win32_Handler *win32_handlers = NULL;
111 static Ecore_Win32_Handler *win32_handler_current = NULL;
112 static int win32_handlers_delete_me = 0;
116 static int (*main_loop_select)(int , fd_set *, fd_set *, fd_set *, struct timeval *) = _ecore_main_win32_select;
118 static int (*main_loop_select)(int , fd_set *, fd_set *, fd_set *, struct timeval *) = select;
121 static double t1 = 0.0;
122 static double t2 = 0.0;
125 * @defgroup Ecore_Main_Loop_Group Main Loop Functions
127 * These functions control the Ecore event handling loop. This loop is
128 * designed to work on embedded systems all the way to large and
129 * powerful mutli-cpu workstations.
131 * It serialises all system signals and events into a single event
132 * queue, that can be easily processed without needing to worry about
133 * concurrency. A properly written, event-driven program using this
134 * kind of programming does not need threads. It makes the program very
135 * robust and easy to follow.
137 * Here is an example of simple program and its basic event loop flow:
138 * @image html prog_flow.png
140 * For examples of setting up and using a main loop, see
141 * @ref event_handler_example.c and @ref timer_example.c.
145 * Runs a single iteration of the main loop to process everything on the
147 * @ingroup Ecore_Main_Loop_Group
150 ecore_main_loop_iterate(void)
152 _ecore_main_loop_iterate_internal(1);
156 * Runs the application main loop.
158 * This function will not return until @ref ecore_main_loop_quit is called.
160 * @ingroup Ecore_Main_Loop_Group
163 ecore_main_loop_begin(void)
166 for (;do_quit == 0;) _ecore_main_loop_iterate_internal(0);
172 * Quits the main loop once all the events currently on the queue have
174 * @ingroup Ecore_Main_Loop_Group
177 ecore_main_loop_quit(void)
183 * Sets the function to use when monitoring multiple file descriptors,
184 * and waiting until one of more of the file descriptors before ready
185 * for some class of I/O operation.
187 * This function will be used instead of the system call select and
188 * could possible be used to integrate the Ecore event loop with an
189 * external event loop.
191 * @warning you don't know how to use, don't even try to use it.
193 * @ingroup Ecore_Main_Loop_Group
196 ecore_main_loop_select_func_set(int (*func)(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout))
198 main_loop_select = func;
202 * Gets the select function set by ecore_select_func_set(),
203 * or the native select function if none was set.
205 * @ingroup Ecore_Main_Loop_Group
208 ecore_main_loop_select_func_get(void)
210 return main_loop_select;
214 * @defgroup Ecore_FD_Handler_Group File Event Handling Functions
216 * Functions that deal with file descriptor handlers.
220 * Adds a callback for activity on the given file descriptor.
222 * @p func will be called during the execution of @ref ecore_main_loop_begin
223 * when the file descriptor is available for reading, or writing, or both.
225 * Normally the return value from the @p func is "zero means this handler is
226 * finished and can be deleted" as is usual for handler callbacks. However,
227 * if the @p buf_func is supplied, then the return value from the @p func is
228 * "non zero means the handler should be called again in a tight loop".
230 * @p buf_func is called during event loop handling to check if data that has
231 * been read from the file descriptor is in a buffer and is available to
232 * read. Some systems (notably xlib) handle their own buffering, and would
233 * otherwise not work with select(). These systems should use a @p buf_func.
234 * This is a most annoying hack, only ecore_x uses it, so refer to that for
235 * an example. NOTE - @p func should probably return "one" always if
236 * @p buf_func is used, to avoid confusion with the other return value
239 * @param fd The file descriptor to watch.
240 * @param flags To watch it for read (@c ECORE_FD_READ) and/or
241 * (@c ECORE_FD_WRITE) write ability. @c ECORE_FD_ERROR
243 * @param func The callback function.
244 * @param data The data to pass to the callback.
245 * @param buf_func The function to call to check if any data has been
246 * buffered and already read from the fd. Can be @c NULL.
247 * @param buf_data The data to pass to the @p buf_func function.
248 * @return A fd handler handle if successful. @c NULL otherwise.
249 * @ingroup Ecore_FD_Handler_Group
251 EAPI Ecore_Fd_Handler *
252 ecore_main_fd_handler_add(int fd, Ecore_Fd_Handler_Flags flags, int (*func) (void *data, Ecore_Fd_Handler *fd_handler), const void *data, int (*buf_func) (void *buf_data, Ecore_Fd_Handler *fd_handler), const void *buf_data)
254 Ecore_Fd_Handler *fdh;
258 (!func)) return NULL;
260 fdh = calloc(1, sizeof(Ecore_Fd_Handler));
261 if (!fdh) return NULL;
262 ECORE_MAGIC_SET(fdh, ECORE_MAGIC_FD_HANDLER);
265 fdh->read_active = 0;
266 fdh->write_active = 0;
267 fdh->error_active = 0;
270 fdh->data = (void *)data;
271 fdh->buf_func = buf_func;
272 fdh->buf_data = (void *)buf_data;
273 fd_handlers = (Ecore_Fd_Handler *) eina_inlist_append(EINA_INLIST_GET(fd_handlers),
274 EINA_INLIST_GET(fdh));
279 EAPI Ecore_Win32_Handler *
280 ecore_main_win32_handler_add(void *h,
281 int (*func) (void *data, Ecore_Win32_Handler *wh),
284 Ecore_Win32_Handler *wh;
289 wh = calloc(1, sizeof(Ecore_Win32_Handler));
290 if (!wh) return NULL;
291 ECORE_MAGIC_SET(wh, ECORE_MAGIC_WIN32_HANDLER);
295 wh->data = (void *)data;
296 win32_handlers = (Ecore_Win32_Handler *)eina_inlist_append(EINA_INLIST_GET(win32_handlers),
297 EINA_INLIST_GET(wh));
301 EAPI Ecore_Win32_Handler *
302 ecore_main_win32_handler_add(void *h __UNUSED__,
303 int (*func) (void *data, Ecore_Win32_Handler *wh) __UNUSED__,
304 const void *data __UNUSED__)
311 * Deletes the given FD handler.
312 * @param fd_handler The given FD handler.
313 * @return The data pointer set using @ref ecore_main_fd_handler_add,
314 * for @p fd_handler on success. @c NULL otherwise.
315 * @ingroup Ecore_FD_Handler_Group
318 ecore_main_fd_handler_del(Ecore_Fd_Handler *fd_handler)
320 if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER))
322 ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER,
323 "ecore_main_fd_handler_del");
326 fd_handler->delete_me = 1;
327 fd_handlers_delete_me = 1;
328 return fd_handler->data;
333 ecore_main_win32_handler_del(Ecore_Win32_Handler *win32_handler)
335 if (!ECORE_MAGIC_CHECK(win32_handler, ECORE_MAGIC_WIN32_HANDLER))
337 ECORE_MAGIC_FAIL(win32_handler, ECORE_MAGIC_WIN32_HANDLER,
338 "ecore_main_win32_handler_del");
341 win32_handler->delete_me = 1;
342 win32_handlers_delete_me = 1;
343 return win32_handler->data;
347 ecore_main_win32_handler_del(Ecore_Win32_Handler *win32_handler __UNUSED__)
354 ecore_main_fd_handler_prepare_callback_set(Ecore_Fd_Handler *fd_handler, void (*func) (void *data, Ecore_Fd_Handler *fd_handler), const void *data)
356 if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER))
358 ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER,
359 "ecore_main_fd_handler_prepare_callback_set");
362 fd_handler->prep_func = func;
363 fd_handler->prep_data = (void *) data;
367 * Retrieves the file descriptor that the given handler is handling.
368 * @param fd_handler The given FD handler.
369 * @return The file descriptor the handler is watching.
370 * @ingroup Ecore_FD_Handler_Group
373 ecore_main_fd_handler_fd_get(Ecore_Fd_Handler *fd_handler)
375 if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER))
377 ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER,
378 "ecore_main_fd_handler_fd_get");
381 return fd_handler->fd;
385 * Return if read, write or error, or a combination thereof, is active on the
386 * file descriptor of the given FD handler.
387 * @param fd_handler The given FD handler.
388 * @param flags The flags, @c ECORE_FD_READ, @c ECORE_FD_WRITE or
389 * @c ECORE_FD_ERROR to query.
390 * @return @c 1 if any of the given flags are active. @c 0 otherwise.
391 * @ingroup Ecore_FD_Handler_Group
394 ecore_main_fd_handler_active_get(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_Flags flags)
398 if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER))
400 ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER,
401 "ecore_main_fd_handler_active_get");
405 if ((flags & ECORE_FD_READ) && (fd_handler->read_active)) ret = 1;
406 if ((flags & ECORE_FD_WRITE) && (fd_handler->write_active)) ret = 1;
407 if ((flags & ECORE_FD_ERROR) && (fd_handler->error_active)) ret = 1;
412 * Set what active streams the given FD handler should be monitoring.
413 * @param fd_handler The given FD handler.
414 * @param flags The flags to be watching.
415 * @ingroup Ecore_FD_Handler_Group
418 ecore_main_fd_handler_active_set(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_Flags flags)
420 if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER))
422 ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER,
423 "ecore_main_fd_handler_active_set");
426 fd_handler->flags = flags;
430 _ecore_main_shutdown(void)
435 "*** ECORE WARINING: Calling ecore_shutdown() while still in the main loop.\n"
436 "*** Program may crash or behave strangely now.");
441 Ecore_Fd_Handler *fdh;
444 fd_handlers = (Ecore_Fd_Handler *) eina_inlist_remove(EINA_INLIST_GET(fd_handlers),
445 EINA_INLIST_GET(fdh));
446 ECORE_MAGIC_SET(fdh, ECORE_MAGIC_NONE);
449 fd_handlers_delete_me = 0;
450 fd_handler_current = NULL;
453 while (win32_handlers)
455 Ecore_Win32_Handler *wh;
458 win32_handlers = (Ecore_Win32_Handler *) eina_inlist_remove(EINA_INLIST_GET(win32_handlers),
459 EINA_INLIST_GET(wh));
460 ECORE_MAGIC_SET(wh, ECORE_MAGIC_NONE);
463 win32_handlers_delete_me = 0;
464 win32_handler_current = NULL;
469 _ecore_main_select(double timeout)
471 struct timeval tv, *t;
472 fd_set rfds, wfds, exfds;
475 Ecore_Fd_Handler *fdh;
478 if ((!finite(timeout)) || (timeout == 0.0)) /* finite() tests for NaN, too big, too small, and infinity. */
484 else if (timeout > 0.0)
489 timeout += (0.5 / HZ);
491 usec = (int)((timeout - (double)sec) * 1000000);
494 usec = (int)((timeout - (double)sec) * 1000000);
505 /* call the prepare callback for all handlers */
506 EINA_INLIST_FOREACH(fd_handlers, fdh)
507 if (!fdh->delete_me && fdh->prep_func)
510 fdh->prep_func (fdh->prep_data, fdh);
513 EINA_INLIST_FOREACH(fd_handlers, fdh)
516 if (fdh->flags & ECORE_FD_READ)
518 FD_SET(fdh->fd, &rfds);
519 if (fdh->fd > max_fd) max_fd = fdh->fd;
521 if (fdh->flags & ECORE_FD_WRITE)
523 FD_SET(fdh->fd, &wfds);
524 if (fdh->fd > max_fd) max_fd = fdh->fd;
526 if (fdh->flags & ECORE_FD_ERROR)
528 FD_SET(fdh->fd, &exfds);
529 if (fdh->fd > max_fd) max_fd = fdh->fd;
532 if (_ecore_signal_count_get()) return -1;
534 ret = main_loop_select(max_fd + 1, &rfds, &wfds, &exfds, t);
536 _ecore_loop_time = ecore_time_get();
540 if (errno == EINTR) return -1;
541 else if (errno == EBADF)
542 _ecore_main_fd_handlers_bads_rem();
547 EINA_INLIST_FOREACH(fd_handlers, fdh)
550 if (FD_ISSET(fdh->fd, &rfds))
551 fdh->read_active = 1;
552 if (FD_ISSET(fdh->fd, &wfds))
553 fdh->write_active = 1;
554 if (FD_ISSET(fdh->fd, &exfds))
555 fdh->error_active = 1;
557 _ecore_main_fd_handlers_cleanup();
559 _ecore_main_win32_handlers_cleanup();
568 _ecore_main_fd_handlers_bads_rem(void)
570 ERR("Removing bad fds");
571 Ecore_Fd_Handler *fdh;
574 for (l = EINA_INLIST_GET(fd_handlers); l; )
576 fdh = (Ecore_Fd_Handler *) l;
580 if ((fcntl(fdh->fd, F_GETFD) < 0) && (errno == EBADF))
582 ERR("Found bad fd at index %d", fdh->fd);
583 if (fdh->flags & ECORE_FD_ERROR)
585 ERR("Fd set for error! calling user");
587 if (!fdh->func(fdh->data, fdh))
589 ERR("Fd function err returned 0, remove it");
591 fd_handlers_delete_me = 1;
597 ERR("Problematic fd found at %d! setting it for delete", fdh->fd);
599 fd_handlers_delete_me = 1;
604 _ecore_main_fd_handlers_cleanup();
609 _ecore_main_fd_handlers_cleanup(void)
611 Ecore_Fd_Handler *fdh;
613 int deleted_in_use = 0;
615 if (!fd_handlers_delete_me) return;
616 for (l = EINA_INLIST_GET(fd_handlers); l; )
618 fdh = (Ecore_Fd_Handler *) l;
623 // ERR("Removing fd %d", fdh->fd);
631 fd_handlers = (Ecore_Fd_Handler *) eina_inlist_remove(EINA_INLIST_GET(fd_handlers),
632 EINA_INLIST_GET(fdh));
633 ECORE_MAGIC_SET(fdh, ECORE_MAGIC_NONE);
638 fd_handlers_delete_me = 0;
643 _ecore_main_win32_handlers_cleanup(void)
645 Ecore_Win32_Handler *wh;
647 int deleted_in_use = 0;
649 if (!win32_handlers_delete_me) return;
650 for (l = EINA_INLIST_GET(win32_handlers); l; )
652 wh = (Ecore_Win32_Handler *)l;
663 win32_handlers = (Ecore_Win32_Handler *)eina_inlist_remove(EINA_INLIST_GET(win32_handlers),
664 EINA_INLIST_GET(wh));
665 ECORE_MAGIC_SET(wh, ECORE_MAGIC_NONE);
670 win32_handlers_delete_me = 0;
675 _ecore_main_fd_handlers_call(void)
677 if (!fd_handler_current)
679 /* regular main loop, start from head */
680 fd_handler_current = fd_handlers;
684 /* recursive main loop, continue from where we were */
685 fd_handler_current = (Ecore_Fd_Handler *)EINA_INLIST_GET(fd_handler_current)->next;
688 while (fd_handler_current)
690 Ecore_Fd_Handler *fdh = fd_handler_current;
694 if ((fdh->read_active) ||
695 (fdh->write_active) ||
699 if (!fdh->func(fdh->data, fdh))
702 fd_handlers_delete_me = 1;
706 fdh->read_active = 0;
707 fdh->write_active = 0;
708 fdh->error_active = 0;
712 if (fd_handler_current) /* may have changed in recursive main loops */
713 fd_handler_current = (Ecore_Fd_Handler *)EINA_INLIST_GET(fd_handler_current)->next;
718 _ecore_main_fd_handlers_buf_call(void)
720 Ecore_Fd_Handler *fdh;
724 EINA_INLIST_FOREACH(fd_handlers, fdh)
730 if (fdh->buf_func(fdh->buf_data, fdh))
732 ret |= fdh->func(fdh->data, fdh);
733 fdh->read_active = 1;
743 _ecore_main_loop_iterate_internal(int once_only)
745 double next_time = -1.0;
750 /* expire any timers */
751 while (_ecore_timer_call(_ecore_loop_time));
752 _ecore_timer_cleanup();
754 /* process signals into events .... */
755 while (_ecore_signal_count_get()) _ecore_signal_call();
756 if (_ecore_event_exist())
758 _ecore_idle_enterer_call();
760 _ecore_main_select(0.0);
761 _ecore_loop_time = ecore_time_get();
762 _ecore_timer_enable_new();
765 /* call idle enterers ... */
766 if (!once_only) _ecore_idle_enterer_call();
769 have_event = have_signal = 0;
771 if (_ecore_main_select(0.0) > 0) have_event = 1;
772 if (_ecore_signal_count_get() > 0) have_signal = 1;
773 if (have_signal || have_event)
775 _ecore_loop_time = ecore_time_get();
776 _ecore_timer_enable_new();
781 /* if these calls caused any buffered events to appear - deal with them */
782 _ecore_main_fd_handlers_buf_call();
784 /* if ther are any - jump to processing them */
785 if (_ecore_event_exist())
788 _ecore_main_select(0.0);
789 _ecore_loop_time = ecore_time_get();
790 _ecore_timer_enable_new();
795 _ecore_idle_enterer_call();
797 _ecore_loop_time = ecore_time_get();
798 _ecore_timer_enable_new();
802 if (_ecore_fps_debug)
804 t2 = ecore_time_get();
805 if ((t1 > 0.0) && (t2 > 0.0))
806 _ecore_fps_debug_runtime_add(t2 - t1);
809 /* any timers re-added as a result of these are allowed to go */
810 _ecore_timer_enable_new();
813 _ecore_loop_time = ecore_time_get();
815 _ecore_timer_enable_new();
818 if (!_ecore_event_exist())
821 have_event = have_signal = 0;
822 next_time = _ecore_timer_next_get();
827 if (!_ecore_idler_exist())
829 if (_ecore_main_select(-1.0) > 0) have_event = 1;
836 if (!_ecore_idler_call()) goto start_loop;
837 if (_ecore_event_exist()) break;
838 if (_ecore_main_select(0.0) > 0) have_event = 1;
839 if (_ecore_signal_count_get() > 0) have_signal = 1;
840 if (have_event || have_signal) break;
841 if (_ecore_timers_exists()) goto start_loop;
850 if (!_ecore_idler_exist())
852 if (_ecore_main_select(next_time) > 0) have_event = 1;
859 if (!_ecore_idler_call()) goto start_loop;
860 if (_ecore_event_exist()) break;
861 if (_ecore_main_select(0.0) > 0) have_event = 1;
862 if (_ecore_signal_count_get() > 0) have_signal = 1;
863 if (have_event || have_signal) break;
864 next_time = _ecore_timer_next_get();
865 if (next_time <= 0) break;
870 _ecore_loop_time = ecore_time_get();
872 if (_ecore_fps_debug)
874 t1 = ecore_time_get();
876 /* we came out of our "wait state" so idle has exited */
878 _ecore_idle_exiter_call();
879 /* call the fd handler per fd that became alive... */
880 /* this should read or write any data to the monitored fd and then */
881 /* post events onto the ecore event pipe if necessary */
884 _ecore_main_fd_handlers_call();
885 _ecore_main_fd_handlers_buf_call();
888 /* process signals into events .... */
889 while (_ecore_signal_count_get()) _ecore_signal_call();
890 /* handle events ... */
892 _ecore_main_fd_handlers_cleanup();
894 // while (_ecore_main_fd_handlers_buf_call());
896 /* ok - too much optimising. let's call idle enterers more often. if we
897 * have events that place more events or jobs etc. on the event queue
898 * we may never get to call an idle enterer
902 _ecore_idle_enterer_call();
908 _ecore_main_win32_select(int nfds, fd_set *readfds, fd_set *writefds,
909 fd_set *exceptfds, struct timeval *tv)
911 HANDLE objects[MAXIMUM_WAIT_OBJECTS];
912 int sockets[MAXIMUM_WAIT_OBJECTS];
913 Ecore_Win32_Handler *wh;
914 unsigned int objects_nbr = 0;
915 unsigned int handles_nbr = 0;
916 unsigned int events_nbr = 0;
923 /* Create an event object per socket */
924 for(i = 0; i < nfds; i++)
930 if(FD_ISSET(i, readfds))
931 network_event |= FD_READ;
932 if(FD_ISSET(i, writefds))
933 network_event |= FD_WRITE;
934 if(FD_ISSET(i, exceptfds))
935 network_event |= FD_OOB;
939 event = WSACreateEvent();
940 WSAEventSelect(i, event, network_event);
941 objects[objects_nbr] = event;
942 sockets[events_nbr] = i;
948 /* store the HANDLEs in the objects to wait for */
949 EINA_INLIST_FOREACH(win32_handlers, wh)
951 objects[objects_nbr] = wh->h;
956 /* Empty the queue before waiting */
957 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
959 TranslateMessage(&msg);
960 DispatchMessage(&msg);
963 /* Wait for any message sent or posted to this queue */
964 /* or for one of the passed handles be set to signaled. */
968 timeout = (DWORD)(tv->tv_sec * 1000.0 + tv->tv_usec / 1000.0);
970 if (timeout == 0) return 0;
972 result = MsgWaitForMultipleObjects(objects_nbr, (const HANDLE *)objects, EINA_FALSE,
973 timeout, QS_ALLINPUT);
979 /* The result tells us the type of event we have. */
980 if (result == WAIT_FAILED)
984 msg = evil_last_error_get();
989 else if (result == WAIT_TIMEOUT)
994 else if (result == (WAIT_OBJECT_0 + objects_nbr))
996 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
998 TranslateMessage(&msg);
999 DispatchMessage(&msg);
1004 else if ((result >= 0) && (result < WAIT_OBJECT_0 + events_nbr))
1006 WSANETWORKEVENTS network_event;
1008 WSAEnumNetworkEvents(sockets[result], objects[result], &network_event);
1010 if(network_event.lNetworkEvents & FD_READ)
1011 FD_SET(sockets[result], readfds);
1012 if(network_event.lNetworkEvents & FD_WRITE)
1013 FD_SET(sockets[result], writefds);
1014 if(network_event.lNetworkEvents & FD_OOB)
1015 FD_SET(sockets[result], exceptfds);
1019 else if ((result >= WAIT_OBJECT_0 + events_nbr) && (result < WAIT_OBJECT_0 + objects_nbr))
1022 if (!win32_handler_current)
1024 /* regular main loop, start from head */
1025 win32_handler_current = win32_handlers;
1029 /* recursive main loop, continue from where we were */
1030 win32_handler_current = (Ecore_Win32_Handler *)EINA_INLIST_GET(win32_handler_current)->next;
1033 while (win32_handler_current)
1035 wh = win32_handler_current;
1037 if (objects[result - WAIT_OBJECT_0] == wh->h)
1041 if (!wh->func(wh->data, wh))
1044 win32_handlers_delete_me = 1;
1053 ERR("unknown result...\n");
1057 /* Remove event objects again */
1058 for(i = 0; i < (int)events_nbr; i++)
1059 WSACloseEvent(objects[i]);