]>
Commit | Line | Data |
---|---|---|
44e6186e AB |
1 | #/* @file\r |
2 | # Copyright (c) 2018, Linaro Limited. All rights reserved.\r | |
3 | #\r | |
4 | # This program and the accompanying materials\r | |
5 | # are licensed and made available under the terms and conditions of the BSD License\r | |
6 | # which accompanies this distribution. The full text of the license may be found at\r | |
7 | # http://opensource.org/licenses/bsd-license.php\r | |
8 | #\r | |
9 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | #\r | |
12 | #*/\r | |
13 | \r | |
14 | #include <Base.h>\r | |
15 | #include <Library/BaseLib.h>\r | |
16 | #include <Library/DebugLib.h>\r | |
17 | \r | |
18 | unsigned long strtoul(const char *nptr, char **endptr, int base)\r | |
19 | {\r | |
20 | RETURN_STATUS Status;\r | |
21 | UINTN ReturnValue;\r | |
22 | \r | |
23 | ASSERT (base == 10 || base == 16);\r | |
24 | \r | |
25 | if (base == 10) {\r | |
26 | Status = AsciiStrDecimalToUintnS (nptr, endptr, &ReturnValue);\r | |
27 | } else if (base == 16) {\r | |
28 | Status = AsciiStrHexToUintnS (nptr, endptr, &ReturnValue);\r | |
29 | } else {\r | |
30 | Status = RETURN_INVALID_PARAMETER;\r | |
31 | }\r | |
32 | \r | |
33 | if (RETURN_ERROR (Status)) {\r | |
34 | return MAX_UINTN;\r | |
35 | }\r | |
36 | \r | |
37 | return ReturnValue;\r | |
38 | }\r |