_info 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #include "config.h"
  2. #include <stdio.h>
  3. #include <string.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 (3 clause)
  53. * Version: 0.2
  54. * Ccanlint:
  55. * // We actually depend (indirectly) on the LGPL talloc
  56. * license_depends_compat FAIL
  57. */
  58. int main(int argc, char *argv[])
  59. {
  60. /* Expect exactly one argument */
  61. if (argc != 2)
  62. return 1;
  63. if (strcmp(argv[1], "depends") == 0) {
  64. printf("ccan/block_pool\n");
  65. return 0;
  66. }
  67. return 1;
  68. }