1 #include <ccan/err/err.h>
2 #include <ccan/tal/path/path.h>
8 /* Walk up to find /ccan/ => ccan directory. */
9 static unsigned int ccan_dir_prefix(const char *fulldir)
13 assert(fulldir[0] == '/');
14 for (i = strlen(fulldir) - 1; i > 0; i--) {
15 if (strncmp(fulldir+i, "/ccan", 5) != 0)
17 if (fulldir[i+5] != '\0' && fulldir[i+5] != '/')
24 const char *find_ccan_dir(const char *base)
26 static char *ccan_dir;
30 const char *tmpctx = path_cwd(NULL);
31 find_ccan_dir(path_join(tmpctx, tmpctx, base));
34 unsigned int prefix = ccan_dir_prefix(base);
36 ccan_dir = tal_strndup(NULL, base, prefix);