1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup libmisc_conv_help Conversion Helpers |
---|
5 | * |
---|
6 | * @brief Convert String to Pointer (with validation) |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * COPYRIGHT (c) 2009. |
---|
11 | * On-Line Applications Research Corporation (OAR). |
---|
12 | * |
---|
13 | * Copyright (c) 2011 Ralf Corsépius, Ulm, Germany. |
---|
14 | * |
---|
15 | * The license and distribution terms for this file may be |
---|
16 | * found in the file LICENSE in this distribution or at |
---|
17 | * http://www.rtems.org/license/LICENSE. |
---|
18 | */ |
---|
19 | |
---|
20 | #ifdef HAVE_CONFIG_H |
---|
21 | #include "config.h" |
---|
22 | #endif |
---|
23 | |
---|
24 | #include <errno.h> |
---|
25 | #include <stdlib.h> |
---|
26 | #include <limits.h> |
---|
27 | #include <stdint.h> |
---|
28 | |
---|
29 | #include <rtems/stringto.h> |
---|
30 | |
---|
31 | /* |
---|
32 | * Instantiate an error checking wrapper for strtoul/strtoull (void *) |
---|
33 | */ |
---|
34 | |
---|
35 | #if (UINTPTR_MAX == ULONG_MAX) |
---|
36 | #define STRTOFUNC(a,b,c) rtems_string_to_unsigned_long(a, (unsigned long*) b, c, 0) |
---|
37 | #elif (UINTPTR_MAX == ULONG_LONG_MAX) |
---|
38 | #define STRTOFUNC(a,b,c) rtems_string_to_unsigned_long_long(a, (unsigned long long*) b, c, 0) |
---|
39 | #elif (UINTPTR_MAX == UINT_MAX) |
---|
40 | #define STRTOFUNC(a,b,c) rtems_string_to_unsigned_int(a, (unsigned int*) b, c, 0) |
---|
41 | #else |
---|
42 | /* Fallback to unsigned long */ |
---|
43 | #define STRTOFUNC(a,b,c) rtems_string_to_unsigned_long(a, (unsigned long*) b, c, 0) |
---|
44 | #endif |
---|
45 | |
---|
46 | rtems_status_code rtems_string_to_pointer ( |
---|
47 | const char *s, |
---|
48 | void **n, |
---|
49 | char **endptr |
---|
50 | ) |
---|
51 | { |
---|
52 | return STRTOFUNC( s, n, endptr ); |
---|
53 | } |
---|