_info 1.3 KB

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