1 /*
2 Copyright (c) 1990 Regents of the University of California.
3 All rights reserved.
4 */
5 /*
6 FUNCTION
7 <<atoi>>, <<atol>>---string to integer
8
9 INDEX
10 atoi
11 INDEX
12 atol
13 INDEX
14 _atoi_r
15 INDEX
16 _atol_r
17
18 SYNOPSIS
19 #include <stdlib.h>
20 int atoi(const char *<[s]>);
21 long atol(const char *<[s]>);
22 int _atoi_r(struct _reent *<[ptr]>, const char *<[s]>);
23 long _atol_r(struct _reent *<[ptr]>, const char *<[s]>);
24
25 DESCRIPTION
26 <<atoi>> converts the initial portion of a string to an <<int>>.
27 <<atol>> converts the initial portion of a string to a <<long>>.
28
29 <<atoi(s)>> is implemented as <<(int)strtol(s, NULL, 10).>>
30 <<atol(s)>> is implemented as <<strtol(s, NULL, 10).>>
31
32 <<_atoi_r>> and <<_atol_r>> are reentrant versions of <<atoi>> and
33 <<atol>> respectively, passing the reentrancy struct pointer.
34
35 RETURNS
36 The functions return the converted value, if any. If no conversion was
37 made, <<0>> is returned.
38
39 PORTABILITY
40 <<atoi>>, <<atol>> are ANSI.
41
42 No supporting OS subroutines are required.
43 */
44
45 /*
46 * Andy Wilson, 2-Oct-89.
47 */
48
49 #include <stdlib.h>
50 #include <_ansi.h>
51
52 #ifndef _REENT_ONLY
53 int
atoi(const char * s)54 atoi (const char *s)
55 {
56 return (int) strtol (s, NULL, 10);
57 }
58 #endif /* !_REENT_ONLY */
59