]> git.ozlabs.org Git - ccan/blob - ccan/generator/_info
ccanlint: Move ccanlint test options from _info comments to code
[ccan] / ccan / generator / _info
1 #include "config.h"
2 #include <stdio.h>
3 #include <string.h>
4
5 #include <ccan/coroutine/coroutine.h>
6
7 /**
8  * generator - generators for C
9  *
10  * Generators are a limited form of coroutines, which provide a useful
11  * way of expressing certain problems, while being much simpler to
12  * understand than general coroutines.
13  *
14  * Instead of returning a single value, a generator can "yield" a
15  * value at various points during its execution.  Whenever it yields,
16  * the "calling" function resumes and obtains the newly yielded value
17  * to work with.  When the caller asks for the next value from the
18  * generator, the generator resumes execution from the last yield and
19  * continues onto the next.
20  *
21  * Example:
22  *      #include <stdio.h>
23  *      #include <ccan/generator/generator.h>
24  *
25  *      generator_def_static(simple_gen, int)
26  *      {
27  *              generator_yield(1);
28  *              generator_yield(3);
29  *              generator_yield(17);
30  *      }
31  *
32  *      int main(int argc, char *argv[])
33  *      {
34  *              generator_t(int) gen = simple_gen();
35  *              int *ret;
36  *
37  *              while ((ret = generator_next(gen)) != NULL) {
38  *                      printf("Generator returned %d\n", *ret);
39  *              }
40  *
41  *              return 0;
42  *      }
43  *
44  * Author: David Gibson <david@gibson.dropbear.id.au>
45  * License: LGPL (v2.1 or any later version)
46  */
47 int main(int argc, char *argv[])
48 {
49         /* Expect exactly one argument */
50         if (argc != 2)
51                 return 1;
52
53         if (strcmp(argv[1], "depends") == 0) {
54                 printf("ccan/alignof\n");
55                 printf("ccan/coroutine\n");
56                 printf("ccan/cppmagic\n");
57                 printf("ccan/compiler\n");
58                 return 0;
59         }
60
61         if (strcmp(argv[1], "ported") == 0) {
62 #if COROUTINE_AVAILABLE
63                 printf("\n");
64                 return 1;
65 #else
66                 printf("Needs coroutine support\n");
67 #endif
68         }
69
70         if (strcmp(argv[1], "testdepends") == 0) {
71                 printf("ccan/str\n");
72                 return 0;
73         }
74
75         if (strcmp(argv[1], "ccanlint") == 0) {
76                 /* We need several gcc extensions */
77                 printf("objects_build_without_features FAIL\n");
78                 printf("tests_compile_without_features FAIL\n");
79                 printf("tests_helpers_compile_without_features FAIL\n");
80                 return 0;
81         }
82
83         return 1;
84 }