1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
/* ply-event-loop.h - small epoll based event loop
*
* Copyright (C) 2007 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Written by: Ray Strode <rstrode@redhat.com>
*/
#ifndef PLY_EVENT_LOOP_H
#define PLY_EVENT_LOOP_H
#include <stdbool.h>
#include <signal.h>
#include <stdint.h>
typedef struct _ply_event_loop ply_event_loop_t;
typedef struct _ply_fd_watch ply_fd_watch_t;
typedef enum {
PLY_EVENT_LOOP_FD_STATUS_NONE = 0,
PLY_EVENT_LOOP_FD_STATUS_HAS_DATA = 0x1,
PLY_EVENT_LOOP_FD_STATUS_HAS_CONTROL_DATA = 0x2,
PLY_EVENT_LOOP_FD_STATUS_CAN_TAKE_DATA = 0x4,
} ply_event_loop_fd_status_t;
typedef void (* ply_event_handler_t) (void *user_data,
int source_fd);
typedef void (* ply_event_loop_exit_handler_t) (void *user_data,
int exit_code,
ply_event_loop_t *loop);
typedef void (* ply_event_loop_timeout_handler_t) (void *user_data,
ply_event_loop_t *loop);
#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
ply_event_loop_t *ply_event_loop_new (void);
void ply_event_loop_free (ply_event_loop_t *loop);
ply_fd_watch_t *ply_event_loop_watch_fd (ply_event_loop_t *loop,
int fd,
ply_event_loop_fd_status_t status,
ply_event_handler_t status_met_handler,
ply_event_handler_t disconnected_handler,
void *user_data);
void ply_event_loop_stop_watching_fd (ply_event_loop_t *loop,
ply_fd_watch_t *watch);
void ply_event_loop_watch_signal (ply_event_loop_t *loop,
int signal_number,
ply_event_handler_t signal_handler,
void *user_data);
void ply_event_loop_stop_watching_signal (ply_event_loop_t *loop,
int signal_number);
void ply_event_loop_watch_for_exit (ply_event_loop_t *loop,
ply_event_loop_exit_handler_t exit_handler,
void *user_data);
void ply_event_loop_stop_watching_for_exit (ply_event_loop_t *loop,
ply_event_loop_exit_handler_t exit_handler,
void *user_data);
void ply_event_loop_watch_for_timeout (ply_event_loop_t *loop,
double seconds,
ply_event_loop_timeout_handler_t timeout_handler,
void *user_data);
void ply_event_loop_stop_watching_for_timeout (ply_event_loop_t *loop,
ply_event_loop_timeout_handler_t timeout_handler,
void *user_data);
int ply_event_loop_run (ply_event_loop_t *loop);
void ply_event_loop_exit (ply_event_loop_t *loop,
int exit_code);
#endif
#endif
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
|