Reactos
at listview 107 lines 3.6 kB view raw
1// 2// atox.cpp 3// 4// Copyright (c) Microsoft Corporation. All rights reserved. 5// 6// The "simple" string conversion functions: atoi, atol, atoll, and their wide 7// string functions. 8// 9#define _ALLOW_OLD_VALIDATE_MACROS 10#include <corecrt_internal_strtox.h> 11#include <stdlib.h> 12 13 14 15//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 16// 17// Narrow Strings => Various Integers (Simple Functions, wtox) 18// 19//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 20extern "C" int __cdecl atoi(char const* const string) 21{ 22 // Note: We parse as a long to avoid an extra specialization of parse_integer_from_string 23 return __crt_strtox::parse_integer_from_string<long>(string, nullptr, 10, nullptr); 24} 25 26extern "C" int __cdecl _atoi_l(char const* const string, _locale_t const locale) 27{ 28 return __crt_strtox::parse_integer_from_string<long>(string, nullptr, 10, locale); 29} 30 31extern "C" long __cdecl atol(char const* const string) 32{ 33 return __crt_strtox::parse_integer_from_string<long>(string, nullptr, 10, nullptr); 34} 35 36extern "C" long __cdecl _atol_l(char const* const string, _locale_t const locale) 37{ 38 return __crt_strtox::parse_integer_from_string<long>(string, nullptr, 10, locale); 39} 40 41extern "C" long long __cdecl atoll(char const* const string) 42{ 43 return __crt_strtox::parse_integer_from_string<long long>(string, nullptr, 10, nullptr); 44} 45 46extern "C" long long __cdecl _atoll_l(char const* const string, _locale_t const locale) 47{ 48 return __crt_strtox::parse_integer_from_string<long long>(string, nullptr, 10, locale); 49} 50 51extern "C" __int64 __cdecl _atoi64(char const* const string) 52{ 53 return __crt_strtox::parse_integer_from_string<__int64>(string, nullptr, 10, nullptr); 54} 55 56extern "C" __int64 __cdecl _atoi64_l(char const* const string, _locale_t const locale) 57{ 58 return __crt_strtox::parse_integer_from_string<__int64>(string, nullptr, 10, locale); 59} 60 61 62 63//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 64// 65// Wide Strings => Various Integers (Simple Functions, wtox) 66// 67//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 68extern "C" int __cdecl _wtoi(wchar_t const* const string) 69{ 70 // Note: We parse as a long to avoid an extra specialization of parse_integer_from_string 71 return __crt_strtox::parse_integer_from_string<long>(string, nullptr, 10, nullptr); 72} 73 74extern "C" int __cdecl _wtoi_l(wchar_t const* const string, _locale_t const locale) 75{ 76 return __crt_strtox::parse_integer_from_string<long>(string, nullptr, 10, locale); 77} 78 79extern "C" long __cdecl _wtol(wchar_t const* const string) 80{ 81 return __crt_strtox::parse_integer_from_string<long>(string, nullptr, 10, nullptr); 82} 83 84extern "C" long __cdecl _wtol_l(wchar_t const* const string, _locale_t const locale) 85{ 86 return __crt_strtox::parse_integer_from_string<long>(string, nullptr, 10, locale); 87} 88 89extern "C" long long __cdecl _wtoll(wchar_t const* const string) 90{ 91 return __crt_strtox::parse_integer_from_string<long long>(string, nullptr, 10, nullptr); 92} 93 94extern "C" long long __cdecl _wtoll_l(wchar_t const* const string, _locale_t const locale) 95{ 96 return __crt_strtox::parse_integer_from_string<long long>(string, nullptr, 10, locale); 97} 98 99extern "C" __int64 __cdecl _wtoi64(wchar_t const* const string) 100{ 101 return __crt_strtox::parse_integer_from_string<__int64>(string, nullptr, 10, nullptr); 102} 103 104extern "C" __int64 __cdecl _wtoi64_l(wchar_t const* const string, _locale_t const locale) 105{ 106 return __crt_strtox::parse_integer_from_string<__int64>(string, nullptr, 10, locale); 107}