]> git.ozlabs.org Git - ccan-lca-2011.git/blobdiff - ccan/oserver/_info
lca2011: valgrind catches an error for us.
[ccan-lca-2011.git] / ccan / oserver / _info
index 087b0436185d69db59678f70e8e232210aaa900c..5a69855d2bb06f2c5a89442335ebd9eb9c915b98 100644 (file)
  *     #include <sys/types.h>
  *     #include <sys/socket.h>
  *     #include <ccan/oserver/oserver.h>
+ *     #include <ccan/opt/opt.h>
  *     #include <err.h>
  *     #include <stdlib.h>
  *
- *     int main(void)
+ *     int main(int argc, char *argv[])
  *     {
- *             int fd, sockfd;
+ *             struct tevent_context *ev = tevent_context_init(NULL);
+ *             unsigned int port = OSERVER_PORT;
  *
- *             sockfd = oserver_setup();
+ *             opt_register_noarg("--help|--usage|-h", opt_usage_and_exit,
+ *                                "\nA oserver program", "Usage information");
+ *             opt_register_arg("--port", opt_set_uintval, opt_show_uintval,
+ *                              &port, "Server port number");
  *
- *             fd = accept(sockfd, NULL, NULL);
- *             if (fd < 0)
- *                     err(1, "Accepting connection on TCP socket");
+ *             opt_parse(&argc, argv, opt_log_stderr_exit);
+ *             if (argc != 1)
+ *                     opt_log_stderr_exit("Unknown extra arguments");
  *
- *             oserver_serve(fd);
+ *             if (!oserver_setup(ev, port))
+ *                     err(1, "Failed to set up server");
+ *
+ *             while (tevent_loop_wait(ev) == 0);
+ *             err(1, "Serving client");
  *     }
  */
 int main(int argc, char *argv[])
@@ -35,8 +44,13 @@ int main(int argc, char *argv[])
                return 1;
 
        if (strcmp(argv[1], "depends") == 0) {
-               printf("ccan/compiler\n");
                printf("ccan/read_write_all\n");
+               printf("ccan/str\n");
+               printf("ccan/foreach\n");
+               printf("ccan/failtest\n");
+               printf("ccan/opt\n");
+               printf("ccan/array_size\n");
+               printf("ccan/tevent\n");
                return 0;
        }