initial commit
[xdos] / src / client.h
1 #ifndef CLIENT_H_
2 #define CLIENT_H_
3
4 enum client_state {
5         CLIENT_SETUP,   /* setup stage: waiting for the initial byteorder/version data */
6         CLIENT_ACTIVE,  /* main stage: accepting requests and sending events */
7         CLIENT_TEARDOWN /* TBD */
8 };
9
10 #define CLIENT_BUF_SIZE         256
11
12 struct client {
13         int sock;
14         int swap;       /* true if we must byteswap all data to/from this client */
15
16         enum client_state state;
17
18         char inbuf[CLIENT_BUF_SIZE];
19         int bufsz;
20
21         struct client *next;
22 };
23
24 /* functions to manage the client list */
25 int add_client(int s);
26 int remove_client(int s);
27 int remove_closed(void);
28
29 struct client *find_client_sock(int s); /* find by socket */
30 struct client *get_clients(void);
31
32 void free_clients(void);
33
34 /* functions to handle client communictation */
35 int handle_client(struct client *c);
36
37 #endif  /* CLIENT_H_ */