_info 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #include "config.h"
  2. #include <stdio.h>
  3. #include <string.h>
  4. /**
  5. * strset - an ordered set of strings
  6. *
  7. * This code implements an ordered set of string 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. * Note that ccan/htable is faster and uses less memory, but doesn't provide
  13. * ordered or prefix operations.
  14. *
  15. * Example:
  16. * // Print all words in order.
  17. * #include <ccan/strset/strset.h>
  18. * #include <ccan/tal/grab_file/grab_file.h>
  19. * #include <err.h>
  20. * #include <string.h>
  21. *
  22. * static bool dump(const char *member, void *unused)
  23. * {
  24. * printf("%s ", member);
  25. * return true; // Keep going with iteration.
  26. * }
  27. *
  28. * int main(void)
  29. * {
  30. * struct strset words;
  31. * char *file, *word;
  32. *
  33. * strset_init(&words);
  34. * file = grab_fd(NULL, 0);
  35. * if (!file)
  36. * err(1, "Reading stdin");
  37. *
  38. * for (word = strtok(file, " \t\r\n");
  39. * word;
  40. * word = strtok(NULL, " \t\r\n")) {
  41. * strset_add(&words, word);
  42. * }
  43. * strset_iterate(&words, dump, NULL);
  44. * printf("\n");
  45. * return 0;
  46. * }
  47. * // Given "foo bar" outputs "bar foo "
  48. * // Given "foo foo bar" outputs "bar foo "
  49. *
  50. * License: CC0 (but some dependencies are LGPL!)
  51. * Author: Rusty Russell <rusty@rustcorp.com.au>
  52. * Ccanlint:
  53. * license_depends_compat FAIL
  54. */
  55. int main(int argc, char *argv[])
  56. {
  57. /* Expect exactly one argument */
  58. if (argc != 2)
  59. return 1;
  60. if (strcmp(argv[1], "depends") == 0) {
  61. printf("ccan/ilog\n"
  62. "ccan/likely\n"
  63. "ccan/short_types\n"
  64. "ccan/str\n"
  65. "ccan/typesafe_cb\n");
  66. return 0;
  67. }
  68. return 1;
  69. }