]> git.ozlabs.org Git - ccan-lca-2011.git/blob - ccan/oserver/_info
c5f5b4be48225f8482ec325bc7fc16032a3cf432
[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  * Example:
12  *      #include <sys/types.h>
13  *      #include <sys/socket.h>
14  *      #include <ccan/oserver/oserver.h>
15  *      #include <ccan/opt/opt.h>
16  *      #include <err.h>
17  *      #include <stdlib.h>
18  *
19  *      int main(int argc, char *argv[])
20  *      {
21  *              struct tevent_context *ev = tevent_context_init(NULL);
22  *              unsigned int port = OSERVER_PORT;
23  *
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");
28  *
29  *              opt_parse(&argc, argv, opt_log_stderr_exit);
30  *              if (argc != 1)
31  *                      opt_log_stderr_exit("Unknown extra arguments");
32  *
33  *              if (!oserver_setup(ev, port))
34  *                      err(1, "Failed to set up server");
35  *
36  *              while (tevent_loop_wait(ev) == 0);
37  *              err(1, "Serving client");
38  *      }
39  */
40 int main(int argc, char *argv[])
41 {
42         /* Expect exactly one argument */
43         if (argc != 2)
44                 return 1;
45
46         if (strcmp(argv[1], "depends") == 0) {
47                 printf("ccan/read_write_all\n");
48                 printf("ccan/str\n");
49                 printf("ccan/foreach\n");
50                 printf("ccan/noerr\n");
51                 printf("ccan/failtest\n");
52                 printf("ccan/opt\n");
53                 printf("ccan/array_size\n");
54                 printf("ccan/tevent\n");
55                 return 0;
56         }
57
58         return 1;
59 }