summaryrefslogtreecommitdiff
path: root/accel-pptpd/triton/triton.h
blob: b726076e05f52b95d0b56fe845be99f94b3b416b (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
68
69
70
71
72
73
74
75
76
77
78
#ifndef TRITON_H
#define TRITON_H

#include <sys/time.h>

struct triton_md_handler_t
{
	int fd;
	int twait;
	void *pd;

	void (*read)(struct triton_md_handler_t *h);
	void (*write)(struct triton_md_handler_t *h);
	void (*timeout)(struct triton_md_handler_t *h);
};

#define MD_MODE_READ 1
#define MD_MODE_WRITE 2
void triton_md_register_handler(struct triton_md_handler_t *h);
void triton_md_unregister_handler(struct triton_md_handler_t *h);
void triton_md_enable_handler(struct triton_md_handler_t *h, int mode);
void triton_md_disable_handler(struct triton_md_handler_t *h,int mode);
int triton_md_wait(struct triton_md_handler_t *h);
int triton_md_wait2(int fd,int mode,int timeout);

struct triton_timer_t
{
	struct timeval expire_tv;
	int period;
	void *pd;
	int active;

	int (*expire)(struct triton_timer_t*);
};

void triton_timer_add(struct triton_timer_t*);
void triton_timer_del(struct triton_timer_t*);

typedef void (*triton_ss_func)(void);
void triton_timer_single_shot1(int twait,triton_ss_func,int argc,...);
void triton_timer_single_shot2(struct  timeval *shot_tv,triton_ss_func,int argc,...);
void triton_timer_single_shot3(int tv_sec,int tv_usec,triton_ss_func,int argc,...);

typedef void (*triton_event_func)(void);
void triton_event_register_handler(int ev_id,triton_event_func,int argc,...);
void triton_event_unregister_handler(int ev_id,triton_event_func);
void triton_event_fire(int ev_id,int argc,...);

int triton_get_int_option(const char *str);
const char* triton_get_str_option(const char *str);
double triton_get_double_option(const char *str);

void triton_terminate(void);
void triton_process_events(void);

#ifdef USE_CORO
#define DEF_COROUTINE_STACK 64*1024
typedef void (*triton_coroutine_func)(void*);
long int triton_coroutine_create(int stack_size,triton_coroutine_func func,void *arg,int run);
void triton_coroutine_delete(long int id);
void triton_coroutine_wakeup(long int id);
void triton_coroutine_schedule();
int triton_coroutine_schedule_timeout(int msec);
#endif

#define TRITON_OK          0
#define TRITON_ERR_NOCOMP -1
#define TRITON_ERR_NOSUPP -2
#define TRITON_ERR_NOINTF -3
#define TRITON_ERR_EXISTS -4
#define TRITON_ERR_NOCHAN -5
#define TRITON_ERR_NOMSG  -6
#define TRITON_ERR_BUSY   -5

int triton_init(const char *conf_file);
int triton_run(int (*post_init)(void*),void *arg);

#endif