summaryrefslogtreecommitdiffstats
path: root/types.h
blob: 058d3dfd5556b0315b04176db94e1cfc482bda40 (plain) (blame)
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
44
45
46
47
48
49
50
51
52
#ifndef _TYPES_H_
#define _TYPES_H_

#include <stddef.h>
#include <stdint.h>
#include <time.h>

#define REQLEN 4000
#define MAXMSGLEN 10000

#define BOOL uint8_t
#define TRUE 1
#define FALSE 0

typedef struct {
	void (*callback)(void *data, int haveIn, int haveOut, int doCleanup);
	int fd;
} epoll_item_t;

typedef struct {
	void (*callback)(void *data, int haveIn, int haveOut, int doCleanup);
	int fd;
} epoll_listen_t;

typedef struct {
	void (*callback)(void *data, int haveIn, int haveOut, int doCleanup);
	int fd;
	int padding;
	// Send buffer (me to client)
	size_t sbPos, sbFill, sbLen;
	char *sendBuffer; // Dynamically allocated, might or might not get huge
	// Recv buffer (client's request)
	size_t rbPos;
	char readBuffer[REQLEN]; // Static, queries > 4000 bytes simply not supported
	BOOL bound;
} epoll_client_t;

typedef struct {
	void (*callback)(void *data, int haveIn, int haveOut, int doCleanup);
	int fd;
	// Send buffer (me to server)
	size_t sbPos, sbFill, sbLen;
	char *sendBuffer; // Dynamically allocated, might or might not get huge
	// Recv buffer (server's response)
	size_t rbPos;
	char readBuffer[MAXMSGLEN];
	BOOL bound;
	//unsigned long messageId; // ID of message currently being received
	time_t lastActive;
} epoll_server_t;

#endif