5 * oserver - a demonstration module for LCA2011
7 * This code shows off the features of CCAN and various C cantrips.
12 * #include <sys/types.h>
13 * #include <sys/socket.h>
14 * #include <ccan/oserver/oserver.h>
15 * #include <ccan/opt/opt.h>
19 * int main(int argc, char *argv[])
21 * struct tevent_context *ev = tevent_context_init(NULL);
22 * unsigned int port = OSERVER_PORT;
24 * opt_register_noarg("--help|--usage|-h", opt_usage_and_exit,
25 * "\nA oserver program", "Usage information");
26 * opt_register_arg("--port", opt_set_uintval, opt_show_uintval,
27 * &port, "Server port number");
29 * opt_parse(&argc, argv, opt_log_stderr_exit);
31 * opt_log_stderr_exit("Unknown extra arguments");
33 * if (!oserver_setup(ev, port))
34 * err(1, "Failed to set up server");
36 * while (tevent_loop_wait(ev) == 0);
37 * err(1, "Serving client");
40 int main(int argc, char *argv[])
42 /* Expect exactly one argument */
46 if (strcmp(argv[1], "depends") == 0) {
47 printf("ccan/read_write_all\n");
49 printf("ccan/foreach\n");
50 printf("ccan/failtest\n");
52 printf("ccan/array_size\n");
53 printf("ccan/tevent\n");
54 printf("ccan/cdump\n");