xref: /freebsd/lib/libc/stdlib/a64l.3 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
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.Dd November 20, 2005
36257551c6STom Rhodes.Dt A64L 3
37257551c6STom Rhodes.Os
38257551c6STom Rhodes.Sh NAME
39257551c6STom Rhodes.Nm a64l ,
40257551c6STom Rhodes.Nm l64a ,
41257551c6STom Rhodes.Nm l64a_r
42257551c6STom Rhodes.Nd "convert between a long integer and a base-64 ASCII string"
43257551c6STom Rhodes.Sh LIBRARY
44257551c6STom Rhodes.Lb libc
45257551c6STom Rhodes.Sh SYNOPSIS
46257551c6STom Rhodes.In stdlib.h
47257551c6STom Rhodes.Ft long
48257551c6STom Rhodes.Fn a64l "const char *s"
49257551c6STom Rhodes.Ft char *
50257551c6STom Rhodes.Fn l64a "long int l"
51257551c6STom Rhodes.Ft int
52257551c6STom Rhodes.Fn l64a_r "long int l" "char *buffer" "int buflen"
53257551c6STom Rhodes.Sh DESCRIPTION
54257551c6STom RhodesThese functions are used to maintain numbers stored in radix-64
55257551c6STom Rhodes.Tn ASCII
56257551c6STom Rhodescharacters.
57257551c6STom RhodesThis is a notation by which 32-bit integers can be represented by
58257551c6STom Rhodesup to six characters; each character represents a digit in
59257551c6STom Rhodesradix-64 notation.
60257551c6STom RhodesIf the type long contains more than 32 bits, only the low-order
61257551c6STom Rhodes32 bits are used for these operations.
62257551c6STom Rhodes.Pp
63257551c6STom RhodesThe characters used to represent
64257551c6STom Rhodes.Dq digits
65257551c6STom Rhodesare
66257551c6STom Rhodes.Ql .\&
67257551c6STom Rhodesfor 0,
68ad136d1eSRuslan Ermilov.Ql /
69257551c6STom Rhodesfor 1,
70ad136d1eSRuslan Ermilov.Ql 0
71ad136d1eSRuslan Ermilov-
72ad136d1eSRuslan Ermilov.Ql 9
73ad136d1eSRuslan Ermilovfor 2 - 11,
74ad136d1eSRuslan Ermilov.Ql A
75ad136d1eSRuslan Ermilov-
76ad136d1eSRuslan Ermilov.Ql Z
77ad136d1eSRuslan Ermilovfor 12 - 37, and
78ad136d1eSRuslan Ermilov.Ql a
79ad136d1eSRuslan Ermilov-
80ad136d1eSRuslan Ermilov.Ql z
81ad136d1eSRuslan Ermilovfor 38 - 63.
82257551c6STom Rhodes.Pp
83257551c6STom RhodesThe
84257551c6STom Rhodes.Fn a64l
85257551c6STom Rhodesfunction takes a pointer to a radix-64 representation, in which the first
86257551c6STom Rhodesdigit is the least significant, and returns a corresponding
87ad136d1eSRuslan Ermilov.Vt long
88257551c6STom Rhodesvalue.
89257551c6STom RhodesIf the string pointed to by
90257551c6STom Rhodes.Fa s
91257551c6STom Rhodescontains more than six characters,
92257551c6STom Rhodes.Fn a64l
93257551c6STom Rhodesuses the first six.
94257551c6STom RhodesIf the first six characters of the string contain a null terminator,
95257551c6STom Rhodes.Fn a64l
96257551c6STom Rhodesuses only characters preceding the null terminator.
97257551c6STom RhodesThe
98257551c6STom Rhodes.Fn a64l
99257551c6STom Rhodesfunction scans the character string from left to right with the least
100257551c6STom Rhodessignificant digit on the left, decoding each character as a 6-bit
101257551c6STom Rhodesradix-64 number.
102257551c6STom RhodesIf the type long contains more than 32 bits, the resulting value is
103257551c6STom Rhodessign-extended.
104257551c6STom RhodesThe behavior of
105257551c6STom Rhodes.Fn a64l
106257551c6STom Rhodesis unspecified if
107257551c6STom Rhodes.Fa s
108257551c6STom Rhodesis a null pointer or the string pointed to by
109257551c6STom Rhodes.Fa s
110257551c6STom Rhodeswas not generated by a previous call to
111257551c6STom Rhodes.Fn l64a .
112257551c6STom Rhodes.Pp
113257551c6STom RhodesThe
114257551c6STom Rhodes.Fn l64a
115ad136d1eSRuslan Ermilovfunction takes a
116ad136d1eSRuslan Ermilov.Vt long
117ad136d1eSRuslan Ermilovargument and returns a pointer to the corresponding
118257551c6STom Rhodesradix-64 representation.
119257551c6STom RhodesThe behavior of
120257551c6STom Rhodes.Fn l64a
121257551c6STom Rhodesis unspecified if value is negative.
122257551c6STom Rhodes.Pp
123257551c6STom RhodesThe value returned by
124257551c6STom Rhodes.Fn l64a
125257551c6STom Rhodesis a pointer into a static buffer.
126257551c6STom RhodesSubsequent calls to
127257551c6STom Rhodes.Fn l64a
128257551c6STom Rhodesmay overwrite the buffer.
129257551c6STom Rhodes.Pp
130257551c6STom RhodesThe
131257551c6STom Rhodes.Fn l64a_r
132257551c6STom Rhodesfunction performs a conversion identical to that of
133257551c6STom Rhodes.Fn l64a
134257551c6STom Rhodesand stores the resulting representation in the memory area pointed to by
135257551c6STom Rhodes.Fa buffer ,
136257551c6STom Rhodesconsuming at most
137257551c6STom Rhodes.Fa buflen
138ad136d1eSRuslan Ermilovcharacters including the terminating
139ad136d1eSRuslan Ermilov.Dv NUL
140ad136d1eSRuslan Ermilovcharacter.
141257551c6STom Rhodes.Sh RETURN VALUES
142257551c6STom RhodesOn successful completion,
143257551c6STom Rhodes.Fn a64l
144257551c6STom Rhodesreturns the
145ad136d1eSRuslan Ermilov.Vt long
146257551c6STom Rhodesvalue resulting from conversion of the input string.
147ad136d1eSRuslan ErmilovIf a string pointed to by
148ad136d1eSRuslan Ermilov.Fa s
149ad136d1eSRuslan Ermilovis an empty string,
150257551c6STom Rhodes.Fn a64l
151257551c6STom Rhodesreturns 0.
152257551c6STom Rhodes.Pp
153257551c6STom RhodesThe
154ad136d1eSRuslan Ermilov.Fn l64a
155257551c6STom Rhodesfunction returns a pointer to the radix-64 representation.
156257551c6STom RhodesIf value is 0,
157257551c6STom Rhodes.Fn l64a
158257551c6STom Rhodesreturns a pointer to an empty string.
159257551c6STom Rhodes.Sh SEE ALSO
1609d0e4617SWojciech A. Koszek.Xr strtoul 3
161257551c6STom Rhodes.Sh HISTORY
162257551c6STom RhodesThe
163257551c6STom Rhodes.Fn a64l ,
164257551c6STom Rhodes.Fn l64a ,
165257551c6STom Rhodesand
166257551c6STom Rhodes.Fn l64a_r
167257551c6STom Rhodesfunctions are derived from
168257551c6STom Rhodes.Nx
169257551c6STom Rhodeswith modifications.
170ad136d1eSRuslan ErmilovThey appeared in
171257551c6STom Rhodes.Fx 6.1 .
172257551c6STom Rhodes.Sh AUTHORS
173257551c6STom RhodesThe
174257551c6STom Rhodes.Fn a64l ,
175257551c6STom Rhodes.Fn l64a ,
176257551c6STom Rhodesand
177257551c6STom Rhodes.Fn l64a_r
178ad136d1eSRuslan Ermilovfunctions
179257551c6STom Rhodeswere added to
180257551c6STom Rhodes.Fx
181257551c6STom Rhodesby
182*8fbf3d50SBaptiste Daroussin.An Tom Rhodes Aq Mt trhodes@FreeBSD.org .
183257551c6STom RhodesAlmost all of this manual page came from the
184257551c6STom Rhodes.Tn POSIX
185257551c6STom Rhodesstandard.
186