_info 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include <string.h>
  2. #include "config.h"
  3. /**
  4. * objset - unordered set of pointers.
  5. *
  6. * This code implements a very simple unordered set of pointers. It's very
  7. * fast to add and check if something is in the set; it's implemented by
  8. * a hash table.
  9. *
  10. * License: LGPL (v2.1 or any later version)
  11. *
  12. * Example:
  13. * // Silly example to determine if an arg starts with a -
  14. * #include <ccan/objset/objset.h>
  15. * #include <stdio.h>
  16. *
  17. * struct objset_arg {
  18. * OBJSET_MEMBERS(const char *);
  19. * };
  20. *
  21. * int main(int argc, char *argv[])
  22. * {
  23. * struct objset_arg args;
  24. * unsigned int i;
  25. *
  26. * objset_init(&args);
  27. * // Put all args starting with - in the set.
  28. * for (i = 1; i < argc; i++)
  29. * if (argv[i][0] == '-')
  30. * objset_add(&args, argv[i]);
  31. *
  32. * if (objset_empty(&args))
  33. * printf("No arguments start with -.\n");
  34. * else {
  35. * for (i = 1; i < argc; i++)
  36. * if (objset_get(&args, argv[i]))
  37. * printf("%i,", i);
  38. * printf("\n");
  39. * }
  40. * return 0;
  41. * }
  42. * // Given 'a b c' outputs No arguments start with -.
  43. * // Given 'a -b c' outputs 2,
  44. * // Given 'a -b -c d' outputs 2,3,
  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/hash\n");
  53. printf("ccan/htable\n");
  54. printf("ccan/tcon\n");
  55. return 0;
  56. }
  57. return 1;
  58. }