X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Foserver%2F_info;h=7bfaa3b129e6cbd101b9c9804d22ec903709fcd1;hb=2b79cd40277869a85810c5b14503cdda4f32dedd;hp=a05fa035f169a7a11923c79d0be639fcc18e10f8;hpb=55629c7a4496e0b559f30a8bf33af6cb3888d063;p=ccan-lca-2011.git diff --git a/ccan/oserver/_info b/ccan/oserver/_info index a05fa03..7bfaa3b 100644 --- a/ccan/oserver/_info +++ b/ccan/oserver/_info @@ -12,20 +12,44 @@ * #include * #include * #include + * #include * #include * #include * - * int main(void) + * #define STATE_FILE "/var/run/oserver/dump" + * + * int main(int argc, char *argv[]) * { - * int fd, sockfd; + * struct tevent_context *ev = tevent_context_init(NULL); + * unsigned int port = OSERVER_PORT; + * bool restore = false; + * char **restore_argv; + * + * // Save args before opt_parse mangles them. + * restore_argv = talloc_array(NULL, char *, argc+2); + * restore_argv[0] = argv[0]; + * restore_argv[1] = "--restore"; + * memcpy(restore_argv+2, argv+1, sizeof(argv[0])*argc); + * + * 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"); + * opt_register_noarg("--restore", opt_set_bool, + * &restore, opt_hidden); * - * sockfd = oserver_setup(); + * opt_parse(&argc, argv, opt_log_stderr_exit); + * if (argc != 1) + * opt_log_stderr_exit("Unknown extra arguments"); * - * fd = accept(sockfd, NULL, NULL); - * if (fd < 0) - * err(1, "Accepting connection on TCP socket"); + * if (restore) { + * if (!oserver_restore(ev, STATE_FILE)) + * err(1, "Restoring server"); + * } else if (!oserver_setup(ev, port, STATE_FILE, restore_argv)) + * err(1, "Failed to set up server"); * - * oserver_serve(fd); + * while (tevent_loop_wait(ev) == 0); + * err(1, "Serving client"); * } */ int main(int argc, char *argv[]) @@ -35,10 +59,15 @@ 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"); + printf("ccan/cdump\n"); + printf("ccan/grab_file\n"); return 0; }