X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Foserver%2Foserver_types.h;fp=ccan%2Foserver%2Foserver_types.h;h=78ef48cb9788fac5a0e6f031ff85f3847861059e;hb=9b50bdc2a1781d39fa812dbfacaa3b168d861a2a;hp=0000000000000000000000000000000000000000;hpb=5cde12ca405f988a8a35b4281c90fbaf53f5464f;p=ccan-lca-2011.git diff --git a/ccan/oserver/oserver_types.h b/ccan/oserver/oserver_types.h new file mode 100644 index 0000000..78ef48c --- /dev/null +++ b/ccan/oserver/oserver_types.h @@ -0,0 +1,42 @@ +#ifndef CCAN_OSERVER_TYPES_H +#define CCAN_OSERVER_TYPES_H +#include + +enum state { + SENDING_GREETING, + RECEIVING_USER_QUESTION, + SENDING_OTHER_QUESTION_PREFIX, + SENDING_OTHER_QUESTION, + RECEIVING_OTHER_ANSWER, + SENDING_ANSWER_PREFIX, + SENDING_ANSWER, + FINISHED +}; + +struct client { + /* What are we doing today, brain? */ + enum state state; + /* Our event info, and the file descriptor. */ + struct tevent_fd *fde; + int fd; + /* The question we read from client. */ + char *question; + /* The answer to the client. */ + char *answer; + /* How many bytes of the reply we sent so far. */ + size_t bytes_sent; + /* Our server. */ + struct oserver *oserver; + /* Whose question this client is answering. */ + struct client *subclient; + /* Who is answering our question. */ + struct client *oracle; +}; + +struct oserver { + /* 5 clients should be enough for anybody! */ + struct client *clients[5]; + int fd; + struct tevent_fd *fde; +}; +#endif /* CCAN_OSERVER_TYPES_H */