]> git.ozlabs.org Git - ccan-lca-2011.git/blob - ccan/oserver/oserver_types.h
6f7b42b82b581513dc138d62f67dacbae856d36c
[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         /* Position in oserver's clients array. */
24         unsigned int id;
25         /* The question we read from client. */
26         char *question;
27         /* The answer to the client. */
28         char *answer;
29         /* How many bytes of the reply we sent so far. */
30         size_t bytes_sent;
31         /* Our server. */
32         struct oserver *oserver CDUMP_IGNORE;
33         /* Whose question this client is answering (-1 for none) */
34         int subclient;
35         /* Who is answering our question (-1 for none) */
36         int oracle;
37 };
38
39 CDUMP_SAVED struct oserver {
40         unsigned int max_clients;
41         /* 5 clients should be enough for anybody! */
42         struct client *clients[5];
43         int fd;
44         struct tevent_fd *fde CDUMP_IGNORE;
45         const char *dumpfile;
46         int argv_len;
47         char **argv CDUMP_LEN(argv_len);
48 };
49 #endif /* CCAN_OSERVER_TYPES_H */