_info 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "config.h"
  4. /**
  5. * stringmap - Macros for mapping strings to things
  6. *
  7. * stringmap provides a generic string map via macros. It also supports byte
  8. * strings with null characters.
  9. *
  10. * Features which are sorely lacking in this version of stringmap are deletion and traversal.
  11. *
  12. * Example:
  13. *
  14. * #include <ccan/stringmap/stringmap.h>
  15. *
  16. * static const char *get_string(void) {
  17. * static char buffer[4096];
  18. * char *tail;
  19. * if (!fgets(buffer, sizeof(buffer), stdin))
  20. * return NULL;
  21. * tail = strchr(buffer, 0);
  22. * if (tail>buffer && tail[-1]=='\n')
  23. * *--tail = 0;
  24. * if (!*buffer)
  25. * return NULL;
  26. * return buffer;
  27. * }
  28. *
  29. * int main(void) {
  30. * stringmap(int) map = stringmap_new(NULL);
  31. * const char *string;
  32. *
  33. * while ((string = get_string()) != NULL) {
  34. * int *count = stringmap_lookup(map, string);
  35. *
  36. * if (!count) {
  37. * printf("\"%s\" is new\n", string);
  38. * count = stringmap_enter(map, string);
  39. * }
  40. *
  41. * (*count) ++;
  42. *
  43. * printf("\"%s\" has been entered %d times\n", string, *count);
  44. * }
  45. *
  46. * stringmap_free(map);
  47. *
  48. * return 0;
  49. * }
  50. *
  51. * Authors: Joey Adams, Anders Magnusson
  52. * License: BSD
  53. */
  54. int main(int argc, char *argv[])
  55. {
  56. /* Expect exactly one argument */
  57. if (argc != 2)
  58. return 1;
  59. if (strcmp(argv[1], "depends") == 0) {
  60. printf("ccan/block_pool\n");
  61. return 0;
  62. }
  63. return 1;
  64. }