xref: /dflybsd-src/lib/libc/stdlib/a64l.3 (revision 98b3d9adc9c22415cb65dea171616322211baa7a)
15d0641a4SPeter Avalos.\" Copyright (c) 2005 Tom Rhodes
25d0641a4SPeter Avalos.\" All rights reserved.
35d0641a4SPeter Avalos.\"
45d0641a4SPeter Avalos.\" Redistribution and use in source and binary forms, with or without
55d0641a4SPeter Avalos.\" modification, are permitted provided that the following conditions
65d0641a4SPeter Avalos.\" are met:
75d0641a4SPeter Avalos.\" 1. Redistributions of source code must retain the above copyright
85d0641a4SPeter Avalos.\"    notice, this list of conditions and the following disclaimer.
95d0641a4SPeter Avalos.\" 2. Redistributions in binary form must reproduce the above copyright
105d0641a4SPeter Avalos.\"    notice, this list of conditions and the following disclaimer in the
115d0641a4SPeter Avalos.\"    documentation and/or other materials provided with the distribution.
125d0641a4SPeter Avalos.\"
135d0641a4SPeter Avalos.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
145d0641a4SPeter Avalos.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
155d0641a4SPeter Avalos.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
165d0641a4SPeter Avalos.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
175d0641a4SPeter Avalos.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
185d0641a4SPeter Avalos.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
195d0641a4SPeter Avalos.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
205d0641a4SPeter Avalos.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
215d0641a4SPeter Avalos.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
225d0641a4SPeter Avalos.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
235d0641a4SPeter Avalos.\" SUCH DAMAGE.
245d0641a4SPeter Avalos.\"
255d0641a4SPeter Avalos.\" Portions of this text are reprinted and reproduced in electronic form
265d0641a4SPeter Avalos.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --
275d0641a4SPeter Avalos.\" Portable Operating System Interface (POSIX), The Open Group Base
285d0641a4SPeter Avalos.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of
295d0641a4SPeter Avalos.\" Electrical and Electronics Engineers, Inc and The Open Group.  In the
305d0641a4SPeter Avalos.\" event of any discrepancy between this version and the original IEEE and
315d0641a4SPeter Avalos.\" The Open Group Standard, the original IEEE and The Open Group Standard is
325d0641a4SPeter Avalos.\" the referee document.  The original Standard can be obtained online at
335d0641a4SPeter Avalos.\"	http://www.opengroup.org/unix/online.html.
345d0641a4SPeter Avalos.\"
355d0641a4SPeter Avalos.\" $FreeBSD: src/lib/libc/stdlib/a64l.3,v 1.3 2006/09/30 10:29:43 ru Exp $
365d0641a4SPeter Avalos.\"
375d0641a4SPeter Avalos.Dd November 20, 2005
385d0641a4SPeter Avalos.Dt A64L 3
395d0641a4SPeter Avalos.Os
405d0641a4SPeter Avalos.Sh NAME
415d0641a4SPeter Avalos.Nm a64l ,
425d0641a4SPeter Avalos.Nm l64a ,
435d0641a4SPeter Avalos.Nm l64a_r
445d0641a4SPeter Avalos.Nd "convert between a long integer and a base-64 ASCII string"
455d0641a4SPeter Avalos.Sh LIBRARY
465d0641a4SPeter Avalos.Lb libc
475d0641a4SPeter Avalos.Sh SYNOPSIS
485d0641a4SPeter Avalos.In stdlib.h
495d0641a4SPeter Avalos.Ft long
505d0641a4SPeter Avalos.Fn a64l "const char *s"
515d0641a4SPeter Avalos.Ft char *
525d0641a4SPeter Avalos.Fn l64a "long int l"
535d0641a4SPeter Avalos.Ft int
545d0641a4SPeter Avalos.Fn l64a_r "long int l" "char *buffer" "int buflen"
555d0641a4SPeter Avalos.Sh DESCRIPTION
565d0641a4SPeter AvalosThese functions are used to maintain numbers stored in radix-64
575d0641a4SPeter Avalos.Tn ASCII
585d0641a4SPeter Avaloscharacters.
595d0641a4SPeter AvalosThis is a notation by which 32-bit integers can be represented by
605d0641a4SPeter Avalosup to six characters; each character represents a digit in
615d0641a4SPeter Avalosradix-64 notation.
625d0641a4SPeter AvalosIf the type long contains more than 32 bits, only the low-order
635d0641a4SPeter Avalos32 bits are used for these operations.
645d0641a4SPeter Avalos.Pp
655d0641a4SPeter AvalosThe characters used to represent
665d0641a4SPeter Avalos.Dq digits
675d0641a4SPeter Avalosare
685d0641a4SPeter Avalos.Ql .\&
695d0641a4SPeter Avalosfor 0,
705d0641a4SPeter Avalos.Ql /
715d0641a4SPeter Avalosfor 1,
725d0641a4SPeter Avalos.Ql 0
735d0641a4SPeter Avalos-
745d0641a4SPeter Avalos.Ql 9
755d0641a4SPeter Avalosfor 2 - 11,
765d0641a4SPeter Avalos.Ql A
775d0641a4SPeter Avalos-
785d0641a4SPeter Avalos.Ql Z
795d0641a4SPeter Avalosfor 12 - 37, and
805d0641a4SPeter Avalos.Ql a
815d0641a4SPeter Avalos-
825d0641a4SPeter Avalos.Ql z
835d0641a4SPeter Avalosfor 38 - 63.
845d0641a4SPeter Avalos.Pp
855d0641a4SPeter AvalosThe
865d0641a4SPeter Avalos.Fn a64l
875d0641a4SPeter Avalosfunction takes a pointer to a radix-64 representation, in which the first
885d0641a4SPeter Avalosdigit is the least significant, and returns a corresponding
895d0641a4SPeter Avalos.Vt long
905d0641a4SPeter Avalosvalue.
915d0641a4SPeter AvalosIf the string pointed to by
925d0641a4SPeter Avalos.Fa s
935d0641a4SPeter Avaloscontains more than six characters,
945d0641a4SPeter Avalos.Fn a64l
955d0641a4SPeter Avalosuses the first six.
965d0641a4SPeter AvalosIf the first six characters of the string contain a null terminator,
975d0641a4SPeter Avalos.Fn a64l
985d0641a4SPeter Avalosuses only characters preceding the null terminator.
995d0641a4SPeter AvalosThe
1005d0641a4SPeter Avalos.Fn a64l
1015d0641a4SPeter Avalosfunction scans the character string from left to right with the least
1025d0641a4SPeter Avalossignificant digit on the left, decoding each character as a 6-bit
1035d0641a4SPeter Avalosradix-64 number.
1045d0641a4SPeter AvalosIf the type long contains more than 32 bits, the resulting value is
1055d0641a4SPeter Avalossign-extended.
1065d0641a4SPeter AvalosThe behavior of
1075d0641a4SPeter Avalos.Fn a64l
1085d0641a4SPeter Avalosis unspecified if
1095d0641a4SPeter Avalos.Fa s
1105d0641a4SPeter Avalosis a null pointer or the string pointed to by
1115d0641a4SPeter Avalos.Fa s
1125d0641a4SPeter Avaloswas not generated by a previous call to
1135d0641a4SPeter Avalos.Fn l64a .
1145d0641a4SPeter Avalos.Pp
1155d0641a4SPeter AvalosThe
1165d0641a4SPeter Avalos.Fn l64a
1175d0641a4SPeter Avalosfunction takes a
1185d0641a4SPeter Avalos.Vt long
1195d0641a4SPeter Avalosargument and returns a pointer to the corresponding
1205d0641a4SPeter Avalosradix-64 representation.
1215d0641a4SPeter AvalosThe behavior of
1225d0641a4SPeter Avalos.Fn l64a
1235d0641a4SPeter Avalosis unspecified if value is negative.
1245d0641a4SPeter Avalos.Pp
1255d0641a4SPeter AvalosThe value returned by
1265d0641a4SPeter Avalos.Fn l64a
1275d0641a4SPeter Avalosis a pointer into a static buffer.
1285d0641a4SPeter AvalosSubsequent calls to
1295d0641a4SPeter Avalos.Fn l64a
1305d0641a4SPeter Avalosmay overwrite the buffer.
1315d0641a4SPeter Avalos.Pp
1325d0641a4SPeter AvalosThe
1335d0641a4SPeter Avalos.Fn l64a_r
1345d0641a4SPeter Avalosfunction performs a conversion identical to that of
1355d0641a4SPeter Avalos.Fn l64a
1365d0641a4SPeter Avalosand stores the resulting representation in the memory area pointed to by
1375d0641a4SPeter Avalos.Fa buffer ,
1385d0641a4SPeter Avalosconsuming at most
1395d0641a4SPeter Avalos.Fa buflen
1405d0641a4SPeter Avaloscharacters including the terminating
1415d0641a4SPeter Avalos.Dv NUL
1425d0641a4SPeter Avaloscharacter.
1435d0641a4SPeter Avalos.Sh RETURN VALUES
1445d0641a4SPeter AvalosOn successful completion,
1455d0641a4SPeter Avalos.Fn a64l
1465d0641a4SPeter Avalosreturns the
1475d0641a4SPeter Avalos.Vt long
1485d0641a4SPeter Avalosvalue resulting from conversion of the input string.
1495d0641a4SPeter AvalosIf a string pointed to by
1505d0641a4SPeter Avalos.Fa s
1515d0641a4SPeter Avalosis an empty string,
1525d0641a4SPeter Avalos.Fn a64l
1535d0641a4SPeter Avalosreturns 0.
1545d0641a4SPeter Avalos.Pp
1555d0641a4SPeter AvalosThe
1565d0641a4SPeter Avalos.Fn l64a
1575d0641a4SPeter Avalosfunction returns a pointer to the radix-64 representation.
1585d0641a4SPeter AvalosIf value is 0,
1595d0641a4SPeter Avalos.Fn l64a
1605d0641a4SPeter Avalosreturns a pointer to an empty string.
1615d0641a4SPeter Avalos.Sh SEE ALSO
1625d0641a4SPeter Avalos.Xr strtoul 3
1635d0641a4SPeter Avalos.Sh HISTORY
1645d0641a4SPeter AvalosThe
1655d0641a4SPeter Avalos.Fn a64l ,
1665d0641a4SPeter Avalos.Fn l64a ,
1675d0641a4SPeter Avalosand
1685d0641a4SPeter Avalos.Fn l64a_r
1695d0641a4SPeter Avalosfunctions are derived from
1705d0641a4SPeter Avalos.Nx
1715d0641a4SPeter Avaloswith modifications.
1725d0641a4SPeter AvalosThey appeared in
1735d0641a4SPeter Avalos.Fx 6.1 .
1745d0641a4SPeter Avalos.Sh AUTHORS
1755d0641a4SPeter AvalosThe
1765d0641a4SPeter Avalos.Fn a64l ,
1775d0641a4SPeter Avalos.Fn l64a ,
1785d0641a4SPeter Avalosand
1795d0641a4SPeter Avalos.Fn l64a_r
1805d0641a4SPeter Avalosfunctions
1815d0641a4SPeter Avaloswere added to
1825d0641a4SPeter Avalos.Fx
1835d0641a4SPeter Avalosby
184*98b3d9adSFranco Fichtner.An Tom Rhodes Aq Mt trhodes@FreeBSD.org .
1855d0641a4SPeter AvalosAlmost all of this manual page came from the
1865d0641a4SPeter Avalos.Tn POSIX
1875d0641a4SPeter Avalosstandard.
188