]> git.ozlabs.org Git - ccan-lca-2011.git/blob - ccan/oserver/_info
5dfc5f88fb27a001e1e9b68fb807cbbf9ff669e0
[ccan-lca-2011.git] / ccan / oserver / _info
1 #include <string.h>
2 #include "config.h"
3
4 /**
5  * oserver - a demonstration module for LCA2011
6  *
7  * This code shows off the features of CCAN and various C cantrips.
8  *
9  * License: GPL
10  *
11  * Ccanlint:
12  *      // hack to make valgrind show the error.  FIXME!
13  *      tests_pass_valgrind  --child-silent-after-fork=no
14  *
15  * Example:
16  *      #include <sys/types.h>
17  *      #include <sys/socket.h>
18  *      #include <ccan/oserver/oserver.h>
19  *      #include <ccan/opt/opt.h>
20  *      #include <err.h>
21  *      #include <stdlib.h>
22  *
23  *      int main(int argc, char *argv[])
24  *      {
25  *              struct tevent_context *ev = tevent_context_init(NULL);
26  *              unsigned int port = OSERVER_PORT;
27  *
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");
32  *
33  *              opt_parse(&argc, argv, opt_log_stderr_exit);
34  *              if (argc != 1)
35  *                      opt_log_stderr_exit("Unknown extra arguments");
36  *
37  *              if (!oserver_setup(ev, port))
38  *                      err(1, "Failed to set up server");
39  *
40  *              while (tevent_loop_wait(ev) == 0);
41  *              err(1, "Serving client");
42  *      }
43  */
44 int main(int argc, char *argv[])
45 {
46         /* Expect exactly one argument */
47         if (argc != 2)
48                 return 1;
49
50         if (strcmp(argv[1], "depends") == 0) {
51                 printf("ccan/read_write_all\n");
52                 printf("ccan/str\n");
53                 printf("ccan/foreach\n");
54                 printf("ccan/failtest\n");
55                 printf("ccan/opt\n");
56                 printf("ccan/array_size\n");
57                 printf("ccan/tevent\n");
58                 return 0;
59         }
60
61         return 1;
62 }