File indexing completed on 2025-05-11 08:24:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #ifdef HAVE_CONFIG_H
0021 #include "config.h"
0022 #endif
0023
0024 #include <errno.h>
0025 #include <stdlib.h>
0026 #include <limits.h>
0027
0028 #include <rtems/stringto.h>
0029
0030
0031 #ifndef LONG_LONG_MAX
0032 #define LONG_LONG_MAX LLONG_MAX
0033 #endif
0034
0035 #ifndef LONG_LONG_MIN
0036 #define LONG_LONG_MIN LLONG_MIN
0037 #endif
0038
0039
0040
0041
0042
0043 rtems_status_code rtems_string_to_long_long (
0044 const char *s,
0045 long long *n,
0046 char **endptr,
0047 int base
0048 )
0049 {
0050 long long result;
0051 char *end;
0052
0053 if ( !n )
0054 return RTEMS_INVALID_ADDRESS;
0055
0056 errno = 0;
0057 *n = 0;
0058
0059 result = strtoll( s, &end, base );
0060
0061 if ( endptr )
0062 *endptr = end;
0063
0064 if ( end == s )
0065 return RTEMS_NOT_DEFINED;
0066
0067 if ( ( errno == ERANGE ) &&
0068 (( result == 0 ) || ( result == LONG_LONG_MAX ) || ( result == LONG_LONG_MIN )))
0069 return RTEMS_INVALID_NUMBER;
0070
0071 *n = result;
0072
0073 return RTEMS_SUCCESSFUL;
0074 }