diff --git a/common/os_calls.c b/common/os_calls.c index e13ca334..0dd0067a 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -1082,6 +1082,84 @@ g_atoi(char* str) return atoi(str); } +/*****************************************************************************/ +int APP_CC +g_htoi(char* str) +{ + int len; + int index; + int rv; + int val; + int shift; + + rv = 0; + len = strlen(str); + index = len - 1; + shift = 0; + while (index >= 0) + { + val = 0; + switch (str[index]) + { + case '1': + val = 1; + break; + case '2': + val = 2; + break; + case '3': + val = 3; + break; + case '4': + val = 4; + break; + case '5': + val = 5; + break; + case '6': + val = 6; + break; + case '7': + val = 7; + break; + case '8': + val = 8; + break; + case '9': + val = 9; + break; + case 'a': + case 'A': + val = 10; + break; + case 'b': + case 'B': + val = 11; + break; + case 'c': + case 'C': + val = 12; + break; + case 'd': + case 'D': + val = 13; + break; + case 'e': + case 'E': + val = 14; + break; + case 'f': + case 'F': + val = 15; + break; + } + rv = rv | (val << shift); + index--; + shift += 4; + } + return rv; +} + /*****************************************************************************/ int APP_CC g_pos(char* str, const char* to_find) diff --git a/common/os_calls.h b/common/os_calls.h index 80f8cff1..d86776ad 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -154,6 +154,8 @@ g_strncasecmp(const char* c1, const char* c2, int len); int APP_CC g_atoi(char* str); int APP_CC +g_htoi(char* str); +int APP_CC g_pos(char* str, const char* to_find); int APP_CC g_mbstowcs(twchar* dest, const char* src, int n);