Add config framework non-empty string validation requirement option.

Add config framework OPT_CHAR_ARRAY_T and OPT_STRINGFIELD_T non-empty
requirement option.  There are cases were you don't want a config option
string to be empty.  To require the option string to be non-empty, just
set the aco_option_register() flags parameter to non-zero.

* Updated some config framework enum aco_option_type comments.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@393034 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Richard Mudgett
2013-06-27 02:55:16 +00:00
parent d014ad2261
commit d416b15c52
2 changed files with 18 additions and 8 deletions

View File

@@ -1342,6 +1342,10 @@ static int stringfield_handler_fn(const struct aco_option *opt, struct ast_varia
ast_string_field *field = (const char **)(obj + opt->args[0]);
struct ast_string_field_pool **pool = (struct ast_string_field_pool **)(obj + opt->args[1]);
struct ast_string_field_mgr *mgr = (struct ast_string_field_mgr *)(obj + opt->args[2]);
if (opt->flags && ast_strlen_zero(var->value)) {
return -1;
}
ast_string_field_ptr_set_by_fields(*pool, *mgr, field, var->value);
return 0;
}
@@ -1384,7 +1388,7 @@ static int sockaddr_handler_fn(const struct aco_option *opt, struct ast_variable
return ast_parse_arg(var->value, PARSE_ADDR | opt->flags, field);
}
/*! \brief Default handler for doing noithing
/*! \brief Default handler for doing nothing
*/
static int noop_handler_fn(const struct aco_option *opt, struct ast_variable *var, void *obj)
{
@@ -1400,6 +1404,9 @@ static int chararray_handler_fn(const struct aco_option *opt, struct ast_variabl
char *field = (char *)(obj + opt->args[0]);
size_t len = opt->args[1];
if (opt->flags && ast_strlen_zero(var->value)) {
return -1;
}
ast_copy_string(field, var->value, len);
return 0;
}