]> git.proxmox.com Git - mirror_edk2.git/blame - EmbeddedPkg/Library/FdtLib/fdt_strtoul.c
EmbeddedPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / EmbeddedPkg / Library / FdtLib / fdt_strtoul.c
CommitLineData
44e6186e
AB
1#/* @file\r
2# Copyright (c) 2018, Linaro Limited. All rights reserved.\r
3#\r
878b807a 4# SPDX-License-Identifier: BSD-2-Clause-Patent\r
44e6186e
AB
5#\r
6#*/\r
7\r
8#include <Base.h>\r
9#include <Library/BaseLib.h>\r
10#include <Library/DebugLib.h>\r
11\r
12unsigned long strtoul(const char *nptr, char **endptr, int base)\r
13{\r
14 RETURN_STATUS Status;\r
15 UINTN ReturnValue;\r
16\r
17 ASSERT (base == 10 || base == 16);\r
18\r
19 if (base == 10) {\r
20 Status = AsciiStrDecimalToUintnS (nptr, endptr, &ReturnValue);\r
21 } else if (base == 16) {\r
22 Status = AsciiStrHexToUintnS (nptr, endptr, &ReturnValue);\r
23 } else {\r
24 Status = RETURN_INVALID_PARAMETER;\r
25 }\r
26\r
27 if (RETURN_ERROR (Status)) {\r
28 return MAX_UINTN;\r
29 }\r
30\r
31 return ReturnValue;\r
32}\r