<div dir="ltr">Voila!<div><br></div><div>atoi was messing things:</div><div><div>Jul 11 13:29:14 plat1 /sbin/opensips[30500]: ERROR:<span style="font-size:12.8px">custom_check </span>:mi_custom_check: XXX value: '65'</div><div>Jul 11 13:29:14 plat1 /sbin/opensips[30500]: ERROR:<span style="font-size:12.8px">custom_check </span>:mi_custom_check: XXX value: '5000'</div><div>Jul 11 13:29:14 plat1 /sbin/opensips[30500]: ERROR:<span style="font-size:12.8px">custom_check </span>:mi_custom_check: XXX value: '100000'</div></div><div><br></div><div>I didn't consider the pointer may not have a null at the end, you're absolutely correct.</div><div><br></div><div>Thanks Liviu</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 11, 2016 at 5:46 AM, Liviu Chircu <span dir="ltr"><<a href="mailto:liviu@opensips.org" target="_blank">liviu@opensips.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<tt>Hi Daniel!<br>
<br>
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.<br>
<br>
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()?<br>
<br>
...<br>
LM_INFO("XXX value: '%.*s'\n", node->value.len,
node->value.s);</tt><tt><br>
...<br>
</tt>
<pre cols="72">Liviu Chircu
OpenSIPS Developer
<a href="http://www.opensips-solutions.com" target="_blank">http://www.opensips-solutions.com</a></pre><div><div class="h5">
<div>On 09.07.2016 23:26, Daniel Zanutti
wrote:<br>
</div>
</div></div><blockquote type="cite"><div><div class="h5">
<div dir="ltr"><span style="font-size:12.8px">I'm trying to read 3
integers parameters from MI, but Opensips is for some reason
combining 2 values.</span>
<div style="font-size:12.8px"><br>
</div>
<div style="font-size:12.8px">This is the command: opensipsctl
fifo custom_check 10 2000 50000</div>
<div style="font-size:12.8px"><br>
</div>
<div style="font-size:12.8px">For some reason, I'm getting these
values on the nodes:</div>
<div style="font-size:12.8px">val1 = 10</div>
<div style="font-size:12.8px">val2 = 200050000</div>
<div style="font-size:12.8px">val3 = 50000</div>
<div style="font-size:12.8px"><br>
</div>
<div style="font-size:12.8px">This is the summarized code:</div>
<div style="font-size:12.8px"><br>
</div>
<div style="font-size:12.8px">
<div>struct mi_root * custom_check(struct mi_root *cmd_tree,
void *param )</div>
<div>{</div>
<div><span style="white-space:pre-wrap">        </span>struct
mi_node* node;</div>
</div>
<div style="font-size:12.8px"> int val1, val2, val3;</div>
<div style="font-size:12.8px"><br>
</div>
<div style="font-size:12.8px">
<div><span style="white-space:pre-wrap">        </span>node =
cmd_tree->node.kids;</div>
<div><span style="white-space:pre-wrap">        </span>if
(!node->value.s || !node->value.len)</div>
<div><span style="white-space:pre-wrap">                </span>return
init_mi_tree( 400, MI_SSTR(MI_BAD_PARM));</div>
<div><span style="white-space:pre-wrap">        </span>val1 =
atoi(node->value.s);</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap">        </span>node =
node->next;</div>
<div><span style="white-space:pre-wrap">        </span>if (
!node->value.s || !node->value.len)</div>
<div><span style="white-space:pre-wrap">                </span>return
init_mi_tree( 400, MI_SSTR(MI_BAD_PARM));</div>
<div><span style="white-space:pre-wrap">        </span>val2 =
atoi(node->value.s);</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap">        </span>node =
node->next;</div>
<div><span style="white-space:pre-wrap">        </span>if (
!node->value.s || !node->value.len)</div>
<div><span style="white-space:pre-wrap">                </span>return
init_mi_tree( 400, MI_SSTR(MI_BAD_PARM));</div>
<div><span style="white-space:pre-wrap">        </span>val3 =
atoi(node->value.s);</div>
</div>
<div style="font-size:12.8px"> .....</div>
<div style="font-size:12.8px">}</div>
<div style="font-size:12.8px"><br>
</div>
<div style="font-size:12.8px">Am I doing something wrong? </div>
<div style="font-size:12.8px"><br>
</div>
<div style="font-size:12.8px">Thanks in advance</div>
</div>
<br>
<fieldset></fieldset>
<br>
</div></div><pre>_______________________________________________
Devel mailing list
<a href="mailto:Devel@lists.opensips.org" target="_blank">Devel@lists.opensips.org</a>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/devel" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/devel</a>
</pre>
</blockquote>
<br>
</div>
<br>_______________________________________________<br>
Devel mailing list<br>
<a href="mailto:Devel@lists.opensips.org">Devel@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/devel</a><br>
<br></blockquote></div><br></div>