_info 1.3 KB

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