On 2/8/10 11:48 PM, Iñaki Baz Castillo wrote:
El Lunes, 8 de Febrero de 2010, Daniel-Constantin
Mierla escribió:
Ok:
-------------
16.9.1. Return Values
Returning values from the command functions have a special meaning in the
configuration file. The command functions return an integer value, and the
config file interpreter use it as follows:
- if<0 - evaluation of the return code is FALSE
- if 0 - the interpreter stop executing the configuration file
- if>0 - evaluation of the return code is TRUE
-------------
So what about if I want to develop a module function which can return 0 as a
valid integer
You can do that ...
and store it in a pv?
but it won't get here!
(i.e. a function returning the number of
locations for a given AoR).
Return the value in a PV or make the function a new PV. All functions
needing such behavior used this approach so far (see group, dispatcher,
etc ...).
Returning 0 from a function (core or module) is 'exit' from the
beginning of SER in 2001, it is how tm functions absorb retransmissions
and the config is not executed further (e.g., t_check_trans(),
t_newtran(), ...).
It seems that allow_source_address_group() behaves as
"return(0)" when
the returned value is 0. But this is not documented and IMHO it cannot be
the expected behavior, am I right?
You mean 'return 0' is not documented or this particular
function's
behavior with group id 0?
"return 0" is document (AFAIK) but I didn't expect that any
function returning
0 means "exiting".
It means. 'return' is a core function.
Also, in the current module (permissions) and current
function
(allow_source_address_group) this is a limitation
not a feature :-) ?!? Do you want
to have if's around each functions to
see if it is the case to exit the script?
Moreover cfg functions do not follow usual C/other languages patterns
where 0 is false and !=0 (negative or positive) is true.
Cheers,
Daniel
as it doesn't allow
returning a group value 0.
--
Daniel-Constantin Mierla
eLearning class for Kamailio 3.0.0
*
http://www.asipto.com/