diff options
Diffstat (limited to 'src/lib/libc/stdlib/a64l.3')
| -rw-r--r-- | src/lib/libc/stdlib/a64l.3 | 133 |
1 files changed, 133 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..f2957a7ad4 --- /dev/null +++ b/src/lib/libc/stdlib/a64l.3 | |||
| @@ -0,0 +1,133 @@ | |||
| 1 | .\" $OpenBSD: a64l.3,v 1.9 2005/02/25 03:12:44 cloder Exp $ | ||
| 2 | .\" | ||
| 3 | .\" Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com> | ||
| 4 | .\" | ||
| 5 | .\" Permission to use, copy, modify, and distribute this software for any | ||
| 6 | .\" purpose with or without fee is hereby granted, provided that the above | ||
| 7 | .\" copyright notice and this permission notice appear in all copies. | ||
| 8 | .\" | ||
| 9 | .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 10 | .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 11 | .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 12 | .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 13 | .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 14 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 15 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 16 | .\" | ||
| 17 | .Dd August 17, 1997 | ||
| 18 | .Dt A64L 3 | ||
| 19 | .Os | ||
| 20 | .Sh NAME | ||
| 21 | .Nm a64l , | ||
| 22 | .Nm l64a | ||
| 23 | .Nd convert between 32-bit integer and radix-64 ASCII string | ||
| 24 | .Sh SYNOPSIS | ||
| 25 | .Fd #include <stdlib.h> | ||
| 26 | .Ft long | ||
| 27 | .Fn a64l "const char *s" | ||
| 28 | .Ft char * | ||
| 29 | .Fn l64a "long l" | ||
| 30 | .Sh DESCRIPTION | ||
| 31 | The | ||
| 32 | .Fn a64l | ||
| 33 | and | ||
| 34 | .Fn l64a | ||
| 35 | functions are used to maintain numbers stored in radix-64 | ||
| 36 | .Tn ASCII | ||
| 37 | characters. | ||
| 38 | This is a notation by which 32-bit integers | ||
| 39 | can be represented by up to six characters; each character represents a | ||
| 40 | .Dq digit | ||
| 41 | in a radix-64 notation. | ||
| 42 | .Pp | ||
| 43 | The characters used to represent digits are | ||
| 44 | .Ql \&. | ||
| 45 | for 0, | ||
| 46 | .Ql / | ||
| 47 | for 1, | ||
| 48 | .Ql 0 | ||
| 49 | through | ||
| 50 | .Ql 9 | ||
| 51 | for 2-11, | ||
| 52 | .Ql A | ||
| 53 | through | ||
| 54 | .Ql Z | ||
| 55 | for 12-37, and | ||
| 56 | .Ql a | ||
| 57 | through | ||
| 58 | .Ql z | ||
| 59 | for 38-63. | ||
| 60 | .Pp | ||
| 61 | The | ||
| 62 | .Fn a64l | ||
| 63 | function takes a pointer to a NUL-terminated radix-64 representation | ||
| 64 | and returns a corresponding 32-bit value. | ||
| 65 | If the string pointed to by | ||
| 66 | .Fa s | ||
| 67 | contains more than six characters, | ||
| 68 | .Fn a64l | ||
| 69 | will use the first six. | ||
| 70 | .Fn a64l | ||
| 71 | scans the character string from left to right, decoding | ||
| 72 | each character as a 6-bit radix-64 number. | ||
| 73 | If a long integer is | ||
| 74 | larger than 32 bits, the return value will be sign-extended. | ||
| 75 | .Pp | ||
| 76 | .Fn l64a | ||
| 77 | takes a long integer argument | ||
| 78 | .Fa l | ||
| 79 | and returns a pointer to the corresponding radix-64 representation. | ||
| 80 | .Sh RETURN VALUES | ||
| 81 | On success, | ||
| 82 | .Fn a64l | ||
| 83 | returns a 32-bit representation of | ||
| 84 | .Fa s . | ||
| 85 | If | ||
| 86 | .Fa s | ||
| 87 | is a null pointer or if it contains digits other than those described above, | ||
| 88 | .Fn a64l | ||
| 89 | returns \-1 and sets the global variable | ||
| 90 | .Va errno | ||
| 91 | to | ||
| 92 | .Er EINVAL . | ||
| 93 | .Pp | ||
| 94 | On success, | ||
| 95 | .Fn l64a | ||
| 96 | returns a pointer to a string containing the radix-64 representation of | ||
| 97 | .Fa l . | ||
| 98 | If | ||
| 99 | .Fa l | ||
| 100 | is 0, | ||
| 101 | .Fn l64a | ||
| 102 | returns a pointer to the empty string. | ||
| 103 | If | ||
| 104 | .Fa l | ||
| 105 | is negative, | ||
| 106 | .Fn l64a | ||
| 107 | returns a null pointer and sets the global variable | ||
| 108 | .Va errno | ||
| 109 | to | ||
| 110 | .Er EINVAL . | ||
| 111 | .Sh WARNINGS | ||
| 112 | The value returned by | ||
| 113 | .Fn l64a | ||
| 114 | is a pointer into a static buffer, the contents of which | ||
| 115 | will be overwritten by subsequent calls. | ||
| 116 | .Pp | ||
| 117 | The value returned by | ||
| 118 | .Fn a64l | ||
| 119 | may be incorrect if the value is too large; for that reason, only strings | ||
| 120 | that resulted from a call to | ||
| 121 | .Fn l64a | ||
| 122 | should be used to call | ||
| 123 | .Fn a64l . | ||
| 124 | .Pp | ||
| 125 | If a long integer is larger than 32 bits, only the low-order | ||
| 126 | 32 bits are used. | ||
| 127 | .Sh STANDARDS | ||
| 128 | The | ||
| 129 | .Fn a64l | ||
| 130 | and | ||
| 131 | .Fn l64a | ||
| 132 | functions conform to | ||
| 133 | .St -xpg4.2 . | ||
