Changeset 0aaca60 for lib/events.h


Ignore:
Timestamp:
2006-07-19T16:52:38Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
d3a672c
Parents:
04026d4
Message:

Added some (more) comments to .h files in lib/ and some minor fixes/cleanups.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/events.h

    r04026d4 r0aaca60  
    2020 */
    2121
    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. */
    2733
    2834
     
    3945#include <gmodule.h>
    4046
     47/* The conditions you can pass to gaim_input_add()/that will be passed to
     48   the given callback function. */
    4149typedef enum {
    4250        GAIM_INPUT_READ = 1 << 1,
     
    4553typedef gboolean (*b_event_handler)(gpointer data, gint fd, b_input_condition cond);
    4654
     55/* For internal use. */
    4756#define GAIM_READ_COND  (G_IO_IN | G_IO_HUP | G_IO_ERR)
    4857#define GAIM_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL)
     
    5261#define event_debug( x... )
    5362
     63/* Call this once when the program starts. It'll initialize the event handler
     64   library (if necessary) and then return immediately. */
    5465G_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(). */
    5569G_MODULE_EXPORT void b_main_run();
    5670G_MODULE_EXPORT void b_main_quit();
    5771
     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. */
    5877G_MODULE_EXPORT gint b_input_add(int fd, b_input_condition cond, b_event_handler func, gpointer data);
    5978G_MODULE_EXPORT gint b_timeout_add(gint timeout, b_event_handler func, gpointer data);
    6079G_MODULE_EXPORT void b_event_remove(gint id);
    6180
     81/* For now, closesocket() is only a function when using libevent. With GLib
     82   it's a preprocessor macro. */
    6283#ifdef EVENTS_LIBEVENT
    6384G_MODULE_EXPORT void closesocket(int fd);
Note: See TracChangeset for help on using the changeset viewer.