_info 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include "config.h"
  2. #include <stdio.h>
  3. #include <string.h>
  4. /**
  5. * strmap - an ordered map of strings to values
  6. *
  7. * This code implements an ordered map of strings as a critbit tree. See:
  8. *
  9. * http://cr.yp.to/critbit.html
  10. * http://github.com/agl/critbit (which this code is based on)
  11. *
  12. * License: CC0 (but some dependencies are LGPL!)
  13. * Author: Rusty Russell <rusty@rustcorp.com.au>
  14. * Ccanlint:
  15. * license_depends_compat FAIL
  16. *
  17. * Example:
  18. * #include <ccan/strmap/strmap.h>
  19. * #include <stdio.h>
  20. *
  21. * static bool dump(const char *member, size_t value, void *unused)
  22. * {
  23. * printf("%s at %zu. ", member, value);
  24. * // true means keep going with iteration.
  25. * return true;
  26. * }
  27. *
  28. * int main(int argc, char *argv[])
  29. * {
  30. * size_t i;
  31. * STRMAP(size_t) map;
  32. *
  33. * strmap_init(&map);
  34. * for (i = 1; i < argc; i++)
  35. * // This only adds the first time for this arg.
  36. * strmap_add(&map, argv[i], i);
  37. *
  38. * strmap_iterate(&map, dump, NULL);
  39. * printf("\n");
  40. * return 0;
  41. * }
  42. * // Given "foo" outputs "foo at 1. \n"
  43. * // Given "foo bar" outputs "bar at 2. foo at 1. \n"
  44. * // Given "foo foo bar zebra" outputs "bar at 3. foo at 1. zebra at 4. \n"
  45. */
  46. int main(int argc, char *argv[])
  47. {
  48. /* Expect exactly one argument */
  49. if (argc != 2)
  50. return 1;
  51. if (strcmp(argv[1], "depends") == 0) {
  52. printf("ccan/ilog\n"
  53. "ccan/short_types\n"
  54. "ccan/str\n"
  55. "ccan/tcon\n"
  56. "ccan/typesafe_cb\n");
  57. return 0;
  58. }
  59. return 1;
  60. }