summaryrefslogtreecommitdiff
path: root/connection.h
blob: 9d6322b4ad67752a0854f6441f4601a2f881a0f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef _CONNECTION_H_
#define _CONNECTION_H_

typedef struct Connection Connection;
typedef union  ConnectionEvent ConnectionEvent;

typedef enum
{
    CONNECTION_READ,
    CONNECTION_CLOSE,
    CONNECTION_ERROR
} ConnectionEventType;

union ConnectionEvent
{
    ConnectionEventType		type;

    struct
    {
	ConnectionEventType	type;
    } read;

    struct
    {
	ConnectionEventType	type;
    } close;

    struct
    {
	ConnectionEventType	type;
    } error;
};

typedef void (* ConnectionFunc) (Connection *connection,
				 ConnectionEvent *event);

Connection *connection_new (int fd,
			    MainContext *context,
			    ConnectionFunc func,
			    gpointer data);


#endif