diff options
Diffstat (limited to 'src/lib/libc/stdlib/a64l.3')
-rw-r--r-- | src/lib/libc/stdlib/a64l.3 | 125 |
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 | ||
46 | The | ||
47 | .Fn a64l | ||
48 | and | ||
49 | .Fn l64a | ||
50 | functions are used to maintain numbers stored in radix-64 | ||
51 | ASCII characters. This is a notation by which 32-bit integers | ||
52 | can be represented by up to six characters; each character | ||
53 | represents a "digit" in a radix-64 notation. | ||
54 | .Pp | ||
55 | The 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 | ||
59 | The | ||
60 | .Fn a64l | ||
61 | function takes a pointer to a null-terminated radix-64 representation | ||
62 | and returns a corresponding 32-bit value. If the string pointed to by | ||
63 | .Ar s | ||
64 | contains more than six characters, | ||
65 | .Fn a64l | ||
66 | will use the first six. | ||
67 | .Fn A64l | ||
68 | scans the character string from left to right, decoding | ||
69 | each character as a 6-bit radix-64 number. If a long integer is | ||
70 | larger than 32 bits, the return value will be sign-extended. | ||
71 | .Pp | ||
72 | .Fn l64a | ||
73 | takes a long integer argument | ||
74 | .Ar l | ||
75 | and returns a pointer to the corresponding radix-64 representation. | ||
76 | .Sh RETURN VALUES | ||
77 | On success, | ||
78 | .Fn a64l | ||
79 | returns a 32-bit representation of | ||
80 | .Ar s . | ||
81 | If | ||
82 | .Ar s | ||
83 | is a NULL pointer or if it contains "digits" other than those described above, | ||
84 | .Fn a64l | ||
85 | returns -1L and sets the global variable errno to | ||
86 | .Va EINVAL . | ||
87 | .Pp | ||
88 | On success, | ||
89 | .Fn l64a | ||
90 | returns a pointer to a string containing the radix-64 representation of | ||
91 | .Ar l . | ||
92 | If | ||
93 | .Ar l | ||
94 | is 0, | ||
95 | .Fn l64a | ||
96 | returns a pointer to the empty string. | ||
97 | If | ||
98 | .Ar l | ||
99 | is negative, | ||
100 | .Fn l64a | ||
101 | returns a NULL pointer and sets the global variable errno to | ||
102 | .Va EINVAL . | ||
103 | .Sh WARNINGS | ||
104 | The value returned by | ||
105 | .Fn l64a | ||
106 | is a pointer into a static buffer, the contents of which | ||
107 | will be overwritten by subsequent calls. | ||
108 | .Pp | ||
109 | The value returned by | ||
110 | .Fn a64l | ||
111 | may be incorrect if the value is too large; for that reason, only strings | ||
112 | that resulted from a call to | ||
113 | .Fn l64a | ||
114 | should be used to call | ||
115 | .Fn a64l . | ||
116 | .Pp | ||
117 | If a long integer is larger than 32 bits, only the low-order | ||
118 | 32 bits are used. | ||
119 | .Sh STANDARDS | ||
120 | The | ||
121 | .Fn a64l | ||
122 | and | ||
123 | .Fn l64a | ||
124 | functions conform to | ||
125 | .St -xpg4.2 . | ||