]> git.ozlabs.org Git - ccan/blob - ccan/idtree/_info
hash: use config.h settings for endian.
[ccan] / ccan / idtree / _info
1 #include <stdio.h>
2 #include <string.h>
3 #include "config.h"
4
5 /**
6  * idtree - id allocation tree
7  *
8  * There are often cases where you want to provide an integer handle for
9  * some data, and easily map it back to another structure.
10  *
11  * idtree is an efficient implementation of an int->void * mapping, with
12  * assignment of the lowest available id number.  It is from the Linux kernel
13  * via the Samba project.
14  *
15  * Example:
16  *      #include <ccan/idtree/idtree.h>
17  *      #include <ccan/talloc/talloc.h>
18  *      #include <stdlib.h>
19  *      #include <stdio.h>
20  *
21  *      // Silly example which puts args in the idtree and retreives them
22  *      int main(int argc, char *argv[])
23  *      {
24  *              struct idtree *idtree = idtree_new(NULL);
25  *              unsigned int i;
26  *      
27  *              // This will return consecutive id numbers.
28  *              for (i = 0; i < argc; i++) {
29  *                      printf("idtree_add('%s') -> id %i\n",
30  *                             argv[i], idtree_add(idtree, argv[i], -1));
31  *              }
32  *              for (i = 0; i < argc; i++) {
33  *                      printf("id %i -> '%s'\n",
34  *                             i, (char *)idtree_lookup(idtree, i));
35  *              }
36  *              return 0;
37  *      }
38  *
39  * License: GPL (2 or any later version)
40  * Maintainer: Rusty Russell <rusty@rustcorp.com.au>
41  * Author: Jim Houston <jim.houston@ccur.com>
42  */
43 int main(int argc, char *argv[])
44 {
45         if (argc != 2)
46                 return 1;
47
48         if (strcmp(argv[1], "depends") == 0) {
49                 printf("ccan/talloc\n");
50                 return 0;
51         }
52
53         return 1;
54 }