[asterisk-dev] [Code Review] 4313: func_config: Add ability to retrieve specific occurrence of a variable

Joshua Colp reviewboard at asterisk.org
Wed Jan 7 09:09:10 CST 2015


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/4313/#review14103
-----------------------------------------------------------



branches/13/funcs/func_config.c
<https://reviewboard.asterisk.org/r/4313/#comment24605>

    This should return a -1. If I'm specifying an index of some sort I'm expecting specific behavior. If you continue then, while it may return a value, it could be unexpected.



branches/13/funcs/func_config.c
<https://reviewboard.asterisk.org/r/4313/#comment24606>

    Instead of having all the logic in an if just do:
    
    if (strcasecmp(args.variable, var->name)) {
    continue;
    }
    
    It's less indentation.



branches/13/funcs/func_config.c
<https://reviewboard.asterisk.org/r/4313/#comment24607>

    This debug message should be extended to include the index. It may even be useful to show the highest index it got to.


- Joshua Colp


On Jan. 2, 2015, 6:39 p.m., George Joseph wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/4313/
> -----------------------------------------------------------
> 
> (Updated Jan. 2, 2015, 6:39 p.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Repository: Asterisk
> 
> 
> Description
> -------
> 
> I guess nobody uses templates with AST_CONFIG because today if you have a context that inherits from a template and you call AST_CONFIG on the context, you'll get the value from the template even if you've overridden it in the context.  This is because AST_CONFIG only gets the first occurrence which is always from the template.
> 
> This patch adds an optional 'index' parameter to AST_CONFIG which lets you specify the exact occurrence to retrieve, or '-1' to retrieve the last.  The default behavior is the current behavior.
> 
> From the new help...
> 
> [Syntax]
> AST_CONFIG(config_file,category,variable_name[,index])
> 
> [Arguments]
> index
>     If there are multiple variables with the same name, you can specify
>     '0' for the first item (default), '-1' for the last item, or any other
>     number for that specific item.  '-1' is useful when the variable is derived
>     from a template and you want the effective value (the last occurrence),
>     not the value from the template (the first occurrence).
> 
> 
> Diffs
> -----
> 
>   branches/13/tests/test_config.c 430163 
>   branches/13/funcs/func_config.c 430163 
> 
> Diff: https://reviewboard.asterisk.org/r/4313/diff/
> 
> 
> Testing
> -------
> 
> Added a unit test to test_config which passes of course.
> 
> 
> Thanks,
> 
> George Joseph
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20150107/94fb91f2/attachment.html>


More information about the asterisk-dev mailing list