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