[OpenSER-Devel] SF.net SVN: openser: [2662] trunk/modules

Dan Pascu dan at ag-projects.com
Mon Sep 3 10:48:56 CEST 2007


On Wednesday 29 August 2007, Henning Westerholt wrote:
> Log Message:
> -----------
> - remove another str2int fixup implementation in lcr, mediaproxy and
> dispatcher - use the one from mod_fix.h

Henning,

I think that the way these helper functions were separated is not the best 
approach, because the test for the param_no shouldn't be done by the 
generic helper function. Else you will have to write helper functions for 
every parameter combination out there, or people will start implementing 
their own versions of these again. For example if you consider only 
functions with integer arguments, you will have to write 3 helpers for 
str2int alone.

IMO the helper functions should simply convert from one type to another 
and leave the test for the param_no to be done by a wrapper in the 
module. The module is the only one that knows which argument is of which 
type and how should it be converted.

What I have in mind is something like this (as a wrapper in a module):

fix_arguments(void **param, int param_no)
{
    if (param_no == 1) {
        fixup_str2int(param);
    } else if (param_no == 2) {
        something_other_conversion(param);
    }
}

and the fixup_str2int should do the conversion without any check on the 
param_no argument.

-- 
Dan



More information about the Devel mailing list