summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/a64l.3
diff options
context:
space:
mode:
authormillert <>1997-08-17 22:58:34 +0000
committermillert <>1997-08-17 22:58:34 +0000
commit8a261abefde3eb7c4a3ecb94acbb4b500b8cd1aa (patch)
tree212dd7f0f17b38e109915044266255b50045cbfd /src/lib/libc/stdlib/a64l.3
parentcba49e2afc06b0931ffbc483c4bb576c342c3384 (diff)
downloadopenbsd-8a261abefde3eb7c4a3ecb94acbb4b500b8cd1aa.tar.gz
openbsd-8a261abefde3eb7c4a3ecb94acbb4b500b8cd1aa.tar.bz2
openbsd-8a261abefde3eb7c4a3ecb94acbb4b500b8cd1aa.zip
Man page for a64l(3) and l64a(3), based on a64l.3 from the MiNT docs 0.1.
Also make a64l(3) and l64a(3) deal reasonably with inapropriate input. The standard does not require this, but it does not disallow it either.
Diffstat (limited to 'src/lib/libc/stdlib/a64l.3')
-rw-r--r--src/lib/libc/stdlib/a64l.3125
1 files changed, 125 insertions, 0 deletions
diff --git a/src/lib/libc/stdlib/a64l.3 b/src/lib/libc/stdlib/a64l.3
new file mode 100644
index 0000000000..5093edb51f
--- /dev/null
+++ b/src/lib/libc/stdlib/a64l.3
@@ -0,0 +1,125 @@
1.\"
2.\" Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\" notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\" notice, this list of conditions and the following disclaimer in the
12.\" documentation and/or other materials provided with the distribution.
13.\" 3. All advertising materials mentioning features or use of this software
14.\" must display the following acknowledgement:
15.\" This product includes software developed by Todd C. Miller.
16.\" 4. The name of the author may not be used to endorse or promote products
17.\" derived from this software without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21.\" AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22.\" THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23.\" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24.\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25.\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29.\"
30.\" $OpenBSD: a64l.3,v 1.1 1997/08/17 22:58:33 millert Exp $
31.\"
32.Dd August 17, 1997
33.Dt A64L 3
34.Os
35.Sh NAME
36.Nm a64l ,
37.Nm l64a
38.Nd convert between 32-bit integer and radix-64 ASCII string
39.Sh SYNOPSIS
40.Fd #include <stdlib.h>
41.Ft long
42.Fn a64l "const char *s"
43.Ft char *
44.Fn l64a "long l"
45.Sh DESCRIPTION
46The
47.Fn a64l
48and
49.Fn l64a
50functions are used to maintain numbers stored in radix-64
51ASCII characters. This is a notation by which 32-bit integers
52can be represented by up to six characters; each character
53represents a "digit" in a radix-64 notation.
54.Pp
55The characters used to represent "digits" are '.' for 0, '/' for 1,
56'0' through '9' for 2-11, 'A' through 'Z' for 12-37, and 'a' through
57'z' for 38-63.
58.Pp
59The
60.Fn a64l
61function takes a pointer to a null-terminated radix-64 representation
62and returns a corresponding 32-bit value. If the string pointed to by
63.Ar s
64contains more than six characters,
65.Fn a64l
66will use the first six.
67.Fn A64l
68scans the character string from left to right, decoding
69each character as a 6-bit radix-64 number. If a long integer is
70larger than 32 bits, the return value will be sign-extended.
71.Pp
72.Fn l64a
73takes a long integer argument
74.Ar l
75and returns a pointer to the corresponding radix-64 representation.
76.Sh RETURN VALUES
77On success,
78.Fn a64l
79returns a 32-bit representation of
80.Ar s .
81If
82.Ar s
83is a NULL pointer or if it contains "digits" other than those described above,
84.Fn a64l
85returns -1L and sets the global variable errno to
86.Va EINVAL .
87.Pp
88On success,
89.Fn l64a
90returns a pointer to a string containing the radix-64 representation of
91.Ar l .
92If
93.Ar l
94is 0,
95.Fn l64a
96returns a pointer to the empty string.
97If
98.Ar l
99is negative,
100.Fn l64a
101returns a NULL pointer and sets the global variable errno to
102.Va EINVAL .
103.Sh WARNINGS
104The value returned by
105.Fn l64a
106is a pointer into a static buffer, the contents of which
107will be overwritten by subsequent calls.
108.Pp
109The value returned by
110.Fn a64l
111may be incorrect if the value is too large; for that reason, only strings
112that resulted from a call to
113.Fn l64a
114should be used to call
115.Fn a64l .
116.Pp
117If a long integer is larger than 32 bits, only the low-order
11832 bits are used.
119.Sh STANDARDS
120The
121.Fn a64l
122and
123.Fn l64a
124functions conform to
125.St -xpg4.2 .