if (!p->confdir)
return;
- if ((asprintf(&filename, "%s/%s", UCI_SAVEDIR, p->e.name) < 0) || !filename)
+ if ((asprintf(&filename, "%s/%s", ctx->savedir, p->e.name) < 0) || !filename)
UCI_THROW(ctx, UCI_ERR_MEM);
UCI_TRAP_SAVE(ctx, done);
char *filename;
UCI_ASSERT(ctx, uci_validate_name(name));
- filename = uci_malloc(ctx, strlen(name) + sizeof(UCI_CONFDIR) + 2);
- sprintf(filename, UCI_CONFDIR "/%s", name);
+ filename = uci_malloc(ctx, strlen(name) + strlen(ctx->confdir) + 2);
+ sprintf(filename, "%s/%s", ctx->confdir, name);
return filename;
}
if (uci_list_empty(&p->history))
return 0;
- if ((asprintf(&filename, "%s/%s", UCI_SAVEDIR, p->e.name) < 0) || !filename)
+ if ((asprintf(&filename, "%s/%s", ctx->savedir, p->e.name) < 0) || !filename)
UCI_THROW(ctx, UCI_ERR_MEM);
ctx->errno = 0;
glob_t globbuf;
int size, i;
char *buf;
+ char *dir;
UCI_HANDLE_ERR(ctx);
- if (glob(UCI_CONFDIR "/*", GLOB_MARK, NULL, &globbuf) != 0)
+ dir = uci_malloc(ctx, strlen(ctx->confdir) + 1 + sizeof("/*"));
+ sprintf(dir, "%s/*", ctx->confdir);
+ if (glob(dir, GLOB_MARK, NULL, &globbuf) != 0)
UCI_THROW(ctx, UCI_ERR_NOTFOUND);
size = sizeof(char *) * (globbuf.gl_pathc + 1);
buf += strlen(buf) + 1;
}
*list = configs;
+ free(dir);
return 0;
}