2007-09-01 06:19:11 +00:00
|
|
|
.\" Copyright (c) 2007 Eric Anderson <anderson@FreeBSD.org>
|
|
|
|
.\" Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org>
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
2019-07-20 16:03:54 +00:00
|
|
|
.Dd July 20, 2019
|
2007-09-01 06:19:11 +00:00
|
|
|
.Dt EXPAND_NUMBER 3
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm expand_number
|
|
|
|
.Nd format a number from human readable form
|
|
|
|
.Sh LIBRARY
|
|
|
|
.Lb libutil
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
.In libutil.h
|
|
|
|
.Ft int
|
|
|
|
.Fo expand_number
|
2010-08-15 18:32:06 +00:00
|
|
|
.Fa "const char *buf" "uint64_t *num"
|
2007-09-01 06:19:11 +00:00
|
|
|
.Fc
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Fn expand_number
|
2019-07-20 16:03:54 +00:00
|
|
|
function parses the
|
2007-09-01 06:19:11 +00:00
|
|
|
.Fa buf
|
2019-07-20 16:03:54 +00:00
|
|
|
string and stores a unsigned 64-bit quantity at
|
|
|
|
.Fa *num .
|
2007-09-01 06:19:11 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn expand_number
|
|
|
|
function
|
2013-11-12 00:56:22 +00:00
|
|
|
is case-insensitive and
|
2007-09-01 06:19:11 +00:00
|
|
|
follows the SI power of two convention.
|
|
|
|
.Pp
|
2019-07-20 16:03:54 +00:00
|
|
|
The suffixes are:
|
|
|
|
.Bl -column "Suffix" "Description" "1000000000000000000" -offset indent
|
|
|
|
.It Sy "Suffix" Ta Sy "Description" Ta Sy "Multiplier"
|
2013-11-12 00:56:22 +00:00
|
|
|
.It Li K Ta No kilo Ta 1024
|
2007-09-01 06:19:11 +00:00
|
|
|
.It Li M Ta No mega Ta 1048576
|
|
|
|
.It Li G Ta No giga Ta 1073741824
|
|
|
|
.It Li T Ta No tera Ta 1099511627776
|
|
|
|
.It Li P Ta No peta Ta 1125899906842624
|
|
|
|
.It Li E Ta No exa Ta 1152921504606846976
|
|
|
|
.El
|
|
|
|
.Sh RETURN VALUES
|
|
|
|
.Rv -std
|
|
|
|
.Sh ERRORS
|
|
|
|
The
|
|
|
|
.Fn expand_number
|
|
|
|
function will fail if:
|
|
|
|
.Bl -tag -width Er
|
|
|
|
.It Bq Er EINVAL
|
|
|
|
The given string contains no digits.
|
|
|
|
.It Bq Er EINVAL
|
2019-07-20 16:03:54 +00:00
|
|
|
An unrecognized suffix was given.
|
2007-09-01 06:19:11 +00:00
|
|
|
.It Bq Er ERANGE
|
|
|
|
Result doesn't fit into 64 bits.
|
|
|
|
.El
|
2007-09-05 14:25:16 +00:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr humanize_number 3
|
2007-09-01 06:19:11 +00:00
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
.Fn expand_number
|
|
|
|
function first appeared in
|
2007-09-28 15:31:44 +00:00
|
|
|
.Fx 6.3 .
|