xref: /freebsd/lib/libc/stdlib/a64l.3 (revision 9d0e4617f38ea22b1a89d82cc6860aff62ab32e7)
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,
70257551c6STom Rhodes.Ql /\&
71257551c6STom Rhodesfor 1,
72257551c6STom Rhodes.Ql 0\&
73257551c6STom Rhodes.Fl
74257551c6STom Rhodes.Ql 9\&
75257551c6STom Rhodesfor 2
76257551c6STom Rhodes.Fl
77257551c6STom Rhodes11,
78257551c6STom Rhodes.Ql A\&
79257551c6STom Rhodes.Fl
80257551c6STom Rhodes.Ql Z\&
81257551c6STom Rhodesfor 12
82257551c6STom Rhodes.Fl
83257551c6STom Rhodes37, and
84257551c6STom Rhodes.Ql a\&
85257551c6STom Rhodes.Fl
86257551c6STom Rhodes.Ql z\&
87257551c6STom Rhodesfor 38
88257551c6STom Rhodes.Fl
89257551c6STom Rhodes63.
90257551c6STom Rhodes.Pp
91257551c6STom RhodesThe
92257551c6STom Rhodes.Fn a64l
93257551c6STom Rhodesfunction takes a pointer to a radix-64 representation, in which the first
94257551c6STom Rhodesdigit is the least significant, and returns a corresponding
95257551c6STom Rhodes.Ft long
96257551c6STom Rhodesvalue.
97257551c6STom RhodesIf the string pointed to by
98257551c6STom Rhodes.Fa s
99257551c6STom Rhodescontains more than six characters,
100257551c6STom Rhodes.Fn a64l
101257551c6STom Rhodesuses the first six.
102257551c6STom RhodesIf the first six characters of the string contain a null terminator,
103257551c6STom Rhodes.Fn a64l
104257551c6STom Rhodesuses only characters preceding the null terminator.
105257551c6STom RhodesThe
106257551c6STom Rhodes.Fn a64l
107257551c6STom Rhodesfunction scans the character string from left to right with the least
108257551c6STom Rhodessignificant digit on the left, decoding each character as a 6-bit
109257551c6STom Rhodesradix-64 number.
110257551c6STom RhodesIf the type long contains more than 32 bits, the resulting value is
111257551c6STom Rhodessign-extended.
112257551c6STom RhodesThe behavior of
113257551c6STom Rhodes.Fn a64l
114257551c6STom Rhodesis unspecified if
115257551c6STom Rhodes.Fa s
116257551c6STom Rhodesis a null pointer or the string pointed to by
117257551c6STom Rhodes.Fa s
118257551c6STom Rhodeswas not generated by a previous call to
119257551c6STom Rhodes.Fn l64a .
120257551c6STom Rhodes.Pp
121257551c6STom RhodesThe
122257551c6STom Rhodes.Fn l64a
123257551c6STom Rhodesfunction takes a long argument and returns a pointer to the corresponding
124257551c6STom Rhodesradix-64 representation.
125257551c6STom RhodesThe behavior of
126257551c6STom Rhodes.Fn l64a
127257551c6STom Rhodesis unspecified if value is negative.
128257551c6STom Rhodes.Pp
129257551c6STom RhodesThe value returned by
130257551c6STom Rhodes.Fn l64a
131257551c6STom Rhodesis a pointer into a static buffer.
132257551c6STom RhodesSubsequent calls to
133257551c6STom Rhodes.Fn l64a
134257551c6STom Rhodesmay overwrite the buffer.
135257551c6STom Rhodes.Pp
136257551c6STom RhodesThe
137257551c6STom Rhodes.Fn l64a_r
138257551c6STom Rhodesfunction performs a conversion identical to that of
139257551c6STom Rhodes.Fn l64a
140257551c6STom Rhodesand stores the resulting representation in the memory area pointed to by
141257551c6STom Rhodes.Fa buffer ,
142257551c6STom Rhodesconsuming at most
143257551c6STom Rhodes.Fa buflen
144257551c6STom Rhodescharacters including the terminating NUL character.
145257551c6STom Rhodes.Sh RETURN VALUES
146257551c6STom RhodesOn successful completion,
147257551c6STom Rhodes.Fn a64l
148257551c6STom Rhodesreturns the
149257551c6STom Rhodes.Ft long
150257551c6STom Rhodesvalue resulting from conversion of the input string.
151257551c6STom RhodesIf a string pointed to by s is an empty string,
152257551c6STom Rhodes.Fn a64l
153257551c6STom Rhodesreturns 0.
154257551c6STom Rhodes.Pp
155257551c6STom RhodesThe
156257551c6STom Rhodesl64a
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.
172257551c6STom RhodesThey were added to
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
180257551c6STom Rhodeswere added to
181257551c6STom Rhodes.Fx
182257551c6STom Rhodesby
183257551c6STom Rhodes.An Tom Rhodes Aq trhodes@FreeBSD.org .
184257551c6STom RhodesAlmost all of this manual page came from the
185257551c6STom Rhodes.Tn POSIX
186257551c6STom Rhodesstandard.
187