00001
00007 #include "stdlib.h"
00008
00009
00010
00011 int dkcstd_atoi(const char *p)
00012 {
00013 int r = 0;
00014 for(;*p;p++)
00015 {
00016
00017 r = r * 10 + *p - 0x30;
00018 }
00019 return r;
00020 }
00027 int dkcstd_atox(const char *p)
00028 {
00029 int r = 0;
00030
00031 for(;*p;p++)
00032 {
00033 if('0' <= *p && *p <= '9'){
00034 r = r * 16 + *p - '0';
00035 }else if('A' <= *p && *p <= 'F'){
00036 r = r * 16 + *p - 'A' + 10;
00037 }else if('a' <= *p && *p <= 'f'){
00038 r = r * 16 + *p - 'a' + 10;
00039 }
00040 }
00041 return r;
00042 }