]> git.ozlabs.org Git - ccan-lca-2011.git/blobdiff - ccan/oserver/oserver_types.h
lca2011: use max_clients field to control dynamic length of clients array.
[ccan-lca-2011.git] / ccan / oserver / oserver_types.h
index 78ef48cb9788fac5a0e6f031ff85f3847861059e..4d70199b351e3bab0f8419e10826d23ce1de0e71 100644 (file)
@@ -1,8 +1,9 @@
 #ifndef CCAN_OSERVER_TYPES_H
 #define CCAN_OSERVER_TYPES_H
 #include <stdlib.h>
+#include <ccan/cdump/cdump.h>
 
-enum state {
+CDUMP_SAVED enum state {
        SENDING_GREETING,
        RECEIVING_USER_QUESTION,
        SENDING_OTHER_QUESTION_PREFIX,
@@ -13,12 +14,14 @@ enum state {
        FINISHED
 };
 
-struct client {
+CDUMP_SAVED struct client {
        /* What are we doing today, brain? */
        enum state state;
        /* Our event info, and the file descriptor. */
-       struct tevent_fd *fde;
+       struct tevent_fd *fde CDUMP_IGNORE;
        int fd;
+       /* Position in oserver's clients array. */
+       unsigned int id;
        /* The question we read from client. */
        char *question;
        /* The answer to the client. */
@@ -26,17 +29,20 @@ struct client {
        /* 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 *oserver CDUMP_IGNORE;
+       /* Whose question this client is answering (-1 for none) */
+       int subclient;
+       /* Who is answering our question (-1 for none) */
+       int oracle;
 };
 
-struct oserver {
-       /* 5 clients should be enough for anybody! */
-       struct client *clients[5];
+CDUMP_SAVED struct oserver {
+       unsigned int max_clients;
+       struct client **clients CDUMP_LEN(max_clients);
        int fd;
-       struct tevent_fd *fde;
+       struct tevent_fd *fde CDUMP_IGNORE;
+       const char *dumpfile;
+       int argv_len;
+       char **argv CDUMP_LEN(argv_len);
 };
 #endif /* CCAN_OSERVER_TYPES_H */