2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
10 #ifndef AROS_NO_LIMITS_H
13 # define LONG_MAX 2147483647L
14 # define LONG_MIN (-LONG_MAX - 1L)
17 /*****************************************************************************
30 Convert a string of digits into an integer according to the
34 str - The string which should be converted. Leading
35 whitespace are ignored. The number may be prefixed
36 by a '+' or '-'. If base is above 10, then the
37 alphabetic characters from 'A' are used to specify
38 digits above 9 (ie. 'A' or 'a' is 10, 'B' or 'b' is
39 11 and so on until 'Z' or 'z' is 35).
40 endptr - If this is non-NULL, then the address of the first
41 character after the number in the string is stored
43 base - The base for the number. May be 0 or between 2 and 36,
44 including both. 0 means to autodetect the base. strtoul()
45 selects the base by inspecting the first characters
46 of the string. If they are "0x", then base 16 is
47 assumed. If they are "0", then base 8 is assumed. Any
48 other digit will assume base 10. This is like in C.
50 If you give base 16, then an optional "0x" may
51 precede the number in the string.
54 The value of the string. The first character after the number
55 is returned in *endptr, if endptr is non-NULL. If no digits can
56 be converted, *endptr contains str (if non-NULL) and 0 is
62 // returns 1, ptr points to the 0-Byte
63 strol (" \t +0x1", &ptr, 0);
65 // Returns 15. ptr points to the a
66 strol ("017a", &ptr, 0);
68 // Returns 215 (5*36 + 35)
69 strol ("5z", &ptr, 36);
74 atof(), atoi(), atol(), strtod(), strtoul()
78 ******************************************************************************/
84 while (isspace (*str
))
91 val
= strtoul (str
, &ptr
, base
);
101 /* Remember: strtoul() has already done the sign conversion */
104 if ((signed long)val
> 0)
114 if ((signed long)val
< 0)
125 *endptr
= (char *)str
;