xref: /freebsd/lib/libc/stdlib/a64l.3 (revision 8fbf3d50e331929dfa82912749a2a5ce240d475b)
1257551c6STom Rhodes.\" Copyright (c) 2005 Tom Rhodes
2257551c6STom Rhodes.\" All rights reserved.
3257551c6STom Rhodes.\"
4257551c6STom Rhodes.\" Redistribution and use in source and binary forms, with or without
5257551c6STom Rhodes.\" modification, are permitted provided that the following conditions
6257551c6STom Rhodes.\" are met:
7257551c6STom Rhodes.\" 1. Redistributions of source code must retain the above copyright
8257551c6STom Rhodes.\"    notice, this list of conditions and the following disclaimer.
9257551c6STom Rhodes.\" 2. Redistributions in binary form must reproduce the above copyright
10257551c6STom Rhodes.\"    notice, this list of conditions and the following disclaimer in the
11257551c6STom Rhodes.\"    documentation and/or other materials provided with the distribution.
12257551c6STom Rhodes.\"
13257551c6STom Rhodes.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14257551c6STom Rhodes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15257551c6STom Rhodes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16257551c6STom Rhodes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17257551c6STom Rhodes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18257551c6STom Rhodes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19257551c6STom Rhodes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20257551c6STom Rhodes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21257551c6STom Rhodes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22257551c6STom Rhodes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23257551c6STom Rhodes.\" SUCH DAMAGE.
24257551c6STom Rhodes.\"
25257551c6STom Rhodes.\" Portions of this text are reprinted and reproduced in electronic form
26257551c6STom Rhodes.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --
27257551c6STom Rhodes.\" Portable Operating System Interface (POSIX), The Open Group Base
28257551c6STom Rhodes.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of
29257551c6STom Rhodes.\" Electrical and Electronics Engineers, Inc and The Open Group.  In the
30257551c6STom Rhodes.\" event of any discrepancy between this version and the original IEEE and
31257551c6STom Rhodes.\" The Open Group Standard, the original IEEE and The Open Group Standard is
32257551c6STom Rhodes.\" the referee document.  The original Standard can be obtained online at
33257551c6STom Rhodes.\"	http://www.opengroup.org/unix/online.html.
34257551c6STom Rhodes.\"
35257551c6STom Rhodes.\" $FreeBSD$
36257551c6STom Rhodes.\"
37257551c6STom Rhodes.Dd November 20, 2005
38257551c6STom Rhodes.Dt A64L 3
39257551c6STom Rhodes.Os
40257551c6STom Rhodes.Sh NAME
41257551c6STom Rhodes.Nm a64l ,
42257551c6STom Rhodes.Nm l64a ,
43257551c6STom Rhodes.Nm l64a_r
44257551c6STom Rhodes.Nd "convert between a long integer and a base-64 ASCII string"
45257551c6STom Rhodes.Sh LIBRARY
46257551c6STom Rhodes.Lb libc
47257551c6STom Rhodes.Sh SYNOPSIS
48257551c6STom Rhodes.In stdlib.h
49257551c6STom Rhodes.Ft long
50257551c6STom Rhodes.Fn a64l "const char *s"
51257551c6STom Rhodes.Ft char *
52257551c6STom Rhodes.Fn l64a "long int l"
53257551c6STom Rhodes.Ft int
54257551c6STom Rhodes.Fn l64a_r "long int l" "char *buffer" "int buflen"
55257551c6STom Rhodes.Sh DESCRIPTION
56257551c6STom RhodesThese functions are used to maintain numbers stored in radix-64
57257551c6STom Rhodes.Tn ASCII
58257551c6STom Rhodescharacters.
59257551c6STom RhodesThis is a notation by which 32-bit integers can be represented by
60257551c6STom Rhodesup to six characters; each character represents a digit in
61257551c6STom Rhodesradix-64 notation.
62257551c6STom RhodesIf the type long contains more than 32 bits, only the low-order
63257551c6STom Rhodes32 bits are used for these operations.
64257551c6STom Rhodes.Pp
65257551c6STom RhodesThe characters used to represent
66257551c6STom Rhodes.Dq digits
67257551c6STom Rhodesare
68257551c6STom Rhodes.Ql .\&
69257551c6STom Rhodesfor 0,
70ad136d1eSRuslan Ermilov.Ql /
71257551c6STom Rhodesfor 1,
72ad136d1eSRuslan Ermilov.Ql 0
73ad136d1eSRuslan Ermilov-
74ad136d1eSRuslan Ermilov.Ql 9
75ad136d1eSRuslan Ermilovfor 2 - 11,
76ad136d1eSRuslan Ermilov.Ql A
77ad136d1eSRuslan Ermilov-
78ad136d1eSRuslan Ermilov.Ql Z
79ad136d1eSRuslan Ermilovfor 12 - 37, and
80ad136d1eSRuslan Ermilov.Ql a
81ad136d1eSRuslan Ermilov-
82ad136d1eSRuslan Ermilov.Ql z
83ad136d1eSRuslan Ermilovfor 38 - 63.
84257551c6STom Rhodes.Pp
85257551c6STom RhodesThe
86257551c6STom Rhodes.Fn a64l
87257551c6STom Rhodesfunction takes a pointer to a radix-64 representation, in which the first
88257551c6STom Rhodesdigit is the least significant, and returns a corresponding
89ad136d1eSRuslan Ermilov.Vt long
90257551c6STom Rhodesvalue.
91257551c6STom RhodesIf the string pointed to by
92257551c6STom Rhodes.Fa s
93257551c6STom Rhodescontains more than six characters,
94257551c6STom Rhodes.Fn a64l
95257551c6STom Rhodesuses the first six.
96257551c6STom RhodesIf the first six characters of the string contain a null terminator,
97257551c6STom Rhodes.Fn a64l
98257551c6STom Rhodesuses only characters preceding the null terminator.
99257551c6STom RhodesThe
100257551c6STom Rhodes.Fn a64l
101257551c6STom Rhodesfunction scans the character string from left to right with the least
102257551c6STom Rhodessignificant digit on the left, decoding each character as a 6-bit
103257551c6STom Rhodesradix-64 number.
104257551c6STom RhodesIf the type long contains more than 32 bits, the resulting value is
105257551c6STom Rhodessign-extended.
106257551c6STom RhodesThe behavior of
107257551c6STom Rhodes.Fn a64l
108257551c6STom Rhodesis unspecified if
109257551c6STom Rhodes.Fa s
110257551c6STom Rhodesis a null pointer or the string pointed to by
111257551c6STom Rhodes.Fa s
112257551c6STom Rhodeswas not generated by a previous call to
113257551c6STom Rhodes.Fn l64a .
114257551c6STom Rhodes.Pp
115257551c6STom RhodesThe
116257551c6STom Rhodes.Fn l64a
117ad136d1eSRuslan Ermilovfunction takes a
118ad136d1eSRuslan Ermilov.Vt long
119ad136d1eSRuslan Ermilovargument and returns a pointer to the corresponding
120257551c6STom Rhodesradix-64 representation.
121257551c6STom RhodesThe behavior of
122257551c6STom Rhodes.Fn l64a
123257551c6STom Rhodesis unspecified if value is negative.
124257551c6STom Rhodes.Pp
125257551c6STom RhodesThe value returned by
126257551c6STom Rhodes.Fn l64a
127257551c6STom Rhodesis a pointer into a static buffer.
128257551c6STom RhodesSubsequent calls to
129257551c6STom Rhodes.Fn l64a
130257551c6STom Rhodesmay overwrite the buffer.
131257551c6STom Rhodes.Pp
132257551c6STom RhodesThe
133257551c6STom Rhodes.Fn l64a_r
134257551c6STom Rhodesfunction performs a conversion identical to that of
135257551c6STom Rhodes.Fn l64a
136257551c6STom Rhodesand stores the resulting representation in the memory area pointed to by
137257551c6STom Rhodes.Fa buffer ,
138257551c6STom Rhodesconsuming at most
139257551c6STom Rhodes.Fa buflen
140ad136d1eSRuslan Ermilovcharacters including the terminating
141ad136d1eSRuslan Ermilov.Dv NUL
142ad136d1eSRuslan Ermilovcharacter.
143257551c6STom Rhodes.Sh RETURN VALUES
144257551c6STom RhodesOn successful completion,
145257551c6STom Rhodes.Fn a64l
146257551c6STom Rhodesreturns the
147ad136d1eSRuslan Ermilov.Vt long
148257551c6STom Rhodesvalue resulting from conversion of the input string.
149ad136d1eSRuslan ErmilovIf a string pointed to by
150ad136d1eSRuslan Ermilov.Fa s
151ad136d1eSRuslan Ermilovis an empty string,
152257551c6STom Rhodes.Fn a64l
153257551c6STom Rhodesreturns 0.
154257551c6STom Rhodes.Pp
155257551c6STom RhodesThe
156ad136d1eSRuslan Ermilov.Fn l64a
157257551c6STom Rhodesfunction returns a pointer to the radix-64 representation.
158257551c6STom RhodesIf value is 0,
159257551c6STom Rhodes.Fn l64a
160257551c6STom Rhodesreturns a pointer to an empty string.
161257551c6STom Rhodes.Sh SEE ALSO
1629d0e4617SWojciech A. Koszek.Xr strtoul 3
163257551c6STom Rhodes.Sh HISTORY
164257551c6STom RhodesThe
165257551c6STom Rhodes.Fn a64l ,
166257551c6STom Rhodes.Fn l64a ,
167257551c6STom Rhodesand
168257551c6STom Rhodes.Fn l64a_r
169257551c6STom Rhodesfunctions are derived from
170257551c6STom Rhodes.Nx
171257551c6STom Rhodeswith modifications.
172ad136d1eSRuslan ErmilovThey appeared in
173257551c6STom Rhodes.Fx 6.1 .
174257551c6STom Rhodes.Sh AUTHORS
175257551c6STom RhodesThe
176257551c6STom Rhodes.Fn a64l ,
177257551c6STom Rhodes.Fn l64a ,
178257551c6STom Rhodesand
179257551c6STom Rhodes.Fn l64a_r
180ad136d1eSRuslan Ermilovfunctions
181257551c6STom Rhodeswere added to
182257551c6STom Rhodes.Fx
183257551c6STom Rhodesby
184*8fbf3d50SBaptiste Daroussin.An Tom Rhodes Aq Mt trhodes@FreeBSD.org .
185257551c6STom RhodesAlmost all of this manual page came from the
186257551c6STom Rhodes.Tn POSIX
187257551c6STom Rhodesstandard.
188