aboutsummaryrefslogtreecommitdiffstats
path: root/libglouglou/libglouglou.c
diff options
context:
space:
mode:
authorLaurent Ghigonis <laurent@p1sec.com>2012-11-29 10:08:56 +0100
committerLaurent Ghigonis <laurent@p1sec.com>2012-11-29 10:08:56 +0100
commit2a5e8c3534d070de3bf142af47e29fb835498ad9 (patch)
treec969d878e5f128152507e72312ab1c9f43ece076 /libglouglou/libglouglou.c
parentfix callback function definition (diff)
downloadglouglou-2a5e8c3534d070de3bf142af47e29fb835498ad9.tar.xz
glouglou-2a5e8c3534d070de3bf142af47e29fb835498ad9.zip
add a way to pass userdata to server and client callbacks
Diffstat (limited to 'libglouglou/libglouglou.c')
-rw-r--r--libglouglou/libglouglou.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libglouglou/libglouglou.c b/libglouglou/libglouglou.c
index efbd256..a3eb271 100644
--- a/libglouglou/libglouglou.c
+++ b/libglouglou/libglouglou.c
@@ -29,7 +29,8 @@ void cb_cli_receive(evutil_socket_t, short, void *);
struct gg_server *
gg_server_start(struct event_base *ev_base, char *ip, int port,
int (*handle_conn)(struct gg_server *, struct gg_user *),
- int (*handle_packet)(struct gg_server *, struct gg_user *, struct gg_packet *))
+ int (*handle_packet)(struct gg_server *, struct gg_user *, struct gg_packet *),
+ void *usrdata)
{
struct gg_server *srv;
struct sockaddr_in sock_addr;
@@ -42,6 +43,7 @@ gg_server_start(struct event_base *ev_base, char *ip, int port,
srv->port = port;
srv->handle_conn = handle_conn;
srv->handle_packet = handle_packet;
+ srv->usrdata = usrdata;
s = socket(AF_INET, SOCK_DGRAM, 0);
if (s < 0)
goto err;
@@ -272,7 +274,8 @@ void cb_srv_receive(evutil_socket_t fd, short what, void *arg)
struct gg_client *
gg_client_connect(struct event_base *ev_base, char *ip, int port,
int (*handle_conn)(struct gg_client *),
- int (*handle_packet)(struct gg_client *, struct gg_packet *))
+ int (*handle_packet)(struct gg_client *, struct gg_packet *),
+ void *usrdata)
{
struct gg_client *cli;
struct sockaddr_in sock_addr;
@@ -285,6 +288,7 @@ gg_client_connect(struct event_base *ev_base, char *ip, int port,
cli->port = port;
cli->handle_conn = handle_conn;
cli->handle_packet = handle_packet;
+ cli->usrdata = usrdata;
s = socket(AF_INET, SOCK_DGRAM, 0);
if (s < 0)
goto err;