summaryrefslogtreecommitdiff
path: root/lib/ccan/tlist/_info
blob: e18e2efb23b654924d0ec726765eb35340118cfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <stdio.h>
#include <string.h>
#include "config.h"

/**
 * tlist - typesafe double linked list routines
 *
 * The list header contains routines for manipulating double linked lists;
 * this extends it so you can create list head types which only accomodate
 * a specific entry type.
 *
 * Example:
 *	#include <err.h>
 *	#include <stdio.h>
 *	#include <stdlib.h>
 *	#include <ccan/tlist/tlist.h>
 *
 *	// We could use TLIST_TYPE(children, struct child) to define this.
 *	struct tlist_children {
 *		struct list_head raw;
 *		TCON(struct child *canary);
 *	};
 *	struct parent {
 *		const char *name;
 *		struct tlist_children children;
 *		unsigned int num_children;
 *	};
 *
 *	struct child {
 *		const char *name;
 *		struct list_node list;
 *	};
 *
 *	int main(int argc, char *argv[])
 *	{
 *		struct parent p;
 *		struct child *c;
 *		unsigned int i;
 *
 *		if (argc < 2)
 *			errx(1, "Usage: %s parent children...", argv[0]);
 *
 *		p.name = argv[1];
 *		tlist_init(&p.children);
 *		for (i = 2; i < argc; i++) {
 *			c = malloc(sizeof(*c));
 *			c->name = argv[i];
 *			tlist_add(&p.children, c, list);
 *			p.num_children++;
 *		}
 *
 *		printf("%s has %u children:", p.name, p.num_children);
 *		tlist_for_each(&p.children, c, list)
 *			printf("%s ", c->name);
 *		printf("\n");
 *		return 0;
 *	}
 *
 * License: LGPL
 * Author: Rusty Russell <rusty@rustcorp.com.au>
 */
int main(int argc, char *argv[])
{
	if (argc != 2)
		return 1;

	if (strcmp(argv[1], "depends") == 0) {
		printf("ccan/list\n");
		printf("ccan/tcon\n");
		return 0;
	}

	return 1;
}