Changeset 69cb623 for lib/events.h
- Timestamp:
- 2006-10-15T09:41:12Z (18 years ago)
- Branches:
- master
- Children:
- 2529faf
- Parents:
- 695e392 (diff), e97827b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
lib/events.h
r695e392 r69cb623 20 20 */ 21 21 22 /* 23 * Split off the event handling things from proxy.[ch] (and adding timer 24 * stuff. This to allow BitlBee to use other libs than GLib for event 25 * handling. 26 */ 22 /* This stuff used to be in proxy.c too, but I split it off so BitlBee can 23 use other libraries (like libevent) to handle events. proxy.c is one very 24 nice piece of work from Gaim. It connects to a TCP server in the back- 25 ground and calls a callback function once the connection is ready to use. 26 This function (proxy_connect()) can be found in proxy.c. (It also 27 transparently handles HTTP/SOCKS proxies, when necessary.) 28 29 This file offers some extra event handling toys, which will be handled 30 by GLib or libevent. The advantage of using libevent is that it can use 31 more advanced I/O polling functions like epoll() in recent Linux 32 kernels. This should improve BitlBee's scalability. */ 27 33 28 34 … … 39 45 #include <gmodule.h> 40 46 47 /* The conditions you can pass to gaim_input_add()/that will be passed to 48 the given callback function. */ 41 49 typedef enum { 42 50 GAIM_INPUT_READ = 1 << 1, … … 45 53 typedef gboolean (*b_event_handler)(gpointer data, gint fd, b_input_condition cond); 46 54 55 /* For internal use. */ 47 56 #define GAIM_READ_COND (G_IO_IN | G_IO_HUP | G_IO_ERR) 48 57 #define GAIM_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL) … … 52 61 #define event_debug( x... ) 53 62 63 /* Call this once when the program starts. It'll initialize the event handler 64 library (if necessary) and then return immediately. */ 54 65 G_MODULE_EXPORT void b_main_init(); 66 67 /* This one enters the event loop. It shouldn't return until one of the event 68 handlers calls b_main_quit(). */ 55 69 G_MODULE_EXPORT void b_main_run(); 56 70 G_MODULE_EXPORT void b_main_quit(); 57 71 72 73 /* Add event handlers (for I/O or a timeout). The event handler will be called 74 every time the event "happens", until your event handler returns FALSE (or 75 until you remove it using b_event_remove(). As usual, the data argument 76 can be used to pass your own data to the event handler. */ 58 77 G_MODULE_EXPORT gint b_input_add(int fd, b_input_condition cond, b_event_handler func, gpointer data); 59 78 G_MODULE_EXPORT gint b_timeout_add(gint timeout, b_event_handler func, gpointer data); 60 79 G_MODULE_EXPORT void b_event_remove(gint id); 61 80 81 /* For now, closesocket() is only a function when using libevent. With GLib 82 it's a preprocessor macro. */ 62 83 #ifdef EVENTS_LIBEVENT 63 84 G_MODULE_EXPORT void closesocket(int fd);
Note: See TracChangeset
for help on using the changeset viewer.