]> git.ozlabs.org Git - ccan-lca-2011.git/blob - ccan/oserver/oserver_types.h
78ef48cb9788fac5a0e6f031ff85f3847861059e
[ccan-lca-2011.git] / ccan / oserver / oserver_types.h
1 #ifndef CCAN_OSERVER_TYPES_H
2 #define CCAN_OSERVER_TYPES_H
3 #include <stdlib.h>
4
5 enum state {
6         SENDING_GREETING,
7         RECEIVING_USER_QUESTION,
8         SENDING_OTHER_QUESTION_PREFIX,
9         SENDING_OTHER_QUESTION,
10         RECEIVING_OTHER_ANSWER,
11         SENDING_ANSWER_PREFIX,
12         SENDING_ANSWER,
13         FINISHED
14 };
15
16 struct client {
17         /* What are we doing today, brain? */
18         enum state state;
19         /* Our event info, and the file descriptor. */
20         struct tevent_fd *fde;
21         int fd;
22         /* The question we read from client. */
23         char *question;
24         /* The answer to the client. */
25         char *answer;
26         /* How many bytes of the reply we sent so far. */
27         size_t bytes_sent;
28         /* Our server. */
29         struct oserver *oserver;
30         /* Whose question this client is answering. */
31         struct client *subclient;
32         /* Who is answering our question. */
33         struct client *oracle;
34 };
35
36 struct oserver {
37         /* 5 clients should be enough for anybody! */
38         struct client *clients[5];
39         int fd;
40         struct tevent_fd *fde;
41 };
42 #endif /* CCAN_OSERVER_TYPES_H */