diff options
Diffstat (limited to 'src/lib/libc/stdlib/a64l.3')
-rw-r--r-- | src/lib/libc/stdlib/a64l.3 | 122 |
1 files changed, 122 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..4ec707adf1 --- /dev/null +++ b/src/lib/libc/stdlib/a64l.3 | |||
@@ -0,0 +1,122 @@ | |||
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. The name of the author may not be used to endorse or promote products | ||
14 | .\" derived from this software without specific prior written permission. | ||
15 | .\" | ||
16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
17 | .\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY | ||
18 | .\" AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | ||
19 | .\" THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
20 | .\" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
21 | .\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | ||
22 | .\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
23 | .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | ||
24 | .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
25 | .\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | .\" | ||
27 | .\" $OpenBSD: a64l.3,v 1.2 1998/06/21 22:13:48 millert Exp $ | ||
28 | .\" | ||
29 | .Dd August 17, 1997 | ||
30 | .Dt A64L 3 | ||
31 | .Os | ||
32 | .Sh NAME | ||
33 | .Nm a64l , | ||
34 | .Nm l64a | ||
35 | .Nd convert between 32-bit integer and radix-64 ASCII string | ||
36 | .Sh SYNOPSIS | ||
37 | .Fd #include <stdlib.h> | ||
38 | .Ft long | ||
39 | .Fn a64l "const char *s" | ||
40 | .Ft char * | ||
41 | .Fn l64a "long l" | ||
42 | .Sh DESCRIPTION | ||
43 | The | ||
44 | .Fn a64l | ||
45 | and | ||
46 | .Fn l64a | ||
47 | functions are used to maintain numbers stored in radix-64 | ||
48 | ASCII characters. This is a notation by which 32-bit integers | ||
49 | can be represented by up to six characters; each character | ||
50 | represents a "digit" in a radix-64 notation. | ||
51 | .Pp | ||
52 | The characters used to represent "digits" are '.' for 0, '/' for 1, | ||
53 | '0' through '9' for 2-11, 'A' through 'Z' for 12-37, and 'a' through | ||
54 | 'z' for 38-63. | ||
55 | .Pp | ||
56 | The | ||
57 | .Fn a64l | ||
58 | function takes a pointer to a null-terminated radix-64 representation | ||
59 | and returns a corresponding 32-bit value. If the string pointed to by | ||
60 | .Ar s | ||
61 | contains more than six characters, | ||
62 | .Fn a64l | ||
63 | will use the first six. | ||
64 | .Fn A64l | ||
65 | scans the character string from left to right, decoding | ||
66 | each character as a 6-bit radix-64 number. If a long integer is | ||
67 | larger than 32 bits, the return value will be sign-extended. | ||
68 | .Pp | ||
69 | .Fn l64a | ||
70 | takes a long integer argument | ||
71 | .Ar l | ||
72 | and returns a pointer to the corresponding radix-64 representation. | ||
73 | .Sh RETURN VALUES | ||
74 | On success, | ||
75 | .Fn a64l | ||
76 | returns a 32-bit representation of | ||
77 | .Ar s . | ||
78 | If | ||
79 | .Ar s | ||
80 | is a NULL pointer or if it contains "digits" other than those described above, | ||
81 | .Fn a64l | ||
82 | returns -1L and sets the global variable errno to | ||
83 | .Va EINVAL . | ||
84 | .Pp | ||
85 | On success, | ||
86 | .Fn l64a | ||
87 | returns a pointer to a string containing the radix-64 representation of | ||
88 | .Ar l . | ||
89 | If | ||
90 | .Ar l | ||
91 | is 0, | ||
92 | .Fn l64a | ||
93 | returns a pointer to the empty string. | ||
94 | If | ||
95 | .Ar l | ||
96 | is negative, | ||
97 | .Fn l64a | ||
98 | returns a NULL pointer and sets the global variable errno to | ||
99 | .Va EINVAL . | ||
100 | .Sh WARNINGS | ||
101 | The value returned by | ||
102 | .Fn l64a | ||
103 | is a pointer into a static buffer, the contents of which | ||
104 | will be overwritten by subsequent calls. | ||
105 | .Pp | ||
106 | The value returned by | ||
107 | .Fn a64l | ||
108 | may be incorrect if the value is too large; for that reason, only strings | ||
109 | that resulted from a call to | ||
110 | .Fn l64a | ||
111 | should be used to call | ||
112 | .Fn a64l . | ||
113 | .Pp | ||
114 | If a long integer is larger than 32 bits, only the low-order | ||
115 | 32 bits are used. | ||
116 | .Sh STANDARDS | ||
117 | The | ||
118 | .Fn a64l | ||
119 | and | ||
120 | .Fn l64a | ||
121 | functions conform to | ||
122 | .St -xpg4.2 . | ||