MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / str2sint

Function str2sint

ut.h:767–796  ·  view source on GitHub ↗

* Convert a str into signed integer */

Source from the content-addressed store, hash-verified

765 * Convert a str into signed integer
766 */
767static inline int str2sint(const str* _s, int* _r)
768{
769 int i;
770 int s;
771
772 if (_s==0 || _s->s == 0 || _s->len == 0 || _r == 0)
773 return -1;
774
775 *_r = 0;
776 s = 1;
777 i=0;
778 if(_s->s[i]=='-') {
779 s=-1;
780 i++;
781 } else if (_s->s[i]=='+') {
782 i++;
783 }
784 for(; i < _s->len; i++) {
785 if ((_s->s[i] >= '0') && (_s->s[i] <= '9')) {
786 *_r *= 10;
787 *_r += _s->s[i] - '0';
788 } else {
789 //Preserve sign for partially converted strings
790 *_r *= s;
791 return -1;
792 }
793 }
794 *_r *= s;
795 return 0;
796}
797
798
799/*

Callers 15

tr_eval_stringFunction · 0.85
tr_eval_sdpFunction · 0.85
tr_parse_sdpFunction · 0.85
try_get_mi_int_paramFunction · 0.85
try_get_mi_arr_param_intFunction · 0.85
mi_xmlrpc_get_paramFunction · 0.85
tcp_store_pathFunction · 0.85
msg_call_functionFunction · 0.85
h350_call_preferencesFunction · 0.85
param_set_xvarFunction · 0.85
set_list_from_pvsFunction · 0.85
set_list_from_stringFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected