-/*
- * Clean up all extra memory used by the parser
- */
-static void uci_parse_cleanup(struct uci_context *ctx)
-{
- struct uci_parse_context *pctx;
-
- pctx = ctx->pctx;
- if (!pctx)
- return;
-
- ctx->pctx = NULL;
- if (pctx->cfg) {
- uci_list_del(&pctx->cfg->list);
- uci_drop_config(pctx->cfg);
- }
- if (pctx->buf)
- free(pctx->buf);
- if (pctx->file)
- fclose(pctx->file);
-
- free(pctx);
-}
-
-/*
- * move the string pointer forward until a non-whitespace character or
- * EOL is reached
- */
-static void skip_whitespace(char **str)
-{
- while (**str && isspace(**str))
- *str += 1;
-}
-
-static inline void addc(char **dest, char **src)
-{
- **dest = **src;
- *dest += 1;
- *src += 1;
-}
-
-static inline void parse_backslash(char **str, char **target)
-{
- /* skip backslash */
- *str += 1;
- /* FIXME: decode escaped characters? */
- addc(target, str);
-}
-
-/*
- * parse a double quoted string argument from the command line
- */
-static void parse_double_quote(struct uci_context *ctx, char **str, char **target)
-{
- char c;
-
- /* skip quote character */
- *str += 1;
-
- while ((c = **str)) {
- switch(c) {
- case '\\':
- parse_backslash(str, target);
- continue;
- case '"':
- **target = 0;
- *str += 1;
- return;
- default:
- addc(target, str);