From 9b50bdc2a1781d39fa812dbfacaa3b168d861a2a Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sat, 22 Jan 2011 14:10:51 +1030 Subject: [PATCH] lca2011: move types out to a separate header. Preparation for cdump. --- ccan/oserver/oserver.c | 39 +-------------------------------- ccan/oserver/oserver_types.h | 42 ++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 38 deletions(-) create mode 100644 ccan/oserver/oserver_types.h diff --git a/ccan/oserver/oserver.c b/ccan/oserver/oserver.c index ad8f315..317a01c 100644 --- a/ccan/oserver/oserver.c +++ b/ccan/oserver/oserver.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -17,17 +18,6 @@ #include #include -enum state { - SENDING_GREETING, - RECEIVING_USER_QUESTION, - SENDING_OTHER_QUESTION_PREFIX, - SENDING_OTHER_QUESTION, - RECEIVING_OTHER_ANSWER, - SENDING_ANSWER_PREFIX, - SENDING_ANSWER, - FINISHED -}; - static uint16_t state_flag_map[] = { [SENDING_GREETING] = TEVENT_FD_WRITE, [RECEIVING_USER_QUESTION] = TEVENT_FD_READ, @@ -39,33 +29,6 @@ static uint16_t state_flag_map[] = { [FINISHED] = 0 }; -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; -}; - static ssize_t write_string(int fd, const char *str) { return write(fd, str, strlen(str)); 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 */ -- 2.39.2