edelib 1.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List

Listener.h
1 /*
2 * $Id: Listener.h 2839 2009-09-28 11:36:20Z karijes $
3 *
4 * Descriptor monitoring functions
5 * Copyright (c) 2008 edelib authors
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef __EDELIB_LISTENER_H__
22 #define __EDELIB_LISTENER_H__
23
24 #include "edelib-global.h"
25
26 EDELIB_NS_BEGIN
27
28 enum {
29 LISTENER_READ = 1,
30 LISTENER_WRITE = 4,
31 LISTENER_EXCEPT = 8
32 };
33
51 EDELIB_API void listener_add_fd(int fd, int when, void(*cb)(int, void*), void* arg = 0);
52
56 EDELIB_API inline void listener_add_fd(int fd, void(*cb)(int, void*), void* arg = 0) {
57 listener_add_fd(fd, LISTENER_READ, cb, arg);
58 }
59
66 EDELIB_API void listener_remove_fd(int fd, int when);
67
71 EDELIB_API inline void listener_remove_fd(int fd) {
72 listener_remove_fd(fd, LISTENER_READ);
73 }
74
87 EDELIB_API double listener_wait(double t);
88
92 EDELIB_API inline int listener_wait(void) {
93 // FLTK uses 1e20 for forever so I'm using it too
94 return (int)listener_wait(1e20);
95 }
96
97 EDELIB_NS_END
98 #endif