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