summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/a64l.3
blob: 97545e99231640776f536b177a2f875ca28c4608 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
.\" Copyright (c) 2005 Tom Rhodes
.\" 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 AUTHOR 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 AUTHOR 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.
.\"
.\" Portions of this text are reprinted and reproduced in electronic form
.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --
.\" Portable Operating System Interface (POSIX), The Open Group Base
.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of
.\" Electrical and Electronics Engineers, Inc and The Open Group.  In the
.\" event of any discrepancy between this version and the original IEEE and
.\" The Open Group Standard, the original IEEE and The Open Group Standard is
.\" the referee document.  The original Standard can be obtained online at
.\"	http://www.opengroup.org/unix/online.html.
.\"
.\" $FreeBSD$
.\"
.Dd November 20, 2005
.Dt A64L 3
.Os
.Sh NAME
.Nm a64l ,
.Nm l64a ,
.Nm l64a_r
.Nd "convert between a long integer and a base-64 ASCII string"
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In stdlib.h
.Ft long
.Fn a64l "const char *s"
.Ft char *
.Fn l64a "long int l"
.Ft int
.Fn l64a_r "long int l" "char *buffer" "int buflen"
.Sh DESCRIPTION
These functions are used to maintain numbers stored in radix-64
.Tn ASCII
characters.
This is a notation by which 32-bit integers can be represented by
up to six characters; each character represents a digit in
radix-64 notation.
If the type long contains more than 32 bits, only the low-order
32 bits are used for these operations.
.Pp
The characters used to represent
.Dq digits
are
.Ql .\&
for 0,
.Ql /\&
for 1,
.Ql 0\&
.Fl
.Ql 9\&
for 2
.Fl
11,
.Ql A\&
.Fl
.Ql Z\&
for 12
.Fl
37, and
.Ql a\&
.Fl
.Ql z\&
for 38
.Fl
63.
.Pp
The
.Fn a64l
function takes a pointer to a radix-64 representation, in which the first
digit is the least significant, and returns a corresponding
.Ft long
value.
If the string pointed to by
.Fa s
contains more than six characters,
.Fn a64l
uses the first six.
If the first six characters of the string contain a null terminator,
.Fn a64l
uses only characters preceding the null terminator.
The
.Fn a64l
function scans the character string from left to right with the least
significant digit on the left, decoding each character as a 6-bit
radix-64 number.
If the type long contains more than 32 bits, the resulting value is
sign-extended.
The behavior of
.Fn a64l
is unspecified if
.Fa s
is a null pointer or the string pointed to by
.Fa s
was not generated by a previous call to
.Fn l64a .
.Pp
The
.Fn l64a
function takes a long argument and returns a pointer to the corresponding
radix-64 representation.
The behavior of
.Fn l64a
is unspecified if value is negative.
.Pp
The value returned by
.Fn l64a
is a pointer into a static buffer.
Subsequent calls to
.Fn l64a
may overwrite the buffer.
.Pp
The
.Fn l64a_r
function performs a conversion identical to that of
.Fn l64a
and stores the resulting representation in the memory area pointed to by
.Fa buffer ,
consuming at most
.Fa buflen
characters including the terminating NUL character.
.Sh RETURN VALUES
On successful completion,
.Fn a64l
returns the
.Ft long
value resulting from conversion of the input string.
If a string pointed to by s is an empty string,
.Fn a64l
returns 0.
.Pp
The
l64a
function returns a pointer to the radix-64 representation.
If value is 0,
.Fn l64a
returns a pointer to an empty string.
.Sh SEE ALSO
.Xr stroul 3
.Sh HISTORY
The
.Fn a64l ,
.Fn l64a ,
and
.Fn l64a_r
functions are derived from
.Nx
with modifications.
They were added to
.Fx 6.1 .
.Sh AUTHORS
The
.Fn a64l ,
.Fn l64a ,
and
.Fn l64a_r
were added to
.Fx
by
.An Tom Rhodes Aq trhodes@FreeBSD.org .
Almost all of this manual page came from the
.Tn POSIX
standard.
OpenPOWER on IntegriCloud