Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
215 | victor | 1 | #include "stdio.h" |
2 | #include "stdlib.h" |
||
3 | #include "ctype.h" |
||
4 | |||
5 | /* |
||
6 | ** atoib(s,b) - Convert s to "unsigned" integer in base b. |
||
7 | ** NOTE: This is a non-standard function. |
||
8 | */ |
||
9 | int atoib(char *s,int b) |
||
10 | { |
||
11 | int n, digit; |
||
12 | n = 0; |
||
13 | while(isspace(*s)) ++s; |
||
14 | while((digit = (127 & *s++)) >= '0') { |
||
15 | if(digit >= 'a') digit -= 87; |
||
16 | else if(digit >= 'A') digit -= 55; |
||
17 | else digit -= '0'; |
||
18 | if(digit >= b) break; |
||
19 | n = b * n + digit; |
||
20 | } |
||
21 | return (n); |
||
22 | } |