UCI_THROW(ctx, UCI_ERR_NOTFOUND);
}
- fd = open(filename, (write ? O_RDWR | O_CREAT : O_RDONLY));
+ fd = open(filename, (write ? O_RDWR | O_CREAT : O_RDONLY), UCI_FILEMODE);
if (fd <= 0)
goto error;
fprintf(f, "\n");
else
fprintf(f, "=%s\n", h->value);
- uci_list_del(&e->list);
+ uci_free_history(h);
}
done:
return p;
}
-char **uci_list_configs(struct uci_context *ctx)
+int uci_list_configs(struct uci_context *ctx, char ***list)
{
char **configs;
glob_t globbuf;
int size, i;
char *buf;
+ UCI_HANDLE_ERR(ctx);
+
if (glob(UCI_CONFDIR "/*", GLOB_MARK, NULL, &globbuf) != 0)
- return NULL;
+ UCI_THROW(ctx, UCI_ERR_NOTFOUND);
size = sizeof(char *) * (globbuf.gl_pathc + 1);
for(i = 0; i < globbuf.gl_pathc; i++) {
strcpy(buf, p);
buf += strlen(buf) + 1;
}
- return configs;
+ *list = configs;
+
+ return 0;
}