]> git.saurik.com Git - apple/libc.git/blame - stdlib/FreeBSD/atol.3
Libc-1244.50.9.tar.gz
[apple/libc.git] / stdlib / FreeBSD / atol.3
CommitLineData
5b2abdfb 1.\" Copyright (c) 1990, 1991, 1993
e9ce8d39
A
2.\" The Regents of the University of California. All rights reserved.
3.\"
5b2abdfb
A
4.\" This code is derived from software contributed to Berkeley by
5.\" the American National Standards Committee X3, on Information
6.\" Processing Systems.
7.\"
e9ce8d39
A
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
e9ce8d39
A
16.\" 4. Neither the name of the University nor the names of its contributors
17.\" may be used to endorse or promote products derived from this software
18.\" without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
5b2abdfb 32.\" @(#)atol.3 8.1 (Berkeley) 6/4/93
1f2f436a 33.\" $FreeBSD: src/lib/libc/stdlib/atol.3,v 1.16 2009/03/01 05:44:28 delphij Exp $
e9ce8d39 34.\"
1f2f436a 35.Dd February 1, 2009
5b2abdfb 36.Dt ATOL 3
e9ce8d39
A
37.Os
38.Sh NAME
ad3c9f2a
A
39.Nm atol , atoll ,
40.Nm atol_l , atoll_l
5b2abdfb
A
41.Nd convert
42.Tn ASCII
9385eb3d
A
43string to
44.Vt long
45or
46.Vt "long long"
47integer
e9ce8d39
A
48.Sh LIBRARY
49.Lb libc
50.Sh SYNOPSIS
5b2abdfb
A
51.In stdlib.h
52.Ft long
ad3c9f2a 53.Fn atol "const char *str"
9385eb3d 54.Ft "long long"
ad3c9f2a
A
55.Fn atoll "const char *str"
56.In xlocale.h
57.Ft long
58.Fn atol_l "const char *str" "locale_t loc"
59.Ft "long long"
60.Fn atoll_l "const char *str" "locale_t loc"
e9ce8d39
A
61.Sh DESCRIPTION
62The
5b2abdfb
A
63.Fn atol
64function converts the initial portion of the string pointed to by
ad3c9f2a 65.Fa str
5b2abdfb 66to
9385eb3d
A
67.Vt long
68integer
5b2abdfb
A
69representation.
70.Pp
71It is equivalent to:
9385eb3d 72.Pp
ad3c9f2a 73.Dl "strtol(str, (char **)NULL, 10);"
9385eb3d
A
74.Pp
75The
76.Fn atoll
77function converts the initial portion of the string pointed to by
ad3c9f2a 78.Fa str
9385eb3d
A
79to
80.Vt "long long"
81integer
82representation.
83.Pp
84It is equivalent to:
85.Pp
ad3c9f2a
A
86.Dl "strtoll(str, (char **)NULL, 10);"
87.Pp
88While the
89.Fn atol
90and
91.Fn atoll
92functions use the current locale, the
93.Fn atol_l
94and
95.Fn atoll_l
96functions may be passed locales directly. See
97.Xr xlocale 3
98for more information.
99.Sh IMPLEMENTATION NOTES
100The
101.Fn atol ,
102.Fn atoll ,
103.Fn atol_l ,
104and
105.Fn atoll_l
106functions are thread-safe and async-cancel-safe.
107.Pp
1f2f436a
A
108The
109.Fx
110implementations of the
111.Fn atol
112and
113.Fn atoll
114functions are thin wrappers around
115.Fn strtol
116and
117.Fn stroll
118respectively, so these functions will affect the value of
119.Va errno
120in the same way that the
121.Fn strtol
122and
123.Fn stroll
124functions are able to.
125This behavior of
126.Fn atol
127and
128.Fn atoll
129is not required by
130.St -isoC
131or
132.St -isoC-99 ,
133but it is allowed by all of
134.St -isoC , St -isoC-99
135and
136.St -p1003.1-2001 .
9385eb3d
A
137.Sh ERRORS
138The functions
139.Fn atol
140and
141.Fn atoll
1f2f436a 142may affect the value of
9385eb3d
A
143.Va errno
144on an error.
e9ce8d39 145.Sh SEE ALSO
5b2abdfb
A
146.Xr atof 3 ,
147.Xr atoi 3 ,
148.Xr strtod 3 ,
149.Xr strtol 3 ,
ad3c9f2a
A
150.Xr strtoul 3 ,
151.Xr xlocale 3
5b2abdfb 152.Sh STANDARDS
e9ce8d39 153The
5b2abdfb
A
154.Fn atol
155function
156conforms to
157.St -isoC .
9385eb3d
A
158The
159.Fn atoll
160function
161conforms to
162.St -isoC-99 .