/*
* extract the next argument from the command line
*/
-static int next_arg(struct uci_context *ctx, bool required, bool name)
+static int next_arg(struct uci_context *ctx, bool required, bool name, bool package)
{
struct uci_parse_context *pctx = ctx->pctx;
int val, ptr;
goto done;
}
- if (name && !uci_validate_name(pctx_str(pctx, val)))
+ if (name && !uci_validate_str(pctx_str(pctx, val), name, package))
uci_parse_error(ctx, "invalid character in name field");
done:
uci_getln(ctx, 0);
/*FIXME do we need to skip empty lines? */
- ofs_result = next_arg(ctx, false, false);
+ ofs_result = next_arg(ctx, false, false, false);
*result = pctx_str(ctx->pctx, ofs_result);
*str = pctx_cur_str(ctx->pctx);
int ofs_tmp;
skip_whitespace(ctx);
- ofs_tmp = next_arg(ctx, false, false);
+ ofs_tmp = next_arg(ctx, false, false, false);
tmp = pctx_str(ctx->pctx, ofs_tmp);
if (*tmp && (ctx->flags & UCI_FLAG_STRICT))
uci_parse_error(ctx, "too many arguments");
/* command string null-terminated by strtok */
pctx->pos += strlen(pctx_cur_str(pctx)) + 1;
- ofs_name = next_arg(ctx, true, true);
+ ofs_name = next_arg(ctx, true, true, true);
name = pctx_str(pctx, ofs_name);
assert_eol(ctx);
if (single)
/* command string null-terminated by strtok */
pctx->pos += strlen(pctx_cur_str(pctx)) + 1;
- ofs_type = next_arg(ctx, true, false);
+ ofs_type = next_arg(ctx, true, false, false);
type = pctx_str(pctx, ofs_type);
if (!uci_validate_type(type))
uci_parse_error(ctx, "invalid character in type field");
- ofs_name = next_arg(ctx, false, true);
+ ofs_name = next_arg(ctx, false, true, false);
type = pctx_str(pctx, ofs_type);
name = pctx_str(pctx, ofs_name);
assert_eol(ctx);
/* command string null-terminated by strtok */
pctx->pos += strlen(pctx_cur_str(pctx)) + 1;
- ofs_name = next_arg(ctx, true, true);
- ofs_value = next_arg(ctx, false, false);
+ ofs_name = next_arg(ctx, true, true, false);
+ ofs_value = next_arg(ctx, false, false, false);
name = pctx_str(pctx, ofs_name);
value = pctx_str(pctx, ofs_value);
assert_eol(ctx);
__private void *uci_malloc(struct uci_context *ctx, size_t size);
__private void *uci_realloc(struct uci_context *ctx, void *ptr, size_t size);
__private char *uci_strdup(struct uci_context *ctx, const char *str);
-__private bool uci_validate_str(const char *str, bool name);
+__private bool uci_validate_str(const char *str, bool name, bool package);
__private void uci_add_delta(struct uci_context *ctx, struct uci_list *list, int cmd, const char *section, const char *option, const char *value);
__private void uci_free_delta(struct uci_delta *h);
__private struct uci_package *uci_alloc_package(struct uci_context *ctx, const char *name);
static inline bool uci_validate_package(const char *str)
{
- return uci_validate_str(str, false);
+ return uci_validate_str(str, false, true);
}
static inline bool uci_validate_type(const char *str)
{
- return uci_validate_str(str, false);
+ return uci_validate_str(str, false, false);
}
static inline bool uci_validate_name(const char *str)
{
- return uci_validate_str(str, true);
+ return uci_validate_str(str, true, false);
}
/* initialize a list head/item */