1 /* MIT (BSD) license - see LICENSE file for details */
4 #include <ccan/tal/tal.h>
5 #include <ccan/typesafe_cb/typesafe_cb.h>
8 * ungraph: extract a graph from an ASCII graph.
9 * @ctx: context for callbacks, and/or returned errstr.
10 * @str: a string containing a graph.
11 * @add_node: callback for a new node, returns node.
12 * @add_edge: callback for a new edge, with tal_count(labels).
13 * @arg: callback argument.
15 * On success, returns NULL. On failure, returns some error message
16 * (allocated off @ctx, or returned from callbacks).
18 * If @add_node returns NULL, it must set @errstr. @add_edge
19 * returns the error message directly.
21 * @add_node and @add_edge can tal_steal the name/labels if they want,
22 * otherwise they will be freed.
24 const char *ungraph_(const tal_t *ctx,
26 void *(*add_node)(const tal_t *ctx,
30 const char *(*add_edge)(const tal_t *ctx,
38 #define ungraph(ctx, str, add_node, add_edge, arg) \
39 ungraph_((ctx), (str), \
40 typesafe_cb_preargs(void *, void *, \
44 const char **errstr), \
45 typesafe_cb_preargs(const char *, void *, \
53 #endif /* CCAN_UNGRAPH_H */