5 * oserver - a demonstration module for LCA2011
7 * This code shows off the features of CCAN and various C cantrips.
12 * // hack to make valgrind show the error. FIXME!
13 * tests_pass_valgrind --child-silent-after-fork=no
16 * #include <sys/types.h>
17 * #include <sys/socket.h>
18 * #include <ccan/oserver/oserver.h>
19 * #include <ccan/opt/opt.h>
23 * int main(int argc, char *argv[])
25 * struct tevent_context *ev = tevent_context_init(NULL);
26 * unsigned int port = OSERVER_PORT;
28 * opt_register_noarg("--help|--usage|-h", opt_usage_and_exit,
29 * "\nA oserver program", "Usage information");
30 * opt_register_arg("--port", opt_set_uintval, opt_show_uintval,
31 * &port, "Server port number");
33 * opt_parse(&argc, argv, opt_log_stderr_exit);
35 * opt_log_stderr_exit("Unknown extra arguments");
37 * if (!oserver_setup(ev, port))
38 * err(1, "Failed to set up server");
40 * while (tevent_loop_wait(ev) == 0);
41 * err(1, "Serving client");
44 int main(int argc, char *argv[])
46 /* Expect exactly one argument */
50 if (strcmp(argv[1], "depends") == 0) {
51 printf("ccan/read_write_all\n");
53 printf("ccan/foreach\n");
54 printf("ccan/failtest\n");
56 printf("ccan/array_size\n");
57 printf("ccan/tevent\n");