-}
-
-int uci_parse(struct uci_context *ctx, const char *name)
-{
- struct uci_parse_context *pctx;
-
- UCI_HANDLE_ERR(ctx);
- UCI_ASSERT(ctx, name != NULL);
-
- /* make sure no memory from previous parse attempts is leaked */
- uci_parse_cleanup(ctx);
-
- pctx = (struct uci_parse_context *) uci_malloc(ctx, sizeof(struct uci_parse_context));
- ctx->pctx = pctx;
-
- /* TODO: use /etc/config/ */
- pctx->file = fopen(name, "r");
- if (!pctx->file)
- UCI_THROW(ctx, UCI_ERR_NOTFOUND);
-
- pctx->cfg = uci_alloc_file(ctx, name);
-
- while (!feof(pctx->file)) {
- uci_getln(ctx);
- if (*(pctx->buf))
- uci_parse_line(ctx);
- }
-
- /* add to main config file list */
- uci_list_add(&ctx->root, &pctx->cfg->list);
- pctx->cfg = NULL;
-
- /* if no error happened, we can get rid of the parser context now */
- uci_parse_cleanup(ctx);