summaryrefslogtreecommitdiff
path: root/ccan/objset/_info
blob: 5831f584da9e3707710c6141f34cbaeac6da3e98 (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
#include "config.h"
#include <stdio.h>
#include <string.h>

/**
 * objset - unordered set of pointers.
 *
 * This code implements a very simple unordered set of pointers.  It's very
 * fast to add and check if something is in the set; it's implemented by
 * a hash table.
 *
 * License: LGPL (v2.1 or any later version)
 *
 * Example:
 *	// Silly example to determine if an arg starts with a -
 *	#include <ccan/objset/objset.h>
 *	#include <stdio.h>
 *
 *	struct objset_arg {
 *		OBJSET_MEMBERS(const char *);
 *	};
 *
 *	int main(int argc, char *argv[])
 *	{
 *		struct objset_arg args;
 *		unsigned int i;
 *
 *		objset_init(&args);
 *		// Put all args starting with - in the set.
 *		for (i = 1; i < argc; i++)
 *			if (argv[i][0] == '-')
 *				objset_add(&args, argv[i]);
 *
 *		if (objset_empty(&args))
 *			printf("No arguments start with -.\n");
 *		else {
 *			for (i = 1; i < argc; i++)
 *				if (objset_get(&args, argv[i]))
 *					printf("%i,", i);
 *			printf("\n");
 *		}
 *		return 0;
 *	}
 *	// Given 'a b c' outputs No arguments start with -.
 *	// Given 'a -b c' outputs 2,
 *	// Given 'a -b -c d' outputs 2,3,
 */
int main(int argc, char *argv[])
{
	/* Expect exactly one argument */
	if (argc != 2)
		return 1;

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

	return 1;
}