[OpenSER-Devel] Request for comment: module interface extension

Henning Westerholt henning.westerholt at 1und1.de
Mon Dec 17 14:01:43 UTC 2007


On Monday 17 December 2007, Dan Pascu wrote:
> > So for now i suggest only to change the module functions export to:
> >
> > typedef int (*cmd_function)(struct sip_msg*, int count, char **params);
>
> I do not like this model too much. All arguments are hidden inside an
> array, from where the function must take and assign them to variables.
> No clear function prototype can be defined by this model and calling
> functions exported by other modules will become complex and awkward.

Hi Dan, 

well, sure there is some sort of information hiding in this array. But to 
define more prototypes like this:

typedef int (*cmd_function)(struct sip_msg*, char *param1, char* param2, ... 
char* paramN);

is also not optimal. Here happens also some sort of information hiding, the 
actually used variables vs. the boilerplate code.. And the current interface 
with char* that gets casted around to fit to arbitrary variables is also not 
really clean..

In regards to the second point you've raised, the intermodule function calls:

Modules that holds functions that needs to be used from outside should export 
a clean API struct with a 'bind' function, like the tm or auth modules, in my 
opinion. No modules should call functions that are only exported via the 
config script. This is not type safe at all. And the module functions 
exported with this type of API don't need to adhere to the interface of the 
config script.

Thank you and regards,

Henning



More information about the Devel mailing list