FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
str_convfrom_uint.c
Go to the documentation of this file.
1
/* valuint function */
2
3
#include "
fb.h
"
4
5
FBCALL
unsigned
int
fb_hStr2UInt
(
char
*src, ssize_t len )
6
{
7
char
*
p
;
8
int
radix, skip;
9
10
/* skip white spc */
11
p =
fb_hStrSkipChar
( src, len, 32 );
12
13
len -= (ssize_t)(p - src);
14
if
( len < 1 )
15
return
0;
16
17
radix = 10;
18
if
( (len >= 2) && (p[0] ==
'&'
) )
19
{
20
skip = 2;
21
switch
( p[1] )
22
{
23
case
'h'
:
24
case
'H'
:
25
radix = 16;
26
break
;
27
case
'o'
:
28
case
'O'
:
29
radix = 8;
30
break
;
31
case
'b'
:
32
case
'B'
:
33
radix = 2;
34
break
;
35
36
default
:
/* assume octal */
37
radix = 8;
38
skip = 1;
39
break
;
40
}
41
42
if
( radix != 10 )
43
p += skip;
44
}
45
46
return
strtoul( p,
NULL
, radix );
47
}
48
49
FBCALL
unsigned
int
fb_VALUINT
(
FBSTRING
*str )
50
{
51
unsigned
int
val;
52
53
if
( str ==
NULL
)
54
return
0;
55
56
if
( (str->
data
==
NULL
) || (
FB_STRSIZE
( str ) == 0) )
57
val = 0;
58
else
59
val =
fb_hStr2UInt
( str->
data
,
FB_STRSIZE
( str ) );
60
61
/* del if temp */
62
fb_hStrDelTemp
( str );
63
64
return
val;
65
}
rtlib
str_convfrom_uint.c
Generated on Thu Jan 23 2014 19:40:12 for FreeBASIC by
1.8.4