tizen 2.3.1 release
[framework/connectivity/bluez.git] / src / shared / mainloop.h
1 /*
2  *
3  *  BlueZ - Bluetooth protocol stack for Linux
4  *
5  *  Copyright (C) 2011-2014  Intel Corporation
6  *  Copyright (C) 2002-2010  Marcel Holtmann <marcel@holtmann.org>
7  *
8  *
9  *  This library is free software; you can redistribute it and/or
10  *  modify it under the terms of the GNU Lesser General Public
11  *  License as published by the Free Software Foundation; either
12  *  version 2.1 of the License, or (at your option) any later version.
13  *
14  *  This library is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  *  Lesser General Public License for more details.
18  *
19  *  You should have received a copy of the GNU Lesser General Public
20  *  License along with this library; if not, write to the Free Software
21  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22  *
23  */
24
25 #include <signal.h>
26 #include <sys/epoll.h>
27
28 typedef void (*mainloop_destroy_func) (void *user_data);
29
30 typedef void (*mainloop_event_func) (int fd, uint32_t events, void *user_data);
31 typedef void (*mainloop_timeout_func) (int id, void *user_data);
32 typedef void (*mainloop_signal_func) (int signum, void *user_data);
33
34 void mainloop_init(void);
35 void mainloop_quit(void);
36 void mainloop_exit_success(void);
37 void mainloop_exit_failure(void);
38 int mainloop_run(void);
39
40 int mainloop_add_fd(int fd, uint32_t events, mainloop_event_func callback,
41                                 void *user_data, mainloop_destroy_func destroy);
42 int mainloop_modify_fd(int fd, uint32_t events);
43 int mainloop_remove_fd(int fd);
44
45 int mainloop_add_timeout(unsigned int msec, mainloop_timeout_func callback,
46                                 void *user_data, mainloop_destroy_func destroy);
47 int mainloop_modify_timeout(int fd, unsigned int msec);
48 int mainloop_remove_timeout(int id);
49
50 int mainloop_set_signal(sigset_t *mask, mainloop_signal_func callback,
51                                 void *user_data, mainloop_destroy_func destroy);