[OpenSIPS-Devel] Weirs param parsing - MI

Liviu Chircu liviu at opensips.org
Mon Jul 11 10:46:56 CEST 2016


Hi Daniel!

The majority of OpenSIPS's codebase relies on "str"-based strings, which 
are basically both a memory and performance optimization, but they make 
programming/debugging more difficult, since most of them will not be 
NULL-terminated anymore, making you unable to use half (if not more) of 
glibc's string processing functions.

atoi() may very well be one of the above cases. In order to confirm 
this, could you print each of your 3 values before feeding it to atoi()?

...
LM_INFO("XXX value: '%.*s'\n", node->value.len, node->value.s);
...

Liviu Chircu
OpenSIPS Developer
http://www.opensips-solutions.com

On 09.07.2016 23:26, Daniel Zanutti wrote:
> I'm trying to read 3 integers parameters from MI, but Opensips is for 
> some reason combining 2 values.
>
> This is the command: opensipsctl fifo custom_check 10 2000 50000
>
> For some reason, I'm getting these values on the nodes:
> val1 = 10
> val2 = 200050000
> val3 = 50000
>
> This is the summarized code:
>
> struct mi_root * custom_check(struct mi_root *cmd_tree, void *param )
> {
> struct mi_node* node;
>         int val1, val2, val3;
>
> node = cmd_tree->node.kids;
> if (!node->value.s || !node->value.len)
> return init_mi_tree( 400, MI_SSTR(MI_BAD_PARM));
> val1 = atoi(node->value.s);
>
> node = node->next;
> if ( !node->value.s || !node->value.len)
> return init_mi_tree( 400, MI_SSTR(MI_BAD_PARM));
> val2 = atoi(node->value.s);
>
> node = node->next;
> if ( !node->value.s || !node->value.len)
> return init_mi_tree( 400, MI_SSTR(MI_BAD_PARM));
> val3 = atoi(node->value.s);
>         .....
> }
>
> Am I doing something wrong?
>
> Thanks in advance
>
>
> _______________________________________________
> Devel mailing list
> Devel at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/devel/attachments/20160711/4986dc61/attachment.htm>


More information about the Devel mailing list