1.\" $NetBSD: a64l.3,v 1.6 2002/02/07 07:00:27 ross Exp $ 2.\" 3.\" Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Klaus Klein. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 3. All advertising materials mentioning features or use of this software 18.\" must display the following acknowledgement: 19.\" This product includes software developed by the NetBSD 20.\" Foundation, Inc. and its contributors. 21.\" 4. Neither the name of The NetBSD Foundation nor the names of its 22.\" contributors may be used to endorse or promote products derived 23.\" from this software without specific prior written permission. 24.\" 25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35.\" POSSIBILITY OF SUCH DAMAGE. 36.\" 37.Dd February 6, 1999 38.Dt A64L 3 39.Os 40.Sh NAME 41.Nm a64l , 42.Nm l64a , 43.Nm l64a_r 44.Nd "convert between a long integer and a base-64 ASCII string" 45.Sh LIBRARY 46.Lb libc 47.Sh SYNOPSIS 48.Fd #include \*[Lt]stdlib.h\*[Gt] 49.Ft long 50.Fn a64l "const char *s" 51.Ft char * 52.Fn l64a "long int l" 53.Ft int 54.Fn l64a_r "long int l" "char *buffer" "int buflen" 55.Sh DESCRIPTION 56The 57.Fn a64l 58and 59.Fn l64a 60functions convert between a long integer and its base-64 ASCII string 61representation. 62.Pp 63The characters used to represent ``digits'' are 64`.' for 0, 65`/' for 1, 66`0' - `9' for 2 - 11, 67`A' - `Z' for 12 - 37, and 68`a' - `z' for 38 - 63. 69.Pp 70.Fn a64l 71takes a pointer to a NUL-terminated base-64 ASCII string 72representation, 73.Fa s , 74and returns the corresponding long integer value. 75.Pp 76.Fn l64a 77takes a long integer value, 78.Fa l , 79and returns a pointer to the corresponding NUL-terminated base-64 80ASCII string representation. 81.Pp 82.Fn l64a_r 83performs a conversion identical to that of 84.Fn l64a 85and stores the resulting representation in the memory area pointed to by 86.Fa buffer , 87consuming at most 88.Fa buflen 89characters including the terminating NUL character. 90.Sh RETURN VALUES 91On successful completion, 92.Fn a64l 93returns the long integer value corresponding to the input string. 94If the string pointed to by 95.Fa s 96is an empty string, 97.Fn a64l 98returns a value of 0L. 99.Pp 100.Fn l64a 101returns a pointer to the base-64 ASCII string representation corresponding to 102the input value. 103If 104.Fa l 105is 0L, 106.Fn l64a 107returns a pointer to an empty string. 108.Pp 109On successful completion, 110.Fn l64a_r 111returns 0; if 112.Fa buffer 113is of insufficient length, -1 is returned. 114.Sh SEE ALSO 115.Xr strtol 3 116.Sh STANDARDS 117The 118.Fn a64l 119and 120.Fn l64a 121functions conform to 122.St -xpg4.2 . 123The 124.Fn l64a_r 125function conforms to 126.St -svid4 , 127Multithreading Extension. 128.Sh BUGS 129The 130.Fn l64a 131function is not reentrant. The value returned by it points into a 132static buffer area; subsequent calls to 133.Fn la64a 134may overwrite this buffer. 135In multi-threaded applications, 136.Fn l64a_r 137should be used instead. 138