6 * stringmap - Macros for mapping strings to things
8 * stringmap provides a generic string map via macros. It also supports byte
9 * strings with null characters.
11 * Features which are sorely lacking in this version of stringmap are deletion and traversal.
15 * #include <ccan/stringmap/stringmap.h>
17 * static const char *get_string(void) {
18 * static char buffer[4096];
20 * if (!fgets(buffer, sizeof(buffer), stdin))
22 * tail = strchr(buffer, 0);
23 * if (tail>buffer && tail[-1]=='\n')
31 * stringmap(int) map = stringmap_new(NULL);
34 * while ((string = get_string()) != NULL) {
35 * int *count = stringmap_lookup(map, string);
38 * printf("\"%s\" is new\n", string);
39 * count = stringmap_enter(map, string);
44 * printf("\"%s\" has been entered %d times\n", string, *count);
47 * stringmap_free(map);
52 * Authors: Joey Adams, Anders Magnusson
53 * License: BSD (3 clause)
56 * // We actually depend (indirectly) on the LGPL talloc
57 * license_depends_compat FAIL
59 int main(int argc, char *argv[])
61 /* Expect exactly one argument */
65 if (strcmp(argv[1], "depends") == 0) {
66 printf("ccan/block_pool\n");