Commit 5559353a authored by Dafydd Harries's avatar Dafydd Harries

add typedefs for UDP structs

darcs-hash:20070111165210-c9803-0d25f5e8d8a8a1eab6f74c8eb87c0db267241cba.gz
parent 3b55c637
......@@ -11,8 +11,8 @@
gint
main (void)
{
struct UDPSocketManager man;
struct UDPSocket sock;
UDPSocketManager man;
UDPSocket sock;
struct sockaddr_in sin;
udp_socket_manager_init (&man);
......
......@@ -8,8 +8,8 @@
gint
main (void)
{
struct UDPSocketManager man;
struct UDPSocket sock;
UDPSocketManager man;
UDPSocket sock;
struct sockaddr_in sin;
udp_socket_manager_init (&man);
......
......@@ -24,7 +24,7 @@
static gint
udp_socket_recv (
struct UDPSocket *sock,
UDPSocket *sock,
struct sockaddr_in *from,
guint len,
gchar *buf)
......@@ -40,7 +40,7 @@ udp_socket_recv (
static gboolean
udp_socket_send (
struct UDPSocket *sock,
UDPSocket *sock,
struct sockaddr_in *to,
guint len,
gchar *buf)
......@@ -51,7 +51,7 @@ udp_socket_send (
}
static void
udp_socket_close (struct UDPSocket *sock)
udp_socket_close (UDPSocket *sock)
{
close (sock->fileno);
}
......@@ -64,8 +64,8 @@ udp_socket_close (struct UDPSocket *sock)
*/
static gboolean
udp_socket_manager_init_socket (
struct UDPSocketManager *man,
struct UDPSocket *sock,
UDPSocketManager *man,
UDPSocket *sock,
struct sockaddr_in *sin)
{
gint sockfd;
......@@ -105,12 +105,12 @@ udp_socket_manager_select (UDPPacketRecvFunc cb)
}
static void
udp_socket_manager_close (struct UDPSocketManager *man)
udp_socket_manager_close (UDPSocketManager *man)
{
}
void
udp_socket_manager_init (struct UDPSocketManager *man)
udp_socket_manager_init (UDPSocketManager *man)
{
man->init = udp_socket_manager_init_socket;
man->select = udp_socket_manager_select;
......
......@@ -2,30 +2,34 @@
#ifndef _UDP_H
#define _UDP_H
struct UDPSocket
typedef struct _UDPSocket UDPSocket;
struct _UDPSocket
{
guint fileno;
guint port;
gint (*recv) (struct UDPSocket *sock, struct sockaddr_in *from, guint len,
gint (*recv) (UDPSocket *sock, struct sockaddr_in *from, guint len,
gchar *buf);
gboolean (*send) (struct UDPSocket *sock, struct sockaddr_in *to, guint len,
gboolean (*send) (UDPSocket *sock, struct sockaddr_in *to, guint len,
gchar *buf);
void (*close) (struct UDPSocket *sock);
void (*close) (UDPSocket *sock);
};
typedef gboolean (*UDPPacketRecvFunc) (struct sockaddr_in *from, guint len,
gchar *buf);
struct UDPSocketManager
typedef struct _UDPSocketManager UDPSocketManager;
struct _UDPSocketManager
{
gboolean (*init) (struct UDPSocketManager *man, struct UDPSocket *sock,
gboolean (*init) (UDPSocketManager *man, UDPSocket *sock,
struct sockaddr_in *sin);
void (*select) (UDPPacketRecvFunc cb);
void (*close) (struct UDPSocketManager *man);
void (*close) (UDPSocketManager *man);
};
void
udp_socket_manager_init (struct UDPSocketManager *man);
udp_socket_manager_init (UDPSocketManager *man);
#endif /* _UDP_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment