]> git.ozlabs.org Git - ccan/blobdiff - ccan/strmap/_info
strmap: new module for ordered map of strings using a critbit tree.
[ccan] / ccan / strmap / _info
diff --git a/ccan/strmap/_info b/ccan/strmap/_info
new file mode 100644 (file)
index 0000000..9832f80
--- /dev/null
@@ -0,0 +1,62 @@
+#include <string.h>
+#include "config.h"
+
+/**
+ * strmap - an ordered map of strings to values
+ *
+ * This code implements an ordered map of strings as a critbit tree. See:
+ *
+ *  http://cr.yp.to/critbit.html
+ *  http://github.com/agl/critbit (which this code is based on)
+ *
+ * License: Public domain (but some dependencies are LGPL!)
+ * Author: Rusty Russell <rusty@rustcorp.com.au>
+ * Ccanlint:
+ *     license_depends_compat FAIL
+ *
+ * Example:
+ * #include <ccan/strmap/strmap.h>
+ * #include <stdio.h>
+ *
+ * static bool dump(const char *member, size_t value, void *unused)
+ * {
+ *     printf("%s at %zu. ", member, value);
+ *     // false means keep going with iteration.
+ *     return false;
+ * }
+ *
+ * int main(int argc, char *argv[])
+ * {
+ *     size_t i;
+ *     struct { STRMAP_MEMBERS(size_t); } map;
+ *
+ *     strmap_init(&map);
+ *     for (i = 1; i < argc; i++)
+ *             // This only adds the first time for this arg.
+ *             strmap_add(&map, argv[i], i);
+ *
+ *     strmap_iterate(&map, dump, NULL);
+ *     printf("\n");
+ *     return 0;
+ * }
+ * // Given 'foo' outputs 'foo at 1. '
+ * // Given 'foo bar' outputs 'bar at 2. foo at 1. '
+ * // Given 'foo foo bar zebra' outputs 'bar at 3. foo at 1. zebra at 4. '
+ */
+int main(int argc, char *argv[])
+{
+       /* Expect exactly one argument */
+       if (argc != 2)
+               return 1;
+
+       if (strcmp(argv[1], "depends") == 0) {
+               printf("ccan/ilog\n"
+                      "ccan/short_types\n"
+                      "ccan/str\n"
+                      "ccan/tcon\n"
+                      "ccan/typesafe_cb\n");
+               return 0;
+       }
+
+       return 1;
+}