_info 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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/compiler/compiler.h>
  19. * #include <ccan/strmap/strmap.h>
  20. * #include <stdio.h>
  21. *
  22. * static bool dump(const char *member, size_t value, void *unused UNNEEDED)
  23. * {
  24. * printf("%s at %zu. ", member, value);
  25. * // true means keep going with iteration.
  26. * return true;
  27. * }
  28. *
  29. * int main(int argc, char *argv[])
  30. * {
  31. * size_t i;
  32. * STRMAP(size_t) map;
  33. *
  34. * strmap_init(&map);
  35. * for (i = 1; i < (size_t)argc; i++)
  36. * // This only adds the first time for this arg.
  37. * strmap_add(&map, argv[i], i);
  38. *
  39. * strmap_iterate(&map, dump, NULL);
  40. * printf("\n");
  41. * return 0;
  42. * }
  43. * // Given "foo" outputs "foo at 1. \n"
  44. * // Given "foo bar" outputs "bar at 2. foo at 1. \n"
  45. * // Given "foo foo bar zebra" outputs "bar at 3. foo at 1. zebra at 4. \n"
  46. */
  47. int main(int argc, char *argv[])
  48. {
  49. /* Expect exactly one argument */
  50. if (argc != 2)
  51. return 1;
  52. if (strcmp(argv[1], "depends") == 0) {
  53. printf("ccan/ilog\n"
  54. "ccan/short_types\n"
  55. "ccan/str\n"
  56. "ccan/tcon\n"
  57. "ccan/typesafe_cb\n");
  58. return 0;
  59. }
  60. return 1;
  61. }