2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 ANSI C function strtoll().
8 /* This requires the C99 type long long. */
10 #include <aros/system.h>
11 #if defined(AROS_HAVE_LONG_LONG)
15 #ifndef AROS_NO_LIMITS_H
18 # define LLONG_MAX 0x7fffffffffffffffLL
19 # define LLONG_MIN (-0x7fffffffffffffffLL - 1)
22 /*****************************************************************************
30 const char * restrict str
,
31 char ** restrict endptr
,
35 Convert a string of digits into an integer according to the
39 str - The string which should be converted. Leading
40 whitespace are ignored. The number may be prefixed
41 by a '+' or '-'. If base is above 10, then the
42 alphabetic characters from 'A' are used to specify
43 digits above 9 (ie. 'A' or 'a' is 10, 'B' or 'b' is
44 11 and so on until 'Z' or 'z' is 35).
45 endptr - If this is non-NULL, then the address of the first
46 character after the number in the string is stored
48 base - The base for the number. May be 0 or between 2 and 36,
49 including both. 0 means to autodetect the base. strtoul()
50 selects the base by inspecting the first characters
51 of the string. If they are "0x", then base 16 is
52 assumed. If they are "0", then base 8 is assumed. Any
53 other digit will assume base 10. This is like in C.
55 If you give base 16, then an optional "0x" may
56 precede the number in the string.
59 The value of the string. The first character after the number
60 is returned in *endptr, if endptr is non-NULL. If no digits can
61 be converted, *endptr contains str (if non-NULL) and 0 is
67 // returns 1, ptr points to the 0-Byte
68 strtoll (" \t +0x1", &ptr, 0);
70 // Returns 15. ptr points to the a
71 strtoll ("017a", &ptr, 0);
73 // Returns 215 (5*36 + 35)
74 strtoll ("5z", &ptr, 36);
83 ******************************************************************************/
89 while (isspace (*str
))
96 val
= strtoull (str
, &ptr
, base
);
106 /* Remember: strtoull() has already done the sign conversion */
109 if ((signed long long)val
> 0)
117 if ((signed long long)val
< 0)
126 *endptr
= (char *)str
;
131 #endif /* AROS_HAVE_LONG_LONG */