[sr-dev] How to cast int val from db and cast to str?

Konstantin M. evilzluk at gmail.com
Tue Jan 29 20:32:07 CET 2013


Sorry, a small correction :)
tmp_id.len = 10;
tmp_id.s = (char *)pkg_malloc(tmp_id.len * sizeof(char));
snprintf(tmp_id.s, tmp_id.len, "%d", row->values[COL_ID].val.int_val);

2013/1/29 Konstantin M. <evilzluk at gmail.com>

> char buf[10];
> snprintf(buf, sizeof(buf), "%d", (char *)row->values[COL_ID].val.int_val);
>
> ?
>
> 2013/1/29 Mino Haluz <mino.haluz at gmail.com>
>
>> Hi,
>>
>> I'm changing carrierroute module so that it could set into another avp
>> the ID of the rule that was chosen. I have already adjusted all functions
>> but I have still one problem when kamailio starts.
>>
>> tmp_id.s=(char *)row->values[COL_ID].val.string_val;
>>
>> It gives Segfault at this line. The question is, how can I convert the
>> row value that is int(10) to char (tmp_id is const str *, it is the same as
>> comment). Thanks,
>>
>> Mino
>>
>> _______________________________________________
>> sr-dev mailing list
>> sr-dev at lists.sip-router.org
>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-dev/attachments/20130129/7044b8cc/attachment.htm>


More information about the sr-dev mailing list