utf8: don't allow NUL in decoded strings.
[ccan] / ccan / tlist / _info
1 #include "config.h"
2 #include <stdio.h>
3 #include <string.h>
4
5 /**
6  * tlist - typesafe double linked list routines
7  *
8  * The list header contains routines for manipulating double linked lists;
9  * this extends it so you can create list head types which only accommodate
10  * a specific entry type.
11  *
12  * Example:
13  *      #include <err.h>
14  *      #include <stdio.h>
15  *      #include <stdlib.h>
16  *      #include <ccan/tlist/tlist.h>
17  *
18  *      TLIST_TYPE(children, struct child);
19  *      struct parent {
20  *              const char *name;
21  *              unsigned int num_children;
22  *              struct tlist_children children;
23  *      };
24  *
25  *      struct child {
26  *              const char *name;
27  *              struct list_node list;
28  *      };
29  *
30  *      int main(int argc, char *argv[])
31  *      {
32  *              struct parent p;
33  *              struct child *c;
34  *              unsigned int i;
35  *
36  *              if (argc < 2)
37  *                      errx(1, "Usage: %s parent children...", argv[0]);
38  *
39  *              p.name = argv[1];
40  *              tlist_init(&p.children);
41  *              for (i = 2; i < argc; i++) {
42  *                      c = malloc(sizeof(*c));
43  *                      c->name = argv[i];
44  *                      tlist_add(&p.children, c, list);
45  *                      p.num_children++;
46  *              }
47  *
48  *              printf("%s has %u children:", p.name, p.num_children);
49  *              tlist_for_each(&p.children, c, list)
50  *                      printf("%s ", c->name);
51  *              printf("\n");
52  *              return 0;
53  *      }
54  *
55  * License: LGPL
56  * Author: Rusty Russell <rusty@rustcorp.com.au>
57  */
58 int main(int argc, char *argv[])
59 {
60         if (argc != 2)
61                 return 1;
62
63         if (strcmp(argv[1], "depends") == 0) {
64                 printf("ccan/list\n");
65                 printf("ccan/tcon\n");
66                 return 0;
67         }
68
69         return 1;
70 }