[OpenSIPS-Devel] Return codes and str initialization

Bogdan-Andrei Iancu bogdan at voice-system.ro
Fri Nov 14 09:56:16 CET 2008


Hello Sergio,


Sergio Gutierrez wrote:
> Hello to all members.
>
> I have a couple questions about handling to things within OpenSIPS 
> modules.
>
> * What is the right way to initialize/assing the len field of a str 
> struct? When checking code, I have seen that in some places it is 
> initialized with strlen of s field, in others with strlen+1, and in 
> others strlen-1.
.len must contain exactly the length (to be used) of the .s string. So 
depends of what is the source of the string :).
> Besides, what is the recommended way to initialize at declaration a 
> str struct: Direct assignation, or using the STR_INIT macro?
if you want to init str with a static string, use STR_INIT macro as it 
is better (you do not have to manually compute the len part).
>
> * What is the right code for non error conditions in module functions? 
> Should it be zero or nonzero value?
in the internal code, 0 means success and negative vals error; for 
module functions (functions directly triggered from script), negative 
vales means error, 0 means stop the script and positive vals means success

Best regards,
bogdan
>
> Thanks in advancefor your attention, and I apologize for the "newbie" 
> question.
>
> Best regards.
>
> -- 
> Sergio Gutiérrez
> ------------------------------------------------------------------------
>
> _______________________________________________
> Devel mailing list
> Devel at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/devel
>   




More information about the Devel mailing list