summaryrefslogtreecommitdiffstats
path: root/src/include/event.h
blob: 04097287a6324e24d15768b78642d5dc6c7d1c71 (plain)
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
#ifndef FR_EVENT_H
#define FR_EVENT_H

/*
 * event.h	Simple event queue
 *
 * Version:	$Id$
 *
 *   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 of the License, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 *
 * Copyright 2007 The FreeRADIUS server project
 * Copyright 2007 Alan DeKok <aland@deployingradius.com>
 */

RCSIDH(event_h, "$Id$")

#ifdef __cplusplus
extern "C" {
#endif

typedef struct fr_event_list_t fr_event_list_t;
typedef struct fr_event_t fr_event_t;

typedef	void (*fr_event_callback_t)(void *);
typedef	void (*fr_event_status_t)(struct timeval *);
typedef void (*fr_event_fd_handler_t)(fr_event_list_t *el, int sock, void *ctx);

fr_event_list_t *fr_event_list_create(TALLOC_CTX *ctx, fr_event_status_t status);

int fr_event_list_num_fds(fr_event_list_t *el);
int fr_event_list_num_elements(fr_event_list_t *el);

int fr_event_insert(fr_event_list_t *el,
		    fr_event_callback_t callback,
		    void *ctx, struct timeval *when, fr_event_t **parent);
int fr_event_delete(fr_event_list_t *el, fr_event_t **parent);

int fr_event_run(fr_event_list_t *el, struct timeval *when);

int fr_event_now(fr_event_list_t *el, struct timeval *when);

int fr_event_fd_insert(fr_event_list_t *el, int type, int fd,
			 fr_event_fd_handler_t handler, void *ctx);
int fr_event_fd_write_handler(fr_event_list_t *el, int type, int fd,
			      fr_event_fd_handler_t write_handler, void *ctx);
int fr_event_fd_delete(fr_event_list_t *el, int type, int fd);
int fr_event_loop(fr_event_list_t *el);
void fr_event_loop_exit(fr_event_list_t *el, int code);
bool fr_event_loop_exiting(fr_event_list_t *el);

#ifdef __cplusplus
}
#endif

#endif /* FR_HASH_H */