1 #include <ccan/err/err.h>
7 /* Walk up to find /ccan/ => ccan directory. */
8 static unsigned int ccan_dir_prefix(const char *fulldir)
12 assert(fulldir[0] == '/');
13 for (i = strlen(fulldir) - 1; i > 0; i--) {
14 if (strncmp(fulldir+i, "/ccan", 5) != 0)
16 if (fulldir[i+5] != '\0' && fulldir[i+5] != '/')
23 const char *find_ccan_dir(const char *base)
25 static char *ccan_dir;
29 const char *tmpctx = tal_getcwd(NULL);
30 find_ccan_dir(tal_fmt(tmpctx, "%s/%s", tmpctx, base));
33 unsigned int prefix = ccan_dir_prefix(base);
35 ccan_dir = tal_strndup(NULL, base, prefix);