From 3cff3744d055ae7dab86944465d269db1ba375c7 Mon Sep 17 00:00:00 2001 From: Laurent Ghigonis Date: Wed, 28 Nov 2012 01:22:41 +0100 Subject: coded gg_server_start() --- libglouglou/libglouglou.h | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'libglouglou/libglouglou.h') diff --git a/libglouglou/libglouglou.h b/libglouglou/libglouglou.h index 4906bab..c8f1536 100644 --- a/libglouglou/libglouglou.h +++ b/libglouglou/libglouglou.h @@ -1,7 +1,15 @@ #define PACKET_VERSION 1 #define DNSNAME_MAX 20 -struct packet { +struct gg_server { + struct event *ev; + int sock; +}; + +struct gg_client { +}; + +struct gg_packet { u_int8_t ver; u_int8_t type; /* XXX nicer way for _SIZE ... ? */ @@ -48,16 +56,18 @@ struct packet { #define name_fqdn pdat.name.fqdn }; -struct gg_server *gg_server_start(char *ip, int port, - int (*handle_conn)(struct gg_server *s, int client_id, struct sockaddr_in *addr), - int (*handle_packet)(struct gg_server *s, struct gg_packet *p)); -int gg_server_send(struct gg_server *s, int client_id, - struct gg_packet *p); -void gg_server_stop(struct gg_server *s); +struct gg_server *gg_server_start(struct event_base *, char *, int, + int (*handle_conn)(struct gg_server *, int, struct sockaddr_in *), + int (*handle_packet)(struct gg_server *, struct gg_packet *)); +int gg_server_send(struct gg_server *, int, struct gg_packet *); +void gg_server_stop(struct gg_server *); + +struct gg_client *gg_client_connect(char *, int, + int (*handle_conn)(struct gg_client *, int), + int (*handle_packet)(struct gg_client *, struct gg_packet *)); +int gg_client_send(struct gg_client *, struct gg_packet *); +void gg_client_disconnect(struct gg_client *); -struct gg_client *gg_client_connect(char *ip, int port, - int (*handle_conn)(struct gg_client *c, int status), - int (*handle_packet)(struct gg_client *c, - struct gg_packet *p)); -int gg_client_send(struct gg_client *c, struct gg_packet *p); -void gg_client_disconnect(struct gg_client *c); +void *xmalloc(size_t); +void *xcalloc(size_t, size_t); +void fd_nonblock(int); -- cgit v1.2.3-59-g8ed1b