1 | /* |
---|
2 | * This file Copyright (C) 2007 Charles Kerr <charles@rebelbase.com> |
---|
3 | * |
---|
4 | * This file is licensed by the GPL version 2. Works owned by the |
---|
5 | * Transmission project are granted a special exemption to clause 2(b) |
---|
6 | * so that the bulk of its code can remain under the MIT license. |
---|
7 | * This exemption does not extend to derived works not owned by |
---|
8 | * the Transmission project. |
---|
9 | * |
---|
10 | * $Id: trevent.h 3247 2007-10-01 04:12:24Z charles $ |
---|
11 | */ |
---|
12 | |
---|
13 | #ifndef TR_EVENT_H |
---|
14 | |
---|
15 | #include <stddef.h> /* for size_t */ |
---|
16 | |
---|
17 | /** |
---|
18 | **/ |
---|
19 | |
---|
20 | void tr_eventInit( struct tr_handle * tr_handle ); |
---|
21 | |
---|
22 | void tr_eventClose( struct tr_handle * tr_handle ); |
---|
23 | |
---|
24 | /** |
---|
25 | **/ |
---|
26 | |
---|
27 | struct event; |
---|
28 | enum evhttp_cmd_type; |
---|
29 | struct evhttp_request; |
---|
30 | struct evhttp_connection; |
---|
31 | struct bufferevent; |
---|
32 | |
---|
33 | void tr_evhttp_make_request (struct tr_handle * tr_handle, |
---|
34 | struct evhttp_connection * evcon, |
---|
35 | struct evhttp_request * req, |
---|
36 | enum evhttp_cmd_type type, |
---|
37 | char * uri); |
---|
38 | |
---|
39 | void tr_bufferevent_write( struct tr_handle * tr_handle, |
---|
40 | struct bufferevent * bufferEvent, |
---|
41 | const void * buf, |
---|
42 | size_t buflen ); |
---|
43 | |
---|
44 | |
---|
45 | void tr_setBufferEventMode( struct tr_handle * tr_handle, |
---|
46 | struct bufferevent * bufferEvent, |
---|
47 | short mode_enable, |
---|
48 | short mode_disable ); |
---|
49 | |
---|
50 | /** |
---|
51 | *** |
---|
52 | **/ |
---|
53 | |
---|
54 | typedef struct tr_timer tr_timer; |
---|
55 | |
---|
56 | /** |
---|
57 | * Calls timer_func(user_data) after the specified interval. |
---|
58 | * The timer is freed if timer_func returns zero. |
---|
59 | * Otherwise, it's called again after the same interval. |
---|
60 | */ |
---|
61 | tr_timer* tr_timerNew( struct tr_handle * handle, |
---|
62 | int func( void * user_data ), |
---|
63 | void * user_data, |
---|
64 | int timeout_milliseconds ); |
---|
65 | |
---|
66 | /** |
---|
67 | * Frees a timer and sets the timer pointer to NULL. |
---|
68 | */ |
---|
69 | void tr_timerFree( tr_timer ** timer ); |
---|
70 | |
---|
71 | void tr_runInEventThread( struct tr_handle * handle, |
---|
72 | void func( void* ), |
---|
73 | void * user_data ); |
---|
74 | |
---|
75 | #endif |
---|