1 .\" $NetBSD: strsuftoll.3,v 1.11 2010/12/14 13:00:34 jruoho Exp $
3 .\" Copyright (c) 2002,2007 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
36 .Nd "convert a string to a long long, with suffix parsing"
42 .Fn strsuftoll "const char *desc" "const char *val" "long long min" "long long max"
44 .Fn strsuftollx "const char *desc" "const char *val" "long long min" "long long max" "char *errbuf" "size_t errbuflen"
54 checking that the result is not smaller than
58 Two or more decimal numbers may be separated by an
60 to indicate a product.
62 Each decimal number may have one of the following optional suffixes:
64 .Bl -tag -width 3n -offset indent -compact
66 Block; multiply by 512
68 Kibi; multiply by 1024 (1 KiB)
70 Mebi; multiply by 1048576 (1 MiB)
72 Gibi; multiply by 1073741824 (1 GiB)
74 Tebi; multiply by 1099511627776 (1 TiB)
76 Word; multiply by the number of bytes in an integer
79 In the case of an error (range overflow or an invalid number),
81 places an error message into
85 bytes long) and returns 0,
88 displays that error and terminates the process.
105 return either the result of the conversion,
106 unless the value overflows or is not a number;
109 displays an error message and terminates the process with exit code
115 contains a non-empty error message.
119 The given string was out of range; the value converted has been clamped.
126 At least few limitations should be mentioned:
129 Both functions ignore the current locale.
135 fail gracefully in case of invalid,
139 Arguably the return type should be
146 function is prone to buffer overflows if used incorrectly.
149 should be exposed to a caller.